Reputation: 609
In my android app there are two SurfaceView
s. One SurfaceView
is drawn upon when user touches it. I want to copy and replicate the content of this SurfaceView
on the other SurfaceView
. Probably this can be done by caching the content of the first SurfaceView
in a bitmap and then drawing the bitmap on the second SurfaceView
. But how to cache the first SurfaceView
?
There are a few similar questions on this forum but they really do not work out for me.
Upvotes: 2
Views: 2844
Reputation: 1793
This: surfaceview.getDrawingCache();
will return the bitmap out of the SurfaceView and then you can draw it to the second SurfaceView: canvas.drawBitmap(bitmap, 0, 0, null);
.
Another way is to copy the canvas, not the surface view, like this:
Bitmap bitmap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
This means, that if you'll draw something on the canvas, it will be actually drawn on the bitmap.
Upvotes: 3