Browse Source

Span<T> on IPixel API surface.

pull/213/head
Anton Firszov 9 years ago
parent
commit
ceec035e03
  1. 4
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  2. 24
      src/ImageSharp/Image/PixelAccessor{TPixel}.cs
  3. 8
      src/ImageSharp/PixelFormats/Alpha8.cs
  4. 9
      src/ImageSharp/PixelFormats/Argb32.cs
  5. 8
      src/ImageSharp/PixelFormats/Bgr565.cs
  6. 8
      src/ImageSharp/PixelFormats/Bgra4444.cs
  7. 8
      src/ImageSharp/PixelFormats/Bgra5551.cs
  8. 8
      src/ImageSharp/PixelFormats/Byte4.cs
  9. 9
      src/ImageSharp/PixelFormats/HalfSingle.cs
  10. 9
      src/ImageSharp/PixelFormats/HalfVector2.cs
  11. 9
      src/ImageSharp/PixelFormats/HalfVector4.cs
  12. 8
      src/ImageSharp/PixelFormats/IPixel.cs
  13. 8
      src/ImageSharp/PixelFormats/NormalizedByte2.cs
  14. 8
      src/ImageSharp/PixelFormats/NormalizedByte4.cs
  15. 9
      src/ImageSharp/PixelFormats/NormalizedShort2.cs
  16. 9
      src/ImageSharp/PixelFormats/NormalizedShort4.cs
  17. 42
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
  18. 8
      src/ImageSharp/PixelFormats/Rg32.cs
  19. 8
      src/ImageSharp/PixelFormats/Rgba1010102.cs
  20. 16
      src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs
  21. 9
      src/ImageSharp/PixelFormats/Rgba32.cs
  22. 8
      src/ImageSharp/PixelFormats/Rgba64.cs
  23. 9
      src/ImageSharp/PixelFormats/RgbaVector.cs
  24. 8
      src/ImageSharp/PixelFormats/Short2.cs
  25. 8
      src/ImageSharp/PixelFormats/Short4.cs
  26. 4
      tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs
  27. 4
      tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs
  28. 8
      tests/ImageSharp.Tests/Colors/PixelOperationsTests.cs

4
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -346,11 +346,11 @@ namespace ImageSharp.Formats
if (this.bytesPerPixel == 4)
{
PixelOperations<TPixel>.Instance.ToXyzwBytes(rowSpan, this.rawScanline, 0, this.width);
PixelOperations<TPixel>.Instance.ToXyzwBytes(rowSpan, this.rawScanline, this.width);
}
else
{
PixelOperations<TPixel>.Instance.ToXyzBytes(rowSpan, this.rawScanline, 0, this.width);
PixelOperations<TPixel>.Instance.ToXyzBytes(rowSpan, this.rawScanline, this.width);
}
}

24
src/ImageSharp/Image/PixelAccessor{TPixel}.cs

@ -348,10 +348,8 @@ namespace ImageSharp
for (int y = 0; y < height; y++)
{
Span<TPixel> source = this.GetRowSpan(sourceX, sourceY + y);
using (Buffer<byte> destination = new Buffer<byte>(area.Bytes))
{
Operations.ToZyxBytes(source, destination, y * area.RowStride, width);
}
Span<byte> destination = area.GetRowSpan(y);
Operations.ToZyxBytes(source, destination, width);
}
}
@ -369,10 +367,8 @@ namespace ImageSharp
for (int y = 0; y < height; y++)
{
Span<TPixel> source = this.GetRowSpan(sourceX, sourceY + y);
using (Buffer<byte> destination = new Buffer<byte>(area.Bytes))
{
Operations.ToZyxwBytes(source, destination, y * area.RowStride, width);
}
Span<byte> destination = area.GetRowSpan(y);
Operations.ToZyxwBytes(source, destination, width);
}
}
@ -390,10 +386,8 @@ namespace ImageSharp
for (int y = 0; y < height; y++)
{
Span<TPixel> source = this.GetRowSpan(sourceX, sourceY + y);
using (Buffer<byte> destination = new Buffer<byte>(area.Bytes))
{
Operations.ToXyzBytes(source, destination, y * area.RowStride, width);
}
Span<byte> destination = area.GetRowSpan(y);
Operations.ToXyzBytes(source, destination, width);
}
}
@ -411,10 +405,8 @@ namespace ImageSharp
for (int y = 0; y < height; y++)
{
Span<TPixel> source = this.GetRowSpan(sourceX, sourceY + y);
using (Buffer<byte> destination = new Buffer<byte>(area.Bytes))
{
Operations.ToXyzwBytes(source, destination, y * area.RowStride, width);
}
Span<byte> destination = area.GetRowSpan(y);
Operations.ToXyzwBytes(source, destination, width);
}
}

8
src/ImageSharp/PixelFormats/Alpha8.cs

@ -87,7 +87,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
bytes[startIndex] = 0;
bytes[startIndex + 1] = 0;
@ -96,7 +96,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
bytes[startIndex] = 0;
bytes[startIndex + 1] = 0;
@ -106,7 +106,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
bytes[startIndex] = 0;
bytes[startIndex + 1] = 0;
@ -115,7 +115,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
bytes[startIndex] = 0;
bytes[startIndex + 1] = 0;

9
src/ImageSharp/PixelFormats/Argb32.cs

@ -5,6 +5,7 @@
namespace ImageSharp.PixelFormats
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
@ -241,7 +242,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
bytes[startIndex] = this.R;
bytes[startIndex + 1] = this.G;
@ -250,7 +251,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
bytes[startIndex] = this.R;
bytes[startIndex + 1] = this.G;
@ -260,7 +261,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
bytes[startIndex] = this.B;
bytes[startIndex + 1] = this.G;
@ -269,7 +270,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
bytes[startIndex] = this.B;
bytes[startIndex + 1] = this.G;

8
src/ImageSharp/PixelFormats/Bgr565.cs

@ -110,7 +110,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
bytes[startIndex] = (byte)MathF.Round(vector.X);
@ -120,7 +120,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
bytes[startIndex] = (byte)MathF.Round(vector.X);
@ -131,7 +131,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
bytes[startIndex] = (byte)MathF.Round(vector.Z);
@ -141,7 +141,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
bytes[startIndex] = (byte)MathF.Round(vector.Z);

8
src/ImageSharp/PixelFormats/Bgra4444.cs

@ -101,7 +101,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
bytes[startIndex] = (byte)vector.X;
@ -111,7 +111,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
bytes[startIndex] = (byte)vector.X;
@ -122,7 +122,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
bytes[startIndex] = (byte)vector.Z;
@ -132,7 +132,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
bytes[startIndex] = (byte)vector.Z;

8
src/ImageSharp/PixelFormats/Bgra5551.cs

@ -101,7 +101,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
bytes[startIndex] = (byte)vector.X;
@ -111,7 +111,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
bytes[startIndex] = (byte)vector.X;
@ -122,7 +122,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
bytes[startIndex] = (byte)vector.Z;
@ -132,7 +132,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
bytes[startIndex] = (byte)vector.Z;

8
src/ImageSharp/PixelFormats/Byte4.cs

@ -102,7 +102,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
bytes[startIndex] = (byte)vector.X;
@ -112,7 +112,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
bytes[startIndex] = (byte)vector.X;
@ -123,7 +123,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
bytes[startIndex] = (byte)vector.Z;
@ -133,7 +133,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
bytes[startIndex] = (byte)vector.Z;

9
src/ImageSharp/PixelFormats/HalfSingle.cs

@ -5,6 +5,7 @@
namespace ImageSharp.PixelFormats
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
@ -110,7 +111,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= MaxBytes;
@ -124,7 +125,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= MaxBytes;
@ -139,7 +140,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= MaxBytes;
@ -153,7 +154,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= MaxBytes;

9
src/ImageSharp/PixelFormats/HalfVector2.cs

@ -5,6 +5,7 @@
namespace ImageSharp.PixelFormats
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
@ -124,7 +125,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= MaxBytes;
@ -138,7 +139,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= MaxBytes;
@ -153,7 +154,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= MaxBytes;
@ -167,7 +168,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= MaxBytes;

9
src/ImageSharp/PixelFormats/HalfVector4.cs

@ -5,6 +5,7 @@
namespace ImageSharp.PixelFormats
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
@ -117,7 +118,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= MaxBytes;
@ -131,7 +132,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= MaxBytes;
@ -146,7 +147,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= MaxBytes;
@ -160,7 +161,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= MaxBytes;

8
src/ImageSharp/PixelFormats/IPixel.cs

@ -56,7 +56,7 @@ namespace ImageSharp.PixelFormats
/// </summary>
/// <param name="bytes">The bytes to set the color in.</param>
/// <param name="startIndex">The starting index of the <paramref name="bytes"/>.</param>
void ToXyzBytes(byte[] bytes, int startIndex);
void ToXyzBytes(Span<byte> bytes, int startIndex);
/// <summary>
/// Expands the packed representation into a given byte array.
@ -64,7 +64,7 @@ namespace ImageSharp.PixelFormats
/// </summary>
/// <param name="bytes">The bytes to set the color in.</param>
/// <param name="startIndex">The starting index of the <paramref name="bytes"/>.</param>
void ToXyzwBytes(byte[] bytes, int startIndex);
void ToXyzwBytes(Span<byte> bytes, int startIndex);
/// <summary>
/// Expands the packed representation into a given byte array.
@ -72,7 +72,7 @@ namespace ImageSharp.PixelFormats
/// </summary>
/// <param name="bytes">The bytes to set the color in.</param>
/// <param name="startIndex">The starting index of the <paramref name="bytes"/>.</param>
void ToZyxBytes(byte[] bytes, int startIndex);
void ToZyxBytes(Span<byte> bytes, int startIndex);
/// <summary>
/// Expands the packed representation into a given byte array.
@ -80,6 +80,6 @@ namespace ImageSharp.PixelFormats
/// </summary>
/// <param name="bytes">The bytes to set the color in.</param>
/// <param name="startIndex">The starting index of the <paramref name="bytes"/>.</param>
void ToZyxwBytes(byte[] bytes, int startIndex);
void ToZyxwBytes(Span<byte> bytes, int startIndex);
}
}

8
src/ImageSharp/PixelFormats/NormalizedByte2.cs

@ -134,7 +134,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;
@ -150,7 +150,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;
@ -167,7 +167,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;
@ -183,7 +183,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;

8
src/ImageSharp/PixelFormats/NormalizedByte4.cs

@ -127,7 +127,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;
@ -143,7 +143,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;
@ -160,7 +160,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;
@ -176,7 +176,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;

9
src/ImageSharp/PixelFormats/NormalizedShort2.cs

@ -5,6 +5,7 @@
namespace ImageSharp.PixelFormats
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
@ -120,7 +121,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;
@ -136,7 +137,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;
@ -153,7 +154,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;
@ -169,7 +170,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;

9
src/ImageSharp/PixelFormats/NormalizedShort4.cs

@ -5,6 +5,7 @@
namespace ImageSharp.PixelFormats
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
@ -128,7 +129,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;
@ -144,7 +145,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;
@ -161,7 +162,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;
@ -177,7 +178,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector *= Half;

42
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs

@ -9,8 +9,6 @@ namespace ImageSharp.PixelFormats
using System.Numerics;
using System.Runtime.CompilerServices;
using ImageSharp.Memory;
/// <summary>
/// A stateless class implementing Strategy Pattern for batched pixel-data conversion operations
/// for pixel buffers of type <typeparamref name="TPixel"/>.
@ -86,21 +84,19 @@ namespace ImageSharp.PixelFormats
}
/// <summary>
/// Bulk version of <see cref="IPixel.ToXyzBytes(byte[], int)"/>.
/// Bulk version of <see cref="IPixel.ToXyzBytes(Span{byte}, int)"/>.
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Buffer{T}"/> to the destination bytes.</param>
/// <param name="startIndex">The starting index of the <paramref name="destBytes"/>.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void ToXyzBytes(Span<TPixel> sourceColors, Buffer<byte> destBytes, int startIndex, int count)
internal virtual void ToXyzBytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
{
ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference();
byte[] dest = destBytes.Array;
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceRef, i);
sp.ToXyzBytes(dest, startIndex + (i * 3));
sp.ToXyzBytes(destBytes, i * 3);
}
}
@ -128,21 +124,19 @@ namespace ImageSharp.PixelFormats
}
/// <summary>
/// Bulk version of <see cref="IPixel.ToXyzwBytes(byte[], int)"/>.
/// Bulk version of <see cref="IPixel.ToXyzwBytes(Span{byte}, int)"/>
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Buffer{T}"/> to the destination bytes.</param>
/// <param name="startIndex">The starting index of the <paramref name="destBytes"/>.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void ToXyzwBytes(Span<TPixel> sourceColors, Buffer<byte> destBytes, int startIndex, int count)
internal virtual void ToXyzwBytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
{
ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference();
byte[] dest = destBytes.Array;
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceRef, i);
sp.ToXyzwBytes(dest, startIndex + (i * 4));
sp.ToXyzwBytes(destBytes, i * 4);
}
}
@ -170,21 +164,19 @@ namespace ImageSharp.PixelFormats
}
/// <summary>
/// Bulk version of <see cref="IPixel.ToZyxBytes(byte[], int)"/>.
/// Bulk version of <see cref="IPixel.ToZyxBytes(Span{byte}, int)"/>.
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Buffer{T}"/> to the destination bytes.</param>
/// <param name="startIndex">The starting index of the <paramref name="destBytes"/>.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void ToZyxBytes(Span<TPixel> sourceColors, Buffer<byte> destBytes, int startIndex, int count)
internal virtual void ToZyxBytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
{
ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference();
byte[] dest = destBytes.Array;
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceRef, i);
sp.ToZyxBytes(dest, startIndex + (i * 3));
sp.ToZyxBytes(destBytes, i * 3);
}
}
@ -212,21 +204,19 @@ namespace ImageSharp.PixelFormats
}
/// <summary>
/// Bulk version of <see cref="IPixel.ToZyxwBytes(byte[], int)"/>.
/// Bulk version of <see cref="IPixel.ToZyxwBytes(Span{byte}, int)"/>.
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Buffer{T}"/> to the destination bytes.</param>
/// <param name="startIndex">The starting index of the <paramref name="destBytes"/>.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void ToZyxwBytes(Span<TPixel> sourceColors, Buffer<byte> destBytes, int startIndex, int count)
internal virtual void ToZyxwBytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
{
ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference();
byte[] dest = destBytes.Array;
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceRef, i);
sp.ToZyxwBytes(dest, startIndex + (i * 4));
sp.ToZyxwBytes(destBytes, i * 4);
}
}
}

8
src/ImageSharp/PixelFormats/Rg32.cs

@ -114,7 +114,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
@ -125,7 +125,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
@ -137,7 +137,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
@ -148,7 +148,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;

8
src/ImageSharp/PixelFormats/Rgba1010102.cs

@ -108,7 +108,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
@ -119,7 +119,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
@ -131,7 +131,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
@ -142,7 +142,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;

16
src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs

@ -134,10 +134,10 @@ namespace ImageSharp
}
/// <inheritdoc />
internal override void ToXyzBytes(Span<Rgba32> sourceColors, Buffer<byte> destBytes, int startIndex, int count)
internal override void ToXyzBytes(Span<Rgba32> sourceColors, Span<byte> destBytes, int count)
{
ref Rgba32 sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref new Span<byte>(destBytes.Array, startIndex).DangerousGetPinnableReference());
ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref destBytes.DangerousGetPinnableReference());
for (int i = 0; i < count; i++)
{
@ -155,9 +155,9 @@ namespace ImageSharp
}
/// <inheritdoc />
internal override unsafe void ToXyzwBytes(Span<Rgba32> sourceColors, Buffer<byte> destBytes, int startIndex, int count)
internal override unsafe void ToXyzwBytes(Span<Rgba32> sourceColors, Span<byte> destBytes, int count)
{
SpanHelper.Copy(sourceColors.AsBytes(), new Span<byte>(destBytes.Array, startIndex), count * sizeof(Rgba32));
SpanHelper.Copy(sourceColors.AsBytes(), destBytes, count * sizeof(Rgba32));
}
/// <inheritdoc />
@ -177,10 +177,10 @@ namespace ImageSharp
}
/// <inheritdoc />
internal override void ToZyxBytes(Span<Rgba32> sourceColors, Buffer<byte> destBytes, int startIndex, int count)
internal override void ToZyxBytes(Span<Rgba32> sourceColors, Span<byte> destBytes, int count)
{
ref Rgba32 sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref new Span<byte>(destBytes.Array, startIndex).DangerousGetPinnableReference());
ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref destBytes.DangerousGetPinnableReference());
for (int i = 0; i < count; i++)
{
@ -207,10 +207,10 @@ namespace ImageSharp
}
/// <inheritdoc />
internal override void ToZyxwBytes(Span<Rgba32> sourceColors, Buffer<byte> destBytes, int startIndex, int count)
internal override void ToZyxwBytes(Span<Rgba32> sourceColors, Span<byte> destBytes, int count)
{
ref Rgba32 sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGBA32 destRef = ref Unsafe.As<byte, RGBA32>(ref new Span<byte>(destBytes.Array, startIndex).DangerousGetPinnableReference());
ref RGBA32 destRef = ref Unsafe.As<byte, RGBA32>(ref destBytes.DangerousGetPinnableReference());
for (int i = 0; i < count; i++)
{

9
src/ImageSharp/PixelFormats/Rgba32.cs

@ -5,6 +5,7 @@
namespace ImageSharp
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@ -230,7 +231,7 @@ namespace ImageSharp
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
bytes[startIndex] = this.R;
bytes[startIndex + 1] = this.G;
@ -239,7 +240,7 @@ namespace ImageSharp
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
bytes[startIndex] = this.R;
bytes[startIndex + 1] = this.G;
@ -249,7 +250,7 @@ namespace ImageSharp
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
bytes[startIndex] = this.B;
bytes[startIndex + 1] = this.G;
@ -258,7 +259,7 @@ namespace ImageSharp
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
bytes[startIndex] = this.B;
bytes[startIndex + 1] = this.G;

8
src/ImageSharp/PixelFormats/Rgba64.cs

@ -107,7 +107,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
@ -118,7 +118,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
@ -130,7 +130,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;
@ -141,7 +141,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4() * 255F;

9
src/ImageSharp/PixelFormats/RgbaVector.cs

@ -5,6 +5,7 @@
namespace ImageSharp.PixelFormats
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
@ -234,7 +235,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes;
vector += Half;
@ -245,7 +246,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes;
vector += Half;
@ -257,7 +258,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes;
vector += Half;
@ -268,7 +269,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes;
vector += Half;

8
src/ImageSharp/PixelFormats/Short2.cs

@ -119,7 +119,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector2 vector = this.ToVector2();
vector /= 65534;
@ -135,7 +135,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector2 vector = this.ToVector2();
vector /= 65534;
@ -152,7 +152,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector2 vector = this.ToVector2();
vector /= 65534;
@ -168,7 +168,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector2 vector = this.ToVector2();
vector /= 65534;

8
src/ImageSharp/PixelFormats/Short4.cs

@ -125,7 +125,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex)
public void ToXyzBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector /= 65534;
@ -141,7 +141,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex)
public void ToXyzwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector /= 65534;
@ -158,7 +158,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex)
public void ToZyxBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector /= 65534;
@ -174,7 +174,7 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex)
public void ToZyxwBytes(Span<byte> bytes, int startIndex)
{
Vector4 vector = this.ToVector4();
vector /= 65534;

4
tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs

@ -46,13 +46,13 @@ namespace ImageSharp.Benchmarks.Color.Bulk
[Benchmark]
public void CommonBulk()
{
new PixelOperations<TPixel>().ToXyzBytes(this.source, this.destination, 0, this.Count);
new PixelOperations<TPixel>().ToXyzBytes(this.source, this.destination, this.Count);
}
[Benchmark]
public void OptimizedBulk()
{
PixelOperations<TPixel>.Instance.ToXyzBytes(this.source, this.destination, 0, this.Count);
PixelOperations<TPixel>.Instance.ToXyzBytes(this.source, this.destination, this.Count);
}
}

4
tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs

@ -51,13 +51,13 @@ namespace ImageSharp.Benchmarks.Color.Bulk
[Benchmark]
public void CommonBulk()
{
new PixelOperations<TPixel>().ToXyzwBytes(this.source, this.destination, 0, this.Count);
new PixelOperations<TPixel>().ToXyzwBytes(this.source, this.destination, this.Count);
}
[Benchmark]
public void OptimizedBulk()
{
PixelOperations<TPixel>.Instance.ToXyzwBytes(this.source, this.destination, 0, this.Count);
PixelOperations<TPixel>.Instance.ToXyzwBytes(this.source, this.destination, this.Count);
}
}

8
tests/ImageSharp.Tests/Colors/PixelOperationsTests.cs

@ -181,7 +181,7 @@ namespace ImageSharp.Tests.Colors
TestOperation(
source,
expected,
(s, d) => Operations.ToXyzBytes(s, d, 0, count)
(s, d) => Operations.ToXyzBytes(s, d, count)
);
}
@ -222,7 +222,7 @@ namespace ImageSharp.Tests.Colors
TestOperation(
source,
expected,
(s, d) => Operations.ToXyzwBytes(s, d, 0, count)
(s, d) => Operations.ToXyzwBytes(s, d, count)
);
}
@ -263,7 +263,7 @@ namespace ImageSharp.Tests.Colors
TestOperation(
source,
expected,
(s, d) => Operations.ToZyxBytes(s, d, 0, count)
(s, d) => Operations.ToZyxBytes(s, d, count)
);
}
@ -304,7 +304,7 @@ namespace ImageSharp.Tests.Colors
TestOperation(
source,
expected,
(s, d) => Operations.ToZyxwBytes(s, d, 0, count)
(s, d) => Operations.ToZyxwBytes(s, d, count)
);
}

Loading…
Cancel
Save