图片的切割和旋转怎样实现到一起
解决方案 »
- 关于使用Visual Studio 2010 实现程序打包功能
- 急!!!gridview更新的时候应该注意些那些呀
- Cookies问题,新人求救。。。。。
- ListBox1.Items.Add(...) 貌似LISTBOX每个ITEM的TEXT和VALUE的值是一样的
- 关于treeview控件复选框
- gridview自定义表头后 为何数据格式不能对齐
- 谁可以发给我一个atlas的安装包呢?
- asp.net登陆问题,在线等。。
- Asp.net中,有没有根据Id从List<Id>集合筛选出来需要的列表集合(不用循环筛选)???求解
- 还是关于datagrid:9
- WIN7 IIS问题,VS2008运行程序出错。如果在IIS中没有将虚拟目录Web.Config录配置为应用程序,导致错误。
- 大家都在说12306的恶心,那就看看csdn的搜索功能吧
/// <summary>
/// 图像切割
/// </summary>
/// <param name="url">图像文件名称</param>
/// <param name="width">切割后图像宽度</param>
/// <param name="height">切割后图像高度</param>
/// <param name="savePath">切割后图像文件保存路径</param>
/// <param name="fileExt">切割后图像文件扩展名</param>
public static void Cut(string url, int width, int height, string savePath, string fileExt, string logofile)
{
Bitmap bitmap = new Bitmap(url);
Decimal MaxRow = Math.Ceiling((Decimal)bitmap.Height / height);
Decimal MaxColumn = Math.Ceiling((decimal)bitmap.Width / width);
for (decimal i = 0; i < MaxRow; i++)
{
for (decimal j = 0; j < MaxColumn; j++)
{
string filename = i.ToString() + "," + j.ToString() + "." + fileExt;
Bitmap bmp = new Bitmap(width, height); for (int offsetX = 0; offsetX < width; offsetX++)
{
for (int offsetY = 0; offsetY < height; offsetY++)
{
if (((j * width + offsetX) < bitmap.Width) && ((i * height + offsetY) < bitmap.Height))
{
bmp.SetPixel(offsetX, offsetY, bitmap.GetPixel((int)(j * width + offsetX), (int)(i * height + offsetY)));
}
}
}
Graphics g = Graphics.FromImage(bmp);
g.DrawString("ss", new Font("黑体", 20), new SolidBrush(Color.FromArgb(70, Color.WhiteSmoke)), 60, height / 2);//加水印
ImageFormat format = ImageFormat.Png;
switch (fileExt.ToLower())
{
case "png":
format = ImageFormat.Png;
break;
case "bmp":
format = ImageFormat.Bmp;
break;
case "gif":
format = ImageFormat.Gif;
break; }
bmp.Save(savePath + "\\" + filename, format);
}
} }/// <summary>
/// 自动旋转
/// /// </summary>
/// /// <param name="bmp">Bitmap 对象</param>
/// /// <param name="picBox">PictureBox 对象</param>
public static void XuanZhuan(Bitmap MyBitmap, PictureBox picBox)
{
Graphics g = picBox.CreateGraphics();
float MyAngle = 0;//旋转的角度
while (MyAngle < 360)
{
TextureBrush MyBrush = new TextureBrush(MyBitmap);
picBox.Refresh();
MyBrush.RotateTransform(MyAngle);
g.FillRectangle(MyBrush, 0, 0, MyBitmap.Width, MyBitmap.Height);
MyAngle += 0.5f; System.Threading.Thread.Sleep(50);
}
}