简体   繁体   中英

Xamarin android Camera2 - image preview getting stretched on 18:9 aspect ratio devices

On running the Camera2Basic in 18:9 screen aspect ratio devices, the image preview and captured image is getting stretched.

Device camera and camera2 basic side by side:

设备相机和 camera2 基本并排

How would i resolve this while keeping the preview ratio as 1.33? I tried setting the height of the texture preview by keeping the ratio 1.33 as constant and scaling the height with width as 1080.

    var ratio = 1.33;
    var scaledWidth = mPreviewSize.Height;
    var scaledHeight = (int)Java.Lang.Math.Round(scaledWidth * ratio);
    mTextureView.SetAspectRatio(scaledWidth, scaledHeight);

But result is still the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM