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


C# Matrix.Invert方法代码示例

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


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

示例1: DrawRect

        public override void DrawRect(System.Drawing.RectangleF dirtyRect)
        {
            Graphics g = new Graphics();
            int offset = 20;

            // Invert matrix:
            Matrix m = new Matrix(1, 2, 3, 4, 0, 0);
            g.DrawString("Original Matrix:", this.Font, Brushes.Black, 10, 10);
            DrawMatrix(m, g, 10, 10 + offset);
            g.DrawString("Inverted Matrix:", this.Font, Brushes.Black, 10, 10 + 2*offset);
            m.Invert();
            DrawMatrix(m, g, 10, 10 + 3 * offset);

            // Matrix multiplication - MatrixOrder.Append:
            Matrix m1 = new Matrix(1, 2, 3, 4, 0, 1);
            Matrix m2 = new Matrix(0, 1, 2, 1, 0, 1);
            g.DrawString("Original Matrices:", this.Font, Brushes.Black, 10, 10 + 4 * offset);
            DrawMatrix(m1, g, 10, 10 + 5 * offset);
            DrawMatrix(m2, g, 10 + 130, 10 + 5 * offset);
            m1.Multiply(m2, MatrixOrder.Append);
            g.DrawString("Resultant Matrix - Append:", this.Font, Brushes.Black, 10, 10 + 6 * offset);
            DrawMatrix(m1, g, 10, 10 + 7 * offset);

            // Matrix multiplication - MatrixOrder.Prepend:
            m1 = new Matrix(1, 2, 3, 4, 0, 1);
            m1.Multiply(m2, MatrixOrder.Prepend);
            g.DrawString("Resultant Matrix - Prepend:", this.Font, Brushes.Black, 10, 10 + 8 * offset);
            DrawMatrix(m1, g, 10, 10 + 9 * offset);
        }
开发者ID:stnk3000,项目名称:sysdrawing-coregraphics,代码行数:29,代码来源:DrawingView.cs

示例2: SurfaceBackgroundChangeMemento

		public SurfaceBackgroundChangeMemento(Surface surface, Matrix matrix) {
			_surface = surface;
			_image = surface.Image;
			_matrix = matrix.Clone();
			// Make sure the reverse is applied
			_matrix.Invert();
		}
开发者ID:logtcn,项目名称:greenshot,代码行数:7,代码来源:SurfaceBackgroundChangeMemento.cs

示例3: getAffineTransformMatrix

        private static Matrix getAffineTransformMatrix(PointF p01, PointF p02, PointF p03,
                                                        PointF p11, PointF p12, PointF p13)
        {
            Matrix a = new Matrix(p02.X - p01.X,
                                  p02.Y - p01.Y,
                                  p03.X - p01.X,
                                  p03.Y - p01.Y,
                                  p01.X,
                                  p01.Y);

            Matrix b = new Matrix(p12.X - p11.X,
                                  p12.Y - p11.Y,
                                  p13.X - p11.X,
                                  p13.Y - p11.Y,
                                  p11.X,
                                  p11.Y);

            if (!a.IsInvertible)
                return null;

            a.Invert();
            a.Multiply(b, MatrixOrder.Append);

            return a;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:25,代码来源:RasterAlgorithms.cs

示例4: 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

示例5: Draw

        public override void Draw(CGRect rect)
        {
            Graphics g = Graphics.FromCurrentContext ();
            int offset = 20;

            // Invert matrix:
            var m = new Matrix (1, 2, 3, 4, 0, 0);
            g.DrawString ("Original Matrix:", Font, Brushes.Black, 10, 10);
            DrawMatrix (m, g, 10, 10 + offset);
            g.DrawString ("Inverted Matrix:", Font, Brushes.Black, 10, 10 + 2 * offset);
            m.Invert ();
            DrawMatrix (m, g, 10, 10 + 3 * offset);

            // Matrix multiplication - MatrixOrder.Append:
            var m1 = new Matrix (1, 2, 3, 4, 0, 1);
            var m2 = new Matrix (0, 1, 2, 1, 0, 1);
            g.DrawString ("Original Matrices:", Font, Brushes.Black, 10, 10 + 4 * offset);
            DrawMatrix (m1, g, 10, 10 + 5 * offset);
            DrawMatrix (m2, g, 10 + 130, 10 + 5 * offset);
            m1.Multiply (m2, MatrixOrder.Append);
            g.DrawString ("Resultant Matrix - Append:", Font, Brushes.Black, 10, 10 + 6 * offset);
            DrawMatrix (m1, g, 10, 10 + 7 * offset);

            // Matrix multiplication - MatrixOrder.Prepend:
            m1 = new Matrix (1, 2, 3, 4, 0, 1);
            m1.Multiply (m2, MatrixOrder.Prepend);
            g.DrawString ("Resultant Matrix - Prepend:", Font, Brushes.Black, 10, 10 + 8 * offset);
            DrawMatrix (m1, g, 10, 10 + 9 * offset);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:29,代码来源:DrawingView.cs

示例6: SetupTransform

 private void SetupTransform()
 {
     //world points
     float x1 = 0, y1 = 0, x2 = 100, y2 = 100;
     //device points
     Rectangle crect = this.ClientRectangle;
     float x1d = (float)5 * crect.Width / 14;//up left corner
     float y1d = 0.1f * crect.Height;//up left corner
     float x2d = (float)13 * crect.Width / 14;//bottom rigth corner
     float y2d = 0.9f * crect.Height;//bottom right corner
     //calcutae the scalling
     s1 = (x1d - x2d) / (x1 - x2);
     s2 = (y1d - y2d) / (y1 - y2);
     t1 = (x1 * x2d - x2 * x1d) / (x1 - x2);
     t2 = (y1 * y2d - y2 * y1d) / (y1 - y2);
     m = new Matrix();
     m.Translate(t1, t2);//transalation
     m.Scale(s1, s2);//scaling
     //get the inverse
     m.Invert();
     minv = m.Clone();
     m.Invert();
 }
开发者ID:robnils,项目名称:Chaotic-Waterwheel,代码行数:23,代码来源:WaterWheel.cs

示例7: DrawGraph

        // Draw the graph.
        private void DrawGraph(Graphics gr)
        {
            // Map to turn right-side up and center at the origin.
            const float wxmin = -10;
            const float wymin = -10;
            const float wxmax = 10;
            const float wymax = 10;
            RectangleF rect = new RectangleF(wxmin, wymin, wxmax - wxmin, wymax - wymin);
            PointF[] pts =
            {
                new PointF(0, graphPictureBox.ClientSize.Height),
                new PointF(graphPictureBox.ClientSize.Width, graphPictureBox.ClientSize.Height),
                new PointF(0, 0),
            };
            Matrix transform = new Matrix(rect, pts);
            gr.Transform = transform;

            // See how far it is between horizontal pixels in world coordinates.
            pts = new PointF[] { new PointF(1, 0) };
            transform.Invert();
            transform.TransformVectors(pts);
            float dx = pts[0].X;

            // Generate points on the curve.
            List<PointF> points = new List<PointF>();
            for (float x = wxmin; x <= wxmax; x += dx)
                points.Add(new PointF(x, TheFunction(x)));

            // Use a thin pen.
            using (Pen thin_pen = new Pen(Color.Gray, 0))
            {
                // Draw the coordinate axes.
                gr.DrawLine(thin_pen, wxmin, 0, wxmax, 0);
                gr.DrawLine(thin_pen, 0, wymin, 0, wymax);
                for (float x = wxmin; x <= wxmax; x++)
                    gr.DrawLine(thin_pen, x, -0.5f, x, 0.5f);
                for (float y = wymin; y <= wymax; y++)
                    gr.DrawLine(thin_pen, -0.5f, y, 0.5f, y);

                // Draw the graph.
                thin_pen.Color = Color.Red;
                //thin_pen.Color = Color.Black;
                gr.DrawLines(thin_pen, points.ToArray());
            }
        }
开发者ID:vikramadhav,项目名称:Certification_70-483,代码行数:46,代码来源:Form1.cs

示例8: Draw


//.........这里部分代码省略.........
          pts[1].X - 1.5f * width2 - this.secondPointDistance,
          pts[1].Y + width2);

        GraphicsPath firstArrow = new GraphicsPath();
        GraphicsPath secondArrow = new GraphicsPath();

        firstArrow.AddLines(
          new PointF[] 
              { 
                bottomRightBar1,
                bottomLeftBar1,
                bottomCorner1,
                tip1,
                topCorner1,
                topLeftBar1,
                topRightBar1
              });

        secondArrow.AddLines(
          new PointF[] 
              { 
                topLeftBar2,
                topRightBar2,
                topCorner2,
                tip2,
                bottomCorner2,
                bottomRightBar2,
                bottomLeftBar2
              });

        PointF[] firstPts = firstArrow.PathPoints;
        PointF[] secondPts = secondArrow.PathPoints;

        rotate.Invert();
        rotate.TransformPoints(firstPts);
        rotate.TransformPoints(secondPts);

        firstArrow.Reset();
        secondArrow.Reset();
        firstArrow.AddLines(firstPts);
        secondArrow.AddLines(secondPts);

        if ((this.ShapeDrawAction & ShapeDrawAction.Fill) == ShapeDrawAction.Fill)
        {
          if (width1 > 0)
          {
            graphics.FillPath(this.Brush, firstArrow);
          }

          if (width2 > 0)
          {
            graphics.FillPath(this.Brush, secondArrow);
          }
        }

        if ((this.ShapeDrawAction & ShapeDrawAction.Edge) == ShapeDrawAction.Edge)
        {
          if (width1 > 0)
          {
            graphics.DrawPath(this.Pen, firstArrow);
          }

          if (width2 > 0)
          {
            graphics.DrawPath(this.Pen, secondArrow);
          }
开发者ID:DeSciL,项目名称:Ogama,代码行数:67,代码来源:VGArrow.cs

示例9: ClientSizeToLogical

 public Size ClientSizeToLogical(Size clientSize)
 {
     Point[] pts = new Point[] { new Point(clientSize) };
     Matrix matrix = new Matrix();
     matrix.Scale(this.ScaleZoomFactor, this.ScaleZoomFactor);
     matrix.Invert();
     matrix.TransformPoints(pts);
     matrix.Invert();
     return new Size(pts[0]);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:WorkflowView.cs

示例10: CalculateMatrix

 protected void CalculateMatrix()
 {
   _cachedForwardMatrix.Reset();
   _cachedForwardMatrix.Translate(_cachedLayerPosition.X, _cachedLayerPosition.Y);
   _cachedForwardMatrix.Scale((float)_location.Scale, (float)_location.Scale);
   _cachedForwardMatrix.Rotate(-(float)_location.Angle);
   _cachedReverseMatrix = _cachedForwardMatrix.Clone();
   _cachedReverseMatrix.Invert();
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:9,代码来源:XYPlotLayer.cs

示例11: matrix

        /**
        You can use this matrix as follows:
            1 - Create new object with identity matrix (empty constructor)
            2 - Apply a set of transformations that you want to this matrix
            3 - Transform the four corners of the original image to calculate
            4 - The min X and min Y of the transformed image
            5 - The width & height of the new image buffer
            6 - Translate this matrix by (- min X, - min Y)
            7 - Invert the matrix
            8 - Use the inverted version to reverse transform all new locations in the new image buffer
        **/
        public BufferedImage perform_concat_matrices_operations(BufferedImage _src_img, TextBox _console, float _shear_x = (float)0, float _shear_y = (float)0, float _scale_x = (float)1, float _scale_y = (float)1, float _rotate_theta = (float)0)
        {
            BufferedImage ret;
            // 1 - Create new object with identity matrix (empty constructor)
            Matrix transformations_matrix = new Matrix();
            // 2 - Apply a set of transformations that you want to this matrix
            transformations_matrix.Rotate(_rotate_theta);
            transformations_matrix.Scale(_scale_x, _scale_y);
            transformations_matrix.Shear(_shear_x, _shear_y);
            // 3 - Transform the four corners of the original image to calculate
            /**
             * To get the size of the new (destination) image,
             * apply the forward mapping to the four corners of the original image
             * ([0,0], [W-1,0], [0,H-1], [W-1,H-1])
             * to get their new locations.
             * Then use these new four locations to get the width and height of the destination image
             * (e.g. to get new width:
             * find min X & max X of the four new points and subtract them,
             * do the same for Y to get the new height)
             */
            Point[] corner_points = {
                                        new Point(0, 0),
                                        new Point(_src_img.width - 1, 0),
                                        new Point(0, _src_img.height - 1),
                                        new Point(_src_img.width - 1, _src_img.height - 1)
                                    };

            transformations_matrix.TransformPoints(corner_points);

            int min_x = find_min_x(corner_points);
            int min_y = find_min_y(corner_points);

            int max_x = find_max_x(corner_points);
            int max_y = find_max_y(corner_points);

            int new_width = max_x - min_x;
            int new_height = max_y - min_y;

            _console.Text += "Min X = ";
            _console.Text += min_x;
            _console.Text += Environment.NewLine;

            _console.Text += "Min Y = ";
            _console.Text += min_y;
            _console.Text += Environment.NewLine;

            _console.Text += "Max X = ";
            _console.Text += max_x;
            _console.Text += Environment.NewLine;

            _console.Text += "Max Y = ";
            _console.Text += max_y;
            _console.Text += Environment.NewLine;

            _console.Text += "New Width = ";
            _console.Text += new_width;
            _console.Text += Environment.NewLine;

            _console.Text += "New Height = ";
            _console.Text += new_height;
            _console.Text += Environment.NewLine;

            // 4 - The min X and min Y of the transformed image
            /**
             * To make the transformed image totally fit inside the buffer, a translation with (- min X, - min Y) should be appended to the original transformation matrix (W) before inverting it.
             */

            // 6 - Translate this matrix by (- min X, - min Y)
            transformations_matrix.Translate(-min_x, -min_y);

            // 7 - Invert the matrix
            transformations_matrix.Invert();

            // 8 - Use the inverted version to reverse transform all new locations in the new image buffer
            ret = apply_transformation_matrix_to_bitmap_or_buffer(transformations_matrix, _src_img, new_width, new_height, _console);
            return ret;
        }
开发者ID:thecortex,项目名称:CS-Tasks,代码行数:88,代码来源:ImageMatrixTransformations.cs

示例12: BitmapTransform

        // Computer the transform from coordinates of the bitmap to world coordinates
        Matrix BitmapTransform()
        {
            // (worldcoord in mm) / 25.4F * dpi = pixels
            float scaleFactor = bitmapDpi / 25.4F;

            Matrix matrix = new Matrix();
            matrix.Translate(0, bitmap.PixelHeight);
            matrix.Scale(scaleFactor, -scaleFactor);
            matrix.Invert();
            return matrix;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:12,代码来源:MapDisplay.cs

示例13: Transform

        public void Transform(Matrix transform_matrix, Interpolation _interpolation = Interpolation.Bilinear)
        {
            PointF[] ps = new PointF[4];
            ps[0].X = 0; ps[0].Y = 0;
            ps[1].X = width; ps[1].Y = 0;
            ps[2].X = 0; ps[2].Y = height;
            ps[3].X = width; ps[3].Y = height;

            transform_matrix.TransformPoints(ps);

            float MinX = ps[0].X, MinY = ps[0].Y,
                MaxX = ps[0].X, MaxY = ps[0].Y;
            for (int i = 0; i < 4; i++)
            {
                if (ps[i].X < MinX) MinX = ps[i].X;
                if (ps[i].Y < MinY) MinY = ps[i].Y;
                if (ps[i].X > MaxX) MaxX = ps[i].X;
                if (ps[i].Y > MaxY) MaxY = ps[i].Y;
            }

            int new_width = (int)(MaxX - MinX);
            int new_height = (int)(MaxY - MinY);

            transform_matrix.Translate(-MinX, -MinY, MatrixOrder.Append);

            if(transform_matrix.IsInvertible)
            {
                transform_matrix.Invert();
            }

            bitmap = new Bitmap(new_width, new_height);

            Color[,] new_buffer2d = new Color[new_width, new_height];

            PointF[] pt = new PointF[1];
            for (int y = 0; y < new_height; y++)
            {
                for (int x = 0; x < new_width; x++)
                {
                    pt[0].X = x; pt[0].Y = y;
                    transform_matrix.TransformPoints(pt);
                    if (pt[0].X < width - 1 && pt[0].Y < height - 1 && pt[0].X > 0 && pt[0].Y > 0)
                    {
                        Color color = Bilinear_Interpolate(pt[0]);
                        switch (_interpolation)
                        {
                            case Interpolation.None:
                                new_buffer2d[x, y] = buffer2d[(Int32)pt[0].X, (Int32)pt[0].Y];
                                break;
                            case Interpolation.Bilinear:
                                new_buffer2d[x, y] = color;
                                break;
                            default:
                                new_buffer2d[x, y] = buffer2d[(Int32)pt[0].X, (Int32)pt[0].Y];
                                break;
                        }

                    }
                    else
                    {
                        new_buffer2d[x, y] = Color.FromArgb(255, 255, 255);
                    }
                    bitmap.SetPixel(x, y, new_buffer2d[x, y]);

                }
            }

            width = new_width;
            height = new_height;
            buffer2d = new_buffer2d;
        }
开发者ID:AlexanderHosnie,项目名称:IP-FCIS,代码行数:71,代码来源:TypicalImage.cs

示例14: BackTrackMouse

		/// <summary>
		/// Back Track the Mouse to return accurate coordinates regardless of zoom or pan effects.
		/// Courtesy of BobPowell.net <seealso cref="http://www.bobpowell.net/backtrack.htm"/>
		/// </summary>
		/// <param name="p">Point to backtrack</param>
		/// <returns>Backtracked point</returns>
		public Point BackTrackMouse(Point p)
		{
			// Backtrack the mouse...
			Point[] pts = new Point[] { p };
			Matrix mx = new Matrix();
			mx.Translate(-this.ClientSize.Width / 2, -this.ClientSize.Height / 2, MatrixOrder.Append);
			mx.Rotate(_rotation, MatrixOrder.Append);
			mx.Translate(this.ClientSize.Width / 2 + _panX, this.ClientSize.Height / 2 + _panY, MatrixOrder.Append);
			mx.Scale(_zoom, _zoom, MatrixOrder.Append);
			mx.Invert();
			mx.TransformPoints(pts);
			return pts[0];
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:19,代码来源:DrawArea.cs

示例15: TransFormPoints

 /// <summary>
 /// use matrix to transform point
 /// </summary>
 /// <param name="pts">contain the points to be transform</param>
 private void TransFormPoints(Point[] pts)
 {
     System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix(
         1, 0, 0, 1, this.openingPictureBox.Width / 2, this.openingPictureBox.Height / 2);
     matrix.Invert();
     matrix.TransformPoints(pts);
 }
开发者ID:AMEE,项目名称:revit,代码行数:11,代码来源:NewOpeningsForm.cs


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