Created
March 28, 2011 14:41
-
-
Save srgtuszy/890579 to your computer and use it in GitHub Desktop.
Easy image cropping with core graphics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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