Android: What is the difference of TextureView's setTransform() and setScaleX/Y()?

懵懂的女人 提交于 2021-01-29 16:17:32

问题


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

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