# How do I blend a bitmap with a color?

I have a png which is mostly transparent, except for a shape I've drawn in white. I want to be able to blend this bitmap with a color when drawing it with Canvas. I'd like something like [Sa, (Dc * (1 - Sa)) + (Sc * C * Sa)], where C would be the color I want to blend with. I assumed I would just set the paint color to C, then call drawBitmap, but the default behavior doesn't seem to be blending.

Is this the right approach? Are there some Xfer codes I'm missing? Can I create a custom shader to do this? Is there an example in the android sdk api I missed that does this?

As an additional constraint, I should mention I want to avoid just creating a new bitmap with the blended color to use. The color C (above) could change every frame, and I don't want to have to generate 100's of these bitmaps for every color that I might need.

Paint p = new Paint();

Then draw with that Paint object.