I use JCrop to crop Image . It works fine if I show an Actual Image to a user. But if I show Resize Image , not Actual Image , I get Co-ordinates from Resize Image . Then, how to draw an Image based on this? Here I go the way Image Saved Image .
In short, If Saved Image size, if for ie 715 * 350 , then I show it in a CSS-based Small Size popup. So, I get the Co-ordinates this Small Size Image . and I apply those Co-ordinates on the Main Image .
My code is:
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(); } } }
source share