Click to See Complete Forum and Search --> : Resizing Bitmaps


Nemzer
January 26th, 2003, 08:55 AM
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

Athley
January 27th, 2003, 01:03 AM
Try the pb.Image.Save method.

/Leyan

Nemzer
January 27th, 2003, 01:23 PM
OK so I did but the saved image from picturebox.image.save has the original size and not the "screen size". . .

DdH
January 27th, 2003, 04:27 PM
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()

Nemzer
January 28th, 2003, 01:02 PM
DdH,

The code works fine.

Thanks,

Leon