Screenshot while using the camera (Android)

做~自己de王妃 提交于 2020-01-06 05:53:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!