如何使用SurfaceView将画布绘图保存为图像而不是视图。
答案 0 :(得分:2)
尝试下面的代码可能有帮助
Bitmap bitmap = Bitmap.createBitmap(mSurfaceView.getWidth(), mSurfaceView.getHeight(), Bitmap.Config.ARGB_8888);
mSurfaceView.draw(new Canvas(bitmap));
try {
OutputStream out = new BufferedOutputStream(new FileOutputStream(saved.png));
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
} catch (IOException e) {
Log.w(TAG, e);
}