3

How can I create an Icon object that contains multiple sizes? I cannot load it from a resource because the content is created from different overlayed bitmaps. I cannot create a .ico file because the bitmaps are generated at runtime.

I have 4 Bitmap objects (16x16, 32x32, 64x64 and 128x128). I want to combine these 4 Bitmaps into a single Icon object.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Horcrux7
  • 23,758
  • 21
  • 98
  • 156
  • possible duplicate of [How to create an Icon file that contains Multiple Sizes / Images in C#](http://stackoverflow.com/questions/3213999/how-to-create-an-icon-file-that-contains-multiple-sizes-images-in-c-sharp) – LarsTech Aug 22 '12 at 16:05
  • It's not a duplicate of that question because this one wants to create System.Drawing.Icon rather than a .ico file. – David Heffernan Aug 22 '12 at 20:37

2 Answers2

3

To create an Icon object with multiple sizes you need an ico file or a stream of a ico file. This C# sample code of an IconFactory show how you can create such stream form multiple images in C#. It should be easy to change this sample to use Bitmap objects instead of the BufferedImage objects.

Horcrux7
  • 23,758
  • 21
  • 98
  • 156
0

How can I create one System.Drawing.Icon from multiple Bitmaps?

You can't. System.Drawing.Icon only contains one image.

A .ico file or an icon group resource can contain multiple images. But when you load into System.Drawing.Icon you select just one of those images.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490