-
-
Notifications
You must be signed in to change notification settings - Fork 887
Description
Prerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of ImageSharp
- I have verified if the problem exist in both
DEBUG
andRELEASE
mode - I have searched open and closed issues to ensure it has not already been reported
ImageSharp version
3.0.1
Other ImageSharp packages and versions
>= 2.0.0 (tested up to 3.0.2-alpha.0.17)
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.
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:
using (var dmImage = Image.Load<Rgb24>("datamatrix.bmp"))
using (var fs = File.OpenWrite("corrupt.bmp")))
{
dmImage.SaveAsBmp(fs);
}
The resulting corrupt.bmp
is visibly (zoom in, it is 10x10 pixels) different on the right side of the image.