我正在尝试实现包括在拍摄视频时拍照的功能。这就是我总结使用SurfaceView的截图方法的原因。
但是,当我尝试拍摄SurfaceView的屏幕截图时。我总是得到一张空白图像。
在其中使用相机预览拍摄SurfaceView的视频
下面是我使用拍摄快照代码:
View tempView = (View)MY_SURFACE_VIEW;
tempView.setDrawingCacheEnabled(true);
Bitmap tempBmp = Bitmap.createBitmap(tempView.getDrawingCache());
tempView.setDrawingCacheEnabled(false);
//Saving this Bitmap to a File....
万一你们可能会认为这是一个重复的问题,让我向你保证,我已经尝试提供了以下解决方案在问这个问题之前,对于同样的问题。
- https://stackoverflow.com/questions/24134964/issue-with-camera-picture-taken-snapshot-using-surfaceview-in-android
- Facing issue to take a screenshot while recording a video
- Take camera screenshot while recording - Like in Galaxy S3?
- Taking screen shot of a SurfaceView in android
- Get screenshot of surfaceView in Android(这是正确的答案,但部分答案。我已经问@sajar解释答案)
Internet上的其他资源:
1. http://www.coderanch.com/t/622613/Android/Mobile/capture-screenshot-simple-animation-project 2. http://www.phonesdevelopers.com/1795894/
这都不是迄今为我工作。我也知道我们需要创建一些与Surface Holder交互并从中获取位图的Thread。但我不知道如何实现。
任何帮助都得到高度评价。
上帝今天寄给我你。感谢这个问题 – 2015-12-04 13:19:25
..我的快乐:) – 2015-12-30 19:00:54
你能找出解决这个问题的办法吗? – Sheharyar 2016-02-08 11:21:25