how to rotate textureView to show a cameraPreview

╄→尐↘猪︶ㄣ 提交于 2019-12-13 05:23:42

问题


I use the camera2 api to show a camerapreview, and i lock the screen orientation on lanscape, my problem is that i want to rotate the textureview to display the correct camerapreview, when i rotate it using the method setRotation, it becomes smaller. I search on stack but all solutions are relative to camera(first api) so is there a solution to rotate the textureView.


回答1:


You can add a rotation to the TextureView's matrix. For an example, see Grafika's "play movie activity", which sends the output of a video decoder to a TextureView (same basic principles as Camera preview).

If you look at adjustAspectRatio() you can see it adjusting the position (translation) and scale of the output to match the video's aspect ratio. There's also a commented out postRotate() call that would rotate the output 10 degrees.

Note this is rotating the video frame within the View, not the View itself.



来源:https://stackoverflow.com/questions/31650446/how-to-rotate-textureview-to-show-a-camerapreview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!