.NET C# : Image Conversion from Bitmap to Icon doesn't seem to work
Posted
by contactmatt
on Stack Overflow
See other posts from Stack Overflow
or by contactmatt
Published on 2010-04-19T02:55:22Z
Indexed on
2010/04/19
3:23 UTC
Read the original article
Hit count: 581
I have a simple function that takes a bitmap, and converts the bitmap to an ICON format. Below is the function. (I placed literal values in place of the variables)
Bitmap tempBmp = new Bitmap(@"C:\temp\mypicture.jpeg");
Bitmap bmp = new Bitmap(tempBmp, 16, 16);
bmp.Save("@C:\temp\mypicture2.ico", ImageFormat.Icon)
It doesn't seem to be converting correctly...or so I think. After the image is converted, some browsers do not reconigze the image as a true "ICON" , and even Visual Studio 2008 doesn't reconigze the image as an icon after its converted to an Icon format.
For example, I was going to set the Icon property for my Win32 form app with the Icon i just converted. I open the dialouge box and select the icon I just converted and get the following error.
-- "Argument 'picture' must be a picture that can be used as a Icon."
I've browsed the web and come across complicated code where people take the time to manually convert the bitmap to different formats, but I would think the above code should work, and that the .NET framework would take care of this conversion.
© Stack Overflow or respective owner