日期:2014-05-18  浏览次数:21151 次

c#如何裁剪图片并保存成新的图片
c#如何裁剪图片并保存成新的图片,要是有较详细代码更好。谢谢
裁剪方式需要是能固定一个长宽比例的矩形。

------解决方案--------------------
看孟老大的回复,源代码
http://topic.csdn.net/u/20120329/12/40b4a202-db5f-46a4-8d28-dd4f113755e5.html?seed=714847456&r=78069715#r_78069715
------解决方案--------------------
参考一下这段合不合适
int width = this.groupBox1.Width+3;
int height = this.groupBox1.Height;

Bitmap myImage = new Bitmap(width, height);
Graphics g = Graphics.FromImage(myImage);

g.CopyFromScreen(new Point(this.Location.X + 180, this.Location.Y + 83), new Point(0, 0), new Size(width, height));
IntPtr dc1 = g.GetHdc();
g.ReleaseHdc(dc1);
myImage.Save(string.Format("{0}{1}_2.jpg", AppDomain.CurrentDomain.BaseDirectory, DateTime.Now.ToString("yyyyMMddHHmmss")));