我正在嘗試實現包括在拍攝視頻時拍照的功能。這就是我總結使用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