我正在尝试在录制视频时截屏。我可以截屏并将其保存到我的 SD 卡中。但它在 SD 卡上显示空白图像。有人可以帮我摆脱这个吗?
我正在使用下面的代码来捕获屏幕截图:
View v1 = cameraView; // CameraView is object of SurfaceView
v1.setDrawingCacheEnabled(true);
Bitmap bm = Bitmap.createBitmap(v1.getDrawingCache());
OutputStream outStream = null;
File file = new File(Environment.getExternalStorageDirectory(), "test12345658.jpeg");
try {
outStream = new FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
outStream.flush();
outStream.close();
Log.i("Hub", "OK, Image Saved to SD");
Log.i("Hub", "height = "+ bm.getHeight() + ", width = " + bm.getWidth());
} catch (FileNotFoundException e) {
e.printStackTrace();
Log.i("Hub", "FileNotFoundException: "+ e.toString());
} catch (IOException e) {
e.printStackTrace();
Log.i("Hub", "IOException: "+ e.toString());
}