Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Create a System.Drawing.Icon with Multiple Sizes/Images?

I would like to create a single System.Drawing.Icon programmatically from 32x32, 16x16 Bitmaps. Is this possible? If I load an icon with -

Icon myIcon = new Icon(@"C:\myIcon.ico");

...it can contain multiple images.

like image 638
Damien Avatar asked Feb 01 '10 03:02

Damien


1 Answers

An .ico file can have multiple images in it, but when you load an .ico file and create an Icon object, only one of those images is loaded. Windows chooses the most appropriate image based on the current display mode and system settings and uses that one to initialize the System.Drawing.Icon object, ignoring the others.

So you can't create a System.Drawing.Icon with multiple images, you have to pick one before you create the Icon object.

Of course, It is possible to create an Icon at runtime from a bitmap, is that what you are really asking? Or are you asking how to create an .ico file?

like image 107
John Knoeller Avatar answered Nov 08 '22 01:11

John Knoeller