Skip to content

ICO: Zero all channels for AND-mask-transparent pixels#3003

Open
mpospelova wants to merge 2 commits into
image-rs:mainfrom
mpospelova:zero-all-channels
Open

ICO: Zero all channels for AND-mask-transparent pixels#3003
mpospelova wants to merge 2 commits into
image-rs:mainfrom
mpospelova:zero-all-channels

Conversation

@mpospelova

Copy link
Copy Markdown
Contributor

Zero out all four channels (R, G, B, A) instead of only the alpha channel when the AND mask marks a pixel as transparent.

Previously, transparent pixels retained their original RGB values, which left meaningless data in the output buffer. Now they are fully zeroed.

Also updated reference images to reflect the new output.

@RunDevelopment

Copy link
Copy Markdown
Member

Is this correct? If I'm reading this and this correctly, then the AND mask is applied before the XOR mask (=color). So the AND mask shouldn't be able to remove color, right?

@mpospelova

Copy link
Copy Markdown
Contributor Author

@RunDevelopment Thank you for the review! You are right that the AND mask only determines the transparency of the pixel. As I've understood the code, here we are decoding the image to an RGBA buffer, and when the AND mask marks a pixel as transparent, the previous code already set alpha to 0 which makes the color invisible, so this change additionally zeros the RGB channels to clean up that unused data

@RunDevelopment

Copy link
Copy Markdown
Member

I think you misunderstood what I said. My comment is talking about how ICO files are supposed to be decoded according to the linked resources. I know how we're doing it and what your PR changes. I'm asking whether those changes are correct.

Hmmm, I tested it with GIMP and that does leave the transparent white in the two test images as is. However, GIMP did decode various image formats incorrectly in the past, so take this with a grain of salt.

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.

2 participants