我希望有人能够解释这些值是如何相关的。 (我会将我的解释放在 self 回答中,看看它有多站得住脚)。
我正在开发一项功能,用户可以选择图像,然后提供一个方形裁剪边界,他们可以根据需要使用该边界。
所以,我正在使用 UIImagePickerController
与 allowsEditing
这些文档并不是特别有启发性 ->
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/