0

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.

ahakkal
  • 11
  • 6

1 Answers1

0

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.

fadden
  • 48,613
  • 5
  • 104
  • 152
  • i did as you said, adding a new function the same as yours, i added this line so to rotate the textureView as you said: myMatrix.postRotate(90), but the textureView disappear, and on the info log i had this message : " only received metering rectangles with wieght 0" – ahakkal Jul 28 '15 at 09:16
  • 1
    i call this method from the method onsurfaceavailable as i lock the screen orientation. – ahakkal Jul 28 '15 at 09:18
  • Start with a smaller rotation. Depending on how your matrix is set up you may be rotating it completely out of the view. – fadden Jul 28 '15 at 15:49