在32位bmp上的透明度不起作用

此32位bmp https://drive.google.com/open?id=1thySBsggtdihd3LByiAwQwZmVo1lzZfl具有透明性。但是由于某些原因,我的图像查看器/编辑器都没有显示透明性。

如何修复此bmp?

Sdfadfadf 回答:在32位bmp上的透明度不起作用

您的BMP文件未正确编码以支持透明性。

根据following post

取决于压缩方法,默认的RGB方法支持24位颜色,但是BITFIELDS压缩支持32位颜色(24位+ alpha通道)。

根据Wikipedia
对于BI_BITFIELDS,标头地址1Eh的值应为3
地址36h3Ah3Eh42h的值定义了掩码:

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

您可以在线分析图像的元数据here

您的文件分析结果,压缩为
File Name: BLUE_CLOSEBUTTON_BMP.bmp
File Size: 14 kB
...
Compression: None

您的BMP文件(位深为32位,但不透明):
enter image description here


我使用GIMP保存具有透明度的BMP。

分析结果,压缩为位字段

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

这是带有透明条纹的BMP(网站已将文件自动转换为PNG):
enter image description here


检查图像是否真正具有透明度:

<img src="https://www.codej.cn/res/2022/08-01/12/a67e66ce9880266aaf8eae6ac9928966.png" style="background-color:blue;" />

检查我发布的图像是否确实具有透明度:

<img src="https://www.codej.cn/res/2022/08-01/12/834835801480651b71d00477bf2fde93.png" style="background-color:blue;" />

本文链接:https://www.f2er.com/2809382.html

大家都在问