From 9b29319ea97835e9960cdf142ecb103b047bd7cc Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 7 Sep 2022 08:00:53 +1000 Subject: [PATCH] Reverse breaking change. --- src/ImageSharp/Color/Color.cs | 6 +++++- .../Processors/Dithering/PaletteDitherProcessor{TPixel}.cs | 2 +- .../Processing/Processors/Quantization/PaletteQuantizer.cs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Color/Color.cs b/src/ImageSharp/Color/Color.cs index 17e0964d0..9cff680e4 100644 --- a/src/ImageSharp/Color/Color.cs +++ b/src/ImageSharp/Color/Color.cs @@ -287,12 +287,16 @@ namespace SixLabors.ImageSharp /// Bulk converts a span of to a span of a specified type. /// /// The pixel type to convert to. + /// The configuration. /// The source color span. /// The destination pixel span. [MethodImpl(InliningOptions.ShortMethod)] - public static void ToPixel(ReadOnlySpan source, Span destination) +#pragma warning disable RCS1163 // Unused parameter. + public static void ToPixel(Configuration configuration, ReadOnlySpan source, Span destination) +#pragma warning restore RCS1163 // Unused parameter. where TPixel : unmanaged, IPixel { + // TODO: Investigate bulk operations utilizing configuration parameter here. Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination)); for (int i = 0; i < source.Length; i++) { diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs index 4933b9f75..5b336d78f 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs @@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering ReadOnlySpan sourcePalette = definition.Palette.Span; this.paletteOwner = this.Configuration.MemoryAllocator.Allocate(sourcePalette.Length); - Color.ToPixel(sourcePalette, this.paletteOwner.Memory.Span); + Color.ToPixel(this.Configuration, sourcePalette, this.paletteOwner.Memory.Span); this.ditherProcessor = new DitherProcessor( this.Configuration, diff --git a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs index cc4b4a33f..30043abfb 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization int length = Math.Min(this.colorPalette.Length, options.MaxColors); TPixel[] palette = new TPixel[length]; - Color.ToPixel(this.colorPalette.Span, palette.AsSpan()); + Color.ToPixel(configuration, this.colorPalette.Span, palette.AsSpan()); return new PaletteQuantizer(configuration, options, palette); } }