Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you tint a bitmap in Android?

I draw a bitmap onto a canvas using the following call:

_playerImage = BitmapFactory.decodeResource(getResources(), R.drawable.player);

How can I now tint this image white? I'm trying to make the image flash white like in top-scrollers when an enemy is hit by a bullet.

Do I need to use something other than BitmapFactory?

like image 790
FoppyOmega Avatar asked Aug 17 '10 03:08

FoppyOmega


People also ask

How do I change a bitmap color?

Click Bitmaps Bitmap color mask. Choose a color from the list of masked colors. Click the Edit color button . Use the controls in the Select color dialog box to edit the color.

What is bitmap used for in Android?

A bitmap is simply a rectangle of pixels. Each pixel can be set to a given color but exactly what color depends on the type of the pixel. The first two parameters give the width and the height in pixels. The third parameter specifies the type of pixel you want to use.

What is Bitmap class in Android?

Everything that is drawn in android is a Bitmap . We can create a Bitmap instance , either by using the Bitmap class which has methods that allow us to manipulate pixels in the 2d coordinate system , or we can can create a Bitmap from an image or a file or a resource by using the BitmapFactory class.


1 Answers

You can use a ColorFilter on your Paint when you draw the bitmap.

like image 59
Romain Guy Avatar answered Sep 27 '22 20:09

Romain Guy