Save Icon in different sizes

  • Thread starter Thread starter K
  • Start date Start date
K

K

Hi all, I am using Visual Basic 2008. I have Visual Basic code (see
below) which changes the Form icon image with PictureBox image. My
question is that what code line I should use in code below that I can
save this icon on a path in different sizes like 16 x 16 or 32 x 32
etc. Please can any friend can help

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim img As New Bitmap(PictureBox1.Image)
Dim g As Graphics = Graphics.FromImage(img)
g.DrawImage(img, 0, 0)
Dim Hicon As IntPtr = img.GetHicon
Dim newicon As Icon = System.Drawing.Icon.FromHandle(Hicon)
Me.Icon = newicon
DestroyIcon(newicon.Handle)
End Sub
 
Dim img1 As New Bitmap(16, 16, Imaging.PixelFormat.Format32bppArgb)
Dim g As Graphics = Graphics.FromImage(img1)
g.DrawImage(img, New Rectangle(0, 0, 16, 16), New Rectangle(0, 0,
img.Width, img.Height), GraphicsUnit.Pixel)
img1 = New Bitmap(32,32, Imaging.PixelFormat.Format32bppArgb)
Dim g As Graphics = Graphics.FromImage(img1)
g.DrawImage(img, New Rextangle(0, 0, 32, 32), New Rectangle(0, 0,
img.Width, img.Height), GraphicsUnit.Pixel)
 
Hi James, Thanks for replying. You didnt mention in your code that
where to get image from as in my code i am getting it from PictureBox.
 
Back
Top