开发者

How does windows really choose the right image from a resource?

I read the following on MSDN:

Once an RT_GROUP_ICON is chosen, the individual icon image, or RT_ICON resource, must be selected and extracted. Again, if there exists only one RT_ICON resource for the group in que开发者_如何学编程stion, the choice is trivial. However, if multiple images are present in the group, the following selection rules are applied:

  1. The image closest in size to the requested size is chosen.

  2. If two or more images of that size are present, the one that matches the color depth of the display is chosen.

  3. If none exactly match the color depth of the display, Windows chooses the image with the greatest color depth without exceeding the color depth of the display.

  4. If all the size-matched images exceed the color depth of the display, the one with the lowest color depth is chosen.

  5. Windows treats all color depths of 8 or more bpp as equal. For example, it is pointless to have a 16x16 256 color image and a 16x16 16bpp image in the same resource—Windows will simply choose the first one it encounters.

  6. When the display is in 8bpp mode, Windows will prefer a 16 color icon over a 256 color icon, and will display all icons using the system default palette.

But I also read that developers should provide an 8-bit and 24-bit, 8-bit and 4-bit versions of each size to support different depths. If #5 above is true, why do I need the 8-bit version? And if #5 is true, how does #6 apply?

How does Windows really choose? Does it really matter to include all these color depths if windows treats them all the same?


If #5 is true, the order of icons is important:

  • 32x32x16bpp << Will be chosen if display is >= 16bpp
  • 32x32x8bpp << Will be chosen if display is < 16bpp and could be designed to look better than a auto converted true color icon

(I know the icon editor I use automatically sorts the icons by size and color depth when you save)

If your app runs on < XP it is also important to provide icons < 32bpp since Win9x/2000 has problems with the alpha transparency.

I'm pretty sure #6 is not true, IIRC the plus pack for Win95 enabled the shell to use 256 colors over the default 16 color icons.

Vista added LoadIconMetric and it tries to scale icons down with a better source icon algorythm.

Most people run @ 32bpp these days so the color depth and 16/256 color icons is probably not that important anymore...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜