473,387 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,387 developers and data experts.

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

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
Jan 29 '08 #1
1 10578
RedSon
5,000 Expert 4TB
Sizing your pic is necessary to size it to a square, I believe.
Jan 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
3
by: Shadowboxer | last post by:
How do I add an Icon or bmp or jpg to a resource file? there doesnt appear to be a clear way to do so in the IDE.... thanks -J
1
by: Mats-Lennart Hansson | last post by:
Hi, I want to create a resource file with 2 icons and then use them in a c# project. First I create the resx file with reseditor.exe. After that I add the resx-file into my project and then I try...
3
by: Ignacio Marcos | last post by:
Hi all. I need to convert files on my server from gif to jpg format. I tried with the thumb function, but it does not work (on the line thumb.Save(Response.OutputStream,...
3
by: Pitcairnia | last post by:
The basic purpose of the site is for authenticated users to post event listings, which often include photographs. The user is faced with a page where they can insert all of the information about...
5
by: =?Utf-8?B?Um9i?= | last post by:
Hi all, I want to fire the drag events when someone drags a file over the application's icon. This means the application has not opened yet. Scenario would be: 1. user selects file they want...
0
by: Maciej =?iso-8859-2?Q?Drobi=F1ski?= | last post by:
1. Download and screenshots 2. Information 3. Version history 1. Download and screenshots Main web site - http://www.multiextractor.com Screenshots -...
14
by: Ashutosh Bhawasinka | last post by:
Hi, How can I retrieve the system icon associated with a file/folder so that I can show it in the list view adjacent to the file/folder name? Regards, Ashutosh Bhawasinka
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.