I have an alpha mask and I want to use this mask as a rubber, when user touch on the screen that part of bitmap should be erased as the shape of the alpha mask. I have tried it but it always get the whole bitmap as mask not the alpha part. Later, user will save the bitmap so those erased parts should be transparent.
Here is the code that I use:
paintMask.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
Canvas canvas = new Canvas(bitmapOriginal);
int sc = canvas.saveLayer(0, 0, width, height, null, Canvas.ALL_SAVE_FLAG);
canvas.drawBitmap(bitmapOriginal, 0, 0, null);
canvas.drawBitmap(bitmapMask, 0, 0, paintMask);
canvas.restoreToCount(sc);
and in your layout file ...
hope it help