Code example for AvoidXfermode

        // set up the rect for the image 
        Rect imageRect = new Rect(0, 0, width, height);
        // set up paint object such that it only paints on Color.WHITE 
        paint.setXfermode(new AvoidXfermode(Color.WHITE, 255, AvoidXfermode.Mode.TARGET));
        // draw resized bitmap onto imageRect in canvas, using paint as configured above 
        canvas.drawBitmap(bitmap, imageRect, imageRect, paint);
        return output;
    public static Bitmap getRoundedCornerBitmap(Context context, Bitmap input, int pixels , int w , int h , boolean squareTL, boolean squareTR, boolean squareBL, boolean squareBR  ) {
        Bitmap output = Bitmap.createBitmap(w, h, Config.ARGB_8888);
        Canvas canvas = new Canvas(output);
        final float densityMultiplier = context.getResources().getDisplayMetrics().density;
        final int color = 0xff424242;
        final Paint paint = new Paint();