博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
图像旋转
阅读量:6855 次
发布时间:2019-06-26

本文共 2331 字,大约阅读时间需要 7 分钟。

一个坐标点围绕任意中心点旋转--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///           /// 对一个坐标点按照一个中心进行旋转          ///           /// 中心点          /// 要旋转的点          /// 旋转角度,笛卡尔直角坐标          /// 
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);//置为此状态

 

转载地址:http://viyyl.baihongyu.com/

你可能感兴趣的文章
分享33个不容错过的免费社交图标集
查看>>
如果是你你会如何重新设计和定义维基百科(wikipedia)?
查看>>
ppp pap和chap 认证
查看>>
交换机的基本配置
查看>>
PHP结合Python的WEB开发技术
查看>>
华为:缺省路由:默认路由 default route
查看>>
K均值聚类算法的MATLAB实现
查看>>
php中sql语句
查看>>
linux中MySQL小结
查看>>
浅谈以人为本
查看>>
Programmer10载身心成长历程回顾
查看>>
记一次springboot下maven工程方式导入pom.xml首行报错
查看>>
匿名内部类,Object类
查看>>
Tomcat(2)配置Tomcat的虚拟主机 、日志
查看>>
Linux环境下编译安装Mysql
查看>>
Rsync+Inotify
查看>>
LNMP架构搭建
查看>>
功能表单之子功能集合字段类型的使用—JEPLUS软件快速开发平台
查看>>
eyoucms 后台能不能上传视频跟播放?
查看>>
MYSQL的主从复制与读写分离
查看>>