3
votes

I'm having trouble with my application icon looking bad after adding it into my project, building it, and creating a shortcut to it.

Here's what I've done:

1) I started with a 256x256 PNG file that looks great.

2) I used IcoFX to generate a .ICO file with all the recommended sizes.

3) I add the icon to my project as follows: A) Open project properties -> Resources -> Add Resource -> Add Existing File B) Choose the .ICO file that I created in step 2.

4) Go to "Application" section of project properties.

5) In "Icon and Manifest", drop down "Icon" and choose the icon that I added in step 3.

6) Save my project and build it.

7) Go to Windows Explorer and find the newly built EXE.

8) Create a shortcut to the EXE on the desktop.

The icon looks like this: Bad Looking Icon

As you can see, it doesn't look very good. The edges are jagged, etc.

At first, I thought it was an issue with my .ICO file, but here's the kicker... I then did the following:

9) Right-click on the desktop icon, and go to Properties.

10) Go to the Shortcut tab and click "Change Icon".

11) Click "Browse", and select the EXACT SAME ICON FILE that I added to my project in step 3.

Now, my desktop icon looks like this: Good Looking Icon

Now, the icon looks pretty and smooth!

Again, both icons used the exact same source .ICO file. The only difference is that the first one was imported into Visual Studio and embedded in my .EXE, and the other one was directly used via the OS.

What is Visual Studio doing to my icon to make it look so crummy, and how can I prevent it?

1

1 Answers

1
votes

This could be a problem with the windows icon cache. I had the same problem that I fixed by clearing the cache.

The first version of your code that you copied to the desktop - did this have a low res icon ? Windows will cache the icon when it first sees the EXE, and then does not refresh even when you rebuild your executable if it has the same filename. You will also see the same behavior in windows explorer.

I think by changing the icon through the OS, you've just manually refreshed the icon cache.

You can quickly test this by renaming the EXE before copying it to the desktop. This will bypass the cache and show the actual icon in your EXE.

To get rid of any old icons in the icon cache, you can clear it as described in this link

http://www.winability.com/how-to-erase-icon-thumbnail-cache-windows-8/