Search code examples
winapiiconswindows-11windows-explorerico

Create ICO file with transparent background which looks error-free in explorer preview


I have an ICO file (for my c++ application) with a transparent background which looks unclean in the small preview view of Windows Explorer.

(My icon is a drawn shape in PhotoShop and exported as PNG in different sizes to create it in Gimp as an ICO. My ICO contains the following pixel sizes: 16, 20, 24, 28, 32, 36, 40, 48, 64, 128)

It looks normal and sharp everywhere except in the preview. I noticed that all other program icons also look like this as soon as they have a transparent background.

All the icons in the pictures, marked in red, look strange. Although PDF24's is more detailed, it doesn't look that bad. At least the edges aren't that weird.

Chrome icon

PDF24 icon

Image Resizer icon

Why is this so, can it be fixed?

I've searched Microsoft and the Internet, but can't find a solution. I suspect that a BMP with a transparent background may be needed. Unfortunately, the information on this is not available either. I'm not a designer. Could someone tell me how I can generate the solution from the shape I created?

PS: I thought I would upload the file somewhere, but it is probably safer if you just download the file from PDF24. You simply unzip the exe with e.g. 7-Zip and in the .rsrc is the ICON folder with all ICO files. The only difference I can see is that PDF24 has an Alpha Channel. But when I add an Alpha Channel to my file, nothing changes.


Solution

  • Alpha blended icons was introduced with Windows XP. Before that transparency mask was used in ICO files. And it seems until now not all Windows shell views are supporting alpha blended icons...Also, from Windows Vista they have added support for 256px PNG compressed icons.

    Why is this so, can it be fixed?

    No, it couldn't.

    This page have a good description of icon design principles and recommended sizes and color count that should be included in your icon.

    recommended icon sizes

    From this page:

    Application icons and Control Panel items: The full set includes 16x16, 32x32, 48x48, and 256x256 (code scales between 32 and 256). The .ico file format is required. For Classic Mode, the full set is 16x16, 24x24, 32x32, 48x48 and 64x64.

    Icon (.ico format) files must contain the 4- and 8-bit versions, as well as the 24-bit + alpha.

    Only a 32-bit copy of the 256x256 pixel image should be included, and only the 256x256 pixel image should be compressed to keep the file size down.