捏和缩放WIN2D

时间:2019-12-10 20:28:18

标签: c# canvas xamarin.forms uwp win2d

我使用WIN2D在画布上绘制了一些弧线和线条。现在我试图使用ManipulationDelta来实现平移和缩放,但是我的图像质量下降了。我认为该图像不会更新,因此使它失去了变焦的质量。这是我的代码...

    private void Preview_Draw(Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasDrawEventArgs args)
    {
        try
        {
            string GCodefile = ((ltvSelectExecution).SelectedItem as FolderFilesInfo).Name + ((ltvSelectExecution).SelectedItem as FolderFilesInfo).Extension;
            var EntityArcLines = execution.GetArcLinesParams(GCodefile, null, false);
            var pathGeometric = execution.GetPathGeometry(EntityArcLines);
            int flag;

            CanvasPathBuilder pathBuilder = new CanvasPathBuilder(ManipulateMe.Device);
            pathGeometric.ForEach(t =>
            {
                Vector2 finalPoints = new Vector2()
                {
                    X = (float)t.Xf,
                    Y = (float)t.Yf
                };
                float r = (float)Math.Sqrt(Math.Pow(t.I, 2) + Math.Pow(t.J, 2));
                float x = 7;
                float y = 7;
                var clockwise = t.DirectionRotate;


                CanvasSweepDirection canvasSweepDirection = clockwise == 0 ? CanvasSweepDirection.CounterClockwise:CanvasSweepDirection.Clockwise;
                flag = t.G == 0 ? 0 : 1;
                if (t.I != 0 || t.J != 0)
                {
                    pathBuilder.BeginFigure((float)t.Xi, (float)t.Yi);
                    pathBuilder.AddArc(finalPoints, x, y, (float)0, canvasSweepDirection, CanvasArcSize.Small);
                    pathBuilder.EndFigure(CanvasFigureLoop.Open);
                }
                else
                {
                    pathBuilder.BeginFigure((float)t.Xi, (float)t.Yi);
                    pathBuilder.AddLine(finalPoints);
                    pathBuilder.EndFigure(CanvasFigureLoop.Open);

                }



            });
            CanvasGeometry triangleGeometry = CanvasGeometry.CreatePath(pathBuilder);

            using (var drawSession = args.DrawingSession)
            {


                drawSession.DrawGeometry(triangleGeometry, Colors.White, (float)1);

            }



        }
        catch(Exception ex) 
        { var teste = 0;
        };
    } 

有人可以帮助实现此代码的放大和缩小吗?

谢谢!

0 个答案:

没有答案