社区
C#
帖子详情
C#旋转图形的算法
whyabc
2009-03-31 04:30:42
我想用算法实现图形的旋转,不是用系统的,因为系统的不符合条件!
旋转的效果同PPT上的图形旋转相似,当鼠标放到图形上拖动时可以任意角度的旋转!
要求用C#实现!如果有用过DrawTools的,也可以交流一下!
...全文
945
12
打赏
收藏
C#旋转图形的算法
我想用算法实现图形的旋转,不是用系统的,因为系统的不符合条件! 旋转的效果同PPT上的图形旋转相似,当鼠标放到图形上拖动时可以任意角度的旋转! 要求用C#实现!如果有用过DrawTools的,也可以交流一下!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
12 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
chadguo
2009-06-02
打赏
举报
回复
在一个画图面板上面,我写到可以旋转,但是旋转之后句柄计算就不对了
whyabc
2009-04-01
打赏
举报
回复
顶一下
whyabc
2009-03-31
打赏
举报
回复
这也是一种方法,但这样实现起来很麻烦的,我需要重新设计与写代码!
dyshadow
2009-03-31
打赏
举报
回复
不同的图形画在不同的BITMAP上,旋转的话就旋转自己的BITMAP,这个方法如何?
whyabc
2009-03-31
打赏
举报
回复
顶一下
whyabc
2009-03-31
打赏
举报
回复
这样当然是可以旋转图形,但我这的情况是一个画板上有多个图形,这样会不会让画板上的所有图形都旋转呢?
zgke
2009-03-31
打赏
举报
回复
晕~~我说算坐标..你真计算去了..
Graphics _Graphics = this.CreateGraphics();
GraphicsPath _Path =new GraphicsPath();
_Path.AddRectangle(new Rectangle(0,0,100,100));
Region _Region = new Region(_Path);
Matrix _Mtrx = new Matrix();
_Mtrx.Rotate(30); //30度
_Region.Transform(_Mtrx);
_Graphics.FillRegion(Brushes.Yellow, _Region);
使用 Matrix 和 Region 做做看
yeniao5203
2009-03-31
打赏
举报
回复
帮定
whyabc
2009-03-31
打赏
举报
回复
是呀,是需要坐标点!
rect是图形的坐标和大小
int left = rect.Left;
int right = rect.Right;
int bottom = rect.Bottom;
int top = rect.Top;
int x = right;
int y = top;
int xcenter = (right - left + 1) / 2 + left;
int ycenter = (bottom - top + 1) / 2 + top;
double sinA = Math.Cos(angle);
double cosA = Math.Sin(angle);
double xNew = (x - xcenter) * cosA + (y - ycenter) * sinA + xcenter;
double yNew = -(x - xcenter) * sinA + (y - ycenter) * cosA + ycenter;
rect.X = (int)Math.Round(xNew);
rect.Y = (int)Math.Round(yNew);
this.Refresh();
这样得到的好像不对!有没有高手指教一下!
zgke
2009-03-31
打赏
举报
回复
哪个可能需要计算坐标点了.
whyabc
2009-03-31
打赏
举报
回复
我说的意思是图形,不是图片!
zgke
2009-03-31
打赏
举报
回复
/// <summary>
/// 任意角度旋转
/// </summary>
/// <param name="bmp">原始图Bitmap </param>
/// <param name="angle">旋转角度 </param>
/// <param name="bkColor">背景色 </param>
/// <returns>输出Bitmap </returns>
public static Bitmap ImageRotate(Bitmap p_Image, float p_Angle, Color p_BlackColor)
{
int _Width = p_Image.Width + 2;
int _Height = p_Image.Height + 2;
PixelFormat _BitmapPixelFormat = PixelFormat.Format32bppArgb;
if (p_BlackColor != Color.Transparent) _BitmapPixelFormat = p_Image.PixelFormat;
Bitmap _OldBitmap = new Bitmap(_Width, _Height, _BitmapPixelFormat);
Graphics _Graphics = Graphics.FromImage(_OldBitmap);
_Graphics.Clear(p_BlackColor);
_Graphics.DrawImageUnscaled(p_Image, 1, 1);
_Graphics.Dispose();
GraphicsPath _Path = new GraphicsPath();
_Path.AddRectangle(new RectangleF(0f, 0f, _Width, _Height));
Matrix _Mtrx = new Matrix();
_Mtrx.Rotate(p_Angle);
RectangleF _Rect = _Path.GetBounds(_Mtrx);
Bitmap _NewBitmap = new Bitmap((int)_Rect.Width, (int)_Rect.Height, _BitmapPixelFormat);
_Graphics = Graphics.FromImage(_NewBitmap);
_Graphics.Clear(p_BlackColor);
_Graphics.TranslateTransform(-_Rect.X, -_Rect.Y);
_Graphics.RotateTransform(p_Angle);
_Graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
_Graphics.DrawImageUnscaled(_OldBitmap, 0, 0);
_Graphics.Dispose();
_OldBitmap.Dispose();
return _NewBitmap;
}
抄别人的.
3维
图形
旋转
,使用
旋转
矩阵
算法
本3d模型在多方面查找出最合适的可用的程序改编而来,里面的3d模型是
C#
语言纯代码编写建立,无需任何模型插件,里面运行3维
旋转
矩阵对模型的空间位置坐标进行变换实现3维
旋转
,
算法
适用于任何语言,代码注释清晰,...
C#
实现的计算机
图形
学基本绘图
算法
此外还实现了对
图形
的平移、
旋转
和缩放三种基本操作。其中缩放操作提供了普通模式与智能模式,使用后者可以消除普通模式缩放时产生的像素稀疏以及锯齿化现象。同时新版本对操作界面进行了改进和优化。
C#
二维三维
图形
绘制工程实例宝典 随书光盘
第二部分 二维
图形
的基本
算法
第4章 二维矩阵和变换 82 4.1 矩阵基础和变换 82 4.2 齐次坐标 82 4.2.1 齐次坐标中的缩放 83 4.2.2 齐次坐标中的平移 83 4.2.3 齐次坐标中的
旋转
84 4.2.4 变换组合 85 4.2.5 ...
C#
图像几何运算(平移 镜像 缩放
旋转
)
C#
编程实现图像的平移、镜像、缩放、
旋转
,附带窗口的例图!
计算机
图形
学 二维
图形
变换
使用
C#
实现计算机
图形
学中二维
图形
的平移、
旋转
、缩放等
算法
,界面友好,功能完善
C#
110,536
社区成员
642,578
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章