问题
I'm trying to make a snapshot of my app. The problem I have is that this app is intented to be a augmented reality app and I have a view with some layers and the background layer is the camera view.
I tried it by enabling and getting root view drawing cache but the result was a bitmap with a black background and the rest of the layers on it. Also, to get the camera os a background again I had to disable the cache and restart the camera. (i.e. How to programmatically take a screenshot in Android? )
Next approach, and it almost works for me, was by making a photo and setting it as a background before doing the screen capture "as usual". The result is pretty good but too tricky and bit slow, and also I have to fix the image size according to the device screen.
Can anyone give me an advice on how to approach this task in a better way?
Thank you!
回答1:
Sorry you can't. The SurfaceView associated to the camera is hardware accelerated so it won't show in your screenshot.
The only solution I came across is to get the preview from the camera and paint it in the SurfaceView programmatically. Then the screenshot will work.
来源:https://stackoverflow.com/questions/48589522/how-to-save-camerasourcepreview-contents-into-a-jpg-fileandroid-camera