Click to See Complete Forum and Search --> : expanding/zooming in on picture


shadowdemon
October 6th, 2001, 02:01 PM
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.??

thebernieb
October 9th, 2001, 03:36 PM
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