Using the Icon Editor in Visual Studio 2005

by Gong Liu February 13, 2009 20:04

The Icon Editor in Visual Studio 2003/2005 is somewhat under utilized and under-documented. Admittedly, the Icon Editor is awkward to use and has quite a few limitations, such as you cannot create an icon with more than 256 colors or a compressed icon as those used in Vista. However, if you are a developer who occasionally needs to create some icons, the Icon Editor in Visual Studio is a viable choice. Especially if you combine your favorite image editing tool, such as Photoshop, with the Icon Editor, you can get the job done fairly easily. And you don't have to buy any third-party icon tools or plug-ins.

In this post I'll show you how to create an icon that contains multiple image types (size and color depth) using the Icon Editor and Photoshop. Before we dive in, let's first take a look at the Windows standard icon sizes.

Size 16x16 32x32 48x48 96x96 256x256
XP List view/Details view/Windows title bar Icons view Tiles view Thumbnails view Does not support
Vista List view/Details view/Windows title bar Classic view Medium icons Large icons Extra large icons

When you create an icon for your Windows application (especially the one at the top-left corner of a Windows Form), you want to pack all these standard sized icon images into one .ico file. This way, depending on the view, the icon image with the best-fit size will be used for display. If you try to use one size to fit all, sometimes you will get a fuzzy or jagged image.

Now here are the steps to create an icon that contains multiple image types:

  1. Prepare some standard-sized images with Photoshop and save them as transparent .gif files. Don't use .png or other formats, as the Icon Editor can't handle an image with more than 256 colors. In our example I have these images.
    16x16 32x32 48x48 96x96 256x256

  2. Save the color palette for each image. In Photoshop, you click Image -> Mode -> Color Table to bring out the Color Table dialog box. Click Save button to bring out the Save dialog box. Specify a file name and the Microsoft Palette .PAL format, and then click Save button. Leave Photoshop open. We will need it in later steps.


  3. Launch Visual Studio 2005 and create a new Windows Application project with a project name, say IconTest.
  4. Right click IconTest project in Solution Explorer, and then click Add -> New Item.
  5. In the Add New Item dialog box, select Icon File, gave a name to the icon to be created, say GPS.ico, and click Add button.


  6. By default Icon Editor gives you two image types 16x16 16 colors and 32x32 16 colors. We need to delete the two default types and add 5 new types 16x16 256 colors, 32x32 256 colors, 48x48 256 colors, 96x96 256 colors and 256x256 256 colors. To add a new image type, click Image -> New Image Type, and from the New Icon Image Type dialog box select the type you want. To delete an image type, click Image -> Current Icon Image Type, select the type you want to delete, and then click Image -> Delete Image Type. After adding and deleting image types, we should have the 5 new image types under Current Icon Image Types submenu:


  7. Make one of the 5 image types the current type and load the corresponding palette saved in Step 2. To do this, click Image -> Load Palette, in the Load Palette dialog box, browse to the palette file and press Open button.
  8. Go to Photoshop, select the corresponding image, and copy it to clipboard.
  9. Go back to Icon Editor, right click any empty space, and select Paste.


  10. Repeat Steps 7 ~ 9 for all other image types.
  11. Click Save button on the tool bar. The icon GPS.ico is now successfully created.
  12. Now you can add the icon to a WinForm. Double click the WinForm, in the Properties panel select Icon and click . In the Open dialog box, browse to GPS.ico, and press Open button.


You can download the icon GPS.ico here (right click the link and select Save Target As).

About

A seasoned computer professional. A tofu culture evangelist...
more >>

Tag Cloud

Calendar

<<  April 2017  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar
Copyright © 2008-2011 Gong Liu. All rights reserved. | credits | contact me
The content on this site represents my own personal opinions, and does not reflect those of my employer in any way.