1

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!

j0k
  • 22,600
  • 28
  • 79
  • 90
atnatn
  • 238
  • 5
  • 13

2 Answers2

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.

This question should help you

Community
  • 1
  • 1
Amit Shah
  • 4,176
  • 2
  • 22
  • 26