使用相机时的屏幕截图 (Android) [英] Screenshot while using the camera (Android)

查看:35
本文介绍了使用相机时的屏幕截图 (Android)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的应用制作快照.我遇到的问题是该应用程序旨在成为增强现实应用程序,并且我有一个带有一些图层的视图,而背景图层是相机视图.

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.

我通过启用和获取根视图绘图缓存进行了尝试,但结果是一个具有黑色背景的位图以及其上的其余图层.此外,为了让相机操作系统再次成为背景,我必须禁用缓存并重新启动相机.(即如何在Android中以编程方式截取屏幕截图?)

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?

谢谢!

推荐答案

对不起,你不能.与相机关联的 SurfaceView 是硬件加速的,因此它不会显示在您的屏幕截图中.

Sorry you can't. The SurfaceView associated to the camera is hardware accelerated so it won't show in your screenshot.

我遇到的唯一解决方案是从相机获取预览并以编程方式在 SurfaceView 中绘制它.然后截图就可以了.

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.

这篇关于使用相机时的屏幕截图 (Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆