Repository navigation
Add ICO icon file decoding - #450
Conversation
|
Thanks! Looks pretty good to me, I don't have any feedback. |
There was a problem hiding this comment.
I vaguely expected multiplication here, not that it should make a big difference in practice.
There was a problem hiding this comment.
Updated to use multiplication in the latest revision.
|
Updated to use multiplication when comparing sizes based on feedback from @samlh, and to support 32-bit RGBA bitmaps in ICO files, which is needed for many common website favicons like https://assets-cdn.github.com/favicon.ico |
|
Can you please a test image to the tests directory? Please create a new folder for |
|
@nwin Added a few test images (one BMP + AND mask, one 32-bit BMP with alpha channel, one PNG). |
|
Great thanks. Though I'm a bit unsure whether we are allowed to include these files in the repo. |
|
The Rust and Mozilla logo artwork are available under free/open source licenses, and subject to the Rust trademark policy and Mozilla trademark policy. The GitHub logo is available from this official repo, again with a trademark policy. I don't believe that including the unmodified images in the test suite violates any of these policies or licenses, but I am not a lawyer. If you'd prefer, I can create some totally original test files. |
|
Nevermind, I decided to just create new ICO test files by re-encoding one of the existing PNG test files. |
|
Thank you for contributing this new decoder! I think adding the logos would have been fine given their license. |
This adds basic support for the ICO file format. This format is really just a container for PNG or BMP data. This decoder is structured a little unusually so that it can delegate most of its work to either PNGDecoder or BMPDecoder. It also requires some extra hooks in the BMPDecoder code.
A single ICO file may contain multiple images. The decoder currently just selects the highest-resolution image, but it could easily be extended to select images by size or other criteria.