Android examples for Graphics:Color
colorize Bitmap
import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.support.v4.util.ArrayMap; public class Main{ private static final String TAG = ColorUtils.class.getSimpleName(); public static Bitmap colorizeBitmap(int markerColor, Bitmap bitmap) { try {//from ww w . j a v a2 s.co m Bitmap obm = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig()); Canvas canvas = new Canvas(obm); canvas.drawBitmap(bitmap, 0f, 0f, getNewPaintColorFilter(markerColor)); return obm; } catch (Exception e) { MTLog.w(TAG, e, "Error while colorizing bitmap!"); return bitmap; } } public static Paint getNewPaintColorFilter(int colorInt) { Paint paint = new Paint(); paint.setColorFilter(new PorterDuffColorFilter(colorInt, PorterDuff.Mode.MULTIPLY)); return paint; } }