Click here to Skip to main content
15,889,595 members
Articles / Desktop Programming
Tip/Trick

Icon Pro - Create icons for Windows Desktop

Rate me:
Please Sign up or sign in to vote.
4.33/5 (18 votes)
13 Nov 2017CPOL5 min read 22.7K   24   11
Icon Pro - A C# + WPF open source tool for creating windows icons from PNG images or SVG vectors

Introduction

Ever needed to create an icon for your Windows Desktop project?

Well, I did, and many times. Nowadays, we can find some nice Websites that provide easy ways to create a Windows Icon file from a PNG image. But, in the past, things were different. Some years ago, before the explosion of the mobile development world, finding a good, and more important, free tool to help create an icon was a really tough deal!

That's why I begun the development of this tool some years ago. And now, I've just updated and uploaded it to GITHUB, in the way that everyone can make use of it and, if want, help in the development process.

In fact, it might not seems to be this way but, the icon of a software is like its profile picture. Our mind associates that tiny picture with our program. So, you should expend more time creating a particular Icon that defines your application.

Think about it!

With this cool open source tool, you will be able to design you application's icon, on your favorite program (Like GIMP, Illustrator, Corel), export it to a PNG image or even a SVG vector and just open Icon Pro and import that image. It will do all the background work, generating all the multiple size frames from that single image.

With a few clicks, your icon will be there for you!

Please, note that, even though I've done lots of researches and studied a lot about icon files, this software might be still not perfect.

If you find a bug, help me out to fix it. Write a reply, tell me what's wrong, let's share some code. Please, don't vote down, the main goal here is to build a simple, free and open source tool to help everyone.

Background

So, this is a WPF application, written in C# (7.1) for Microsoft .NET Framework 4.6.1.

This tool is, basically, a complement for my project described here:

There, you can understand a little bit more about its background.

But, for now, I'm going to tell you the most important things about its background:

It's divided into layers, 3 layers:

  1. The first layer is the Core API. The core works with bytes and bits, and provides the basic operations for opening and writing Icons and Static Cursors. Yeah, this tool comes with a CursorBitmapDecoder and a CursorBitmapEncoder as well!
  2. The second layer is the WPF Library. It's a wrapper around the Core API. It brings to the Windows Presentation Foundation four important objects: IconBitmapEncoder, IconBitmapDecoder, CursorBitmapEncoder, CursorBitmapDecoder.
  3. The third layer is the Application itself, a WPF Windows Application! It provides a very simple and objective GUI for working with Icons!

This tool allows you to extract icons from executables (.exe and .dll). This very cool functionality is based on the great article below by :

This tool can open Windows Cursor files (.cur), but still, there's no implemented functionality that allows you to create one, even though that's already possible with the CursorBitmapEncoder class.

With the use of the great API SVG.NET, this application lets you create an Icon from a SVG vector file. You can, as well, create an Icon file from a PNG image!

In short words, the main functionalities of this program are:

  1. Create an Icon file from a single PNG or SVG image. You design your icon once, and the software will generate all the icon frame sizes from that single image (That must be 256x256px).
  2. Extract an Icon file from an win32 executable (.exe, .dll).
  3. Open an Icon or a Cursor file. Both static and animated cursors are now supported on a very experimental phase.
  4. Create an Icon from a folder containing all the frames and its different sizes and bit depths.

Now, after lots of researches I've successful implemented an very experimental support for opening Animated Cursors. I would like to mention the great article series by Jeff Friesen that helped me a lot understing the structure of the cursor files!

Introduce Animated Cursors to Java GUIs, Part 1 | Let There Be Animated Cursors

On the latest updates, I've included a piece of code from the great article bellow:

IconLib - Icons Unfolded (MultiIcon and Windows Vista supported) - CodeProject

The code I've included is related to the AND mask creation. 

Using the Code

Actually, you don't need to write even one single line of code to create an icon, but, in the background, this tool and the libraries behind it, allows you to code things like this:

C#
IconPro.Lib.Wpf.IconBitmapEncoder encoder = new Lib.Wpf.IconBitmapEncoder();
encoder.UsePngCompression = compression;
foreach (Models.IconFrameModel fr in _Frames)
{
    encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(fr.Frame));
}
encoder.Save(Output);
encoder = null;

Points of Interest and Considerations

Okay, I know, it's 2017 and now everything is about Mobile Development, and it makes no much sense to publish a project to handle files from the past century. But, I found the development of this tool very fun, and, as it can be useful for someone, I'm publishing it for everyone on GITHUB.

I would like to thanks asiwel for pointing out some issues and bugs. Thanks to him, I've made some changes and fixed some bugs.

There you can find the source code and the release:

History and Road-map

I'd like to present the road-map for this tool. Currently, I'm doing improvements on PHASE 2. But there is already som progress towards the PHASE 3. For example, the Core Lib already contains a namespace, called Motion, with some classes to handle Animated Cursor files. Even though that it is on a very experimental stage, this codes lets you open animated cursor files and view its frames. In fact, the core library is already on version 2.2.x while the rest of the codes are still on version 1.x.x.

Image 1

  • The development begun in 2013
  • First release in 2014 - Created the GUI, and almost all the functionalities
  • Some updates in 2015
  • Major updates in November 2017 - Code uploaded to GITHUB, and ported to Visual Studio 2017 and NET STANDARD 2.0; Added support for cursor files; Added support for SVG files
  • 11/11/2017 - Build 238 released and codes updated on GITHUB. I rewrote the core library to be easier to understand. Some overall bug fixes as well.
  • 13/11/2017 - Some small bug fixes. Added experimental support for Animated cursor files. Road-map released. Short demo video uploaded.

License

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


Written By
Student
Brazil Brazil
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionOnly see up to 48x48 size frames from image Pin
asiwel7-Nov-17 15:09
professionalasiwel7-Nov-17 15:09 
Hi, This appears to be a very handy tool and a very nice piece of work (having gone through the same problem myself multiple times in the past trying to create full icon sets for Windows desktop apps ... last time I settled on using the "GIF Movie Gear" app for doing that successfully).

I downloaded your app zipfile from GITHUB and had no difficultly unzipping it, loading the solution in VS 2017, building the libraries and the app, and running the program. Opening one of my own "hand-made icon files, I see all of the frame sizes from 16 to 256. Nice.

But when I try to create an icon from a .png image, I see the nice square image and all the sizes are checked and 8 BPP selected. (I do not see a 32 BPP option either, like the one show in your animated demo. All I see are 8, 4 and 8+4?) However, when I click CREATE, I only see and can preview four frames sizes (16, 24, 32, 48). Why is that? I expected to see all of the checked sizes and to then be able to save a full icon set. The app will save an icon file with those 4 frames and it will save those 4 frames in a folder. But of course I need all of the frames in the set.

[EDIT] I think I figured out my problem. Apparently the images I was trying to use were saved as 8 BPP images, rather than 32 BPP images. Why that makes a difference in the frames sizes, I really have no idea. (All of those "hand-made" icon files I mentioned above contain all the frames sizes and were created from 8 BPP images, I think ... and seem to work fine. Maybe they would be poor or fail on certain hardware??? I guess I thought using 8 BPP just meant a smaller icon file with fewer colors available? I tend to use indexed color files anyway for icons and simple images. Maybe that is bad?)

PS / Oddly, "exporting" (apparently SAVE saves icon files and EXPORT saves icon images) opens a "Browse for Folder" dialog that shows folders/places to save such as Libraries, Network, Control Panel, and my User Name folder (!?!) as well as ordinary desktop folders and the This PC folder, etc.

This seems to me to be a "poor design" or else a bug in that no one would want to accidentally drop a bunch of image files (or anything else) into those system folders. I suggest this be fixed.

Incidentally I think I just noticed another "bug." When you click EXPORT and the "Browse for Folder window is open, it of course has the focus. But if you then click on your app window, giving it the focus, and then click on the X box to close the app, it does close ... but the Browse for Folder window stays open. That is not good. When you close your application, all of the windows and other stuff associated with that running process should close properly as well.

Thank you.

modified 7-Nov-17 21:27pm.

GeneralRe: Only see up to 48x48 size frames from image Pin
Herbert Lausmann8-Nov-17 2:47
professionalHerbert Lausmann8-Nov-17 2:47 
GeneralRe: Only see up to 48x48 size frames from image Pin
asiwel8-Nov-17 13:28
professionalasiwel8-Nov-17 13:28 
GeneralRe: Only see up to 48x48 size frames from image Pin
Herbert Lausmann10-Nov-17 10:46
professionalHerbert Lausmann10-Nov-17 10:46 
GeneralRe: Only see up to 48x48 size frames from image Pin
asiwel10-Nov-17 15:17
professionalasiwel10-Nov-17 15:17 
GeneralRe: Only see up to 48x48 size frames from image Pin
Herbert Lausmann11-Nov-17 0:46
professionalHerbert Lausmann11-Nov-17 0:46 
GeneralGreat Improvements Pin
asiwel12-Nov-17 17:32
professionalasiwel12-Nov-17 17:32 
GeneralRe: Great Improvements Pin
Herbert Lausmann13-Nov-17 0:49
professionalHerbert Lausmann13-Nov-17 0:49 
NewsANIMATED CURSOR FILES SUPPORT Pin
Herbert Lausmann11-Nov-17 7:32
professionalHerbert Lausmann11-Nov-17 7:32 
GeneralRe: ANIMATED CURSOR FILES SUPPORT Pin
Southmountain11-Nov-17 15:00
Southmountain11-Nov-17 15:00 
GeneralRe: ANIMATED CURSOR FILES SUPPORT Pin
Herbert Lausmann11-Nov-17 23:16
professionalHerbert Lausmann11-Nov-17 23:16 

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.