Pradeep AJ

Pradeep AJ

  • NA
  • 8
  • 1.2k

Capture Signature on windows phone

Nov 13 2014 2:27 AM

Hi,

I want to capture signature from user, and I am using Canvas and Touch points to draw curves. I am able to get curve/signature, however the result is not good.

Code:

 void Touch_FrameReported(object sender, TouchFrameEventArgs e)

        {

            int pointsNumber = e.GetTouchPoints(drawCanvas).Count;

            TouchPointCollection pointCollection = e.GetTouchPoints(drawCanvas);


            for (int i = 0; i < pointsNumber; i++)

            {

                if (pointCollection[i].Action == TouchAction.Down)

                {

                    preXArray[i] = pointCollection[i].Position.X;

                    preYArray[i] = pointCollection[i].Position.Y;

                }

                if (pointCollection[i].Action == TouchAction.Move)

                {



                    var line = new Polyline();

                    line.StrokeLineJoin = PenLineJoin.Round;

                    line.StrokeDashCap = PenLineCap.Round;

                    line.StrokeStartLineCap = PenLineCap.Round;

                    line.StrokeEndLineCap = PenLineCap.Round;



                    var p1 = new Point(preXArray[i],preYArray[i]);

                    var p2 = new Point(pointCollection[i].Position.X, pointCollection[i].Position.Y);

                    line.Points.Add(p1);

                    line.Points.Add(p2);


                    line.Stroke = new SolidColorBrush(Colors.Black);

                    line.StrokeThickness = 5;

                    line.Fill = new SolidColorBrush(Colors.Black);

                    drawCanvas.Children.Add(line);


                    preXArray[i] = pointCollection[i].Position.X;

                    preYArray[i] = pointCollection[i].Position.Y;

                }

            }

        }


Result:

Displaying image.png

Now, what I need to do is to remove the sharp edges. In Windows Store Apps, there are lot of support for this using "InkManager". InkManager  gives InkStrokeRenderingSegment which hasBezierControlPoints so we can do some processing with Bezier Curves. 

If anyone have any idea on how to achieve this in windows phone, kindly share.

Thanks,

Pradeep