I'm working with Android and I really need a fast way to get a bitmap of a predetermined size to be filled with a predetermined colour.
The following code is not working for me however;
Bitmap input is a mutable bitmap
int old = input.getPixel(0, 0);
Canvas c = new Canvas(input);
Rect rect = c.getClipBounds(); // The dimensions of the bitmap are returned
c.drawARGB(a, r, g, b);
int n = input.getPixel(0, 0);
if(old==n)
Log.e(TAG, "Values didn't change!");
return input;
Rest assured, the 'old' value and the value of (a|r|g|b) are different but having 'drawn' the colour using a canvas with my mutable bitmap underneath, the bitmap retains it's old value.
I'd be happy with any method that takes a bitmap and a colour value and returns a bitmap filled with that colour.
I didn't provide enough info!
My alpha value was out of range;
int a = 0xFF<<24
So when I called
c.drawARGB(a,r,g,b);
It failed quietly and didn't change the values.
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