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


C# Matrix.Rotate方法代码示例

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


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

示例1: KiRotate

 public static Bitmap KiRotate(Bitmap bmp, float angle, Color bkColor)
 {
     PixelFormat pf;
     int w = bmp.Width + 2;
     int h = bmp.Height + 2;
     if (bkColor == Color.Transparent)
     {
         pf = PixelFormat.Format32bppArgb;
     }
     else
     {
         pf = bmp.PixelFormat;
     }
     Bitmap tmp = new Bitmap(w, h, pf);
     Graphics g = Graphics.FromImage(tmp);
     g.Clear(bkColor);
     g.DrawImageUnscaled(bmp, 1, 1);
     g.Dispose();
     GraphicsPath path = new GraphicsPath();
     path.AddRectangle(new RectangleF(0f, 0f, (float)w, (float)h));
     Matrix mtrx = new Matrix();
     mtrx.Rotate(angle);
     RectangleF rct = path.GetBounds(mtrx);
     Bitmap dst = new Bitmap((int)rct.Width, (int)rct.Height, pf);
     g = Graphics.FromImage(dst);
     g.Clear(bkColor);
     g.TranslateTransform(-rct.X, -rct.Y);
     g.RotateTransform(angle);
     g.InterpolationMode = InterpolationMode.HighQualityBilinear;
     g.DrawImageUnscaled(tmp, 0, 0);
     g.Dispose();
     tmp.Dispose();
     return dst;
 }
开发者ID:vancourt,项目名称:BaseGunnyII,代码行数:34,代码来源:ValidateCode.aspx.cs

示例2: GetMatrix

		static public Matrix GetMatrix (int index)
		{
			// not defined (-1) or first (0)
			if (index <= 0)
				return null;

			Matrix m = new Matrix ();
			switch (index) {
			case 1:
				// empty
				break;
			case 2:
				m.Rotate (15);
				break;
			case 3:
				m.RotateAt (45, new PointF (100, 100));
				break;
			case 4:
				m.Scale (1.5f, 0.5f);
				break;
			case 5:
				m.Shear (2.0f, 2.0f);
				break;
			case 6:
				m.Translate (50, 50);
				break;
			}
			return m;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:29,代码来源:Matrices.cs

示例3: RotateImg

        public Bitmap RotateImg(Bitmap bmp, float angle)
        {
            var bkColor = Color.White;

            int w = bmp.Width;
            int h = bmp.Height;
            PixelFormat pf;
            pf = bkColor == Color.Transparent ? PixelFormat.Format32bppArgb : bmp.PixelFormat;

            Bitmap tempImg = new Bitmap(w, h, pf);
            Graphics g = Graphics.FromImage(tempImg);
            g.Clear(bkColor);
            g.DrawImageUnscaled(bmp, 1, 1);
            g.Dispose();

            GraphicsPath path = new GraphicsPath();
            path.AddRectangle(new RectangleF(0f, 0f, w, h));
            Matrix mtrx = new Matrix();
            //Using System.Drawing.Drawing2D.Matrix class
            mtrx.Rotate(angle);
            RectangleF rct = path.GetBounds(mtrx);
            Bitmap newImg = new Bitmap(Convert.ToInt32(rct.Width), Convert.ToInt32(rct.Height), pf);
            g = Graphics.FromImage(newImg);
            g.Clear(bkColor);
            g.TranslateTransform(-rct.X, -rct.Y);
            g.RotateTransform(angle);
            g.InterpolationMode = InterpolationMode.HighQualityBilinear;
            g.DrawImageUnscaled(tempImg, 0, 0);
            g.Dispose();
            tempImg.Dispose();
            return newImg;
        }
开发者ID:CheViana,项目名称:ImageServer,代码行数:32,代码来源:RotatedProcessor.cs

示例4: rotate

 public Color[,] rotate(Color[,] Org_Buffer, int angle)
 {
     flag_rotate_shear = true;
     Matrix M = new Matrix();
     M.Rotate(angle);
     return Transform(Org_Buffer, M);
 }
开发者ID:ahmedelkashef,项目名称:GP,代码行数:7,代码来源:GeometryOperations.cs

示例5: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            if (backBuffer == null)
                backBuffer = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);

            Graphics g = doubleBuffering ? Graphics.FromImage(backBuffer) : e.Graphics;

            g.SmoothingMode = smoothing ? SmoothingMode.AntiAlias : SmoothingMode.Default;

            g.Clear(SystemColors.Control);

            Matrix mx = new Matrix();
            mx.Rotate(angle);
            mx.Translate(this.ClientSize.Width / 2, this.ClientSize.Height / 2, MatrixOrder.Append);
            g.Transform = mx;
            g.FillRectangle(Brushes.Red, -100, -100, 200, 200);

            mx = new Matrix();
            mx.Rotate(-angle);
            mx.Translate(this.ClientSize.Width / 2, this.ClientSize.Height / 2, MatrixOrder.Append);
            g.Transform = mx;
            g.FillRectangle(Brushes.Green, -75, -75, 150, 150);

            mx = new Matrix();
            mx.Rotate(angle * 2);
            mx.Translate(this.ClientSize.Width / 2, this.ClientSize.Height / 2, MatrixOrder.Append);
            g.Transform = mx;
            g.FillRectangle(Brushes.Blue, -50, -50, 100, 100);

            if (doubleBuffering)
            {
                g.Dispose();
                e.Graphics.DrawImageUnscaled(backBuffer, 0, 0);
            }
        }
开发者ID:davidbedok,项目名称:oeprogvep,代码行数:35,代码来源:TestForm.cs

示例6: Run

        public static void Run()
        {
            // ExStart:CalculateCenterOfSubShapes
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

            // Load Visio diagram
            Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
            // Get a group shape by ID and page index is 0
            Shape shape = diagram.Pages[0].Shapes.GetShape(795);
            // Get a sub-shape of the group shape by id
            Shape subShape = shape.Shapes.GetShape(794);

            Matrix m = new Matrix();
            // Apply the translation vector
            m.Translate(-(float)subShape.XForm.LocPinX.Value, -(float)subShape.XForm.LocPinY.Value);
            // Set the elements of that matrix to a rotation
            m.Rotate((float)subShape.XForm.Angle.Value);
            // Apply the translation vector
            m.Translate((float)subShape.XForm.PinX.Value, (float)subShape.XForm.PinY.Value);

            // Get pinx and piny
            double pinx = m.OffsetX;
            double piny = m.OffsetY;
            // Calculate the sub-shape pinx and piny
            double resultx = shape.XForm.PinX.Value - shape.XForm.LocPinX.Value - pinx;
            double resulty = shape.XForm.PinY.Value - shape.XForm.LocPinY.Value - piny;
            // ExEnd:CalculateCenterOfSubShapes
        }
开发者ID:aspose-diagram,项目名称:Aspose.Diagram-for-.NET,代码行数:29,代码来源:CalculateCenterOfSubShapes.cs

示例7: RenderPage

    /// <summary>
    /// Demonstrates the use of XGraphics.Transform.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      //gfx.Clear(this.properties.General.BackColor.Color);
      base.RenderPage(gfx);

      gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
      gfx.DrawPolygon(properties.Pen1.Pen, GetPentagram(75, new PointF(150, 200)));

      Matrix matrix = new Matrix();
      //matrix.Scale(2f, 1.5f);
      //matrix.Translate(-200, -400);
      //matrix.Rotate(45);
      //matrix.Translate(200, 400);
      //gfx.Transform = matrix;
      //gfx.TranslateTransform(50, 30);

#if true
      gfx.TranslateTransform(30, 40, XMatrixOrder.Prepend);
      gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Prepend);
      gfx.RotateTransform(15, XMatrixOrder.Prepend);
#else
      gfx.TranslateTransform(30, 40, XMatrixOrder.Append);
      gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Append);
      gfx.RotateTransform(15, XMatrixOrder.Append);
#endif
      bool id = matrix.IsIdentity;
      matrix.Scale(2.0f, 2.0f, MatrixOrder.Prepend);
      //matrix.Translate(30, -50);
      matrix.Rotate(15, MatrixOrder.Prepend);
      //Matrix mtx = gfx.Transform.ToGdiMatrix();
      //gfx.Transform = matrix;

      gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
      gfx.DrawPolygon(properties.Pen2.Pen, GetPentagram(75, new PointF(150, 200)));
    }
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:38,代码来源:ShapesTransform.cs

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

示例9: Form1_Paint

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            using (Graphics g = e.Graphics)
            {
                // Создаем траекторию
                GraphicsPath path = new GraphicsPath();
                Rectangle rect = new Rectangle(20, 20, 150, 150);
                path.AddRectangle(rect);
                // Создаем градиентную кисть
                PathGradientBrush pgBrush =
                    new PathGradientBrush(path.PathPoints);
                // Уснинавливаем цвета кисти
                pgBrush.CenterColor = Color.Red;
                pgBrush.SurroundColors = new Color[] { Color.Blue };
                // Создаем объект Matrix
                Matrix X = new Matrix();
                // Translate
                X.Translate(30.0f, 10.0f, MatrixOrder.Append);
                // Rotate
                X.Rotate(10.0f, MatrixOrder.Append);
                // Scale
                X.Scale(1.2f, 1.0f, MatrixOrder.Append);
                // Shear
                X.Shear(.2f, 0.03f, MatrixOrder.Prepend);
                // Применяем преобразование к траектории и кисти
                path.Transform(X);
                pgBrush.Transform = X;
                // Выполняем визуализацию
                g.FillPath(pgBrush, path);
            }

        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:32,代码来源:Form1.cs

示例10: Draw

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

            // Scale:
            var m = new Matrix(1, 2, 3, 4, 0, 1);
            g.DrawString ("Original Matrix:", Font, Brushes.Black, 10, 10);
            DrawMatrix (m, g, 10, 10 + offset);
            g.DrawString ("Scale - Prepend:", Font, Brushes.Black, 10, 10 + 2 * offset);
            m.Scale (1, 0.5f, MatrixOrder.Prepend);
            DrawMatrix (m, g, 10, 10 + 3 * offset);
            g.DrawString ("Scale - Append:", Font, Brushes.Black, 10, 10 + 4 * offset);
            m = new Matrix (1, 2, 3, 4, 0, 1);
            m.Scale (1, 0.5f, MatrixOrder.Append);
            DrawMatrix (m, g, 10, 10 + 5 * offset);

            // Translation:
            m = new Matrix (1, 2, 3, 4, 0, 1);
            g.DrawString ("Translation - Prepend:", Font, Brushes.Black, 10, 10 + 6 * offset);
            m.Translate (1, 0.5f, MatrixOrder.Prepend);
            DrawMatrix (m, g, 10, 10 + 7 * offset);
            g.DrawString ("Translation - Append:", Font, Brushes.Black, 10, 10 + 8 * offset);
            // Reset m to the original matrix:
            m = new Matrix(1, 2, 3, 4, 0, 1);
            m.Translate (1, 0.5f, MatrixOrder.Append);
            DrawMatrix (m, g, 10, 10 + 9 * offset);

            m = new Matrix (1, 2, 3, 4, 0, 1);
            g.DrawString ("Rotation - Prepend:", Font, Brushes.Black, 10, 10 + 10 * offset);
            m.Rotate (45, MatrixOrder.Prepend);
            DrawMatrix (m, g, 10, 10 + 11 * offset);
            g.DrawString ("Rotation - Append:", Font, Brushes.Black, 10, 10 + 12 * offset);
            // Reset m to the original matrix:
            m = new Matrix (1, 2, 3, 4, 0, 1);
            m.Rotate (45, MatrixOrder.Append);
            DrawMatrix (m, g, 10, 10 + 13 * offset);

            // Rotation at (x = 1, y = 2):
            m = new Matrix (1, 2, 3, 4, 0, 1);
            g.DrawString ("Rotation At - Prepend:", Font, Brushes.Black, 10, 10 + 14 * offset);
            m.RotateAt (45, new Point (1, 2), MatrixOrder.Prepend);
            DrawMatrix (m, g, 10, 10 + 15 * offset);
            g.DrawString ("Rotation At - Append:", Font, Brushes.Black, 10, 10 + 16 * offset);
            m = new Matrix (1, 2, 3, 4, 0, 1);
            m.RotateAt (45, new Point (1, 2), MatrixOrder.Append);
            DrawMatrix(m, g, 10, 10 + 17 * offset);

            // Shear:
            m = new Matrix (1, 2, 3, 4, 0, 1);
            g.DrawString ("Shear - Prepend:", Font, Brushes.Black, 10, 10 + 18 * offset);
            m.Shear (1, 2, MatrixOrder.Prepend);
            DrawMatrix (m, g, 10, 10 + 19 * offset);
            g.DrawString ("Shear - Append:", Font, Brushes.Black, 10, 10 + 20 * offset);
            // Reset m to the original matrix:
            m = new Matrix (1, 2, 3, 4, 0, 1);
            m.Shear (1, 2, MatrixOrder.Append);
            DrawMatrix (m, g, 10, 10 + 21 * offset);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:59,代码来源:DrawingView.cs

示例11: Form2_Paint

        private void Form2_Paint(object sender, PaintEventArgs e)
        {
            //패스 그래디언트
            Point[] pts = { new Point(100, 0), new Point(0, 100), new Point(200, 100) };
            PathGradientBrush B = new PathGradientBrush(pts, WrapMode.Tile);
            e.Graphics.FillRectangle(B, ClientRectangle);

            //패스 그래디언트 끝
            //패스변형
            GraphicsPath Path = new GraphicsPath();
            Path.AddString("한글", new FontFamily("궁서"), 0, 100, new Point(10, 30), new StringFormat());
            //확장 후 외곽선 그리기
            Path.Widen(new Pen(Color.Black, 3));
            e.Graphics.DrawPath(Pens.Black, Path);

            //확장 후 채우기
            Path.Widen(new Pen(Color.Blue, 3));
            e.Graphics.DrawPath(Pens.Black, Path);

            //곡선 펴기
            Path.Flatten(new Matrix(), 12f);
            e.Graphics.DrawPath(Pens.Black, Path);

            //회전
            Matrix M = new Matrix();
            M.Rotate(-10);
            Path.Transform(M);
            e.Graphics.FillPath(Brushes.Blue, Path);

            //휘기
            RectangleF R = Path.GetBounds();
            PointF[] arPoint = new PointF[4];
            arPoint[0] = new PointF(R.Left, R.Top + 30);
            arPoint[1] = new PointF(R.Right, R.Top - 10);
            arPoint[2] = new PointF(R.Left + 10, R.Bottom - 10);
            arPoint[3] = new PointF(R.Right + 30, R.Bottom + 30);

            Path.Warp(arPoint, R);
            e.Graphics.FillPath(Brushes.Blue, Path);

            //클리핑

            //graphicspath path= new graphicspath();
            //path.fillmode = fillmode.winding;
            //path.addellipse(50, 10, 100, 80);
            //path.addellipse(20, 45, 160, 120);
            //e.graphics.fillpath(brushes.white, path);

            //e.graphics.setclip(path);

            //for (int y = 0; y < bottom; y+= 20)
            //{
            //    string str = "눈사람의 모양의클리핑 영역에 글자를 쓴것입니다";
            //    e.graphics.drawstring(str, font, brushes.blue, 0, y);
            //}

            //클리핑 끝
        }
开发者ID:sunnamkim,项目名称:doc,代码行数:58,代码来源:Form2.cs

示例12: full_transform

        public void full_transform(float ScX, float ScY, float ShX, float ShY, float RoAngle)
        {
            Matrix transform_matrix = new Matrix();
            transform_matrix.Scale(ScX, ScY, MatrixOrder.Append);
            transform_matrix.Shear(ShX, ShY, MatrixOrder.Append);
            transform_matrix.Rotate(RoAngle, MatrixOrder.Append);

            Transform(transform_matrix);
        }
开发者ID:MohamedNewhey,项目名称:IP-FCIS,代码行数:9,代码来源:ImageP.cs

示例13: Draw

        /// <summary>
        /// Draws the GameObject
        /// </summary>
        /// <param name="draw">Graphics to use for drawing</param>
        public void Draw(Graphics draw)
        {
            Matrix rotate = new Matrix();
            rotate.Rotate(m_rotation);

            Matrix oldTransform = draw.Transform;
            draw.Transform = rotate;
            PreformDraw(draw);
            draw.Transform = oldTransform;
        }
开发者ID:GGulati,项目名称:WF_Xtension,代码行数:14,代码来源:GameObject.cs

示例14: brickRotateNotification

 /// <summary>
 /// This method is called by the owner brick when the brick has rotated to allow
 /// the attached rulers to follow the brick.
 /// </summary>
 public void brickRotateNotification()
 {
     // compute the rotation matrix
     Matrix matrix = new Matrix();
     matrix.Rotate(mOwnerBrick.Orientation);
     // rotate all the anchor offset
     foreach (Anchor anchor in mAnchors)
         anchor.rotate(matrix);
     // then call the move notification
     brickMoveNotification();
 }
开发者ID:henrihs,项目名称:bluebrick-id-fork,代码行数:15,代码来源:RulerAttachementSet.cs

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


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