Browse Source

Switch default quantizer for the bitmap encoder to Wu-quantizer

pull/1623/head
Brian Popow 5 years ago
parent
commit
33192d396b
  1. 2
      src/ImageSharp/Formats/Bmp/BmpEncoder.cs
  2. 2
      src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
  3. 1
      src/ImageSharp/Formats/Bmp/IBmpEncoderOptions.cs
  4. 14
      tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs

2
src/ImageSharp/Formats/Bmp/BmpEncoder.cs

@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <summary> /// <summary>
/// Gets or sets the quantizer for reducing the color count for 8-Bit images. /// Gets or sets the quantizer for reducing the color count for 8-Bit images.
/// Defaults to OctreeQuantizer. /// Defaults to Wu Quantizer.
/// </summary> /// </summary>
public IQuantizer Quantizer { get; set; } public IQuantizer Quantizer { get; set; }

2
src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs

@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
this.memoryAllocator = memoryAllocator; this.memoryAllocator = memoryAllocator;
this.bitsPerPixel = options.BitsPerPixel; this.bitsPerPixel = options.BitsPerPixel;
this.writeV4Header = options.SupportTransparency; this.writeV4Header = options.SupportTransparency;
this.quantizer = options.Quantizer ?? KnownQuantizers.Octree; this.quantizer = options.Quantizer ?? KnownQuantizers.Wu;
} }
/// <summary> /// <summary>

1
src/ImageSharp/Formats/Bmp/IBmpEncoderOptions.cs

@ -25,7 +25,6 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <summary> /// <summary>
/// Gets the quantizer for reducing the color count for 8-Bit, 4-Bit, and 1-Bit images. /// Gets the quantizer for reducing the color count for 8-Bit, 4-Bit, and 1-Bit images.
/// Defaults to the Octree Quantizer.
/// </summary> /// </summary>
IQuantizer Quantizer { get; } IQuantizer Quantizer { get; }
} }

14
tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs

@ -212,11 +212,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
// The Magick Reference Decoder can not decode 1-Bit bitmaps, so only execute this on windows. // The Magick Reference Decoder can not decode 1-Bit bitmaps, so only execute this on windows.
if (TestEnvironment.IsWindows) if (TestEnvironment.IsWindows)
{ {
TestBmpEncoderCore( TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: false);
provider,
bitsPerPixel,
supportTransparency: false,
quantizer: KnownQuantizers.Wu); // using the wu quantizer, because the octree seems to have problems with just two colors.
} }
} }
@ -230,11 +226,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
// The Magick Reference Decoder can not decode 1-Bit bitmaps, so only execute this on windows. // The Magick Reference Decoder can not decode 1-Bit bitmaps, so only execute this on windows.
if (TestEnvironment.IsWindows) if (TestEnvironment.IsWindows)
{ {
TestBmpEncoderCore( TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true);
provider,
bitsPerPixel,
supportTransparency: true,
quantizer: KnownQuantizers.Wu); // using the wu quantizer, because the octree seems to have problems with just two colors.
} }
} }
@ -351,7 +343,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
{ {
BitsPerPixel = bitsPerPixel, BitsPerPixel = bitsPerPixel,
SupportTransparency = supportTransparency, SupportTransparency = supportTransparency,
Quantizer = quantizer ?? KnownQuantizers.Octree Quantizer = quantizer ?? KnownQuantizers.Wu
}; };
// Does DebugSave & load reference CompareToReferenceInput(): // Does DebugSave & load reference CompareToReferenceInput():

Loading…
Cancel
Save