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?
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.
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.
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.
You can use a ColorFilter
on your Paint
when you draw the bitmap.
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