拍摄SurfaceView的快照

时间:2013-08-21 13:25:17

标签: android screenshot surfaceview snapshot

如何拍摄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的快照吗?

0 个答案:

没有答案
相关问题