Skip to content

Add ICO icon file decoding - #450

Merged
nwin merged 4 commits into
image-rs:masterfrom
mbrubeck:ico
Oct 10, 2015
Merged

nwin merged 4 commits into
image-rs:masterfrom
mbrubeck:ico

Conversation

@mbrubeck

@mbrubeck mbrubeck commented Oct 7, 2015

Copy link
Copy Markdown
Contributor

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.

@xaviershay

Copy link
Copy Markdown

Thanks! Looks pretty good to me, I don't have any feedback.

Comment thread src/ico/decoder.rs Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vaguely expected multiplication here, not that it should make a big difference in practice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use multiplication in the latest revision.

@mbrubeck

mbrubeck commented Oct 7, 2015

Copy link
Copy Markdown
Contributor Author

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

@nwin

nwin commented Oct 7, 2015

Copy link
Copy Markdown
Contributor

Can you please a test image to the tests directory? Please create a new folder for ico in test and change references_images.rs accordingly.

@mbrubeck

mbrubeck commented Oct 7, 2015

Copy link
Copy Markdown
Contributor Author

@nwin Added a few test images (one BMP + AND mask, one 32-bit BMP with alpha channel, one PNG).

@nwin

nwin commented Oct 8, 2015

Copy link
Copy Markdown
Contributor

Great thanks. Though I'm a bit unsure whether we are allowed to include these files in the repo.

@mbrubeck

mbrubeck commented Oct 8, 2015

Copy link
Copy Markdown
Contributor Author

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.

@mbrubeck

mbrubeck commented Oct 8, 2015

Copy link
Copy Markdown
Contributor Author

Nevermind, I decided to just create new ICO test files by re-encoding one of the existing PNG test files.

@nwin

nwin commented Oct 10, 2015

Copy link
Copy Markdown
Contributor

Thank you for contributing this new decoder!

I think adding the logos would have been fine given their license.

nwin added a commit that referenced this pull request Oct 10, 2015
Add ICO icon file decoding
@nwin
nwin merged commit f2aa983 into image-rs:master Oct 10, 2015
@bvssvni bvssvni mentioned this pull request Oct 20, 2015
fintelia pushed a commit that referenced this pull request Dec 20, 2024
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.

4 participants