[英]UIImage gets rotated after cropping
裁剪圖像時出現問題。 我正在從文檔文件夾中獲取圖像。 裁剪后,我的圖像在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];
有人知道為什么我的圖像旋轉嗎?
CoreGraphics Image框架未考慮圖像的EXIF數據,這可能就是您看到旋轉的原因。 嘗試使用未旋轉的UIImage制作圖像,它將正常工作,或者嘗試使用CoreGraphics庫解析EXIF數據進行補償。
根據UIImage類文檔,您可能可以使用...
+ (UIImage *)imageWithCGImage:(CGImageRef)imageRef
scale:(CGFloat)scale
orientation:(UIImageOrientation)orientation
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.