I am using JCrop
to Crop Image
. It is working fine if I show Actual Image to user. But, If I show Resize Image
rather than Actual Image
then I am getting Co-ordinates
of Resize Image
.
Then, How do I Crop Image
based on it ? Here, I am passing Image
path of Saved Image
.
In short, If Saved Image
size if for i.e. 715 * 350
then I am showing it in popup in Small Size based on CSS. So, I will get Co-ordinates
of that Small Size Image
. and I am applying those Co-ordinates
on Main Image
.
My Code:
using (System.Drawing.Image OriginalImage = System.Drawing.Image.FromFile(Img))
{
using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(Width, Height))
{
bmp.SetResolution(OriginalImage.HorizontalResolution, OriginalImage.VerticalResolution);
using (System.Drawing.Graphics Graphic = System.Drawing.Graphics.FromImage(bmp))
{
Graphic.SmoothingMode = SmoothingMode.AntiAlias;
Graphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
Graphic.PixelOffsetMode = PixelOffsetMode.HighQuality;
Graphic.DrawImage(OriginalImage, new System.Drawing.Rectangle(0, 0, Width, Height), X, Y, Width, Height, System.Drawing.GraphicsUnit.Pixel);
MemoryStream ms = new MemoryStream();
bmp.Save(ms, OriginalImage.RawFormat);
ms.Close();
ms.Flush();
ms.Dispose();
return ms.GetBuffer();
}
}
}