Connecting Tech Pros Worldwide Help | Site Map
Reply
 
LinkBack Thread Tools Search this Thread
  #1  
Old January 29th, 2008, 07:16 PM
Newbie
 
Join Date: Jan 2008
Posts: 1
Default Convert Pic file (jpg, bmp, etc) to Icon c#

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 08:52 PM. Reason: URL
Reply



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

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

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.