How can one select a portion of a picture, say with a mouse click and have an arbitrary small x,y area surrounding that mouse click painted on a second picturebox?
I also would like that transfered area magnified.
Thanks for any help
Using the mouse down event with the X and Y parameters will give you the location of the mouse click, so all's you would need to do is do a minus and a plus of that position to get your region. Then you could use the BitBlt and StretchBlt API's to get the rest of the functionality you are looking for.
Dim iX As Integer, iY As Integer
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
iX = X
iY = Y
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Picture1.Refresh
Picture1.Line (iX, iY)-(X, Y), , B
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Dim X1 As Integer, X2 As Integer, Magnification As Single
Magnification = 2
Picture1.Refresh
Picture2.Cls
Picture2.PaintPicture Picture1.Image, 0, 0, (X - iX) * Magnification, (Y - iY) * Magnification, iX, iY, X - iX, Y - iY, vbSrcCopy
End If
End Sub
Hypetia,
I've been working with your suggested program and making some (learning) progress. But the program is not working just yet.
What are X1 and X2 supposed to do?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.