Utter lack of Icon documentation
I'm trying to update an application to be nice and Vista-y; the current problem is with icons.
- What icon sizes should my application have to be Vista+XP compatible.
- How can I tell?
In particular, why doesn't Microsoft actually documentation the icon file format? As near as I can tell, there are single-byte 'height' and 'width' values in the list-of-icons in the icon header. This means that icons can only be 0 to 255 pixels. However, it seems that icons in Vista can in fact be 256 pixels, so clearly there isn't a simple mathematical relationship between the value in the file and the value used.
My question is: what is the mathematical relationship between the height and width fields and the actual icon height? Are they just set to zero, but then I have to paw through the actual icon data? Or does Microsoft simply decree that zero means 256? Or is there some other answer?
If I do ship an application where some icons are '0x0', will it cause any issues with pre-vista software? As a programmer, I always worry when a height or width might be zero; it seems like fertile grounds for divide-by-zero bugs. Is Microsoft ready to guarantee that existing Microsoft software won't fail? Or do I need a Vista version of my software that's seperate from the pre-Vista?
Zero means 256. The icon file format was documented back in the Windows 3.1 SDK.
Thank you for a quick reply, but I unfortunately can't fathom why this would be considered an answer, and I hope that some microsoft person will write something which is actually useful.
If zero in the height field means 256 high, what on earth will Microsoft use when icons grow to 1k? It's that question that makes me wonder what the actual mathematical relationship between field-value and actual-value is.
And I am extremely worried about shipping an application with 256x256 icons into a windows-XP world; I would really like some assurance that Microsoft has tested these icon sizes on current real-world application and that they will not cause any problems.
The icon file format may have been documented back in the Windows 3.1 SDK, but if it was, it's not any more. The closest I can come up with is the ICONRESDIR format which, alas, clearly and unambigously states that icons sizes other than 16, 32, and 64 are not legal.
Thanks,
Peter
(PS -- sorry for the rude tone, but I've found from experience that rude questions get replies from Microsoft employess, but polite ones do not)
I'm sorry that telling you what 0 means wasn't useful. I'll shut up now.
I used "zero" four times in my question. The clear implication is that yes, I can tell that the value, in the few examples I have, is zero. My question -- and one that you in particular very rightly spend a lot of time on in your very excellant 'not a .net blog' -- is "what's the contract?" What can I rely on today that I am likely to be able to rely on in five years?
The actual numbered questions are:
1. What sizes of icons should my application have?
2. How can I tell?
These are both very practical questions, and ones that cannot be answered with 'zero means 256'. If you are willing to authoritatively answer that for all icons in the future a width of zero means 256, and a height of zero means 256, then do so. Otherwise you're just saying something expedient that will cause application compatibility problems down the road.
And to add to the actual information content of this thread: in MSDN Library > Win32 and Com Development > User Interface there is a topic called "Icons in Win32" by John Hornick. This seems to document the icon file format except for the Vista extensions, and except that it contradicts the ICONRESDIR information re: acceptable icon sizes (the Icons in Win32 seems to be more accurate).
Peter
There is a lot of information on the Axialis site:
http://www.axialis.com/tutorials/
They have software that enables you to create and edit icons in the Vista format as well as some good discussion on XP vs Vista icon issues.
Hello, Peter.
This is Len Gray, the author of Microangelo icon software.
I understand your concern about the use of zero to represent 256. Our software has been observing 0 as 256 since WIndows 95. Although W95 didn't support images this large, someone at MSFT placed one into a system DLL way back then. :)
In my testing I have not found any problems with compatibility of these "zero/256" size images icons back to Windows 2000. Both XP and W2K ignore these image sizes and process the rest of the images O.K.
However, Windows 2000 looks to be the oldest Win platform that is willing to process an icon resource with images larger than 72x72. This may be the issue you're looking to dig down to. If you include a 256x256 image in your program icon, Windows 98 will display an ugly default image.
I hope this info helps you get closer to your goals. If you have more questions, please ask!
0 has meant 256 since 1995, possibly even before then, I didn't check.
Icon sizes from 1 to 256 are supported. I don't know which ones are recommended. Presumably there will eventually be a Vista UI style guide that answers this question.
An important point, and one that hasn't been mentioned in the other replies, is that an icon (.ICO) file can, and typically does, contain several icons with different color depths *and sizes*. Therefore those 1-byte values in the file header that you refer to don't mean a great deal; they probably should correspond to the size of at least one of the icons in the file (maybe the first one?) but they tell you nothing about the others.
To discover the true sizes of the icons I always use the biWidth and biHeight values in the relevant BITMAPINFOHEADER, which significantly are 32-bit values. Had it been me, I would have defined zero in those 1-byte fields as meaning 'size unknown, refer to the individual icon bitmaps'.
Richard.
Yes, the ICO format can have multiple individual icons; there's a little "directory" structure at the start of the file that lists them all. We're actually talking about that little directory; it only has a single byte for the x and y size of each individual icon-y thing in the icon file.
You're going to be surprised if you use the BITMAPINFO structure -- Vista icons can contiain PNG icons, and they apparently don't contain BITMAPINFO. Take a look at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=88546&SiteID=1 for some details.
Microsoft: why is a required part of your system -- one that should have been nailed down long ago -- still undocumented?
Nobody from the SDK team has asked me to write the documentation for the new icon format.
Good point: I've only ever bothered to look at the '1-byte' size values for the first icon (which I presume is also what Explorer does when it displays the icon's dimensions in a tooltip) and had forgotten that they were also present for the others. I still prefer to use the values in the BITMAPINFOHEADER (when present) since in a situation where they differ from those in the file header - which I guess shouldn't really ever happen - I would consider them more reliable. As I said, had a 1-byte value of zero been defined as meaning 'refer to the bitmap header' it would have provided a neat way to support icons bigger than 256x256.
In the case of Vista PNG icons, which don't have a BITMAPINFOHEADER, the dimensions can presumably be read (again as 32-bit values) from the IHDR chunk so the same arguments apply. In general I don't like it when the same information is supposed to be in two different places!