Browse Source

Feed Configuration to all methods in PixelOperations

pull/751/head
Anton Firszov 8 years ago
parent
commit
53ac430e7e
  1. 12
      src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
  2. 17
      src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
  3. 18
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs
  4. 6
      src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs
  5. 2
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  6. 46
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  7. 8
      src/ImageSharp/Formats/Png/PngScanlineProcessor.cs
  8. 4
      src/ImageSharp/ImageFrame{TPixel}.cs
  9. 6
      src/ImageSharp/PixelFormats/NamedColors{TPixel}.cs
  10. 20
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
  11. 20
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs
  12. 20
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs
  13. 20
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs
  14. 20
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs
  15. 20
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs
  16. 20
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs
  17. 20
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs
  18. 20
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs
  19. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude
  20. 180
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs
  21. 20
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt
  22. 2
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
  23. 2
      src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs
  24. 11
      tests/ImageSharp.Benchmarks/Color/Bulk/FromRgba32Bytes.cs
  25. 21
      tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs
  26. 21
      tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs
  27. 44
      tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs
  28. 5
      tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs
  29. 5
      tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs
  30. 12
      tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs
  31. 23
      tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs

12
src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs

@ -436,7 +436,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp
this.stream.Read(row);
int newY = Invert(y, height, inverted);
Span<TPixel> pixelSpan = pixels.GetRowSpan(newY);
PixelOperations<TPixel>.Instance.FromBgr24Bytes(row.GetSpan(), pixelSpan, width);
PixelOperations<TPixel>.Instance.FromBgr24Bytes(
this.configuration,
row.GetSpan(),
pixelSpan,
width);
}
}
}
@ -461,7 +465,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp
this.stream.Read(row);
int newY = Invert(y, height, inverted);
Span<TPixel> pixelSpan = pixels.GetRowSpan(newY);
PixelOperations<TPixel>.Instance.FromBgra32Bytes(row.GetSpan(), pixelSpan, width);
PixelOperations<TPixel>.Instance.FromBgra32Bytes(
this.configuration,
row.GetSpan(),
pixelSpan,
width);
}
}
}

17
src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs

@ -3,6 +3,8 @@
using System;
using System.IO;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Common.Helpers;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.MetaData;
@ -23,6 +25,8 @@ namespace SixLabors.ImageSharp.Formats.Bmp
private readonly MemoryAllocator memoryAllocator;
private Configuration configuration;
private BmpBitsPerPixel? bitsPerPixel;
/// <summary>
@ -48,6 +52,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream));
this.configuration = image.GetConfiguration();
ImageMetaData metaData = image.MetaData;
BmpMetaData bmpMetaData = metaData.GetFormatMetaData(BmpFormat.Instance);
this.bitsPerPixel = this.bitsPerPixel ?? bmpMetaData.BitsPerPixel;
@ -163,7 +168,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp
for (int y = pixels.Height - 1; y >= 0; y--)
{
Span<TPixel> pixelSpan = pixels.GetRowSpan(y);
PixelOperations<TPixel>.Instance.ToBgra32Bytes(pixelSpan, row.GetSpan(), pixelSpan.Length);
PixelOperations<TPixel>.Instance.ToBgra32Bytes(
this.configuration,
pixelSpan,
row.GetSpan(),
pixelSpan.Length);
stream.Write(row.Array, 0, row.Length());
}
}
@ -183,7 +192,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp
for (int y = pixels.Height - 1; y >= 0; y--)
{
Span<TPixel> pixelSpan = pixels.GetRowSpan(y);
PixelOperations<TPixel>.Instance.ToBgr24Bytes(pixelSpan, row.GetSpan(), pixelSpan.Length);
PixelOperations<TPixel>.Instance.ToBgr24Bytes(
this.configuration,
pixelSpan,
row.GetSpan(),
pixelSpan.Length);
stream.Write(row.Array, 0, row.Length());
}
}

18
src/ImageSharp/Formats/Gif/GifEncoderCore.cs

@ -27,6 +27,11 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// </summary>
private readonly MemoryAllocator memoryAllocator;
/// <summary>
/// Configuration bound to the encoding operation.
/// </summary>
private Configuration configuration;
/// <summary>
/// A reusable buffer used to reduce allocations.
/// </summary>
@ -82,6 +87,8 @@ namespace SixLabors.ImageSharp.Formats.Gif
Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream));
this.configuration = image.GetConfiguration();
ImageMetaData metaData = image.MetaData;
this.gifMetaData = metaData.GetFormatMetaData(GifFormat.Instance);
this.colorTableMode = this.colorTableMode ?? this.gifMetaData.ColorTableMode;
@ -220,7 +227,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
{
Span<Rgba32> rgbaSpan = rgbaBuffer.GetSpan();
ref Rgba32 paletteRef = ref MemoryMarshal.GetReference(rgbaSpan);
PixelOperations<TPixel>.Instance.ToRgba32(quantized.Palette, rgbaSpan);
PixelOperations<TPixel>.Instance.ToRgba32(this.configuration, quantized.Palette, rgbaSpan);
for (int i = quantized.Palette.Length - 1; i >= 0; i--)
{
@ -322,7 +329,8 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <param name="stream">The stream to write to.</param>
private void WriteComments(ImageMetaData metadata, Stream stream)
{
if (!metadata.TryGetProperty(GifConstants.Comments, out ImageProperty property) || string.IsNullOrEmpty(property.Value))
if (!metadata.TryGetProperty(GifConstants.Comments, out ImageProperty property)
|| string.IsNullOrEmpty(property.Value))
{
return;
}
@ -420,7 +428,11 @@ namespace SixLabors.ImageSharp.Formats.Gif
using (IManagedByteBuffer colorTable = this.memoryAllocator.AllocateManagedByteBuffer(colorTableLength))
{
PixelOperations<TPixel>.Instance.ToRgb24Bytes(image.Palette.AsSpan(), colorTable.GetSpan(), pixelCount);
PixelOperations<TPixel>.Instance.ToRgb24Bytes(
this.configuration,
image.Palette.AsSpan(),
colorTable.GetSpan(),
pixelCount);
stream.Write(colorTable.Array, 0, colorTableLength);
}
}

6
src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs

@ -53,12 +53,12 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
/// <summary>
/// Converts a 8x8 image area inside 'pixels' at position (x,y) placing the result members of the structure (<see cref="Y"/>, <see cref="Cb"/>, <see cref="Cr"/>)
/// </summary>
public void Convert(IPixelSource<TPixel> pixels, int x, int y)
public void Convert(ImageFrame<TPixel> frame, int x, int y)
{
this.pixelBlock.LoadAndStretchEdges(pixels, x, y);
this.pixelBlock.LoadAndStretchEdges(frame, x, y);
Span<Rgb24> rgbSpan = this.rgbBlock.AsSpanUnsafe();
PixelOperations<TPixel>.Instance.ToRgb24(this.pixelBlock.AsSpanUnsafe(), rgbSpan);
PixelOperations<TPixel>.Instance.ToRgb24(frame.Configuration, this.pixelBlock.AsSpanUnsafe(), rgbSpan);
ref float yBlockStart = ref Unsafe.As<Block8x8F, float>(ref this.Y);
ref float cbBlockStart = ref Unsafe.As<Block8x8F, float>(ref this.Cb);

2
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -702,6 +702,7 @@ namespace SixLabors.ImageSharp.Formats.Png
case PngColorType.Rgb:
PngScanlineProcessor.ProcessRgbScanline(
this.configuration,
this.header,
scanlineSpan,
rowSpan,
@ -715,6 +716,7 @@ namespace SixLabors.ImageSharp.Formats.Png
case PngColorType.RgbWithAlpha:
PngScanlineProcessor.ProcessRgbaScanline(
this.configuration,
this.header,
scanlineSpan,
rowSpan,

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

@ -43,6 +43,11 @@ namespace SixLabors.ImageSharp.Formats.Png
/// </summary>
private readonly MemoryAllocator memoryAllocator;
/// <summary>
/// The configuration instance for the decoding operation
/// </summary>
private Configuration configuration;
/// <summary>
/// The maximum block size, defaults at 64k for uncompressed blocks.
/// </summary>
@ -201,6 +206,7 @@ namespace SixLabors.ImageSharp.Formats.Png
Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream));
this.configuration = image.GetConfiguration();
this.width = image.Width;
this.height = image.Height;
@ -328,7 +334,7 @@ namespace SixLabors.ImageSharp.Formats.Png
{
Span<Gray16> luminanceSpan = luminanceBuffer.GetSpan();
ref Gray16 luminanceRef = ref MemoryMarshal.GetReference(luminanceSpan);
PixelOperations<TPixel>.Instance.ToGray16(rowSpan, luminanceSpan);
PixelOperations<TPixel>.Instance.ToGray16(this.configuration, rowSpan, luminanceSpan);
// Can't map directly to byte array as it's big endian.
for (int x = 0, o = 0; x < luminanceSpan.Length; x++, o += 2)
@ -343,19 +349,28 @@ namespace SixLabors.ImageSharp.Formats.Png
if (this.bitDepth == 8)
{
// 8 bit grayscale
PixelOperations<TPixel>.Instance.ToGray8Bytes(rowSpan, rawScanlineSpan, rowSpan.Length);
PixelOperations<TPixel>.Instance.ToGray8Bytes(
this.configuration,
rowSpan,
rawScanlineSpan,
rowSpan.Length);
}
else
{
// 1, 2, and 4 bit grayscale
using (IManagedByteBuffer temp = this.memoryAllocator.AllocateManagedByteBuffer(rowSpan.Length, AllocationOptions.Clean))
using (IManagedByteBuffer temp = this.memoryAllocator.AllocateManagedByteBuffer(
rowSpan.Length,
AllocationOptions.Clean))
{
int scaleFactor = 255 / (ImageMaths.GetColorCountForBitDepth(this.bitDepth) - 1);
Span<byte> tempSpan = temp.GetSpan();
ref byte tempSpanRef = ref MemoryMarshal.GetReference(tempSpan);
// We need to first create an array of luminance bytes then scale them down to the correct bit depth.
PixelOperations<TPixel>.Instance.ToGray8Bytes(rowSpan, tempSpan, rowSpan.Length);
PixelOperations<TPixel>.Instance.ToGray8Bytes(
this.configuration,
rowSpan,
tempSpan,
rowSpan.Length);
this.ScaleDownFrom8BitArray(tempSpan, rawScanlineSpan, this.bitDepth, scaleFactor);
}
}
@ -371,7 +386,7 @@ namespace SixLabors.ImageSharp.Formats.Png
{
Span<Rgba64> rgbaSpan = rgbaBuffer.GetSpan();
ref Rgba64 rgbaRef = ref MemoryMarshal.GetReference(rgbaSpan);
PixelOperations<TPixel>.Instance.ToRgba64(rowSpan, rgbaSpan);
PixelOperations<TPixel>.Instance.ToRgba64(this.configuration, rowSpan, rgbaSpan);
// Can't map directly to byte array as it's big endian.
for (int x = 0, o = 0; x < rgbaSpan.Length; x++, o += 4)
@ -391,7 +406,8 @@ namespace SixLabors.ImageSharp.Formats.Png
for (int x = 0, o = 0; x < rowSpan.Length; x++, o += 2)
{
Unsafe.Add(ref rowSpanRef, x).ToRgba32(ref rgba);
Unsafe.Add(ref rawScanlineSpanRef, o) = ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B);
Unsafe.Add(ref rawScanlineSpanRef, o) =
ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B);
Unsafe.Add(ref rawScanlineSpanRef, o + 1) = rgba.A;
}
}
@ -413,14 +429,22 @@ namespace SixLabors.ImageSharp.Formats.Png
case 4:
{
// 8 bit Rgba
PixelOperations<TPixel>.Instance.ToRgba32Bytes(rowSpan, rawScanlineSpan, this.width);
PixelOperations<TPixel>.Instance.ToRgba32Bytes(
this.configuration,
rowSpan,
rawScanlineSpan,
this.width);
break;
}
case 3:
{
// 8 bit Rgb
PixelOperations<TPixel>.Instance.ToRgb24Bytes(rowSpan, rawScanlineSpan, this.width);
PixelOperations<TPixel>.Instance.ToRgb24Bytes(
this.configuration,
rowSpan,
rawScanlineSpan,
this.width);
break;
}
@ -431,7 +455,7 @@ namespace SixLabors.ImageSharp.Formats.Png
{
Span<Rgba64> rgbaSpan = rgbaBuffer.GetSpan();
ref Rgba64 rgbaRef = ref MemoryMarshal.GetReference(rgbaSpan);
PixelOperations<TPixel>.Instance.ToRgba64(rowSpan, rgbaSpan);
PixelOperations<TPixel>.Instance.ToRgba64(this.configuration, rowSpan, rgbaSpan);
// Can't map directly to byte array as it's big endian.
for (int x = 0, o = 0; x < rowSpan.Length; x++, o += 8)
@ -454,7 +478,7 @@ namespace SixLabors.ImageSharp.Formats.Png
{
Span<Rgb48> rgbSpan = rgbBuffer.GetSpan();
ref Rgb48 rgbRef = ref MemoryMarshal.GetReference(rgbSpan);
PixelOperations<TPixel>.Instance.ToRgb48(rowSpan, rgbSpan);
PixelOperations<TPixel>.Instance.ToRgb48(this.configuration, rowSpan, rgbSpan);
// Can't map directly to byte array as it's big endian.
for (int x = 0, o = 0; x < rowSpan.Length; x++, o += 6)

8
src/ImageSharp/Formats/Png/PngScanlineProcessor.cs

@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Formats.Png
{
/// <summary>
/// Provides methods to allow the decoding of raw scanlines to image rows of different pixel formats.
/// TODO: We should make this a stateful class or struct to reduce the number of arguments on methods (most are invariant).
/// </summary>
internal static class PngScanlineProcessor
{
@ -346,6 +347,7 @@ namespace SixLabors.ImageSharp.Formats.Png
}
public static void ProcessRgbScanline<TPixel>(
Configuration configuration,
in PngHeader header,
ReadOnlySpan<byte> scanlineSpan,
Span<TPixel> rowSpan,
@ -357,7 +359,6 @@ namespace SixLabors.ImageSharp.Formats.Png
where TPixel : struct, IPixel<TPixel>
{
TPixel pixel = default;
ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan);
ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan);
if (!hasTrans)
@ -377,7 +378,7 @@ namespace SixLabors.ImageSharp.Formats.Png
}
else
{
PixelOperations<TPixel>.Instance.FromRgb24Bytes(scanlineSpan, rowSpan, header.Width);
PixelOperations<TPixel>.Instance.FromRgb24Bytes(configuration, scanlineSpan, rowSpan, header.Width);
}
return;
@ -500,6 +501,7 @@ namespace SixLabors.ImageSharp.Formats.Png
}
public static void ProcessRgbaScanline<TPixel>(
Configuration configuration,
in PngHeader header,
ReadOnlySpan<byte> scanlineSpan,
Span<TPixel> rowSpan,
@ -526,7 +528,7 @@ namespace SixLabors.ImageSharp.Formats.Png
}
else
{
PixelOperations<TPixel>.Instance.FromRgba32Bytes(scanlineSpan, rowSpan, header.Width);
PixelOperations<TPixel>.Instance.FromRgba32Bytes(configuration, scanlineSpan, rowSpan, header.Width);
}
}

4
src/ImageSharp/ImageFrame{TPixel}.cs

@ -252,7 +252,7 @@ namespace SixLabors.ImageSharp
}
/// <inheritdoc/>
public override string ToString() => $"ImageFrame<{typeof(TPixel).Name}>: {this.Width}x{this.Height}";
public override string ToString() => $"ImageFrame<{typeof(TPixel).Name}>({this.Width}x{this.Height})";
/// <summary>
/// Clones the current instance.
@ -300,7 +300,7 @@ namespace SixLabors.ImageSharp
{
Span<TPixel> sourceRow = this.GetPixelRowSpan(y);
Span<TPixel2> targetRow = target.GetPixelRowSpan(y);
PixelOperations<TPixel>.Instance.To(sourceRow, targetRow);
PixelOperations<TPixel>.Instance.To(configuration, sourceRow, targetRow);
}
});

6
src/ImageSharp/PixelFormats/NamedColors{TPixel}.cs

@ -739,7 +739,11 @@ namespace SixLabors.ImageSharp.PixelFormats
var safe = new TPixel[constants.Length + 1];
Span<byte> constantsBytes = MemoryMarshal.Cast<Rgba32, byte>(constants.AsSpan());
PixelOperations<TPixel>.Instance.FromRgba32Bytes(constantsBytes, safe, constants.Length);
PixelOperations<TPixel>.Instance.FromRgba32Bytes(
Configuration.Default,
constantsBytes,
safe,
constants.Length);
return safe;
}
}

20
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
/// <inheritdoc />
internal override void FromArgb32(ReadOnlySpan<Argb32> source, Span<Argb32> destPixels)
internal override void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> source, Span<Argb32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Argb32> sourcePixels, Span<Argb32> destPixels)
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Argb32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
internal override void ToBgr24(ReadOnlySpan<Argb32> sourcePixels, Span<Bgr24> destPixels)
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgr24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(ReadOnlySpan<Argb32> sourcePixels, Span<Bgra32> destPixels)
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgra32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray8(ReadOnlySpan<Argb32> sourcePixels, Span<Gray8> destPixels)
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Gray8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(ReadOnlySpan<Argb32> sourcePixels, Span<Gray16> destPixels)
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Gray16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(ReadOnlySpan<Argb32> sourcePixels, Span<Rgb24> destPixels)
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgb24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(ReadOnlySpan<Argb32> sourcePixels, Span<Rgba32> destPixels)
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgba32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(ReadOnlySpan<Argb32> sourcePixels, Span<Rgb48> destPixels)
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgb48> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(ReadOnlySpan<Argb32> sourcePixels, Span<Rgba64> destPixels)
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgba64> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));

20
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
/// <inheritdoc />
internal override void FromBgr24(ReadOnlySpan<Bgr24> source, Span<Bgr24> destPixels)
internal override void FromBgr24(Configuration configuration, ReadOnlySpan<Bgr24> source, Span<Bgr24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(ReadOnlySpan<Bgr24> sourcePixels, Span<Bgr24> destPixels)
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Bgr24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Bgr24> sourcePixels, Span<Argb32> destPixels)
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Argb32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(ReadOnlySpan<Bgr24> sourcePixels, Span<Bgra32> destPixels)
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Bgra32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray8(ReadOnlySpan<Bgr24> sourcePixels, Span<Gray8> destPixels)
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Gray8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(ReadOnlySpan<Bgr24> sourcePixels, Span<Gray16> destPixels)
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Gray16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb24> destPixels)
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba32> destPixels)
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb48> destPixels)
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb48> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba64> destPixels)
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba64> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));

20
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
/// <inheritdoc />
internal override void FromBgra32(ReadOnlySpan<Bgra32> source, Span<Bgra32> destPixels)
internal override void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> source, Span<Bgra32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(ReadOnlySpan<Bgra32> sourcePixels, Span<Bgra32> destPixels)
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Bgra32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Bgra32> sourcePixels, Span<Argb32> destPixels)
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Argb32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(ReadOnlySpan<Bgra32> sourcePixels, Span<Bgr24> destPixels)
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Bgr24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray8(ReadOnlySpan<Bgra32> sourcePixels, Span<Gray8> destPixels)
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Gray8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(ReadOnlySpan<Bgra32> sourcePixels, Span<Gray16> destPixels)
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Gray16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb24> destPixels)
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba32> destPixels)
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb48> destPixels)
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb48> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba64> destPixels)
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba64> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));

20
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
/// <inheritdoc />
internal override void FromGray16(ReadOnlySpan<Gray16> source, Span<Gray16> destPixels)
internal override void FromGray16(Configuration configuration, ReadOnlySpan<Gray16> source, Span<Gray16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(ReadOnlySpan<Gray16> sourcePixels, Span<Gray16> destPixels)
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Gray16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Gray16> sourcePixels, Span<Argb32> destPixels)
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Argb32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(ReadOnlySpan<Gray16> sourcePixels, Span<Bgr24> destPixels)
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Bgr24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(ReadOnlySpan<Gray16> sourcePixels, Span<Bgra32> destPixels)
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Bgra32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray8(ReadOnlySpan<Gray16> sourcePixels, Span<Gray8> destPixels)
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Gray8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(ReadOnlySpan<Gray16> sourcePixels, Span<Rgb24> destPixels)
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Rgb24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(ReadOnlySpan<Gray16> sourcePixels, Span<Rgba32> destPixels)
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Rgba32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(ReadOnlySpan<Gray16> sourcePixels, Span<Rgb48> destPixels)
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Rgb48> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(ReadOnlySpan<Gray16> sourcePixels, Span<Rgba64> destPixels)
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Rgba64> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));

20
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
/// <inheritdoc />
internal override void FromGray8(ReadOnlySpan<Gray8> source, Span<Gray8> destPixels)
internal override void FromGray8(Configuration configuration, ReadOnlySpan<Gray8> source, Span<Gray8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray8(ReadOnlySpan<Gray8> sourcePixels, Span<Gray8> destPixels)
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Gray8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Gray8> sourcePixels, Span<Argb32> destPixels)
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Argb32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(ReadOnlySpan<Gray8> sourcePixels, Span<Bgr24> destPixels)
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Bgr24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(ReadOnlySpan<Gray8> sourcePixels, Span<Bgra32> destPixels)
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Bgra32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(ReadOnlySpan<Gray8> sourcePixels, Span<Gray16> destPixels)
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Gray16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(ReadOnlySpan<Gray8> sourcePixels, Span<Rgb24> destPixels)
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Rgb24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(ReadOnlySpan<Gray8> sourcePixels, Span<Rgba32> destPixels)
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Rgba32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(ReadOnlySpan<Gray8> sourcePixels, Span<Rgb48> destPixels)
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Rgb48> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(ReadOnlySpan<Gray8> sourcePixels, Span<Rgba64> destPixels)
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Rgba64> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));

20
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
/// <inheritdoc />
internal override void FromRgb24(ReadOnlySpan<Rgb24> source, Span<Rgb24> destPixels)
internal override void FromRgb24(Configuration configuration, ReadOnlySpan<Rgb24> source, Span<Rgb24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb24> destPixels)
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Rgb24> sourcePixels, Span<Argb32> destPixels)
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Argb32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(ReadOnlySpan<Rgb24> sourcePixels, Span<Bgr24> destPixels)
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Bgr24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(ReadOnlySpan<Rgb24> sourcePixels, Span<Bgra32> destPixels)
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Bgra32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray8(ReadOnlySpan<Rgb24> sourcePixels, Span<Gray8> destPixels)
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Gray8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(ReadOnlySpan<Rgb24> sourcePixels, Span<Gray16> destPixels)
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Gray16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba32> destPixels)
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb48> destPixels)
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb48> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba64> destPixels)
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba64> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));

20
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
/// <inheritdoc />
internal override void FromRgb48(ReadOnlySpan<Rgb48> source, Span<Rgb48> destPixels)
internal override void FromRgb48(Configuration configuration, ReadOnlySpan<Rgb48> source, Span<Rgb48> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb48> destPixels)
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb48> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Rgb48> sourcePixels, Span<Argb32> destPixels)
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Argb32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(ReadOnlySpan<Rgb48> sourcePixels, Span<Bgr24> destPixels)
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgr24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(ReadOnlySpan<Rgb48> sourcePixels, Span<Bgra32> destPixels)
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgra32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray8(ReadOnlySpan<Rgb48> sourcePixels, Span<Gray8> destPixels)
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Gray8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(ReadOnlySpan<Rgb48> sourcePixels, Span<Gray16> destPixels)
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Gray16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb24> destPixels)
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba32> destPixels)
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba64> destPixels)
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba64> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));

20
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
/// <inheritdoc />
internal override void FromRgba32(ReadOnlySpan<Rgba32> source, Span<Rgba32> destPixels)
internal override void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> source, Span<Rgba32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba32> destPixels)
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Rgba32> sourcePixels, Span<Argb32> destPixels)
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Argb32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(ReadOnlySpan<Rgba32> sourcePixels, Span<Bgr24> destPixels)
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgr24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(ReadOnlySpan<Rgba32> sourcePixels, Span<Bgra32> destPixels)
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgra32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray8(ReadOnlySpan<Rgba32> sourcePixels, Span<Gray8> destPixels)
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Gray8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(ReadOnlySpan<Rgba32> sourcePixels, Span<Gray16> destPixels)
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Gray16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb24> destPixels)
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb48> destPixels)
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb48> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba64> destPixels)
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba64> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));

20
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
/// <inheritdoc />
internal override void FromRgba64(ReadOnlySpan<Rgba64> source, Span<Rgba64> destPixels)
internal override void FromRgba64(Configuration configuration, ReadOnlySpan<Rgba64> source, Span<Rgba64> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba64> destPixels)
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba64> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Rgba64> sourcePixels, Span<Argb32> destPixels)
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Argb32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(ReadOnlySpan<Rgba64> sourcePixels, Span<Bgr24> destPixels)
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Bgr24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(ReadOnlySpan<Rgba64> sourcePixels, Span<Bgra32> destPixels)
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Bgra32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray8(ReadOnlySpan<Rgba64> sourcePixels, Span<Gray8> destPixels)
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Gray8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(ReadOnlySpan<Rgba64> sourcePixels, Span<Gray16> destPixels)
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Gray16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(ReadOnlySpan<Rgba64> sourcePixels, Span<Rgb24> destPixels)
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgb24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba32> destPixels)
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(ReadOnlySpan<Rgba64> sourcePixels, Span<Rgb48> destPixels)
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgb48> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));

6
src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude

@ -19,7 +19,7 @@ using System.Runtime.InteropServices;
#>
/// <inheritdoc />
internal override void From<#=pixelType#>(ReadOnlySpan<<#=pixelType#>> source, Span<<#=pixelType#>> destPixels)
internal override void From<#=pixelType#>(Configuration configuration, ReadOnlySpan<<#=pixelType#>> source, Span<<#=pixelType#>> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -27,7 +27,7 @@ using System.Runtime.InteropServices;
}
/// <inheritdoc />
internal override void To<#=pixelType#>(ReadOnlySpan<<#=pixelType#>> sourcePixels, Span<<#=pixelType#>> destPixels)
internal override void To<#=pixelType#>(Configuration configuration, ReadOnlySpan<<#=pixelType#>> sourcePixels, Span<<#=pixelType#>> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -42,7 +42,7 @@ using System.Runtime.InteropServices;
#>
/// <inheritdoc />
internal override void To<#=toPixelType#>(ReadOnlySpan<<#=fromPixelType#>> sourcePixels, Span<<#=toPixelType#>> destPixels)
internal override void To<#=toPixelType#>(Configuration configuration, ReadOnlySpan<<#=fromPixelType#>> sourcePixels, Span<<#=toPixelType#>> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));

180
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs

@ -13,9 +13,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <summary>
/// Converts all pixels in 'source` span of <see cref="Argb32"/> into a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Argb32"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromArgb32(ReadOnlySpan<Argb32> source, Span<TPixel> destPixels)
internal virtual void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> source, Span<TPixel> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -32,24 +33,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="FromArgb32(ReadOnlySpan{Argb32}, Span{TPixel})"/> that expects a byte span.
/// A helper for <see cref="FromArgb32(Configuration, ReadOnlySpan{Argb32}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Argb32"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromArgb32Bytes(ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
internal void FromArgb32Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.FromArgb32(MemoryMarshal.Cast<byte, Argb32>(sourceBytes).Slice(0, count), destPixels);
this.FromArgb32(configuration, MemoryMarshal.Cast<byte, Argb32>(sourceBytes).Slice(0, count), destPixels);
}
/// <summary>
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="Argb32"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Argb32"/> data.</param>
internal virtual void ToArgb32(ReadOnlySpan<TPixel> sourcePixels, Span<Argb32> destPixels)
internal virtual void ToArgb32(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Argb32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -66,24 +69,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="ToArgb32(ReadOnlySpan{TPixel}, Span{Argb32})"/> that expects a byte span as destination.
/// A helper for <see cref="ToArgb32(Configuration, ReadOnlySpan{TPixel}, Span{Argb32})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Argb32"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source pixels.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToArgb32Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
internal void ToArgb32Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToArgb32(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Argb32>(destBytes));
this.ToArgb32(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Argb32>(destBytes));
}
/// <summary>
/// Converts all pixels in 'source` span of <see cref="Bgr24"/> into a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Bgr24"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromBgr24(ReadOnlySpan<Bgr24> source, Span<TPixel> destPixels)
internal virtual void FromBgr24(Configuration configuration, ReadOnlySpan<Bgr24> source, Span<TPixel> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -100,24 +105,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="FromBgr24(ReadOnlySpan{Bgr24}, Span{TPixel})"/> that expects a byte span.
/// A helper for <see cref="FromBgr24(Configuration, ReadOnlySpan{Bgr24}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Bgr24"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromBgr24Bytes(ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
internal void FromBgr24Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.FromBgr24(MemoryMarshal.Cast<byte, Bgr24>(sourceBytes).Slice(0, count), destPixels);
this.FromBgr24(configuration, MemoryMarshal.Cast<byte, Bgr24>(sourceBytes).Slice(0, count), destPixels);
}
/// <summary>
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="Bgr24"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Bgr24"/> data.</param>
internal virtual void ToBgr24(ReadOnlySpan<TPixel> sourcePixels, Span<Bgr24> destPixels)
internal virtual void ToBgr24(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Bgr24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -134,24 +141,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="ToBgr24(ReadOnlySpan{TPixel}, Span{Bgr24})"/> that expects a byte span as destination.
/// A helper for <see cref="ToBgr24(Configuration, ReadOnlySpan{TPixel}, Span{Bgr24})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Bgr24"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source pixels.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgr24Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
internal void ToBgr24Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToBgr24(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Bgr24>(destBytes));
this.ToBgr24(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Bgr24>(destBytes));
}
/// <summary>
/// Converts all pixels in 'source` span of <see cref="Bgra32"/> into a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Bgra32"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromBgra32(ReadOnlySpan<Bgra32> source, Span<TPixel> destPixels)
internal virtual void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> source, Span<TPixel> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -168,24 +177,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="FromBgra32(ReadOnlySpan{Bgra32}, Span{TPixel})"/> that expects a byte span.
/// A helper for <see cref="FromBgra32(Configuration, ReadOnlySpan{Bgra32}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Bgra32"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromBgra32Bytes(ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
internal void FromBgra32Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.FromBgra32(MemoryMarshal.Cast<byte, Bgra32>(sourceBytes).Slice(0, count), destPixels);
this.FromBgra32(configuration, MemoryMarshal.Cast<byte, Bgra32>(sourceBytes).Slice(0, count), destPixels);
}
/// <summary>
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="Bgra32"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Bgra32"/> data.</param>
internal virtual void ToBgra32(ReadOnlySpan<TPixel> sourcePixels, Span<Bgra32> destPixels)
internal virtual void ToBgra32(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Bgra32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -202,24 +213,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="ToBgra32(ReadOnlySpan{TPixel}, Span{Bgra32})"/> that expects a byte span as destination.
/// A helper for <see cref="ToBgra32(Configuration, ReadOnlySpan{TPixel}, Span{Bgra32})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Bgra32"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source pixels.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgra32Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
internal void ToBgra32Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToBgra32(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Bgra32>(destBytes));
this.ToBgra32(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Bgra32>(destBytes));
}
/// <summary>
/// Converts all pixels in 'source` span of <see cref="Gray8"/> into a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Gray8"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromGray8(ReadOnlySpan<Gray8> source, Span<TPixel> destPixels)
internal virtual void FromGray8(Configuration configuration, ReadOnlySpan<Gray8> source, Span<TPixel> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -236,24 +249,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="FromGray8(ReadOnlySpan{Gray8}, Span{TPixel})"/> that expects a byte span.
/// A helper for <see cref="FromGray8(Configuration, ReadOnlySpan{Gray8}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Gray8"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromGray8Bytes(ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
internal void FromGray8Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.FromGray8(MemoryMarshal.Cast<byte, Gray8>(sourceBytes).Slice(0, count), destPixels);
this.FromGray8(configuration, MemoryMarshal.Cast<byte, Gray8>(sourceBytes).Slice(0, count), destPixels);
}
/// <summary>
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="Gray8"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Gray8"/> data.</param>
internal virtual void ToGray8(ReadOnlySpan<TPixel> sourcePixels, Span<Gray8> destPixels)
internal virtual void ToGray8(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Gray8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -270,24 +285,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="ToGray8(ReadOnlySpan{TPixel}, Span{Gray8})"/> that expects a byte span as destination.
/// A helper for <see cref="ToGray8(Configuration, ReadOnlySpan{TPixel}, Span{Gray8})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Gray8"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source pixels.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToGray8Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
internal void ToGray8Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToGray8(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Gray8>(destBytes));
this.ToGray8(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Gray8>(destBytes));
}
/// <summary>
/// Converts all pixels in 'source` span of <see cref="Gray16"/> into a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Gray16"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromGray16(ReadOnlySpan<Gray16> source, Span<TPixel> destPixels)
internal virtual void FromGray16(Configuration configuration, ReadOnlySpan<Gray16> source, Span<TPixel> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -304,24 +321,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="FromGray16(ReadOnlySpan{Gray16}, Span{TPixel})"/> that expects a byte span.
/// A helper for <see cref="FromGray16(Configuration, ReadOnlySpan{Gray16}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Gray16"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromGray16Bytes(ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
internal void FromGray16Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.FromGray16(MemoryMarshal.Cast<byte, Gray16>(sourceBytes).Slice(0, count), destPixels);
this.FromGray16(configuration, MemoryMarshal.Cast<byte, Gray16>(sourceBytes).Slice(0, count), destPixels);
}
/// <summary>
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="Gray16"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Gray16"/> data.</param>
internal virtual void ToGray16(ReadOnlySpan<TPixel> sourcePixels, Span<Gray16> destPixels)
internal virtual void ToGray16(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Gray16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -338,24 +357,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="ToGray16(ReadOnlySpan{TPixel}, Span{Gray16})"/> that expects a byte span as destination.
/// A helper for <see cref="ToGray16(Configuration, ReadOnlySpan{TPixel}, Span{Gray16})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Gray16"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source pixels.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToGray16Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
internal void ToGray16Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToGray16(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Gray16>(destBytes));
this.ToGray16(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Gray16>(destBytes));
}
/// <summary>
/// Converts all pixels in 'source` span of <see cref="Rgb24"/> into a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Rgb24"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromRgb24(ReadOnlySpan<Rgb24> source, Span<TPixel> destPixels)
internal virtual void FromRgb24(Configuration configuration, ReadOnlySpan<Rgb24> source, Span<TPixel> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -372,24 +393,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="FromRgb24(ReadOnlySpan{Rgb24}, Span{TPixel})"/> that expects a byte span.
/// A helper for <see cref="FromRgb24(Configuration, ReadOnlySpan{Rgb24}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Rgb24"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromRgb24Bytes(ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
internal void FromRgb24Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.FromRgb24(MemoryMarshal.Cast<byte, Rgb24>(sourceBytes).Slice(0, count), destPixels);
this.FromRgb24(configuration, MemoryMarshal.Cast<byte, Rgb24>(sourceBytes).Slice(0, count), destPixels);
}
/// <summary>
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="Rgb24"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Rgb24"/> data.</param>
internal virtual void ToRgb24(ReadOnlySpan<TPixel> sourcePixels, Span<Rgb24> destPixels)
internal virtual void ToRgb24(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Rgb24> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -406,24 +429,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="ToRgb24(ReadOnlySpan{TPixel}, Span{Rgb24})"/> that expects a byte span as destination.
/// A helper for <see cref="ToRgb24(Configuration, ReadOnlySpan{TPixel}, Span{Rgb24})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Rgb24"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source pixels.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgb24Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
internal void ToRgb24Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToRgb24(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgb24>(destBytes));
this.ToRgb24(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgb24>(destBytes));
}
/// <summary>
/// Converts all pixels in 'source` span of <see cref="Rgba32"/> into a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Rgba32"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromRgba32(ReadOnlySpan<Rgba32> source, Span<TPixel> destPixels)
internal virtual void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> source, Span<TPixel> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -440,24 +465,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="FromRgba32(ReadOnlySpan{Rgba32}, Span{TPixel})"/> that expects a byte span.
/// A helper for <see cref="FromRgba32(Configuration, ReadOnlySpan{Rgba32}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Rgba32"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromRgba32Bytes(ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
internal void FromRgba32Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.FromRgba32(MemoryMarshal.Cast<byte, Rgba32>(sourceBytes).Slice(0, count), destPixels);
this.FromRgba32(configuration, MemoryMarshal.Cast<byte, Rgba32>(sourceBytes).Slice(0, count), destPixels);
}
/// <summary>
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="Rgba32"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Rgba32"/> data.</param>
internal virtual void ToRgba32(ReadOnlySpan<TPixel> sourcePixels, Span<Rgba32> destPixels)
internal virtual void ToRgba32(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Rgba32> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -474,24 +501,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="ToRgba32(ReadOnlySpan{TPixel}, Span{Rgba32})"/> that expects a byte span as destination.
/// A helper for <see cref="ToRgba32(Configuration, ReadOnlySpan{TPixel}, Span{Rgba32})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Rgba32"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source pixels.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgba32Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
internal void ToRgba32Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToRgba32(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgba32>(destBytes));
this.ToRgba32(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgba32>(destBytes));
}
/// <summary>
/// Converts all pixels in 'source` span of <see cref="Rgb48"/> into a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Rgb48"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromRgb48(ReadOnlySpan<Rgb48> source, Span<TPixel> destPixels)
internal virtual void FromRgb48(Configuration configuration, ReadOnlySpan<Rgb48> source, Span<TPixel> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -508,24 +537,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="FromRgb48(ReadOnlySpan{Rgb48}, Span{TPixel})"/> that expects a byte span.
/// A helper for <see cref="FromRgb48(Configuration, ReadOnlySpan{Rgb48}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Rgb48"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromRgb48Bytes(ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
internal void FromRgb48Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.FromRgb48(MemoryMarshal.Cast<byte, Rgb48>(sourceBytes).Slice(0, count), destPixels);
this.FromRgb48(configuration, MemoryMarshal.Cast<byte, Rgb48>(sourceBytes).Slice(0, count), destPixels);
}
/// <summary>
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="Rgb48"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Rgb48"/> data.</param>
internal virtual void ToRgb48(ReadOnlySpan<TPixel> sourcePixels, Span<Rgb48> destPixels)
internal virtual void ToRgb48(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Rgb48> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -542,24 +573,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="ToRgb48(ReadOnlySpan{TPixel}, Span{Rgb48})"/> that expects a byte span as destination.
/// A helper for <see cref="ToRgb48(Configuration, ReadOnlySpan{TPixel}, Span{Rgb48})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Rgb48"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source pixels.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgb48Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
internal void ToRgb48Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToRgb48(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgb48>(destBytes));
this.ToRgb48(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgb48>(destBytes));
}
/// <summary>
/// Converts all pixels in 'source` span of <see cref="Rgba64"/> into a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Rgba64"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromRgba64(ReadOnlySpan<Rgba64> source, Span<TPixel> destPixels)
internal virtual void FromRgba64(Configuration configuration, ReadOnlySpan<Rgba64> source, Span<TPixel> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -576,24 +609,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="FromRgba64(ReadOnlySpan{Rgba64}, Span{TPixel})"/> that expects a byte span.
/// A helper for <see cref="FromRgba64(Configuration, ReadOnlySpan{Rgba64}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Rgba64"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromRgba64Bytes(ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
internal void FromRgba64Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.FromRgba64(MemoryMarshal.Cast<byte, Rgba64>(sourceBytes).Slice(0, count), destPixels);
this.FromRgba64(configuration, MemoryMarshal.Cast<byte, Rgba64>(sourceBytes).Slice(0, count), destPixels);
}
/// <summary>
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="Rgba64"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Rgba64"/> data.</param>
internal virtual void ToRgba64(ReadOnlySpan<TPixel> sourcePixels, Span<Rgba64> destPixels)
internal virtual void ToRgba64(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Rgba64> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -610,16 +645,17 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// A helper for <see cref="ToRgba64(ReadOnlySpan{TPixel}, Span{Rgba64})"/> that expects a byte span as destination.
/// A helper for <see cref="ToRgba64(Configuration, ReadOnlySpan{TPixel}, Span{Rgba64})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Rgba64"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source pixels.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgba64Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
internal void ToRgba64Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToRgba64(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgba64>(destBytes));
this.ToRgba64(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgba64>(destBytes));
}
}
}

20
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt

@ -18,9 +18,10 @@
/// <summary>
/// Converts all pixels in 'source` span of <see cref="<#=pixelType#>"/> into a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="<#=pixelType#>"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void From<#=pixelType#>(ReadOnlySpan<<#=pixelType#>> source, Span<TPixel> destPixels)
internal virtual void From<#=pixelType#>(Configuration configuration, ReadOnlySpan<<#=pixelType#>> source, Span<TPixel> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -37,16 +38,17 @@
}
/// <summary>
/// A helper for <see cref="From<#=pixelType#>(ReadOnlySpan{<#=pixelType#>}, Span{TPixel})"/> that expects a byte span.
/// A helper for <see cref="From<#=pixelType#>(Configuration, ReadOnlySpan{<#=pixelType#>}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="<#=pixelType#>"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void From<#=pixelType#>Bytes(ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
internal void From<#=pixelType#>Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.From<#=pixelType#>(MemoryMarshal.Cast<byte, <#=pixelType#>>(sourceBytes).Slice(0, count), destPixels);
this.From<#=pixelType#>(configuration, MemoryMarshal.Cast<byte, <#=pixelType#>>(sourceBytes).Slice(0, count), destPixels);
}
<#
@ -58,9 +60,10 @@
/// <summary>
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="<#=pixelType#>"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="<#=pixelType#>"/> data.</param>
internal virtual void To<#=pixelType#>(ReadOnlySpan<TPixel> sourcePixels, Span<<#=pixelType#>> destPixels)
internal virtual void To<#=pixelType#>(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<<#=pixelType#>> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -77,16 +80,17 @@
}
/// <summary>
/// A helper for <see cref="To<#=pixelType#>(ReadOnlySpan{TPixel}, Span{<#=pixelType#>})"/> that expects a byte span as destination.
/// A helper for <see cref="To<#=pixelType#>(Configuration, ReadOnlySpan{TPixel}, Span{<#=pixelType#>})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="<#=pixelType#>"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source pixels.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void To<#=pixelType#>Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
internal void To<#=pixelType#>Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.To<#=pixelType#>(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, <#=pixelType#>>(destBytes));
this.To<#=pixelType#>(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, <#=pixelType#>>(destBytes));
}
<#
}

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

@ -125,9 +125,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Converts 'sourceColors.Length' pixels from 'sourceColors' into 'destinationColors'.
/// </summary>
/// <typeparam name="TDestinationPixel">The destination pixel type.</typeparam>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destinationColors">The <see cref="Span{T}"/> to the destination colors.</param>
internal virtual void To<TDestinationPixel>(
Configuration configuration,
ReadOnlySpan<TPixel> sourceColors,
Span<TDestinationPixel> destinationColors)
where TDestinationPixel : struct, IPixel<TDestinationPixel>

2
src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs

@ -448,7 +448,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
{
Span<TPixel> row = source.GetPixelRowSpan(y);
Span<Rgba32> rgbaSpan = rgbaBuffer.GetSpan();
PixelOperations<TPixel>.Instance.ToRgba32(row, rgbaSpan);
PixelOperations<TPixel>.Instance.ToRgba32(source.Configuration, row, rgbaSpan);
ref Rgba32 scanBaseRef = ref MemoryMarshal.GetReference(rgbaSpan);
// And loop through each column

11
tests/ImageSharp.Benchmarks/Color/Bulk/FromRgba32Bytes.cs

@ -20,14 +20,17 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
private IMemoryOwner<byte> source;
private Configuration configuration;
[Params(16, 128, 1024)]
public int Count { get; set; }
[GlobalSetup]
public void Setup()
{
this.destination = Configuration.Default.MemoryAllocator.Allocate<TPixel>(this.Count);
this.source = Configuration.Default.MemoryAllocator.Allocate<byte>(this.Count * 4);
this.configuration = Configuration.Default;
this.destination = this.configuration.MemoryAllocator.Allocate<TPixel>(this.Count);
this.source = this.configuration.MemoryAllocator.Allocate<byte>(this.Count * 4);
}
[GlobalCleanup]
@ -55,13 +58,13 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
[Benchmark]
public void CommonBulk()
{
new PixelOperations<TPixel>().FromRgba32Bytes(this.source.GetSpan(), this.destination.GetSpan(), this.Count);
new PixelOperations<TPixel>().FromRgba32Bytes(this.configuration, this.source.GetSpan(), this.destination.GetSpan(), this.Count);
}
[Benchmark]
public void OptimizedBulk()
{
PixelOperations<TPixel>.Instance.FromRgba32Bytes(this.source.GetSpan(), this.destination.GetSpan(), this.Count);
PixelOperations<TPixel>.Instance.FromRgba32Bytes(this.configuration, this.source.GetSpan(), this.destination.GetSpan(), this.Count);
}
}

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

@ -17,14 +17,17 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
private IMemoryOwner<byte> destination;
private Configuration configuration;
[Params(16, 128, 1024)]
public int Count { get; set; }
[GlobalSetup]
public void Setup()
{
this.source = Configuration.Default.MemoryAllocator.Allocate<TPixel>(this.Count);
this.destination = Configuration.Default.MemoryAllocator.Allocate<byte>(this.Count * 3);
this.configuration = Configuration.Default;
this.source = this.configuration.MemoryAllocator.Allocate<TPixel>(this.Count);
this.destination = this.configuration.MemoryAllocator.Allocate<byte>(this.Count * 3);
}
[GlobalCleanup]
@ -35,10 +38,20 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
}
[Benchmark(Baseline = true)]
public void CommonBulk() => new PixelOperations<TPixel>().ToRgb24Bytes(this.source.GetSpan(), this.destination.GetSpan(), this.Count);
public void CommonBulk() =>
new PixelOperations<TPixel>().ToRgb24Bytes(
this.configuration,
this.source.GetSpan(),
this.destination.GetSpan(),
this.Count);
[Benchmark]
public void OptimizedBulk() => PixelOperations<TPixel>.Instance.ToRgb24Bytes(this.source.GetSpan(), this.destination.GetSpan(), this.Count);
public void OptimizedBulk() =>
PixelOperations<TPixel>.Instance.ToRgb24Bytes(
this.configuration,
this.source.GetSpan(),
this.destination.GetSpan(),
this.Count);
}
public class ToXyz_Rgba32 : ToXyz<Rgba32>

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

@ -19,14 +19,17 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
private IMemoryOwner<byte> destination;
private Configuration configuration;
[Params(16, 128, 1024)]
public int Count { get; set; }
[GlobalSetup]
public void Setup()
{
this.source = Configuration.Default.MemoryAllocator.Allocate<TPixel>(this.Count);
this.destination = Configuration.Default.MemoryAllocator.Allocate<byte>(this.Count * 4);
this.configuration = Configuration.Default;
this.source = this.configuration.MemoryAllocator.Allocate<TPixel>(this.Count);
this.destination = this.configuration.MemoryAllocator.Allocate<byte>(this.Count * 4);
}
[GlobalCleanup]
@ -56,10 +59,20 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
}
[Benchmark]
public void CommonBulk() => new PixelOperations<TPixel>().ToRgba32Bytes(this.source.GetSpan(), this.destination.GetSpan(), this.Count);
public void CommonBulk() =>
new PixelOperations<TPixel>().ToRgba32Bytes(
this.configuration,
this.source.GetSpan(),
this.destination.GetSpan(),
this.Count);
[Benchmark]
public void OptimizedBulk() => PixelOperations<TPixel>.Instance.ToRgba32Bytes(this.source.GetSpan(), this.destination.GetSpan(), this.Count);
public void OptimizedBulk() =>
PixelOperations<TPixel>.Instance.ToRgba32Bytes(
this.configuration,
this.source.GetSpan(),
this.destination.GetSpan(),
this.Count);
}
public class ToXyzw_Rgba32 : ToXyzw<Rgba32>

44
tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs

@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.FromGray8Bytes(s, d.GetSpan(), count)
(s, d) => Operations.FromGray8Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToGray8Bytes(s, d.GetSpan(), count)
(s, d) => Operations.ToGray8Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -123,7 +123,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.FromGray16Bytes(s, d.GetSpan(), count)
(s, d) => Operations.FromGray16Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToGray16Bytes(s, d.GetSpan(), count)
(s, d) => Operations.ToGray16Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
}
@ -177,7 +177,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.FromGray8Bytes(s, d.GetSpan(), count)
(s, d) => Operations.FromGray8Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -198,7 +198,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToGray8Bytes(s, d.GetSpan(), count)
(s, d) => Operations.ToGray8Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -219,7 +219,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.FromGray16Bytes(s, d.GetSpan(), count)
(s, d) => Operations.FromGray16Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -243,7 +243,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToGray16Bytes(s, d.GetSpan(), count)
(s, d) => Operations.ToGray16Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
}
@ -457,7 +457,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.FromArgb32Bytes(s, d.GetSpan(), count)
(s, d) => Operations.FromArgb32Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -483,7 +483,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToArgb32Bytes(s, d.GetSpan(), count)
(s, d) => Operations.ToArgb32Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -504,7 +504,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.FromBgr24Bytes(s, d.GetSpan(), count)
(s, d) => Operations.FromBgr24Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -528,7 +528,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToBgr24Bytes(s, d.GetSpan(), count)
(s, d) => Operations.ToBgr24Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -549,7 +549,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.FromBgra32Bytes(s, d.GetSpan(), count)
(s, d) => Operations.FromBgra32Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -574,7 +574,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToBgra32Bytes(s, d.GetSpan(), count)
(s, d) => Operations.ToBgra32Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -595,7 +595,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.FromRgb24Bytes(s, d.GetSpan(), count)
(s, d) => Operations.FromRgb24Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -619,7 +619,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToRgb24Bytes(s, d.GetSpan(), count)
(s, d) => Operations.ToRgb24Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -640,7 +640,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.FromRgba32Bytes(s, d.GetSpan(), count)
(s, d) => Operations.FromRgba32Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -665,7 +665,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToRgba32Bytes(s, d.GetSpan(), count)
(s, d) => Operations.ToRgba32Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -686,7 +686,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.FromRgb48Bytes(s, d.GetSpan(), count)
(s, d) => Operations.FromRgb48Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -714,7 +714,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToRgb48Bytes(s, d.GetSpan(), count)
(s, d) => Operations.ToRgb48Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -735,7 +735,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.FromRgba64Bytes(s, d.GetSpan(), count)
(s, d) => Operations.FromRgba64Bytes(this.Configuration, s, d.GetSpan(), count)
);
}
@ -765,7 +765,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToRgba64Bytes(s, d.GetSpan(), count)
(s, d) => Operations.ToRgba64Bytes(this.Configuration, s, d.GetSpan(), count)
);
}

5
tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs

@ -28,14 +28,15 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
var bBuffer = new Rgba64[width];
var differences = new List<PixelDifference>();
Configuration configuration = expected.Configuration;
for (int y = 0; y < actual.Height; y++)
{
Span<TPixelA> aSpan = expected.GetPixelRowSpan(y);
Span<TPixelB> bSpan = actual.GetPixelRowSpan(y);
PixelOperations<TPixelA>.Instance.ToRgba64(aSpan, aBuffer);
PixelOperations<TPixelB>.Instance.ToRgba64(bSpan, bBuffer);
PixelOperations<TPixelA>.Instance.ToRgba64(configuration, aSpan, aBuffer);
PixelOperations<TPixelB>.Instance.ToRgba64(configuration, bSpan, bBuffer);
for (int x = 0; x < width; x++)
{

5
tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs

@ -74,14 +74,15 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
float totalDifference = 0F;
var differences = new List<PixelDifference>();
Configuration configuration = expected.Configuration;
for (int y = 0; y < actual.Height; y++)
{
Span<TPixelA> aSpan = expected.GetPixelRowSpan(y);
Span<TPixelB> bSpan = actual.GetPixelRowSpan(y);
PixelOperations<TPixelA>.Instance.ToRgba64(aSpan, aBuffer);
PixelOperations<TPixelB>.Instance.ToRgba64(bSpan, bBuffer);
PixelOperations<TPixelA>.Instance.ToRgba64(configuration, aSpan, aBuffer);
PixelOperations<TPixelB>.Instance.ToRgba64(configuration, bSpan, bBuffer);
for (int x = 0; x < width; x++)
{

12
tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs

@ -31,14 +31,22 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
{
byte[] data = pixels.ToByteArray(PixelMapping.RGBA);
PixelOperations<TPixel>.Instance.FromRgba32Bytes(data, resultPixels, resultPixels.Length);
PixelOperations<TPixel>.Instance.FromRgba32Bytes(
configuration,
data,
resultPixels,
resultPixels.Length);
}
else if (magickImage.Depth == 16)
{
ushort[] data = pixels.ToShortArray(PixelMapping.RGBA);
Span<byte> bytes = MemoryMarshal.Cast<ushort, byte>(data.AsSpan());
PixelOperations<TPixel>.Instance.FromRgba64Bytes(bytes, resultPixels, resultPixels.Length);
PixelOperations<TPixel>.Instance.FromRgba64Bytes(
configuration,
bytes,
resultPixels,
resultPixels.Length);
}
else
{

23
tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs

@ -33,7 +33,9 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
if (bmp.PixelFormat != PixelFormat.Format32bppArgb)
{
throw new ArgumentException($"{nameof(From32bppArgbSystemDrawingBitmap)} : pixel format should be {PixelFormat.Format32bppArgb}!", nameof(bmp));
throw new ArgumentException(
$"{nameof(From32bppArgbSystemDrawingBitmap)} : pixel format should be {PixelFormat.Format32bppArgb}!",
nameof(bmp));
}
BitmapData data = bmp.LockBits(fullRect, ImageLockMode.ReadWrite, bmp.PixelFormat);
@ -43,6 +45,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
long destRowByteCount = w * sizeof(Bgra32);
var image = new Image<TPixel>(w, h);
Configuration configuration = image.GetConfiguration();
using (IMemoryOwner<Bgra32> workBuffer = Configuration.Default.MemoryAllocator.Allocate<Bgra32>(w))
{
@ -55,7 +58,10 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
byte* sourcePtr = sourcePtrBase + (data.Stride * y);
Buffer.MemoryCopy(sourcePtr, destPtr, destRowByteCount, sourceRowByteCount);
PixelOperations<TPixel>.Instance.FromBgra32(workBuffer.GetSpan().Slice(0, w), row);
PixelOperations<TPixel>.Instance.FromBgra32(
configuration,
workBuffer.GetSpan().Slice(0, w),
row);
}
}
}
@ -79,7 +85,9 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
if (bmp.PixelFormat != PixelFormat.Format24bppRgb)
{
throw new ArgumentException($"{nameof(From24bppRgbSystemDrawingBitmap)}: pixel format should be {PixelFormat.Format24bppRgb}!", nameof(bmp));
throw new ArgumentException(
$"{nameof(From24bppRgbSystemDrawingBitmap)}: pixel format should be {PixelFormat.Format24bppRgb}!",
nameof(bmp));
}
BitmapData data = bmp.LockBits(fullRect, ImageLockMode.ReadWrite, bmp.PixelFormat);
@ -89,6 +97,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
long destRowByteCount = w * sizeof(Bgr24);
var image = new Image<TPixel>(w, h);
Configuration configuration = image.GetConfiguration();
using (IMemoryOwner<Bgr24> workBuffer = Configuration.Default.MemoryAllocator.Allocate<Bgr24>(w))
{
@ -101,7 +110,10 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
byte* sourcePtr = sourcePtrBase + (data.Stride * y);
Buffer.MemoryCopy(sourcePtr, destPtr, destRowByteCount, sourceRowByteCount);
PixelOperations<TPixel>.Instance.FromBgr24(workBuffer.GetSpan().Slice(0, w), row);
PixelOperations<TPixel>.Instance.FromBgr24(
configuration,
workBuffer.GetSpan().Slice(0, w),
row);
}
}
}
@ -112,6 +124,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
internal static unsafe Bitmap To32bppArgbSystemDrawingBitmap<TPixel>(Image<TPixel> image)
where TPixel : struct, IPixel<TPixel>
{
Configuration configuration = image.GetConfiguration();
int w = image.Width;
int h = image.Height;
@ -130,7 +143,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
for (int y = 0; y < h; y++)
{
Span<TPixel> row = image.Frames.RootFrame.GetPixelRowSpan(y);
PixelOperations<TPixel>.Instance.ToBgra32(row, workBuffer.GetSpan());
PixelOperations<TPixel>.Instance.ToBgra32(configuration, row, workBuffer.GetSpan());
byte* destPtr = destPtrBase + (data.Stride * y);
Buffer.MemoryCopy(sourcePtr, destPtr, destRowByteCount, sourceRowByteCount);

Loading…
Cancel
Save