0

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?

Relt
  • 19
  • 3

1 Answers1

1

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.stack.imgur.com/NCdOW.png" style="background-color:blue;" />

Check if the image I posted actually has transparency:

<img src="https://i.stack.imgur.com/urljs.png" style="background-color:blue;" />
Rotem
  • 30,366
  • 4
  • 32
  • 65
  • The problem is that windows xp takes this bmp from luna.msstyles and interprets the transparency correctly(the corners of the buttons are transparent). So there must be transparency in this image, right? – Relt Jan 08 '20 at 07:54
  • Looks like the source image had transparency, but the transparency got lost during some conversion process. I added a code snippet to my post (proves nothing). According to Wikipedia the format of your BMP image is not the correct format of BMP image with transparency. The fact that the corners of the buttons are transparent is not a good proof - check if the center can also be transparent. I recommend you to use PNG image format instead of BMP (if possible). – Rotem Jan 08 '20 at 11:49
  • XNViewMP sees the transparency. I was extracting assets from luna.msstyles which has them saved as BMP. Luckily XNViewMP can export it to png. – Relt Sep 13 '22 at 12:04
  • Took you few years to respond... You claim is that none of your image viewers/editors show the transparency. My answers tries to explain why other viewers/editors are not showing transparency. The fact that XNViewMP sees the transparency, and other viewers don't is probably because XNViewMP uses non-standard encoding format. – Rotem Sep 13 '22 at 15:31