Loss of alpha channel information opening BMP file

I have a BMP file that I know is 32bpp and contains alpha information. Whenever I use the constructor of the System.Drawing.Bitmap or FromFile class, it loads it as 32bppRgb instead of 32bppArgb. Is there a way to save alpha information? I know BMP is a simple file format for which I could write my own bootloader, but I would prefer. There seems to be an option somewhere.

+4
source share
1 answer

Unfortunately, GDI + does not support alpha channels in BMP files. Here's the relevant note in:

The image class does not support alpha transparency in bitmap images. To enable alpha transparency, use PNG images with 32 bits per pixel.

It is best to convert the file to a format that supports transparency (for example, PNG) in a separate program that supports BMP alpha, or write your own code for this.

0
source

Source: https://habr.com/ru/post/1528006/


All Articles