How do I take an existing bitmap, say
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.somebitmap);
and write a method that returns a darkened version of the bitmap?
private Bitmap darkenBitMap(Bitmap bm) { }
I've been trying to use Paint and Canvas with no results so far.
To make view darker.
canvas.drawARGB(200, 0, 0, 0);
Short and simple :)
I got it finally. Hope it helps someone else.
private Bitmap darkenBitMap(Bitmap bm) {
Canvas canvas = new Canvas(bm);
Paint p = new Paint(Color.RED);
//ColorFilter filter = new LightingColorFilter(0xFFFFFFFF , 0x00222222); // lighten
ColorFilter filter = new LightingColorFilter(0xFF7F7F7F, 0x00000000); // darken
p.setColorFilter(filter);
canvas.drawBitmap(bm, new Matrix(), p);
return bm;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With