Skip to content

Commit

Permalink
Merge pull request #2819 from mistoll/bmp_dither
Browse files Browse the repository at this point in the history
Fix using dither in BmpEncoder when bit per pixel is <= 4
  • Loading branch information
JimBobSquarePants authored Oct 12, 2024
2 parents 0919534 + bfbade1 commit ed2c2a1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,9 @@ private void Write4BitPixelData<TPixel>(Configuration configuration, Stream stre
{
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new QuantizerOptions()
{
MaxColors = 16
MaxColors = 16,
Dither = this.quantizer.Options.Dither,
DitherScale = this.quantizer.Options.DitherScale
});

frameQuantizer.BuildPalette(this.pixelSamplingStrategy, image);
Expand Down Expand Up @@ -623,7 +625,9 @@ private void Write2BitPixelData<TPixel>(Configuration configuration, Stream stre
{
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new QuantizerOptions()
{
MaxColors = 4
MaxColors = 4,
Dither = this.quantizer.Options.Dither,
DitherScale = this.quantizer.Options.DitherScale
});

frameQuantizer.BuildPalette(this.pixelSamplingStrategy, image);
Expand Down Expand Up @@ -680,7 +684,9 @@ private void Write1BitPixelData<TPixel>(Configuration configuration, Stream stre
{
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new QuantizerOptions()
{
MaxColors = 2
MaxColors = 2,
Dither = this.quantizer.Options.Dither,
DitherScale = this.quantizer.Options.DitherScale
});

frameQuantizer.BuildPalette(this.pixelSamplingStrategy, image);
Expand Down

0 comments on commit ed2c2a1

Please sign in to comment.