Skip to content
jtippet edited this page Mar 23, 2019 · 2 revisions

ICO220: NonzeroAlpha

When storing a bitmap in an ICO file, the ICO file also requires a mask. The mask specifies which pixels are transparent: both for painting, and also possibly for hit-testing. For example, if the user clicks on a masked-out pixel of an icon, the GUI framework might choose to ignore the click.

Since the mask and the bitmap are stored separately, it's possible to have both a mask in the ICO frame and an alpha channel in the bitmap itself. This is somewhat redundant; you don't usually need two separate ways of making pixels transparent. Except -- the ICO file's mask is just a 1-bit value: either fully opaque or fully transparent; while a bitmap can have partial transparency. So the ICO file format permits 32-bit and 16-bit bitmaps to have an alpha channel for partial transparency.

However, the ICO file format does not allow bitmaps of a lower bit depth to store an alpha channel in the bitmap. (Presumably if you're desperate enough to need to limit yourself to 8-bit colors, you aren't interested in fancy per-pixel transparency effects.) You will receive warning ICO220 if an icon with a low color depth has any transparency in its bitmap. Specifically, you receive this error when the color table contains an RGBA entry with A nonzero.

If you're trying to create the icon, you either need to encode this frame at a higher color depth, or give up on per-pixel transparency.

You might receive this warning if another tool is sloppy about how it embeds bitmaps inside the ICO file. If you happen to know exactly which tool generated this icon, please file an issue here on GitHub with that info, so we can improve the documentation and tooling.

Clone this wiki locally