Android AvoidXfermode - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android AvoidXfermode class.

This code example shows how to use the following methods:
		//TempCanvas.drawBitmap(Gameactivity.SplatWepon, new Rect(0,0,Gameactivity.SplatWepon.getWidth(),Gameactivity.SplatWepon.getHeight()), new Rect((int)(f-k/2) ,(int)(g-k/2) , (int)(f+k/2), (int)(g+k/2)), RemovePaint); 
		RemovePaint.setXfermode(new AvoidXfermode(removeColor, 0, AvoidXfermode.Mode.TARGET));
This code example shows how to use the following methods:
		// then, set the Xfermode of the pain to AvoidXfermode 
		// removeColor is the color that will be replaced with the pain't color 
		// 0 is the tolerance (in this case, only the color to be removed is targetted) 
		// Mode.TARGET means pixels with color the same as removeColor are drawn on 
		paint.setXfermode(new AvoidXfermode(removeColor, 0, AvoidXfermode.Mode.TARGET));
		// draw transparent on the "brown" pixels 
		// mb should now have transparent pixels where they were red before 
		return mb;
	public int getDrawWidth(){ 
		return drawWidth;
	public Colour getDrawColour(){ 
		return drawColour;
This code example shows how to use the following methods:
        // 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;
This code example shows how to use the following methods:
		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);
        // 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.drawBitmap(bmask, x, y, null);
        canvas.drawRect(x, y, x+W-1, y+H-1, avoidPaint);

Related Android AvoidXfermode Questions & Answers:

See Code Examples for Android AvoidXfermode Methods: