Relt
Relt

Reputation: 19

transparency on a 32-bit bmp doesnt do anything

This 32-bit bmp https://drive.google.com/open?id=1thySBsggtdihd3LByiAwQwZmVo1lzZfl has transparency in it. But for some reason none of my image viewers/editors dont show the transparency.

How can i fix this bmp?

Upvotes: 0

Views: 1513

Answers (1)

Rotem
Rotem

Reputation: 32094

Your BMP file is not encoded correctly for supporting transparency.

According to the following post:

It depends on the compression method, the default RGB method supports 24-bit color, but BITFIELDS compression supports 32-bit color (24-bit + alpha channel).

According to Wikipedia:
For BI_BITFIELDS, the header address 1Eh value should be 3.
And addresses 36h, 3Ah, 3Eh, 42h values defines the mask:

36h 4 00 00 FF 00 00FF0000 Red channel bit mask (BI_BITFIELDS)
3Ah 4 00 FF 00 00 0000FF00 Green channel bit mask (BI_BITFIELDS)
3Eh 4 FF 00 00 00 000000FF Blue channel bit mask (BI_BITFIELDS)
42h 4 00 00 00 FF FF000000 Alpha channel bit mask

You can analyze the Metadata of your image online here

Your file analysis result, Compression is None:
File Name: BLUE_CLOSEBUTTON_BMP.bmp
File Size: 14 kB
...
Compression: None

Your BMP file (bit depth is 32 bits, but no transparency):
enter image description here


I used GIMP for saving BMP with transparency.

Analysis result, Compression is Bitfields:

File Name: 1.bmp
File Size: 14 kB
Compression: Bitfields
...
Red Mask: 0xff000000
Green Mask: 0x00ff0000
Blue Mask: 0x0000ff00
Alpha Mask: 0x000000ff

Here is the BMP with transparent stripes (file was automatically converted to PNG by the site):
enter image description here


Check if your image actually has transparency:

<img src="https://i.sstatic.net/NCdOW.png" style="background-color:blue;" />

Check if the image I posted actually has transparency:

<img src="https://i.sstatic.net/urljs.png" style="background-color:blue;" />

Upvotes: 1

Related Questions