-
Resizing Bitmaps
I'm making my first steps in vb.net and I'm trying to resize a bitmap.
I want to make an app that processes a folder with images to a new folder of images of the same size with a thumbnail version for web publication.
Opening an image and changing the size of the image in a form is easy (making use of the picturebox) but how can I save the resized image?
Thanks,
Leon
-
Try the pb.Image.Save method.
/Leyan
-
OK so I did but the saved image from picturebox.image.save has the original size and not the "screen size". . .
-
To resize a picture you don't need a picturebox.
Try the follow code example:
Dim Scale As Double
Dim NewWidth As Integer
Dim p1 As New System.Drawing.Bitmap("picture.jpg")
Scale = p1.Height / p1.Width
NewWidth = 200
Dim p2 As New System.Drawing.Bitmap(p1, NewWidth, CType(NewWidth * Scale, Integer))
p2.Save("new picture.jpg")
p1.Dispose()
p2.Dispose()
-
DdH,
The code works fine.
Thanks,
Leon