Click to See Complete Forum and Search --> : Anyone know how to resize and save JPGs in VB?
ZenMan
Mar 4th, 2001, 05:34 PM
Hey, I was wondering if anyone out there could show
me a way to resize a .jpg picture and then save it as
a .jpg again. To make thumbnails and such. Any help
would be greatly appreciated.
-Zen
Arcom
Mar 4th, 2001, 06:00 PM
You can easily resize the picture using the PaintPicture method. Just pass the selected values for the Width and Height parameters. As for saving a picture to JPG, use this code (www.vbaccelerator.com) from vbAccelerator (click on the "Media" category).
ZenMan
Mar 4th, 2001, 06:20 PM
I'm not really sure how to use paintpicture, do you think
you could help me out with that too? Thanks a lot :)
-Zen
Arcom
Mar 4th, 2001, 06:39 PM
Ok... put a PictureBox control on the form and load a picture in it. Leave the names as they are.
Private Sub Form_Load()
Picture1.Visible = False
' Set the desired width and height
Picture1.Width = 1440
Picture1.Height = 780
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) = vbLeftButton Then
Me.Cls
Me.PaintPicture Picture1.Picture, X, Y, Picture1.Width, Picture1.Height
ElseIf (Button And vbRightButton) = vbRightButton Then
Me.Cls
Me.PaintPicture Picture1.Picture, X, Y
End If
End Sub
When you click a form with the left mouse button, the picture will be displayed like a thumbnail and when you click with the right mouse button, it will be displayed in full-size.
ZenMan
Mar 4th, 2001, 07:26 PM
Ok, I tried that and it worked well. But now how do I
save this? I see what happens is that it just resizes the
picturebox and doesn't resize the picture IN the
picturebox. It makes a new image that has nothing to
do with the picturebox, right? Now if I wanted to save
this what would I have to do (using the vbAccelerator
code you showed me). If it had been resized inside the
picturebox I could just saved the result from it, but now
I don't really know what to do.
I'm sorry if I'm asking to many questions, but I am kinda
newbie here so :) Thanks for the help so far though!
-Zen
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.