Skip to content

ICO: Use bit count from BMP header for alpha mask#3047

Open
RunDevelopment wants to merge 1 commit into
image-rs:mainfrom
RunDevelopment:ico-don't-trust-icon-dir-entries
Open

ICO: Use bit count from BMP header for alpha mask#3047
RunDevelopment wants to merge 1 commit into
image-rs:mainfrom
RunDevelopment:ico-don't-trust-icon-dir-entries

Conversation

@RunDevelopment

Copy link
Copy Markdown
Member

Turns out, ICON dir entries can just lie and we shouldn't trust them. We previously used the ICON dir entry's bit count to determine whether to apply the AND mask. This is wrong, because the this bit count may mismatch with the bit count of the encoded BMP.

I added a test image that is reported as 8 bpp in the ICON dir entry, but the BMP is actually 32 bpp. With the AND mask set to completely transparent (all 1), the output is determined by which bit count value is used. For 8 bpp, the AND mask would be applied, giving us a completely transparent image. For 32 bpp, the AND mask is ignored. Of course, Windows Explorer (and most other ICO decoders) correctly decode the test image, and now we do too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant