views:

839

answers:

2

I'm currently looking for a way to use a black and white bitmap to mask the alpha channel of another bitmap or Drawable on Android. I'm curious as to what the best way to do this is. I certainly have a couple of ideas for how to do this, but they are not optimal.

I need to be able to apply a new mask to the image every so often (the black and white bitmap will change every few seconds).

Any feedback on how to achieve this would be greatly appreciated.

A: 

I'm not entirely clear on what you're going for, but I believe that a combination of BitmapDrawable and LayerDrawable may work. BitmapDrawable will allow you to use your Bitmaps as Drawables, and then you can use LayerDrawable to layer the mask on top of another Drawable.

Daniel Lew
I'll check it out, thanks.
Joshua Rodgers
+1  A: 

Using the Xfermodes example in the API Demo I was able to use a PorterDuffXfermode applied to a Paint object to blend together two bitmaps on a canvas. This works exactly how I need it to.

Joshua Rodgers
Could you add more details?
Casebash