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

查看:370
本文介绍了使用相机时的屏幕截图(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天全站免登陆