Click here to Skip to main content
15,868,016 members
Articles / Operating Systems / Windows
Article

How to Create Icon Files for Your Windows App using Visual Studio and Microsoft Paint.

Rate me:
Please Sign up or sign in to vote.
4.12/5 (40 votes)
6 Jan 2006CPOL5 min read 597.9K   3.2K   63   60
This article will show how to use Visual Studio and Microsoft Paint to convert an existing bitmap image into an icon file that your Windows application can use.

Introduction

For the longest time, I was limited to only having the icons I could create artistically or existing icons I could reuse in my Windows apps. I don't know about you, but I am not artistic enough to make good icons from scratch. This article describes how to use Visual Studio and Microsoft Paint to create icons for your Windows app starting with an existing bitmap.

NOTE: I am using Tech-Pro’s logo with permission. I am currently employed with Tech-Pro and I asked to use it as the example for this article.
NOTE: If you are going to use someone else’s bitmap image, make sure that you have permission to do so.

Background

I was creating a new Windows app and I was again faced with having the default icon on the app. I had a little time on my hands and decided to try to make a new icon file from an existing bitmap file. I figured there may be a few other programmers out there that would like to know what I learned.

Icon Files

There are a few things I should mention about Icon files. First they can hold multiple sizes and color depths in them, i.e. one icon file can have 16 X 16 pixels, 32 X 32, 48 x 48, 64 X 64, 96 X 96. Each one of those sizes can have three color options: monochrome, 16 colors and 256 colors. Now if you only have a 16 X 16 image, your application will use that image in Windows Explorer, but you will get some default image for a desktop shortcut. You need a 32 X 32 or higher image for the desktop shortcut. So you need at least two images. One image 16 X 16 pixels in size and the other image which is 32 X 32 pixels or larger in size.

Creating the Icon File

First, you want to add a new Icon file to your Windows application project. Make sure you name it properly. In our example, I am just taking the default Icon1.ico name.

New file Dialog

VS Icon File

Next, you will want to open the bitmap file you want to convert to an icon in Microsoft Paint. We are going to strip off any text, get the file into a square that fits one of the above sizes. In this example, we are going for 64 x 64 pixels. Then we will copy the images from Paint and paste it into the correct image type in Visual Studio.

Tech-pro bitmap Tech-pro bitmap with text removed and centered

We need to create the correct new image type in the icon file. We are going to create a 64 X 64 pixels 256 color image type. So select the Icon file in Visual Studio and then right click and select New Image type. The new Icon Image Type dialog will come up so we can select the one we want.

New Icon Image type dialog

Next, we will need to properly set the background color of the new Icon Image type. It defaults to a blue color. In this example I am picking white, but you should choose whatever color works best for your image. It is easiest to change the color all at once. If you go to the Image menu, then tools, then fill tool, you can then select a color from the palette and set the background color of the icon image type. Next go to Paint and do a select all and copy. Next, go back to Visual Studio and paste into the icon file.

VS Icon file paste

We will be repeating this process for the other icon image sizes. Next we need to go back to Paint to create our 16 X 16 pixel image. If you go to the Image menu and stretch/skew, you can reduce the image by half, making it 32 X 32. We will do this again to get the image down to 16 X 16.

MS Paint stretch/skew

Next we need to change the image attributes to have a width of 16 and a height of 16. In Microsoft Paint, go to the Image menu, then attributes. Back in Visual Studio, we need to create a new icon image type of 16 X 16 pixels with 256 colors. Set the background color of the new icon image type. Copy the image from Microsoft Paint and paste it into the new icon image.

At this point, we have the two icon image files that are necessary for what we want in an icon file. Go to your Windows form and select the icon property. Select the icon we have just created. This will cause the form itself to use the icon. Next go to the project properties and change the icon to be the one you just created. This will cause the icon to be used in Windows Explorer, a short cut on the desktop and the application down on the tray.

Tech-pro desktop icon

Finally, you may want to delete the default icon image types. They are both 16 colors. Note that you may want to add a 32 X 32 pixel image as well. To switch between icon image types, just right click on the icon file and select current icon image types. That will allow you to select the existing icon image types in the icon file.

Conclusion

I am sure there are other ways of creating Icon files, but I have found this one to work well for me. I hope you have learned a little bit about icon files and find this technique useful.

History

  • 6th January, 2006: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
I started my programmer career over 26 years ago doing COBOL and SAS on a MVS mainframe. It didn't take long for me to move into windows programming. I started my windows programming in Delphi (Pascal) with a Microsoft SQL server back end. I started working with vb.net when the beta 2 came out in 2001. After spending most of my programming life as a windows programmer I started to check out asp.net in 2004. I achieved my MCSD.net in April 2005. I have done a lot of MS SQL database stuff. I have a lot of experience with Window Service and Web services as well. I spent three years as a consultant programing in C#. I really enjoyed it and found the switch between vb.net and C# to be mostly syntax. In my current position I am programming in C# working on WPF and MSSql database stuff. Lately I have been using VS2019.

On a personal note I am a born again Christian, if anyone has any questions about what it means to have a right relationship with God or if you have questions about who Jesus Christ is, send me an e-mail. ben.kubicek[at]netzero[dot]com You need to replace the [at] with @ and [dot] with . for the email to work. My relationship with God gives purpose and meaning to my life.

Comments and Discussions

 
QuestionCaption Pin
Member 1040618421-May-15 3:38
Member 1040618421-May-15 3:38 
AnswerRe: Caption Pin
Member 1040618421-May-15 5:23
Member 1040618421-May-15 5:23 
QuestionGUIDANCE OF GOD Pin
tmjamal26-May-14 21:24
tmjamal26-May-14 21:24 
AnswerRe: GUIDANCE OF GOD Pin
kubben27-May-14 1:25
kubben27-May-14 1:25 
QuestionGreat Article Pin
Jay Larmee5-Dec-12 11:54
Jay Larmee5-Dec-12 11:54 
AnswerRe: Great Article Pin
kubben5-Dec-12 15:59
kubben5-Dec-12 15:59 
GeneralGreate Article Pin
Member 44765384-Jan-12 8:40
Member 44765384-Jan-12 8:40 
GeneralRe: Greate Article Pin
kubben4-Jan-12 9:33
kubben4-Jan-12 9:33 
GeneralMy vote of 4 Pin
Chip VonBurg7-Jun-11 14:05
Chip VonBurg7-Jun-11 14:05 
GeneralMy vote of 1 Pin
angelique649-Apr-10 7:55
angelique649-Apr-10 7:55 
GeneralThe icon doesn't seem to work... Pin
Anupama Sankaran15-Apr-09 2:38
Anupama Sankaran15-Apr-09 2:38 
GeneralRe: The icon doesn't seem to work... Pin
kubben15-Apr-09 4:35
kubben15-Apr-09 4:35 
GeneralRe: The icon doesn't seem to work... Pin
Anupama Sankaran21-Apr-09 4:16
Anupama Sankaran21-Apr-09 4:16 
GeneralRe: The icon doesn't seem to work... Pin
kubben21-Apr-09 10:53
kubben21-Apr-09 10:53 
GeneralRe: The icon doesn't seem to work... Pin
Anupama Sankaran23-Apr-09 5:25
Anupama Sankaran23-Apr-09 5:25 
QuestionI need help with a math problem... Anyone, anyone... Beuller???? Pin
blkbagger27-Feb-09 10:44
blkbagger27-Feb-09 10:44 
AnswerRe: I need help with a math problem... Anyone, anyone... Beuller???? Pin
kubben27-Feb-09 11:14
kubben27-Feb-09 11:14 
GeneralThanks for the detailed explanation Pin
Poornima Sekhar21-May-08 11:57
Poornima Sekhar21-May-08 11:57 
GeneralRe: Thanks for the detailed explanation Pin
kubben21-May-08 14:37
kubben21-May-08 14:37 
GeneralThanks Pin
Naveen R Hegde14-Apr-08 15:26
Naveen R Hegde14-Apr-08 15:26 
GeneralRe: Thanks Pin
kubben15-Apr-08 0:44
kubben15-Apr-08 0:44 
GeneralOnly Applies to Full Visual Studio Editions Pin
bradford_bantam3-Jan-08 11:33
bradford_bantam3-Jan-08 11:33 
GeneralRe: Only Applies to Full Visual Studio Editions Pin
kubben3-Jan-08 12:05
kubben3-Jan-08 12:05 
GeneralClear and Easy-to-follow Article Pin
JimOwen28-Sep-07 8:00
JimOwen28-Sep-07 8:00 
Thanks for the well-written and east-to-follow article. I had many times found myself wondering how to create a decent icon for many of my programs. My from-scratch attempts were often pretty pitiful.

One thing to note is that you can actually start with any type of file supported by Paint in pretty much any size. I found a jpg that had an image similar to what I wanted, but its size was about 288 x 180. I opened the file in Paint, then used the resize option on the image menu to scale it down to where the first dimension was 64 pixels. Then I simply copy-n-pasted into the icon editor in vs2005.

The easiest way of getting exactly 64 pixels was to use the percent resize so you can get one dimension exactly correct.

When you paste into the icon editor in VS2005, you can move the image that was pasted until it's centered like you want.

Also, it's a lot easier to paste from the icon editor within VS2005 when making new image types within the ico file. A lot less work than pasting from Paint once the first one is done.

Thanks for a workable procedure.

Regards,
Jim

GeneralRe: Clear and Easy-to-follow Article Pin
kubben28-Sep-07 8:13
kubben28-Sep-07 8:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.