The HTML 5 canvas supports composite operations (See here).
Is this possible in an Android Canvas? I scanned the API of the Canvas class but couldn't find anything useful. I need at least the composite operation "source-in" or (if this isn't possible) "source-atop".
Composition is handled by drawing on a
Canvas with a
Paint that uses a
Paint p=new Paint(); p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DARKEN)); canvas.drawBitmap(bitmap, 0, 0, p);
See here for more info. I also managed to override
onPaint so that we can apply this composition to elements that draw themeselves.
Found it myself. The PorterDuffXfermode implements all these composite modes.