相机胶卷图像大于相机预览

时间:2020-04-11 10:23:47

标签: ios swift avfoundation avcapture

我正在创建相机应用。我可以拍摄一张图像,并将该图像传递回视图控制器以显示该图像。它还保存到相机胶卷中。 如果我将带有相机预览的图像与保存的图像进行比较,则似乎相机预览有点放大了。

相机预览中的图像: enter image description here

图库图片: enter image description here

这是我到目前为止与相机预览无关的代码:

getCityList() {
    const { StoreInfo } = this.props;
    this.emptyCityList();
    return StoreInfo.map((StoreInfo, index) => {
        if (this.cityPushCheck(StoreInfo.city)) {
            CITY_LIST.push({
                id: index, label: StoreInfo.city, value: StoreInfo.city, disabled: false
            });
        }
    });
}

cityPushCheck(cityLabel) {
    const cityFromList = CITY_LIST.find(city => city.label === cityLabel);
    return cityFromList === undefined;
} 

如何使相机预览的尺寸与保存的图像相同?

1 个答案:

答案 0 :(得分:0)

罪魁祸首是videoGravity设置。 .resizeAspectFill将调整预览的大小以填满整个视图,即使那意味着裁剪内容。

如果要查看整个框架,请将其设置为.resizeAspect。不过,这会引入黑条。