【问题标题】:confused by the UIImageOrientation of portrait/landscape mode photo被纵向/横向模式照片的 UIImageOrientation 弄糊涂了
【发布时间】:2013-07-29 10:33:42
【问题描述】:

我使用 ios 的系统相机拍摄了两张照片,一张是纵向模式,另一张是横向模式,然后我使用 imagePicker 在我的应用中挑选它们,如下所示:

-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

    UIImage* sourceImage = [info objectForKey:UIImagePickerControllerOriginalImage];


    UIImageOrientation imageOrientation = sourceImage.imageOrientation;
    NSLog(@"%d",imageOrientation);

}

请注意,我 NSLog 了我刚刚挑选的图像的 UIImageOrientation 值。 结果是 纵向模式照片的值为 3(代表 UIImageOrientationRight)而 横向模式照片的值为 0 (UIImageOrientationUp) 我只是不明白为什么。谁能解释一下?谢谢!

【问题讨论】:

标签: ios objective-c landscape-portrait uiimageorientation


【解决方案1】:

无论设备方向如何,iPhone 的相机都会保存照片,但它会向图像添加元信息以允许正确渲染此图像。 imageOrientation 描述了图像应该旋转多少度才能正确渲染。

【讨论】:

  • 感谢@Max K.!所以肖像照片的 UIImageOrientationRight 意味着系统必须将图像逆时针旋转 90 度才能正确渲染?
  • 是的,请查看UIImage 参考以获取更多信息developer.apple.com/library/ios/#documentation/UIKit/Reference/…。仔细阅读以了解这些常量的实际含义。
  • 它似乎保存为风景令人难以置信的混乱/奇怪?所以始终默认的纵向模式是 UIImageOrientationRight。我想。
猜你喜欢
  • 2022-01-23
  • 2019-01-12
  • 1970-01-01
  • 2013-04-18
  • 2014-08-14
  • 2016-02-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多