Code example for PorterDuffXfermode

1
        mPaint.setColor(Color.BLACK);
        mPaint.setStyle(Paint.Style.FILL);
        canvas.drawPath(fillPath, mPaint);
 
        // mask in the icon where the bitmap is opaque 
        mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
        canvas.drawBitmap(bitmap, cropRect, circleRect, mPaint);
 
        // prepare paint for frame drawing 
        mPaint.setXfermode(null);
 
        mScale = 1f;
 
        mSrcRect = new Rect(0, 0, mSize, mSize);
        mDstRect = new RectF(0, 0, mSize, mSize);
        mFrameRect = new RectF(mDstRect);
        mFramePath = new Path();
    } 
 
    public void reset() { 
        mScale = 1f;