Bug 28073

Summary: Cross-platform ICO decoder gets wrong bit depth for icons w/o color count
Product: WebKit Reporter: Peter Kasting <pkasting>
Component: ImagesAssignee: Peter Kasting <pkasting>
Status: RESOLVED FIXED    
Severity: Normal CC: eric
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: All   
URL: http://games.tiscali.cz/favicon.ico
Attachments:
Description Flags
patch
eric: review-
patch w/test, no expected results eric: review+

Peter Kasting
Reported 2009-08-07 10:45:38 PDT
The ICO decoder ranks icons by quality, which is calculated first by size, then by bit depth. To find the bit depth to use, we read the directory entry's wBitCount and bColorCount entries. If the bit count is nonzero, it is used; otherwise, the bit depth is calculated from the color count. Apparently, real-world icons exist which use wBitCount == 0, bColorCount == 0 to mean "256 colors". The URL above is one such example; imdb.com/favicon.ico is another. I already knew 0 meant "256" for bWidth and bHeight, but I didn't know that for bColorCount. http://msdn.microsoft.com/en-us/library/ms997538.aspx implies this is legitimate (although it's not clear). This is a simple one-liner.
Attachments
patch (1.69 KB, patch)
2009-08-07 10:51 PDT, Peter Kasting
eric: review-
patch w/test, no expected results (6.84 KB, patch)
2009-08-07 16:43 PDT, Peter Kasting
eric: review+
Peter Kasting
Comment 1 2009-08-07 10:51:00 PDT
Created attachment 34294 [details] patch OK, not quite one line, but pretty simple.
Eric Seidel (no email)
Comment 2 2009-08-07 10:55:26 PDT
Comment on attachment 34294 [details] patch You and your wrapping! Test case? Our style is a bit lame, but this is technically stylistically wrong: + if (colorCount == 0) r- for lack of test.
Peter Kasting
Comment 3 2009-08-07 16:43:45 PDT
Created attachment 34342 [details] patch w/test, no expected results Here's the patch with the style violation fixed and a layout test added. I don't seem to be able to generate expected pixel results on my Windows box. Expected results should be identical for all platforms, though. Not sure if there's some way to have the buildbot do this for me or something?
Eric Seidel (no email)
Comment 4 2009-08-07 21:45:55 PDT
Comment on attachment 34342 [details] patch w/test, no expected results Fantastic! Will need pixel test results but those can be added in separate commits.
Peter Kasting
Comment 5 2009-08-11 12:00:39 PDT
Fixed in r47042.
Eric Seidel (no email)
Comment 6 2009-08-11 15:44:17 PDT
Adding results: Committing to http://svn.webkit.org/repository/webkit/trunk ... M LayoutTests/ChangeLog A LayoutTests/fast/images/icon-0colors-expected.checksum A LayoutTests/fast/images/icon-0colors-expected.png A LayoutTests/fast/images/icon-0colors-expected.txt Committed r47070
Note You need to log in before you can comment on or make changes to this bug.