The difficulty I am having now is to take a screenshot of the SurfaceView. Could anyone please help?
My team is doing an Android project where we use MediaCodec to decode the video feed and render the feed onto a Surface.
The activity implements
SurfaceHolder.Callback
Then we created a SurfaceView and add the Callback:
mySurfaveView.getHolder().addCallback(this);
Then we start decode the video feed in (we have a method that does the decode)
surfaceChanged(SurfaceHolder holder, int format, int width, int height)
The video work fine, now I want to take screenshot of what gets rendered onto the SurfaceView. I have tried several ways to do this, but I didn't succeed. Following are what I have tried:
- I have tired getting rootView's drawingcache.
- Tried getting the frame directly from MediaCodec.
- Tried the draw() method to draw on a canvas.
As of now I am tring to create a custom SurfaceView and override the onDraw method there. However, I have never created a custom SurfaceView. Am I on the right direction?
Help please. Thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…