如何裁剪图像

时间:2012-11-28 15:28:10

标签: c# jquery crop jcrop

我正在使用Jcrop尝试裁剪和图像并保存。

http://deepliquid.com/content/Jcrop.html

在演示中,这是我正在实施的:

http://deepliquid.com/projects/Jcrop/demos.php?demo=handler

它给出了几个坐标x1,y1,x2,y2,x,y

一旦这些被提交,我如何使用它们来裁剪图像?

我看过http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing

这是最好的方法吗?它只使用x,y,w和h

1 个答案:

答案 0 :(得分:2)

使用Graphics.DrawImage更好的方法是在c#

中裁剪图像
Rectangle cropRect = new Rectangle(...);
Bitmap src = Image.FromFile(fileName) as Bitmap;
Bitmap target = new Bitmap(cropRect.Width, cropRect.Height);

 using(Graphics g = Graphics.FromImage(target))
 {
  g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height), 
                cropRect,                        
                GraphicsUnit.Pixel);
 }

来自来源Thread

相关问题