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?
Copyright © 2021 Jogjafile Inc.
In the Android graphics architecture a
Surfaceplays 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
ImageReaderthat allows direct application access to image data rendered into itsSurface.There is a less efficient way to copy the contents of a
SurfaceViewinto aBitmapusingPixelCopy. WhileTextureViewallows you to get theBitmapdirectly.You can then draw the
Bitmapimage onto anotherSurfaceusing itsCanvas.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)
https://developer.android.com/reference/android/graphics/Canvas#drawBitmap(android.graphics.Bitmap,%20android.graphics.Rect,%20android.graphics.Rect,%20android.graphics.Paint)