By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,016 Online
Bytes IT Community
Submit an Article
Got Smarts?
Share your bits of IT knowledge by writing an article on Bytes.

Convert Pic file (jpg, bmp, etc) to Icon c#

P: 1
Pleease reference this thread:

Size your Pic file to .5 x .5 inches. (for some reason this was necessary.)

You can use Microsoft Photo Editor or Photoshop for editing/cropping.

Here's the C# code:

this.Icon = Icon.FromHandle(new Bitmap(Bitmap.FromFile(YourFilePath_PIC)).GetHicon ());
Stream st = new FileStream(YourFilePath_ICO, FileMode.Create);

YourFilePath_PIC would be like @"c:\test\myimage.bmp"
YourFIlePath_ICO would be like @"c:\test\myimage.ico"

Hope this helps,
Jan 29 '08 #1
Share this Article
Share on Google+
1 Comment

Expert 5K+
P: 5,000
Sizing your pic is necessary to size it to a square, I believe.
Jan 29 '08 #2