问题
I am using TextureView for displaying graphical video content.
As the MediaCodec will render the content occupying the whole of the TextureView, so I need to scale it to keep the aspect ratio of the original content.
We know that TextureView has its own method of transforming:
setTransform(android.graphics.Matrix)
And also two other methods inherited from View class:
setScaleX (float scaleX)
setScaleY (float scaleY)
Both can be used to achieve the same purpose.
However, I noticed some difference of the final result.
Using setScaleX/Y() method is perfect.
But when using setTransform(), there are some "duplicated lines of pixels" at the bottom of the displayed content on screen, if the resolution of the content is "not good", e.g. 488 x 345. It looks like there are some paddings added to the displayed content by the system.
I have got a screenshot as following:
Could anyone please help to explain the reason of this difference? And, if I keep using setScaleX/Y() method, is there any performance issue comparing using setTransform()?
Thanks a lot.
来源:https://stackoverflow.com/questions/61137482/android-what-is-the-difference-of-textureviews-settransform-and-setscalex-y