Groups | Blog | Home
all groups > dotnet drawing api > february 2006 >

dotnet drawing api : Creating Image files from Bitmaps - Problem with Icons


Bob Costello
2/9/2006 1:16:31 PM
I created a drawing program using VS.NET 2003. I use GDI+ for the graphics. I
also wanted the option of creating Image files using the same painting
software. Here is what I do:

// Create bitmap
Bitmap bmp = new Bitmap(32, 32)

// Get a graphics object
Graphics g = Graphics.FromImage(bmp);

// Create the drawing on the bitmap
DrawOnBitmap(g, ......);

// Save the image to disk
bmp.Save(FileName, imgfmt);

where imgfmt is an ImageFormat property. All the following work:

Bmp, Emf, Gif, Jpeg, Png, Tiff, Wnf.

However, when I try to use ImageFormat.Icon, the file gets created by isn't
recognized by VS.NET and is brought up in a VS hex editor. I compared this
file with one supplied with the system and noticed a significant difference
in file size. Mine was 192 bytes whereas the system supplied ico file was
1078 bytes.

Any ideas greatly appreciated.

Bob Costello
Michael Phillips, Jr.
2/9/2006 6:56:35 PM
Gdi+ does not offer a encoder for the .ico format.

If you want to learn more about the file structure of icons,
please read the following article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/msdn_icons.asp?_r=1

[quoted text, click to view]

AddThis Social Bookmark Button