change mouse move to:
VB Code:
Private Sub picDraw_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picDraw.MouseMove If shouldpaint Then Dim graphic As Graphics = createGraphicsEx(picDraw) graphic.FillEllipse(New SolidBrush(_BrushColor), e.X, e.Y, _BrushSize, _BrushSize) graphic.Dispose() picDraw.Invalidate() End If End Sub
createGraphicsEx is a function I wrote:
basically the only thing different is that instead of saying picbox.creategraphics, you are calling graphics.fromimage. That's all. I just made that a function so that you could use it again if you want. Also you shouldnt be drawing this with an ellipse. You should save the mouse position on each mousemove event and then draw a line from the last mouse position to the current mouse position.VB Code:
' Returns a Graphics object to be used for drawing on the picturebox Private Function createGraphicsEx(ByVal picbox As PictureBox) As Graphics ' If the picturebox's image is nothing, create a bitmap the same size as ' the picturebox If picbox.Image Is Nothing Then picbox.Image = New Bitmap(picbox.ClientSize.Width, picbox.ClientSize.Height) Dim gr As Graphics = Graphics.FromImage(picbox.Image) gr.Clear(picbox.BackColor) Return gr Else Return Graphics.FromImage(picbox.Image) End If End Function
You can save the picture now, and it wont disappear again![]()




Reply With Quote