Evil Science A whole load of stuff

22Feb/090

C#: Convert .BMP to .ICO

Some handy code:

public void BitmapToIcon(string sourceFileName, string destFileName)
{
// Create a Bitmap object from an image file.
Bitmap bmp = new Bitmap(sourceFileName);
// Get an Hicon for myBitmap.
IntPtr Hicon = bmp.GetHicon();
// Create a new icon from the handle.
Icon newIcon = Icon.FromHandle(Hicon);
//Write Icon to File Stream
FileStream fs = new FileStream(destFileName, FileMode.OpenOrCreate);
newIcon.Save(fs);
fs.Close();
}
Filed under: C# Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.