Android - fill bitmap with color

I work with Android, and I really need a quick way to get a bitmap of a given size, which should be filled with a predefined color.

The following code does not work for me,

Bitmap Insert - Resizable 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; 

Be sure that the β€œold” value and the value (a | r | g | b) are different, but β€œpainted” the color using the canvas with my variable bitmap on the bottom, the bitmap retains its previous value.

I would be pleased with any method that takes a bitmap and color value and returns a bitmap filled with that color.

+6
android bitmap fill
source share
1 answer

I did not provide enough information!

The value of my alpha range was out of range;

 int a = 0xFF<<24 

So when I called

 c.drawARGB(a,r,g,b); 

He failed calmly and did not change the meaning.

+6
source share

All Articles