Icon Chalange

K

K

Dim img As New Bitmap(PictureBox1.Image, 32, 32)
img.Save(RichTextBox2.Text & "\" & RichTextBox3.Text & ".ico",
System.Drawing.Imaging.ImageFormat.Bmp)
MsgBox("Image has been converted", MsgBoxStyle.Information, "Done!")

Hi all, I am using Visual Basic 2008. The above code saves
PictureBox1 image into 32 x 32 icon file. The only problem I am facing
that when I chose this icon file from the Properties of my Form as for
Form icon in Visual Basic 2008 I get error message saying "Argument
'picture' must be a picture that can be used as a Icon". If I use same
icon file from the Properties of Active X Control Button which is on
excel Sheet then it works fine. I think if a icon file which can work
on Visual Basic Form and as well as on Active X Control Button on an
excel Sheet is the perfect icon. i tried different methods by
searching on internet to create perfect 16 x 16 or 32 x 32 icon files
which have no lost of colour or quality but only whith above code i
get near to what i want to achive. But i cant use it for my Visual
Basic application Form. I have created icon with below code which
works everywhere but with below code you lose the quality and colors
of the icon. I also studied "IconLib" example which you can find on
internet but its to much for me. So i am kind of stuck. Is there any
friend out there to help me out with some code.

Dim pth As String = "C:\Document\test.gif"
Dim img As New Bitmap(pth)
Dim grh As Graphics = Graphics.FromImage(img)
grh.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic
grh.DrawImage(img, 0, 0)
Dim Hicon As IntPtr = img.GetHicon
Dim newicon As Icon = System.Drawing.Icon.FromHandle(Hicon)
Dim fpth As New IO.FileStream("C\Document\test.ico",
IO.FileMode.Create)
newicon.Save(fpth)
newicon.Dispose()
MsgBox("Image has been converted", MsgBoxStyle.Information, "Done!")
 
G

GS

K wrote :
Dim img As New Bitmap(PictureBox1.Image, 32, 32)
img.Save(RichTextBox2.Text & "\" & RichTextBox3.Text & ".ico",
System.Drawing.Imaging.ImageFormat.Bmp)
MsgBox("Image has been converted", MsgBoxStyle.Information, "Done!")

Hi all, I am using Visual Basic 2008. The above code saves
PictureBox1 image into 32 x 32 icon file. The only problem I am facing
that when I chose this icon file from the Properties of my Form as for
Form icon in Visual Basic 2008 I get error message saying "Argument
'picture' must be a picture that can be used as a Icon". If I use same
icon file from the Properties of Active X Control Button which is on
excel Sheet then it works fine. I think if a icon file which can work
on Visual Basic Form and as well as on Active X Control Button on an
excel Sheet is the perfect icon. i tried different methods by
searching on internet to create perfect 16 x 16 or 32 x 32 icon files
which have no lost of colour or quality but only whith above code i
get near to what i want to achive. But i cant use it for my Visual
Basic application Form. I have created icon with below code which
works everywhere but with below code you lose the quality and colors
of the icon. I also studied "IconLib" example which you can find on
internet but its to much for me. So i am kind of stuck. Is there any
friend out there to help me out with some code.

Dim pth As String = "C:\Document\test.gif"
Dim img As New Bitmap(pth)
Dim grh As Graphics = Graphics.FromImage(img)
grh.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic
grh.DrawImage(img, 0, 0)
Dim Hicon As IntPtr = img.GetHicon
Dim newicon As Icon = System.Drawing.Icon.FromHandle(Hicon)
Dim fpth As New IO.FileStream("C\Document\test.ico",
IO.FileMode.Create)
newicon.Save(fpth)
newicon.Dispose()
MsgBox("Image has been converted", MsgBoxStyle.Information, "Done!")

Changing the file extension to ".ico" doesn't make the BMP a valid
icon. You need a converter to convert images to icons.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top