拿相机的屏幕截图,同时记录 - 银河S3样? [英] Take camera screenshot while recording - Like in Galaxy S3?

查看:101
本文介绍了拿相机的屏幕截图,同时记录 - 银河S3样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林开发相机应用,它使用SurfaceView显示。

Im developing a camera app which uses SurfaceView for display.

我能够采取SurfaceView的截图(并将其保存为位图)
与getDrawingCache()(在版面包装了SurfaceView)
并且还与canvas.drawBitmap(...)

I'm able to take screenshot of the SurfaceView (and save it as a bitmap)
with getDrawingCache() (on a layout which wraps the SurfaceView)
and also with canvas.drawBitmap(...)

然而,在这两个方面,位图始终是透明/空白。

however in both ways, the bitmap is always transparent/blank.

我有银河S3,我可以看到他们有这个功能在他们的相机 他们究竟如何做到的呢?

I have galaxy S3 and I can see that they have that feature in their camera how exactly they do it?

谢谢!

推荐答案

嗯小时后,我得到了一个很好的解决方案。照片 也许这是不是最好的方式,但它是很好的足够了。

Well after hours, I got a nice solution for that.
Maybe it isn't the best way, but it is good enough for me.

private long start;
private long end;
private long period;

首先得到启动时间媒体记录器启动后右:

First get a start time right after the media recorder starts:

private void startRecording()
{
   mMediaRecoder.start();
   start = System.currentTimeMillis();
}

然后,当u屏幕/按钮采取截图preSS,保存期:

Then, when u press on the screen/button for taking screenshot, save the period:

private void captureImage()
{
   end = System.currentTimeMillis();
   period = end - start;
}

最后,当你停止录制,使用周期和媒体检索得到的位图:

Finally, when you stop recording, get the bitmap using the period and the Media retriever:

private void saveVideo()
{
   MediaMetadataRetriever retriever = new MediaMetadataRetriever();
   //path -> the path to the video
   retriever.setDataSource(path);
   Bitmap bitmap = retriever.getFrameAtTime(period * 1000,MediaMetadataRetriever.OPTION_CLOSEST);
}

希望它可以帮助你!

Hope it helps you!

这篇关于拿相机的屏幕截图,同时记录 - 银河S3样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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