[愚翁专栏]图像旋转的C#示例
2006-05-18 19:53
316 查看
private void RotateTransform_Click(object sender, System.EventArgs e)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Graphics graphics=this.CreateGraphics();
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
graphics.Clear(Color.White);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//装入图片
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Bitmap image=new Bitmap("nemo.bmp");
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//获取当前窗口的中心点
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Rectangle rect=new Rectangle(0,0,this.ClientSize.Width,this.ClientSize.Height);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
PointF center=new PointF(rect.Width/2,rect.Height/2);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
float offsetX=0;
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
float offsetY=0;
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
offsetX=center.X-image.Width/2;
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
offsetY=center.Y-image.Height/2;
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//构造图片显示区域:让图片的中心点与窗口的中心点一致
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
RectangleF picRect=new RectangleF(offsetX,offsetY,image.Width,image.Height);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
PointF Pcenter=new PointF(picRect.X+picRect.Width/2,
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
picRect.Y+picRect.Height/2);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//让图片绕中心旋转一周
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
for(int i=0;i<361;i+=10)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// 绘图平面以图片的中心点旋转
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
graphics.TranslateTransform(Pcenter.X, Pcenter.Y);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
graphics.RotateTransform(i);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//恢复绘图平面在水平和垂直方向的平移
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
graphics.TranslateTransform(-Pcenter.X, -Pcenter.Y);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//绘制图片并延时
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
graphics.DrawImage(image,picRect);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Thread.Sleep(100);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//重置绘图平面的所有变换
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
graphics.ResetTransform();
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
}
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=638397
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Graphics graphics=this.CreateGraphics();
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
graphics.Clear(Color.White);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//装入图片
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Bitmap image=new Bitmap("nemo.bmp");
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//获取当前窗口的中心点
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Rectangle rect=new Rectangle(0,0,this.ClientSize.Width,this.ClientSize.Height);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
PointF center=new PointF(rect.Width/2,rect.Height/2);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
float offsetX=0;
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
float offsetY=0;
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
offsetX=center.X-image.Width/2;
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
offsetY=center.Y-image.Height/2;
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//构造图片显示区域:让图片的中心点与窗口的中心点一致
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
RectangleF picRect=new RectangleF(offsetX,offsetY,image.Width,image.Height);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
PointF Pcenter=new PointF(picRect.X+picRect.Width/2,
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
picRect.Y+picRect.Height/2);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//让图片绕中心旋转一周
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
for(int i=0;i<361;i+=10)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// 绘图平面以图片的中心点旋转
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
graphics.TranslateTransform(Pcenter.X, Pcenter.Y);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
graphics.RotateTransform(i);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//恢复绘图平面在水平和垂直方向的平移
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
graphics.TranslateTransform(-Pcenter.X, -Pcenter.Y);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//绘制图片并延时
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
graphics.DrawImage(image,picRect);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Thread.Sleep(100);
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//重置绘图平面的所有变换
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
graphics.ResetTransform();
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://jhtchina.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
}
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=638397
相关文章推荐
- 图像旋转的C#示例
- 图像旋转的C#示例
- c# 实现图像180度旋转
- 使用C#旋转图像
- C#图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果,滤波,图像截取) 对图片的处理 : 亮度调整 抓屏 翻转 随鼠标画矩形
- c#的图像处理(直方图;反差,密度的四边圆补偿示例)
- c#图像旋转和翻转
- 黄聪:C#窗体程序OpenGL绘制立方体多边形旋转示例教程(VS2008,Winform)
- C#下PICTRUEBOX拖动残影,双缓存无效!——接( 图像处理(旋转)_基于EMGUCV(一))
- c#的图像处理(直方图;反差,密度的四边圆补偿示例)
- 黄聪:C#图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果) (转)
- C#图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果)
- C# 图像旋转
- [愚翁专栏]如何用C#写一个简单的Login窗口
- [愚翁专栏]如何在窗体以外的地方绘制图像
- C# (GDI+相关) 图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果)
- 黄聪:C#图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果) (转)
- C# Graphics图像旋转与绘图总结
- C#控制图像旋转和翻转的方法
- C#图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果)