資源簡介
c# 圖片旋轉任意角度的函數
代碼片段和文件信息
#region?圖片旋轉任意角度的函數
///?
///?以逆時針為方向對圖像進行旋轉
///?
///?位圖流
///?旋轉角度[0360](前臺給的)
///?
public?Bitmap?Rotate(Bitmap?b?int?angle)
{
angle?=?angle?%?360;?//弧度轉換
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)));
//目標位圖
Bitmap?dsImage?=?new?Bitmap(W?H);
System.Drawing.Graphics?g?=?System.Drawing.Graphics.FromImage(dsImage);
g.Int
- 上一篇:bootstrap datetimepicker
- 下一篇:utf-8編碼和解碼
評論
共有 條評論