Okay, have to look to the graphics experts on this one. I have a rectangular bitmap (large) and a circular bitmap (small). I want to place the large rectangular bitmap behind the smaller circular bitmap with the larger rectangular bitmap taking on the shape of the smaller circular bitmap (i.e. the rectangular bitmap should be clipped or otherwise). The smaller circular bitmap has some transparency and so the clipped rectangular bitmap will show through after transformation. I have tried the following:
protected void onDraw(Canvas c) {
int sc = canvas.saveLayer(x, y, x + w, y + h, null,
Canvas.MATRIX_SAVE_FLAG |
Canvas.CLIP_SAVE_FLAG |
Canvas.HAS_ALPHA_LAYER_SAVE_FLAG |
Canvas.FULL_COLOR_LAYER_SAVE_FLAG |
Canvas.CLIP_TO_LAYER_SAVE_FLAG);
canvas.drawBitmap(bmpSmallCircular, 0, 0, backgroundPaint);
backgroundPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
canvas.drawBitmap(bmpLargeRectangular, 0 , 0, backgroundPaint);
backgroundPaint.setXfermode(null);
canvas.restoreToCount(sc);
}
So, this gives part of the solution but the rectangular bitmap draws over the smaller bitmap (though it does assume the shape of the smaller). I am probably missing something obvious and would appreciate a point or push in the right direction. Thanks!