none
手指画线获取的Stroke和手写获取的轨迹不一样? RRS feed

  • 问题

  • 获取点的代码如下

    private void _PointerPressed(object sender, PointerRoutedEventArgs e)

    {

    _InkManager.ProcessPointerDown(pointerPoint);

    }

    private void _PointerMoved(object sender, PointerRoutedEventArgs e)
    {

    var intermediatePoints = e.GetIntermediatePoints(_Canvas);
     for (int i = intermediatePoints.Count - 1; i >= 0; i--)
     {
     _InkManager.ProcessPointerUpdate(intermediatePoints[i]);
    }

    }

    private void _PointerReleased(object sender, PointerRoutedEventArgs e)

    {

    _InkManager.ProcessPointerUp(pointerPoint);

    }

    根据点绘制曲线

    public static Path CreateBezierPath(InkStroke stroke)
    {

    var figure = new PathFigure();

                var segments = stroke.GetRenderingSegments().GetEnumerator();
                segments.MoveNext();
                // First segment is degenerate and corresponds to initial position
                figure.StartPoint = segments.Current.Position;
                // Now loop through all remaining segments

                while (segments.MoveNext())
                {
                    var bs = new BezierSegment();
                    bs.Point1 = segments.Current.BezierControlPoint1;
                    bs.Point2 = segments.Current.BezierControlPoint2;
                    bs.Point3 = segments.Current.Position;
                    figure.Segments.Add(bs);
                }

                // Create and initialize the data structures necessary to render the figure
                var geometry = new PathGeometry();
                geometry.Figures.Add(figure);
                var path = new Path();
                path.Data = geometry;

                // Set the stroke's graphical properties, which are controlled by the Path object
                path.Stroke = new SolidColorBrush(stroke.DrawingAttributes.Color);
                path.StrokeThickness = stroke.DrawingAttributes.Size.Width;
                path.StrokeLineJoin = PenLineJoin.Round;
                path.StrokeStartLineCap = PenLineCap.Round;

                return path;
    }

    用手写笔的线,微小的曲折都能重现

    但是用手指直接画线的时候,一些明显的折线都被变成曲线了

    如何使手指和手写笔画线保持一样呢?


    2013年4月23日 3:48

答案

  • Hi,

    Pointer这个概念实际包含了鼠标手指和画笔,换句话说实际上他们都是用一个事件来处理的轨迹,因为没有办法看到源代码所以没有办法解决你的问题。而且毕竟Windows Store app并不是用来画图的专业软件,无论是PointerMove触发的速度,以及通过PointerMove得到的坐标之后通过贝塞尔曲线模拟曲线都没有办法完全还原用户的输入。


    Aaron
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2013年4月24日 10:32
    版主