Connecting Tech Pros Worldwide Help | Site Map

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

  #1  
Old January 29th, 2008, 08:16 PM
Newbie
 
Join Date: Jan 2008
Posts: 1
Pleease reference this thread:

http://www.thescripts.com/forum/thread596738.html

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);
this.Icon.Save(st);


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

Hope this helps,
David

Last edited by RedSon; January 29th, 2008 at 09:52 PM. Reason: URL



  #2  
Old January 29th, 2008, 09:52 PM
RedSon's Avatar
Site Moderator
 
Join Date: Jan 2007
Location: America
Posts: 3,362

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


Sizing your pic is necessary to size it to a square, I believe.
Reply