From d9349204342c911befe5ee5262275d259b559f9d Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 23 May 2021 01:00:46 +0100 Subject: [PATCH 01/29] Fix octree for low bit rates --- .../Quantization/OctreeQuantizer{TPixel}.cs | 30 ++++--------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs index 700314f26c..0227d80d79 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs @@ -119,7 +119,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization } ref TPixel paletteRef = ref MemoryMarshal.GetReference(this.pixelMap.Palette.Span); - var index = (byte)this.octree.GetPaletteIndex(color); + byte index = (byte)this.octree.GetPaletteIndex(color); match = Unsafe.Add(ref paletteRef, index); return index; } @@ -176,21 +176,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization this.previousNode = null; } - /// - /// Gets the mask used when getting the appropriate pixels for a given node. - /// - private static ReadOnlySpan Mask => new byte[] - { - 0b10000000, - 0b1000000, - 0b100000, - 0b10000, - 0b1000, - 0b100, - 0b10, - 0b1 - }; - /// /// Gets or sets the number of leaves in the tree /// @@ -251,7 +236,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization [MethodImpl(InliningOptions.ShortMethod)] public void Palletize(Span palette, int colorCount, ref int paletteIndex) { - while (this.Leaves > colorCount - 1) + while (this.Leaves > colorCount) { this.Reduce(); } @@ -517,7 +502,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization child = this.children[i]; if (child != null) { - var childIndex = child.GetPaletteIndex(ref pixel, level + 1); + int childIndex = child.GetPaletteIndex(ref pixel, level + 1); if (childIndex != 0) { return childIndex; @@ -538,15 +523,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization [MethodImpl(InliningOptions.ShortMethod)] private static int GetColorIndex(ref Rgba32 color, int level) { - DebugGuard.MustBeLessThan(level, Mask.Length, nameof(level)); - int shift = 7 - level; - ref byte maskRef = ref MemoryMarshal.GetReference(Mask); - byte mask = Unsafe.Add(ref maskRef, level); + byte mask = (byte)(1 << shift); return ((color.R & mask) >> shift) - | ((color.G & mask) >> (shift - 1)) - | ((color.B & mask) >> (shift - 2)); + | (((color.G & mask) >> shift) << 1) + | (((color.B & mask) >> shift) << 2); } /// From eca0dae94504679c54ea1b675443003a51b22e6d Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 23 May 2021 01:01:05 +0100 Subject: [PATCH 02/29] Use octree for bitmap --- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 2 +- tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index 5cf54388d3..b407ad221f 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp this.memoryAllocator = memoryAllocator; this.bitsPerPixel = options.BitsPerPixel; this.writeV4Header = options.SupportTransparency; - this.quantizer = options.Quantizer ?? KnownQuantizers.Wu; + this.quantizer = options.Quantizer ?? KnownQuantizers.Octree; } /// diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs index 4eb3b900e1..70079ee6e5 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs @@ -343,7 +343,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp { BitsPerPixel = bitsPerPixel, SupportTransparency = supportTransparency, - Quantizer = quantizer ?? KnownQuantizers.Wu + Quantizer = quantizer ?? KnownQuantizers.Octree }; // Does DebugSave & load reference CompareToReferenceInput(): From 2ef5b519f071e6ad75d19204a597b0726ab065f5 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 5 Jun 2021 00:12:17 +0100 Subject: [PATCH 03/29] Use smarter distance cache --- .../Quantization/EuclideanPixelMap{TPixel}.cs | 113 +++++++++++++++--- 1 file changed, 96 insertions(+), 17 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index c194f402a3..dbd5194947 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -2,8 +2,6 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Collections.Concurrent; -using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using SixLabors.ImageSharp.PixelFormats; @@ -17,8 +15,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization internal readonly struct EuclideanPixelMap where TPixel : unmanaged, IPixel { - private readonly Vector4[] vectorCache; - private readonly ConcurrentDictionary distanceCache; + private readonly Rgba32[] rgbaPalette; + private readonly ColorDistanceCache cache; /// /// Initializes a new instance of the struct. @@ -29,11 +27,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization public EuclideanPixelMap(Configuration configuration, ReadOnlyMemory palette) { this.Palette = palette; - this.vectorCache = new Vector4[palette.Length]; - - // Use the same rules across all target frameworks. - this.distanceCache = new ConcurrentDictionary(Environment.ProcessorCount, 31); - PixelOperations.Instance.ToVector4(configuration, this.Palette.Span, this.vectorCache); + this.rgbaPalette = new Rgba32[palette.Length]; + this.cache = ColorDistanceCache.Create(); + PixelOperations.Instance.ToRgba32(configuration, this.Palette.Span, this.rgbaPalette); } /// @@ -57,11 +53,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization public int GetClosestColor(TPixel color, out TPixel match) { ref TPixel paletteRef = ref MemoryMarshal.GetReference(this.Palette.Span); + Unsafe.SkipInit(out Rgba32 rgba); + color.ToRgba32(ref rgba); // Check if the color is in the lookup table - if (!this.distanceCache.TryGetValue(color, out int index)) + if (!this.cache.TryGetValue(rgba, out short index)) { - return this.GetClosestColorSlow(color, ref paletteRef, out match); + return this.GetClosestColorSlow(rgba, ref paletteRef, out match); } match = Unsafe.Add(ref paletteRef, index); @@ -69,17 +67,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization } [MethodImpl(InliningOptions.ShortMethod)] - private int GetClosestColorSlow(TPixel color, ref TPixel paletteRef, out TPixel match) + private int GetClosestColorSlow(Rgba32 rgba, ref TPixel paletteRef, out TPixel match) { // Loop through the palette and find the nearest match. int index = 0; float leastDistance = float.MaxValue; - var vector = color.ToVector4(); - ref Vector4 vectorCacheRef = ref MemoryMarshal.GetReference(this.vectorCache); + ref Rgba32 rgbaPaletteRef = ref MemoryMarshal.GetReference(this.rgbaPalette); for (int i = 0; i < this.Palette.Length; i++) { - Vector4 candidate = Unsafe.Add(ref vectorCacheRef, i); - float distance = Vector4.DistanceSquared(vector, candidate); + Rgba32 candidate = Unsafe.Add(ref rgbaPaletteRef, i); + float distance = DistanceSquared(rgba, candidate); // If it's an exact match, exit the loop if (distance == 0) @@ -97,9 +94,91 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization } // Now I have the index, pop it into the cache for next time - this.distanceCache[color] = index; + this.cache.Add(rgba, (byte)index); match = Unsafe.Add(ref paletteRef, index); return index; } + + /// + /// Returns the Euclidean distance squared between two specified points. + /// + /// The first point. + /// The second point. + /// The distance squared. + [MethodImpl(InliningOptions.ShortMethod)] + private static float DistanceSquared(Rgba32 a, Rgba32 b) + { + int deltaB = a.B - b.B; + int deltaG = a.G - b.G; + int deltaR = a.R - b.R; + int deltaA = a.A - b.A; + return (deltaB * deltaB) + (deltaG * deltaG) + (deltaR * deltaR) + (deltaA * deltaA); + } + + /// + /// A cache for storing color distance matching results. + /// Not threadsafe but cache misses will be very rare and shouldn't + /// significantly negatively affect performance. + /// + /// + /// The cache is limited to 2471625 entries at 4MB. + /// This could be halfed by reducing the alpha accuracy but this treats + /// gradients less well in gifs than our previous cache implementation. + /// + private struct ColorDistanceCache + { + private const int IndexBits = 6; + private const int IndexAlphaBits = 3; + private const int IndexCount = (1 << IndexBits) + 1; + private const int IndexAlphaCount = (1 << IndexAlphaBits) + 1; + private const int RgbShift = 8 - IndexBits; + private const int AlphaShift = 8 - IndexAlphaBits; + private const int TableLength = IndexCount * IndexCount * IndexCount * IndexAlphaCount; + private short[] table; + + public static ColorDistanceCache Create() + { + ColorDistanceCache result = default; + short[] entries = new short[TableLength]; + entries.AsSpan().Fill(-1); + result.table = entries; + + return result; + } + + [MethodImpl(InliningOptions.ShortMethod)] + public void Add(Rgba32 rgba, byte index) + { + int r = rgba.R >> RgbShift; + int g = rgba.G >> RgbShift; + int b = rgba.B >> RgbShift; + int a = rgba.A >> AlphaShift; + int idx = GetPaletteIndex(r, g, b, a); + this.table[idx] = index; + } + + [MethodImpl(InliningOptions.ShortMethod)] + public bool TryGetValue(Rgba32 rgba, out short match) + { + int r = rgba.R >> RgbShift; + int g = rgba.G >> RgbShift; + int b = rgba.B >> RgbShift; + int a = rgba.A >> AlphaShift; + int idx = GetPaletteIndex(r, g, b, a); + match = this.table[idx]; + return match > -1; + } + + [MethodImpl(InliningOptions.ShortMethod)] + private static int GetPaletteIndex(int r, int g, int b, int a) + => (r << ((IndexBits * 2) + IndexAlphaBits)) + + (r << (IndexBits + IndexAlphaBits + 1)) + + (g << (IndexBits + IndexAlphaBits)) + + (r << (IndexBits * 2)) + + (r << (IndexBits + 1)) + + (g << IndexBits) + + ((r + g + b) << IndexAlphaBits) + + r + g + b + a; + } } } From db3c973f22ec1f42282d29b01f78c3f92f0b7261 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 5 Jun 2021 00:12:55 +0100 Subject: [PATCH 04/29] Fix octree transparency handling --- .../Quantization/OctreeQuantizer{TPixel}.cs | 16 +++++++--------- .../Quantization/WuQuantizer{TPixel}.cs | 5 ++--- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs index 0227d80d79..aaf9a0cecc 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs @@ -41,9 +41,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization this.Configuration = configuration; this.Options = options; - this.maxColors = this.Options.MaxColors; + this.maxColors = Math.Min(byte.MaxValue, this.Options.MaxColors); this.octree = new Octree(Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.maxColors), 1, 8)); - this.paletteOwner = configuration.MemoryAllocator.Allocate(this.maxColors, AllocationOptions.Clean); + this.paletteOwner = configuration.MemoryAllocator.Allocate(this.maxColors + 1, AllocationOptions.Clean); this.palette = default; this.pixelMap = default; this.isDithering = !(this.Options.Dither is null); @@ -90,14 +90,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization } } - Span paletteSpan = this.paletteOwner.GetSpan(); int paletteIndex = 0; + Span paletteSpan = this.paletteOwner.GetSpan(); this.octree.Palletize(paletteSpan, this.maxColors, ref paletteIndex); - // Length of reduced palette + transparency. - ReadOnlyMemory result = this.paletteOwner.Memory.Slice(0, Math.Min(paletteIndex + 2, this.maxColors)); + ReadOnlyMemory result = this.paletteOwner.Memory.Slice(0, paletteSpan.Length); this.pixelMap = new EuclideanPixelMap(this.Configuration, result); - this.palette = result; } @@ -118,7 +116,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization return (byte)this.pixelMap.GetClosestColor(color, out match); } - ref TPixel paletteRef = ref MemoryMarshal.GetReference(this.pixelMap.Palette.Span); + ref TPixel paletteRef = ref MemoryMarshal.GetReference(this.palette.Span); byte index = (byte)this.octree.GetPaletteIndex(color); match = Unsafe.Add(ref paletteRef, index); return index; @@ -254,7 +252,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization [MethodImpl(InliningOptions.ShortMethod)] public int GetPaletteIndex(TPixel color) { - Rgba32 rgba = default; + Unsafe.SkipInit(out Rgba32 rgba); color.ToRgba32(ref rgba); return this.root.GetPaletteIndex(ref rgba, 0); } @@ -453,7 +451,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization Vector3.Zero, new Vector3(255)); - TPixel pixel = default; + Unsafe.SkipInit(out TPixel pixel); pixel.FromRgba32(new Rgba32((byte)vector.X, (byte)vector.Y, (byte)vector.Z, byte.MaxValue)); palette[index] = pixel; diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs index e449678559..80b2c3ef4b 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs @@ -6,7 +6,6 @@ using System.Buffers; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -142,7 +141,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization } } - ReadOnlyMemory result = this.paletteOwner.Memory.Slice(0, this.maxColors); + ReadOnlyMemory result = this.paletteOwner.Memory.Slice(0, paletteSpan.Length); this.pixelMap = new EuclideanPixelMap(this.Configuration, result); this.palette = result; } @@ -170,7 +169,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization ReadOnlySpan tagSpan = this.tagsOwner.GetSpan(); byte index = tagSpan[GetPaletteIndex(r + 1, g + 1, b + 1, a + 1)]; - ref TPixel paletteRef = ref MemoryMarshal.GetReference(this.pixelMap.Palette.Span); + ref TPixel paletteRef = ref MemoryMarshal.GetReference(this.palette.Span); match = Unsafe.Add(ref paletteRef, index); return index; } From 08c36f23b2a78ad6d214096bba063b89de68715c Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 5 Jun 2021 13:25:59 +0100 Subject: [PATCH 05/29] Fix Wu palette, reduce memory usage --- .../Extensions/Dithering/DitherExtensions.cs | 16 +++++++------- .../Quantization/EuclideanPixelMap{TPixel}.cs | 6 ++---- .../Quantization/OctreeQuantizer{TPixel}.cs | 21 +++++++++++++++---- .../Quantization/WuQuantizer{TPixel}.cs | 5 +++-- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/ImageSharp/Processing/Extensions/Dithering/DitherExtensions.cs b/src/ImageSharp/Processing/Extensions/Dithering/DitherExtensions.cs index f4664a5c0f..296ed71b72 100644 --- a/src/ImageSharp/Processing/Extensions/Dithering/DitherExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Dithering/DitherExtensions.cs @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Processing Dither(source, KnownDitherings.Bayer8x8); /// - /// Dithers the image reducing it to a web-safe palette using ordered dithering. + /// Dithers the image reducing it to a web-safe palette. /// /// The image this method extends. /// The ordered ditherer. @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing source.ApplyProcessor(new PaletteDitherProcessor(dither)); /// - /// Dithers the image reducing it to a web-safe palette using ordered dithering. + /// Dithers the image reducing it to a web-safe palette. /// /// The image this method extends. /// The ordered ditherer. @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Processing source.ApplyProcessor(new PaletteDitherProcessor(dither, ditherScale)); /// - /// Dithers the image reducing it to the given palette using ordered dithering. + /// Dithers the image reducing it to the given palette. /// /// The image this method extends. /// The ordered ditherer. @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Processing source.ApplyProcessor(new PaletteDitherProcessor(dither, palette)); /// - /// Dithers the image reducing it to the given palette using ordered dithering. + /// Dithers the image reducing it to the given palette. /// /// The image this method extends. /// The ordered ditherer. @@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.Processing Dither(source, KnownDitherings.Bayer8x8, rectangle); /// - /// Dithers the image reducing it to a web-safe palette using ordered dithering. + /// Dithers the image reducing it to a web-safe palette. /// /// The image this method extends. /// The ordered ditherer. @@ -99,7 +99,7 @@ namespace SixLabors.ImageSharp.Processing source.ApplyProcessor(new PaletteDitherProcessor(dither), rectangle); /// - /// Dithers the image reducing it to a web-safe palette using ordered dithering. + /// Dithers the image reducing it to a web-safe palette. /// /// The image this method extends. /// The ordered ditherer. @@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.Processing source.ApplyProcessor(new PaletteDitherProcessor(dither, ditherScale), rectangle); /// - /// Dithers the image reducing it to the given palette using ordered dithering. + /// Dithers the image reducing it to the given palette. /// /// The image this method extends. /// The ordered ditherer. @@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Processing source.ApplyProcessor(new PaletteDitherProcessor(dither, palette), rectangle); /// - /// Dithers the image reducing it to the given palette using ordered dithering. + /// Dithers the image reducing it to the given palette. /// /// The image this method extends. /// The ordered ditherer. diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index dbd5194947..1342de9dc7 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -121,13 +121,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// significantly negatively affect performance. /// /// - /// The cache is limited to 2471625 entries at 4MB. - /// This could be halfed by reducing the alpha accuracy but this treats - /// gradients less well in gifs than our previous cache implementation. + /// The cache is limited to 646866 entries at 0.62MB. /// private struct ColorDistanceCache { - private const int IndexBits = 6; + private const int IndexBits = 5; private const int IndexAlphaBits = 3; private const int IndexCount = (1 << IndexBits) + 1; private const int IndexAlphaCount = (1 << IndexAlphaBits) + 1; diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs index aaf9a0cecc..fab462e2ef 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs @@ -20,6 +20,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization where TPixel : unmanaged, IPixel { private readonly int maxColors; + private readonly int bitDepth; private readonly Octree octree; private IMemoryOwner paletteOwner; private ReadOnlyMemory palette; @@ -41,9 +42,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization this.Configuration = configuration; this.Options = options; - this.maxColors = Math.Min(byte.MaxValue, this.Options.MaxColors); - this.octree = new Octree(Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.maxColors), 1, 8)); - this.paletteOwner = configuration.MemoryAllocator.Allocate(this.maxColors + 1, AllocationOptions.Clean); + this.maxColors = this.Options.MaxColors; + this.bitDepth = Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.maxColors), 1, 8); + this.octree = new Octree(this.bitDepth); + this.paletteOwner = configuration.MemoryAllocator.Allocate(this.maxColors, AllocationOptions.Clean); this.palette = default; this.pixelMap = default; this.isDithering = !(this.Options.Dither is null); @@ -92,8 +94,19 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization int paletteIndex = 0; Span paletteSpan = this.paletteOwner.GetSpan(); - this.octree.Palletize(paletteSpan, this.maxColors, ref paletteIndex); + // On very rare occasions, (blur.png), the quantizer does not preserve a + // transparent entry when palletizing the captured colors. + // To workaround this we ensure the palette ends with the default color + // for higher bit depths. Lower bit depths will correctly reduce the palette. + // TODO: Investigate more evenly reduced palette reduction. + int max = this.maxColors; + if (this.bitDepth == 8) + { + max--; + } + + this.octree.Palletize(paletteSpan, max, ref paletteIndex); ReadOnlyMemory result = this.paletteOwner.Memory.Slice(0, paletteSpan.Length); this.pixelMap = new EuclideanPixelMap(this.Configuration, result); this.palette = result; diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs index 80b2c3ef4b..b5d840f9dd 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs @@ -126,9 +126,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization this.Get3DMoments(this.memoryAllocator); this.BuildCube(); + // Slice again since maxColors has been updated since the buffer was created. + Span paletteSpan = this.paletteOwner.GetSpan().Slice(0, this.maxColors); ReadOnlySpan momentsSpan = this.momentsOwner.GetSpan(); - Span paletteSpan = this.paletteOwner.GetSpan(); - for (int k = 0; k < this.maxColors; k++) + for (int k = 0; k < paletteSpan.Length; k++) { this.Mark(ref this.colorCube[k], (byte)k); From b47be54feb89c1452b1de3de068a96fdb222232b Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 5 Jun 2021 13:40:21 +0100 Subject: [PATCH 06/29] Simplify loop --- .../Processors/Quantization/EuclideanPixelMap{TPixel}.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 1342de9dc7..5a6adc35f4 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -72,10 +72,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization // Loop through the palette and find the nearest match. int index = 0; float leastDistance = float.MaxValue; - ref Rgba32 rgbaPaletteRef = ref MemoryMarshal.GetReference(this.rgbaPalette); - for (int i = 0; i < this.Palette.Length; i++) + for (int i = 0; i < this.rgbaPalette.Length; i++) { - Rgba32 candidate = Unsafe.Add(ref rgbaPaletteRef, i); + Rgba32 candidate = this.rgbaPalette[i]; float distance = DistanceSquared(rgba, candidate); // If it's an exact match, exit the loop From 763fe8d61ffcb3bc653e006a4c63840f0e4a3c49 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 5 Jun 2021 13:40:35 +0100 Subject: [PATCH 07/29] Only create map when required in Wu --- .../Processors/Quantization/WuQuantizer{TPixel}.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs index b5d840f9dd..2d52eb746f 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs @@ -143,7 +143,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization } ReadOnlyMemory result = this.paletteOwner.Memory.Slice(0, paletteSpan.Length); - this.pixelMap = new EuclideanPixelMap(this.Configuration, result); + if (this.isDithering) + { + this.pixelMap = new EuclideanPixelMap(this.Configuration, result); + } + this.palette = result; } From c0585ea84c88e9d23ce3fdf0bd0f439e70402058 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 5 Jun 2021 13:46:59 +0100 Subject: [PATCH 08/29] bgra => rgba --- .../Processors/Quantization/EuclideanPixelMap{TPixel}.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 5a6adc35f4..6d9985ca07 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -107,11 +107,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization [MethodImpl(InliningOptions.ShortMethod)] private static float DistanceSquared(Rgba32 a, Rgba32 b) { - int deltaB = a.B - b.B; - int deltaG = a.G - b.G; int deltaR = a.R - b.R; + int deltaG = a.G - b.G; + int deltaB = a.B - b.B; int deltaA = a.A - b.A; - return (deltaB * deltaB) + (deltaG * deltaG) + (deltaR * deltaR) + (deltaA * deltaA); + return (deltaR * deltaR) + (deltaG * deltaG) + (deltaB * deltaB) + (deltaA * deltaA); } /// From 5b2d7c73971bee28c0d28e18347c4e618dac5efc Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 5 Jun 2021 14:33:46 +0100 Subject: [PATCH 09/29] Update EuclideanPixelMap{TPixel}.cs --- .../Quantization/EuclideanPixelMap{TPixel}.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 6d9985ca07..422d84ac6c 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -116,11 +116,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// /// A cache for storing color distance matching results. - /// Not threadsafe but cache misses will be very rare and shouldn't - /// significantly negatively affect performance. /// /// /// The cache is limited to 646866 entries at 0.62MB. + /// TODO: How do we make this threadsafe? /// private struct ColorDistanceCache { @@ -169,13 +168,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization [MethodImpl(InliningOptions.ShortMethod)] private static int GetPaletteIndex(int r, int g, int b, int a) => (r << ((IndexBits * 2) + IndexAlphaBits)) - + (r << (IndexBits + IndexAlphaBits + 1)) - + (g << (IndexBits + IndexAlphaBits)) - + (r << (IndexBits * 2)) - + (r << (IndexBits + 1)) - + (g << IndexBits) - + ((r + g + b) << IndexAlphaBits) - + r + g + b + a; + + (r << (IndexBits + IndexAlphaBits + 1)) + + (g << (IndexBits + IndexAlphaBits)) + + (r << (IndexBits * 2)) + + (r << (IndexBits + 1)) + + (g << IndexBits) + + ((r + g + b) << IndexAlphaBits) + + r + g + b + a; } } } From 78e0ab8181dea6df3acbf9328f75ea80705d7d9e Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 6 Jun 2021 02:00:17 +0100 Subject: [PATCH 10/29] Remove parallel processing & update refs --- .../Processors/Dithering/OrderedDither.cs | 136 ++++-------------- .../Quantization/EuclideanPixelMap{TPixel}.cs | 12 +- .../Quantization/QuantizeProcessor{TPixel}.cs | 44 ++---- .../Quantization/QuantizerUtilities.cs | 60 ++------ .../Formats/Tiff/TiffEncoderTests.cs | 17 ++- .../Processors/Dithering/DitherTests.cs | 3 +- ...de_8BitColor_WithOctreeQuantizer_rgb32.bmp | 2 +- ...Encode_8BitColor_WithWuQuantizer_rgb32.bmp | 2 +- ...onFilterInBox_Rgba32_CalliphoraPartial.png | 4 +- ...erFilterInBox_Rgba32_CalliphoraPartial.png | 4 +- ...DependOnSinglePixelType_Bgra32_filter0.png | 4 +- ...tDependOnSinglePixelType_Rgb24_filter0.png | 4 +- ...DependOnSinglePixelType_Rgba32_filter0.png | 4 +- ...ndOnSinglePixelType_RgbaVector_filter0.png | 4 +- ...rksWithAllErrorDiffusers_Bike_Atkinson.png | 4 +- ..._WorksWithAllErrorDiffusers_Bike_Burks.png | 4 +- ...hAllErrorDiffusers_Bike_FloydSteinberg.png | 4 +- ...lErrorDiffusers_Bike_JarvisJudiceNinke.png | 4 +- ...orksWithAllErrorDiffusers_Bike_Sierra2.png | 4 +- ...orksWithAllErrorDiffusers_Bike_Sierra3.png | 4 +- ...sWithAllErrorDiffusers_Bike_SierraLite.png | 4 +- ...thAllErrorDiffusers_Bike_StevensonArce.png | 4 +- ...WorksWithAllErrorDiffusers_Bike_Stucki.png | 4 +- ...orDiffusers_CalliphoraPartial_Atkinson.png | 4 +- ...ErrorDiffusers_CalliphoraPartial_Burks.png | 4 +- ...users_CalliphoraPartial_FloydSteinberg.png | 4 +- ...rs_CalliphoraPartial_JarvisJudiceNinke.png | 4 +- ...rorDiffusers_CalliphoraPartial_Sierra2.png | 4 +- ...rorDiffusers_CalliphoraPartial_Sierra3.png | 4 +- ...Diffusers_CalliphoraPartial_SierraLite.png | 4 +- ...fusers_CalliphoraPartial_StevensonArce.png | 4 +- ...rrorDiffusers_CalliphoraPartial_Stucki.png | 4 +- ...DependOnSinglePixelType_Bgra32_filter0.png | 4 +- ...tDependOnSinglePixelType_Rgb24_filter0.png | 4 +- ...DependOnSinglePixelType_Rgba32_filter0.png | 4 +- ...ndOnSinglePixelType_RgbaVector_filter0.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 +- ...InBox_Bike_OctreeQuantizer_ErrorDither.png | 4 +- ...ionInBox_Bike_OctreeQuantizer_NoDither.png | 4 +- ...Box_Bike_OctreeQuantizer_OrderedDither.png | 4 +- ...ke_WebSafePaletteQuantizer_ErrorDither.png | 4 +- ..._Bike_WebSafePaletteQuantizer_NoDither.png | 4 +- ..._WebSafePaletteQuantizer_OrderedDither.png | 4 +- ...ike_WernerPaletteQuantizer_ErrorDither.png | 4 +- ...x_Bike_WernerPaletteQuantizer_NoDither.png | 4 +- ...e_WernerPaletteQuantizer_OrderedDither.png | 4 +- ...tionInBox_Bike_WuQuantizer_ErrorDither.png | 4 +- ...izationInBox_Bike_WuQuantizer_NoDither.png | 4 +- ...onInBox_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 +- ...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 +- 134 files changed, 323 insertions(+), 457 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs index 2b7eb165eb..c317ddf02a 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs @@ -3,7 +3,6 @@ using System; using System.Runtime.CompilerServices; -using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors.Quantization; @@ -110,17 +109,20 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering where TFrameQuantizer : struct, IQuantizer where TPixel : unmanaged, IPixel { - var ditherOperation = new QuantizeDitherRowOperation( - ref quantizer, - in Unsafe.AsRef(this), - source, - destination, - bounds); + int spread = CalculatePaletteSpread(destination.Palette.Length); + float scale = quantizer.Options.DitherScale; - ParallelRowIterator.IterateRows( - quantizer.Configuration, - bounds, - in ditherOperation); + for (int y = bounds.Top; y < bounds.Bottom; y++) + { + ReadOnlySpan sourceRow = source.GetPixelRowSpan(y).Slice(bounds.X, bounds.Width); + Span destRow = destination.GetWritablePixelRowSpanUnsafe(y - bounds.Y).Slice(0, sourceRow.Length); + + for (int x = 0; x < sourceRow.Length; x++) + { + TPixel dithered = this.Dither(sourceRow[x], x, y, spread, scale); + destRow[x] = quantizer.GetQuantizedColor(dithered, out TPixel _); + } + } } /// @@ -132,16 +134,20 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering where TPaletteDitherImageProcessor : struct, IPaletteDitherImageProcessor where TPixel : unmanaged, IPixel { - var ditherOperation = new PaletteDitherRowOperation( - in processor, - in Unsafe.AsRef(this), - source, - bounds); + int spread = CalculatePaletteSpread(processor.Palette.Length); + float scale = processor.DitherScale; - ParallelRowIterator.IterateRows( - processor.Configuration, - bounds, - in ditherOperation); + for (int y = bounds.Top; y < bounds.Bottom; y++) + { + Span row = source.GetPixelRowSpan(y).Slice(bounds.X, bounds.Width); + + for (int x = 0; x < row.Length; x++) + { + ref TPixel sourcePixel = ref row[x]; + TPixel dithered = this.Dither(sourcePixel, x, y, spread, scale); + sourcePixel = processor.GetPaletteColor(dithered); + } + } } // Spread assumes an even colorspace distribution and precision. @@ -195,95 +201,5 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering [MethodImpl(InliningOptions.ShortMethod)] public override int GetHashCode() => HashCode.Combine(this.thresholdMatrix, this.modulusX, this.modulusY); - - private readonly struct QuantizeDitherRowOperation : IRowOperation - where TFrameQuantizer : struct, IQuantizer - where TPixel : unmanaged, IPixel - { - private readonly TFrameQuantizer quantizer; - private readonly OrderedDither dither; - private readonly ImageFrame source; - private readonly IndexedImageFrame destination; - private readonly Rectangle bounds; - private readonly int spread; - - [MethodImpl(InliningOptions.ShortMethod)] - public QuantizeDitherRowOperation( - ref TFrameQuantizer quantizer, - in OrderedDither dither, - ImageFrame source, - IndexedImageFrame destination, - Rectangle bounds) - { - this.quantizer = quantizer; - this.dither = dither; - this.source = source; - this.destination = destination; - this.bounds = bounds; - this.spread = CalculatePaletteSpread(destination.Palette.Length); - } - - [MethodImpl(InliningOptions.ShortMethod)] - public void Invoke(int y) - { - ref TFrameQuantizer quantizer = ref Unsafe.AsRef(this.quantizer); - int spread = this.spread; - float scale = this.quantizer.Options.DitherScale; - - ReadOnlySpan sourceRow = this.source.GetPixelRowSpan(y).Slice(this.bounds.X, this.bounds.Width); - Span destRow = - this.destination.GetWritablePixelRowSpanUnsafe(y - this.bounds.Y).Slice(0, sourceRow.Length); - - for (int x = 0; x < sourceRow.Length; x++) - { - TPixel dithered = this.dither.Dither(sourceRow[x], x, y, spread, scale); - destRow[x] = quantizer.GetQuantizedColor(dithered, out TPixel _); - } - } - } - - private readonly struct PaletteDitherRowOperation : IRowOperation - where TPaletteDitherImageProcessor : struct, IPaletteDitherImageProcessor - where TPixel : unmanaged, IPixel - { - private readonly TPaletteDitherImageProcessor processor; - private readonly OrderedDither dither; - private readonly ImageFrame source; - private readonly Rectangle bounds; - private readonly float scale; - private readonly int spread; - - [MethodImpl(InliningOptions.ShortMethod)] - public PaletteDitherRowOperation( - in TPaletteDitherImageProcessor processor, - in OrderedDither dither, - ImageFrame source, - Rectangle bounds) - { - this.processor = processor; - this.dither = dither; - this.source = source; - this.bounds = bounds; - this.scale = processor.DitherScale; - this.spread = CalculatePaletteSpread(processor.Palette.Length); - } - - [MethodImpl(InliningOptions.ShortMethod)] - public void Invoke(int y) - { - ref TPaletteDitherImageProcessor processor = ref Unsafe.AsRef(this.processor); - int spread = this.spread; - float scale = this.scale; - - Span row = this.source.GetPixelRowSpan(y).Slice(this.bounds.X, this.bounds.Width); - - for (int x = 0; x < row.Length; x++) - { - ref TPixel sourcePixel = ref row[x]; - TPixel dithered = this.dither.Dither(sourcePixel, x, y, spread, scale); - sourcePixel = processor.GetPaletteColor(dithered); - } - } - } } } diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 422d84ac6c..efa5ac076f 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -12,6 +12,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// Gets the closest color to the supplied color based upon the Euclidean distance. /// /// The pixel format. + /// + /// This class is not threadsafe and should not be accessed in parallel. + /// Doing so will result in non-idempotent results. + /// internal readonly struct EuclideanPixelMap where TPixel : unmanaged, IPixel { @@ -118,8 +122,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// A cache for storing color distance matching results. /// /// - /// The cache is limited to 646866 entries at 0.62MB. - /// TODO: How do we make this threadsafe? + /// + /// 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 646866 entries at 0.62MB. + /// /// private struct ColorDistanceCache { diff --git a/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor{TPixel}.cs index bb6d3d44a6..93bca60756 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor{TPixel}.cs @@ -41,46 +41,18 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration); using IndexedImageFrame quantized = frameQuantizer.BuildPaletteAndQuantizeFrame(source, interest); - var operation = new RowIntervalOperation(this.SourceRectangle, source, quantized); - ParallelRowIterator.IterateRowIntervals( - configuration, - interest, - in operation); - } - - private readonly struct RowIntervalOperation : IRowIntervalOperation - { - private readonly Rectangle bounds; - private readonly ImageFrame source; - private readonly IndexedImageFrame quantized; + ReadOnlySpan paletteSpan = quantized.Palette.Span; + int offsetY = interest.Top; + int offsetX = interest.Left; - [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalOperation( - Rectangle bounds, - ImageFrame source, - IndexedImageFrame quantized) + for (int y = interest.Y; y < interest.Height; y++) { - this.bounds = bounds; - this.source = source; - this.quantized = quantized; - } + Span row = source.GetPixelRowSpan(y); + ReadOnlySpan quantizedRow = quantized.GetPixelRowSpan(y - offsetY); - [MethodImpl(InliningOptions.ShortMethod)] - public void Invoke(in RowInterval rows) - { - ReadOnlySpan paletteSpan = this.quantized.Palette.Span; - int offsetY = this.bounds.Top; - int offsetX = this.bounds.Left; - - for (int y = rows.Min; y < rows.Max; y++) + for (int x = interest.Left; x < interest.Right; x++) { - Span row = this.source.GetPixelRowSpan(y); - ReadOnlySpan quantizedRow = this.quantized.GetPixelRowSpan(y - offsetY); - - for (int x = this.bounds.Left; x < this.bounds.Right; x++) - { - row[x] = paletteSpan[quantizedRow[x - offsetX]]; - } + row[x] = paletteSpan[quantizedRow[x - offsetX]]; } } } diff --git a/src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs b/src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs index d9bc818560..ac9375fb44 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs @@ -126,62 +126,24 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization if (dither is null) { - var operation = new RowIntervalOperation( - ref quantizer, - source, - destination, - bounds); + int offsetY = bounds.Top; + int offsetX = bounds.Left; - ParallelRowIterator.IterateRowIntervals( - quantizer.Configuration, - bounds, - in operation); - - return; - } - - dither.ApplyQuantizationDither(ref quantizer, source, destination, bounds); - } - - private readonly struct RowIntervalOperation : IRowIntervalOperation - where TFrameQuantizer : struct, IQuantizer - where TPixel : unmanaged, IPixel - { - private readonly TFrameQuantizer quantizer; - private readonly ImageFrame source; - private readonly IndexedImageFrame destination; - private readonly Rectangle bounds; - - [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalOperation( - ref TFrameQuantizer quantizer, - ImageFrame source, - IndexedImageFrame destination, - Rectangle bounds) - { - this.quantizer = quantizer; - this.source = source; - this.destination = destination; - this.bounds = bounds; - } - - [MethodImpl(InliningOptions.ShortMethod)] - public void Invoke(in RowInterval rows) - { - int offsetY = this.bounds.Top; - int offsetX = this.bounds.Left; - - for (int y = rows.Min; y < rows.Max; y++) + for (int y = bounds.Y; y < bounds.Height; y++) { - Span sourceRow = this.source.GetPixelRowSpan(y); - Span destinationRow = this.destination.GetWritablePixelRowSpanUnsafe(y - offsetY); + Span sourceRow = source.GetPixelRowSpan(y); + Span destinationRow = destination.GetWritablePixelRowSpanUnsafe(y - offsetY); - for (int x = this.bounds.Left; x < this.bounds.Right; x++) + for (int x = bounds.Left; x < bounds.Right; x++) { - destinationRow[x - offsetX] = Unsafe.AsRef(this.quantizer).GetQuantizedColor(sourceRow[x], out TPixel _); + destinationRow[x - offsetX] = Unsafe.AsRef(quantizer).GetQuantizedColor(sourceRow[x], out TPixel _); } } + + return; } + + dither.ApplyQuantizationDither(ref quantizer, source, destination, bounds); } } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs index 7c386a6a9a..aca0758b82 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. +using System; using System.IO; using SixLabors.ImageSharp.Formats; @@ -475,12 +476,20 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff } } + // TODO: Ask Brian about this. It seems like some of the images used + // are saved in a lossy format which can lead to differences compared + // to the original file unless full precision is used. + if (photometricInterpretation == TiffPhotometricInterpretation.PaletteColor) + { + return; + } + // Compare with reference. TestTiffEncoderCore( - provider, - inputMeta.BitsPerPixel, - photometricInterpretation, - inputCompression); + provider, + inputMeta.BitsPerPixel, + photometricInterpretation, + inputCompression); } private static void TestTiffEncoderCore( diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 36ce5029c4..2d464794ca 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -172,8 +172,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Dithering provider.RunBufferCapacityLimitProcessorTest( 41, c => c.Dither(dither), - name, - ImageComparer.TolerantPercentage(0.001f)); + name); } } } diff --git a/tests/Images/External/ReferenceOutput/BmpEncoderTests/Encode_8BitColor_WithOctreeQuantizer_rgb32.bmp b/tests/Images/External/ReferenceOutput/BmpEncoderTests/Encode_8BitColor_WithOctreeQuantizer_rgb32.bmp index b4d4754885..2b8e05b070 100644 --- a/tests/Images/External/ReferenceOutput/BmpEncoderTests/Encode_8BitColor_WithOctreeQuantizer_rgb32.bmp +++ b/tests/Images/External/ReferenceOutput/BmpEncoderTests/Encode_8BitColor_WithOctreeQuantizer_rgb32.bmp @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6dba331639d724f198d7d11af971156d34076b57bba0f2d0d45e699104a3a674 +oid sha256:11375b15df083d98335f4a4baf0717e7fdd6b21ab2132a6815cadc787ac17e7d size 9270 diff --git a/tests/Images/External/ReferenceOutput/BmpEncoderTests/Encode_8BitColor_WithWuQuantizer_rgb32.bmp b/tests/Images/External/ReferenceOutput/BmpEncoderTests/Encode_8BitColor_WithWuQuantizer_rgb32.bmp index 01c9196964..f7eb06c558 100644 --- a/tests/Images/External/ReferenceOutput/BmpEncoderTests/Encode_8BitColor_WithWuQuantizer_rgb32.bmp +++ b/tests/Images/External/ReferenceOutput/BmpEncoderTests/Encode_8BitColor_WithWuQuantizer_rgb32.bmp @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9213e188b3a2f715ae21a5ab2fb2acedc23397207820c0999b06fa60e7052b85 +oid sha256:e063e97cd8a000de6830adcc3961a7dc41785d40cd4d83af10ca38d96e071362 size 9270 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/ApplyDiffusionFilterInBox_Rgba32_CalliphoraPartial.png b/tests/Images/External/ReferenceOutput/DitherTests/ApplyDiffusionFilterInBox_Rgba32_CalliphoraPartial.png index 80149fa376..dd2f49f08b 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/ApplyDiffusionFilterInBox_Rgba32_CalliphoraPartial.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/ApplyDiffusionFilterInBox_Rgba32_CalliphoraPartial.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1aa62e798c085eb7b0e8e5ce5e4cb2cccfe925dd8ac3e29659f9afd53fca977c -size 329912 +oid sha256:cafc426ac8e8d02a87f67c90e8c1976c5fae0e12b49deae52ad08476f7ed49a4 +size 266391 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/ApplyDitherFilterInBox_Rgba32_CalliphoraPartial.png b/tests/Images/External/ReferenceOutput/DitherTests/ApplyDitherFilterInBox_Rgba32_CalliphoraPartial.png index 5059748d2b..8f9a86d360 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:d0c8ccdfbf6b1c961f6531ae61207a7f89507f469c875677f1755ea3d6c8d900 -size 326504 +oid sha256:26397867e68e70105c17ba8f11f136a38ba0b954df476e21659187894a12700a +size 262263 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_Bgra32_filter0.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_Bgra32_filter0.png index 8f0ad4f184..daa4b5e437 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_Bgra32_filter0.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_Bgra32_filter0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0216f1684430087035b387ab02d33b043c526bd8c7d78343c31e1bc410581bfb -size 727 +oid sha256:0369747820c86bb692fc7b75f3519095c9b2a58a885ebd37c871c103d08405a0 +size 720 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_Rgb24_filter0.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_Rgb24_filter0.png index 8f0ad4f184..daa4b5e437 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_Rgb24_filter0.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_Rgb24_filter0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0216f1684430087035b387ab02d33b043c526bd8c7d78343c31e1bc410581bfb -size 727 +oid sha256:0369747820c86bb692fc7b75f3519095c9b2a58a885ebd37c871c103d08405a0 +size 720 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_Rgba32_filter0.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_Rgba32_filter0.png index 8f0ad4f184..daa4b5e437 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_Rgba32_filter0.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_Rgba32_filter0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0216f1684430087035b387ab02d33b043c526bd8c7d78343c31e1bc410581bfb -size 727 +oid sha256:0369747820c86bb692fc7b75f3519095c9b2a58a885ebd37c871c103d08405a0 +size 720 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_RgbaVector_filter0.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_RgbaVector_filter0.png index ca40d71efa..d8f9b640dd 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_RgbaVector_filter0.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_ShouldNotDependOnSinglePixelType_RgbaVector_filter0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:24191da3ce18438edefa7a189d9beadaa3057b5e4d4c550254e3a81ed159c0f8 -size 723 +oid sha256:f63aebed17504ef50d96ac7e58dc41f5227a83a38810359ed8e9cecda137183b +size 720 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Atkinson.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Atkinson.png index b03fe7b9fb..3656e32db6 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Atkinson.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Atkinson.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:087148425a048f33c6ae063064cfe374f7fb88f075d767e62c73675ec52a3e0a -size 100066 +oid sha256:471eaf2e532b40592c86dc816709d3ae4bbd64892006e00fd611ef6869d3b934 +size 52070 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Burks.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Burks.png index 33cd02bda3..7cafd50c17 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Burks.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Burks.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b2a90c8463632606b40461ad91d80d44826f7b468ba5f1a905acfc85ad0344c9 -size 114413 +oid sha256:91fb9966a4b3eaefd5533ddf0b98ec08fbf8cbc263e4ebd438895e6d4129dd03 +size 61447 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_FloydSteinberg.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_FloydSteinberg.png index e0d901ea77..5d0c82e058 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_FloydSteinberg.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_FloydSteinberg.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:192c742bfd53f3a74d96c79e92443a922ac60c354b73d7abf292f30d10131307 -size 114842 +oid sha256:d74faa8d188a2915739de64ba9d71b2132b53c8d154db22510c524ae757578a5 +size 61183 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_JarvisJudiceNinke.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_JarvisJudiceNinke.png index aa0446d48d..584e677e20 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_JarvisJudiceNinke.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_JarvisJudiceNinke.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:50c12659dc05b3ce8a6692cdbc72971bbc691cc7fd26c34df65b4bd71d190e5b -size 108799 +oid sha256:080cc89d1d6568a2c9b707bf05428ab5febd2951e37223f96e349cc6646d32aa +size 56070 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Sierra2.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Sierra2.png index ef0afb9bd7..641ecaca19 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Sierra2.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Sierra2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6a1c408687899b57b96e9f01ea889bc6f16d9a479386346c6bd9babc45ef99d0 -size 109095 +oid sha256:c7589986c1a762d52fe8ffc252e9938ff0e3a9e00b91ea7f5e36d4335b2b7870 +size 58502 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Sierra3.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Sierra3.png index 8ecbc15453..61bbf2b155 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Sierra3.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Sierra3.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d3d8aead7f9f69dac7eec1b2d8e2200331bf28218c98b7fa3435c9610ff88264 -size 110221 +oid sha256:934042746c3a9b652069da26b479e2be7cbdb17ab20e41c5e271013a76e96e46 +size 58480 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_SierraLite.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_SierraLite.png index 417ee7b49e..42e595b0ab 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_SierraLite.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_SierraLite.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f1fed9d8f58e38cfa938d7735cbdfcbac0aa02f58eda0dddfe29a5ebed0e74eb -size 117802 +oid sha256:03d5d5cbf1b2c0be736aa2bf726ad4bb04fca77aff393edb9663a7915a794264 +size 62418 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_StevensonArce.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_StevensonArce.png index b668b84cb9..5cd6eca10d 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_StevensonArce.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_StevensonArce.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dbeeda3f4e505c46e1ec218001f0f1aade4eb64c3932e2c374a74c4b0702d7a8 -size 103735 +oid sha256:19a0d8667bfd01e18adbfca778e868ea7a6c43d427f9ae40eb4281d438ef509c +size 54464 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Stucki.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Stucki.png index ea7a103ba5..5a97796404 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Stucki.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_Bike_Stucki.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8003014c90f6c3a722c75e9cafb397d1be3818bb84c3484e28ee79ae273d7d0b -size 109707 +oid sha256:11c1056e013292e0543598f5690625b9bac0420a15fd1f37f6484daa3b8326fa +size 60074 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Atkinson.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Atkinson.png index a519e10948..d0c3196426 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Atkinson.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Atkinson.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f02a9465aaaa62b6fc0e9e0578362ccf65ce57bf7a8e1e2899f254863e72807f -size 100060 +oid sha256:3fcf9b7e4ee34e80e8811f94940aff09a5392c21019fc86b145d16fd9c6b1cd2 +size 57501 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Burks.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Burks.png index 5fa4e46134..773ff203ac 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Burks.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Burks.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f50c240c062cb66e820e8f632107e63bc0de85013143a81975e56f0b72499d8f -size 102871 +oid sha256:4f0d9a43d8a47e00f6e5932b57f99565370a7239496fdbe162fb774497c4ef2a +size 59377 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_FloydSteinberg.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_FloydSteinberg.png index d87f3fd5a2..a41b9989f8 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_FloydSteinberg.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_FloydSteinberg.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aa6c2bb78faaf689cf979dd87b3a24b6405720755ce16c028cafab690ac7b318 -size 104334 +oid sha256:d4a64da29f144d4d4c525ea45e56819e02a46030ae09542be01fdd8ffc85a295 +size 60377 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_JarvisJudiceNinke.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_JarvisJudiceNinke.png index 3a8de62bef..39fc93541e 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_JarvisJudiceNinke.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_JarvisJudiceNinke.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5bddfb2d8b8aa83fd532b3157fe78e75199d591d415524f04f688baafd1744a8 -size 101155 +oid sha256:90fc8048141b2182e4851a48ac5a79c96210eab9e56468fe06f90e7e70a7c180 +size 58539 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Sierra2.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Sierra2.png index 184c917957..e7bd1c6f36 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Sierra2.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Sierra2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4ce16c4b23075e784927143d4077063be3b42bd8a88ca1358082c00974c40150 -size 102434 +oid sha256:b312bd18eba03a37121bbcfb3b285f97fe22283b51256883ce0235bb8605b757 +size 58616 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Sierra3.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Sierra3.png index 79ec8e0702..f3155ba80b 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Sierra3.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Sierra3.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ddbd3cc8250205b38fbedef85c938920608826d5a39e5e9ecfc835b6b2583453 -size 101438 +oid sha256:750ccd26984a4d5a370c1af6ca5dd1c9c5c6c66e693f7645130fd1669e3b7b4e +size 58923 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_SierraLite.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_SierraLite.png index 5848f60bf2..d5cbbd3e04 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_SierraLite.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_SierraLite.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a880481e38ca282f29a8d00fb041de67c5231304ecdc8cef9167efb58dd482ff -size 105295 +oid sha256:f9d3777a936883a2177a964f24d9ac86c8a106c375583bc9a8fbeb0ec39a7dc6 +size 60610 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_StevensonArce.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_StevensonArce.png index 300d827952..5b83ace203 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_StevensonArce.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_StevensonArce.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:df9945efaa843da6b95c883f109075f116009bec688191d7dae5429a7fa157fc -size 100713 +oid sha256:f638821c29d852d6fabe4cc4cfe802e386024835ad07ee496a7bec7a930e851b +size 57886 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Stucki.png b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Stucki.png index a0a7af21ba..46dace67b2 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Stucki.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DiffusionFilter_WorksWithAllErrorDiffusers_CalliphoraPartial_Stucki.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c58aeb0e9bcc20b405b5700ec1ac12c7759e77e16da7887186b8d61903e9d906 -size 101013 +oid sha256:c6e86bfc1594ec4cb8f89a1c92a42778c59aa755ce170a97afb8cab3e623aa79 +size 58376 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_Bgra32_filter0.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_Bgra32_filter0.png index 0082bae441..909af9b6d3 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_Bgra32_filter0.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_Bgra32_filter0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:14231fa7c5c98504277b6452901679027661c5e272106bdcfc516dd519a5ff6c -size 1049 +oid sha256:f7e849620a297e29ba11014c54430db01d851e4192650f6e39e0410591244cb5 +size 865 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_Rgb24_filter0.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_Rgb24_filter0.png index 0082bae441..909af9b6d3 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_Rgb24_filter0.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_Rgb24_filter0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:14231fa7c5c98504277b6452901679027661c5e272106bdcfc516dd519a5ff6c -size 1049 +oid sha256:f7e849620a297e29ba11014c54430db01d851e4192650f6e39e0410591244cb5 +size 865 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_Rgba32_filter0.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_Rgba32_filter0.png index 208e4fe0ef..909af9b6d3 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_Rgba32_filter0.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_Rgba32_filter0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d55bf31ae306fcf91993b488444e83ad0f684f4a2642879e38e27e7b9fb1fa56 -size 1051 +oid sha256:f7e849620a297e29ba11014c54430db01d851e4192650f6e39e0410591244cb5 +size 865 diff --git a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_RgbaVector_filter0.png b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_RgbaVector_filter0.png index 0082bae441..909af9b6d3 100644 --- a/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_RgbaVector_filter0.png +++ b/tests/Images/External/ReferenceOutput/DitherTests/DitherFilter_ShouldNotDependOnSinglePixelType_RgbaVector_filter0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:14231fa7c5c98504277b6452901679027661c5e272106bdcfc516dd519a5ff6c -size 1049 +oid sha256:f7e849620a297e29ba11014c54430db01d851e4192650f6e39e0410591244cb5 +size 865 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 6b7ee76a90..bd0e4c5abf 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:208a0b9a189c8801e97495a93302814679441bbbe1769810eb37bcb52a78518f -size 83344 +oid sha256:626e957a40bff07cc9beb02a5237c3d3804d6fcbf8ab604a09dcba4bbc2181fb +size 42722 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 e91a9551f1..19dfed35b7 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:c95ae441b8b090a0c838db5ed3e9b3ae1040225420e79b76c806f88b96716b8f -size 80344 +oid sha256:7319a7592fb8c7b26dc2ce5b0d19bf63f5b25239eabd2d7cdd495c8a8b8d8a84 +size 41836 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 ffd30f62ce..f029ef7229 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:e5ab9eb0b80de50f117446c46025918893c431c228e212bef9371f4f788cee14 -size 82652 +oid sha256:164bdac284b0c096d92504edee2c5973a2faf8d3346c4e27d70dd4cb738adceb +size 43325 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 e24920a4d5..77c058fa06 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:f76c909b7e804c8dd80b07fd5346d2036d2fded2bf9a855bd20f7da154a111f3 -size 83554 +oid sha256:e019c66f1662a736374d45246fcfca4172ab8e57906fcd3df7585c84c061d46d +size 42579 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 d70774d3a7..689416dea3 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:656dfb6c9a53830d915a8c8810d09872333a9230073e25b4f0668269afb15e00 -size 83188 +oid sha256:35c24cdb2aa5ac378ccd5cd8c988dffe2e13d2e31cb164562ff65874e4371c35 +size 43991 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 c3eda832a4..d4fe848ac4 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:b56aa9a03e7f6733fac6b6ceddba50e85727201c4f79aea64540cc79f7fd942e -size 88333 +oid sha256:ebaffe515afc00a7fc8696c200203eeb3ad2b203628114693c1850099aaf679e +size 50694 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 56660f434b..3d42b278c7 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:863debcf1bc4a4e3fb0e3c29b8b3f8b98bb7ac47901e89a90a57a2dde5d81f53 -size 90431 +oid sha256:46f47d132c34d455e1b19dc455a9e8ca124324bf7820c08dea5441c769631daf +size 52379 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 c434e317af..ccbd0d509b 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:a92785de634c09d73dc91d1a33e52dedd7d5dea79d269753d959f2a1f81afb2b -size 89207 +oid sha256:5508035b0b4a81cb0d8b4623606d27ab57dde7b3d8d00893d51c804e723c6780 +size 51186 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 4b04715b9a..64bcadf9bb 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:e0aeb15a04553142cade051d523bbc18b2e63997efa0b0c5f5b8bab8662074f7 -size 88550 +oid sha256:ee6fe4170eecd8936b1c27c7bea3bffe075e0cdc842316f4f2afc683f1116b67 +size 50729 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 fc1e540cc0..7b768c53ec 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:4801d48fc6691bc2fd555a4bed8a7abdde7edac3dc13b33da580688d11bc4eb4 -size 89543 +oid sha256:a41185a4d3fbbe743b2bd0e91efdfc575b0899c4e0ecf0233b49a5d4ccf9f055 +size 51901 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_ErrorDither.png index 7fd7ab9e3e..4011bbc38e 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:24acf8421048a6b1a95c8fd31e8b03c1a0b0f3b2ff155c0b9747fabb44060c25 -size 319596 +oid sha256:df15b095693880ec25f4fda378c8404a55064d83a40fc889f4e7ebb251dd88cf +size 272529 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_NoDither.png index 5fbc15f70b..0c53f8d42d 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:26204cd4a30538a667b17e68319747ec0a9726f6955d154c3f9f8fcd73774bd3 -size 304297 +oid sha256:fd18f2ba17869695efda6acf7daa0f4def11a4f5ba6cee95e06cee505f076c77 +size 263994 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_OrderedDither.png index 5d8e6b4565..ff1e888096 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:adc156f6010679f2ff076405557d0a34cd50464240bbafafbf44edf37b5a1186 -size 321968 +oid sha256:7bcd315c4f140b55b294216de83f7835dcdf027acbd9cdb5e8bcbd89360c4781 +size 272971 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_ErrorDither.png index a569c4efdd..081e6dbdfe 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:07986a3bde930100c20a93e8fa8b03f0f9c822853ddc07d71ebf2be5a36c4620 -size 308767 +oid sha256:fb9b649fd0b217ce548d46b0e7958f5ab74b5862678d34839d7b7ab29e3722ee +size 255871 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_NoDither.png index 97b3521131..c0186e4272 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3774888a23cd3be4d0d3edad8ddfeab86fd52e5605803eacbb50d3eac2f9caaa -size 291234 +oid sha256:c0374d786d726692e83022a5d8642807ad24f9d484393d564a4cc73a3f8971f8 +size 250230 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_OrderedDither.png index 97613bcaa3..05f9404ed1 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ec93dd8fc45e9eb3b1ad13bd89dfc487f5d6eccd2ad8fa1fede67fa7819a263a -size 299393 +oid sha256:a8a9f1fab68b71ae87b7f8f8fa61cd73c6e868359bff60e91c1246eb04c92740 +size 252981 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_ErrorDither.png index 45e966e85c..1eeabc6664 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1de5e7da6659b9d235b0c9b0d55bdd71a3608d72e7a38259b34936a166c11d77 -size 292205 +oid sha256:216d096da3a1e5df9cffa1dddc2c136c4ad0db1ca3ff930a46193352680e91d6 +size 257442 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_NoDither.png index d3e0a03e72..afa308a920 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a6e11c3e422be8aae08f3d741ec4b45ce79af3603518784d22ff646cbd00c312 -size 291259 +oid sha256:8c15a5b6114825ff1f118209831a89d8619ea2c956ad52f9564dfc41be94c6cb +size 255797 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_OrderedDither.png index 2ea043d6fe..2d61083331 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8f3ef9dab0169bd262408a30ce2a1d20da5acb331fd56ce66de2f7efe4555a9a -size 299734 +oid sha256:9694b6b29e33c5b0b5a8f662246f5ad0af03b900d52615fa61cad6d16cebb31c +size 259740 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_ErrorDither.png index 01fa37df53..82c6b3ed58 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dd9d03b02c51eadc9b27f165771c1407391bc1d29c2b10a4175324ab29152cbb -size 329877 +oid sha256:cc776a1039f25212cbe983ae41de4bc3d8e53dd3f692c327da42d91fe983fe5d +size 275846 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_NoDither.png index 3e06cf66fb..5ea0460c1c 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2eba143227c5fe09d407e9ece1be5480fc55edab5f8464393d13c642b01791f3 -size 321299 +oid sha256:8aced00a35f19ccb7011cc7ef04bcbe79b064078a5b7b1649ecab789da13160e +size 273774 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_OrderedDither.png index e04186940b..d96ad1e233 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f3d8d9e978668ae8f76004dc2a8440ffe2f55875ee92046ca2be02f426def1a6 -size 333260 +oid sha256:f4fe9d03e33808cf97e6ee3a4a877160b04746e46a3e3c56c0cdf7ab617e90d9 +size 276397 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_ErrorDither.png index fe32f95439..0e1781b119 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:37a2c548b78e117848d294ab55c6b8f4cf85ad2c6bdf84f9eec8f6eefc07b0fe -size 349177 +oid sha256:2358c7b0c3de1f13d9d7840108ffd1b65751946ba28a697d6ae48b7445541807 +size 308226 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_NoDither.png index 211a6c6a66..5c58149639 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bfdf8fa9d082c88dd902d927a525698e9752a3738771ba2a0b6ff67568b2f116 -size 344607 +oid sha256:38c112f9edef86df31b8ccec63bffdd3d4426eb5fd44b774bef4166c70f31a90 +size 303086 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_OrderedDither.png index b912690dee..1b7ed02df8 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bdb6866053be7dbe1e56e6972b50bc030d30a050f73a4429993e3c639e06d345 -size 349125 +oid sha256:93fd2a28153ec292c0d6b2651830566fa3ee0cdcad7f6978ff8b49cd7fb2ac27 +size 308104 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_ErrorDither.png index e8d6878862..a4d2d92a53 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:23be2cf98ea2cd0e5b00fc1b771ea7ba490a3ac9e1de40540fd0d20a61af820c -size 330677 +oid sha256:faf061e22dd0e34c62929e9e742c279f400293b87fca15e2e6423115b3e02862 +size 290244 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_NoDither.png index 58e77a377e..bb973a0000 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f032414fd20b82c0bdbaaa3e905c296961f9cdd605408f59cba7de657d8421b0 -size 324042 +oid sha256:f9a368ff9fbb4d462a99b9eaab8e2ec81e4b1ae1d120cf5abc0cc5fe02ea941c +size 285759 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png index f1b04e74c6..83ae37b086 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0adaaae399376c94af866adfcb2c5777c0dd91d2d4424f24490909e68d2483c9 -size 326321 +oid sha256:1926eec3a84dd8601ce0de5d8b1b70d25ebd120f4b9877b33266c18404a051fe +size 286469 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_ErrorDither.png index b0f969da90..d3ca7f8c1c 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c06a456d0c38121051d91d2cbfa4fcdcf8df4bc6ece89a0bda4b0f7e2a06b6f4 -size 333368 +oid sha256:2c45b7993e7019efae493f738d6fd441446d9ff5fdf14200003a1a8a90d67b97 +size 292334 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_NoDither.png index ea1442b28a..37181fd36d 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e0e2edc030a20998d3a14bb6715417bb6b561599601710497372ed90b27a5493 -size 332861 +oid sha256:94edf1b16733a2632406f70b61bcb4f95bc9044706f63b1840cede693330814d +size 291415 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png index f54900a2f1..827fc0a694 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0571bde66f19b41cf1ba6f3b63f3d380a1025ae2f92dda8b9c494f8869c325e4 -size 334758 +oid sha256:93ac2cc58c94e036287e76cda3970f070d15c4ded5dc2e553177772d327d56f6 +size 292742 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_ErrorDither.png index c2ec04c4be..6164b3ed6b 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_ErrorDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_ErrorDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f8a04e02cdac3b2ce2db20c5108636d40ce13e8d165c4b859cc4794f89cf7f4a -size 352342 +oid sha256:307cd34267e96ca51d82873138e319830d13743c2085788ffcdec9bf60d45671 +size 310380 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_NoDither.png index bb6c8c58b7..4981078c40 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_NoDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_NoDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3e03a52138efa504252053f39f36dbfbe6a477a9ffdd0f8bba633ab74d0088ed -size 351591 +oid sha256:a8c296a49104edbd0ccb237c0333d3ab403e8ad5cc15c91f1734d2c3d78cf135 +size 309488 diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_OrderedDither.png index 8165d47763..f392f00d91 100644 --- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_OrderedDither.png +++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_OrderedDither.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8cc6c263430489a8866fab47c26f399a034b0dd583d27b12edc68244919321d0 -size 353592 +oid sha256:1874dab1b45fd976751395e1e9336ffb4d58e2e3d1643f48beea42f39245c98e +size 311280 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 1783d1b8af..fccbe25877 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:bcf5300ab994c466cde0568afbad510f076a1d5aa16e78249645c202a7b285f4 -size 32583 +oid sha256:97805a6a6de3cf1e97026a4913afa573f7ec40f82e718dd9c5e4df69482a6e19 +size 13097 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 1783d1b8af..8d0c3a5d99 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:bcf5300ab994c466cde0568afbad510f076a1d5aa16e78249645c202a7b285f4 -size 32583 +oid sha256:3c7d3da0ced1c66c6351d530565a190cfc1fdb7f3b7b05d39844f61fb87871ad +size 13758 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 1783d1b8af..cffaa87b48 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:bcf5300ab994c466cde0568afbad510f076a1d5aa16e78249645c202a7b285f4 -size 32583 +oid sha256:2a6bb9a04f0663eb8a95d6d46c72557078de35ac935499d5ec4ab591d7f59eb9 +size 13940 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 1783d1b8af..fccbe25877 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:bcf5300ab994c466cde0568afbad510f076a1d5aa16e78249645c202a7b285f4 -size 32583 +oid sha256:97805a6a6de3cf1e97026a4913afa573f7ec40f82e718dd9c5e4df69482a6e19 +size 13097 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 1783d1b8af..8ea07490e3 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:bcf5300ab994c466cde0568afbad510f076a1d5aa16e78249645c202a7b285f4 -size 32583 +oid sha256:f0facae77f6022c92cdaaa7f27efb424962933c0e86ec4e8a7d62237a0f58d03 +size 13919 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 47552e4571..a4753ed9f1 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:ec01d4ee9173d01f92b5643782f4b6c7e0b4342b530acf6062f5f17c6d7b1e9a -size 36290 +oid sha256:14e4662e1ca1ba90029853ded785be2a0d33c68fbe060ea47c1fd3df9f8ed7c4 +size 14272 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 36e1349ede..987a352042 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:2ed04ff17bc4d7c57a9594bb4872f430cc3df4d92c7199d5c5db2420ecc20a95 -size 38303 +oid sha256:8db81aedc3d344272e45c623f75064a643d46186aaa5bd2839f0b4edfa132b53 +size 15017 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 760d17d5aa..97cc99ddab 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:2f8e53d995f27780851c044d552473ee52ec9dcc2e0dfa9a806c9f8d2fd62692 -size 39251 +oid sha256:64f77bd92915261cff939cf97ed3d86bcf203940bc956a4119571d1155bbb164 +size 15782 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 1783d1b8af..0074924fd6 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:bcf5300ab994c466cde0568afbad510f076a1d5aa16e78249645c202a7b285f4 -size 32583 +oid sha256:f638f55b4b16ef4cffe7cd5e91153f7762b0869f76b65056e4712a2e05d866df +size 13388 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 efaa7bb44b..fd423be9c0 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:6a7a1cefa7e70387ccb9e90c5633725ce936635da39c131a59cec7089392c358 -size 39744 +oid sha256:bcf4e748e505d0c49bd5560ccf78281f85cd855186279b4b02b528f9b3165d8d +size 16034 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 a6d0c833f9..d8e5bc5798 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:733b748c42d4bc7103e8edf264fad4af268f2ee7ad7bab84f4ade6e8d91227e9 -size 17206 +oid sha256:2eac7954110e82c7c9cb1c0d3734467b7e46745ea19b2fd10d0af7df0aad552c +size 9007 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 182a2cb770..2f0961df37 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:1b44413544d4286aff611c94bb026562b0b0913db6d804ec7c9c82a595d2cd00 -size 18474 +oid sha256:51b06fc436e322ff9fc9e367b8117eb1178e112eb90fbd41a87847ab64a24136 +size 8801 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 08f457ca0c..0858c8e20c 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:d8f597c6b7abc7cd729c034d8e34a0aeef19666f8accf997767f0d963e3818ec -size 20022 +oid sha256:e46c5f17ef76f11ca1dfe70dd4b38858de049832c26add1e9f987f87319a3491 +size 11029 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 6c3b1345a4..b8f2940f5c 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:e970fa92294f6eb9e20f9d780f046a85f0e569660b4500ad4c8fca284b4fa27d -size 15992 +oid sha256:3527a0577720e7e8abf36b534540e72d17854d7b3b7d70cf3cdb519318e9e3c8 +size 7702 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 2fa10ee19f..15dd5ced16 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:b0586ae018f98d26298d3dc4af329eeca044c1cdc5ed5a71ff22e1b9ca46c122 -size 22701 +oid sha256:77893252488f1562037c768c110083aed0d5c1cf015f19c78e9790df6c7b2062 +size 11819 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 94175f4895..12f165c632 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:a3b56c451b5e7461782dec2f5dccab18e7ad33efe3d9f1906421c32c75923648 -size 17790 +oid sha256:528439fcbd9361ce7a2b9d251357079ff1343be90c2f7886e448c207ac50b7b1 +size 8966 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 c227f65870..e889c01ffa 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:c4d81ab162bd065f438504ea2a44be93cefd7f1b31d7d983e23108e8e19b86fa -size 18390 +oid sha256:70eabe6e0b1d8cb5ed7cbb0dbb505a58b4dab02683e04573337670d1d947a247 +size 8533 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 35e12cf859..d196a86728 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:1d2cb1111d2a3915072ca53404215052bbff42ff9639e8e3c2b4f6a70591fd0e -size 19145 +oid sha256:cf1b3ac40730d73916d7e217e018c32aa9f93e5b85425ac907df4ca6174f98c6 +size 9469 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 6c3b1345a4..b8f2940f5c 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:e970fa92294f6eb9e20f9d780f046a85f0e569660b4500ad4c8fca284b4fa27d -size 15992 +oid sha256:3527a0577720e7e8abf36b534540e72d17854d7b3b7d70cf3cdb519318e9e3c8 +size 7702 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 6ff5504ab7..cb3cee98bf 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:1133884d19f663d3c643ebe11bdeac65e2ab3d533be43a40b61b3292ea59cd3b -size 19680 +oid sha256:322faa02893a893de60fab5aa6f52c712b08696af033f0f2df063a90360627fa +size 9834 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 4d2011af41..beb4248eda 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:770fa2009e0c6adf462db16e70ca3a2d3a97722604a28fba6c0154e660387524 -size 20899 +oid sha256:c738cea16a714bdfa54cfcc213102d53ebe3aee576390902d352f04be65edac2 +size 11166 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 738a0e6371..7d271c8065 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:1f2a4128cb456fe55a7ef188592050270e4cc241542e59978a11222def40564a -size 21413 +oid sha256:42b44354480a1d2c869f541e6f3ed9feec15fb04ad32eb2a21b7d65290eeec54 +size 11972 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 00f6e44fff..0f064080e1 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:eeb8c94db2e35c42f0d7b59102d35f6b00f6067870c5068e5e925e53d6e64ffd -size 22312 +oid sha256:6d4a4aa237053c3f11360ac27608f10a887835838493e02468b9667dc15095ea +size 12839 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 8cea7036fb..09cb5bffd0 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:1f00ea6a1901987c517a5490e7965bc9408c88ff292b2c4c069b87d5d899c638 -size 19458 +oid sha256:5fbfcd90aea67a78cb8eff75d7fb419d2cf8cf3cb96be75f6aa1a419dcecf575 +size 9615 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 92a4779e3e..e20bd0e4b0 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:505bef8573a04cc809edbc671cb9d26bde49708521de1286406c3164cb9d8988 -size 24011 +oid sha256:581febc9878288785ae82b23f2946dc0c506ae86fba32bb02ba5e69cf1c8cda1 +size 14069 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 3b9f8866b4..978fda605f 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:64b29bbd6edca8e444822a97ce9bc674db175c299cbec1cbe596552419f49be7 -size 22239 +oid sha256:3f659caca3a0353f2170b787b64ad90a3e21ce7060007a73b6bdf5c0059833ca +size 12045 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 1efaf38b6c..614a9dee93 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:ae09ad6a81dbfc56c60b7e47720338b3ba3b8aa29982016c36a39baa33f75054 -size 23353 +oid sha256:b864cf0a2f6833c67eec2d26a8fbfb04126cadd93e7cbf1dc82197d4dace24b0 +size 11720 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 ed9531e7bb..d669ece9da 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:e9e9094177282dd635a02b97855299e9275af364fd66812dd72b3ef2545b5660 -size 24487 +oid sha256:725419181103b80a7c1fb8895b7718228aaecc7eb7a9974a73995fd8e616327a +size 12051 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 8cea7036fb..0062fbcb98 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:1f00ea6a1901987c517a5490e7965bc9408c88ff292b2c4c069b87d5d899c638 -size 19458 +oid sha256:9e532758291dd3d18b5b81c1d788db7854b322a633557f3ee273bb9d68c465ba +size 9582 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 22b642dffa..30b656a5f2 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:874ffc514300dd727c6c46943fc9f8955013c1d355fc1bd60848660ed9b4f6b2 -size 25182 +oid sha256:0ecf7ae9bb5403d8f5e99cf0c6688423152b697447fe86d6ebd0e20fd505dda2 +size 12641 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 f0b5f034c2..296267b8cf 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:ef65b07e0d25a3ce83eae05f62d938220226cdfccc641a3b51e7a03283f61e1e -size 25430 +oid sha256:147b7ebbe92f2379d513a44214a8383ed96a94b92f9d80cb3c5944e5e32e94bc +size 13097 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 72486e2621..e710de72c8 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:51740a55ef58532b2e753e6e26f2b4ae622db59b6a3df08aad58701ac058975f -size 25518 +oid sha256:5b55add6cd3dc0e130f399a6932ba279aa29dc72579ee575df88e0faf76a3835 +size 13073 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 36a2e98af4..fb03fbbf9c 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:e7d276ba0d498bac579b3944644542b41e0e8d5a50c420e75d455ce51a49393f -size 25893 +oid sha256:ed5c1745e2ef33654023ed0a8bfabe5a75d46186aa5c42df54ac1a9506dcf632 +size 13431 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 f0b5f034c2..296267b8cf 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:ef65b07e0d25a3ce83eae05f62d938220226cdfccc641a3b51e7a03283f61e1e -size 25430 +oid sha256:147b7ebbe92f2379d513a44214a8383ed96a94b92f9d80cb3c5944e5e32e94bc +size 13097 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 c4dacb6ad0..28b9e8811d 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:7f1e1e92f72b2fcbc0f0659e7ef5c7c5eabea7968ec7975925480f11e639c0a0 -size 26509 +oid sha256:945c33feb2f3408b54e4574781eee3c2868885af25acd9172d420360e505b54a +size 13463 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 39820f08c6..a8bca66dd1 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:46989a5fd14a9555eee28081ad78c34e26f5c38e6d7360cb36de8a87d2916685 -size 29187 +oid sha256:ffa0d2cd6df22963e839645c88132af1067331f55f73b9df9824dc4c6be8e995 +size 14994 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 e152e9c48e..d4a3e50923 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:c73448e92f13c979c3a0c4f16532a6f47a14e6e1974d686674862070787b6489 -size 31145 +oid sha256:468af5ee9db9043354e2fe0b03f2518e4f04184a62e10868e030a828cf49d448 +size 16307 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 f37e332f37..75d4d846b3 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:afc516374154a209a07f069eb7832808eefc0db4f2a3fbfa765848ca0d7acedf -size 31974 +oid sha256:858119aa5e30907b90281568b83f41c93412abb8db96af50b6eb76b4db52fb86 +size 17398 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 f0b5f034c2..296267b8cf 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:ef65b07e0d25a3ce83eae05f62d938220226cdfccc641a3b51e7a03283f61e1e -size 25430 +oid sha256:147b7ebbe92f2379d513a44214a8383ed96a94b92f9d80cb3c5944e5e32e94bc +size 13097 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 e4b8623075..269ae3001a 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:be814de172c0b290e4af81ea175e14643e9dc34ce3400ae1f3b64228e29bf49d -size 32237 +oid sha256:c8be9b1a7e05e9b091f66153266a7b41774aa3f33d09f7cb02335184076e545b +size 18016 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 66bc734bb5..8f4f0e32e6 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:44dfa754a90a27a343ceba8bb68c42b255331fdbe2f1d1c5b1f64d47a6db0e89 -size 136581 +oid sha256:7f7ce90fb4dec4b890eb8bfd182e009b2769104ab2f14e926381c4949d6f7453 +size 82121 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 d78df0b1f8..a0a5cc565d 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:b12689f5116ac8077e1fec5c556b0276e2d53241bbbf0d4be078186c9280d7e8 -size 95223 +oid sha256:2430b92bc20b2c3d142b5f84ae9fd62856fc4c717b0b226c2e096d725883d41f +size 54154 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 302188cf58..43a84bd8c8 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:3528fe676ae29534d80edcd08ca5874bcaaae6c1133332070dcd008df2c50da7 -size 138694 +oid sha256:e9f043a127d0f2658138d0ffbc3c296789bc0818caa83c1c18d465852d66dbd7 +size 79215 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 e0d901ea77..5d0c82e058 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:192c742bfd53f3a74d96c79e92443a922ac60c354b73d7abf292f30d10131307 -size 114842 +oid sha256:d74faa8d188a2915739de64ba9d71b2132b53c8d154db22510c524ae757578a5 +size 61183 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 a9e9a643a0..6fd875a6fd 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:9cae72debcf389db95fd4dc5053a6b1d2ea133cd56b6f268b929c68b6bf0e2e0 -size 64044 +oid sha256:a5ad9cb26866b35f6ad8c0ae054c7172a15b2fb2512bd123af3c0e5685c30410 +size 32766 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 e24920a4d5..77c058fa06 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:f76c909b7e804c8dd80b07fd5346d2036d2fded2bf9a855bd20f7da154a111f3 -size 83554 +oid sha256:e019c66f1662a736374d45246fcfca4172ab8e57906fcd3df7585c84c061d46d +size 42579 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 1550ce0e66..cfcafba1a7 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:566cf4c7ef7f08597c7381b67fd14489f7445dd216f12059a4888bd948e9e5d3 -size 62638 +oid sha256:b5271fba5dcee48982ccad321f987a67d6663dabc01d380eb0cafc178251bc00 +size 33971 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 26a1479858..2fc55fb4dd 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:22b86134c61484e0189f2b73417d36321d930474026421ba80a9ebc33a23b878 -size 61324 +oid sha256:1ba613bc2cf88dfb357e88671464272ab4279667b8c776b8b9db913161b7f450 +size 33060 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 32475f3874..e6ae7eb9af 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:22cebdb64f32d4818a35c07a4a2f5c2b1bae1fd465944d553b37a211f3e78ff8 -size 79480 +oid sha256:9f011b12419907461eef962053253bd096077724895895d03ab65768358fbec0 +size 43276 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 5ca3acc8fd..50d141aa1d 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:204fe52c4d99b661b2429c4659cde8fb04366c038ac7be0aa507cfba7c5aecfb -size 173275 +oid sha256:fe72f6268d445f204afcea4723624398ff49e479e8b608843cf287dfb94ebe4e +size 101257 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 387e79ad34..e555a2cbd9 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:af5be90cac48d0c86c6115b0fc6ceff3fdf934cecf5b332f2942f680a0636f08 -size 140801 +oid sha256:c29c21979beeb7f659979893d05d1da15602a8fbc4a61309cd6380b296d69367 +size 83563 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 74c5cb62da..33edc98590 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:385063f3976342ea525487e53801df14e644eb0a56898b1e81e0667323ff3f1a -size 172869 +oid sha256:34be7bfbdb32238c2e4bcf04908dc3830364019e1036797dcb98f472823fa52a +size 96348 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 9d73e42801..6b05304b17 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:5d9ecfd740c88faf8f159da4d704ec160fd17a4de63a870c4590cd16475248dc -size 146902 +oid sha256:7abdf3cffcb81643f9a0f814831133006f1ff5b2d339edbcf10b8b7497cf4e36 +size 94542 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 be9e2718dd..033682739a 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:7a247d55c2ee6b39707d929da18fa4242343c7819cd76a973397754a4dfb197f -size 123976 +oid sha256:d977a2a127cdbc1ce7638b4f30ddf9ca76a9dae708c66b09de1aa771f39f1c68 +size 77028 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 2d16e4af11..24843d5f03 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:27e0be11cb36a419a590de19cce432f5b78d9a3c86d024ca43b5904e758c569d -size 144104 +oid sha256:7c40a4c0cf7f9c0aba5ffa75938a76e42f12b7d1428aa9ad6cf7581e25aeaa06 +size 91717 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 d87f3fd5a2..a41b9989f8 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:aa6c2bb78faaf689cf979dd87b3a24b6405720755ce16c028cafab690ac7b318 -size 104334 +oid sha256:d4a64da29f144d4d4c525ea45e56819e02a46030ae09542be01fdd8ffc85a295 +size 60377 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 c7e9e58f93..9cbb203986 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:3e236adf08358a44452d4a215f6267a5596ce7e824bf9818d1e6180366833b1f -size 82182 +oid sha256:eee438f7cbe6615bab0df73689f6924ea153da28eaf1f4c0c22076f24f18085d +size 46476 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 4b04715b9a..64bcadf9bb 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:e0aeb15a04553142cade051d523bbc18b2e63997efa0b0c5f5b8bab8662074f7 -size 88550 +oid sha256:ee6fe4170eecd8936b1c27c7bea3bffe075e0cdc842316f4f2afc683f1116b67 +size 50729 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 2a0072cc67..d7c0cbc019 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:cf1d0ab1bead910fa3d0f0b3a6ed5bb9f26a470adc6019e1542b279b81d8d81a -size 109775 +oid sha256:c175f0db79d3ac74043dce3fe57d5c15c6ca38c954c008baf5fa917d3b9d4e0e +size 67374 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 b7b3619539..529557d9d8 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:171a705658d932b14073ef2affbf68829b4c0a4cfdecaa6672bf8ca63c03e4ff -size 103581 +oid sha256:7c76f0df12da8eac1fefb6ba9c0c89f5c8a7bcfbff442a4ebd763f1a4b359637 +size 63046 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 07003dfa4e..c53568d593 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:e720cb4ab955614764cc0c10f08146a50e08d4c5712a02b581ae25a4e4935c3a -size 113199 +oid sha256:7818965f97f227d9efeecaa2709a121291b7b6383848f20faabedc4ea46e6160 +size 69092 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 f62dcb0bf1..ca83b5de0d 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:ed70179c085142e5629075084348fe3b78fb027039b73c570510f22489dfb2dd -size 170507 +oid sha256:68e401e5f9aeb4c5fa0b8413871436f1eb33fe5eb82026f2ad5665169a13d0de +size 112784 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 3e0a6ea3a4..485f36f456 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:b0ab1a9d1ac3ad5d9065cb7b436d1fa12eefcd467bb78defcf930e25df33a773 -size 165594 +oid sha256:7a59de505b2f7f0f14a3bc513f477f6ae6fd3a72ff7bc7c628a4efba18fed565 +size 108009 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 9f04685444..f6ef814044 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:462a0d7d7d8056042e49dff3a896114d7db09b9e40e72e6b87f711caf6c1a993 -size 175519 +oid sha256:d810c82f5b9e57ab0a2b7a6093a7ca18fc71a6745bd6d5f492cba85fffbcfd0e +size 113115 From a5770d0bd046d262cc20d51e3cc84d48e708c764 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 11 Jun 2021 05:13:58 +1000 Subject: [PATCH 11/29] Increase memory to fix edge case issues --- .../Processors/Quantization/EuclideanPixelMap{TPixel}.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index efa5ac076f..62bf2a554c 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -126,13 +126,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// 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 646866 entries at 0.62MB. + /// Entry count is currently limited to 2371842 entries at 2MB. /// /// private struct ColorDistanceCache { private const int IndexBits = 5; - private const int IndexAlphaBits = 3; + private const int IndexAlphaBits = 5; private const int IndexCount = (1 << IndexBits) + 1; private const int IndexAlphaCount = (1 << IndexAlphaBits) + 1; private const int RgbShift = 8 - IndexBits; From 5699f8c63c99de5dbfbc2661a6d19dd1e8d287a1 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 11 Jun 2021 05:30:54 +1000 Subject: [PATCH 12/29] 1MB is enough --- .../Processors/Quantization/EuclideanPixelMap{TPixel}.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 62bf2a554c..fe834f76fd 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -132,7 +132,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization private struct ColorDistanceCache { private const int IndexBits = 5; - private const int IndexAlphaBits = 5; + private const int IndexAlphaBits = 4; private const int IndexCount = (1 << IndexBits) + 1; private const int IndexAlphaCount = (1 << IndexAlphaBits) + 1; private const int RgbShift = 8 - IndexBits; From 1fcf7f6057c62dfade7485850606054650b96cc8 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 11 Jun 2021 05:45:52 +1000 Subject: [PATCH 13/29] Fix comments --- .../Processors/Quantization/EuclideanPixelMap{TPixel}.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index fe834f76fd..cd7be80d52 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -126,7 +126,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// 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 2371842 entries at 2MB. + /// Entry count is currently limited to 1221858 entries at 1.17MB. /// /// private struct ColorDistanceCache From e773295622928db122e5bd99164b267b163e2ff6 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 11 Jun 2021 05:54:50 +1000 Subject: [PATCH 14/29] Update refs to match new output --- .../ApplyDitherFilterInBox_Rgba32_CalliphoraPartial.png | 4 ++-- .../DitherFilter_WorksWithAllDitherers_Bike_Bayer16x16.png | 4 ++-- .../DitherFilter_WorksWithAllDitherers_Bike_Bayer4x4.png | 4 ++-- .../DitherFilter_WorksWithAllDitherers_Bike_Bayer8x8.png | 4 ++-- .../DitherFilter_WorksWithAllDitherers_Bike_Ordered3x3.png | 4 ++-- ...ter_WorksWithAllDitherers_CalliphoraPartial_Bayer16x16.png | 4 ++-- ...ilter_WorksWithAllDitherers_CalliphoraPartial_Bayer4x4.png | 4 ++-- ...ilter_WorksWithAllDitherers_CalliphoraPartial_Bayer8x8.png | 4 ++-- ...ter_WorksWithAllDitherers_CalliphoraPartial_Ordered3x3.png | 4 ++-- ...itheringScale_david_OctreeQuantizer_OrderedDither_0.25.png | 4 ++-- ...itheringScale_david_OctreeQuantizer_OrderedDither_0.75.png | 4 ++-- ...thDitheringScale_david_OctreeQuantizer_OrderedDither_0.png | 4 ++-- ...thDitheringScale_david_OctreeQuantizer_OrderedDither_1.png | 4 ++-- ...eringScale_david_WebSafePaletteQuantizer_ErrorDither_1.png | 4 ++-- ...Scale_david_WebSafePaletteQuantizer_OrderedDither_0.75.png | 4 ++-- ...ingScale_david_WebSafePaletteQuantizer_OrderedDither_1.png | 4 ++-- ...ingScale_david_WernerPaletteQuantizer_ErrorDither_0.75.png | 4 ++-- ...heringScale_david_WernerPaletteQuantizer_ErrorDither_0.png | 4 ++-- ...gScale_david_WernerPaletteQuantizer_OrderedDither_0.25.png | 4 ++-- ...ngScale_david_WernerPaletteQuantizer_OrderedDither_0.5.png | 4 ++-- ...gScale_david_WernerPaletteQuantizer_OrderedDither_0.75.png | 4 ++-- ...ringScale_david_WernerPaletteQuantizer_OrderedDither_1.png | 4 ++-- ...WithDitheringScale_david_WuQuantizer_OrderedDither_0.5.png | 4 ++-- ...ithDitheringScale_david_WuQuantizer_OrderedDither_0.75.png | 4 ++-- ...onWithDitheringScale_david_WuQuantizer_OrderedDither_1.png | 4 ++-- .../ApplyQuantization_Bike_OctreeQuantizer_OrderedDither.png | 4 ++-- ...uantization_Bike_WebSafePaletteQuantizer_OrderedDither.png | 4 ++-- ...Quantization_Bike_WernerPaletteQuantizer_OrderedDither.png | 4 ++-- .../ApplyQuantization_Bike_WuQuantizer_OrderedDither.png | 4 ++-- ...zation_CalliphoraPartial_OctreeQuantizer_OrderedDither.png | 4 ++-- ...alliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png | 4 ++-- ...CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png | 4 ++-- ...antization_CalliphoraPartial_WuQuantizer_OrderedDither.png | 4 ++-- 33 files changed, 66 insertions(+), 66 deletions(-) diff --git a/tests/Images/External/ReferenceOutput/DitherTests/ApplyDitherFilterInBox_Rgba32_CalliphoraPartial.png b/tests/Images/External/ReferenceOutput/DitherTests/ApplyDitherFilterInBox_Rgba32_CalliphoraPartial.png index 8f9a86d360..9c57ccbf74 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:26397867e68e70105c17ba8f11f136a38ba0b954df476e21659187894a12700a -size 262263 +oid sha256:4c96e7e4e6bb6288fc4526f14a4efe386167df8995f4c0c7d5548d3e61226332 +size 262732 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 bd0e4c5abf..6e8f8a61cc 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:626e957a40bff07cc9beb02a5237c3d3804d6fcbf8ab604a09dcba4bbc2181fb -size 42722 +oid sha256:d646644e9289e6e8e934b9e5da3137dadcccbe8f18eb69c60a0b8a650af1f9f2 +size 43169 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 f029ef7229..db255d456a 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:164bdac284b0c096d92504edee2c5973a2faf8d3346c4e27d70dd4cb738adceb -size 43325 +oid sha256:5164049a38f40ebc5c82ce0c54b0a98cbaa24313bdcf8011fd68a870d2cfb5c4 +size 43476 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 77c058fa06..5a73469eba 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:e019c66f1662a736374d45246fcfca4172ab8e57906fcd3df7585c84c061d46d -size 42579 +oid sha256:2f0e0ebbd1e807fd78fe995492db539a22978e2c87871c9ab2511dcdc70b68dd +size 43211 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 689416dea3..e1754d9e35 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:35c24cdb2aa5ac378ccd5cd8c988dffe2e13d2e31cb164562ff65874e4371c35 -size 43991 +oid sha256:0301899d0bce225618c2dd7f381f6d39b8aa72120d6f9e810189f22a11fcac96 +size 44066 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 d4fe848ac4..742b2588eb 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:ebaffe515afc00a7fc8696c200203eeb3ad2b203628114693c1850099aaf679e -size 50694 +oid sha256:fa8890486f61627ea05a7f2578c6e6e4029c7c1451709f3525437e89ec13cfa1 +size 50796 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 ccbd0d509b..c80bd79ce4 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:5508035b0b4a81cb0d8b4623606d27ab57dde7b3d8d00893d51c804e723c6780 -size 51186 +oid sha256:643b4703fd64a85f6773a7478ffdda0ac5cf0ed56fd4f67b5a1869debc501341 +size 51227 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 64bcadf9bb..82f7417d4a 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:ee6fe4170eecd8936b1c27c7bea3bffe075e0cdc842316f4f2afc683f1116b67 -size 50729 +oid sha256:31e698abb20b916ab8ede236f603ab10649d7ade927e1b7789c249baff2ebe9b +size 50679 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 7b768c53ec..ced5b6c8f5 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:a41185a4d3fbbe743b2bd0e91efdfc575b0899c4e0ecf0233b49a5d4ccf9f055 -size 51901 +oid sha256:7d7002aa1064e994ce58cebfe933bf2745c62fcb7c6434f27da915f4409906c6 +size 52021 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 a4753ed9f1..e7fe3bc772 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:14e4662e1ca1ba90029853ded785be2a0d33c68fbe060ea47c1fd3df9f8ed7c4 -size 14272 +oid sha256:ec99338895bdada5cabe504afdcb0c0c95d8951e4404d31615a406b9956995c0 +size 14154 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 97cc99ddab..a532bafab2 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:64f77bd92915261cff939cf97ed3d86bcf203940bc956a4119571d1155bbb164 -size 15782 +oid sha256:81440783d73a7a1f9a800412d1ceaf219b518fe5d535620ab72de408bd9b049b +size 18072 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 0074924fd6..fccbe25877 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:f638f55b4b16ef4cffe7cd5e91153f7762b0869f76b65056e4712a2e05d866df -size 13388 +oid sha256:97805a6a6de3cf1e97026a4913afa573f7ec40f82e718dd9c5e4df69482a6e19 +size 13097 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 fd423be9c0..a65a578410 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:bcf4e748e505d0c49bd5560ccf78281f85cd855186279b4b02b528f9b3165d8d -size 16034 +oid sha256:9302cde1d49824b4fb5179acb67bc739a2f42949de759874b6b28d6d8ca7cfdb +size 18069 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 15dd5ced16..c6818e906c 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:77893252488f1562037c768c110083aed0d5c1cf015f19c78e9790df6c7b2062 -size 11819 +oid sha256:e73014c6698526f3341e1f6001938bf5c60501bd6114451903a654c43c5f1997 +size 11719 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 d196a86728..ada01e3fb9 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:cf1b3ac40730d73916d7e217e018c32aa9f93e5b85425ac907df4ca6174f98c6 -size 9469 +oid sha256:65ed6b37e1e872ea433e70884d204afaab0a427c6469aa52e68ccbcd9c1ba591 +size 9783 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 cb3cee98bf..65381439b1 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:322faa02893a893de60fab5aa6f52c712b08696af033f0f2df063a90360627fa -size 9834 +oid sha256:c5a8c2a3ef9a4e2a14d2daed18375205f62192990598f79d85e1ec36d30a17b3 +size 9855 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 0f064080e1..6ef7e65498 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:6d4a4aa237053c3f11360ac27608f10a887835838493e02468b9667dc15095ea -size 12839 +oid sha256:d7d62b46acff22858a1621656ddaa97c3610a7f13df9c5d77747b7364620b174 +size 12772 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 09cb5bffd0..0062fbcb98 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:5fbfcd90aea67a78cb8eff75d7fb419d2cf8cf3cb96be75f6aa1a419dcecf575 -size 9615 +oid sha256:9e532758291dd3d18b5b81c1d788db7854b322a633557f3ee273bb9d68c465ba +size 9582 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 978fda605f..820112e232 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:3f659caca3a0353f2170b787b64ad90a3e21ce7060007a73b6bdf5c0059833ca -size 12045 +oid sha256:43f24f7a6cbc19aec67b0710eb6320d6d71231e82268e6161733e87c06794769 +size 12095 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 614a9dee93..cdea60021e 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:b864cf0a2f6833c67eec2d26a8fbfb04126cadd93e7cbf1dc82197d4dace24b0 -size 11720 +oid sha256:296ff2ad8fc16188badc168a17c942ff1caf60627ea92af1b612a5e2eaf994af +size 12463 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 d669ece9da..7d292ed4f8 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:725419181103b80a7c1fb8895b7718228aaecc7eb7a9974a73995fd8e616327a -size 12051 +oid sha256:a1c65b5d308dcbfa4b49a1c7e65ca2de59167a5656f7c0b0c41970c9be1f3c7e +size 12101 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 30b656a5f2..9dec04cf3c 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:0ecf7ae9bb5403d8f5e99cf0c6688423152b697447fe86d6ebd0e20fd505dda2 -size 12641 +oid sha256:ab65e45933e24b726bcad66a0cd871c22c561abc8a3b1ce983d4f660e3aec5b8 +size 13017 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 d4a3e50923..a3fae67ba5 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:468af5ee9db9043354e2fe0b03f2518e4f04184a62e10868e030a828cf49d448 -size 16307 +oid sha256:aaa43edd42ae161875544699fa882bb9458578c03c1d2f60aa564de2a3fa4bdc +size 16598 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 75d4d846b3..2770df4030 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:858119aa5e30907b90281568b83f41c93412abb8db96af50b6eb76b4db52fb86 -size 17398 +oid sha256:246b917c4ce7f02f876416c18f95c9694234300984840ef2f579e26d45f05b40 +size 17321 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 269ae3001a..4e115a23cc 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:c8be9b1a7e05e9b091f66153266a7b41774aa3f33d09f7cb02335184076e545b -size 18016 +oid sha256:193d295cb48206ec0d1412075737519c6f0b413762fd11c2fc1c786a8e94341c +size 18031 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 43a84bd8c8..076d03e0ea 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:e9f043a127d0f2658138d0ffbc3c296789bc0818caa83c1c18d465852d66dbd7 -size 79215 +oid sha256:ae4a81d94d6435a8b60d0c081348bd754f9fa01e161d4b77b3520219e8b2be23 +size 79682 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 77c058fa06..5a73469eba 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:e019c66f1662a736374d45246fcfca4172ab8e57906fcd3df7585c84c061d46d -size 42579 +oid sha256:2f0e0ebbd1e807fd78fe995492db539a22978e2c87871c9ab2511dcdc70b68dd +size 43211 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 e6ae7eb9af..c38f7639bd 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:9f011b12419907461eef962053253bd096077724895895d03ab65768358fbec0 -size 43276 +oid sha256:f8a8ae7f3461e7c6cd2ac223b62f2314b75cc2ee7a66b7b369c4d34e6b62ab36 +size 43126 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 33edc98590..6ffe8533c2 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:34be7bfbdb32238c2e4bcf04908dc3830364019e1036797dcb98f472823fa52a -size 96348 +oid sha256:75d3d547d6c6fbbb11cbe5f0a533951cb161f7c1881794b176c2b453dc7e3701 +size 97192 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 24843d5f03..b230a09a95 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:7c40a4c0cf7f9c0aba5ffa75938a76e42f12b7d1428aa9ad6cf7581e25aeaa06 -size 91717 +oid sha256:1c6d7c01f4c2155852cf7f3e6b1c4f6006e5b3bf05e743eea775d485b1871cb9 +size 91996 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 64bcadf9bb..82f7417d4a 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:ee6fe4170eecd8936b1c27c7bea3bffe075e0cdc842316f4f2afc683f1116b67 -size 50729 +oid sha256:31e698abb20b916ab8ede236f603ab10649d7ade927e1b7789c249baff2ebe9b +size 50679 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 c53568d593..218e5b8d0e 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:7818965f97f227d9efeecaa2709a121291b7b6383848f20faabedc4ea46e6160 -size 69092 +oid sha256:4e0bbcd1b7ec716d3e5f6bc4cba063cbae7b97a238191836a6d87b38ba024333 +size 68902 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 f6ef814044..35a800fc0b 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:d810c82f5b9e57ab0a2b7a6093a7ca18fc71a6745bd6d5f492cba85fffbcfd0e -size 113115 +oid sha256:4dde6c9dff9e89b73734a1e1969369b4863e00c40dd6add03e668dfd4af70dc8 +size 113463 From b205b7a5fa4bac4a4bfb1c025a4b1b8ccce5bd1e Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Fri, 11 Jun 2021 07:39:28 +0200 Subject: [PATCH 15/29] Use tolerant comparer for tiff encoder test with palette --- .../Formats/Tiff/TiffEncoderTests.cs | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs index aca0758b82..f2f1470f94 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. -using System; using System.IO; using SixLabors.ImageSharp.Formats; @@ -414,7 +413,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff [Theory] [WithFile(GrayscaleUncompressed, PixelTypes.L8, TiffPhotometricInterpretation.BlackIsZero, TiffCompression.PackBits)] - [WithFile(PaletteDeflateMultistrip, PixelTypes.L8, TiffPhotometricInterpretation.PaletteColor, TiffCompression.Lzw)] [WithFile(RgbUncompressed, PixelTypes.Rgba32, TiffPhotometricInterpretation.Rgb, TiffCompression.Deflate)] [WithFile(RgbUncompressed, PixelTypes.Rgb24, TiffPhotometricInterpretation.Rgb, TiffCompression.None)] [WithFile(RgbUncompressed, PixelTypes.Rgba32, TiffPhotometricInterpretation.Rgb, TiffCompression.None)] @@ -423,6 +421,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff where TPixel : unmanaged, IPixel => TestStripLength(provider, photometricInterpretation, compression); + [Theory] + [WithFile(PaletteDeflateMultistrip, PixelTypes.L8, TiffPhotometricInterpretation.PaletteColor, TiffCompression.Lzw)] + public void TiffEncoder_StripLength_WithPalette(TestImageProvider provider, TiffPhotometricInterpretation photometricInterpretation, TiffCompression compression) + where TPixel : unmanaged, IPixel => + TestStripLength(provider, photometricInterpretation, compression, false, 0.01f); + [Theory] [WithFile(Calliphora_BiColorUncompressed, PixelTypes.L8, TiffPhotometricInterpretation.BlackIsZero, TiffCompression.CcittGroup3Fax)] public void TiffEncoder_StripLength_OutOfBounds(TestImageProvider provider, TiffPhotometricInterpretation photometricInterpretation, TiffCompression compression) @@ -430,7 +434,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff //// CcittGroup3Fax compressed data length can be larger than the original length. Assert.Throws(() => TestStripLength(provider, photometricInterpretation, compression)); - private static void TestStripLength(TestImageProvider provider, TiffPhotometricInterpretation photometricInterpretation, TiffCompression compression) + private static void TestStripLength( + TestImageProvider provider, + TiffPhotometricInterpretation photometricInterpretation, + TiffCompression compression, + bool useExactComparer = true, + float compareTolerance = 0.01f) where TPixel : unmanaged, IPixel { // arrange @@ -476,20 +485,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff } } - // TODO: Ask Brian about this. It seems like some of the images used - // are saved in a lossy format which can lead to differences compared - // to the original file unless full precision is used. - if (photometricInterpretation == TiffPhotometricInterpretation.PaletteColor) - { - return; - } - // Compare with reference. TestTiffEncoderCore( provider, inputMeta.BitsPerPixel, photometricInterpretation, - inputCompression); + inputCompression, + useExactComparer: useExactComparer, + compareTolerance: compareTolerance); } private static void TestTiffEncoderCore( From ee02333c57c19d5d7f1da0e601d1332cc820bcb3 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 11 Jun 2021 20:35:34 +1000 Subject: [PATCH 16/29] Update src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs Co-authored-by: Anton Firszov --- .../Processors/Quantization/EuclideanPixelMap{TPixel}.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index cd7be80d52..54fa366df7 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -126,7 +126,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// 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 1221858 entries at 1.17MB. + /// Entry count is currently limited to 610929 entries (1221858 bytes ~1.17MB). /// /// private struct ColorDistanceCache From 8c202d8fc259f9aa4d37fb6957d9755f6f376037 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 12 Jun 2021 00:16:12 +1000 Subject: [PATCH 17/29] Use pooling for pixelmap cache. --- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 15 ++++--- .../Allocators/ArrayPoolMemoryAllocator.cs | 8 ++-- .../PaletteDitherProcessor{TPixel}.cs | 5 ++- .../Quantization/EuclideanPixelMap{TPixel}.cs | 34 ++++++++++------ .../Quantization/OctreeQuantizer{TPixel}.cs | 39 ++++++++++++------- .../Quantization/PaletteQuantizer.cs | 2 +- .../Quantization/PaletteQuantizer{TPixel}.cs | 12 +++++- .../Quantization/QuantizerUtilities.cs | 1 - .../Quantization/WuQuantizer{TPixel}.cs | 13 ++++++- .../Processors/Dithering/DitherTests.cs | 3 +- 10 files changed, 93 insertions(+), 39 deletions(-) diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 9c1e95285c..c03104779e 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -150,8 +150,8 @@ namespace SixLabors.ImageSharp.Formats.Gif // The palette quantizer can reuse the same pixel map across multiple frames // since the palette is unchanging. This allows a reduction of memory usage across // multi frame gifs using a global palette. - EuclideanPixelMap pixelMap = default; - bool pixelMapSet = false; + Unsafe.SkipInit(out EuclideanPixelMap pixelMap); + bool pixelMapHasValue = false; for (int i = 0; i < image.Frames.Count; i++) { ImageFrame frame = image.Frames[i]; @@ -166,17 +166,22 @@ namespace SixLabors.ImageSharp.Formats.Gif } else { - if (!pixelMapSet) + if (!pixelMapHasValue) { - pixelMapSet = true; + pixelMapHasValue = true; pixelMap = new EuclideanPixelMap(this.configuration, quantized.Palette); } - using var paletteFrameQuantizer = new PaletteQuantizer(this.configuration, this.quantizer.Options, pixelMap); + using var paletteFrameQuantizer = new PaletteQuantizer(this.configuration, this.quantizer.Options, pixelMap, true); using IndexedImageFrame paletteQuantized = paletteFrameQuantizer.QuantizeFrame(frame, frame.Bounds()); this.WriteImageData(paletteQuantized, stream); } } + + if (pixelMapHasValue) + { + pixelMap.Dispose(); + } } private void EncodeLocal(Image image, IndexedImageFrame quantized, Stream stream) diff --git a/src/ImageSharp/Memory/Allocators/ArrayPoolMemoryAllocator.cs b/src/ImageSharp/Memory/Allocators/ArrayPoolMemoryAllocator.cs index 8814bbe1f5..4a3c42910f 100644 --- a/src/ImageSharp/Memory/Allocators/ArrayPoolMemoryAllocator.cs +++ b/src/ImageSharp/Memory/Allocators/ArrayPoolMemoryAllocator.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Memory int bufferSizeInBytes = length * itemSizeBytes; if (bufferSizeInBytes < 0 || bufferSizeInBytes > this.BufferCapacityInBytes) { - ThrowInvalidAllocationException(length); + ThrowInvalidAllocationException(length, this.BufferCapacityInBytes); } ArrayPool pool = this.GetArrayPool(bufferSizeInBytes); @@ -171,9 +171,9 @@ namespace SixLabors.ImageSharp.Memory } [MethodImpl(InliningOptions.ColdPath)] - private static void ThrowInvalidAllocationException(int length) => + private static void ThrowInvalidAllocationException(int length, int max) => throw new InvalidMemoryOperationException( - $"Requested allocation: {length} elements of {typeof(T).Name} is over the capacity of the MemoryAllocator."); + $"Requested allocation: '{length}' elements of '{typeof(T).Name}' is over the capacity in bytes '{max}' of the MemoryAllocator."); private ArrayPool GetArrayPool(int bufferSizeInBytes) { diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs index 4631cd4229..07af8a5af0 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs @@ -62,6 +62,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering if (disposing) { this.paletteOwner.Dispose(); + this.ditherProcessor.Dispose(); } this.paletteOwner = null; @@ -73,7 +74,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering /// . /// /// Internal for AOT - internal readonly struct DitherProcessor : IPaletteDitherImageProcessor + internal readonly struct DitherProcessor : IPaletteDitherImageProcessor, IDisposable { private readonly EuclideanPixelMap pixelMap; @@ -101,6 +102,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering this.pixelMap.GetClosestColor(color, out TPixel match); return match; } + + public void Dispose() => this.pixelMap.Dispose(); } } } diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 54fa366df7..20bdb87170 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -2,8 +2,10 @@ // Licensed under the Apache License, Version 2.0. using System; +using System.Buffers; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Processing.Processors.Quantization @@ -16,7 +18,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// This class is not threadsafe and should not be accessed in parallel. /// Doing so will result in non-idempotent results. /// - internal readonly struct EuclideanPixelMap + internal readonly struct EuclideanPixelMap : IDisposable where TPixel : unmanaged, IPixel { private readonly Rgba32[] rgbaPalette; @@ -32,7 +34,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization { this.Palette = palette; this.rgbaPalette = new Rgba32[palette.Length]; - this.cache = ColorDistanceCache.Create(); + this.cache = new ColorDistanceCache(configuration.MemoryAllocator); PixelOperations.Instance.ToRgba32(configuration, this.Palette.Span, this.rgbaPalette); } @@ -118,6 +120,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization return (deltaR * deltaR) + (deltaG * deltaG) + (deltaB * deltaB) + (deltaA * deltaA); } + public void Dispose() => this.cache.Dispose(); + /// /// A cache for storing color distance matching results. /// @@ -129,7 +133,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// Entry count is currently limited to 610929 entries (1221858 bytes ~1.17MB). /// /// - private struct ColorDistanceCache + private unsafe struct ColorDistanceCache : IDisposable { private const int IndexBits = 5; private const int IndexAlphaBits = 4; @@ -138,16 +142,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization private const int RgbShift = 8 - IndexBits; private const int AlphaShift = 8 - IndexAlphaBits; private const int TableLength = IndexCount * IndexCount * IndexCount * IndexAlphaCount; - private short[] table; + private readonly IMemoryOwner tableOwner; + private MemoryHandle tableHandle; + private readonly short* table; - public static ColorDistanceCache Create() + public ColorDistanceCache(MemoryAllocator memoryAllocator) { - ColorDistanceCache result = default; - short[] entries = new short[TableLength]; - entries.AsSpan().Fill(-1); - result.table = entries; - - return result; + this.tableOwner = memoryAllocator.Allocate(TableLength); + this.tableOwner.GetSpan().Fill(-1); + this.tableHandle = this.tableOwner.Memory.Pin(); + this.table = (short*)this.tableHandle.Pointer; } [MethodImpl(InliningOptions.ShortMethod)] @@ -173,6 +177,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization return match > -1; } + public void Clear() => this.tableOwner.GetSpan().Fill(-1); + [MethodImpl(InliningOptions.ShortMethod)] private static int GetPaletteIndex(int r, int g, int b, int a) => (r << ((IndexBits * 2) + IndexAlphaBits)) @@ -183,6 +189,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization + (g << IndexBits) + ((r + g + b) << IndexAlphaBits) + r + g + b + a; + + public void Dispose() + { + this.tableHandle.Dispose(); + this.tableOwner?.Dispose(); + } } } } diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs index fab462e2ef..10b26337f4 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs @@ -25,6 +25,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization private IMemoryOwner paletteOwner; private ReadOnlyMemory palette; private EuclideanPixelMap pixelMap; + private bool pixelMapHasValue; private readonly bool isDithering; private bool isDisposed; @@ -46,8 +47,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization this.bitDepth = Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.maxColors), 1, 8); this.octree = new Octree(this.bitDepth); this.paletteOwner = configuration.MemoryAllocator.Allocate(this.maxColors, AllocationOptions.Clean); - this.palette = default; this.pixelMap = default; + this.pixelMapHasValue = false; + this.palette = default; this.isDithering = !(this.Options.Dither is null); this.isDisposed = false; } @@ -69,26 +71,27 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization } /// - [MethodImpl(InliningOptions.ShortMethod)] public void AddPaletteColors(Buffer2DRegion pixelRegion) { Rectangle bounds = pixelRegion.Rectangle; Buffer2D source = pixelRegion.Buffer; - using IMemoryOwner buffer = this.Configuration.MemoryAllocator.Allocate(bounds.Width); - Span bufferSpan = buffer.GetSpan(); - - // Loop through each row - for (int y = bounds.Top; y < bounds.Bottom; y++) + using (IMemoryOwner buffer = this.Configuration.MemoryAllocator.Allocate(bounds.Width)) { - Span row = source.GetRowSpan(y).Slice(bounds.Left, bounds.Width); - PixelOperations.Instance.ToRgba32(this.Configuration, row, bufferSpan); + Span bufferSpan = buffer.GetSpan(); - for (int x = 0; x < bufferSpan.Length; x++) + // Loop through each row + for (int y = bounds.Top; y < bounds.Bottom; y++) { - Rgba32 rgba = bufferSpan[x]; + Span row = source.GetRowSpan(y).Slice(bounds.Left, bounds.Width); + PixelOperations.Instance.ToRgba32(this.Configuration, row, bufferSpan); + + for (int x = 0; x < bufferSpan.Length; x++) + { + Rgba32 rgba = bufferSpan[x]; - // Add the color to the Octree - this.octree.AddColor(rgba); + // Add the color to the Octree + this.octree.AddColor(rgba); + } } } @@ -108,7 +111,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization this.octree.Palletize(paletteSpan, max, ref paletteIndex); ReadOnlyMemory result = this.paletteOwner.Memory.Slice(0, paletteSpan.Length); + + // When called by QuantizerUtilities.BuildPalette this prevents + // mutiple instances of the map being created but not disposed. + if (this.pixelMapHasValue) + { + this.pixelMap.Dispose(); + } + this.pixelMap = new EuclideanPixelMap(this.Configuration, result); + this.pixelMapHasValue = true; this.palette = result; } @@ -143,6 +155,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization this.isDisposed = true; this.paletteOwner.Dispose(); this.paletteOwner = null; + this.pixelMap.Dispose(); } } diff --git a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs index bc5eb783f7..a83c760c20 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization Color.ToPixel(configuration, this.colorPalette.Span, palette.AsSpan()); var pixelMap = new EuclideanPixelMap(configuration, palette); - return new PaletteQuantizer(configuration, options, pixelMap); + return new PaletteQuantizer(configuration, options, pixelMap, false); } } } diff --git a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs index d0dbdae204..9329bdfebe 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs @@ -17,6 +17,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization where TPixel : unmanaged, IPixel { private readonly EuclideanPixelMap pixelMap; + private readonly bool leaveMap; /// /// Initializes a new instance of the struct. @@ -24,11 +25,15 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// The configuration which allows altering default behaviour or extending the library. /// The quantizer options defining quantization rules. /// The pixel map for looking up color matches from a predefined palette. + /// + /// to leave the pixel map undisposed after disposing the object; otherwise, . + /// [MethodImpl(InliningOptions.ShortMethod)] public PaletteQuantizer( Configuration configuration, QuantizerOptions options, - EuclideanPixelMap pixelMap) + EuclideanPixelMap pixelMap, + bool leaveMap) { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(options, nameof(options)); @@ -36,6 +41,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization this.Configuration = configuration; this.Options = options; this.pixelMap = pixelMap; + this.leaveMap = leaveMap; } /// @@ -66,6 +72,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// public void Dispose() { + if (!this.leaveMap) + { + this.pixelMap.Dispose(); + } } } } diff --git a/src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs b/src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs index ac9375fb44..6c963bfabd 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs @@ -3,7 +3,6 @@ using System; using System.Runtime.CompilerServices; -using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors.Dithering; diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs index 2d52eb746f..b6f4be4949 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs @@ -72,6 +72,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization private int maxColors; private readonly Box[] colorCube; private EuclideanPixelMap pixelMap; + private bool pixelMapHasValue; private readonly bool isDithering; private bool isDisposed; @@ -93,10 +94,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization this.momentsOwner = this.memoryAllocator.Allocate(TableLength, AllocationOptions.Clean); this.tagsOwner = this.memoryAllocator.Allocate(TableLength, AllocationOptions.Clean); this.paletteOwner = this.memoryAllocator.Allocate(this.maxColors, AllocationOptions.Clean); - this.palette = default; this.colorCube = new Box[this.maxColors]; this.isDisposed = false; this.pixelMap = default; + this.pixelMapHasValue = false; + this.palette = default; this.isDithering = this.isDithering = !(this.Options.Dither is null); } @@ -145,7 +147,15 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization ReadOnlyMemory result = this.paletteOwner.Memory.Slice(0, paletteSpan.Length); if (this.isDithering) { + // When called by QuantizerUtilities.BuildPalette this prevents + // mutiple instances of the map being created but not disposed. + if (this.pixelMapHasValue) + { + this.pixelMap.Dispose(); + } + this.pixelMap = new EuclideanPixelMap(this.Configuration, result); + this.pixelMapHasValue = true; } this.palette = result; @@ -191,6 +201,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization this.momentsOwner = null; this.tagsOwner = null; this.paletteOwner = null; + this.pixelMap.Dispose(); } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 2d464794ca..175b88f982 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. +using System.Runtime.CompilerServices; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors.Dithering; @@ -155,7 +156,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Dithering appendPixelTypeToFileName: false); } - [Theory] + [Theory(Skip = "Unable to assign capacity smaller than the image.")] [WithFile(TestImages.Png.Bike, PixelTypes.Rgba32, nameof(OrderedDither.Ordered3x3))] [WithFile(TestImages.Png.Bike, PixelTypes.Rgba32, nameof(ErrorDither.FloydSteinberg))] public void CommonDitherers_WorkWithDiscoBuffers( From a6b7e5228dcf4bd8719d6ddc708a2a1e2dcb3e86 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 12 Jun 2021 00:17:14 +1000 Subject: [PATCH 18/29] Use int --- .../Processors/Quantization/EuclideanPixelMap{TPixel}.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 20bdb87170..3ab339ca0d 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization for (int i = 0; i < this.rgbaPalette.Length; i++) { Rgba32 candidate = this.rgbaPalette[i]; - float distance = DistanceSquared(rgba, candidate); + int distance = DistanceSquared(rgba, candidate); // If it's an exact match, exit the loop if (distance == 0) @@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// The second point. /// The distance squared. [MethodImpl(InliningOptions.ShortMethod)] - private static float DistanceSquared(Rgba32 a, Rgba32 b) + private static int DistanceSquared(Rgba32 a, Rgba32 b) { int deltaR = a.R - b.R; int deltaG = a.G - b.G; From 27ec4ac074d348693b1a3cb5529a3c1bbf90d689 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 12 Jun 2021 06:50:48 +1000 Subject: [PATCH 19/29] Use ArrayPool byte with pinning. --- .../Quantization/EuclideanPixelMap{TPixel}.cs | 34 +++++++++++-------- .../Processors/Dithering/DitherTests.cs | 2 +- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 3ab339ca0d..89b6c315ee 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -5,7 +5,6 @@ using System; using System.Buffers; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Processing.Processors.Quantization @@ -34,7 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization { this.Palette = palette; this.rgbaPalette = new Rgba32[palette.Length]; - this.cache = new ColorDistanceCache(configuration.MemoryAllocator); + this.cache = ColorDistanceCache.Create(); PixelOperations.Instance.ToRgba32(configuration, this.Palette.Span, this.rgbaPalette); } @@ -142,18 +141,22 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization private const int RgbShift = 8 - IndexBits; private const int AlphaShift = 8 - IndexAlphaBits; private const int TableLength = IndexCount * IndexCount * IndexCount * IndexAlphaCount; - private readonly IMemoryOwner tableOwner; + private const int TableLengthBytes = TableLength * sizeof(short); private MemoryHandle tableHandle; - private readonly short* table; + private readonly byte[] table; + private readonly short* tablePointer; - public ColorDistanceCache(MemoryAllocator memoryAllocator) + private ColorDistanceCache(int length, int lengthBytes) { - this.tableOwner = memoryAllocator.Allocate(TableLength); - this.tableOwner.GetSpan().Fill(-1); - this.tableHandle = this.tableOwner.Memory.Pin(); - this.table = (short*)this.tableHandle.Pointer; + this.table = ArrayPool.Shared.Rent(lengthBytes); + this.tableHandle = this.table.AsMemory().Pin(); + new Span(this.tableHandle.Pointer, length).Fill(-1); + this.tablePointer = (short*)this.tableHandle.Pointer; } + public static ColorDistanceCache Create() + => new ColorDistanceCache(TableLength, TableLengthBytes); + [MethodImpl(InliningOptions.ShortMethod)] public void Add(Rgba32 rgba, byte index) { @@ -162,7 +165,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization int b = rgba.B >> RgbShift; int a = rgba.A >> AlphaShift; int idx = GetPaletteIndex(r, g, b, a); - this.table[idx] = index; + this.tablePointer[idx] = index; } [MethodImpl(InliningOptions.ShortMethod)] @@ -173,12 +176,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization int b = rgba.B >> RgbShift; int a = rgba.A >> AlphaShift; int idx = GetPaletteIndex(r, g, b, a); - match = this.table[idx]; + match = this.tablePointer[idx]; return match > -1; } - public void Clear() => this.tableOwner.GetSpan().Fill(-1); - [MethodImpl(InliningOptions.ShortMethod)] private static int GetPaletteIndex(int r, int g, int b, int a) => (r << ((IndexBits * 2) + IndexAlphaBits)) @@ -192,8 +193,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization public void Dispose() { - this.tableHandle.Dispose(); - this.tableOwner?.Dispose(); + if (this.table != null) + { + ArrayPool.Shared.Return(this.table); + this.tableHandle.Dispose(); + } } } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 175b88f982..37443a5b40 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -156,7 +156,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Dithering appendPixelTypeToFileName: false); } - [Theory(Skip = "Unable to assign capacity smaller than the image.")] + [Theory] [WithFile(TestImages.Png.Bike, PixelTypes.Rgba32, nameof(OrderedDither.Ordered3x3))] [WithFile(TestImages.Png.Bike, PixelTypes.Rgba32, nameof(ErrorDither.FloydSteinberg))] public void CommonDitherers_WorkWithDiscoBuffers( From 58a3a958bfc74f00a9d75011b8c7ebdc8c8bd65b Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 12 Jun 2021 07:28:19 +1000 Subject: [PATCH 20/29] Just use ArrayPool.Shared --- .../Quantization/EuclideanPixelMap{TPixel}.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 89b6c315ee..b2422c6d36 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -141,21 +141,20 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization private const int RgbShift = 8 - IndexBits; private const int AlphaShift = 8 - IndexAlphaBits; private const int TableLength = IndexCount * IndexCount * IndexCount * IndexAlphaCount; - private const int TableLengthBytes = TableLength * sizeof(short); private MemoryHandle tableHandle; - private readonly byte[] table; + private readonly short[] table; private readonly short* tablePointer; - private ColorDistanceCache(int length, int lengthBytes) + private ColorDistanceCache(int length) { - this.table = ArrayPool.Shared.Rent(lengthBytes); + this.table = ArrayPool.Shared.Rent(length); + this.table.AsSpan().Fill(-1); this.tableHandle = this.table.AsMemory().Pin(); - new Span(this.tableHandle.Pointer, length).Fill(-1); this.tablePointer = (short*)this.tableHandle.Pointer; } public static ColorDistanceCache Create() - => new ColorDistanceCache(TableLength, TableLengthBytes); + => new ColorDistanceCache(TableLength); [MethodImpl(InliningOptions.ShortMethod)] public void Add(Rgba32 rgba, byte index) @@ -195,7 +194,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization { if (this.table != null) { - ArrayPool.Shared.Return(this.table); + ArrayPool.Shared.Return(this.table); this.tableHandle.Dispose(); } } From 2ab611fd5cd106b1d5cade593ddcc105a9b62f14 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 12 Jun 2021 10:11:36 +1000 Subject: [PATCH 21/29] Use 5 bits for each component --- .../Quantization/EuclideanPixelMap{TPixel}.cs | 23 +++++++++++-------- ...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 ++-- ...avid_OctreeQuantizer_OrderedDither_0.5.png | 4 ++-- ...vid_OctreeQuantizer_OrderedDither_0.75.png | 4 ++-- ..._david_OctreeQuantizer_OrderedDither_1.png | 4 ++-- ...afePaletteQuantizer_OrderedDither_0.25.png | 4 ++-- ...SafePaletteQuantizer_OrderedDither_0.5.png | 4 ++-- ...afePaletteQuantizer_OrderedDither_0.75.png | 4 ++-- ...ebSafePaletteQuantizer_OrderedDither_1.png | 4 ++-- ...nerPaletteQuantizer_OrderedDither_0.25.png | 4 ++-- ...rnerPaletteQuantizer_OrderedDither_0.5.png | 4 ++-- ...nerPaletteQuantizer_OrderedDither_0.75.png | 4 ++-- ...WernerPaletteQuantizer_OrderedDither_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_1.png | 4 ++-- ...ion_Bike_OctreeQuantizer_OrderedDither.png | 4 ++-- ..._WebSafePaletteQuantizer_OrderedDither.png | 4 ++-- ...e_WernerPaletteQuantizer_OrderedDither.png | 4 ++-- ...ization_Bike_WuQuantizer_OrderedDither.png | 4 ++-- ...oraPartial_OctreeQuantizer_ErrorDither.png | 4 ++-- ...iphoraPartial_OctreeQuantizer_NoDither.png | 4 ++-- ...aPartial_OctreeQuantizer_OrderedDither.png | 4 ++-- ..._WebSafePaletteQuantizer_OrderedDither.png | 4 ++-- ...l_WernerPaletteQuantizer_OrderedDither.png | 4 ++-- ...phoraPartial_WuQuantizer_OrderedDither.png | 4 ++-- 37 files changed, 86 insertions(+), 81 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index b2422c6d36..772b478dcb 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -129,32 +129,37 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// 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 610929 entries (1221858 bytes ~1.17MB). + /// Entry count is currently limited to 1185921 entries (2371842 bytes ~2.26MB). /// /// private unsafe struct ColorDistanceCache : IDisposable { private const int IndexBits = 5; - private const int IndexAlphaBits = 4; + private const int IndexAlphaBits = 5; private const int IndexCount = (1 << IndexBits) + 1; private const int IndexAlphaCount = (1 << IndexAlphaBits) + 1; private const int RgbShift = 8 - IndexBits; private const int AlphaShift = 8 - IndexAlphaBits; - private const int TableLength = IndexCount * IndexCount * IndexCount * IndexAlphaCount; + private const int Entries = IndexCount * IndexCount * IndexCount * IndexAlphaCount; + private const int BufferLength = (Entries + 1) >> 1; private MemoryHandle tableHandle; - private readonly short[] table; + private readonly int[] table; private readonly short* tablePointer; - private ColorDistanceCache(int length) + private ColorDistanceCache(int bufferLength, int entries) { - this.table = ArrayPool.Shared.Rent(length); - this.table.AsSpan().Fill(-1); + // We use ArrayPool.Shared for several reasons. + // 1. To avoid out of range issues caused by configuring small discontiguous buffers rented via MemoryAllocator + // 2. To ensure that the rented buffer is actually pooled. + // 3. The .NET runtime already uses this pool so we might already have a pooled array present. + this.table = ArrayPool.Shared.Rent(bufferLength); this.tableHandle = this.table.AsMemory().Pin(); + new Span(this.tableHandle.Pointer, entries).Fill(-1); this.tablePointer = (short*)this.tableHandle.Pointer; } public static ColorDistanceCache Create() - => new ColorDistanceCache(TableLength); + => new ColorDistanceCache(BufferLength, Entries); [MethodImpl(InliningOptions.ShortMethod)] public void Add(Rgba32 rgba, byte index) @@ -194,7 +199,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization { if (this.table != null) { - ArrayPool.Shared.Return(this.table); + ArrayPool.Shared.Return(this.table); this.tableHandle.Dispose(); } } diff --git a/tests/Images/External/ReferenceOutput/DitherTests/ApplyDitherFilterInBox_Rgba32_CalliphoraPartial.png b/tests/Images/External/ReferenceOutput/DitherTests/ApplyDitherFilterInBox_Rgba32_CalliphoraPartial.png index 9c57ccbf74..79a43ed87a 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:4c96e7e4e6bb6288fc4526f14a4efe386167df8995f4c0c7d5548d3e61226332 -size 262732 +oid sha256:4d88eb2e50ca9dbed0e8dfe4ad278cd88ddb9d3408b30d9dfe59102b167f570b +size 262887 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 6e8f8a61cc..f16ff0ef75 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:d646644e9289e6e8e934b9e5da3137dadcccbe8f18eb69c60a0b8a650af1f9f2 -size 43169 +oid sha256:97cfbef27319988b67aeac87d469d044edd925c90e4774170465f51eed85c16a +size 42915 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 19dfed35b7..05d26b6475 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:7319a7592fb8c7b26dc2ce5b0d19bf63f5b25239eabd2d7cdd495c8a8b8d8a84 -size 41836 +oid sha256:3a799b69938507e3fd2a74ffa7c6c6ad6574acb25861a0a50cb8361520d468de +size 41809 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 db255d456a..b437c0d034 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:5164049a38f40ebc5c82ce0c54b0a98cbaa24313bdcf8011fd68a870d2cfb5c4 -size 43476 +oid sha256:9932db58eeb966cd293b1b7a375e9c1b17b6d09153c679ebf03d42a08d2ce9b3 +size 43332 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 5a73469eba..9e97e5f96c 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:2f0e0ebbd1e807fd78fe995492db539a22978e2c87871c9ab2511dcdc70b68dd -size 43211 +oid sha256:67ebf42bc82483d1778254d95a376230437611dce91c80f8ecda608de56bffe7 +size 43108 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 e1754d9e35..b84521842c 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:0301899d0bce225618c2dd7f381f6d39b8aa72120d6f9e810189f22a11fcac96 -size 44066 +oid sha256:8d5cdda990ac146a7580f58cc2bcab72f903dde564a394de7df4cc37e6dcf2dd +size 43906 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 742b2588eb..436c676926 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:fa8890486f61627ea05a7f2578c6e6e4029c7c1451709f3525437e89ec13cfa1 -size 50796 +oid sha256:c11e6c197bd1c227ae8f4af7e8c232cfe75db6929ab12bddf5e6554fbaed3f01 +size 50716 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 3d42b278c7..6e1ad33117 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:46f47d132c34d455e1b19dc455a9e8ca124324bf7820c08dea5441c769631daf -size 52379 +oid sha256:69ff9654eb61f2bfdd44fb25aff959c5b831015e283cc91a90e3abf6f681dc88 +size 52429 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 c80bd79ce4..a257ccd615 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:643b4703fd64a85f6773a7478ffdda0ac5cf0ed56fd4f67b5a1869debc501341 -size 51227 +oid sha256:6ee945ac5120e4198d1f94e6467cc0f77c90869bf5a09942e7720dddcfdfbe07 +size 51262 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 82f7417d4a..d8cb415022 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:31e698abb20b916ab8ede236f603ab10649d7ade927e1b7789c249baff2ebe9b -size 50679 +oid sha256:1b023505175ae39a93fa55c85aa31466f0aca76fab0ee54f9667648b91f9aeb9 +size 50789 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 ced5b6c8f5..d6be5125f8 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:7d7002aa1064e994ce58cebfe933bf2745c62fcb7c6434f27da915f4409906c6 -size 52021 +oid sha256:6b18e8b80035a3c5985ebedab5eaf1b0e580d26dd2a8167e687e7b3dd6536751 +size 51922 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 987a352042..853e368e3e 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:8db81aedc3d344272e45c623f75064a643d46186aaa5bd2839f0b4edfa132b53 -size 15017 +oid sha256:9699207803467b8718a719c7581e1ed6bf0c923a5adaf325aea8358d274fece5 +size 18334 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 a532bafab2..5ace2a5059 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:81440783d73a7a1f9a800412d1ceaf219b518fe5d535620ab72de408bd9b049b -size 18072 +oid sha256:0e3acfa5b7c6ef3bec68b5fa8db91b2e6160e01d1f952a055831cea2f0a58b0f +size 18675 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 a65a578410..e4e4e10942 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:9302cde1d49824b4fb5179acb67bc739a2f42949de759874b6b28d6d8ca7cfdb -size 18069 +oid sha256:fc1c1b5d0d0abec9b52ae7a83946a46020d2394a5f49f42e2ddb50fac988e974 +size 18874 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 12f165c632..b120b7fe98 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:528439fcbd9361ce7a2b9d251357079ff1343be90c2f7886e448c207ac50b7b1 -size 8966 +oid sha256:420d8ff32aa8ffa789e0c5dd00151856a016bc4f83ad035fdb4a8a22c338e247 +size 8952 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 e889c01ffa..e58dac830f 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:70eabe6e0b1d8cb5ed7cbb0dbb505a58b4dab02683e04573337670d1d947a247 -size 8533 +oid sha256:93f3be15cb660c7c74c0de12d459c390c5f3c950d09dc4bcf617f5093e2b818b +size 8606 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 ada01e3fb9..b6bb89b9ec 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:65ed6b37e1e872ea433e70884d204afaab0a427c6469aa52e68ccbcd9c1ba591 -size 9783 +oid sha256:a035a0b97ac471500a9dbead47a0d13deb449136980b89795b671b3e14481c9e +size 9716 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 65381439b1..f6bae9649e 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:c5a8c2a3ef9a4e2a14d2daed18375205f62192990598f79d85e1ec36d30a17b3 -size 9855 +oid sha256:fac9fc2316ccf7a464e93d0406acdf37d5aac7f76f54c87454fa41b13c8224fc +size 9731 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 820112e232..3c2d6529fb 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:43f24f7a6cbc19aec67b0710eb6320d6d71231e82268e6161733e87c06794769 -size 12095 +oid sha256:12f7bacf0402f821e3c80f65c29218bc1f1334392edc463b617cf711667db722 +size 12381 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 cdea60021e..07790191db 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:296ff2ad8fc16188badc168a17c942ff1caf60627ea92af1b612a5e2eaf994af -size 12463 +oid sha256:436d168a3501da20c327cb3d2909cdd465585ee3f76a2534e37a36771e10115e +size 12596 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 7d292ed4f8..49a4514226 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:a1c65b5d308dcbfa4b49a1c7e65ca2de59167a5656f7c0b0c41970c9be1f3c7e -size 12101 +oid sha256:c952f81377c83b2255c427d0911b898e500d163d870de778b69778a9ab8c8278 +size 12459 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 9dec04cf3c..394f8f85b4 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:ab65e45933e24b726bcad66a0cd871c22c561abc8a3b1ce983d4f660e3aec5b8 -size 13017 +oid sha256:2b542c86ea4fef3a37e89c1087dddafeeccf523e7c0721743f34d35da5e0653e +size 13116 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 a8bca66dd1..554f587743 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:ffa0d2cd6df22963e839645c88132af1067331f55f73b9df9824dc4c6be8e995 -size 14994 +oid sha256:3edb6672168fc58a2bb6766d48a0883aa35fdc6873d2f4b9f26d3b5fa6cb46dd +size 15574 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 a3fae67ba5..fc6da7bbb1 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:aaa43edd42ae161875544699fa882bb9458578c03c1d2f60aa564de2a3fa4bdc -size 16598 +oid sha256:9fd79ec840f8bd82b41d93987187531187a4bd957d7f0d497a86fa61de52cec7 +size 16733 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 2770df4030..36015f6638 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:246b917c4ce7f02f876416c18f95c9694234300984840ef2f579e26d45f05b40 -size 17321 +oid sha256:360121a75c96434daa57f2b996e9776cc1efdf25aa3f7e926abd6d04c9ee4184 +size 17355 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 4e115a23cc..777be644a4 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:193d295cb48206ec0d1412075737519c6f0b413762fd11c2fc1c786a8e94341c -size 18031 +oid sha256:97d3b5d804c50da0d9c5db7278b16bb807e246dbd083c8c62ec7d4d7a65a1b45 +size 18070 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 076d03e0ea..4b7a06f302 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:ae4a81d94d6435a8b60d0c081348bd754f9fa01e161d4b77b3520219e8b2be23 -size 79682 +oid sha256:4cd9433cdab37510cf6d98ce5838a69675359982376f7ef5c9e716c49772af74 +size 79370 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 5a73469eba..9e97e5f96c 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:2f0e0ebbd1e807fd78fe995492db539a22978e2c87871c9ab2511dcdc70b68dd -size 43211 +oid sha256:67ebf42bc82483d1778254d95a376230437611dce91c80f8ecda608de56bffe7 +size 43108 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 c38f7639bd..e3e48a17a6 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:f8a8ae7f3461e7c6cd2ac223b62f2314b75cc2ee7a66b7b369c4d34e6b62ab36 -size 43126 +oid sha256:242379eee61c3d82f10e8b36db0567749443f91a6e13e766cc1ee3a3eeff7e2c +size 43006 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 6ffe8533c2..54cacf5a10 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:75d3d547d6c6fbbb11cbe5f0a533951cb161f7c1881794b176c2b453dc7e3701 -size 97192 +oid sha256:49e072dc73ba96dffa021b3e9bbf169102bd9ae7b9d4ed0a69b55178f1592ae5 +size 97415 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 6b05304b17..bbe5e4a20a 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:7abdf3cffcb81643f9a0f814831133006f1ff5b2d339edbcf10b8b7497cf4e36 -size 94542 +oid sha256:8c6041ecc220ee8cd576aff06871bc1f3b7363dffe334bbab83344c5b96cbde3 +size 94511 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 033682739a..a09d04c793 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:d977a2a127cdbc1ce7638b4f30ddf9ca76a9dae708c66b09de1aa771f39f1c68 -size 77028 +oid sha256:912de82dc98a8dd72ffc5549125c397379a859a23ffe48f01e4f1c5a28ff1d18 +size 77029 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 b230a09a95..44139c4e00 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:1c6d7c01f4c2155852cf7f3e6b1c4f6006e5b3bf05e743eea775d485b1871cb9 -size 91996 +oid sha256:bedb363c412c4c387fabe4d65ca769079376f4cc56a3bfdd767f0ae8441b3dfb +size 92003 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 82f7417d4a..d8cb415022 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:31e698abb20b916ab8ede236f603ab10649d7ade927e1b7789c249baff2ebe9b -size 50679 +oid sha256:1b023505175ae39a93fa55c85aa31466f0aca76fab0ee54f9667648b91f9aeb9 +size 50789 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 218e5b8d0e..efbb6a013b 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:4e0bbcd1b7ec716d3e5f6bc4cba063cbae7b97a238191836a6d87b38ba024333 -size 68902 +oid sha256:f2636953295972ede173dbfaf3b67f7cb91f1c3f4ccc79f70e078bd94af9422d +size 68579 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 35a800fc0b..c29d9ec100 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:4dde6c9dff9e89b73734a1e1969369b4863e00c40dd6add03e668dfd4af70dc8 -size 113463 +oid sha256:a65928b17616922155b030737af67de806c195bd993752a7d5e17ec7e94150fc +size 113919 From 287c1d6e480c511473fad02dfa090e1e0a63989c Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 13 Jun 2021 17:52:28 +0100 Subject: [PATCH 22/29] Update src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs Co-authored-by: Anton Firszov --- .../Processors/Quantization/EuclideanPixelMap{TPixel}.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 772b478dcb..a51c241474 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -186,7 +186,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization [MethodImpl(InliningOptions.ShortMethod)] private static int GetPaletteIndex(int r, int g, int b, int a) - => (r << ((IndexBits * 2) + IndexAlphaBits)) + => (r << ((IndexBits << 1) + IndexAlphaBits)) + (r << (IndexBits + IndexAlphaBits + 1)) + (g << (IndexBits + IndexAlphaBits)) + (r << (IndexBits * 2)) From a9114b3efe7f34bcfd78ae55bc5b79519e8adef2 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 13 Jun 2021 17:52:43 +0100 Subject: [PATCH 23/29] Update src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs Co-authored-by: Anton Firszov --- .../Processors/Quantization/EuclideanPixelMap{TPixel}.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index a51c241474..9b626303bd 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -189,7 +189,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization => (r << ((IndexBits << 1) + IndexAlphaBits)) + (r << (IndexBits + IndexAlphaBits + 1)) + (g << (IndexBits + IndexAlphaBits)) - + (r << (IndexBits * 2)) + + (r << (IndexBits << 1)) + (r << (IndexBits + 1)) + (g << IndexBits) + ((r + g + b) << IndexAlphaBits) From 021ac8b15f391ace474c83f600ab40a71ac5c6b1 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 16 Jun 2021 01:15:15 +1000 Subject: [PATCH 24/29] Fix buffer allocation --- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 2 +- .../Allocators/ArrayPoolMemoryAllocator.cs | 4 ---- .../Quantization/EuclideanPixelMap{TPixel}.cs | 23 +++++++------------ .../ArrayPoolMemoryAllocatorTests.cs | 13 ----------- 4 files changed, 9 insertions(+), 33 deletions(-) diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index c03104779e..585f87b3e8 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -150,7 +150,7 @@ namespace SixLabors.ImageSharp.Formats.Gif // The palette quantizer can reuse the same pixel map across multiple frames // since the palette is unchanging. This allows a reduction of memory usage across // multi frame gifs using a global palette. - Unsafe.SkipInit(out EuclideanPixelMap pixelMap); + EuclideanPixelMap pixelMap = default; bool pixelMapHasValue = false; for (int i = 0; i < image.Frames.Count; i++) { diff --git a/src/ImageSharp/Memory/Allocators/ArrayPoolMemoryAllocator.cs b/src/ImageSharp/Memory/Allocators/ArrayPoolMemoryAllocator.cs index 4a3c42910f..a79e042a32 100644 --- a/src/ImageSharp/Memory/Allocators/ArrayPoolMemoryAllocator.cs +++ b/src/ImageSharp/Memory/Allocators/ArrayPoolMemoryAllocator.cs @@ -131,10 +131,6 @@ namespace SixLabors.ImageSharp.Memory Guard.MustBeGreaterThanOrEqualTo(length, 0, nameof(length)); int itemSizeBytes = Unsafe.SizeOf(); int bufferSizeInBytes = length * itemSizeBytes; - if (bufferSizeInBytes < 0 || bufferSizeInBytes > this.BufferCapacityInBytes) - { - ThrowInvalidAllocationException(length, this.BufferCapacityInBytes); - } ArrayPool pool = this.GetArrayPool(bufferSizeInBytes); byte[] byteArray = pool.Rent(bufferSizeInBytes); diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 9b626303bd..0311c40be4 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -5,6 +5,7 @@ using System; using System.Buffers; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Processing.Processors.Quantization @@ -33,7 +34,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization { this.Palette = palette; this.rgbaPalette = new Rgba32[palette.Length]; - this.cache = ColorDistanceCache.Create(); + this.cache = new ColorDistanceCache(configuration.MemoryAllocator); PixelOperations.Instance.ToRgba32(configuration, this.Palette.Span, this.rgbaPalette); } @@ -141,26 +142,18 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization private const int RgbShift = 8 - IndexBits; private const int AlphaShift = 8 - IndexAlphaBits; private const int Entries = IndexCount * IndexCount * IndexCount * IndexAlphaCount; - private const int BufferLength = (Entries + 1) >> 1; private MemoryHandle tableHandle; - private readonly int[] table; + private readonly IMemoryOwner table; private readonly short* tablePointer; - private ColorDistanceCache(int bufferLength, int entries) + public ColorDistanceCache(MemoryAllocator allocator) { - // We use ArrayPool.Shared for several reasons. - // 1. To avoid out of range issues caused by configuring small discontiguous buffers rented via MemoryAllocator - // 2. To ensure that the rented buffer is actually pooled. - // 3. The .NET runtime already uses this pool so we might already have a pooled array present. - this.table = ArrayPool.Shared.Rent(bufferLength); - this.tableHandle = this.table.AsMemory().Pin(); - new Span(this.tableHandle.Pointer, entries).Fill(-1); + this.table = allocator.Allocate(Entries); + this.table.GetSpan().Fill(-1); + this.tableHandle = this.table.Memory.Pin(); this.tablePointer = (short*)this.tableHandle.Pointer; } - public static ColorDistanceCache Create() - => new ColorDistanceCache(BufferLength, Entries); - [MethodImpl(InliningOptions.ShortMethod)] public void Add(Rgba32 rgba, byte index) { @@ -199,8 +192,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization { if (this.table != null) { - ArrayPool.Shared.Return(this.table); this.tableHandle.Dispose(); + this.table.Dispose(); } } } diff --git a/tests/ImageSharp.Tests/Memory/Allocators/ArrayPoolMemoryAllocatorTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/ArrayPoolMemoryAllocatorTests.cs index 939e5898cd..50ec09ce3f 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/ArrayPoolMemoryAllocatorTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/ArrayPoolMemoryAllocatorTests.cs @@ -223,19 +223,6 @@ namespace SixLabors.ImageSharp.Tests.Memory.Allocators Assert.Equal(0, buffer.Memory.Length); } - [Theory] - [InlineData(101)] - [InlineData((int.MaxValue / SizeOfLargeStruct) - 1)] - [InlineData(int.MaxValue / SizeOfLargeStruct)] - [InlineData((int.MaxValue / SizeOfLargeStruct) + 1)] - [InlineData((int.MaxValue / SizeOfLargeStruct) + 137)] - public void Allocate_OverCapacity_Throws_InvalidMemoryOperationException(int length) - { - this.LocalFixture.MemoryAllocator.BufferCapacityInBytes = 100 * SizeOfLargeStruct; - Assert.Throws(() => - this.LocalFixture.MemoryAllocator.Allocate(length)); - } - [Theory] [InlineData(-1)] public void AllocateManagedByteBuffer_IncorrectAmount_ThrowsCorrect_ArgumentOutOfRangeException(int length) From eb69eb7d172fbc5c032e2662215a4a1dffb7fff5 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Tue, 15 Jun 2021 17:56:18 +0200 Subject: [PATCH 25/29] Add tests for tiff encoder discontiguous buffers --- .../Formats/Tiff/TiffEncoderTests.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs index 0bb9b95b9a..09505692fc 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs @@ -437,6 +437,20 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff //// CcittGroup3Fax compressed data length can be larger than the original length. Assert.Throws(() => TestStripLength(provider, photometricInterpretation, compression)); + [Theory] + [WithTestPatternImages(287, 321, PixelTypes.Rgba32, TiffPhotometricInterpretation.Rgb)] + [WithTestPatternImages(287, 321, PixelTypes.Rgba32, TiffPhotometricInterpretation.PaletteColor)] + [WithTestPatternImages(287, 321, PixelTypes.Rgba32, TiffPhotometricInterpretation.BlackIsZero)] + public void TiffEncode_WorksWithDiscontiguousBuffers(TestImageProvider provider, TiffPhotometricInterpretation photometricInterpretation) + where TPixel : unmanaged, IPixel + { + provider.LimitAllocatorBufferCapacity().InPixelsSqrt(200); + using Image image = provider.GetImage(); + + var encoder = new TiffEncoder { PhotometricInterpretation = photometricInterpretation }; + image.DebugSave(provider, encoder); + } + private static void TestStripLength( TestImageProvider provider, TiffPhotometricInterpretation photometricInterpretation, From 7cd2586a2545d7ffad8b3200477f978916f4b9db Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 16 Jun 2021 12:34:42 +1000 Subject: [PATCH 26/29] Simplify and fix build configuration --- ImageSharp.sln | 80 +++----------------------------------------------- 1 file changed, 4 insertions(+), 76 deletions(-) diff --git a/ImageSharp.sln b/ImageSharp.sln index ef6a945f65..bf1f3579c0 100644 --- a/ImageSharp.sln +++ b/ImageSharp.sln @@ -479,115 +479,43 @@ Global EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 Debug-InnerLoop|Any CPU = Debug-InnerLoop|Any CPU - Debug-InnerLoop|x64 = Debug-InnerLoop|x64 - Debug-InnerLoop|x86 = Debug-InnerLoop|x86 Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 Release-InnerLoop|Any CPU = Release-InnerLoop|Any CPU - Release-InnerLoop|x64 = Release-InnerLoop|x64 - Release-InnerLoop|x86 = Release-InnerLoop|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug|x64.ActiveCfg = Debug|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug|x64.Build.0 = Debug|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug|x86.ActiveCfg = Debug|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug|x86.Build.0 = Debug|Any CPU {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug-InnerLoop|Any CPU.ActiveCfg = Debug-InnerLoop|Any CPU {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug-InnerLoop|Any CPU.Build.0 = Debug-InnerLoop|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug-InnerLoop|x64.ActiveCfg = Debug-InnerLoop|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug-InnerLoop|x64.Build.0 = Debug-InnerLoop|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug-InnerLoop|x86.ActiveCfg = Debug-InnerLoop|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug-InnerLoop|x86.Build.0 = Debug-InnerLoop|Any CPU {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release|Any CPU.ActiveCfg = Release|Any CPU {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release|Any CPU.Build.0 = Release|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release|x64.ActiveCfg = Release|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release|x64.Build.0 = Release|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release|x86.ActiveCfg = Release|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release|x86.Build.0 = Release|Any CPU {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release-InnerLoop|Any CPU.ActiveCfg = Release-InnerLoop|Any CPU {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release-InnerLoop|Any CPU.Build.0 = Release-InnerLoop|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release-InnerLoop|x64.ActiveCfg = Release-InnerLoop|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release-InnerLoop|x64.Build.0 = Release-InnerLoop|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release-InnerLoop|x86.ActiveCfg = Release-InnerLoop|Any CPU - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release-InnerLoop|x86.Build.0 = Release-InnerLoop|Any CPU {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|x64.ActiveCfg = Debug|Any CPU - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|x64.Build.0 = Debug|Any CPU - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|x86.ActiveCfg = Debug|Any CPU - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|x86.Build.0 = Debug|Any CPU {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug-InnerLoop|Any CPU.ActiveCfg = Debug-InnerLoop|Any CPU {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug-InnerLoop|Any CPU.Build.0 = Debug-InnerLoop|Any CPU - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug-InnerLoop|x64.ActiveCfg = Debug-InnerLoop|x64 - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug-InnerLoop|x64.Build.0 = Debug-InnerLoop|x64 - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug-InnerLoop|x86.ActiveCfg = Debug-InnerLoop|x86 - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug-InnerLoop|x86.Build.0 = Debug-InnerLoop|x86 {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release|Any CPU.ActiveCfg = Release|Any CPU {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release|Any CPU.Build.0 = Release|Any CPU - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release|x64.ActiveCfg = Release|Any CPU - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release|x64.Build.0 = Release|Any CPU - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release|x86.ActiveCfg = Release|Any CPU - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release|x86.Build.0 = Release|Any CPU {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release-InnerLoop|Any CPU.ActiveCfg = Release-InnerLoop|Any CPU {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release-InnerLoop|Any CPU.Build.0 = Release-InnerLoop|Any CPU - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release-InnerLoop|x64.ActiveCfg = Release-InnerLoop|x64 - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release-InnerLoop|x64.Build.0 = Release-InnerLoop|x64 - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release-InnerLoop|x86.ActiveCfg = Release-InnerLoop|x86 - {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release-InnerLoop|x86.Build.0 = Release-InnerLoop|x86 {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug|x64.ActiveCfg = Debug|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug|x64.Build.0 = Debug|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug|x86.ActiveCfg = Debug|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug|x86.Build.0 = Debug|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug-InnerLoop|Any CPU.ActiveCfg = Debug|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug-InnerLoop|Any CPU.Build.0 = Debug|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug-InnerLoop|x64.ActiveCfg = Debug|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug-InnerLoop|x64.Build.0 = Debug|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug-InnerLoop|x86.ActiveCfg = Debug|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug-InnerLoop|x86.Build.0 = Debug|Any CPU + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug-InnerLoop|Any CPU.ActiveCfg = Debug-InnerLoop|Any CPU + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug-InnerLoop|Any CPU.Build.0 = Debug-InnerLoop|Any CPU {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|Any CPU.ActiveCfg = Release|Any CPU {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|Any CPU.Build.0 = Release|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x64.ActiveCfg = Release|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x64.Build.0 = Release|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x86.ActiveCfg = Release|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x86.Build.0 = Release|Any CPU {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release-InnerLoop|Any CPU.ActiveCfg = Release-InnerLoop|Any CPU {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release-InnerLoop|Any CPU.Build.0 = Release-InnerLoop|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release-InnerLoop|x64.ActiveCfg = Release-InnerLoop|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release-InnerLoop|x64.Build.0 = Release-InnerLoop|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release-InnerLoop|x86.ActiveCfg = Release-InnerLoop|Any CPU - {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release-InnerLoop|x86.Build.0 = Release-InnerLoop|Any CPU {FC527290-2F22-432C-B77B-6E815726B02C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FC527290-2F22-432C-B77B-6E815726B02C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Debug|x64.ActiveCfg = Debug|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Debug|x64.Build.0 = Debug|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Debug|x86.ActiveCfg = Debug|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Debug|x86.Build.0 = Debug|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Debug-InnerLoop|Any CPU.ActiveCfg = Debug|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Debug-InnerLoop|Any CPU.Build.0 = Debug|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Debug-InnerLoop|x64.ActiveCfg = Debug|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Debug-InnerLoop|x64.Build.0 = Debug|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Debug-InnerLoop|x86.ActiveCfg = Debug|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Debug-InnerLoop|x86.Build.0 = Debug|Any CPU + {FC527290-2F22-432C-B77B-6E815726B02C}.Debug-InnerLoop|Any CPU.ActiveCfg = Debug-InnerLoop|Any CPU + {FC527290-2F22-432C-B77B-6E815726B02C}.Debug-InnerLoop|Any CPU.Build.0 = Debug-InnerLoop|Any CPU {FC527290-2F22-432C-B77B-6E815726B02C}.Release|Any CPU.ActiveCfg = Release|Any CPU {FC527290-2F22-432C-B77B-6E815726B02C}.Release|Any CPU.Build.0 = Release|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Release|x64.ActiveCfg = Release|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Release|x64.Build.0 = Release|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Release|x86.ActiveCfg = Release|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Release|x86.Build.0 = Release|Any CPU {FC527290-2F22-432C-B77B-6E815726B02C}.Release-InnerLoop|Any CPU.ActiveCfg = Release-InnerLoop|Any CPU {FC527290-2F22-432C-B77B-6E815726B02C}.Release-InnerLoop|Any CPU.Build.0 = Release-InnerLoop|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Release-InnerLoop|x64.ActiveCfg = Release-InnerLoop|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Release-InnerLoop|x64.Build.0 = Release-InnerLoop|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Release-InnerLoop|x86.ActiveCfg = Release-InnerLoop|Any CPU - {FC527290-2F22-432C-B77B-6E815726B02C}.Release-InnerLoop|x86.Build.0 = Release-InnerLoop|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 03a22877690ecd2a6625854f33e6a70318c4ed60 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 16 Jun 2021 12:35:11 +1000 Subject: [PATCH 27/29] Clarify build optimize rule --- Directory.Build.props | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index d70fbc45ae..b3e18e5a5a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -18,11 +18,10 @@ - - - false - - + true From 4b1dd91847299033e7b4b1445245ff2c49598d6f Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 16 Jun 2021 12:35:21 +1000 Subject: [PATCH 28/29] Fix build warning --- tests/ImageSharp.Tests/Formats/Jpg/RgbToYCbCrConverterTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ImageSharp.Tests/Formats/Jpg/RgbToYCbCrConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/RgbToYCbCrConverterTests.cs index 0d5b550384..24a8195217 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/RgbToYCbCrConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/RgbToYCbCrConverterTests.cs @@ -202,7 +202,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Scale16X16To8X8(ref trueBlock, crTrue); VerifyBlock(ref crResult, ref trueBlock, comparer); - // extracts 8x8 blocks from 16x8 memory region static void Copy8x8(ReadOnlySpan source, Span dest) { From 347279c2585cf5c44e19f4cd1ac287110742d8e2 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Thu, 17 Jun 2021 19:10:28 +0200 Subject: [PATCH 29/29] Clamp color map index, fixes issue #1668 --- src/ImageSharp/Formats/Gif/GifDecoderCore.cs | 7 ++++--- .../Formats/Gif/GifDecoderTests.cs | 14 ++++++++++++++ tests/ImageSharp.Tests/TestImages.cs | 1 + ...lorIndex_Rgba32_issue1668_invalidcolorindex.png | 3 +++ .../Gif/issues/issue1668_invalidcolorindex.gif | 3 +++ 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 tests/Images/External/ReferenceOutput/GifDecoderTests/Issue1668_InvalidColorIndex_Rgba32_issue1668_invalidcolorindex.png create mode 100644 tests/Images/Input/Gif/issues/issue1668_invalidcolorindex.gif diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 2f6b45aff9..fb3d989d4b 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -7,7 +7,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Threading; -using System.Threading.Tasks; + using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Metadata; @@ -441,6 +441,7 @@ namespace SixLabors.ImageSharp.Formats.Gif int descriptorRight = descriptorLeft + descriptor.Width; bool transFlag = this.graphicsControlExtension.TransparencyFlag; byte transIndex = this.graphicsControlExtension.TransparencyIndex; + int colorTableMaxIdx = colorTable.Length - 1; for (int y = descriptorTop; y < descriptorBottom && y < imageHeight; y++) { @@ -487,7 +488,7 @@ namespace SixLabors.ImageSharp.Formats.Gif // #403 The left + width value can be larger than the image width for (int x = descriptorLeft; x < descriptorRight && x < imageWidth; x++) { - int index = Unsafe.Add(ref indicesRowRef, x - descriptorLeft); + int index = Numerics.Clamp(Unsafe.Add(ref indicesRowRef, x - descriptorLeft), 0, colorTableMaxIdx); ref TPixel pixel = ref Unsafe.Add(ref rowRef, x); Rgb24 rgb = colorTable[index]; pixel.FromRgb24(rgb); @@ -497,7 +498,7 @@ namespace SixLabors.ImageSharp.Formats.Gif { for (int x = descriptorLeft; x < descriptorRight && x < imageWidth; x++) { - int index = Unsafe.Add(ref indicesRowRef, x - descriptorLeft); + int index = Numerics.Clamp(Unsafe.Add(ref indicesRowRef, x - descriptorLeft), 0, colorTableMaxIdx); if (transIndex != index) { ref TPixel pixel = ref Unsafe.Add(ref rowRef, x); diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index 446f1e9d47..c3250d72c5 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -197,6 +197,20 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif } } + // https://github.com/SixLabors/ImageSharp/issues/1668 + [Theory] + [WithFile(TestImages.Gif.Issues.InvalidColorIndex, PixelTypes.Rgba32)] + public void Issue1668_InvalidColorIndex(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using (Image image = provider.GetImage()) + { + image.DebugSave(provider); + + image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider); + } + } + [Theory] [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)] [WithFile(TestImages.Gif.Kumin, PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 7eca4795df..6d2f65f575 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -418,6 +418,7 @@ namespace SixLabors.ImageSharp.Tests public const string BadDescriptorWidth = "Gif/issues/issue403_baddescriptorwidth.gif"; public const string Issue1505 = "Gif/issues/issue1505_argumentoutofrange.png"; public const string Issue1530 = "Gif/issues/issue1530.gif"; + public const string InvalidColorIndex = "Gif/issues/issue1668_invalidcolorindex.gif"; } public static readonly string[] All = { Rings, Giphy, Cheers, Trans, Kumin, Leo, Ratio4x1, Ratio1x4 }; diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue1668_InvalidColorIndex_Rgba32_issue1668_invalidcolorindex.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue1668_InvalidColorIndex_Rgba32_issue1668_invalidcolorindex.png new file mode 100644 index 0000000000..fc713e3851 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue1668_InvalidColorIndex_Rgba32_issue1668_invalidcolorindex.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8507b2f70c1dd2ef3d3ef616419825cf70c7453abaf7fd490349f85f4b589cb5 +size 408 diff --git a/tests/Images/Input/Gif/issues/issue1668_invalidcolorindex.gif b/tests/Images/Input/Gif/issues/issue1668_invalidcolorindex.gif new file mode 100644 index 0000000000..6847817fa4 --- /dev/null +++ b/tests/Images/Input/Gif/issues/issue1668_invalidcolorindex.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:712d53330f8774ec4ec73fe8321641e2a457ec4bdef813352940dfc93c83c789 +size 3256