CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2003
    Location
    Netherlands
    Posts
    3

    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

  2. #2
    Join Date
    Oct 2002
    Location
    Växjö, Sweden
    Posts
    225
    Try the pb.Image.Save method.

    /Leyan

  3. #3
    Join Date
    Jan 2003
    Location
    Netherlands
    Posts
    3

    Unhappy

    OK so I did but the saved image from picturebox.image.save has the original size and not the "screen size". . .
    Greetz,

    Leon

  4. #4
    Join Date
    Jan 2003
    Location
    Amsterdam, Netherlands
    Posts
    97
    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()

  5. #5
    Join Date
    Jan 2003
    Location
    Netherlands
    Posts
    3
    DdH,

    The code works fine.

    Thanks,

    Leon

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

Featured