Help - Graphics to Image
Posted: Sat Jul 21, 2012 4:19 pm
Hello i am using this simple code to paint on Picturebox1.creategraphics
Code: Select all
And i wanted to know how to convert this so that it is on picturebox1.imagePrivate Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
'If the left mouse button is down the set IsThePenDown to TRUE
If e.Button = Windows.Forms.MouseButtons.Left Then
IsThePenDown = True
'Set the Point to start drawing from.>>
MouseDownPoint = New Point(e.X, e.Y)
End If
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
'A STATIC variable holds or remebers the previous value.>>
Static LastPoint As New Point
If IsThePenDown = True Then
'Draw a line from the LastPoint.>>
PictureBox1.CreateGraphics.DrawLine(MyPen, LastPoint.X, LastPoint.Y, e.X, e.Y)
End If
'Set the LastPoint to the previous point.>>
LastPoint = New Point(e.X, e.Y)
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
'Set to FALSE on the MouseUp event.>>
IsThePenDown = False
End Sub