473,569 Members | 2,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Saving an image as an .ico file

When trying to save an image as an icon, I've used the following line of
code (img is an System.Drawing. Image)...

img.Save("C:\ou tput.ico", ImageFormat.Ico n)

The files saves without an error, and it can be opened by Windows Picture
and Fax Viewer, but I cannot assign the image as a form icon. Does anyone
know what I can do to get this to work?
Nov 23 '05 #1
3 6067
Dear Jason Barnett,

Why aren't you able to assign the image as a form icon? Does it produce an
error, or aren't you able to browse to it? Could you specify your problem a
bit more?

Michel van den Berg

"Jason Barnett" <jw*@wbai.com > schreef in bericht
news:O%******** *******@TK2MSFT NGP09.phx.gbl.. .
When trying to save an image as an icon, I've used the following line of
code (img is an System.Drawing. Image)...

img.Save("C:\ou tput.ico", ImageFormat.Ico n)

The files saves without an error, and it can be opened by Windows Picture
and Fax Viewer, but I cannot assign the image as a form icon. Does anyone
know what I can do to get this to work?

Nov 23 '05 #2
I'm able to save the image with an .ico extension, however I don't think
it's in the correct .ico format. When I attempt to load it as an Icon
object, I receive an ArgumentExcepti on (with the message, "Argument
'picture' must be a picture that can be used as a Icon."). I'm able to
browse to the file and open it with "Windows Picture and Fax Viewer", but
the image does not appear as the icon for the file when I look at it in
Windows Explorer.

Here's a more detailed example of my code:

Dim icoFile As String = "C:\output. ico"

Dim img As Image = Image.FromFile( "C:\doc01.g if")
img.Save(icoFil e, ImageFormat.Ico n)

Dim icon As New Icon(icoFile)
Me.Icon = icon
"Michel van den Berg" <mv*@promontis. nl> wrote in message
news:eb******** ******@TK2MSFTN GP09.phx.gbl...
Dear Jason Barnett,

Why aren't you able to assign the image as a form icon? Does it produce an
error, or aren't you able to browse to it? Could you specify your problem
a bit more?

Michel van den Berg

"Jason Barnett" <jw*@wbai.com > schreef in bericht
news:O%******** *******@TK2MSFT NGP09.phx.gbl.. .
When trying to save an image as an icon, I've used the following line of
code (img is an System.Drawing. Image)...

img.Save("C:\ou tput.ico", ImageFormat.Ico n)

The files saves without an error, and it can be opened by Windows Picture
and Fax Viewer, but I cannot assign the image as a form icon. Does
anyone know what I can do to get this to work?


Nov 23 '05 #3
Dear Jason Barnett,

Try this:

Dim outputFileName As String = "C:\output. ico"
Dim inputFileName As String = "C:\input.g if"
Dim bmp as Bitmap = Ctype(Image.Fro mFile(inputFile Name, Bitmap)
Dim ico as Icon = Icon.FromHandle (bmp.GetHicon() )
Dim file as FileStream = new FileStream(outp utFileName,
FileMode.OpenOr Create)
ico.Save(file)
file.Close()
ico.Dispose();

Please note, that this is untested code, so I don't know if it will work.

Michel van den Berg

"Jason Barnett" <jw*@wbai.com > schreef in bericht
news:Ou******** **********@tk2m sftngp13.phx.gb l...
I'm able to save the image with an .ico extension, however I don't think
it's in the correct .ico format. When I attempt to load it as an Icon
object, I receive an ArgumentExcepti on (with the message, "Argument
'picture' must be a picture that can be used as a Icon."). I'm able to
browse to the file and open it with "Windows Picture and Fax Viewer", but
the image does not appear as the icon for the file when I look at it in
Windows Explorer.

Here's a more detailed example of my code:

Dim icoFile As String = "C:\output. ico"

Dim img As Image = Image.FromFile( "C:\doc01.g if")
img.Save(icoFil e, ImageFormat.Ico n)

Dim icon As New Icon(icoFile)
Me.Icon = icon
"Michel van den Berg" <mv*@promontis. nl> wrote in message
news:eb******** ******@TK2MSFTN GP09.phx.gbl...
Dear Jason Barnett,

Why aren't you able to assign the image as a form icon? Does it produce
an error, or aren't you able to browse to it? Could you specify your
problem a bit more?

Michel van den Berg

"Jason Barnett" <jw*@wbai.com > schreef in bericht
news:O%******** *******@TK2MSFT NGP09.phx.gbl.. .
When trying to save an image as an icon, I've used the following line of
code (img is an System.Drawing. Image)...

img.Save("C:\ou tput.ico", ImageFormat.Ico n)

The files saves without an error, and it can be opened by Windows
Picture and Fax Viewer, but I cannot assign the image as a form icon.
Does anyone know what I can do to get this to work?



Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
12013
by: Alper Adatoz | last post by:
Hi, i have a little problem. i hope u guys give me a clear solution (: db: mssql i just want to put jpeg file to the image field at the mssql db. and after that i want to call it back..
5
2373
by: Kevin | last post by:
Hi all, Assuming I have stored the binary data of an image file in a blob field of a table, how can I display it as an image in a web page? I found some instructions on the web, such as header('application/octet-stream'); echo $imgdata; I don't know why I always get this warning.
0
1659
by: Umesh | last post by:
Hi, I have an Application, in which 1) need to post data to a URL(Remote Server), by using HTTPRequest. 2) get the Image data in the form of Stream in Response. 3) need to save this stream as a Image file on the local machine. Giving some code snippet below. RequestAPI = CType(WebRequest.Create(URLName), HttpWebRequest)
1
6890
by: Dev | last post by:
Dear Friends, I am passing the image name, size (in bytes) and imgaeformat (like jpg or bmp or pdf) through the network. I want display the image into picturebox without saving image files into Hard disk. Just display the image into PictureBox.... Is it Possible? If so how do to this?
4
2122
by: | last post by:
I cant seem to find the commmand that I can use to save an image file from a url to my local harddrive. I am looking to save a jpg from a webpage that I have screen scraped. I have a web application that uses readHtmlPage(url.ToString()); to read the page in, I am able to use regular expressions to save to url of the jpg to a string...
1
1477
by: rohith | last post by:
Hope someone can help with this question. I have a digital camera that will be used to capture photographs for picture ids. My question is whether I can capture the image from a web page (aspx)and save it to a database without first saving the file on to the harddisk. If anyone can point me in the right direction on where I can find out...
2
339
by: Marc Pelletier | last post by:
Hello all, I have a class which includes a method to create a chart. I want to be able to call this method from asp.net code as well as windows application code, so I have sketched it out as returning a bitmap instance. In my asp.net code I think I should call this method to return a bitmap and then somehow stream it using the response...
0
1991
by: aris1234 | last post by:
hello.. How to upload image file in page update ..?? i have logic like this : if user upload new image then old image must delete and update DB used new name if user not upload new image then old image no delete. code form like this (i dontknow this code right or wrong, please correction if wrong) :
0
1421
by: Waqas.L.Khan | last post by:
Hi guys, I have a problem when trying to create an image file. Basically my code takes any file and gets it's system icon using SHGetFileInfo and then saves the file either by converting it into a bmp and saving to disk or by saving the icon using a filestream. In both cases saving the file works fine. However, when I open the newly created...
1
2134
by: Sinan Alkan | last post by:
Hi All, I have a method to resize any image file to the specific dimensions and save this new image to a path. I found it on a web page(By Joel Neubeck) and i changed it for my project. The code is as follows; --------------------------------- // usings part using System.Drawing; using System.Drawing.Imaging;
0
7701
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.