1

I am using Jcrop to try crop and image and save it.

http://deepliquid.com/content/Jcrop.html

Out of the demos this is the one i am implementing:

http://deepliquid.com/projects/Jcrop/demos.php?demo=handler

It gives me several coordinates x1, y1, x2, y2, x, y

once these are submited how do i use them to crop the image?

I have looked at http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing

is this the best way? and it is only using x, y, w and h

Rodrigo Guedes
  • 1,169
  • 2
  • 13
  • 27
Beginner
  • 28,539
  • 63
  • 155
  • 235

1 Answers1

2

Using Graphics.DrawImage is a better idea to crop the image in 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);
 }

From the source Thread

Community
  • 1
  • 1
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
  • whats in new rectangle?? not sure how this is suppose to work – Beginner Nov 28 '12 at 15:36
  • @Rahul Tripathi excuse me answer you are providing already in stackoverflow answer http://stackoverflow.com/questions/734930/how-to-crop-an-image-using-c by "Daniel LeCheminant" at least mentioning his name will be Good. – MMK Nov 28 '12 at 15:38
  • @MMK:- I am really sorry for that. I have just updated my answerr with the source thread. Hope that is ok? And thanx for updating me!! – Rahul Tripathi Nov 28 '12 at 15:41
  • :) at last credit should be given to person who has answered already. – MMK Nov 28 '12 at 15:41
  • @MMK:- rightly said!!! but it can be given to the person who has dig it out from the well!!! ;) – Rahul Tripathi Nov 28 '12 at 15:42
  • @Rahul Tripathi i remember because i used his solution for one of my tasks, an upvote for Daniel LeCheminant – MMK Nov 28 '12 at 15:43
  • @MMK:- Not a problem Sir!! My effort was to help to OP's question. If I dont get an upvote from you...thats alright!! – Rahul Tripathi Nov 28 '12 at 15:44