Is it possible to add an array of images to a canvas and then delete individual images?So lets say I declare an ArrayList and add my images to it. I then draw them on the canvas.How can i delete just one image instead of them all?Is this possible?
ArrayList<Integer> myImageList = new ArrayList<Integer>();
myImageList.add(R.drawable.image1);
myImageList.add(R.drawable.image2);
myImageList.add(R.drawable.image3);
canvas.drawBitmap(myImageList[0], 300, 400, null);
canvas.drawBitmap(myImageList[1], 300, 400, null);
canvas.drawBitmap(myImageList[2], 300, 400, null);
It is not possible, Because once you have drawn any image on canvas the pixel value of the bitmap of that canvas is changed.
You have to clear the whole canvas and redraw all other images again on the canvas,
One optimization you can do is apply a clip region , in that case don't clear the canvas and follow the steps:
Region clip_region= region of the image(which you want to remove ) on the canvas;
canvas_object.clipRegion(clip_region);
Now clear only the clip_region area and draw all other images on the canvas, With this optimization your app will take less cpu to draw than drawing without CLIP REGION ,