I\'ve got some code that resizes an image so I can get a scaled chunk of the center of the image - I use this to take a UIImage
and return a small, square repre
To crop retina images while keeping the same scale and orientation, use the following method in a UIImage category (iOS 4.0 and above):
- (UIImage *)crop:(CGRect)rect {
if (self.scale > 1.0f) {
rect = CGRectMake(rect.origin.x * self.scale,
rect.origin.y * self.scale,
rect.size.width * self.scale,
rect.size.height * self.scale);
}
CGImageRef imageRef = CGImageCreateWithImageInRect(self.CGImage, rect);
UIImage *result = [UIImage imageWithCGImage:imageRef scale:self.scale orientation:self.imageOrientation];
CGImageRelease(imageRef);
return result;
}