I'm drawing onto a PictureBox, using the code
Dim XPrev, YPrev, XCur, YCur As Integer
Private Sub picCanvas_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picCanvas.MouseDown
'Setting the previous points for line drawing
XPrev = e.X
YPrev = e.Y
End Sub
Private Sub picCanvas_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picCanvas.MouseUp
'Setting the current points for line drawing
XCur = e.X
YCur = e.Y
'Graphics Variables
Dim p As New Pen(Color.Red, 10)
Dim g As Graphics = picCanvas.CreateGraphics
g.DrawLine(p, XPrev, YPrev, XCur, YCur)
End Sub
Although i have no idea how to save this. I've tried picCanvas.Image.Save("C:\img.png", Imaging.ImageFormat.Png)
, but i get a null reference exception.
any help would be appreciated,
Thanks