I currently have two different surfaces (one from SurfaceView and another surface created from MediaCodec).
What are the different ways available to copy from one surface to another?
I currently have two different surfaces (one from SurfaceView and another surface created from MediaCodec).
What are the different ways available to copy from one surface to another?
In the Android graphics architecture a Surface
plays the role of a consumer of buffers containing the graphical data (e.g. video frames).
A typical consumer does not provide access to the buffers that it holds. An exception is the special type ImageReader
that allows direct application access to image data rendered into its Surface
.
There is a less efficient way to copy the contents of a SurfaceView
into a Bitmap
using PixelCopy
. While TextureView
allows you to get the Bitmap
directly.
You can then draw the Bitmap
image onto another Surface
using its Canvas
.
Links:
https://source.android.com/devices/graphics/arch-sh
https://developer.android.com/reference/android/media/ImageReader
https://developer.android.com/reference/android/view/PixelCopy
https://developer.android.com/reference/android/view/Surface#lockCanvas(android.graphics.Rect)