swift - `UIImagePickerControllerOriginalImage ` 、 `UIImagePickerControllerCropRect ` 和 `UIImagePickerControllerEditedImage` 有什么关系?

标签 swift uiimagepickercontroller

我希望有人能够解释这些值是如何相关的。 (我会将我的解释放在 self 回答中,看看它有多站得住脚)。

我正在开发一项功能,用户可以选择图像,然后提供一个方形裁剪边界,他们可以根据需要使用该边界。

所以,我正在使用 UIImagePickerControllerallowsEditing

这些文档并不是特别有启发性 ->

Specifies the cropping rectangle that was applied to the original image https://developer.apple.com/documentation/uikit/uiimagepickercontroller/infokey/1619150-croprect

我正在做边缘情况测试,所以我裁剪了某人发给我的全景图。这是我通过 print 转储数据时的相关结果:

"UIImagePickerControllerOriginalImage": <UIImage: 0x6000014aed80> size {4032, 3024} orientation 1 scale 1.000000,

"UIImagePickerControllerCropRect": NSRect: {{0, 0}, {3071.9999999999995, 2307.710144927536}},

"UIImagePickerControllerEditedImage": <UIImage: 0x6000014a2290> size {826, 620} orientation 0 scale 1.000000,

最佳答案

我的解释是:

获取 UIImagePickerControllerOriginalImage (4032, 3024),然后使用 UIImagePickerControllerCropRect 从原点裁剪它,剃掉 ~3072 x 2308 之外的任何内容。

然后最终图像返回为 (826, 620),我猜测裁剪后的法师已缩放到这些值。 (三者的长宽比看起来非常一致)

关于swift - `UIImagePickerControllerOriginalImage ` 、 `UIImagePickerControllerCropRect ` 和 `UIImagePickerControllerEditedImage` 有什么关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54718711/

相关文章:

ios - 使用 NSLayoutAnchor 在两个标签之间创建约束?

ios - SWIFT:修改某些解析列/对于某些用户而言出现问题。 != 访问控制列表

ios - 如何在 Swift 3.1 中使用 UIImagePickerControllerDelegate 获取目录(本地路径)?

video - "video recording stopped the maximum length for this video has been reached"Xcode iPhone

ios - 尺寸错误的 UIImagePickerController View

ios - 桥接 NSImage 和 UIImage

swift - 如何在 SceneKit 中加载 Gigapixel 图像作为 Material ?

unit-testing - XCTest 中的 Swift 模拟类

iphone - 如何在内存警告 viewDidUnload 后保留值

iphone - UIImagePickerController PresentViewController - ios7 中的状态栏问题