K
K
Hi all, I am creating an application on Visual Basic 2008 to convert
any image into icon. I have written code (see below) which works
fine. It converts any image to icon in specified size. But the
problem is that when I try to use that icon I get error message
saying "invalid image property" or "invalid image" etc. Please can
any friend tell me that what amendments i need in my code below to
achive my objective. help in shape of code will be much appriciated.
Dim imageFinal As System.Drawing.Image = Nothing
Dim g As System.Drawing.Graphics = Nothing
imageFinal = New System.Drawing.Bitmap(64, 64)
g = System.Drawing.Graphics.FromImage(imageFinal)
Dim destRect As New System.Drawing.Rectangle(0, 0, 64, 64)
Dim srcRect As New System.Drawing.Rectangle(0, 0,
PictureBox1.Image.Width, PictureBox1.Image.Height)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(PictureBox1.Image, destRect, srcRect,
System.Drawing.GraphicsUnit.Pixel)
imageFinal.Save(RichTextBox2.Text & "\" & RichTextBox3.Text & ".ico",
System.Drawing.Imaging.ImageFormat.Icon)
MsgBox("Image has been converted", MsgBoxStyle.Information, "Done!")
any image into icon. I have written code (see below) which works
fine. It converts any image to icon in specified size. But the
problem is that when I try to use that icon I get error message
saying "invalid image property" or "invalid image" etc. Please can
any friend tell me that what amendments i need in my code below to
achive my objective. help in shape of code will be much appriciated.
Dim imageFinal As System.Drawing.Image = Nothing
Dim g As System.Drawing.Graphics = Nothing
imageFinal = New System.Drawing.Bitmap(64, 64)
g = System.Drawing.Graphics.FromImage(imageFinal)
Dim destRect As New System.Drawing.Rectangle(0, 0, 64, 64)
Dim srcRect As New System.Drawing.Rectangle(0, 0,
PictureBox1.Image.Width, PictureBox1.Image.Height)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(PictureBox1.Image, destRect, srcRect,
System.Drawing.GraphicsUnit.Pixel)
imageFinal.Save(RichTextBox2.Text & "\" & RichTextBox3.Text & ".ico",
System.Drawing.Imaging.ImageFormat.Icon)
MsgBox("Image has been converted", MsgBoxStyle.Information, "Done!")