Hi All,

I am trying to develop an Eraser tool for a ImageEditor kind of application
on Pocket PC. I can perform the erasing using a DrawImage method of Graphics
for the PictureBox.

The only problem is when user moves the stylus very fast on the screen the
Mouse_Move event misses every e.x and e.y (GraphicsPath) and then it looks
like some part of the image doesn't get cleared.

If you find any solution of this problem please inform me.

Here is the code of MouseMove event...

Private Sub pctMain_MouseMove(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles pctMain.MouseMove
If bolClear Then
rectTemp.X = e.X
rectTemp.Y = e.Y
gr.DrawImage(Savedbmp, e.X, e.Y, rectTemp, GraphicsUnit.Pixel)
pctMain.Image = Nothing
pctMain.Image = bmp
LastPos.X = e.X
LastPos.Y = e.Y
Else
gr.DrawLine(pn, e.X, e.Y, LastPos.X, LastPos.Y)
pctMain.Image = Nothing
pctMain.Image = bmp
LastPos.X = e.X
LastPos.Y = e.Y
End If
End Sub

Re: Eraser tool for PPC by Alex

Alex
Mon Oct 10 17:23:13 CDT 2005

You need to implement an intelligent interpolation algorithm for those
points you might have missed

"AmitSeth" <AmitSeth@discussions.microsoft.com> wrote in message
news:2BDE1B46-0234-496E-8114-EED3DD4AE293@microsoft.com...
> Hi All,
>
> I am trying to develop an Eraser tool for a ImageEditor kind of
> application
> on Pocket PC. I can perform the erasing using a DrawImage method of
> Graphics
> for the PictureBox.
>
> The only problem is when user moves the stylus very fast on the screen the
> Mouse_Move event misses every e.x and e.y (GraphicsPath) and then it looks
> like some part of the image doesn't get cleared.
>
> If you find any solution of this problem please inform me.
>
> Here is the code of MouseMove event...
>
> Private Sub pctMain_MouseMove(ByVal sender As System.Object, ByVal e As
> System.Windows.Forms.MouseEventArgs) Handles pctMain.MouseMove
> If bolClear Then
> rectTemp.X = e.X
> rectTemp.Y = e.Y
> gr.DrawImage(Savedbmp, e.X, e.Y, rectTemp, GraphicsUnit.Pixel)
> pctMain.Image = Nothing
> pctMain.Image = bmp
> LastPos.X = e.X
> LastPos.Y = e.Y
> Else
> gr.DrawLine(pn, e.X, e.Y, LastPos.X, LastPos.Y)
> pctMain.Image = Nothing
> pctMain.Image = bmp
> LastPos.X = e.X
> LastPos.Y = e.Y
> End If
> End Sub
>


Re: Eraser tool for PPC by AmitSeth

AmitSeth
Tue Oct 11 05:00:04 CDT 2005

Oh Yeah,

I have used the Bresenhams Line Drawing Algo and it really worked fine. So
now I have a thick pen for PPC also, but the only problem is it is little
slow while drawing, like many other Picture editor tools.Can I make it little
faster? The code I used is :

'Changing the Width and Height of rectTemp makes the pen thick.

Private Sub pctMain_MouseMove(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles pctMain.MouseMove
Me.line(LastPos.X, e.X, LastPos.Y, e.Y)
LastPos.X = e.X
LastPos.Y = e.Y
pctMain.Invalidate()
End Sub

Private Sub line(ByVal x0 As Integer, ByVal x1 As Integer, ByVal y0 As
Integer, ByVal y1 As Integer)
Dim steep As Boolean = Math.Abs(y1 - y0) > Math.Abs(x1 - x0)
Dim xstep, ystep As Integer
If steep Then
swap(x0, y0)
swap(x1, y1)
End If
Dim deltax As Integer = Abs(x1 - x0)
Dim deltay As Integer = Abs(y1 - y0)
Dim err1 As Integer = 0
Dim deltaerr As Integer = deltay
Dim x As Integer = x0
Dim y As Integer = y0
If x0 < x1 Then
xstep = 1
Else
xstep = -1
End If
If y0 < y1 Then
ystep = 1
Else
ystep = -1
End If
If steep Then
Plot(y, x)
Else
Plot(x, y)
End If
While x <> x1
x = x + xstep
err1 = err1 + deltaerr
If 2 * err1 > deltax Then
y = y + ystep
err1 = err1 - deltax
End If
If steep Then
Plot(y, x)
Else
Plot(x, y)
End If
End While
End Sub

Private Sub Plot(ByVal X As Integer, ByVal Y As Integer)
rectTemp.X = X
rectTemp.Y = Y
If bolClear Then
gr.DrawImage(Savedbmp, X, Y, rectTemp, GraphicsUnit.Pixel)
Else
gr.DrawRectangle(pn, X, Y, rectTemp.Width, rectTemp.Height)
gr.FillRectangle(br, X, Y, rectTemp.Width, rectTemp.Height)
End If
pctMain.Image = Nothing
pctMain.Image = bmp
End Sub

"Alex Feinman [MVP]" wrote:

> You need to implement an intelligent interpolation algorithm for those
> points you might have missed
>
> "AmitSeth" <AmitSeth@discussions.microsoft.com> wrote in message
> news:2BDE1B46-0234-496E-8114-EED3DD4AE293@microsoft.com...
> > Hi All,
> >
> > I am trying to develop an Eraser tool for a ImageEditor kind of
> > application
> > on Pocket PC. I can perform the erasing using a DrawImage method of
> > Graphics
> > for the PictureBox.
> >
> > The only problem is when user moves the stylus very fast on the screen the
> > Mouse_Move event misses every e.x and e.y (GraphicsPath) and then it looks
> > like some part of the image doesn't get cleared.
> >
> > If you find any solution of this problem please inform me.
> >
> > Here is the code of MouseMove event...
> >
> > Private Sub pctMain_MouseMove(ByVal sender As System.Object, ByVal e As
> > System.Windows.Forms.MouseEventArgs) Handles pctMain.MouseMove
> > If bolClear Then
> > rectTemp.X = e.X
> > rectTemp.Y = e.Y
> > gr.DrawImage(Savedbmp, e.X, e.Y, rectTemp, GraphicsUnit.Pixel)
> > pctMain.Image = Nothing
> > pctMain.Image = bmp
> > LastPos.X = e.X
> > LastPos.Y = e.Y
> > Else
> > gr.DrawLine(pn, e.X, e.Y, LastPos.X, LastPos.Y)
> > pctMain.Image = Nothing
> > pctMain.Image = bmp
> > LastPos.X = e.X
> > LastPos.Y = e.Y
> > End If
> > End Sub
> >
>
>