社区
C#
帖子详情
C#旋转图形的算法
whyabc
2009-03-31 04:30:42
我想用算法实现图形的旋转,不是用系统的,因为系统的不符合条件!
旋转的效果同PPT上的图形旋转相似,当鼠标放到图形上拖动时可以任意角度的旋转!
要求用C#实现!如果有用过DrawTools的,也可以交流一下!
...全文
955
12
打赏
收藏
C#旋转图形的算法
我想用算法实现图形的旋转,不是用系统的,因为系统的不符合条件! 旋转的效果同PPT上的图形旋转相似,当鼠标放到图形上拖动时可以任意角度的旋转! 要求用C#实现!如果有用过DrawTools的,也可以交流一下!
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用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;
}
抄别人的.
C#
坐标
旋转
算法
1、A点绕B点
旋转
X度,A点的新坐标
算法
。 2、两点坐标之间的距离
3维
图形
旋转
,使用
旋转
矩阵
算法
本3d模型在多方面查找出最合适的可用的程序改编而来,里面的3d模型是
C#
语言纯代码编写建立,无需任何模型插件,里面运行3维
旋转
矩阵对模型的空间位置坐标进行变换实现3维
旋转
,
算法
适用于任何语言,代码注释清晰,移植性好,可以将
算法
思想快速移植到各种开发平台(java、pathon等),不好用,找我!
C#
图形
处理大全源码(共60多种
算法
).rar
C#
图形
处理大全源码(共60多种
算法
)
c#
绘制3D可
旋转
旋转
矩形
3D矩形
旋转
,GDI+,另类的设计,以便不时之需。
WinForm(
C#
,.net3.5)三维
图形
旋转
练习(自己做的)
自己做的三维
图形
旋转
练习,由于本人数学一窍不通,所以难免有些尴尬....欢迎大家指点批评
C#
111,092
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章