資源簡(jiǎn)介
c# 圖片旋轉(zhuǎn)任意角度的函數(shù)
代碼片段和文件信息
#region?圖片旋轉(zhuǎn)任意角度的函數(shù)
///?
///?以逆時(shí)針為方向?qū)D像進(jìn)行旋轉(zhuǎn)
///?
///?位圖流
///?旋轉(zhuǎn)角度[0360](前臺(tái)給的)
///?
public?Bitmap?Rotate(Bitmap?b?int?angle)
{
angle?=?angle?%?360;?//弧度轉(zhuǎn)換
double?radian?=?angle?*?Math.PI?/?180.0;
double?cos?=?Math.Cos(radian);
double?sin?=?Math.Sin(radian);
//原圖的寬和高
int?w?=?b.Width;
int?h?=?b.Height;
int?W?=?(int)(Math.Max(Math.Abs(w?*?cos?-?h?*?sin)?Math.Abs(w?*?cos?+?h?*?sin)));
int?H?=?(int)(Math.Max(Math.Abs(w?*?sin?-?h?*?cos)?Math.Abs(w?*?sin?+?h?*?cos)));
//目標(biāo)位圖
Bitmap?dsImage?=?new?Bitmap(W?H);
System.Drawing.Graphics?g?=?System.Drawing.Graphics.FromImage(dsImage);
g.Int
- 上一篇:bootstrap datetimepicker
- 下一篇:utf-8編碼和解碼
評(píng)論
共有 條評(píng)論