我正在尝试使用该方法正确旋转UIImage
。我有几张以各种设备方向拍摄的测试照片;照片在照片应用程序中正确显示。的文档说:ALAssetRepresentation
fullScreenImage
fullScreenImage
在 iOS 5 及更高版本中,此方法返回完全裁剪、旋转和调整的图像——与用户在照片或图像选择器中看到的完全一样。
要从 中创建正确旋转的
UIImage
对象CGImage
,请使用imageWithCGImage:scale:orientation:
orinitWithCGImage:scale:orientation:
,并传递orientation
and的值scale
。
给定文档,我的代码如下所示:
ALAssetRepresentation *rep = [asset defaultRepresentation];
UIImage *img = [UIImage
imageWithCGImage:[rep fullScreenImage]
scale:[rep scale]
orientation:[rep orientation]];
但由此产生UIImage
的 ' 旋转是错误的。当我替换[rep orientation]
为 时UIImageOrientationUp
,该图像适用于所有测试照片。显然,我在犹豫是否坚持使用这个“解决方案”,因为它感觉就像是一个 hack。我究竟做错了什么?