About stretching of user-defined camera preview interface in Android

About stretching the user-defined camera preview interface

1. The main reason for the deformation is that the rotation angle of the camera preview interface is different from the mounting angle of the camera. 2. The direction set by our activity is the vertical screen, which is the natural direction of the mobile phone, so the width is shorter than the height. 3. Angle: the so-called angle of the screen and camera refers to the angle rotated relative to the natural direction, The current direction can be obtained according to the rotation angle. 4. If the mobile phone is a vertical screen, the natural angle is 0, but the camera rotates 90 degrees counterclockwise, then it is normal if we set it to rotate 90 degrees clockwise. When the phone is horizontal, the camera returns to 0 degrees. If it is set to rotate 90 degrees clockwise, it will rotate back

How to set the preview interface to be consistent with the real scene? Official documents:

First, get the size list of mobile phone support preview, and return a collection through parmeters.getsupportpreviewsize. Judge the screen direction because the preview size is w > h. if it is a vertical screen, you need to change the width and height. Compare the width and height of each element in the preview size list with the width and height of the surfaceview. If there are width and height dimensions, the width and height of the surfaceview are the same size, then set the current width and height as the preview size. If this step is not found, compare the scale of the size list with that of the surfaceview to find an identical or similar one.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>