0

I found a question similar to mine here but it doesn't answer my specific question.

I have a single .ICO file that contains three icons:

  • 16x16 4-bit (16 colour)
  • 32x32 4-bit (16 colour)
  • 48x48 24-bit (True colour)

I chose to put these three into it although I only have a definite need for the first two (16x16 for the application title bar and task bar; 32x32 for ALT-TAB) because this article said so.

While Windows imposes no restrictions on the sizes of icons, common sizes include 16, 32, and 48 pixels square. For this reason, developers are encouraged to include a minimum of the following sizes and color depths in their icon resources:

16 x 16 16 colors

32 x 32 16 colors

48 x 48 256 colors

However, as you can see, I made an error by adding a True Colour (24-bit colour) instead of a 256 colour (8-bit colour) image as the 48x48 one.

When I use the above .ICO file my ALT-TAB icon is pixelated, as if the 48x48 has been squished down and used instead of the 32x32.

If I change the .ICO file to only contain the 16x16 and 32x32 images, or to have the recommended 8-bit colour 48x48 image then ALT-TAB looks fine and does correctly use my 32x32 image.

My question is why does including a true colour 48x48 size cause the problem with ALT-TAB display?

P.S. Nothing like writing out your question on StackOverflow to help you spot your own error (wrong number of colours!) but I am still curious why the True colour image causes this behaviour.

4
  • Which Windows version?
    – Nyerguds
    Apr 29, 2017 at 21:21
  • I'm using Windows 8.1 Apr 30, 2017 at 6:31
  • That article was wrong when it was written, by the way. Or, at least, oversimplified. Windows 95 supported custom DPI settings, and if you increased your DPI beyond the default 96 DPI setting (to something like 120 DPI), the shell would prefer to use larger icons. 48x48 icons at a 256-color (8-bit) depth were common to include for users with nice, large, fancy SVGA displays. In modern versions of Windows, the advice is even more wrong, as Nyerguds pointed out. The shell will use the largest version of the icon available and downscale it (cf LoadIconWithScaleDown API, available since Vista). Apr 30, 2017 at 8:29
  • 1
    The best practice here is to include all common sizes and bit depths of icons, including 16x16, 24x24, 32x32, 48x48, 64x64, 128x128, and 256x256, each at 8-bit, 24-bit, and 32-bit color (if you need 32-bit color, but come on, who doesn't want alpha-channel transparency?). It substantially improves compatibility and visual effects, at little to no cost. As Nyerguds already pointed out, it is simple to programmatically downscale the icons yourself, with a bit of visual tweaking. This has better results than letting the OS do it. The only other cost is the size; a few bytes are worth it. Apr 30, 2017 at 8:31

1 Answer 1

1

The 'recommendations' you're using are a document from 1995. It is more than just outdated; it's Win95 generation. Completely obsolete.

On the alt-tab issue, I think the 48x48 version is being used because it's in a colour quality more fitting to the environment; high-colour icons have smooth fades to transparency.

You're not limited in how many icons are in there, you know. Not even of the same dimensions. You can perfectly add a 32x32, 256 colour icon in there, and a 32x32, true colour image, and it'll just pick the most appropriate one for the given situation.

So yeah. The answer seems simple. If you really want that backwards compatibility, just add all icon sizes in there as both true colour and 256-colour, and it'll always take the best one for each situation. But as far as I can see, there's no reason whatsoever to even bother with that. Just add them all as true colour. No one is using Windows 95 anymore, and neither file size nor colours are still a limiting problem nowadays.

These days, I no longer bother actually making my own icons, anyway. If I need an icon I make sure I got it as 256x256 high-colour PNG image, and just feed it into an online icon generating site like ConvertICO. It generates all the smaller versions automatically, using high-quality downscaling algorithms. But these also no longer bother putting in 8-bit or 4-bit versions. It's just not needed, unless you're determined to make sure the icon looks good on ancient pre-XP systems.

6
  • 8-bit icons are still important; consider the case where you're running in Safe Mode or some other situation without the correct video drivers. Now, if your app doesn't need to be available/usable in these situations, I guess that's okay and you can omit the lower color-depth icons. But it also doesn't hurt anything to include them. And while it works to do it the lazy way (downsampling all icons from a large image), it doesn't produce the greatest of results. 16x16 icons always need to be hand-tweaked for discernability, often massively simplified. Also helps to tweak 32x32 icons. Apr 30, 2017 at 8:20
  • Well, yes, I did suggest just adding multiple types for each size (except 16-colours; that's just needlessly making the icons look worse). As for the downsampling, I dunno, ConvertICO always gave me pretty nice results even on the 16x16 versions. Also, I honestly wouldn't know what to edit icons with nowadays.
    – Nyerguds
    Apr 30, 2017 at 9:27
  • I just used the Visual Studio ICO editor to edit my icons. I also thought I got better looking icons in the various different places I was using them when I created them by hand. I don't make them very often (or I'd have been more knowledgeable about all this I'm sure) so it wasn't a hardship to do so. May 1, 2017 at 5:06
  • Good to know that MSDN contains such obsolete information! Is there an equivalent more up-to-date article? May 1, 2017 at 5:07
  • I don't think the Visual Studio editor can even do smooth transparency fade,,. well, I know the 2012 version doesn't; I don't have a more recent one. That kind of takes away the biggest advantage of true colour.
    – Nyerguds
    May 1, 2017 at 13:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.