【问题标题】:Landscape photos cropping incorrectly风景照片裁剪不正确
【发布时间】:2012-04-19 12:41:30
【问题描述】:

这是我的代码

using (var photo = System.Drawing.Image.FromFile(Server.MapPath(src)))
using (var result = new Bitmap(width, height, photo.PixelFormat))
{
    result.SetResolution(
    photo.HorizontalResolution,
    photo.VerticalResolution);

    using (var g = Graphics.FromImage(result))
    {
        g.InterpolationMode = InterpolationMode.HighQualityBicubic;

        g.DrawImage(photo,
                new Rectangle(0, 0, width, height),
                new Rectangle(x, y, width, height),
                GraphicsUnit.Pixel);

        photo.Dispose();
        result.Save(Server.MapPath(src));
    }
}

如果我选择垂直图像,它会很酷。但是水平图像裁剪了错误的区域。每次。我正在使用 jcrop。我不认为 jcrop 导致这个。但任何人都这么认为。我可以编写我的 jcrop 代码。

编辑:已解决

我明白了。这是,如何显示上传(未裁剪)的图像;

<img src="blabla.jpg" width="400px" />

所以,Jcrop 正在这 400 像素上寻找点。但是原始图像是800px。

【问题讨论】:

  • 解决您自己的问题的正确方法是在下面发布答案。接受你自己的答案是完全没问题的。

标签: jquery asp.net system.drawing jcrop


【解决方案1】:

我明白了。这是,如何显示上传(未裁剪)的图像;

<img src="blabla.jpg" width="400px" />

所以,Jcrop 正在这 400 像素上寻找点。但是原始图像是800px。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-14
    • 1970-01-01
    • 1970-01-01
    • 2012-11-18
    • 2016-02-08
    • 1970-01-01
    相关资源
    最近更新 更多