From 42913b64b7d8ab9e4660129bff52d2394f3e2d41 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 31 Oct 2018 18:00:11 +0000 Subject: [PATCH] Don't force transparency --- .../PixelFormats/NamedColors{TPixel}.cs | 5 +--- src/ImageSharp/Processing/KnownQuantizers.cs | 4 --- .../Quantization/QuantizedImageTests.cs | 25 ------------------- tests/Images/External | 2 +- 4 files changed, 2 insertions(+), 34 deletions(-) diff --git a/src/ImageSharp/PixelFormats/NamedColors{TPixel}.cs b/src/ImageSharp/PixelFormats/NamedColors{TPixel}.cs index a757a393ef..7e093de042 100644 --- a/src/ImageSharp/PixelFormats/NamedColors{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/NamedColors{TPixel}.cs @@ -746,10 +746,7 @@ namespace SixLabors.ImageSharp.PixelFormats private static TPixel[] GetPalette(Rgba32[] palette) { - // TODO: This should be the length only. - // We need to fix and update tests/reference images. - // If someone wants transparency they should add it to the palette. - var converted = new TPixel[palette.Length + 1]; + var converted = new TPixel[palette.Length]; Span constantsBytes = MemoryMarshal.Cast(palette.AsSpan()); PixelOperations.Instance.FromRgba32Bytes( diff --git a/src/ImageSharp/Processing/KnownQuantizers.cs b/src/ImageSharp/Processing/KnownQuantizers.cs index e93a9921a9..e4a7a75d5f 100644 --- a/src/ImageSharp/Processing/KnownQuantizers.cs +++ b/src/ImageSharp/Processing/KnownQuantizers.cs @@ -12,26 +12,22 @@ namespace SixLabors.ImageSharp.Processing { /// /// Gets the adaptive Octree quantizer. Fast with good quality. - /// The quantizer only supports a single alpha value. /// public static IQuantizer Octree { get; } = new OctreeQuantizer(); /// /// Gets the Xiaolin Wu's Color Quantizer which generates high quality output. - /// The quantizer supports multiple alpha values. /// public static IQuantizer Wu { get; } = new WuQuantizer(); /// /// Gets the palette based quantizer consisting of web safe colors as defined in the CSS Color Module Level 4. - /// The quantizer supports a single alpha value. /// public static IQuantizer WebSafe { get; } = new WebSafePaletteQuantizer(); /// /// Gets the palette based quantizer consisting of colors as defined in the original second edition of Werner’s Nomenclature of Colours 1821. /// The hex codes were collected and defined by Nicholas Rougeux - /// The quantizer supports a single alpha value. /// public static IQuantizer Werner { get; } = new WernerPaletteQuantizer(); } diff --git a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs index 753c2c109c..a0d7869e39 100644 --- a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs +++ b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs @@ -31,31 +31,6 @@ namespace SixLabors.ImageSharp.Tests Assert.True(wu.CreateFrameQuantizer(this.Configuration).Dither); } - [Theory] - [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32, true)] - [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32, false)] - public void PaletteQuantizerYieldsCorrectTransparentPixel( - TestImageProvider provider, - bool dither) - where TPixel : struct, IPixel - { - using (Image image = provider.GetImage()) - { - Assert.True(image[0, 0].Equals(default(TPixel))); - - var quantizer = new WebSafePaletteQuantizer(dither); - - foreach (ImageFrame frame in image.Frames) - { - QuantizedFrame quantized = - quantizer.CreateFrameQuantizer(this.Configuration).QuantizeFrame(frame); - - int index = this.GetTransparentIndex(quantized); - Assert.Equal(index, quantized.GetPixelSpan()[0]); - } - } - } - [Theory] [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32, true)] [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32, false)] diff --git a/tests/Images/External b/tests/Images/External index f41ae0327a..ed8a7b0b6f 160000 --- a/tests/Images/External +++ b/tests/Images/External @@ -1 +1 @@ -Subproject commit f41ae0327a3ab21ab2388c32160bda67debcc082 +Subproject commit ed8a7b0b6fe1b2e2a7c822aa617103ae31192655