日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

图像旋转

發布時間:2024/10/12 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 图像旋转 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一個坐標點圍繞任意中心點旋轉--C#實現 分類: C#/ASP.net 重用代碼之C# 2011-07-19 20:23 1668人閱讀 評論(0) 收藏 舉報假設對圖片上任意點(x,y),繞一個坐標點(rx0,ry0)逆時針旋轉RotaryAngle角度后的新的坐標設為(x', y'),有公式:x'= (x - rx0)*cos(RotaryAngle) + (y - ry0)*sin(RotaryAngle) + rx0 ;y'=-(x - rx0)*sin(RotaryAngle) + (y - ry0)*cos(RotaryAngle) + ry0 ; [csharp] view plaincopy /// <summary> /// 對一個坐標點按照一個中心進行旋轉 /// </summary> /// <param name="center">中心點</param> /// <param name="p1">要旋轉的點</param> /// <param name="angle">旋轉角度,笛卡爾直角坐標</param> /// <returns></returns> private Point PointRotate(Point center, Point p1, double angle) { Point tmp = new Point(); double angleHude = angle * Math.PI / 180;/*角度變成弧度*/ double x1 = (p1.X - center.X) * Math.Cos(angleHude) + (p1.Y - center.Y ) * Math.Sin(angleHude) + center .X; double y1 = -(p1.X - center.X) * Math.Sin(angleHude) + (p1.Y - center.Y) * Math.Cos(angleHude) + center.Y; tmp.X = (int)x1; tmp.Y = (int)y1; return tmp; }

?

?

?

1 、旋轉e.Graphics.RotateTransform(30.0F, MatrixOrder.Prepend);2、平移e.Graphics.TranslateTransform(100.0F, 0.0F);3、縮放e.Graphics.ScaleTransform(3.0F, 1.0F, MatrixOrder.Append); 4、點坐標變換e.Graphics.TranslateTransform(40, 30);e.Graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.World, points);e.Graphics.ResetTransform();// Create array of two points.Point[] points = { new Point(0, 0), new Point(100, 50) };// Draw line connecting two untransformed points.e.Graphics.DrawLine(new Pen(Color.Blue, 3), points[0], points[1]);// Set world transformation of Graphics object to translate.e.Graphics.TranslateTransform(40, 30);// Transform points in array from world to page coordinates. e.Graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.World, points);// Reset world transformation. e.Graphics.ResetTransform();// Draw line that connects transformed points.e.Graphics.DrawLine(new Pen(Color.Red, 3), points[0], points[1]);5、選擇參數:將此變換參數放在已有的變換矩陣之后還是之前。MatrixOrder.Append//MatrixOrder.Prepend //----------------旋轉和平移的順序不一樣,得到的結果頁不一樣。6、輔助功能GraphicsState transState = e.Graphics.Save();//保存當前繪圖板狀態 e.Graphics.ResetTransform();//重置 e.Graphics.Restore(transState);//置為此狀態

?

轉載于:https://www.cnblogs.com/anbylau2130/p/3167612.html

總結

以上是生活随笔為你收集整理的图像旋转的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。