Code example for PorterDuffColorFilter

0
		public void setBounds(final int left, final int top, final int right, final int bottom) {
			mBounds.set(left, top, right, bottom);
		} 
 
		public void setColorFilter(final int color, final PorterDuff.Mode mode) {
			mPaint.setColorFilter(new PorterDuffColorFilter(color, mode));
		} 
 
		@Override 
		protected Bitmap onGetBitmap() {
			final Bitmap orig = super.onGetBitmap();
			if (mPaint.getColorFilter() == null) return orig;
			final Bitmap bitmap = Bitmap.createBitmap(orig.getWidth(), orig.getHeight(), orig.getConfig());
			final Canvas c = new Canvas(bitmap);
			c.drawBitmap(orig, 0, 0, mPaint);
			orig.recycle();
			return bitmap;
		} 
	} 
}