I'm making an App that needs to be able to draw new graphics on top of the last set.
This is my current onDraw() method -
- Code: Select all
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
//do some stuff here - this is all working ok
canvas.drawLine(p1.x, p1.y, p2.x, p2.y, linePaint);
}
Basically, I need to draw the new graphics as a layer on top of the last, so what I'm looking for is a way to carry the image of the last canvas to the current. There is a LOT of lines drawn every frame so simple drawing them all again isn't an option.
I have tried to figure it out myself using the canvas.setBitmap() method but it acts very funny.
This is what I put at the start of the onDraw() method, in my head it makes sense but it doesn't seem to do anything
- Code: Select all
if(bitmap != null) {
canvas.drawBitmap(bitmap, 0, 0, paint);
canvas.setBitmap(bitmap);
}
Any help is greatly appreciated
P.S if it's needed, the the class extends SurfaceView and implements SurfaceHolder.Callback




