views:

89

answers:

3

How do I create an icon file that contains multiple sizes?

I know that I create a icon from a bitmap using Icon.FromHandle() but how do I add another image / size to that icon?

Edit: I need to do this in my application, so I cannot execute an external application to do the combining.

A: 

You can't create an icon using the System.Drawing APIs. They were built for accessing specific icons from within an icon file, but not for writing back multiple icons to an .ico file.

If you are just wanting to make icons, you could use GIMP or another image processing program to create your .ico files. Otherwise if you really need to make the .ico files programatically, you could use png2ico (invoking using System.Diagnostics.Process.Start) or something similar.

Zach Johnson
Sure you can make icon files...from any image: http://www.go4expert.com/forums/showthread.php?t=19250
NickAldwin
@NickAldwin: You can save single layered icons (as your link shows), but you cannot save *multiple* layered icons. I've edited to clarify.
Zach Johnson
Just wanted to clear up a possible misconception, thanks for editing ;)
NickAldwin
A: 

Use IcoFX: http://icofx.ro/

It can create Windows icons and store multiple sizes and colors in 1 ico file

icemanind
+2  A: 

Quick CYA: I just did a Google search, and have not tested the method below. YMMV.

I found this article, which mentions a class that does this (albeit in VB.Net, but easy enough to translate), and tells how he used it. While the page that the thread points to no longer appears to have the source code mentioned, I did find a version of it here.

Wonko the Sane
Your google foo is much better than mine. :)
Geoff