当前位置: 首页>>代码示例>>C#>>正文


C# Matrix.TransformPoints方法代码示例

本文整理汇总了C#中System.Drawing.Drawing2D.Matrix.TransformPoints方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.TransformPoints方法的具体用法?C# Matrix.TransformPoints怎么用?C# Matrix.TransformPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Drawing2D.Matrix的用法示例。


在下文中一共展示了Matrix.TransformPoints方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TransformPoints

        static public void TransformPoints(PointF[] points, PointF origin, bool diagonal, bool horizontal, bool vertical)
        {
            Matrix translate = new Matrix();
            Matrix rotate = new Matrix();

            // Put the points into origin/local space
            translate.Translate(-origin.X, -origin.Y);
            translate.TransformPoints(points);

            // Apply the flips/rotations (order matters)
            if (horizontal)
            {
                Matrix h = new Matrix(-1, 0, 0, 1, 0, 0);
                rotate.Multiply(h);
            }
            if (vertical)
            {
                Matrix v = new Matrix(1, 0, 0, -1, 0, 0);
                rotate.Multiply(v);
            }
            if (diagonal)
            {
                Matrix d = new Matrix(0, 1, 1, 0, 0, 0);
                rotate.Multiply(d);
            }

            // Apply the combined flip/rotate transformation
            rotate.TransformPoints(points);

            // Put points back into world space
            translate.Invert();
            translate.TransformPoints(points);
        }
开发者ID:knunery,项目名称:Tiled2Unity,代码行数:33,代码来源:TmxMath.cs

示例2: boundary

        /**
        For each pixel location in the new buffer P' (NewX, NewY), do:
            Find corresponding old location, P = W-1.P'
            Validate that this old location lie inside the original image boundary (i.e. 0 ≤ OldX < W,  0  ≤ Old Y < H). Otherwise, set the new empty pixel to 0 and continue to next location.
            If Validated, apply Bilinear Interpolation Algorithm to get the new pixel value, as follows:(Refer to above figure)
                */
        public BufferedImage apply_transformation_matrix_to_bitmap_or_buffer(Matrix _transformations_matrix, BufferedImage _src_img, int _new_width, int _new_height, TextBox _console)
        {
            BufferedImage ret = new BufferedImage(_new_width, _new_height);
            BilinearInterpolation obj_bi_lin_interpol = new BilinearInterpolation();
            for (int i = 0; i < _new_width; i++)
            {
                for (int j = 0; j < _new_height; j++)
                {
                    PointF[] points = {
                                          new PointF(i, j)
                                      };
                    _transformations_matrix.TransformPoints(points);
                    _console.Text += "P = (" + points[0].X + ", " + points[0].Y + ")";
                    _console.Text += Environment.NewLine;
                    _console.Text += "P' = (" + i + ", " + j + ")";
                    _console.Text += Environment.NewLine;

                    Color _color = Color.FromArgb(0);
                    if(points[0].X >= 0 && points[0].X < _src_img.width && points[0].Y >= 0 && points[0].Y < _src_img.height)
                        _color = obj_bi_lin_interpol.calculate(_src_img, points[0].X, points[0].Y);
                    ret.buffer[i, j] = _color;
                }
            }
            return ret;
        }
开发者ID:thecortex,项目名称:CS-Tasks,代码行数:31,代码来源:ImageMatrixTransformations.cs

示例3: TankPolygonPoints

        /// <summary>
        /// Returned points 1-4 are the left track, points 5-8 are the right track, 9-16 are the turret
        /// They should be drawn individually
        /// </summary>
        public static PointF[] TankPolygonPoints(int offsetX, int offsetY, float rotDegrees, float size)
        {
            var points = new PointF[16] {
                // Left track
                new PointF(-1, -1),
                new PointF(-1, 1),
                new PointF(-0.5f, 1),
                new PointF(-0.5f, -1),

                // Right track
                new PointF(0.5f, -1),
                new PointF(1, -1),
                new PointF(1, 1),
                new PointF(0.5f, 1),

                // Turret
                new PointF(-0.5f, -0.5f),
                new PointF(0.5f, -0.5f),
                new PointF(-0.5f, 0.5f),
                new PointF(-0.25f, 0.5f),
                new PointF(-0.25f, 1.75f),
                new PointF(0.25f, 1.75f),
                new PointF(0.25f, 0.5f),
                new PointF(0.5f, 0.5f)
            };

            var matrix = new Matrix();
            matrix.Rotate(rotDegrees, MatrixOrder.Append);
            matrix.Translate(offsetX, offsetY, MatrixOrder.Append);
            matrix.Scale(size, size);
            matrix.TransformPoints(points);
            return points;
        }
开发者ID:RogaDanar,项目名称:MineSweeper-Neural-Net,代码行数:37,代码来源:Shapes.cs

示例4: OnPaint

 public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
 {
     Graphics graphics = e.Graphics;
     Bitmap memoryBitmap = viewPortData.MemoryBitmap;
     Rectangle rect = new Rectangle(Point.Empty, memoryBitmap.Size);
     graphics.FillRectangle(AmbientTheme.WorkspaceBackgroundBrush, rect);
     if (((base.parentView.RootDesigner != null) && (base.parentView.RootDesigner.Bounds.Width >= 0)) && (base.parentView.RootDesigner.Bounds.Height >= 0))
     {
         GraphicsContainer container = graphics.BeginContainer();
         Matrix matrix = new Matrix();
         matrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
         Point[] pts = new Point[] { viewPortData.LogicalViewPort.Location };
         matrix.TransformPoints(pts);
         matrix.Translate((float) (-pts[0].X + viewPortData.ShadowDepth.Width), (float) (-pts[0].Y + viewPortData.ShadowDepth.Height), MatrixOrder.Append);
         graphics.Transform = matrix;
         using (Region region = new Region(ActivityDesignerPaint.GetDesignerPath(base.parentView.RootDesigner, false)))
         {
             Region clip = graphics.Clip;
             graphics.Clip = region;
             AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
             graphics.FillRectangle(Brushes.White, base.parentView.RootDesigner.Bounds);
             if (ambientTheme.WorkflowWatermarkImage != null)
             {
                 ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, base.parentView.RootDesigner.Bounds, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, 0.25f, false);
             }
             graphics.Clip = clip;
         }
         graphics.EndContainer(container);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:DefaultWorkflowLayout.cs

示例5: Transform

		public override void Transform(Matrix matrix) {
			Point[] points = capturePoints.ToArray();

			matrix.TransformPoints(points);
			capturePoints.Clear();
			capturePoints.AddRange(points);
			RecalculatePath();
		}
开发者ID:logtcn,项目名称:greenshot,代码行数:8,代码来源:FreehandContainer.cs

示例6: drawGraphLine

        private void drawGraphLine(Graphics graphics, PointF[] points, Pen pen, float yScale, float xScale)
        {
            var matrix = new Matrix();
            matrix.Scale(xScale, yScale);
            matrix.Translate(5, 5, MatrixOrder.Append);
            matrix.TransformPoints(points);

            graphics.DrawLines(pen, points);
        }
开发者ID:RogaDanar,项目名称:MineSweeper-Neural-Net,代码行数:9,代码来源:Graph.cs

示例7: EraseHighlight

        public void EraseHighlight(Graphics g, Matrix xformWorldToPixel, Brush eraseBrush)
        {
            PointF[] pts = { new PointF(rect.Left, rect.Bottom), new PointF(rect.Right, rect.Top) };
            xformWorldToPixel.TransformPoints(pts);
            RectangleF rectPixel = RectangleF.FromLTRB(pts[0].X, pts[0].Y, pts[1].X, pts[1].Y);

            rectPixel.Inflate(penWidth / 2F, penWidth / 2F);
            Rectangle r = Util.Round(rectPixel);
            g.FillRectangle(eraseBrush, r);
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:10,代码来源:Highlights.cs

示例8: DrawHighlight

 public void DrawHighlight(Graphics g, Matrix xformWorldToPixel)
 {
     using (Pen redPen = new Pen(Color.Red, penWidth))
     using (Brush blueBrush = new HatchBrush(HatchStyle.Percent25, Color.DarkBlue, Color.Transparent)) {
         PointF[] pts = { new PointF(rect.Left, rect.Bottom), new PointF(rect.Right, rect.Top) };
         xformWorldToPixel.TransformPoints(pts);
         RectangleF rectPixel = RectangleF.FromLTRB(pts[0].X, pts[0].Y, pts[1].X, pts[1].Y);
         g.FillRectangle(blueBrush, rectPixel.X, rectPixel.Y, rectPixel.Width, rectPixel.Height);
         g.DrawRectangle(redPen, rectPixel.X, rectPixel.Y, rectPixel.Width, rectPixel.Height);
     }
 }
开发者ID:petergolde,项目名称:PurplePen,代码行数:11,代码来源:Highlights.cs

示例9: RotateBitmap

        public Bitmap RotateBitmap(Bitmap bm, float angle)
        {
            // Make a Matrix to represent rotation
            // by this angle.
            Matrix rotate_at_origin = new Matrix();
            rotate_at_origin.Rotate(angle);

            // Rotate the image's corners to see how big
            // it will be after rotation.
            PointF[] points =
            {
                new PointF(0, 0),
                new PointF(bm.Width, 0),
                new PointF(bm.Width, bm.Height),
                new PointF(0, bm.Height),
                 };

            rotate_at_origin.TransformPoints(points);
            float xmin, xmax, ymin, ymax;
            GetPointBounds(points, out xmin, out xmax,
                out ymin, out ymax);

            // Make a bitmap to hold the rotated result.
            int wid = (int)Math.Round(xmax - xmin);
            int hgt = (int)Math.Round(ymax - ymin);
            Bitmap result = new Bitmap(wid, hgt);

            // Create the real rotation transformation.
            Matrix rotate_at_center = new Matrix();
            rotate_at_center.RotateAt(angle,
                new PointF(0, 0));

            // Draw the image onto the new bitmap rotated.
            using (Graphics gr = Graphics.FromImage(result))
            {
                // Use smooth image interpolation.
                gr.InterpolationMode = InterpolationMode.HighQualityBilinear;

                // Clear with the color in the image's upper left corner.
                gr.Clear(bm.GetPixel(0, 0));

                gr.Clear(Color.White);

                // Set up the transformation to rotate.
                gr.Transform = rotate_at_center;

                // Draw the image centered on the bitmap.
                int x = 0;
                int y = 0;
                gr.DrawImage(bm, x, y);
            }
            // Return the result bitmap.
            return result;
        }
开发者ID:Romaxaqaz,项目名称:MRO_E-Ticket,代码行数:54,代码来源:RotateBitmapImage.cs

示例10: Transform

 protected void Transform(Matrix matrixValueToScreen, bool isLog, PointF[] points)
 {
     if (isLog)
     {
         for (int i = 0; i < points.Length; i++)
         {
             points[i] = new PointF(points[i].X, points[i].Y < 0 ? (float)-Math.Log10(-points[i].Y + 1) : (float)Math.Log10(points[i].Y + 1));
         }
     }
     matrixValueToScreen.TransformPoints(points);
 }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:11,代码来源:DrawingItem.cs

示例11: ChangeDirection

        public void ChangeDirection(Point pt, Size sz)
        {
            float angle = 90;
            Matrix matrix = new Matrix();
            matrix.RotateAt(angle, pt);

            int n = pointList.Count;
            Point[] points = new Point[n];
            pointList.CopyTo(points);
            matrix.TransformPoints(points);

            for (int i = 0; i < n; i++)
            {
                Rectangle rc = new Rectangle(0, 0, sz.Width, sz.Height);
                if (!rc.Contains(points[i]))
                {
                    if (points[n - 2].X == points[n - 1].X)
                    {
                        int height = Math.Abs(points[1].Y - points[0].Y);
                        if (points[i].Y < 0)
                        {
                            points[0].Y = 1;
                            points[1].Y = points[0].Y + height;
                        }
                        else if (points[i].Y > sz.Height)
                        {
                            points[0].Y = sz.Height - 2;
                            points[1].Y = points[0].Y - height;
                        }
                    }
                    else if (points[n - 2].Y == points[n - 1].Y)
                    {
                        int width = Math.Abs(points[1].X - points[0].X);
                        if (points[i].X < 0)
                        {
                            points[0].X = 1;
                            points[1].X = points[0].X + width;
                        }
                        else if (points[i].X > sz.Width)
                        {
                            points[0].X = sz.Width - 2;
                            points[1].X = points[0].X - width;
                        }
                    }
                    pointList.Clear();
                    pointList.AddRange(points);
                    return;
                }
            }
            pointList.Clear();
            pointList.AddRange(points);
        }
开发者ID:JiangJunGG,项目名称:SyAutoH,代码行数:52,代码来源:ObjectStraightOp.cs

示例12: MinePolygonPoints

        public static Point[] MinePolygonPoints(int offsetX, int offsetY, float size)
        {
            var points = new Point[4] {
                new Point(-1, -1),
                new Point(-1, 1),
                new Point(1, 1),
                new Point(1, -1)
            };

            var matrix = new Matrix();
            matrix.Translate(offsetX, offsetY);
            matrix.Scale(size, size);
            matrix.TransformPoints(points);
            return points;
        }
开发者ID:RogaDanar,项目名称:MineSweeper-Neural-Net,代码行数:15,代码来源:Shapes.cs

示例13: BoundsOfTransformedRectangle

        // Transform a rectangle with a transform, and return the new rectangle that bounds the corners of the transformed one.
        public static RectangleF BoundsOfTransformedRectangle(RectangleF rect, Matrix transform)
        {
            PointF[] corners = { new PointF(rect.Left, rect.Top),    new PointF(rect.Right, rect.Top),
                             new PointF(rect.Left, rect.Bottom), new PointF(rect.Right, rect.Bottom) };
            transform.TransformPoints(corners);
            float minX = float.MaxValue, maxX = float.MinValue, minY = float.MaxValue, maxY = float.MinValue;
            for (int i = 0; i < corners.Length; ++i) {
                if (corners[i].X < minX)   minX = corners[i].X;
                if (corners[i].X > maxX)   maxX = corners[i].X;
                if (corners[i].Y < minY)   minY = corners[i].Y;
                if (corners[i].Y > maxY)   maxY = corners[i].Y;
            }

            return new RectangleF(minX, minY, maxX - minX, maxY - minY);
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:16,代码来源:Util.cs

示例14: DrawPointMass

        private static void DrawPointMass(IPointMass pointMass, Pen pen, Brush brush, Graphics g)
        {
            var triangle = new[] { new PointF(1, 0), new PointF(-0.7f, 0.7f), new PointF(-0.7f, -0.7f) };

            using (var m = new Matrix())
            {
                m.Translate(pointMass.Position.X, pointMass.Position.Y);
                m.Rotate((float)(Math.Atan2(pointMass.Velocity.Y, pointMass.Velocity.X) * 180 / Math.PI));
                m.Scale(pointMass.Radius*0.9f, pointMass.Radius*0.9f);
                m.TransformPoints(triangle);
            }

            g.FillPolygon(brush, triangle);
            g.DrawCircle(pen, pointMass.Position, pointMass.Radius);
        }
开发者ID:PurdueSIGAI,项目名称:SoccerApp,代码行数:15,代码来源:SimulationDrawingStrategy.cs

示例15: DrawLoopsOnGraphics

    /// <summary>
    /// Draw loops on graphics with the specified
    /// transform and graphics attributes.
    /// </summary>
    static void DrawLoopsOnGraphics(
      Graphics graphics,
      List<Point[]> loops,
      Matrix transform )
    {
      foreach( Point[] loop in loops )
      {
        GraphicsPath path = new GraphicsPath();

        transform.TransformPoints( loop );

        path.AddLines( loop );
        
        graphics.DrawPath( Pen, path );
      }
    }
开发者ID:mtumminello,项目名称:RoomEditorApp,代码行数:20,代码来源:GeoSnoop.cs


注:本文中的System.Drawing.Drawing2D.Matrix.TransformPoints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。