Skip to content

Instantly share code, notes, and snippets.

@srgtuszy
Created March 28, 2011 14:41
Show Gist options
  • Save srgtuszy/890579 to your computer and use it in GitHub Desktop.
Save srgtuszy/890579 to your computer and use it in GitHub Desktop.
Easy image cropping with core graphics
//The image to be cropped
UIImage *image;
//The rect to which the image is going to be cropped
CGRect croppedRect = CGRectMake(0, 0, 40, 40);
//A simple call to Core Graphics function
CGImageRef img = CGImageCreateWithImageInRect(image.CGImage, croppedRect);
//There goes the cropped image
UIImage *result = [[UIImage alloc] initWithCGImage:img] autorelease];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment