Get Bitmap from TextureView efficiently

喜欢而已 提交于 2019-12-09 15:37:51

问题


I am trying to get each frame from a TextureView, unfortunately trying:

textureView.getBitmap();

Results in slow performance is there a faster way to obtain a bitmap. Is it better to use the NDK instead?

Looking for actual examples


回答1:


A TextureView receives frames on a SurfaceTexture, which takes frames sent to its Surface and converts them to a GLES texture. To get the pixel data out, the texture must be rendered to a framebuffer, then read out with glReadPixels(). The pixel data can then be wrapped with a Bitmap object (which may or may not involve copying the pixel data).

Using the NDK isn't going to do you much good, as all of the code that needs to run quickly is already implemented natively.

You may see some improvement by sending the data directly to a SurfaceTexture and doing the GLES work yourself, but presumably you want to display the incoming frames in the TextureView, so all you'd potentially save is the Bitmap overhead (which may or may not be significant).

It might help if you explained in your question where the frames are coming from and what it is you want to do with them.



来源:https://stackoverflow.com/questions/36252437/get-bitmap-from-textureview-efficiently

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