1
如何将使用SurfaceView的画布绘制保存为图像而不是视图。如何使用SurfaceView将图形绘制保存为图像?
如何将使用SurfaceView的画布绘制保存为图像而不是视图。如何使用SurfaceView将图形绘制保存为图像?
试试下面的代码可能会帮助
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);
}