-
Notifications
You must be signed in to change notification settings - Fork 672
Pick ICO entries in order #2678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Great investigation. We can definitely do this in the LGTM but before merging I'd like to hear you opinion on the thought. |
|
As I see it, icons with multiple entries being the same size and bpp are a degenerate case. So I don't think it's worth having a selection strategy option just for them. AFAIK, icons only have entries with the same size but different bpp to support older operating systems (see wikipedia). I'd rather implement the decoder implements |
197g
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me. @fintelia A bit contentious so I'd like to check if that seems fine.
@RunDevelopment Would it be possible for you to start the Changelog for 1.0 and note the change in ICO down, I think this is something that people would like to know changed. Just in case it's been in a test suite somewhere.
fintelia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems fine to me
Co-authored-by: Jonathan Behrens <[email protected]>
What does "start" mean exactly? Do you only want me to add a single entry for the ICO change or do you want me to do the changelog up to new including the ICO change (so basically the whole changelog sans future PRs)? I'm asking because you guys don't squash commits on merge, which makes the commit history on |
|
I was just referring to the |
ICO image files can contain any number of entries (BMP or PNG images). This is a problem for us, because we need to pick one of those entries to display. Luckily, it's pretty obvious which one to pick in most cases. Most ICO files have exactly one entry with the greatest size and greatest number of bits per pixel, ergo, the best quality.
Unfortunately, there isn't always one best entry. There might be multiple entries with the same size, same bpp, and even same number of bytes on disk. So. Which one would you pick?
Since there is no obvious way to pick one entry out of multiple equally good ones, programs do it differently. From my testing, they behave as follows:
And then there's this crate. Our ICO decoder will pick the best entry that appears first in the list, unless the very last entry of the list is one of the best entries.
So I changed the behavior of our decoder to always pick the one that appears first in the list of entries to be consistent with MS Paint. And Chrome, I guess. Again, there is no real right way to do this, but I would say that what we did before was definitely wrong, even if it arguably is a degenerate case.
For tests, I create a new ICO file with 2 entries of the same size and bpp. The first entry is green and the second is red. This makes it easy to see which one is picked. Here it is in GIMP:
resolves #1739
The last 2 icons attached in #1739 that were still loaded incorrectly were icons that have this exact problem. Here are the different entries in GIMP:

As you can see, the icon has 2 layers with the same bpp for each size. I suspect that this is an error by whoever created the icon, because the second entry for each size uses reduced colors (while still being encoded as 32 bpp).
In any case, our ICO decoder now decodes all icons from #1739 correctly, so the issue is fixed.