Prerequisites
ImageSharp version
3.1.5
Other ImageSharp packages and versions
None
Environment (Operating system, version and so on)
Win 11
.NET Framework version
.net 8
Description
When writing 1-bit (or 2, 4) files using BmpEncoder, the dither settings are not respected.
That is, because in
|
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new QuantizerOptions() |
|
{ |
|
MaxColors = 2 |
|
}); |
the QuantizerOptions is replaced with new QuanitzerOptions, which does not include the inital Dither values. Similar code is in Write2BitPixelData and Write4BitPixelData.
I'd write a pull request, but I don't know how you want to handle that. Like modify the original options, create a full clone opt the original options, remove the new options completely, or whatever you come up with.
Steps to Reproduce
var image = // Load any image
var palette =new Color[] { Color.Black, Color.White };
var quantizerOptions = new QuantizerOptions() { MaxColors = 2, Dither = **null** };
var quantizer = new PaletteQuantizer(palette, quantizerOptions);
var encoder = new BmpEncoder { BitsPerPixel = BmpBitsPerPixel.Pixel1, Quantizer = quantizer };
image.SaveAsync(anyFile, encoder);
The result is a image with dithering (example created from car.bmp from test images)

Images
No response
Prerequisites
DEBUGandRELEASEmodeImageSharp version
3.1.5
Other ImageSharp packages and versions
None
Environment (Operating system, version and so on)
Win 11
.NET Framework version
.net 8
Description
When writing 1-bit (or 2, 4) files using BmpEncoder, the dither settings are not respected.
That is, because in
ImageSharp/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
Lines 681 to 684 in 5c28129
the QuantizerOptions is replaced with new QuanitzerOptions, which does not include the inital Dither values. Similar code is in Write2BitPixelData and Write4BitPixelData.
I'd write a pull request, but I don't know how you want to handle that. Like modify the original options, create a full clone opt the original options, remove the new options completely, or whatever you come up with.
Steps to Reproduce
The result is a image with dithering (example created from car.bmp from test images)

Images
No response