Skip to content

Commit 313b4d2

Browse files
committed
Fix using dither in BmpEncoder when bit per pixel is <= 4
1 parent 5c28129 commit 313b4d2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,9 @@ private void Write4BitPixelData<TPixel>(Configuration configuration, Stream stre
575575
{
576576
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new QuantizerOptions()
577577
{
578-
MaxColors = 16
578+
MaxColors = 16,
579+
Dither = this.quantizer.Options.Dither,
580+
DitherScale = this.quantizer.Options.DitherScale
579581
});
580582

581583
frameQuantizer.BuildPalette(this.pixelSamplingStrategy, image);
@@ -623,7 +625,9 @@ private void Write2BitPixelData<TPixel>(Configuration configuration, Stream stre
623625
{
624626
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new QuantizerOptions()
625627
{
626-
MaxColors = 4
628+
MaxColors = 4,
629+
Dither = this.quantizer.Options.Dither,
630+
DitherScale = this.quantizer.Options.DitherScale
627631
});
628632

629633
frameQuantizer.BuildPalette(this.pixelSamplingStrategy, image);
@@ -680,7 +684,9 @@ private void Write1BitPixelData<TPixel>(Configuration configuration, Stream stre
680684
{
681685
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new QuantizerOptions()
682686
{
683-
MaxColors = 2
687+
MaxColors = 2,
688+
Dither = this.quantizer.Options.Dither,
689+
DitherScale = this.quantizer.Options.DitherScale
684690
});
685691

686692
frameQuantizer.BuildPalette(this.pixelSamplingStrategy, image);

0 commit comments

Comments
 (0)