bgrabitmap / lazpaint

🎨 Cross-platform image editor with raster and vector layers similar to Paint.Net written in Lazarus (Free Pascal)
https://lazpaint.github.io/
GNU General Public License v3.0
400 stars 55 forks source link

BMP file issues #189

Open lainz opened 4 years ago

lainz commented 4 years ago

Hi, this attached bmp image is not displayed fine in LazPaint image.zip

Image in LazPaint imagelazpaint

Image in MsPaint imagemspaint

circular17 commented 3 years ago

What probably happens is that the image has the alpha value defined for some pixels and not for others. This is not an obvious one to solve. Which program produces this image?

lainz commented 3 years ago

I have no idea. I get these images at work, and as I have LazPaint as default viewer on Windows, it opens with it. It looks strange since the thumbnails was fine.

I can think this is some kind of android emulator, but is just a guess...

circular17 commented 3 years ago

Ok.

The BMP format is ambiguous regarding the alpha channel. So in some cases, the reader has to guess. Many image readers just consider BMP to be opaque and do not handle any alpha channel, which is why you would see it as opaque in MSPaint.

However a BMP image can be in 24-bit or in 32-bit. The file you provided is 32-bit. So it can be interpreted as having an alpha channel. Some software though use this format to store image without an alpha channel. In this case though, it is recommended to set the alpha value to zero. So the reader of BGRABitmap checks if all alpha values are in fact zero, and if that's the case, it considers the imager to be opaque.

In the file provided, I presume some pixels have an alpha channel some and some don't. In this case, it makes sense to consider the image to have an alpha channel.

There is an option in the reader to consider the image to be opaque all the time. So one way to fix the problem would be to add a setting in LazPaint to say that BMP files are always opaque. Another way would be to fix the image files, for example that the program that writes these images make sure all alpha values are set to 0.

lainz commented 3 years ago

I think is not a problem, I can open these images with mspaint, I never will edit these images. So if it's a bug of the program that made them there is no bug in LazPaint in my opinion.