Code example for AvoidXfermode

0
		Bitmap bmask = mask.getBitmap(),
			   blayer = layer.getBitmap();
		int W = mask.getBitmap().getWidth(),
		    H = mask.getBitmap().getHeight();
		 
		AvoidXfermode avoidXfermode = new AvoidXfermode(color, 0, AvoidXfermode.Mode.TARGET);
		 
		avoidPaint.setColor(Color.TRANSPARENT);
 
        // draw the src/dst example into our offscreen bitmap 
        int sc = canvas.saveLayer(x, y, x + W-1, y + H-1, 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(bmask, x, y, null);
        avoidPaint.setXfermode(avoidXfermode);
        canvas.drawRect(x, y, x+W-1, y+H-1, avoidPaint);
        pdPaint.setXfermode(pdXfermode);