Get Bitmap from TextureView efficiently

后端 未结 1 1431
暗喜
暗喜 2021-02-20 08:05

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

textureView.getBitmap();

Results in slow performance is th

1条回答
  •  广开言路
    2021-02-20 08:39

    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.

    0 讨论(0)
提交回复
热议问题