Question Faster Paint Software

Joined
Sep 15, 2011
Messages
17
Programming Experience
3-5
Hello forum,

I have created a paint program, which I use with a SmartBoard to draw on.
But when I draw, it reacts much slower than a usual Paint Program (MSPaint).

I have a PictureBox which I draw on,to capture the mouse path.
Every time the mouse is moved, the path is added to the "mousePath" variable.

Then I use PictureBox.Refresh() to re-paint the PictureBox, and draw the mousePath.
Is there any way I can get a better reaction, and draw the path faster, than I do now?
It's almost 2 times slower than usual Paint? Maybe use DirectX or XNA?

Please help!
 
Now that you have a minimum amount of graphics operations, which is also limited to only the current drawing shapes bounds, try to remove the timer and call UpdateCurrent from MouseMove.
For the record I measured at most 16ms average updates with the timer with that code, that translates to 60 fps, and 8ms average (125 fps) with direct updating each move event.

Also bear in mind, a release build not hosted in debugger will generally execute faster.

By the way, example was updated with a bug-fix, MouseMove and MouseUp now checks for the 'current' object reference instead of left mouse button.
 
So, I have been working a bit on some code, and I came up with the idea to "predict" the users movement direction.
So I would first have to determine the direction of the mouse, and then add some pixels to the direction.

My code is kinda working, but not exactly:

VB.NET:
Sub AddPath(ByVal LastPoint As PointF, ByVal CurrentLocation As Point)        'Get direction
        Dim xloc As Integer = 0
        Dim yloc As Integer = 0
        Dim intMultiplier = 20


        If System.Math.Abs(LastPoint.X - CurrentLocation.X) > System.Math.Abs(LastPoint.Y - CurrentLocation.Y) Then
            'Change in X is greater, now find Left or Right
            If (LastPoint.X - CurrentLocation.X) < 0 Then
                lblAbout.Text = "Right"
                xloc = -(intMultiplier)
            Else
                lblAbout.Text = "Left"
                xloc = intMultiplier
            End If
        Else
            'Change in Y is greater, now find Up or Down
            If (LastPoint.Y - CurrentLocation.Y) < 0 Then
                lblAbout.Text = "Down"
                yloc = -(intMultiplier)
            Else
                lblAbout.Text = "Up"
                yloc = intMultiplier
            End If
        End If


        mousePath.AddLine(mousePath.GetLastPoint.X, mousePath.GetLastPoint.Y, CurrentLocation.X - xloc, CurrentLocation.Y - yloc)
    End Sub

Am I doing something wrong, or is there maybe a better way of doing this?
(I'll keep trying!)

PS. See the attachment! :)
screen222.png
 
Back
Top