From 38a88b2adc8da47eac3d7db7e7b8b132a0d358d8 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 18 Nov 2020 20:48:45 +0100 Subject: [PATCH] Fix issue in ExtractAlphaRows: Filter needs to be applied after extract green --- src/ImageSharp/Formats/WebP/AlphaDecoder.cs | 2 +- tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs | 1 + tests/ImageSharp.Tests/TestImages.cs | 1 + tests/Images/Input/WebP/sticker.webp | 3 +++ 4 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/Images/Input/WebP/sticker.webp diff --git a/src/ImageSharp/Formats/WebP/AlphaDecoder.cs b/src/ImageSharp/Formats/WebP/AlphaDecoder.cs index a8fce6b0cd..148a7ad94b 100644 --- a/src/ImageSharp/Formats/WebP/AlphaDecoder.cs +++ b/src/ImageSharp/Formats/WebP/AlphaDecoder.cs @@ -261,8 +261,8 @@ namespace SixLabors.ImageSharp.Formats.Experimental.WebP // Extract alpha (which is stored in the green plane). int pixelCount = width * numRowsToProcess; WebPLosslessDecoder.ApplyInverseTransforms(dec, input, this.memoryAllocator); - this.AlphaApplyFilter(0, numRowsToProcess, output, width); ExtractGreen(input, output, pixelCount); + this.AlphaApplyFilter(0, numRowsToProcess, output, width); } private static void ColorIndexInverseTransformAlpha( diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs index cb17184ad4..226f76dbd0 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs @@ -189,6 +189,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP [WithFile(Lossy.Alpha2, PixelTypes.Rgba32)] [WithFile(Lossy.Alpha3, PixelTypes.Rgba32)] [WithFile(Lossy.AlphaThinkingSmiley, PixelTypes.Rgba32)] + [WithFile(Lossy.AlphaSticker, PixelTypes.Rgba32)] public void WebpDecoder_CanDecode_Lossy_WithAlpha(TestImageProvider provider) where TPixel : unmanaged, IPixel { diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 6be4d3dc71..4770717971 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -641,6 +641,7 @@ namespace SixLabors.ImageSharp.Tests public const string AlphaNoCompressionGradientFilter = "WebP/alpha_filter_3_method_0.webp"; public const string AlphaCompressedGradientFilter = "WebP/alpha_filter_3_method_1.webp"; public const string AlphaThinkingSmiley = "WebP/1602311202.webp"; + public const string AlphaSticker = "WebP/Sticker.webp"; } } } diff --git a/tests/Images/Input/WebP/sticker.webp b/tests/Images/Input/WebP/sticker.webp new file mode 100644 index 0000000000..ae781c2d0d --- /dev/null +++ b/tests/Images/Input/WebP/sticker.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49795fc80522dae2ca687b345c21e9b0848f307d3cc3e39fbdcda730772d338c +size 27734