Android 如何使用SurfaceView作为图像保存画布绘图?
如何使用SurfaceView作为图像而不是视图保存画布绘图。尝试下面的代码可能会有所帮助Android 如何使用SurfaceView作为图像保存画布绘图?,android,Android,如何使用SurfaceView作为图像而不是视图保存画布绘图。尝试下面的代码可能会有所帮助 Bitmap bitmap = Bitmap.createBitmap(mSurfaceView.getWidth(), mSurfaceView.getHeight(), Bitmap.Config.ARGB_8888); mSurfaceView.draw(new Canvas(bitmap)); try { OutputStream out = new BufferedOutputS
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);
}