1

我正在使用 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

4

1 回答 1

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);
 }

从源线程

于 2012-11-28T15:34:07.673 回答