Convert Image to a VALID icon
I need help converting an image to a valid icon.
I can save the image as an Icon, no problem. BUT, when I try to use this Icon for it's intended purpose (just as either a project icon, or shortcut icon) .. an error appears telling me it is not a valid icon.
Code:
Dim bmp As New Bitmap(Path & shortLabel & "\" & imgName)
bmp.Save(Path & shortLabel & "\newIco.ico", System.Drawing.Imaging.ImageFormat.Icon)
Any solutions? Ideally without needing extra DLLs that would have to be included with my project, but if that's what it requires then so be it.
Thanks for your time.
Re: Convert Image to a VALID icon
What is the line where you are trying to use it?
Re: Convert Image to a VALID icon
No line, but manual.
So once this program has ran and created the said Icon, I'm going into a different project in VS, and setting the projects icon within the project properties screen.
Re: Convert Image to a VALID icon
try something like
Code:
Dim xxx As New Bitmap(Path & shortLabel & "\" & imgName)
Using ico As Icon = Icon.FromHandle(xxx.GetHicon())
Using icoFile As System.IO.FileStream = New System.IO.FileStream(Path & shortLabel & "\newIco.ico", System.IO.FileMode.OpenOrCreate)
ico.Save(icoFile)
End Using
End Using
Re: Convert Image to a VALID icon
or use Imports System.IO and simplify the code
Code:
Dim bmp As New Bitmap(Path & shortLabel & "\" & imgName)
Using ico As Icon = Icon.FromHandle(bmp.GetHicon())
Using icoFile As FileStream = New FileStream(Path & shortLabel & "\newIco.ico", FileMode.OpenOrCreate)
ico.Save(icoFile)
End Using
End Using
Re: Convert Image to a VALID icon
Still doesn't work... I can't figure out why, I've been trying various methods I've found laying around on the internet.... I'm puzzled! :confused:
Re: Convert Image to a VALID icon
I may of found a work around using an external application and command line.... Thank's for your help kaliman79912, I'll look further into my problem when I have time.