diff --git a/src/ImageSharp/Formats/WebP/WebPTransformType.cs b/src/ImageSharp/Formats/WebP/WebPTransformType.cs index ed6e37e0a..96b73161c 100644 --- a/src/ImageSharp/Formats/WebP/WebPTransformType.cs +++ b/src/ImageSharp/Formats/WebP/WebPTransformType.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Formats.WebP /// The goal of the color transform is to decorrelate the R, G and B values of each pixel. /// Color transform keeps the green (G) value as it is, transforms red (R) based on green and transforms blue (B) based on green and then based on red. /// - ColorTransform = 1, + CrossColorTransform = 1, /// /// The subtract green transform subtracts green values from red and blue values of each pixel. diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs index d8c0b1794..2a0559de8 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs @@ -3,7 +3,6 @@ using System.IO; -using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.WebP; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; @@ -51,8 +50,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP } [Theory] - [WithFile(Lossless.LosslessNoTransform1, PixelTypes.Rgba32)] - [WithFile(Lossless.LosslessNoTransform2, PixelTypes.Rgba32)] + [WithFile(Lossless.NoTransform1, PixelTypes.Rgba32)] + [WithFile(Lossless.NoTransform2, PixelTypes.Rgba32)] public void WebpDecoder_CanDecode_Lossless_WithoutTransforms(TestImageProvider provider) where TPixel : struct, IPixel { @@ -62,5 +61,80 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP image.CompareToOriginal(provider, new MagickReferenceDecoder()); } } + + [Theory] + [WithFile(Lossless.GreenTransform1, PixelTypes.Rgba32)] + [WithFile(Lossless.GreenTransform2, PixelTypes.Rgba32)] + [WithFile(Lossless.GreenTransform3, PixelTypes.Rgba32)] + [WithFile(Lossless.GreenTransform4, PixelTypes.Rgba32)] + [WithFile(Lossless.GreenTransform5, PixelTypes.Rgba32)] + [WithFile(Lossless.GreenTransform6, PixelTypes.Rgba32)] + public void WebpDecoder_CanDecode_Lossless_WithSubstractGreenTransform(TestImageProvider provider) + where TPixel : struct, IPixel + { + using (Image image = provider.GetImage(new WebPDecoder())) + { + image.DebugSave(provider); + image.CompareToOriginal(provider, new MagickReferenceDecoder()); + } + } + + [Theory] + [WithFile(Lossless.ColorIndexTransform1, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform2, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform3, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform4, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform5, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform6, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform7, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform8, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform9, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform10, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform11, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform12, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform13, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform14, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform15, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform16, PixelTypes.Rgba32)] + [WithFile(Lossless.ColorIndexTransform17, PixelTypes.Rgba32)] + public void WebpDecoder_CanDecode_Lossless_WithColorIndexTransform(TestImageProvider provider) + where TPixel : struct, IPixel + { + using (Image image = provider.GetImage(new WebPDecoder())) + { + image.DebugSave(provider); + image.CompareToOriginal(provider, new MagickReferenceDecoder()); + } + } + + [Theory] + [WithFile(Lossless.PredictorTransform1, PixelTypes.Rgba32)] + [WithFile(Lossless.PredictorTransform2, PixelTypes.Rgba32)] + [WithFile(Lossless.PredictorTransform3, PixelTypes.Rgba32)] + [WithFile(Lossless.PredictorTransform4, PixelTypes.Rgba32)] + [WithFile(Lossless.PredictorTransform5, PixelTypes.Rgba32)] + [WithFile(Lossless.PredictorTransform6, PixelTypes.Rgba32)] + public void WebpDecoder_CanDecode_Lossless_WithPredictorTransform(TestImageProvider provider) + where TPixel : struct, IPixel + { + using (Image image = provider.GetImage(new WebPDecoder())) + { + image.DebugSave(provider); + image.CompareToOriginal(provider, new MagickReferenceDecoder()); + } + } + + [Theory] + [WithFile(Lossless.CrossColorTransform1, PixelTypes.Rgba32)] + [WithFile(Lossless.CrossColorTransform2, PixelTypes.Rgba32)] + public void WebpDecoder_CanDecode_Lossless_WithCrossColorTransform(TestImageProvider provider) + where TPixel : struct, IPixel + { + using (Image image = provider.GetImage(new WebPDecoder())) + { + image.DebugSave(provider); + image.CompareToOriginal(provider, new MagickReferenceDecoder()); + } + } } } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 5492091d1..01dc13245 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -380,10 +380,39 @@ namespace SixLabors.ImageSharp.Tests { public const string Lossless1 = "WebP/lossless1.webp"; public const string Lossless2 = "WebP/lossless2.webp"; - public const string Lossless3 = "WebP/lossless3.webp"; - public const string Lossless4 = "WebP/lossless4.webp"; - public const string LosslessNoTransform1 = "WebP/lossless_vec_1_0.webp"; - public const string LosslessNoTransform2 = "WebP/lossless_vec_2_0.webp"; + public const string NoTransform1 = "WebP/lossless_vec_1_0.webp"; + public const string NoTransform2 = "WebP/lossless_vec_2_0.webp"; + public const string GreenTransform1 = "WebP/lossless1.webp"; + public const string GreenTransform2 = "WebP/lossless2.webp"; + public const string GreenTransform3 = "WebP/lossless3.webp"; + public const string GreenTransform4 = "WebP/lossless_vec_1_4.webp"; + public const string GreenTransform5 = "WebP/lossless_vec_1_7.webp"; + public const string GreenTransform6 = "WebP/lossless_vec_2_4.webp"; + public const string CrossColorTransform1 = "WebP/lossless_vec_1_8.webp"; + public const string CrossColorTransform2 = "WebP/lossless_vec_2_8.webp"; + public const string PredictorTransform1 = "WebP/lossless_vec_1_10.webp"; + public const string PredictorTransform2 = "WebP/lossless_vec_1_10.webp"; + public const string PredictorTransform3 = "WebP/lossless_vec_1_2.webp"; + public const string PredictorTransform4 = "WebP/lossless_vec_2_10.webp"; + public const string PredictorTransform5 = "WebP/lossless_vec_2_2.webp"; + public const string PredictorTransform6 = "WebP/near_lossless_75.webp"; + public const string ColorIndexTransform1 = "WebP/lossless4.webp"; + public const string ColorIndexTransform2 = "WebP/lossless_vec_1_1.webp"; + public const string ColorIndexTransform3 = "WebP/lossless_vec_1_11.webp"; + public const string ColorIndexTransform4 = "WebP/lossless_vec_1_13.webp"; + public const string ColorIndexTransform5 = "WebP/lossless_vec_1_15.webp"; + public const string ColorIndexTransform6 = "WebP/lossless_vec_1_3.webp"; + public const string ColorIndexTransform7 = "WebP/lossless_vec_1_5.webp"; + public const string ColorIndexTransform8 = "WebP/lossless_vec_1_7.webp"; + public const string ColorIndexTransform9 = "WebP/lossless_vec_1_9.webp"; + public const string ColorIndexTransform10 = "WebP/lossless_vec_2_1.webp"; + public const string ColorIndexTransform11 = "WebP/lossless_vec_2_11.webp"; + public const string ColorIndexTransform12 = "WebP/lossless_vec_2_13.webp"; + public const string ColorIndexTransform13 = "WebP/lossless_vec_2_15.webp"; + public const string ColorIndexTransform14 = "WebP/lossless_vec_2_3.webp"; + public const string ColorIndexTransform15 = "WebP/lossless_vec_2_5.webp"; + public const string ColorIndexTransform16 = "WebP/lossless_vec_2_7.webp"; + public const string ColorIndexTransform17 = "WebP/lossless_vec_2_9.webp"; } public static class Lossy