CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: stretch image

  1. #1
    Join Date
    May 1999
    Posts
    34

    stretch image

    How to stretch a image in VB?


  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: stretch image

    If you're lloking for a visual effect, you can use imagebox and set the stretch property to true.
    If you're looking for a permanet zoom effect (= rewriting the image file as bigger or smaller), then wait for Shree help or have a search (look at Forum Index|FAq|Profile|...|Search|...) for "resize" or "zoom" or "stretch"

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: stretch image

    In reply to:

    wait for Shree help




    Nice tip, he's the man

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: stretch image


    Unless your image is a metafile, the picture box doesn't allow stretching.
    You can use the Image control which has a stretch property, or use two pictureboxes.

    Here's How to stretch an image:


    Dim ViewLft as Integer, ViewTop as Integer
    Dim ViewWid as Integer, ViewHgt as Integer
    Dim Zoom as Single

    private Sub ComputeDim()
    ViewWid = picView.Width / Zoom
    ViewHgt = picView.Height / Zoom
    If ViewWid > picImage.Width then ViewWid = picImage.Width
    If ViewHgt > picImage.Height then ViewHgt = picImage.Height
    End Sub

    private Sub ShowImage()
    picView.Cls
    picView.PaintPicture picImage.Image, 0, 0, ViewWid * Zoom, ViewHgt * Zoom, ViewLft, ViewTop, ViewWid, ViewHgt
    End Sub

    private Sub Form_Load()
    ViewLft = 0
    ViewTop = 0
    Zoom = 1
    ComputeDim
    ShowImage
    End Sub

    private Sub picView_MouseDown(Button as Integer, Shift as Integer, X as Single, Y as Single)
    If Button = vbLeftButton then
    Zoom = Zoom + 0.5
    else
    Zoom = Zoom - 0.5
    End If
    If Zoom < 0.5 then Zoom = 0.5
    ComputeDim
    ShowImage
    End Sub


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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