Search code examples
jqueryasp.netsystem.drawingjcrop

Landscape photos cropping incorrectly


Here is my code

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

if I choose image vertical, it works cool. But horizontal images cropping wrong areas. Every time. I'm using jcrop. I don't think jcrop cause this. But anybody think that. I can write my jcrop codes.

EDIT: SOLVED

I got it. This is, how is showing uploaded (not croped) image;

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

So, Jcrop is finding points on this 400px. But Orginal image is 800px.


Solution

  • I got it. This is, how is showing uploaded (not croped) image;

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

    So, Jcrop is finding points on this 400px. But Orginal image is 800px.