Objective-C iOS裁剪图像使用缩放?

我想要使​​用这个代码来允许用户缩放和裁剪他们的图像在我的应用程序: https : //github.com/iosdeveloper/ImageCropper/tree/master/Classes/ImageCropper

代码片段

float zoomScale = 1.0 / [scrollView zoomScale]; CGRect rect; rect.origin.x = [scrollView contentOffset].x * zoomScale; rect.origin.y = [scrollView contentOffset].y * zoomScale; rect.size.width = [scrollView bounds].size.width * zoomScale; rect.size.height = [scrollView bounds].size.height * zoomScale; CGImageRef cr = CGImageCreateWithImageInRect([[imageView image] CGImage], rect); UIImage *cropped = [UIImage imageWithCGImage:cr]; CGImageRelease(cr); [delegate imageCropper:self didFinishCroppingWithImage:cropped]; 

但是它并没有考虑到图片被旋转(我猜这是iPhone图片上的某种元数据)。 我不想让用户画一个矩形,因为我更喜欢这个界面。

有人能告诉我如何使它不旋转我的图像?

如果有帮助,我正在iOS 5和6中构build。

[编辑]此外,这是在Game Center应用程序中上传你的个人资料图片很好地完成。 任何人都知道我在哪里可以find的代码?

我在这里find了一个答案,帮助我做我想要的iOS:从UIImagePickerController相机中抓取静止图像并叠加

有兴趣的代码片段

 float zoomScale = 1.0 / [scrollView zoomScale]; CGRect rect; NSLog(@"contentOffset is :%f,%f",[scrollView contentOffset].x,[scrollView contentOffset].y); rect.origin.x = fabsf([scrollView contentOffset].x * zoomScale); rect.origin.y = fabsf([scrollView contentOffset].y * zoomScale); rect.size.width = fabsf([scrollView bounds].size.width * zoomScale); rect.size.height = fabsf([scrollView bounds].size.height * zoomScale); UIGraphicsBeginImageContextWithOptions( CGSizeMake( rect.size.width, rect.size.height), NO, 0.); [[imageView image] drawAtPoint:CGPointMake( -rect.origin.x, -rect.origin.y) blendMode:kCGBlendModeCopy alpha:1.]; UIImage *croppedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();