Click here to Skip to main content
15,889,723 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 
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 
Hi. I checked that it was not VS or debug causing the Select Folder dialog to stay open when the main app closes. It did the same when I just ran the release executable. I'm not a WPF expert, but just looking quickly at your code, maybe your calls to:

FolderBrowserDialog.ShowDialog(System.Windows.Window Parent = null)

need to be passed a parent argument?

Evidently the WPF SelectFolder() method has some interesting quirks as well. Googling that, I read this StackOverFlow link. Maybe there is something there to help?

c# - Select folder dialog WPF - Stack Overflow[^]

At any rate, thanks for the tip about using 32 BPP for icon images. I read your previous article which confirmed my notion that icon files are so (unnecessarily?) complex that it sure makes sense to depend on somebody who has studied the issues! (And created an app for that! Wink | ;) ) For instance, I didn't know that a "proper" icon file should contain 32, 8, and 4 BPI icons. (Still not sure why?)

Apparently the GIF Gear Movie app doesn't do that (it must just convert everything to 32 BPP?)

Thanks again for a useful tool!
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.