1

如何拍摄 SurfaceView 的快照?我已经做了一些研究,但我找不到解决方案。使用 View 拍摄快照工作正常,但使用 SurfaceView 会提供黑屏图像。

View v1 = surfaceview.getRootView();

(或者)

View v1 = linearlayout.getRootView(); //linearlayout which holds surfaceview like linear.addView(surfaceViewObj);
v1.setDrawingCacheEnabled(true);
Bitmap bmp = v1.getDrawingCache();
FileOutputStream outStream = null;
String path = Environment.getExternalStorageDirectory() +"/myzoomSnap.jpg";

try {
    outStream = new FileOutputStream(path);
    bmp.compress(CompressFormat.JPEG, 100, outStream);
    outStream.flush();
    outStream.close();
} catch (FileNotFoundException e) {
    Log.d("CAMERA", e.getMessage());
} catch (IOException e) {
    Log.d("CAMERA", e.getMessage());
}

有些人提到 SurfaceView 不像其他视图那样出现在窗口上。那么甚至可以拍摄 SurfaceView 的快照吗?

4

0 回答 0