Results 1 to 3 of 3

Thread: can you help me with image resize?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2004
    Posts
    169

    can you help me with image resize?

    say my original picture is at:
    c:\dir1\viewsky.jpg

    how to resize the picture proportionaly(so it won't distorted) and save it to another directory but with the same file name
    c:\thumbnails\viewsky.jpg

    Is this doable in visual basic? any sample code to get me started with will be much helpful.
    thank you

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: can you help me with image resize?

    Without any third party's tool you won't have much choices ...
    Here a quick sample or resizing ordinary picturebox - it will work ok to a certain extent.
    Another way is to use Image control with Stretch = True.
    Code:
    Public Sub ZoomPicture(pct As PictureBox, zoom As Double)
        With pct
            .AutoRedraw = True
            .Width = .Width * zoom
            .Height = .Height * zoom
            .PaintPicture .Picture, 0, 0, .ScaleWidth, .ScaleHeight
            .Refresh
        End With
    End Sub
    To save it back to JPG you won't be able from VB - BMP is the only type supported.
    There is Funciton SavePicture().

  3. #3
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: can you help me with image resize?

    It's impossible to stretch a raster (bitmap) image without it being distorted a little, or a lot in some cases...

    If you want to create images that won't be distorted when resized, you would have to use vector images. VB doesn't directly support vector graphics so you would have to write the code for that yourself.

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