Android Camera Preview on a square screen stretched

后端 未结 1 545
一整个雨季
一整个雨季 2020-12-11 06:39

I\'m building an app for Android but The device do have a square screen. The screen is 320x320 and the camera app use the SurfaceView to show the preview as below :

相关标签:
1条回答
  • 2020-12-11 07:18

    The solution which i have figured out is:

    1)-Keep surface view full screen,so that is doesn't stretch.

    2)-Put a view over surfaceview with full opacity.So that is looks like camera is already squared.

    3)-After capturing image or video,you will have to crop them.

    For video you have to use some video processing library like javacv.Using this library you can extract video frames,convert them to bitmap,crop bitmap in square and then re-encode into video.

    To get accurate results you will need to play around with different techniques like zooming camera during capture etc. according to your needs.

    Original Image:

    Squared Image:

    0 讨论(0)
提交回复
热议问题