From 2ddecc60dea91045a6e7ecfa6eebeb483010673d Mon Sep 17 00:00:00 2001 From: Tigran <83982924+tsardaryanCamenAI@users.noreply.github.com> Date: Thu, 11 May 2023 18:01:00 +0200 Subject: [PATCH 01/23] bugfix in Rational.cs --- src/ImageSharp/Primitives/Rational.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ImageSharp/Primitives/Rational.cs b/src/ImageSharp/Primitives/Rational.cs index 59f34331a7..7970f993e8 100644 --- a/src/ImageSharp/Primitives/Rational.cs +++ b/src/ImageSharp/Primitives/Rational.cs @@ -74,6 +74,11 @@ public readonly struct Rational : IEquatable this.Numerator = (uint)rational.Numerator; this.Denominator = (uint)rational.Denominator; + + if(this.Numerator == 0 && this.Denominator == 0) + { + this.Denominator = 1; + } } /// From 9b3d84faf681a8b08c75411ac9c45b9fea120a70 Mon Sep 17 00:00:00 2001 From: Tigran <83982924+tsardaryanCamenAI@users.noreply.github.com> Date: Tue, 16 May 2023 23:04:31 +0200 Subject: [PATCH 02/23] Update LongRational.cs fix issue with 0 Denominator. --- src/ImageSharp/Primitives/LongRational.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Primitives/LongRational.cs b/src/ImageSharp/Primitives/LongRational.cs index e92875a98b..349a3028e9 100644 --- a/src/ImageSharp/Primitives/LongRational.cs +++ b/src/ImageSharp/Primitives/LongRational.cs @@ -203,7 +203,7 @@ internal readonly struct LongRational : IEquatable if (this.Numerator == 0) { - return new LongRational(0, 0); + return new LongRational(0, 1); } if (this.Numerator == this.Denominator) From c09d20e3e95c7a8089f7759150478ec5e3169d53 Mon Sep 17 00:00:00 2001 From: Tigran <83982924+tsardaryanCamenAI@users.noreply.github.com> Date: Wed, 17 May 2023 19:47:27 +0000 Subject: [PATCH 03/23] fix for Retional.FromDouble(0) --- src/ImageSharp/Primitives/LongRational.cs | 9 ++++----- src/ImageSharp/Primitives/Rational.cs | 5 ----- tests/ImageSharp.Tests/Numerics/RationalTests.cs | 12 ++++++++++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/ImageSharp/Primitives/LongRational.cs b/src/ImageSharp/Primitives/LongRational.cs index 349a3028e9..deef2d09be 100644 --- a/src/ImageSharp/Primitives/LongRational.cs +++ b/src/ImageSharp/Primitives/LongRational.cs @@ -153,6 +153,10 @@ internal readonly struct LongRational : IEquatable double df = numerator / (double)denominator; double epsilon = bestPrecision ? double.Epsilon : .000001; + if(val < epsilon) { + return new LongRational(0, 1); + } + while (Math.Abs(df - val) > epsilon) { if (df < val) @@ -201,11 +205,6 @@ internal readonly struct LongRational : IEquatable return this; } - if (this.Numerator == 0) - { - return new LongRational(0, 1); - } - if (this.Numerator == this.Denominator) { return new LongRational(1, 1); diff --git a/src/ImageSharp/Primitives/Rational.cs b/src/ImageSharp/Primitives/Rational.cs index 7970f993e8..59f34331a7 100644 --- a/src/ImageSharp/Primitives/Rational.cs +++ b/src/ImageSharp/Primitives/Rational.cs @@ -74,11 +74,6 @@ public readonly struct Rational : IEquatable this.Numerator = (uint)rational.Numerator; this.Denominator = (uint)rational.Denominator; - - if(this.Numerator == 0 && this.Denominator == 0) - { - this.Denominator = 1; - } } /// diff --git a/tests/ImageSharp.Tests/Numerics/RationalTests.cs b/tests/ImageSharp.Tests/Numerics/RationalTests.cs index d165bd9d39..a696cce9e5 100644 --- a/tests/ImageSharp.Tests/Numerics/RationalTests.cs +++ b/tests/ImageSharp.Tests/Numerics/RationalTests.cs @@ -41,6 +41,18 @@ public class RationalTests Assert.True(first != second); } + /// + /// Tests the correct FromDouble(0). + /// + [Fact] + public void FromDouble0Non0Denominator() + { + var r = Rational.FromDouble(0); + + Assert.Equal(0, r.Numerator); + Assert.Equal(1, r.Denominator); + } + /// /// Tests whether the Rational constructor correctly assign properties. /// From 64fcccd54cdc37313b4bcae04e5ba8a9553296b6 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Thu, 18 May 2023 20:08:08 +0200 Subject: [PATCH 04/23] Undo predictor for cmyk images, fixes #2456 --- src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs b/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs index 9a4e4ba2b9..1c838b0b76 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs @@ -44,6 +44,7 @@ internal static class HorizontalPredictor UndoRgb24Bit(pixelBytes, width); break; case TiffColorType.Rgba8888: + case TiffColorType.Cmyk: UndoRgba32Bit(pixelBytes, width); break; case TiffColorType.Rgb161616: From f558e6f5740b7c726cdacf62a5b2ac4ddc839c4d Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Thu, 18 May 2023 20:08:32 +0200 Subject: [PATCH 05/23] Add test for issue 2456 --- tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs | 1 + tests/ImageSharp.Tests/TestImages.cs | 1 + .../TiffDecoder_CanDecode_Cmyk_Rgba32_Cmyk-lzw-predictor.png | 3 +++ tests/Images/Input/Tiff/Cmyk-lzw-predictor.tiff | 3 +++ 4 files changed, 8 insertions(+) create mode 100644 tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_Cmyk_Rgba32_Cmyk-lzw-predictor.png create mode 100644 tests/Images/Input/Tiff/Cmyk-lzw-predictor.tiff diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index a9e2b75c02..2c8268d413 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -308,6 +308,7 @@ public class TiffDecoderTests : TiffDecoderBaseTester [Theory] [WithFile(Cmyk, PixelTypes.Rgba32)] + [WithFile(CmykLzwPredictor, PixelTypes.Rgba32)] public void TiffDecoder_CanDecode_Cmyk(TestImageProvider provider) where TPixel : unmanaged, IPixel { diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 409378b179..1fc964a064 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -958,6 +958,7 @@ public static class TestImages public const string Cmyk = "Tiff/Cmyk.tiff"; public const string Cmyk64BitDeflate = "Tiff/cmyk_deflate_64bit.tiff"; + public const string CmykLzwPredictor = "Tiff/Cmyk-lzw-predictor.tiff"; public const string Issues1716Rgb161616BitLittleEndian = "Tiff/Issues/Issue1716.tiff"; public const string Issues1891 = "Tiff/Issues/Issue1891.tiff"; diff --git a/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_Cmyk_Rgba32_Cmyk-lzw-predictor.png b/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_Cmyk_Rgba32_Cmyk-lzw-predictor.png new file mode 100644 index 0000000000..00fe4de822 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_Cmyk_Rgba32_Cmyk-lzw-predictor.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db076491d7afc78cb5de99cb1e7a9c53f891157bf064994c60d453aec75b9c90 +size 512 diff --git a/tests/Images/Input/Tiff/Cmyk-lzw-predictor.tiff b/tests/Images/Input/Tiff/Cmyk-lzw-predictor.tiff new file mode 100644 index 0000000000..c5056a9282 --- /dev/null +++ b/tests/Images/Input/Tiff/Cmyk-lzw-predictor.tiff @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d322e42dd61c528e91ba9d16310248a4b9a77094a22761dcb9e6f132fc16fe1b +size 1080 From 107e37eaaeed043f1a095bd7810e9287e0b32c40 Mon Sep 17 00:00:00 2001 From: n0099 Date: Mon, 22 May 2023 06:04:14 +0800 Subject: [PATCH 06/23] Update Rgb48.cs --- src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs index 1cf63eb24c..6bf25717ce 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs @@ -8,7 +8,7 @@ using System.Runtime.InteropServices; namespace SixLabors.ImageSharp.PixelFormats; /// -/// Packed pixel type containing three 16-bit unsigned normalized values ranging from 0 to 635535. +/// Packed pixel type containing three 16-bit unsigned normalized values ranging from 0 to 65535. /// /// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form. /// From 1630e436b0c5d4c01bec1301abb28b858f853914 Mon Sep 17 00:00:00 2001 From: Pavel Date: Tue, 30 May 2023 10:33:32 +0300 Subject: [PATCH 07/23] Update Directory.Build.targets Updated SharpZip package version to 1.4.2 --- tests/Directory.Build.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index c05384fcce..3a29442872 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -30,7 +30,7 @@ - + From b4ad3c30098ecb6e478009bbb40001a9519c00a3 Mon Sep 17 00:00:00 2001 From: Gerard Gunnewijk Date: Wed, 7 Jun 2023 15:54:54 +0200 Subject: [PATCH 08/23] Added test that shows the issue --- .../Formats/Bmp/BmpEncoderTests.cs | 24 +++++++++++++++++++ tests/ImageSharp.Tests/TestImages.cs | 2 ++ tests/Images/Input/Bmp/bit1datamatrix.bmp | 3 +++ 3 files changed, 29 insertions(+) create mode 100644 tests/Images/Input/Bmp/bit1datamatrix.bmp diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs index f486310b78..a0d91c2088 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs @@ -370,6 +370,30 @@ public class BmpEncoderTests TestBmpEncoderCore(provider, bitsPerPixel); } + [Theory] + [WithFile(BlackWhitePalletDataMatrix, PixelTypes.Rgb24, BmpBitsPerPixel.Pixel1)] + public void Encode_Issue2467(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + + using var reencodedStream = new MemoryStream(); + var encoder = new BmpEncoder + { + BitsPerPixel = bitsPerPixel, + SupportTransparency = false, + Quantizer = KnownQuantizers.Octree + }; + image.SaveAsBmp(reencodedStream, encoder); + reencodedStream.Seek(0, SeekOrigin.Begin); + + using Image reencodedImage = Image.Load(reencodedStream); + + reencodedImage.DebugSave(provider); + + reencodedImage.CompareToOriginal(provider); + } + private static void TestBmpEncoderCore( TestImageProvider provider, BmpBitsPerPixel bitsPerPixel, diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 1fc964a064..8a676c02d3 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -407,6 +407,8 @@ public static class TestImages public const string Rgba321010102 = "Bmp/rgba32-1010102.bmp"; public const string RgbaAlphaBitfields = "Bmp/rgba32abf.bmp"; + public const string BlackWhitePalletDataMatrix = "Bmp/bit1datamatrix.bmp"; + public static readonly string[] BitFields = { Rgb32bfdef, diff --git a/tests/Images/Input/Bmp/bit1datamatrix.bmp b/tests/Images/Input/Bmp/bit1datamatrix.bmp new file mode 100644 index 0000000000..ee5535d112 --- /dev/null +++ b/tests/Images/Input/Bmp/bit1datamatrix.bmp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b2288e2a059b15c7855eb141c05e3ce69431e7c3ddef851033f7fd9ca39a2d4 +size 102 From b29cd27c1031a08fb78c50658fed9c8fabf23181 Mon Sep 17 00:00:00 2001 From: Gerard Gunnewijk Date: Wed, 7 Jun 2023 15:55:23 +0200 Subject: [PATCH 09/23] Fixed bug in Write1BitPixelData that wrote too many bits to the byte --- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index fd23a29e37..ce1660a912 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -668,7 +668,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals if (quantizedPixelRow.Length % 8 != 0) { - int startIdx = quantizedPixelRow.Length - 7; + int startIdx = quantizedPixelRow.Length - (quantizedPixelRow.Length % 8); endIdx = quantizedPixelRow.Length; Write1BitPalette(stream, startIdx, endIdx, quantizedPixelRow); } From 973e6f1fa9e0836ea5a94f1678b721e5da904452 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Jun 2023 10:13:09 +1000 Subject: [PATCH 10/23] Fix implementation and tests --- src/ImageSharp/Primitives/LongRational.cs | 9 ++-- .../Numerics/RationalTests.cs | 45 +++++++++++-------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/ImageSharp/Primitives/LongRational.cs b/src/ImageSharp/Primitives/LongRational.cs index deef2d09be..69139ac9c4 100644 --- a/src/ImageSharp/Primitives/LongRational.cs +++ b/src/ImageSharp/Primitives/LongRational.cs @@ -131,6 +131,11 @@ internal readonly struct LongRational : IEquatable /// Whether to use the best possible precision when parsing the value. public static LongRational FromDouble(double value, bool bestPrecision) { + if (value == 0.0) + { + return new LongRational(0, 1); + } + if (double.IsNaN(value)) { return new LongRational(0, 0); @@ -153,10 +158,6 @@ internal readonly struct LongRational : IEquatable double df = numerator / (double)denominator; double epsilon = bestPrecision ? double.Epsilon : .000001; - if(val < epsilon) { - return new LongRational(0, 1); - } - while (Math.Abs(df - val) > epsilon) { if (df < val) diff --git a/tests/ImageSharp.Tests/Numerics/RationalTests.cs b/tests/ImageSharp.Tests/Numerics/RationalTests.cs index a696cce9e5..f9cefaddda 100644 --- a/tests/ImageSharp.Tests/Numerics/RationalTests.cs +++ b/tests/ImageSharp.Tests/Numerics/RationalTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.Tests; @@ -14,15 +14,15 @@ public class RationalTests [Fact] public void AreEqual() { - var r1 = new Rational(3, 2); - var r2 = new Rational(3, 2); + Rational r1 = new(3, 2); + Rational r2 = new(3, 2); Assert.Equal(r1, r2); Assert.True(r1 == r2); - var r3 = new Rational(7.55); - var r4 = new Rational(755, 100); - var r5 = new Rational(151, 20); + Rational r3 = new(7.55); + Rational r4 = new(755, 100); + Rational r5 = new(151, 20); Assert.Equal(r3, r4); Assert.Equal(r4, r5); @@ -34,23 +34,30 @@ public class RationalTests [Fact] public void AreNotEqual() { - var first = new Rational(0, 100); - var second = new Rational(100, 100); + Rational first = new(0, 100); + Rational second = new(100, 100); Assert.NotEqual(first, second); Assert.True(first != second); } /// - /// Tests the correct FromDouble(0). + /// Tests known out-of-range values. /// - [Fact] - public void FromDouble0Non0Denominator() + /// The input value. + /// The expected numerator. + /// The expected denominator. + [Theory] + [InlineData(0, 0, 1)] + [InlineData(double.NaN, 0, 0)] + [InlineData(double.PositiveInfinity, 1, 0)] + [InlineData(double.NegativeInfinity, 1, 0)] + public void FromDoubleOutOfRange(double value, uint numerator, uint denominator) { - var r = Rational.FromDouble(0); + Rational r = Rational.FromDouble(value); - Assert.Equal(0, r.Numerator); - Assert.Equal(1, r.Denominator); + Assert.Equal(numerator, r.Numerator); + Assert.Equal(denominator, r.Denominator); } /// @@ -59,7 +66,7 @@ public class RationalTests [Fact] public void ConstructorAssignsProperties() { - var rational = new Rational(7, 55); + Rational rational = new(7, 55); Assert.Equal(7U, rational.Numerator); Assert.Equal(55U, rational.Denominator); @@ -83,15 +90,15 @@ public class RationalTests [Fact] public void Fraction() { - var first = new Rational(1.0 / 1600); - var second = new Rational(1.0 / 1600, true); + Rational first = new(1.0 / 1600); + Rational second = new(1.0 / 1600, true); Assert.False(first.Equals(second)); } [Fact] public void ToDouble() { - var rational = new Rational(0, 0); + Rational rational = new(0, 0); Assert.Equal(double.NaN, rational.ToDouble()); rational = new Rational(2, 0); @@ -101,7 +108,7 @@ public class RationalTests [Fact] public void ToStringRepresentation() { - var rational = new Rational(0, 0); + Rational rational = new(0, 0); Assert.Equal("[ Indeterminate ]", rational.ToString()); rational = new Rational(double.PositiveInfinity); From ae3900df7a000560dc104643dceeca180c82060c Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Jun 2023 16:02:14 +1000 Subject: [PATCH 11/23] Use more accurate bit for alpha lookup. Fix #2469 --- .../Quantization/EuclideanPixelMap{TPixel}.cs | 4 +- .../Formats/Png/PngDecoderTests.cs | 2 +- .../Formats/Png/PngEncoderTests.cs | 64 +++++++++++-------- .../UniformUnmanagedMemoryPoolTests.Trim.cs | 8 ++- tests/ImageSharp.Tests/TestImages.cs | 5 +- ...erFilterInBox_Rgba32_CalliphoraPartial.png | 4 +- ..._WorksWithAllDitherers_Bike_Bayer16x16.png | 4 +- ...er_WorksWithAllDitherers_Bike_Bayer2x2.png | 4 +- ...er_WorksWithAllDitherers_Bike_Bayer4x4.png | 4 +- ...er_WorksWithAllDitherers_Bike_Bayer8x8.png | 4 +- ..._WorksWithAllDitherers_Bike_Ordered3x3.png | 4 +- ...Ditherers_CalliphoraPartial_Bayer16x16.png | 4 +- ...llDitherers_CalliphoraPartial_Bayer2x2.png | 4 +- ...llDitherers_CalliphoraPartial_Bayer4x4.png | 4 +- ...llDitherers_CalliphoraPartial_Bayer8x8.png | 4 +- ...Ditherers_CalliphoraPartial_Ordered3x3.png | 4 +- ...zed_Encode_Artifacts_Rgba32_issue_2469.png | 3 + ...david_OctreeQuantizer_ErrorDither_0.25.png | 4 +- ..._david_OctreeQuantizer_ErrorDither_0.5.png | 4 +- ...david_OctreeQuantizer_ErrorDither_0.75.png | 4 +- ...le_david_OctreeQuantizer_ErrorDither_0.png | 4 +- ...le_david_OctreeQuantizer_ErrorDither_1.png | 4 +- ...vid_OctreeQuantizer_OrderedDither_0.25.png | 4 +- ...avid_OctreeQuantizer_OrderedDither_0.5.png | 4 +- ...vid_OctreeQuantizer_OrderedDither_0.75.png | 4 +- ..._david_OctreeQuantizer_OrderedDither_0.png | 4 +- ..._david_OctreeQuantizer_OrderedDither_1.png | 4 +- ...bSafePaletteQuantizer_ErrorDither_0.25.png | 4 +- ...ebSafePaletteQuantizer_ErrorDither_0.5.png | 4 +- ...bSafePaletteQuantizer_ErrorDither_0.75.png | 4 +- ..._WebSafePaletteQuantizer_ErrorDither_0.png | 4 +- ..._WebSafePaletteQuantizer_ErrorDither_1.png | 4 +- ...afePaletteQuantizer_OrderedDither_0.25.png | 4 +- ...SafePaletteQuantizer_OrderedDither_0.5.png | 4 +- ...afePaletteQuantizer_OrderedDither_0.75.png | 4 +- ...ebSafePaletteQuantizer_OrderedDither_0.png | 4 +- ...ebSafePaletteQuantizer_OrderedDither_1.png | 4 +- ...ernerPaletteQuantizer_ErrorDither_0.25.png | 4 +- ...WernerPaletteQuantizer_ErrorDither_0.5.png | 4 +- ...ernerPaletteQuantizer_ErrorDither_0.75.png | 4 +- ...d_WernerPaletteQuantizer_ErrorDither_0.png | 4 +- ...d_WernerPaletteQuantizer_ErrorDither_1.png | 4 +- ...nerPaletteQuantizer_OrderedDither_0.25.png | 4 +- ...rnerPaletteQuantizer_OrderedDither_0.5.png | 4 +- ...nerPaletteQuantizer_OrderedDither_0.75.png | 4 +- ...WernerPaletteQuantizer_OrderedDither_0.png | 4 +- ...WernerPaletteQuantizer_OrderedDither_1.png | 4 +- ...ale_david_WuQuantizer_ErrorDither_0.25.png | 4 +- ...cale_david_WuQuantizer_ErrorDither_0.5.png | 4 +- ...ale_david_WuQuantizer_ErrorDither_0.75.png | 4 +- ...gScale_david_WuQuantizer_ErrorDither_0.png | 4 +- ...gScale_david_WuQuantizer_ErrorDither_1.png | 4 +- ...e_david_WuQuantizer_OrderedDither_0.25.png | 4 +- ...le_david_WuQuantizer_OrderedDither_0.5.png | 4 +- ...e_david_WuQuantizer_OrderedDither_0.75.png | 4 +- ...cale_david_WuQuantizer_OrderedDither_0.png | 4 +- ...cale_david_WuQuantizer_OrderedDither_1.png | 4 +- ...ation_Bike_OctreeQuantizer_ErrorDither.png | 4 +- ...tization_Bike_OctreeQuantizer_NoDither.png | 4 +- ...ion_Bike_OctreeQuantizer_OrderedDither.png | 4 +- ...ke_WebSafePaletteQuantizer_ErrorDither.png | 4 +- ..._Bike_WebSafePaletteQuantizer_NoDither.png | 4 +- ..._WebSafePaletteQuantizer_OrderedDither.png | 4 +- ...ike_WernerPaletteQuantizer_ErrorDither.png | 4 +- ...n_Bike_WernerPaletteQuantizer_NoDither.png | 4 +- ...e_WernerPaletteQuantizer_OrderedDither.png | 4 +- ...ntization_Bike_WuQuantizer_ErrorDither.png | 4 +- ...Quantization_Bike_WuQuantizer_NoDither.png | 4 +- ...ization_Bike_WuQuantizer_OrderedDither.png | 4 +- ...oraPartial_OctreeQuantizer_ErrorDither.png | 4 +- ...iphoraPartial_OctreeQuantizer_NoDither.png | 4 +- ...aPartial_OctreeQuantizer_OrderedDither.png | 4 +- ...al_WebSafePaletteQuantizer_ErrorDither.png | 4 +- ...rtial_WebSafePaletteQuantizer_NoDither.png | 4 +- ..._WebSafePaletteQuantizer_OrderedDither.png | 4 +- ...ial_WernerPaletteQuantizer_ErrorDither.png | 4 +- ...artial_WernerPaletteQuantizer_NoDither.png | 4 +- ...l_WernerPaletteQuantizer_OrderedDither.png | 4 +- ...liphoraPartial_WuQuantizer_ErrorDither.png | 4 +- ...CalliphoraPartial_WuQuantizer_NoDither.png | 4 +- ...phoraPartial_WuQuantizer_OrderedDither.png | 4 +- tests/Images/Input/Png/issues/issue_2469.png | 3 + 82 files changed, 209 insertions(+), 180 deletions(-) create mode 100644 tests/Images/External/ReferenceOutput/PngEncoderTests/Issue2469_Quantized_Encode_Artifacts_Rgba32_issue_2469.png create mode 100644 tests/Images/Input/Png/issues/issue_2469.png diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 786248339b..0c6ba7ddc9 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -149,13 +149,13 @@ internal sealed class EuclideanPixelMap : IDisposable /// The granularity of the cache has been determined based upon the current /// suite of test images and provides the lowest possible memory usage while /// providing enough match accuracy. - /// Entry count is currently limited to 1185921 entries (2371842 bytes ~2.26MB). + /// Entry count is currently limited to 2335905 entries (4671810 bytes ~4.45MB). /// /// private unsafe struct ColorDistanceCache : IDisposable { private const int IndexBits = 5; - private const int IndexAlphaBits = 5; + private const int IndexAlphaBits = 6; private const int IndexCount = (1 << IndexBits) + 1; private const int IndexAlphaCount = (1 << IndexAlphaBits) + 1; private const int RgbShift = 8 - IndexBits; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index 97d7b02bea..2dfd99439a 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -7,6 +7,7 @@ using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors.Quantization; using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; @@ -537,7 +538,6 @@ public partial class PngDecoderTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(PngDecoder.Instance); - image.DebugSave(provider); PngMetadata metadata = image.Metadata.GetPngMetadata(); Assert.True(metadata.HasTransparency); } diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index 74038c7616..b4fda5d32f 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -129,8 +129,8 @@ public partial class PngEncoderTests PngFilterMethod.Adaptive, PngBitDepth.Bit8, interlaceMode, - appendPixelType: true, - appendPngColorType: true); + appendPngColorType: true, + appendPixelType: true); } } @@ -321,7 +321,7 @@ public partial class PngEncoderTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - using var ms = new MemoryStream(); + using MemoryStream ms = new(); image.Save(ms, PngEncoder); byte[] data = ms.ToArray().Take(8).ToArray(); @@ -344,13 +344,13 @@ public partial class PngEncoderTests [MemberData(nameof(RatioFiles))] public void Encode_PreserveRatio(string imagePath, int xResolution, int yResolution, PixelResolutionUnit resolutionUnit) { - var testFile = TestFile.Create(imagePath); + TestFile testFile = TestFile.Create(imagePath); using Image input = testFile.CreateRgba32Image(); - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); input.Save(memStream, PngEncoder); memStream.Position = 0; - using var output = Image.Load(memStream); + using Image output = Image.Load(memStream); ImageMetadata meta = output.Metadata; Assert.Equal(xResolution, meta.HorizontalResolution); Assert.Equal(yResolution, meta.VerticalResolution); @@ -361,13 +361,13 @@ public partial class PngEncoderTests [MemberData(nameof(PngBitDepthFiles))] public void Encode_PreserveBits(string imagePath, PngBitDepth pngBitDepth) { - var testFile = TestFile.Create(imagePath); + TestFile testFile = TestFile.Create(imagePath); using Image input = testFile.CreateRgba32Image(); - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); input.Save(memStream, PngEncoder); memStream.Position = 0; - using var output = Image.Load(memStream); + using Image output = Image.Load(memStream); PngMetadata meta = output.Metadata.GetPngMetadata(); Assert.Equal(pngBitDepth, meta.BitDepth); @@ -380,8 +380,8 @@ public partial class PngEncoderTests public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType colorType) { // arrange - var image = new Image(50, 50); - var encoder = new PngEncoder() + Image image = new(50, 50); + PngEncoder encoder = new() { TransparentColorMode = PngTransparentColorMode.Clear, ColorType = colorType @@ -391,7 +391,7 @@ public partial class PngEncoderTests { for (int y = 0; y < image.Height; y++) { - System.Span rowSpan = accessor.GetRowSpan(y); + Span rowSpan = accessor.GetRowSpan(y); // Half of the test image should be transparent. if (y > 25) @@ -407,12 +407,12 @@ public partial class PngEncoderTests }); // act - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); image.Save(memStream, encoder); // assert memStream.Position = 0; - using var actual = Image.Load(memStream); + using Image actual = Image.Load(memStream); Rgba32 expectedColor = Color.Blue; if (colorType is PngColorType.Grayscale or PngColorType.GrayscaleWithAlpha) { @@ -424,7 +424,7 @@ public partial class PngEncoderTests { for (int y = 0; y < accessor.Height; y++) { - System.Span rowSpan = accessor.GetRowSpan(y); + Span rowSpan = accessor.GetRowSpan(y); if (y > 25) { @@ -443,15 +443,15 @@ public partial class PngEncoderTests [MemberData(nameof(PngTrnsFiles))] public void Encode_PreserveTrns(string imagePath, PngBitDepth pngBitDepth, PngColorType pngColorType) { - var testFile = TestFile.Create(imagePath); + TestFile testFile = TestFile.Create(imagePath); using Image input = testFile.CreateRgba32Image(); PngMetadata inMeta = input.Metadata.GetPngMetadata(); Assert.True(inMeta.HasTransparency); - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); input.Save(memStream, PngEncoder); memStream.Position = 0; - using var output = Image.Load(memStream); + using Image output = Image.Load(memStream); PngMetadata outMeta = output.Metadata.GetPngMetadata(); Assert.True(outMeta.HasTransparency); @@ -501,8 +501,8 @@ public partial class PngEncoderTests PngFilterMethod.Adaptive, PngBitDepth.Bit8, interlaceMode, - appendPixelType: true, - appendPngColorType: true); + appendPngColorType: true, + appendPixelType: true); } } @@ -523,8 +523,8 @@ public partial class PngEncoderTests PngFilterMethod.Adaptive, PngBitDepth.Bit8, interlaceMode, - appendPixelType: true, - appendPngColorType: true); + appendPngColorType: true, + appendPixelType: true); } } @@ -538,13 +538,27 @@ public partial class PngEncoderTests public void EncodeFixesInvalidOptions() { // https://github.com/SixLabors/ImageSharp/issues/935 - using var ms = new MemoryStream(); - var testFile = TestFile.Create(TestImages.Png.Issue935); + using MemoryStream ms = new(); + TestFile testFile = TestFile.Create(TestImages.Png.Issue935); using Image image = testFile.CreateRgba32Image(PngDecoder.Instance); image.Save(ms, new PngEncoder { ColorType = PngColorType.RgbWithAlpha }); } + // https://github.com/SixLabors/ImageSharp/issues/2469 + [Theory] + [WithFile(TestImages.Png.Issue2469, PixelTypes.Rgba32)] + public void Issue2469_Quantized_Encode_Artifacts(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(PngDecoder.Instance); + PngEncoder encoder = new() { BitDepth = PngBitDepth.Bit8, ColorType = PngColorType.Palette }; + + string actualOutputFile = provider.Utility.SaveTestOutputFile(image, "png", encoder); + using Image encoded = Image.Load(actualOutputFile); + encoded.CompareToReferenceOutput(ImageComparer.Exact, provider); + } + private static void TestPngEncoderCore( TestImageProvider provider, PngColorType pngColorType, @@ -563,7 +577,7 @@ public partial class PngEncoderTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - var encoder = new PngEncoder + PngEncoder encoder = new() { ColorType = pngColorType, FilterMethod = pngFilterMethod, diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs index 17f04795dc..fd8b6af591 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs @@ -113,9 +113,15 @@ public partial class UniformUnmanagedMemoryPoolTests public static readonly bool Is32BitProcess = !Environment.Is64BitProcess; private static readonly List PressureArrays = new(); - [ConditionalFact(nameof(Is32BitProcess))] + [Fact] public static void GC_Collect_OnHighLoad_TrimsEntirePool() { + if (!Is32BitProcess) + { + // This test is only relevant for 32-bit processes. + return; + } + RemoteExecutor.Invoke(RunTest).Dispose(); static void RunTest() diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 8a676c02d3..1b0c559738 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -129,9 +129,12 @@ public static class TestImages // Issue 2209: https://github.com/SixLabors/ImageSharp/issues/2209 public const string Issue2209IndexedWithTransparency = "Png/issues/Issue_2209.png"; - // Issue 2259: https://github.com/SixLabors/ImageSharp/issues/2259 + // Issue 2259: https://github.com/SixLabors/ImageSharp/issues/2469 public const string Issue2259 = "Png/issues/Issue_2259.png"; + // Issue 2259: https://github.com/SixLabors/ImageSharp/issues/2469 + public const string Issue2469 = "Png/issues/issue_2469.png"; + public static class Bad { public const string MissingDataChunk = "Png/xdtn0g01.png"; diff --git a/tests/Images/External/ReferenceOutput/DitherTests/ApplyDitherFilterInBox_Rgba32_CalliphoraPartial.png b/tests/Images/External/ReferenceOutput/DitherTests/ApplyDitherFilterInBox_Rgba32_CalliphoraPartial.png index 79a43ed87a..f226b166e4 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/ApplyDitherFilterInBox_Rgba32_CalliphoraPartial.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/ApplyDitherFilterInBox_Rgba32_CalliphoraPartial.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d88eb2e50ca9dbed0e8dfe4ad278cd88ddb9d3408b30d9dfe59102b167f570b -size 262887 +oid sha256:98115a7087aced0c28cefa32a57bc72be245886cabeefc4ff7faf7984236218c +size 271226 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer16x16.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer16x16.png index f16ff0ef75..5961b0384d 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer16x16.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer16x16.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:97cfbef27319988b67aeac87d469d044edd925c90e4774170465f51eed85c16a -size 42915 +oid sha256:58c03e354b108033873e2a4c0b043ce15919c4d0630e6ca72ff70b89cbedb979 +size 44239 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer2x2.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer2x2.png index 05d26b6475..a2bbce465e 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer2x2.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer2x2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a799b69938507e3fd2a74ffa7c6c6ad6574acb25861a0a50cb8361520d468de -size 41809 +oid sha256:f987f4d270568facefc11eee7f81dd156af56c26b69fe3a6d2d2e9818652befa +size 43116 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer4x4.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer4x4.png index b437c0d034..727a45d0b1 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer4x4.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer4x4.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9932db58eeb966cd293b1b7a375e9c1b17b6d09153c679ebf03d42a08d2ce9b3 -size 43332 +oid sha256:ebdad83936e50bbb00fd74b7dd7d2f5a480bb7347aa3d151e7827107cd279bac +size 44441 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer8x8.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer8x8.png index 9e97e5f96c..5f9b599b7d 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer8x8.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Bayer8x8.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:67ebf42bc82483d1778254d95a376230437611dce91c80f8ecda608de56bffe7 -size 43108 +oid sha256:ccdf5937c30999e3b09071200de2e1db63b606ad9cbf6f7677a7499fb0b52963 +size 44252 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Ordered3x3.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Ordered3x3.png index b84521842c..b50fce4dc1 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Ordered3x3.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_Bike_Ordered3x3.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8d5cdda990ac146a7580f58cc2bcab72f903dde564a394de7df4cc37e6dcf2dd -size 43906 +oid sha256:baf70b732646d7c6cec60cfbe569ec673418dfb2dd0b5937bccfb91d9821d586 +size 45053 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer16x16.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer16x16.png index 436c676926..dfdb4f642f 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer16x16.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer16x16.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c11e6c197bd1c227ae8f4af7e8c232cfe75db6929ab12bddf5e6554fbaed3f01 -size 50716 +oid sha256:f6a1eae610ed730e4cec41693829929ba8db674886c2bd558f1b8893d2b76802 +size 51201 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer2x2.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer2x2.png index 6e1ad33117..c37ea9dcaf 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer2x2.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer2x2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:69ff9654eb61f2bfdd44fb25aff959c5b831015e283cc91a90e3abf6f681dc88 -size 52429 +oid sha256:ba674e0236c2e146c64a7f3e224c702030769304cd0fd624d1989536da341659 +size 52814 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer4x4.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer4x4.png index a257ccd615..d1ccc680b6 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer4x4.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer4x4.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6ee945ac5120e4198d1f94e6467cc0f77c90869bf5a09942e7720dddcfdfbe07 -size 51262 +oid sha256:316231c8d837f864cf62dcc79fdce698dc8c45c0327372de42c2b89eac1d9f81 +size 51851 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer8x8.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer8x8.png index d8cb415022..35ab5b75b8 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer8x8.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Bayer8x8.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1b023505175ae39a93fa55c85aa31466f0aca76fab0ee54f9667648b91f9aeb9 -size 50789 +oid sha256:b58144146585f50960dfd6ac5dc3f52238160287ae5f9b18c6796962cc3d2fd2 +size 51550 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Ordered3x3.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Ordered3x3.png index d6be5125f8..fde570043d 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Ordered3x3.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_WorksWithAllDitherers_CalliphoraPartial_Ordered3x3.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6b18e8b80035a3c5985ebedab5eaf1b0e580d26dd2a8167e687e7b3dd6536751 -size 51922 +oid sha256:6515be764d7026a87cfeea2d58344c404e4f15908139a25f413d51cc7cc61a0c +size 52216 diff --git a/tests/Images/External/ReferenceOutput/PngEncoderTests/Issue2469_Quantized_Encode_Artifacts_Rgba32_issue_2469.png b/tests/Images/External/ReferenceOutput/PngEncoderTests/Issue2469_Quantized_Encode_Artifacts_Rgba32_issue_2469.png new file mode 100644 index 0000000000..48e4261f1e --- /dev/null +++ b/tests/Images/External/ReferenceOutput/PngEncoderTests/Issue2469_Quantized_Encode_Artifacts_Rgba32_issue_2469.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef5a85b2adde25b5f343a18420fe787f5e159029a361a15ef2d6322eb7bb81fb +size 944597 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.25.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.25.png index fccbe25877..4b1e9fed20 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.25.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.25.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:97805a6a6de3cf1e97026a4913afa573f7ec40f82e718dd9c5e4df69482a6e19 -size 13097 +oid sha256:033bb9e0ce89ffe4abda4d409af5741958d4035f9c9824c28d7598d72c4db96f +size 13818 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.5.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.5.png index 8d0c3a5d99..cdf5f1a963 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.5.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3c7d3da0ced1c66c6351d530565a190cfc1fdb7f3b7b05d39844f61fb87871ad -size 13758 +oid sha256:9c6617ebf10f2fe1608fbc2a3c75f1a86ff4e3835b5d3fd7fcc2e5d0a4e5bbb1 +size 14380 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.75.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.75.png index cffaa87b48..2ad42755c6 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.75.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.75.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2a6bb9a04f0663eb8a95d6d46c72557078de35ac935499d5ec4ab591d7f59eb9 -size 13940 +oid sha256:5bb52f047f410e2b0bdcd8d186043f0d3b03835f39007775608fb05365ac9a20 +size 14616 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.png index fccbe25877..4b1e9fed20 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:97805a6a6de3cf1e97026a4913afa573f7ec40f82e718dd9c5e4df69482a6e19 -size 13097 +oid sha256:033bb9e0ce89ffe4abda4d409af5741958d4035f9c9824c28d7598d72c4db96f +size 13818 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_1.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_1.png index 8ea07490e3..aabb936bd8 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_1.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_ErrorDither_1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f0facae77f6022c92cdaaa7f27efb424962933c0e86ec4e8a7d62237a0f58d03 -size 13919 +oid sha256:47e0924ddbf191dca8932eb46b9c533d0983b9fbce956026b392d5fe589fb90a +size 14630 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.25.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.25.png index e7fe3bc772..0fe9cd8672 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.25.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.25.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ec99338895bdada5cabe504afdcb0c0c95d8951e4404d31615a406b9956995c0 -size 14154 +oid sha256:4ede7ffc5d07a09c7c5706e8e2554897d29acaabf71701191b0f689f2c22ae71 +size 17826 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.5.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.5.png index 853e368e3e..1e8cd88ffe 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.5.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9699207803467b8718a719c7581e1ed6bf0c923a5adaf325aea8358d274fece5 -size 18334 +oid sha256:f91c7f1f687c73dd909b629e40f703740270042507c47aa3834ccd38bf289dc3 +size 19394 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.75.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.75.png index 5ace2a5059..a9f7d76f80 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.75.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.75.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0e3acfa5b7c6ef3bec68b5fa8db91b2e6160e01d1f952a055831cea2f0a58b0f -size 18675 +oid sha256:2b836ab4e0f1c95fe5d553bf5bca37eac402ba431268d25e4641e86c952f5fdd +size 19802 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.png index fccbe25877..4b1e9fed20 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:97805a6a6de3cf1e97026a4913afa573f7ec40f82e718dd9c5e4df69482a6e19 -size 13097 +oid sha256:033bb9e0ce89ffe4abda4d409af5741958d4035f9c9824c28d7598d72c4db96f +size 13818 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_1.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_1.png index e4e4e10942..958eee6ad7 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_1.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_OctreeQuantizer_OrderedDither_1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fc1c1b5d0d0abec9b52ae7a83946a46020d2394a5f49f42e2ddb50fac988e974 -size 18874 +oid sha256:00bcd2ac107f45cb31efee44de275dd597eae6d2d4fda71c397416ff5f2f0914 +size 20175 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.25.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.25.png index d8e5bc5798..881ee4e58a 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.25.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.25.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2eac7954110e82c7c9cb1c0d3734467b7e46745ea19b2fd10d0af7df0aad552c -size 9007 +oid sha256:b04b71b0a4718e5b3f91c33c23ef792fc81a67c9fef7b9e4d80bdb9dce3539dd +size 9107 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.5.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.5.png index 2f0961df37..6804454813 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.5.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:51b06fc436e322ff9fc9e367b8117eb1178e112eb90fbd41a87847ab64a24136 -size 8801 +oid sha256:e0125454d2c3859d8457202856e21591ab96f61e2a29c3f017af29bf03961c48 +size 8883 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.75.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.75.png index 0858c8e20c..52ba79e98b 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.75.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.75.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e46c5f17ef76f11ca1dfe70dd4b38858de049832c26add1e9f987f87319a3491 -size 11029 +oid sha256:213ebd9fc7a190ad7226b487387edb9452284193cee4c4720448d7e19ef38e76 +size 11149 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.png index b8f2940f5c..fc26d1b766 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3527a0577720e7e8abf36b534540e72d17854d7b3b7d70cf3cdb519318e9e3c8 -size 7702 +oid sha256:43b21e948795abb52ebbbf94e785542e55488cc7f17996e2b92404ca8ad1a7cb +size 7844 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_1.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_1.png index c6818e906c..6f67736dd6 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_1.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_ErrorDither_1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e73014c6698526f3341e1f6001938bf5c60501bd6114451903a654c43c5f1997 -size 11719 +oid sha256:0bb8f730a43a8f58e4269905014461bab8dc8b47387ec86a84c1064b1cdabe14 +size 11813 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.25.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.25.png index b120b7fe98..22ce841b48 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.25.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.25.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:420d8ff32aa8ffa789e0c5dd00151856a016bc4f83ad035fdb4a8a22c338e247 -size 8952 +oid sha256:7500be583beb22759dec7e5bbb2a8d2230054366bfbd0e39bf10fdc8af63eb58 +size 8925 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.5.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.5.png index e58dac830f..2457c12e91 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.5.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:93f3be15cb660c7c74c0de12d459c390c5f3c950d09dc4bcf617f5093e2b818b -size 8606 +oid sha256:c48da7aad9c0aad576293d7085f9ddb2ea90a76d53bea54cbe0cb7aef71c7bb4 +size 9136 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.75.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.75.png index b6bb89b9ec..33ec41713e 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.75.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.75.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a035a0b97ac471500a9dbead47a0d13deb449136980b89795b671b3e14481c9e -size 9716 +oid sha256:72e6c327e98d9929a4d850905b1471fcd1191088feb38b028e4240e9f93b4996 +size 9827 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.png index b8f2940f5c..fc26d1b766 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3527a0577720e7e8abf36b534540e72d17854d7b3b7d70cf3cdb519318e9e3c8 -size 7702 +oid sha256:43b21e948795abb52ebbbf94e785542e55488cc7f17996e2b92404ca8ad1a7cb +size 7844 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_1.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_1.png index f6bae9649e..ea35c328c4 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_1.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WebSafePaletteQuantizer_OrderedDither_1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fac9fc2316ccf7a464e93d0406acdf37d5aac7f76f54c87454fa41b13c8224fc -size 9731 +oid sha256:70f8fc84d6e578822582ebee5888514dcd70c8d0da1a920f35e63a1617d1e92c +size 9841 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.25.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.25.png index beb4248eda..e2b742ca45 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.25.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.25.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c738cea16a714bdfa54cfcc213102d53ebe3aee576390902d352f04be65edac2 -size 11166 +oid sha256:ff4d6e3a7c8e69db0d5a88b7f1c91621692962bdbcedd6b8af1311506243bcde +size 11259 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.5.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.5.png index 7d271c8065..61a28a9cfd 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.5.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:42b44354480a1d2c869f541e6f3ed9feec15fb04ad32eb2a21b7d65290eeec54 -size 11972 +oid sha256:520910b75cae834b9844ce896ad9ab6d0b6c33c44c7bd822ce63752aaa2a8c5a +size 12122 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.75.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.75.png index 6ef7e65498..bfaf9e30ab 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.75.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.75.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d7d62b46acff22858a1621656ddaa97c3610a7f13df9c5d77747b7364620b174 -size 12772 +oid sha256:8e1fb4bb5d1591ac6bb8a4fb2504e2e836578c9c42d8286061cf4f57f0b7f97d +size 12876 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.png index 0062fbcb98..78576c467e 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9e532758291dd3d18b5b81c1d788db7854b322a633557f3ee273bb9d68c465ba -size 9582 +oid sha256:3f5babf5f6ae746a9b9f131ecf990f037c8e8bdb257bdbb7f6127460c9b8f98d +size 10507 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_1.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_1.png index e20bd0e4b0..71d771fe36 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_1.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_ErrorDither_1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:581febc9878288785ae82b23f2946dc0c506ae86fba32bb02ba5e69cf1c8cda1 -size 14069 +oid sha256:56a9088fdca14b82fa3ac3ecfb67b6b8e97e8d69b89907c8408e17861e8609e0 +size 14195 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.25.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.25.png index 3c2d6529fb..a68c99d4d9 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.25.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.25.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:12f7bacf0402f821e3c80f65c29218bc1f1334392edc463b617cf711667db722 -size 12381 +oid sha256:7d4ef129d8846e6802997c0ace90abdc7412d232e9a31fc53f25bb9f32de08f2 +size 12665 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.5.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.5.png index 07790191db..992ae04257 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.5.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:436d168a3501da20c327cb3d2909cdd465585ee3f76a2534e37a36771e10115e -size 12596 +oid sha256:69b5771a313aa777341d1460db94a7b3cc74b69c44f6c9d1a1b5b3734936e795 +size 12791 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.75.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.75.png index 49a4514226..7865b70d7a 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.75.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.75.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c952f81377c83b2255c427d0911b898e500d163d870de778b69778a9ab8c8278 -size 12459 +oid sha256:a56f72c5a12e6d216a32404c996e72721b4cf350d82071a43ebe44190adef94a +size 12895 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.png index 0062fbcb98..78576c467e 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9e532758291dd3d18b5b81c1d788db7854b322a633557f3ee273bb9d68c465ba -size 9582 +oid sha256:3f5babf5f6ae746a9b9f131ecf990f037c8e8bdb257bdbb7f6127460c9b8f98d +size 10507 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_1.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_1.png index 394f8f85b4..140af0ed89 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_1.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WernerPaletteQuantizer_OrderedDither_1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2b542c86ea4fef3a37e89c1087dddafeeccf523e7c0721743f34d35da5e0653e -size 13116 +oid sha256:39f85cb564a257381656fd969acaeda04016e09380133f772eb029e332aeaa95 +size 13482 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.25.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.25.png index 296267b8cf..1a53f430c6 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.25.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.25.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:147b7ebbe92f2379d513a44214a8383ed96a94b92f9d80cb3c5944e5e32e94bc -size 13097 +oid sha256:9d528ea896a2e56e0b8967d5ce3486078cbd7bf29e5f0d43a58ef21100147915 +size 13818 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.5.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.5.png index e710de72c8..90823958c7 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.5.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5b55add6cd3dc0e130f399a6932ba279aa29dc72579ee575df88e0faf76a3835 -size 13073 +oid sha256:4e96967a2a6362f42026ab2e2cdd82437e573c16a52c5631f7495cb30615441d +size 13841 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.75.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.75.png index fb03fbbf9c..f0270cd0ac 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.75.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.75.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed5c1745e2ef33654023ed0a8bfabe5a75d46186aa5c42df54ac1a9506dcf632 -size 13431 +oid sha256:d5f9e9e4f7f48681d5b240d6df6ae282c6b9e896eacc1ad73f2a097975fa8d29 +size 14060 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.png index 296267b8cf..1a53f430c6 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:147b7ebbe92f2379d513a44214a8383ed96a94b92f9d80cb3c5944e5e32e94bc -size 13097 +oid sha256:9d528ea896a2e56e0b8967d5ce3486078cbd7bf29e5f0d43a58ef21100147915 +size 13818 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_1.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_1.png index 28b9e8811d..636f8299aa 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_1.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_ErrorDither_1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:945c33feb2f3408b54e4574781eee3c2868885af25acd9172d420360e505b54a -size 13463 +oid sha256:97d6923c3342d600a9a2ab3fa713136b2649b74364d6e90a905de607838e0cb7 +size 14319 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.25.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.25.png index 554f587743..f287f604e0 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.25.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.25.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3edb6672168fc58a2bb6766d48a0883aa35fdc6873d2f4b9f26d3b5fa6cb46dd -size 15574 +oid sha256:66399a4ba262bdacdc5966fa9fc6f8f6bfa3f8c70db889363e9bbd5778dc1ecf +size 16081 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.5.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.5.png index fc6da7bbb1..f6a36e2035 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.5.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9fd79ec840f8bd82b41d93987187531187a4bd957d7f0d497a86fa61de52cec7 -size 16733 +oid sha256:5953a12a2fa67f9fe17485c62d156bb7f80a4bcf4124c123db4440c2559e0e69 +size 17002 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.75.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.75.png index 36015f6638..03519e0322 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.75.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.75.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:360121a75c96434daa57f2b996e9776cc1efdf25aa3f7e926abd6d04c9ee4184 -size 17355 +oid sha256:efc08c6969344de404692c2b367130e3f736442c0722067a9105f036a9e4511e +size 17616 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.png index 296267b8cf..1a53f430c6 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:147b7ebbe92f2379d513a44214a8383ed96a94b92f9d80cb3c5944e5e32e94bc -size 13097 +oid sha256:9d528ea896a2e56e0b8967d5ce3486078cbd7bf29e5f0d43a58ef21100147915 +size 13818 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_1.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_1.png index 777be644a4..c4c8d7aac3 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_1.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationWithDitheringScale_david_WuQuantizer_OrderedDither_1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:97d3b5d804c50da0d9c5db7278b16bb807e246dbd083c8c62ec7d4d7a65a1b45 -size 18070 +oid sha256:455488369cd943f3c3a0b2c402dbb17d6fc9c384b5f26dbc049634ad4bdab73f +size 18259 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_OctreeQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_OctreeQuantizer_ErrorDither.png index 8f4f0e32e6..ce6858e2d8 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_OctreeQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_OctreeQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7f7ce90fb4dec4b890eb8bfd182e009b2769104ab2f14e926381c4949d6f7453 -size 82121 +oid sha256:2a65ffa4c6b8488f52892306052337e17a4e58d28fa43f18009e6d1f997962de +size 83060 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_OctreeQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_OctreeQuantizer_NoDither.png index a0a5cc565d..651ed382fe 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_OctreeQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_OctreeQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2430b92bc20b2c3d142b5f84ae9fd62856fc4c717b0b226c2e096d725883d41f -size 54154 +oid sha256:1f69909cdc4b65548834e30caf44a31b7e5d41be1db05cb43bd8277613f327ed +size 55263 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_OctreeQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_OctreeQuantizer_OrderedDither.png index 4b7a06f302..501074f232 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_OctreeQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_OctreeQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4cd9433cdab37510cf6d98ce5838a69675359982376f7ef5c9e716c49772af74 -size 79370 +oid sha256:ff7d35f1ce04d8f2b6cee41c951487bd24e18f923dc84c77a7944ec3aab61540 +size 80844 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WebSafePaletteQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WebSafePaletteQuantizer_ErrorDither.png index 5d0c82e058..08ddd2deff 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WebSafePaletteQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WebSafePaletteQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d74faa8d188a2915739de64ba9d71b2132b53c8d154db22510c524ae757578a5 -size 61183 +oid sha256:48ac9eea396e010b1c110413a6861b1708f3928243271ea78f390e64dfe11737 +size 62249 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WebSafePaletteQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WebSafePaletteQuantizer_NoDither.png index 6fd875a6fd..da68bff3ce 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WebSafePaletteQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WebSafePaletteQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a5ad9cb26866b35f6ad8c0ae054c7172a15b2fb2512bd123af3c0e5685c30410 -size 32766 +oid sha256:a4786eb2c04be00302996f3ad65987f54fe5d80ded438fdcccf7b9bfe9520dbb +size 33930 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WebSafePaletteQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WebSafePaletteQuantizer_OrderedDither.png index 9e97e5f96c..5f9b599b7d 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WebSafePaletteQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WebSafePaletteQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:67ebf42bc82483d1778254d95a376230437611dce91c80f8ecda608de56bffe7 -size 43108 +oid sha256:ccdf5937c30999e3b09071200de2e1db63b606ad9cbf6f7677a7499fb0b52963 +size 44252 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WernerPaletteQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WernerPaletteQuantizer_ErrorDither.png index cfcafba1a7..60e5f18dc0 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WernerPaletteQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WernerPaletteQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b5271fba5dcee48982ccad321f987a67d6663dabc01d380eb0cafc178251bc00 -size 33971 +oid sha256:898c8524d6fcad8498a22dd97956265302458d43f8d3f93846c2268d7b47fb73 +size 35351 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WernerPaletteQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WernerPaletteQuantizer_NoDither.png index 2fc55fb4dd..cf7cba1811 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WernerPaletteQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WernerPaletteQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1ba613bc2cf88dfb357e88671464272ab4279667b8c776b8b9db913161b7f450 -size 33060 +oid sha256:5f37abc44b703b6feac3a2a950df7f40a8a67fe64fa25c19af59862e5272f0ff +size 34311 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WernerPaletteQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WernerPaletteQuantizer_OrderedDither.png index e3e48a17a6..8ddd2cf001 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WernerPaletteQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WernerPaletteQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:242379eee61c3d82f10e8b36db0567749443f91a6e13e766cc1ee3a3eeff7e2c -size 43006 +oid sha256:1cb4518f6b9e1ed1409b0f4e87c17ae990cff2725c650d69941cc76ba90b2f7b +size 44672 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WuQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WuQuantizer_ErrorDither.png index 50d141aa1d..e2fc05dd92 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WuQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WuQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fe72f6268d445f204afcea4723624398ff49e479e8b608843cf287dfb94ebe4e -size 101257 +oid sha256:16a592718ba5aa15f79ef4864cba75fae5a7cc5e13ca56eeab5fd13a0e5347de +size 102049 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WuQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WuQuantizer_NoDither.png index e555a2cbd9..fb44b61f9e 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WuQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WuQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c29c21979beeb7f659979893d05d1da15602a8fbc4a61309cd6380b296d69367 -size 83563 +oid sha256:86ebb09209d4bfbe266c633df1c7062755cd413f47d0a96a05bcf003a02cb12b +size 84428 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WuQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WuQuantizer_OrderedDither.png index 54cacf5a10..b4ff7af8d8 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WuQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_Bike_WuQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:49e072dc73ba96dffa021b3e9bbf169102bd9ae7b9d4ed0a69b55178f1592ae5 -size 97415 +oid sha256:779521e132b4ee6b3ac7a9186fca3250c6d2ace7e55f4f6c9601fe5393d9eb10 +size 99561 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_OctreeQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_OctreeQuantizer_ErrorDither.png index bbe5e4a20a..8b5956b1ac 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_OctreeQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_OctreeQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8c6041ecc220ee8cd576aff06871bc1f3b7363dffe334bbab83344c5b96cbde3 -size 94511 +oid sha256:a6d0b12e19b980fd558a4920ec18620a9bdb00bd1379a20719ff0ee92c6887a1 +size 96007 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_OctreeQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_OctreeQuantizer_NoDither.png index a09d04c793..e1122365e9 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_OctreeQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_OctreeQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:912de82dc98a8dd72ffc5549125c397379a859a23ffe48f01e4f1c5a28ff1d18 -size 77029 +oid sha256:82c34b115c081a1f3723540b9a273724353930c53006dd6daea576a227271e01 +size 78599 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_OctreeQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_OctreeQuantizer_OrderedDither.png index 44139c4e00..30cfcf2dea 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_OctreeQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_OctreeQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bedb363c412c4c387fabe4d65ca769079376f4cc56a3bfdd767f0ae8441b3dfb -size 92003 +oid sha256:6fbe71277a196e5c57fba7caba5c0a1b2bff2da9eadbd7bab1ae1853fab2dd93 +size 92581 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WebSafePaletteQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WebSafePaletteQuantizer_ErrorDither.png index a41b9989f8..d79f324a77 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WebSafePaletteQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WebSafePaletteQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d4a64da29f144d4d4c525ea45e56819e02a46030ae09542be01fdd8ffc85a295 -size 60377 +oid sha256:b1061a363744661febdd051ef2f6839bfe288eb83f7ebf281fb06717fbe6703a +size 60739 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WebSafePaletteQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WebSafePaletteQuantizer_NoDither.png index 9cbb203986..03baa702a7 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WebSafePaletteQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WebSafePaletteQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eee438f7cbe6615bab0df73689f6924ea153da28eaf1f4c0c22076f24f18085d -size 46476 +oid sha256:cacd80b681c086310d3be7d90575da357e6ab0a62e24227a1e7e3ae4cab1de2d +size 46905 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png index d8cb415022..35ab5b75b8 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1b023505175ae39a93fa55c85aa31466f0aca76fab0ee54f9667648b91f9aeb9 -size 50789 +oid sha256:b58144146585f50960dfd6ac5dc3f52238160287ae5f9b18c6796962cc3d2fd2 +size 51550 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WernerPaletteQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WernerPaletteQuantizer_ErrorDither.png index d7c0cbc019..dfcc0603dc 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WernerPaletteQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WernerPaletteQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c175f0db79d3ac74043dce3fe57d5c15c6ca38c954c008baf5fa917d3b9d4e0e -size 67374 +oid sha256:d54a2b762a16c76ad52919708d0126ae63958e9d900e3870cced695540e16192 +size 68366 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WernerPaletteQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WernerPaletteQuantizer_NoDither.png index 529557d9d8..c1c66f8409 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WernerPaletteQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WernerPaletteQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7c76f0df12da8eac1fefb6ba9c0c89f5c8a7bcfbff442a4ebd763f1a4b359637 -size 63046 +oid sha256:87450152fdccfaebb55e22040206cb246bc59b61461fd8b6ca6e099256fa0f1d +size 63839 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png index efbb6a013b..f79a145a6e 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f2636953295972ede173dbfaf3b67f7cb91f1c3f4ccc79f70e078bd94af9422d -size 68579 +oid sha256:7136f92f3fd1927e98204b1140ca36a901dcd9b67c17f7080413588c2e2dcc28 +size 69579 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WuQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WuQuantizer_ErrorDither.png index ca83b5de0d..79cec59e5f 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WuQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WuQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:68e401e5f9aeb4c5fa0b8413871436f1eb33fe5eb82026f2ad5665169a13d0de -size 112784 +oid sha256:ab5972eaa6b008b9768f3af4c61957db3d6da41cdf52696c05ecd3f2efaf3d5f +size 113964 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WuQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WuQuantizer_NoDither.png index 485f36f456..159e284c59 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WuQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WuQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7a59de505b2f7f0f14a3bc513f477f6ae6fd3a72ff7bc7c628a4efba18fed565 -size 108009 +oid sha256:46c6b9eb83c6d4ffafc2163b0e0ccd5aa24ac56bb65e8cf5f02b80319cf29e4b +size 108931 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WuQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WuQuantizer_OrderedDither.png index c29d9ec100..c11f7ac792 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WuQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantization_CalliphoraPartial_WuQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a65928b17616922155b030737af67de806c195bd993752a7d5e17ec7e94150fc -size 113919 +oid sha256:f54b00e54e8786c9c9ff8e8cf7e42111e06e5dc5d2e69ee2c8c8be2353030e43 +size 114680 diff --git a/tests/Images/Input/Png/issues/issue_2469.png b/tests/Images/Input/Png/issues/issue_2469.png new file mode 100644 index 0000000000..984df7d9d9 --- /dev/null +++ b/tests/Images/Input/Png/issues/issue_2469.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2be3ee00b78810d74f20a8b1c9ea3d68d8ec0560506dcccc8acda741d7c1251a +size 2392860 From 42336ba7f918f1f718b2a954b671629fd53f5b36 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Jun 2023 21:03:57 +1000 Subject: [PATCH 12/23] Fix #2447 --- .../Extensions/Drawing/DrawImageExtensions.cs | 162 +++++++++--------- .../Processors/Drawing/DrawImageProcessor.cs | 31 ++-- .../DrawImageProcessor{TPixelBg,TPixelFg}.cs | 132 +++++++------- .../Drawing/DrawImageTests.cs | 73 ++++++-- tests/ImageSharp.Tests/TestImages.cs | 3 + .../Drawing/DrawImageTests/Issue2447_A.png | 3 + .../Drawing/DrawImageTests/Issue2447_B.png | 3 + .../Drawing/DrawImageTests/Issue2447_C.png | 3 + tests/Images/Input/Png/issues/issue_2447.png | 3 + 9 files changed, 249 insertions(+), 164 deletions(-) create mode 100644 tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/Issue2447_A.png create mode 100644 tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/Issue2447_B.png create mode 100644 tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/Issue2447_C.png create mode 100644 tests/Images/Input/Png/issues/issue_2447.png diff --git a/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs b/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs index ad93d6f167..25e504831d 100644 --- a/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs @@ -15,277 +15,277 @@ public static class DrawImageExtensions /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. + /// The image to draw on the currently processing image. /// The opacity of the image to draw. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, + Image foreground, float opacity) { GraphicsOptions options = source.GetGraphicsOptions(); - return DrawImage(source, image, options.ColorBlendingMode, options.AlphaCompositionMode, opacity); + return DrawImage(source, foreground, options.ColorBlendingMode, options.AlphaCompositionMode, opacity); } /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. - /// The rectangle structure that specifies the portion of the image to draw. + /// The image to draw on the currently processing image. + /// The rectangle structure that specifies the portion of the image to draw. /// The opacity of the image to draw. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, - Rectangle rectangle, + Image foreground, + Rectangle foregroundRectangle, float opacity) { GraphicsOptions options = source.GetGraphicsOptions(); - return DrawImage(source, image, rectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity); + return DrawImage(source, foreground, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity); } /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. + /// The image to draw on the currently processing image. /// The color blending mode. /// The opacity of the image to draw. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, + Image foreground, PixelColorBlendingMode colorBlending, float opacity) - => DrawImage(source, image, Point.Empty, colorBlending, opacity); + => DrawImage(source, foreground, Point.Empty, colorBlending, opacity); /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. - /// The rectangle structure that specifies the portion of the image to draw. + /// The image to draw on the currently processing image. + /// The rectangle structure that specifies the portion of the image to draw. /// The color blending mode. /// The opacity of the image to draw. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, - Rectangle rectangle, + Image foreground, + Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, float opacity) - => DrawImage(source, image, rectangle, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity); + => DrawImage(source, foreground, foregroundRectangle, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity); /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. + /// The image to draw on the currently processing image. /// The color blending mode. /// The alpha composition mode. /// The opacity of the image to draw. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, + Image foreground, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity) - => DrawImage(source, image, Point.Empty, colorBlending, alphaComposition, opacity); + => DrawImage(source, foreground, Point.Empty, colorBlending, alphaComposition, opacity); /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. - /// The rectangle structure that specifies the portion of the image to draw. + /// The image to draw on the currently processing image. + /// The rectangle structure that specifies the portion of the image to draw. /// The color blending mode. /// The alpha composition mode. /// The opacity of the image to draw. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, - Rectangle rectangle, + Image foreground, + Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity) - => DrawImage(source, image, Point.Empty, rectangle, colorBlending, alphaComposition, opacity); + => DrawImage(source, foreground, Point.Empty, foregroundRectangle, colorBlending, alphaComposition, opacity); /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. + /// The image to draw on the currently processing image. /// The options, including the blending type and blending amount. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, + Image foreground, GraphicsOptions options) - => DrawImage(source, image, Point.Empty, options); + => DrawImage(source, foreground, Point.Empty, options); /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. - /// The rectangle structure that specifies the portion of the image to draw. + /// The image to draw on the currently processing image. + /// The rectangle structure that specifies the portion of the image to draw. /// The options, including the blending type and blending amount. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, - Rectangle rectangle, + Image foreground, + Rectangle foregroundRectangle, GraphicsOptions options) - => DrawImage(source, image, Point.Empty, rectangle, options); + => DrawImage(source, foreground, Point.Empty, foregroundRectangle, options); /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. - /// The location on the currenty processing image at which to draw. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. /// The opacity of the image to draw. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, - Point location, + Image foreground, + Point backgroundLocation, float opacity) { GraphicsOptions options = source.GetGraphicsOptions(); - return DrawImage(source, image, location, options.ColorBlendingMode, options.AlphaCompositionMode, opacity); + return DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, opacity); } /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. - /// The location on the currenty processing image at which to draw. - /// The rectangle structure that specifies the portion of the image to draw. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The rectangle structure that specifies the portion of the image to draw. /// The opacity of the image to draw. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, - Point location, - Rectangle rectangle, + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, float opacity) { GraphicsOptions options = source.GetGraphicsOptions(); - return DrawImage(source, image, location, rectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity); + return DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity); } /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. - /// The location on the currenty processing image at which to draw. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. /// The color blending to apply. /// The opacity of the image to draw. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, - Point location, + Image foreground, + Point backgroundLocation, PixelColorBlendingMode colorBlending, float opacity) - => DrawImage(source, image, location, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity); + => DrawImage(source, foreground, backgroundLocation, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity); /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. - /// The location on the currenty processing image at which to draw. - /// The rectangle structure that specifies the portion of the image to draw. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The rectangle structure that specifies the portion of the image to draw. /// The color blending to apply. /// The opacity of the image to draw. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, - Point location, - Rectangle rectangle, + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, float opacity) - => DrawImage(source, image, location, rectangle, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity); + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity); /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. - /// The location on the currenty processing image at which to draw. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. /// The options containing the blend mode and opacity. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, - Point location, + Image foreground, + Point backgroundLocation, GraphicsOptions options) - => DrawImage(source, image, location, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage); + => DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage); /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. - /// The location on the currenty processing image at which to draw. - /// The rectangle structure that specifies the portion of the image to draw. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The rectangle structure that specifies the portion of the image to draw. /// The options containing the blend mode and opacity. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, - Point location, - Rectangle rectangle, + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, GraphicsOptions options) - => DrawImage(source, image, location, rectangle, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage); + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage); /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. - /// The location on the currenty processing image at which to draw. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. /// The color blending to apply. /// The alpha composition mode. /// The opacity of the image to draw. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, - Point location, + Image foreground, + Point backgroundLocation, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity) - => source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, alphaComposition, opacity)); + => source.ApplyProcessor(new DrawImageProcessor(foreground, backgroundLocation, foreground.Bounds, colorBlending, alphaComposition, opacity)); /// /// Draws the given image together with the currently processing image by blending their pixels. /// /// The current image processing context. - /// The image to draw on the currently processing image. - /// The location on the currenty processing image at which to draw. - /// The rectangle structure that specifies the portion of the image to draw. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The rectangle structure that specifies the portion of the image to draw. /// The color blending to apply. /// The alpha composition mode. /// The opacity of the image to draw. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, - Image image, - Point location, - Rectangle rectangle, + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity) => source.ApplyProcessor( - new DrawImageProcessor(image, location, colorBlending, alphaComposition, opacity), - rectangle); + new DrawImageProcessor(foreground, backgroundLocation, foregroundRectangle, colorBlending, alphaComposition, opacity), + foregroundRectangle); } diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs index 88b59b7dc6..98c17dc90a 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs @@ -15,19 +15,22 @@ public class DrawImageProcessor : IImageProcessor /// Initializes a new instance of the class. /// /// The image to blend. - /// The location to draw the blended image. + /// The location to draw the foreground image on the background. + /// The rectangular portion of the foreground image to draw. /// The blending mode to use when drawing the image. /// The Alpha blending mode to use when drawing the image. /// The opacity of the image to blend. public DrawImageProcessor( Image image, - Point location, + Point backgroundLocation, + Rectangle foregoundRectangle, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode, float opacity) { this.Image = image; - this.Location = location; + this.BackgroundLocation = backgroundLocation; + this.ForegroundRectangle = foregoundRectangle; this.ColorBlendingMode = colorBlendingMode; this.AlphaCompositionMode = alphaCompositionMode; this.Opacity = opacity; @@ -39,9 +42,14 @@ public class DrawImageProcessor : IImageProcessor public Image Image { get; } /// - /// Gets the location to draw the blended image. + /// Gets the location to draw the foreground image on the background. /// - public Point Location { get; } + public Point BackgroundLocation { get; } + + /// + /// Gets the rectangular portion of the foreground image to draw. + /// + public Rectangle ForegroundRectangle { get; } /// /// Gets the blending mode to use when drawing the image. @@ -62,7 +70,7 @@ public class DrawImageProcessor : IImageProcessor public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) where TPixelBg : unmanaged, IPixel { - ProcessorFactoryVisitor visitor = new(configuration, this, source, sourceRectangle); + ProcessorFactoryVisitor visitor = new(configuration, this, source); this.Image.AcceptVisitor(visitor); return visitor.Result!; } @@ -73,14 +81,15 @@ public class DrawImageProcessor : IImageProcessor private readonly Configuration configuration; private readonly DrawImageProcessor definition; private readonly Image source; - private readonly Rectangle sourceRectangle; - public ProcessorFactoryVisitor(Configuration configuration, DrawImageProcessor definition, Image source, Rectangle sourceRectangle) + public ProcessorFactoryVisitor( + Configuration configuration, + DrawImageProcessor definition, + Image source) { this.configuration = configuration; this.definition = definition; this.source = source; - this.sourceRectangle = sourceRectangle; } public IImageProcessor? Result { get; private set; } @@ -91,8 +100,8 @@ public class DrawImageProcessor : IImageProcessor this.configuration, image, this.source, - this.sourceRectangle, - this.definition.Location, + this.definition.BackgroundLocation, + this.definition.ForegroundRectangle, this.definition.ColorBlendingMode, this.definition.AlphaCompositionMode, this.definition.Opacity); diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs index 436a447972..378ea20fa8 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs @@ -21,36 +21,42 @@ internal class DrawImageProcessor : ImageProcessor /// Initializes a new instance of the class. /// /// The configuration which allows altering default behaviour or extending the library. - /// The foreground to blend with the currently processing image. - /// The source for the current processor instance. - /// The source area to process for the current processor instance. - /// The location to draw the blended image. + /// The foreground to blend with the currently processing image. + /// The source for the current processor instance. + /// The location to draw the blended image. + /// The source area to process for the current processor instance. /// The blending mode to use when drawing the image. - /// The Alpha blending mode to use when drawing the image. + /// The alpha blending mode to use when drawing the image. /// The opacity of the image to blend. Must be between 0 and 1. public DrawImageProcessor( Configuration configuration, - Image image, - Image source, - Rectangle sourceRectangle, - Point location, + Image foregroundImage, + Image backgroundImage, + Point backgroundLocation, + Rectangle foregroundRectangle, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode, float opacity) - : base(configuration, source, sourceRectangle) + : base(configuration, backgroundImage, backgroundImage.Bounds) { Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); - this.Image = image; + this.ForegroundImage = foregroundImage; + this.ForegroundRectangle = foregroundRectangle; this.Opacity = opacity; this.Blender = PixelOperations.Instance.GetPixelBlender(colorBlendingMode, alphaCompositionMode); - this.Location = location; + this.BackgroundLocation = backgroundLocation; } /// /// Gets the image to blend /// - public Image Image { get; } + public Image ForegroundImage { get; } + + /// + /// Gets the rectangular portion of the foreground image to draw. + /// + public Rectangle ForegroundRectangle { get; } /// /// Gets the opacity of the image to blend @@ -65,43 +71,57 @@ internal class DrawImageProcessor : ImageProcessor /// /// Gets the location to draw the blended image /// - public Point Location { get; } + public Point BackgroundLocation { get; } /// protected override void OnFrameApply(ImageFrame source) { - Rectangle sourceRectangle = this.SourceRectangle; - Configuration configuration = this.Configuration; - - Image targetImage = this.Image; - PixelBlender blender = this.Blender; - int locationY = this.Location.Y; + // Align the bounds so that both the source and targets are the same width and height for blending. + // We ensure that negative locations are subtracted from both bounds so that foreground images can partially overlap. + Rectangle foregroundRectangle = this.ForegroundRectangle; - // Align start/end positions. - Rectangle bounds = targetImage.Bounds; + // Sanitize the location so that we don't try and sample outside the image. + int left = this.BackgroundLocation.X; + int top = this.BackgroundLocation.Y; - int minX = Math.Max(this.Location.X, sourceRectangle.X); - int maxX = Math.Min(this.Location.X + bounds.Width, sourceRectangle.Right); - int targetX = minX - this.Location.X; - - int minY = Math.Max(this.Location.Y, sourceRectangle.Y); - int maxY = Math.Min(this.Location.Y + bounds.Height, sourceRectangle.Bottom); - - int width = maxX - minX; + if (this.BackgroundLocation.X < 0) + { + foregroundRectangle.Width += this.BackgroundLocation.X; + left = 0; + } - Rectangle workingRect = Rectangle.FromLTRB(minX, minY, maxX, maxY); + if (this.BackgroundLocation.Y < 0) + { + foregroundRectangle.Height += this.BackgroundLocation.Y; + top = 0; + } - // Not a valid operation because rectangle does not overlap with this image. - if (workingRect.Width <= 0 || workingRect.Height <= 0) + int width = foregroundRectangle.Width; + int height = foregroundRectangle.Height; + if (width <= 0 || height <= 0) { - throw new ImageProcessingException( - "Cannot draw image because the source image does not overlap the target image."); + // Nothing to do, return. + return; } - DrawImageProcessor.RowOperation operation = new(source.PixelBuffer, targetImage.Frames.RootFrame.PixelBuffer, blender, configuration, minX, width, locationY, targetX, this.Opacity); + // Sanitize the dimensions so that we don't try and sample outside the image. + foregroundRectangle = Rectangle.Intersect(foregroundRectangle, this.ForegroundImage.Bounds); + Rectangle backgroundRectangle = Rectangle.Intersect(new(left, top, width, height), this.SourceRectangle); + Configuration configuration = this.Configuration; + + DrawImageProcessor.RowOperation operation = + new( + configuration, + source.PixelBuffer, + this.ForegroundImage.Frames.RootFrame.PixelBuffer, + backgroundRectangle, + foregroundRectangle, + this.Blender, + this.Opacity); + ParallelRowIterator.IterateRows( configuration, - workingRect, + new(0, 0, foregroundRectangle.Width, foregroundRectangle.Height), in operation); } @@ -110,36 +130,30 @@ internal class DrawImageProcessor : ImageProcessor /// private readonly struct RowOperation : IRowOperation { - private readonly Buffer2D source; - private readonly Buffer2D target; + private readonly Buffer2D background; + private readonly Buffer2D foreground; private readonly PixelBlender blender; private readonly Configuration configuration; - private readonly int minX; - private readonly int width; - private readonly int locationY; - private readonly int targetX; + private readonly Rectangle foregroundRectangle; + private readonly Rectangle backgroundRectangle; private readonly float opacity; [MethodImpl(InliningOptions.ShortMethod)] public RowOperation( - Buffer2D source, - Buffer2D target, - PixelBlender blender, Configuration configuration, - int minX, - int width, - int locationY, - int targetX, + Buffer2D background, + Buffer2D foreground, + Rectangle backgroundRectangle, + Rectangle foregroundRectangle, + PixelBlender blender, float opacity) { - this.source = source; - this.target = target; - this.blender = blender; this.configuration = configuration; - this.minX = minX; - this.width = width; - this.locationY = locationY; - this.targetX = targetX; + this.background = background; + this.foreground = foreground; + this.backgroundRectangle = backgroundRectangle; + this.foregroundRectangle = foregroundRectangle; + this.blender = blender; this.opacity = opacity; } @@ -147,8 +161,8 @@ internal class DrawImageProcessor : ImageProcessor [MethodImpl(InliningOptions.ShortMethod)] public void Invoke(int y) { - Span background = this.source.DangerousGetRowSpan(y).Slice(this.minX, this.width); - Span foreground = this.target.DangerousGetRowSpan(y - this.locationY).Slice(this.targetX, this.width); + Span background = this.background.DangerousGetRowSpan(y + this.backgroundRectangle.Top).Slice(this.backgroundRectangle.Left, this.backgroundRectangle.Width); + Span foreground = this.foreground.DangerousGetRowSpan(y + this.foregroundRectangle.Top).Slice(this.foregroundRectangle.Left, this.foregroundRectangle.Width); this.blender.Blend(this.configuration, background, background, foreground, this.opacity); } } diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs index d017e5ad42..c908ab3d44 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs @@ -112,9 +112,9 @@ public class DrawImageTests } [Theory] - [WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 0, 0)] - [WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 25, 25)] - [WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 75, 50)] + //[WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 0, 0)] + //[WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 25, 25)] + //[WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 75, 50)] [WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, -25, -30)] public void WorksWithDifferentLocations(TestImageProvider provider, int x, int y) { @@ -190,18 +190,65 @@ public class DrawImageTests } [Theory] - [WithSolidFilledImages(100, 100, 255, 255, 255, PixelTypes.Rgba32, -30, -30)] - [WithSolidFilledImages(100, 100, 255, 255, 255, PixelTypes.Rgba32, 130, -30)] - [WithSolidFilledImages(100, 100, 255, 255, 255, PixelTypes.Rgba32, 130, 130)] - [WithSolidFilledImages(100, 100, 255, 255, 255, PixelTypes.Rgba32, -30, 130)] - public void NonOverlappingImageThrows(TestImageProvider provider, int x, int y) + [WithFile(TestImages.Png.Issue2447, PixelTypes.Rgba32)] + public void Issue2447_A(TestImageProvider provider) + where TPixel : unmanaged, IPixel { - using Image background = provider.GetImage(); - using Image overlay = new(Configuration.Default, 10, 10, Color.Black); - ImageProcessingException ex = Assert.Throws(Test); + using Image foreground = provider.GetImage(); + using Image background = new(100, 100, new Rgba32(0, 255, 255)); - Assert.Contains("does not overlap", ex.ToString()); + background.Mutate(c => c.DrawImage(foreground, new Point(64, 10), new Rectangle(32, 32, 32, 32), 1F)); - void Test() => background.Mutate(context => context.DrawImage(overlay, new Point(x, y), new GraphicsOptions())); + background.DebugSave( + provider, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + + background.CompareToReferenceOutput( + provider, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + } + + [Theory] + [WithFile(TestImages.Png.Issue2447, PixelTypes.Rgba32)] + public void Issue2447_B(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image foreground = provider.GetImage(); + using Image background = new(100, 100, new Rgba32(0, 255, 255)); + + background.Mutate(c => c.DrawImage(foreground, new Point(10, 10), new Rectangle(320, 128, 32, 32), 1F)); + + background.DebugSave( + provider, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + + background.CompareToReferenceOutput( + provider, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + } + + [Theory] + [WithFile(TestImages.Png.Issue2447, PixelTypes.Rgba32)] + public void Issue2447_C(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image foreground = provider.GetImage(); + using Image background = new(100, 100, new Rgba32(0, 255, 255)); + + background.Mutate(c => c.DrawImage(foreground, new Point(10, 10), new Rectangle(32, 32, 32, 32), 1F)); + + background.DebugSave( + provider, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + + background.CompareToReferenceOutput( + provider, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); } } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 8a676c02d3..47e1809fc3 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -132,6 +132,9 @@ public static class TestImages // Issue 2259: https://github.com/SixLabors/ImageSharp/issues/2259 public const string Issue2259 = "Png/issues/Issue_2259.png"; + // Issue 2447: https://github.com/SixLabors/ImageSharp/issues/2447 + public const string Issue2447 = "Png/issues/Issue_2447.png"; + public static class Bad { public const string MissingDataChunk = "Png/xdtn0g01.png"; diff --git a/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/Issue2447_A.png b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/Issue2447_A.png new file mode 100644 index 0000000000..6bf7bb19b0 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/Issue2447_A.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2012789669110c08a00d37add7f53967b902bd617c90f85d7e90b13a32a0a429 +size 354 diff --git a/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/Issue2447_B.png b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/Issue2447_B.png new file mode 100644 index 0000000000..232184c4c2 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/Issue2447_B.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f628327efbf1e530d32dc092f2ab361de5ab35fe78db6b5e0274c71f1d170496 +size 363 diff --git a/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/Issue2447_C.png b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/Issue2447_C.png new file mode 100644 index 0000000000..fe4e44fbf8 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/Issue2447_C.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:40fc8f14b8f9e98fd73855f3dfada39062cc1aff874b3389133a55eb2e968f66 +size 354 diff --git a/tests/Images/Input/Png/issues/issue_2447.png b/tests/Images/Input/Png/issues/issue_2447.png new file mode 100644 index 0000000000..3b79487c59 --- /dev/null +++ b/tests/Images/Input/Png/issues/issue_2447.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:52f7e55f812db926d95ac1ab0c3235fbaca53331b99f73e65f3c1c2094503e20 +size 15824 From bc29fbfb84bcd387468befeb0efaf86826e01193 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Jun 2023 21:08:41 +1000 Subject: [PATCH 13/23] Restore tests --- tests/ImageSharp.Tests/Drawing/DrawImageTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs index c908ab3d44..8b0db773ab 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs @@ -112,9 +112,9 @@ public class DrawImageTests } [Theory] - //[WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 0, 0)] - //[WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 25, 25)] - //[WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 75, 50)] + [WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 0, 0)] + [WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 25, 25)] + [WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 75, 50)] [WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, -25, -30)] public void WorksWithDifferentLocations(TestImageProvider provider, int x, int y) { From 3f65ff61b349cde06bb2020fe46976b695663c8f Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Jun 2023 22:23:51 +1000 Subject: [PATCH 14/23] Restore constructor, fix casing --- .../Processors/Drawing/DrawImageProcessor.cs | 34 ++++++++++++++----- tests/ImageSharp.Tests/TestImages.cs | 2 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs index 98c17dc90a..6ecf16fc6b 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs @@ -14,23 +14,41 @@ public class DrawImageProcessor : IImageProcessor /// /// Initializes a new instance of the class. /// - /// The image to blend. + /// The image to blend. /// The location to draw the foreground image on the background. - /// The rectangular portion of the foreground image to draw. /// The blending mode to use when drawing the image. /// The Alpha blending mode to use when drawing the image. /// The opacity of the image to blend. public DrawImageProcessor( - Image image, + Image foreground, Point backgroundLocation, - Rectangle foregoundRectangle, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode, float opacity) + : this(foreground, backgroundLocation, foreground.Bounds, colorBlendingMode, alphaCompositionMode, opacity) { - this.Image = image; + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend. + /// The location to draw the foreground image on the background. + /// The rectangular portion of the foreground image to draw. + /// The blending mode to use when drawing the image. + /// The Alpha blending mode to use when drawing the image. + /// The opacity of the image to blend. + public DrawImageProcessor( + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, + PixelColorBlendingMode colorBlendingMode, + PixelAlphaCompositionMode alphaCompositionMode, + float opacity) + { + this.ForeGround = foreground; this.BackgroundLocation = backgroundLocation; - this.ForegroundRectangle = foregoundRectangle; + this.ForegroundRectangle = foregroundRectangle; this.ColorBlendingMode = colorBlendingMode; this.AlphaCompositionMode = alphaCompositionMode; this.Opacity = opacity; @@ -39,7 +57,7 @@ public class DrawImageProcessor : IImageProcessor /// /// Gets the image to blend. /// - public Image Image { get; } + public Image ForeGround { get; } /// /// Gets the location to draw the foreground image on the background. @@ -71,7 +89,7 @@ public class DrawImageProcessor : IImageProcessor where TPixelBg : unmanaged, IPixel { ProcessorFactoryVisitor visitor = new(configuration, this, source); - this.Image.AcceptVisitor(visitor); + this.ForeGround.AcceptVisitor(visitor); return visitor.Result!; } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 47e1809fc3..ee22c35414 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -133,7 +133,7 @@ public static class TestImages public const string Issue2259 = "Png/issues/Issue_2259.png"; // Issue 2447: https://github.com/SixLabors/ImageSharp/issues/2447 - public const string Issue2447 = "Png/issues/Issue_2447.png"; + public const string Issue2447 = "Png/issues/issue_2447.png"; public static class Bad { From ff9ed1259b0437f321324b2e4c833f559a14142d Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Jun 2023 22:42:36 +1000 Subject: [PATCH 15/23] Fix operations tests --- .../Drawing/DrawImageExtensionsTests.cs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageExtensionsTests.cs b/tests/ImageSharp.Tests/Drawing/DrawImageExtensionsTests.cs index 26129c5998..59e1bc4d88 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageExtensionsTests.cs @@ -13,11 +13,12 @@ public class DrawImageExtensionsTests : BaseImageOperationsExtensionTest [Fact] public void DrawImage_OpacityOnly_VerifyGraphicOptionsTakenFromContext() { - // non-default values as we cant easly defect usage otherwise + // non-default values as we cant easily defect usage otherwise this.options.AlphaCompositionMode = PixelAlphaCompositionMode.Xor; this.options.ColorBlendingMode = PixelColorBlendingMode.Screen; - this.operations.DrawImage(null, 0.5f); + using Image image = new(Configuration.Default, 1, 1); + this.operations.DrawImage(image, 0.5f); DrawImageProcessor dip = this.Verify(); Assert.Equal(0.5, dip.Opacity); @@ -28,11 +29,12 @@ public class DrawImageExtensionsTests : BaseImageOperationsExtensionTest [Fact] public void DrawImage_OpacityAndBlending_VerifyGraphicOptionsTakenFromContext() { - // non-default values as we cant easly defect usage otherwise + // non-default values as we cant easily defect usage otherwise this.options.AlphaCompositionMode = PixelAlphaCompositionMode.Xor; this.options.ColorBlendingMode = PixelColorBlendingMode.Screen; - this.operations.DrawImage(null, PixelColorBlendingMode.Multiply, 0.5f); + using Image image = new(Configuration.Default, 1, 1); + this.operations.DrawImage(image, PixelColorBlendingMode.Multiply, 0.5f); DrawImageProcessor dip = this.Verify(); Assert.Equal(0.5, dip.Opacity); @@ -43,11 +45,12 @@ public class DrawImageExtensionsTests : BaseImageOperationsExtensionTest [Fact] public void DrawImage_LocationAndOpacity_VerifyGraphicOptionsTakenFromContext() { - // non-default values as we cant easly defect usage otherwise + // non-default values as we cant easily defect usage otherwise this.options.AlphaCompositionMode = PixelAlphaCompositionMode.Xor; this.options.ColorBlendingMode = PixelColorBlendingMode.Screen; - this.operations.DrawImage(null, Point.Empty, 0.5f); + using Image image = new(Configuration.Default, 1, 1); + this.operations.DrawImage(image, Point.Empty, 0.5f); DrawImageProcessor dip = this.Verify(); Assert.Equal(0.5, dip.Opacity); @@ -58,11 +61,12 @@ public class DrawImageExtensionsTests : BaseImageOperationsExtensionTest [Fact] public void DrawImage_LocationAndOpacityAndBlending_VerifyGraphicOptionsTakenFromContext() { - // non-default values as we cant easly defect usage otherwise + // non-default values as we cant easily defect usage otherwise this.options.AlphaCompositionMode = PixelAlphaCompositionMode.Xor; this.options.ColorBlendingMode = PixelColorBlendingMode.Screen; - this.operations.DrawImage(null, Point.Empty, PixelColorBlendingMode.Multiply, 0.5f); + using Image image = new(Configuration.Default, 1, 1); + this.operations.DrawImage(image, Point.Empty, PixelColorBlendingMode.Multiply, 0.5f); DrawImageProcessor dip = this.Verify(); Assert.Equal(0.5, dip.Opacity); From 53fc42d1089ac1600ddf01af72c591d093d70b68 Mon Sep 17 00:00:00 2001 From: Ynse Hoornenborg Date: Mon, 19 Jun 2023 22:00:44 +0200 Subject: [PATCH 16/23] End each row on a byte boundary --- src/ImageSharp/Formats/Pbm/BinaryEncoder.cs | 34 +++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs b/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs index b179c775cf..ca1e4eaa2e 100644 --- a/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs +++ b/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs @@ -33,10 +33,14 @@ internal class BinaryEncoder { WriteGrayscale(configuration, stream, image); } - else + else if (componentType == PbmComponentType.Short) { WriteWideGrayscale(configuration, stream, image); } + else + { + throw new ImageFormatException("Component type not supported for Grayscale PBM."); + } } else if (colorType == PbmColorType.Rgb) { @@ -44,14 +48,25 @@ internal class BinaryEncoder { WriteRgb(configuration, stream, image); } - else + else if (componentType == PbmComponentType.Short) { WriteWideRgb(configuration, stream, image); } + else + { + throw new ImageFormatException("Component type not supported for Color PBM."); + } } else { - WriteBlackAndWhite(configuration, stream, image); + if (componentType == PbmComponentType.Bit) + { + WriteBlackAndWhite(configuration, stream, image); + } + else + { + throw new ImageFormatException("Component type not supported for Black & White PBM."); + } } } @@ -165,7 +180,6 @@ internal class BinaryEncoder Span rowSpan = row.GetSpan(); int previousValue = 0; - int startBit = 0; for (int y = 0; y < height; y++) { Span pixelSpan = pixelBuffer.DangerousGetRowSpan(y); @@ -178,7 +192,7 @@ internal class BinaryEncoder for (int x = 0; x < width;) { int value = previousValue; - for (int i = startBit; i < 8; i++) + for (int i = 0; i < 8; i++) { if (rowSpan[x].PackedValue < 128) { @@ -186,19 +200,15 @@ internal class BinaryEncoder } x++; + // End each row on a byte boundary. if (x == width) { - previousValue = value; - startBit = (i + 1) & 7; // Round off to below 8. break; } } - if (startBit == 0) - { - stream.WriteByte((byte)value); - previousValue = 0; - } + stream.WriteByte((byte)value); + previousValue = 0; } } } From bbc14f4ff529925a9e937168cc1ad54a6489c03e Mon Sep 17 00:00:00 2001 From: Ynse Hoornenborg Date: Wed, 21 Jun 2023 18:48:19 +0200 Subject: [PATCH 17/23] Row boundary on decode --- src/ImageSharp/Formats/Pbm/BinaryDecoder.cs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs b/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs index d49633575d..449548f3d2 100644 --- a/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs +++ b/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs @@ -152,7 +152,6 @@ internal class BinaryDecoder { int width = pixels.Width; int height = pixels.Height; - int startBit = 0; MemoryAllocator allocator = configuration.MemoryAllocator; using IMemoryOwner row = allocator.Allocate(width); Span rowSpan = row.GetSpan(); @@ -162,23 +161,11 @@ internal class BinaryDecoder for (int x = 0; x < width;) { int raw = stream.ReadByte(); - int bit = startBit; - startBit = 0; - for (; bit < 8; bit++) + for (int bit = 0; bit < 8; bit++) { bool bitValue = (raw & (0x80 >> bit)) != 0; rowSpan[x] = bitValue ? black : white; x++; - if (x == width) - { - startBit = (bit + 1) & 7; // Round off to below 8. - if (startBit != 0) - { - stream.Seek(-1, System.IO.SeekOrigin.Current); - } - - break; - } } } From 7e4825332b685992e8e965ed61b703125b7bdde7 Mon Sep 17 00:00:00 2001 From: Ynse Hoornenborg Date: Wed, 21 Jun 2023 19:14:21 +0200 Subject: [PATCH 18/23] Out of range fix --- src/ImageSharp/Formats/Pbm/BinaryDecoder.cs | 3 ++- src/ImageSharp/Formats/Pbm/BinaryEncoder.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs b/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs index 449548f3d2..f629282340 100644 --- a/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs +++ b/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs @@ -161,7 +161,8 @@ internal class BinaryDecoder for (int x = 0; x < width;) { int raw = stream.ReadByte(); - for (int bit = 0; bit < 8; bit++) + int stopBit = Math.Min(8, width - x); + for (int bit = 0; bit < stopBit; bit++) { bool bitValue = (raw & (0x80 >> bit)) != 0; rowSpan[x] = bitValue ? black : white; diff --git a/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs b/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs index ca1e4eaa2e..b9bc812f0d 100644 --- a/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs +++ b/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs @@ -192,7 +192,8 @@ internal class BinaryEncoder for (int x = 0; x < width;) { int value = previousValue; - for (int i = 0; i < 8; i++) + int stopBit = Math.Min(8, width - x); + for (int i = 0; i < stopBit; i++) { if (rowSpan[x].PackedValue < 128) { From c60cae82acbaf58e16a03869c2c1ddd9689d8ddc Mon Sep 17 00:00:00 2001 From: Ynse Hoornenborg Date: Wed, 21 Jun 2023 19:14:32 +0200 Subject: [PATCH 19/23] Tests --- tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs | 1 + tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs | 6 ++++++ tests/ImageSharp.Tests/TestImages.cs | 1 + .../PbmDecoderTests/DecodeReferenceImage_L8_issue2477.png | 3 +++ tests/Images/Input/Pbm/issue2477.pbm | 3 +++ 5 files changed, 14 insertions(+) create mode 100644 tests/Images/External/ReferenceOutput/PbmDecoderTests/DecodeReferenceImage_L8_issue2477.png create mode 100644 tests/Images/Input/Pbm/issue2477.pbm diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs index 5bdab7b37a..1b57663f3a 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs @@ -81,6 +81,7 @@ public class PbmDecoderTests [Theory] [WithFile(BlackAndWhitePlain, PixelTypes.L8, "pbm")] [WithFile(BlackAndWhiteBinary, PixelTypes.L8, "pbm")] + [WithFile(Issue2477, PixelTypes.L8, "pbm")] [WithFile(GrayscalePlain, PixelTypes.L8, "pgm")] [WithFile(GrayscalePlainNormalized, PixelTypes.L8, "pgm")] [WithFile(GrayscaleBinary, PixelTypes.L8, "pgm")] diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs index a0a4c1164f..05f1d963b2 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs @@ -26,6 +26,7 @@ public class PbmEncoderTests { { BlackAndWhiteBinary, PbmColorType.BlackAndWhite }, { BlackAndWhitePlain, PbmColorType.BlackAndWhite }, + { Issue2477, PbmColorType.BlackAndWhite }, { GrayscaleBinary, PbmColorType.Grayscale }, { GrayscaleBinaryWide, PbmColorType.Grayscale }, { GrayscalePlain, PbmColorType.Grayscale }, @@ -96,6 +97,11 @@ public class PbmEncoderTests public void PbmEncoder_P4_Works(TestImageProvider provider) where TPixel : unmanaged, IPixel => TestPbmEncoderCore(provider, PbmColorType.BlackAndWhite, PbmEncoding.Binary); + [Theory] + [WithFile(Issue2477, PixelTypes.Rgb24)] + public void PbmEncoder_P4_Irregular_Works(TestImageProvider provider) + where TPixel : unmanaged, IPixel => TestPbmEncoderCore(provider, PbmColorType.BlackAndWhite, PbmEncoding.Binary); + [Theory] [WithFile(GrayscalePlainMagick, PixelTypes.Rgb24)] public void PbmEncoder_P2_Works(TestImageProvider provider) diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 39b8c95a9c..c4eb866c7c 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -1038,5 +1038,6 @@ public static class TestImages public const string RgbPlain = "Pbm/rgb_plain.ppm"; public const string RgbPlainNormalized = "Pbm/rgb_plain_normalized.ppm"; public const string RgbPlainMagick = "Pbm/rgb_plain_magick.ppm"; + public const string Issue2477 = "Pbm/issue2477.pbm"; } } diff --git a/tests/Images/External/ReferenceOutput/PbmDecoderTests/DecodeReferenceImage_L8_issue2477.png b/tests/Images/External/ReferenceOutput/PbmDecoderTests/DecodeReferenceImage_L8_issue2477.png new file mode 100644 index 0000000000..e8a70e6b41 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/PbmDecoderTests/DecodeReferenceImage_L8_issue2477.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:670bc844ba878afa0f03574dea23ab774ac0cc5aa371d0f4b4dff7da4d32f916 +size 2912 diff --git a/tests/Images/Input/Pbm/issue2477.pbm b/tests/Images/Input/Pbm/issue2477.pbm new file mode 100644 index 0000000000..0123c65ee2 --- /dev/null +++ b/tests/Images/Input/Pbm/issue2477.pbm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d625635f7be760fbea935056c0f6d046832dd74bba33a1597b52ab3dfe0c5e4e +size 4956 From eab151fada473198f4f722ec2384677ba917b573 Mon Sep 17 00:00:00 2001 From: Ynse Hoornenborg Date: Wed, 21 Jun 2023 19:20:45 +0200 Subject: [PATCH 20/23] Style fix --- src/ImageSharp/Formats/Pbm/BinaryEncoder.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs b/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs index b9bc812f0d..abb6d2fca1 100644 --- a/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs +++ b/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs @@ -201,6 +201,7 @@ internal class BinaryEncoder } x++; + // End each row on a byte boundary. if (x == width) { From 4c70682d09f26e29768a53786dce4df98823b8b0 Mon Sep 17 00:00:00 2001 From: Ynse Hoornenborg Date: Wed, 21 Jun 2023 22:33:08 +0200 Subject: [PATCH 21/23] Simplify code --- src/ImageSharp/Formats/Pbm/BinaryEncoder.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs b/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs index abb6d2fca1..dddc629b3e 100644 --- a/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs +++ b/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs @@ -179,7 +179,6 @@ internal class BinaryEncoder using IMemoryOwner row = allocator.Allocate(width); Span rowSpan = row.GetSpan(); - int previousValue = 0; for (int y = 0; y < height; y++) { Span pixelSpan = pixelBuffer.DangerousGetRowSpan(y); @@ -191,7 +190,7 @@ internal class BinaryEncoder for (int x = 0; x < width;) { - int value = previousValue; + int value = 0; int stopBit = Math.Min(8, width - x); for (int i = 0; i < stopBit; i++) { @@ -201,16 +200,9 @@ internal class BinaryEncoder } x++; - - // End each row on a byte boundary. - if (x == width) - { - break; - } } stream.WriteByte((byte)value); - previousValue = 0; } } } From 6c439092fd5b89dfddd6b67e13be5c869652a0ad Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sat, 24 Jun 2023 16:09:29 +0200 Subject: [PATCH 22/23] If we read a extension code, read the next 5 bits because some encoder write premature EOL codes instead of extension codes. Throw NotSupportedException, if its actually a Extension code. Fixes #2451 --- .../Compression/Decompressors/T6BitReader.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6BitReader.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6BitReader.cs index 8be0939d3a..fe71b204b1 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6BitReader.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6BitReader.cs @@ -125,13 +125,29 @@ internal sealed class T6BitReader : T4BitReader if (value == Len7Code0000000.Code) { this.Code = Len7Code0000000; - return false; + + // We do not support Extensions1D codes, but some encoders (scanner from epson) write a premature EOL code, + // which at this point cannot be distinguished from a distinguish, because we read the data bit by bit. + // Read the next 5 bit, if its a EOL code return true, indicating its the end of the image. + if (this.ReadValue(5) == 1) + { + return true; + } + + throw new NotSupportedException("ccitt extensions 1D codes are not supported."); } if (value == Len7Code0000001.Code) { this.Code = Len7Code0000001; - return false; + + // Same as above, we do not support Extensions2D codes, but it could be a EOL instead. + if (this.ReadValue(5) == 1) + { + return true; + } + + throw new NotSupportedException("ccitt extensions 2D codes are not supported."); } if (value == Len7Code0000011.Code) From 63aece9018cbf6fcaf5b794998da4d87f4dcaa6a Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 25 Jun 2023 14:47:26 +1000 Subject: [PATCH 23/23] Update src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6BitReader.cs --- .../Formats/Tiff/Compression/Decompressors/T6BitReader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6BitReader.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6BitReader.cs index fe71b204b1..ea03094878 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6BitReader.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6BitReader.cs @@ -127,7 +127,7 @@ internal sealed class T6BitReader : T4BitReader this.Code = Len7Code0000000; // We do not support Extensions1D codes, but some encoders (scanner from epson) write a premature EOL code, - // which at this point cannot be distinguished from a distinguish, because we read the data bit by bit. + // which at this point cannot be distinguished from the marker, because we read the data bit by bit. // Read the next 5 bit, if its a EOL code return true, indicating its the end of the image. if (this.ReadValue(5) == 1) {