CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2001
    Posts
    4

    expanding/zooming in on picture

    can anyone help. i am using "loadpicture" to inport picture files into a picture box. Is ther an easy way to zoom in on the picture.??


  2. #2
    Join Date
    Oct 2001
    Posts
    4

    Re: expanding/zooming in on picture

    Easy Money.

    Just drop this code into a form with an image1 and it should work out. Its already commented so you should be able to follow.

    Hope that helps,

    Bernie

    Private Sub Image1_Click()
    Dim intImageTopStart As Integer
    Dim intImageLeftStart As Integer
    Dim intZoomLevel As Integer

    'Set the level of the zoom.
    'Setting it to 2 doubles the size..
    '3 triples the size.. and so fourth
    intZoomLevel = 2

    'Find the initial top and left values so we can center the image
    'after resizing

    intImageTopStart = Image1.Top
    intImageLeftStart = Image1.Left

    'Set the value of stretch to true so when the image size is
    'increased the photo will grow with it.
    Image1.Stretch = True

    'Increase the width and height by multiplying them by zoom level.
    Image1.Width = Image1.Width * intZoomLevel ' Zoom Level (I used twice its size)
    Image1.Height = Image1.Height * intZoomLevel 'Zoom Level (I used twice its size)

    'Center the picture using the inital top and left values values
    Image1.Top = intImageTopStart - (Int(Image1.Height / 4))
    Image1.Left = intImageLeftStart - (Int(Image1.Width / 4))
    Image1.Refresh

    End Sub


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