Is there a built in function in objective-c to do image cropping like the one in iOS photo gallery? I have tried enabling editing in UIImagePickerController, but it doesn't do the same. Thanks!
Asked
Active
Viewed 3,510 times
2 Answers
2
there are quite a few ways to crop images using the Core Graphics functions, the most basic one would be:
CGRect cropRect = CGRectMake(0, 0, 100, 100);
CGImageRef cropped_img = CGImageCreateWithImageInRect(yourUIImage.CGImage, cropRect)

Peter Sarnowski
- 11,900
- 5
- 36
- 33
-
so if I want the user to define the portion of image they want cropped, I suppose I should implement UIGestureRecognizers? – atnatn Mar 02 '12 at 08:19
-
Yeah, there's a pretty good tutorial here: http://www.icodeblog.com/2010/10/14/working-with-uigesturerecognizers/ – Peter Sarnowski Mar 02 '12 at 08:24
0
This is no built in function. The way to do it would be to take the image an get a frame around the portion of the image you want.
-
that's too bad. I was hoping for an easy way out :p Thank you for confirming that. – atnatn Mar 02 '12 at 08:33