【问题标题】:UIImage gets rotated after croppingUIImage 在裁剪后被旋转
【发布时间】:2013-10-17 18:37:10
【问题描述】:

我在裁剪图像时遇到问题。我正在从文档文件夹中获取我的图像。裁剪后,我的图像在我的 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];

有人知道为什么我的图片会旋转吗?

【问题讨论】:

    标签: ios objective-c uiimageview uiimage crop


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      + (UIImage *)imageWithCGImage:(CGImageRef)imageRef 
                              scale:(CGFloat)scale 
                        orientation:(UIImageOrientation)orientation
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-04-11
        • 2018-10-22
        • 2012-07-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多