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.
 

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

Similar Threads

Creating icons 1
Icon Chalange 2
Bitmap.GetHIcon leaking GDI resources? 2
call sub with e 6
System icons in Listview 6
image and notifyicon problem 2
VB code help 3
Put icon into Picturebox 6

Back
Top