ios – UIDmageOrientation到CIDetectorImageOrientation

ios – UIDmageOrientation到CIDetectorImageOrientation,第1张

概述使用CIDetector检测图像中的面,您需要指定根据文档在TIFF和EXIF规范中指定的图像方向,这意味着它与UI ImageOrientation不同. Google为我找到了以下功能,我尝试了但是发现它似乎不正确,或者我可能错过了其他的东西,因为有时候取向是关闭的.有谁知道发生了什么?似乎只要从iDevice导出照片,然后导入到另一个iDevice,方向信息就会丢失/更改,从而导致某些方向不 使用CIDetector检测图像中的面,您需要指定根据文档在TIFF和EXIF规范中指定的图像方向,这意味着它与UI ImageOrIEntation不同. Google为我找到了以下功能,我尝试了但是发现它似乎不正确,或者我可能错过了其他的东西,因为有时候取向是关闭的.有谁知道发生了什么?似乎只要从IDevice导出照片,然后导入到另一个IDevice,方向信息就会丢失/更改,从而导致某些方向不匹配. @H_301_7@

@H_301_7@

- (int) MetadataOrIEntationForUIImageOrIEntation:(UIImageOrIEntation)orIEntation{    switch (orIEntation) {        case UIImageOrIEntationUp: // the picture was taken with the home button is placed right            return 1;        case UIImageOrIEntationRight: // bottom (portrait)            return 6;        case UIImageOrIEntationDown: // left            return 3;        case UIImageOrIEntationleft: // top            return 8;        default:            return 1;    }}
解决方法 要覆盖所有这些,并且没有幻数分配(CGImagePropertyOrIEntation的原始值可能在将来发生变化,虽然它不太可能……仍然是一个好习惯)你应该包括ImageIO框架并使用实际的常量: @H_301_7@

@H_301_7@

#import <ImageIO/ImageIO.h>- (CGImagePropertyOrIEntation)CGImagePropertyOrIEntation:(UIImageOrIEntation)orIEntation{    switch (orIEntation) {        case UIImageOrIEntationUp:            return kCGImagePropertyOrIEntationUp;        case UIImageOrIEntationUpMirrored:            return kCGImagePropertyOrIEntationUpMirrored;        case UIImageOrIEntationDown:            return kCGImagePropertyOrIEntationDown;        case UIImageOrIEntationDownMirrored:            return kCGImagePropertyOrIEntationDownMirrored;        case UIImageOrIEntationleftMirrored:            return kCGImagePropertyOrIEntationleftMirrored;        case UIImageOrIEntationRight:            return kCGImagePropertyOrIEntationRight;        case UIImageOrIEntationRightmirrored:            return kCGImagePropertyOrIEntationRightmirrored;        case UIImageOrIEntationleft:            return kCGImagePropertyOrIEntationleft;    }}
总结

以上是内存溢出为你收集整理的ios – UIDmageOrientation到CIDetectorImageOrientation全部内容,希望文章能够帮你解决ios – UIDmageOrientation到CIDetectorImageOrientation所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1065035.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存