Friday, June 13, 2008

Visual Studio - Icons

There are a few things involved in adding icons to a Visual Studio project. Where applicable, this guide will reference GIMPshop, but the procedure should be very similar in Photoshop or GIMP (I don't know for sure, as I haven't recently used either one).

First, make your icon in a larger resolution. 255x255 works well, since that's the largest size that the end result can be (Vista allows 255x255/256x256 icons if you have "large icons" enabled). After you have it as you want it, save it as a PNG, then scale it down to 3 different resolutions: 48x48, 32x32, and 16x16. All of these should be scaled down from the original 255x255, as that will provide the best-looking icons. After scaling, some manual pixel manipulation might be needed in order to produce the best-looking results, depending on the nature of the icon.

After you have all 4 image files, open up the 255x255 file, then "Open as Layer" the same file twice more. Then "Open as Layer" each of the other three files three times each. Save the whole thing as an Microsoft Windows Icon file (.ico). A window will come up with each of the layers in it, and next to each layer is a dropdown box. The box lets you select the color bitrate for each layer. For each image size, you want one layer to be 32-bit, one layer to be 8-bit, and one layer to be 4-bit. Reducing the bitrate may require additional touching-up as well.

You now have an icon file that can be imported into Visual Studio. There are two places where it should be imported into your project. The first is in the main window. In the window's Icon field, select the file you just made. Then do the same in the application's properties page (though VS may like it more if you import the icon as a Resource, then add it that way).

With this, Windows should know when to use the right filesize and bitrate for any given situation. These 12 images are all that's recommended by Microsoft for Vista compatibility, but you can put in more if you want to be prepared for situations where Windows would otherwise scale the icons for you.

No comments: