sprintfoot
Nov 26th, 1999, 04:24 AM
Do you have any idea how i could go about zooming in on a picture box? Im currently using the paintpicture method except it causes me a problem. I need to draw on the zoomed picture (im using the line command) , but when i zoom out (redraw it with paintpicture) it erases the lines i drew. I only have one month of programming under my belt and am confused. If you know an answer i would appreciate it. Sprintfoot@aol.com
Aaron Young
Nov 26th, 1999, 01:54 PM
This is only a very basic example, but I think it demonstrates the functionality you're looking for:
Add 2 Pictureboxes to a Form and Load a Picture into Picture1..
Private Sub Form_Load()
Picture1.AutoRedraw = True
Picture2.AutoRedraw = True
Picture2.Visible = False
Picture1.ScaleMode = vbPixels
Picture2.ScaleMode = vbPixels
Picture2.Move 0, 0, Picture1.Width, Picture2.Height
Picture1.MousePointer = vbCrosshair
End Sub
Private Sub Command1_Click()
Static bZoom As Boolean
bZoom = Not bZoom
If bZoom Then
'Zoom in 10x on Top Left of Image
With Picture1
Picture2 = Picture1
.PaintPicture .Picture, 0, 0, .ScaleWidth, .ScaleHeight, 0, 0, .ScaleWidth / 10, .ScaleHeight / 10
Picture1 = .Image
End With
Else
'Zoom Back out to 100%
Picture1 = Picture2.Image
End If
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
'Draw on Normal Sized Picture
Picture2.PSet (X / 10, Y / 10)
With Picture1
'Recopy Zoomed Image to Give Illusion of Drawing on Zoomed Image..
.PaintPicture Picture2.Image, 0, 0, .ScaleWidth, .ScaleHeight, 0, 0, .ScaleWidth / 10, .ScaleHeight / 10
End With
End If
End Sub
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net