Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Painting a portion of a picture to another picturebox 2

Status
Not open for further replies.

domt

Programmer
Mar 13, 2001
115
US
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.

Good Luck

 
Use the PaintPicture method.
___

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
 
Thanks for your help.
Much appreciated.
 
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?
 
They are doing nothing. I just declared them initially but didn't use them so you may remove them safely.[smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top