问题
Imagine I have an UIImage. I need to rotate and then crop it in the global coordinate system (not UIImage coordinate system). So the resulted image will be cropped and rotated.
How can I do this? CGImageCreateWithImageInRect will crop image only in the image-relative coordinates.

PS Answer in comments. You should use CIImage.
回答1:
Maybe this can help
//init
CIImage *image = [CIImage imageWithCGImage:CGImageRef];
//rotation
CIImage *rotatedImage = [image imageByApplyingTransform:someTransform];
//crop
CIImage *croppedImage = [rotatedImage imageByCroppingToRect:someRect];
回答2:
For rotation, you need to apply
CGAffineTransform transform = CGAffineTransformTranslate(self.imageView.transform,deltaX,deltaY);
transform = CGAffineTransformRotate(transform, recognizer.rotation);
transform = CGAffineTransformTranslate(transform, -deltaX, -deltaY);
self.imageView.transform = transform;
For cropping, simply change the frame of your imageView
To convert local coordinates'image, simply use :
// converts a point in local coordinate space to window coordinates.
[self.imageView convertPoint:localPosition toView:nil];
// use this method to calculate a view's origin in window space like this:
[self.imageView convertPoint:self.imageView.frame.origin toView:nil];
If you plan to integrate an image editor to your app, you may wish to consider using a third party like : https://github.com/heitorfr/ios-image-editor
来源:https://stackoverflow.com/questions/25822730/rotate-and-crop-uiimage