Results 1 to 5 of 5

Thread: Anyone know how to resize and save JPGs in VB?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Norway
    Posts
    88

    Question

    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

  2. #2
    Addicted Member
    Join Date
    Aug 2000
    Location
    Croatia
    Posts
    200
    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 from vbAccelerator (click on the "Media" category).

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Norway
    Posts
    88

    Ok, but how to use painpicture?

    I'm not really sure how to use paintpicture, do you think
    you could help me out with that too? Thanks a lot

    -Zen

  4. #4
    Addicted Member
    Join Date
    Aug 2000
    Location
    Croatia
    Posts
    200
    Ok... put a PictureBox control on the form and load a picture in it. Leave the names as they are.

    Code:
    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.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Norway
    Posts
    88

    Question

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width