【问题标题】:how to crop an image如何裁剪图像
【发布时间】:2012-11-16 12:13:07
【问题描述】:

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

【问题讨论】:

    标签: c# jquery crop jcrop


    【解决方案1】:

    使用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

    【讨论】:

    • 新矩形中有什么??不确定这是如何工作的
    • @Rahul Tripathi 请问您已经在 stackoverflow 回答 stackoverflow.com/questions/734930/how-to-crop-an-image-using-c 由“Daniel LeCheminant”提供,至少提及他的名字会很好。
    • @MMK:- 我真的很抱歉。我刚刚用源线程更新了我的回答者。希望没问题?谢谢你更新我!!
    • :) 最后的功劳应该给已经回答的人。
    • @MMK:- 说得对!!!但是可以送给从井里挖出来的人!!! ;)
    猜你喜欢
    • 2017-05-22
    • 2010-11-04
    • 2014-05-07
    • 1970-01-01
    • 2022-01-23
    • 2023-04-02
    • 1970-01-01
    • 2012-07-31
    相关资源
    最近更新 更多