Results 1 to 4 of 4

Thread: Picturebox image zoom + moving function

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    68

    Picturebox image zoom + moving function

    Hello,

    I would like to fit an image in a picturebox but without strechting it like :

    VB Code:
    1. "PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage"

    Just a zoom where the full picture is displayed like in IE6.


    Second thing I try to do is to allow user to move the picture inside the picturebox when the original picture is bigger than the picturebox.


    Thanks

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Its easy to fit a picture inside a picturebox... without stretching. The problem is that making the picture appear normal requires a design decision on your part...

    Since an image may have dimensions of 450 x 200, but your picturebox may be 600 X100 (extreme example), you can't simply assign it, or you lose the proportions of the original image's height and width. In an image of 450 x 200, you have a proportion of 2.25 : 1. While your picturebox has a proportion of 6:1. That's a problem.

    So, do you want to expand your picturebox dimensions to fit the image? Or do you scale in/out the image to fit the dimensions of the picturebox?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    68
    I would like to scale a copy of the picture into the picturebox.

    That's the picture who should be resized, not the piturebox.

    Original image is keep to be saved later.


    Thanks

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    68

    Talking The solution for the Zoom

    VB Code:
    1. Dim Width As Integer
    2.         Dim Height As Integer
    3.         Dim Ratio As Decimal
    4.  
    5.         If PictureBox1.Tag > -1 And Not PictureBox1.Tag Is Nothing Then
    6.  
    7.             If RadioButton1.Checked = True Then              'Option Zoom 100%
    8.                 Height = PictureArray(PictureBox1.Tag).Height
    9.                 Width = PictureArray(PictureBox1.Tag).Width
    10.             Else
    11. ' Option Zoom Fit Image in Picturebox
    12.                 Ratio = PictureArray(PictureBox1.Tag).width / PictureArray(PictureBox1.Tag).height
    13.                 If Ratio < (PictureBox1.Width / PictureBox1.Height) Then
    14.                     Height = PictureBox1.Height
    15.                     Width = PictureBox1.Width * Ratio
    16.                 Else
    17.                     Height = PictureBox1.Height / Ratio
    18.                     Width = PictureBox1.Width
    19.                 End If
    20.  
    21.             End If
    22.             PictureBox1.Image = PictureArray(PictureBox1.Tag).GetThumbnailImage(Width, Height, Nothing, Nothing)
    23.         End If


    Does anyone know How can I move the Image if it is bigger than the picturebox ??? (scrollbar or mouse event)



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