-
-
Notifications
You must be signed in to change notification settings - Fork 865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BMP with 1 bitcount (B/W) corrupts after save #2467
Comments
Most likely error diffusion being turned on by default in the encoder. Try creating a new instance of the BmpEncoder using the Octree Quantizer with the dither property set to null and passing it as the second parameter in your save method. The reason it will work with a new image is that the default metadata will cause the image to be saved with full color |
I tried your suggestion as followed:
But the result is the same: https://github.com/synercoder/BitmapBug/actions/runs/5095035910 |
This is an "FYI bug report", not an "I could use a fix" bug report. |
Now it has become an "I have made a fix for this bug" bug report. 😉 |
Prerequisites
DEBUG
andRELEASE
modeImageSharp version
3.0.1
Other ImageSharp packages and versions
Environment (Operating system, version and so on)
Ubuntu-latest & Windows-latest
.NET Framework version
7.0.0
Description
I have a bmp file that is 10x10 pixels. The bmp file has a bitcount of 1, and thus a color pallet of 2 colors, namely: FFFFFF & 000000.
When loading the bmp, the pixeldata is loaded correctly, but when saving the bmp, the image somehow becomes corrupt.
When you save the image by first copying the pixeldata into a new
Image
object, the resulting image is correct. Indicating that the bug has to do with the original metadata messing somehow with the encoding process.The error bug occurs since ImageSharp version 2.0.0.
Input image:


Corrupt image:


Test project: https://github.com/synercoder/BitmapBug/blob/main/ImageSharp.BmpBug/BmpSavedWrong.cs
Test run showing matrix of os, mode & ImageSharp versions: https://github.com/synercoder/BitmapBug/actions/runs/5094509469
Steps to Reproduce
Use the attached image (
datamatrix.bmp
), and execute the following code:The resulting
corrupt.bmp
is visibly (zoom in, it is 10x10 pixels) different on the right side of the image.Images
datamatrix.zip
The text was updated successfully, but these errors were encountered: