0

裁剪图像时遇到问题。我正在从文档文件夹中获取我的图像。裁剪后,我的图像在我的 uiimageview 中逆时针旋转。请帮忙。这是我用于裁剪的方法:

- (UIImage *)croppedImage:(CGRect)bounds {
CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], bounds);
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
return croppedImage;
}

这是我用来调用该方法的代码:

CGRect cropRect = CGRectMake(0,0,imageview.size.width, imageview.size.height)
UIImage *croppedImage = [previewImage croppedImage:cropRect];

有谁知道为什么我的图像被旋转?

4

2 回答 2

0

CoreGraphics 图像框架没有考虑图像的 EXIF 数据,这可能就是您看到旋转的原因。尝试从未旋转的 UIImage 制作图像,它会正常工作,或者使用 CoreGraphics 库来解析 EXIF 数据以进行补偿。

于 2013-10-17T18:45:53.650 回答
0

根据 UIImage 类文档,您可能可以使用...

+ (UIImage *)imageWithCGImage:(CGImageRef)imageRef 
                        scale:(CGFloat)scale 
                  orientation:(UIImageOrientation)orientation
于 2013-10-17T18:46:53.043 回答