1

I'm using a bitmap resource to mask another image using DST_IN transfer mode. This is the bitmap:

enter image description here

(You probably can't see it because it's white and transparent.)

If I load it like this, everything works as expected:

mMaskBitmap = BitmapFactory.decodeResource(getResources(), mMaskId);

But if I load it like this, it's as though the mask image were entirely transparent:

mMaskDrawable = getResources().getDrawable(mMaskId);    
mMaskBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
mMaskCanvas = new Canvas(mMaskBitmap);
mMaskDrawable.draw(mMaskCanvas);

What's the difference?

The bitmaps produced both ways are config ARGB_8888, density 320, and 512x512. The size is strange because the resource file is 256x256, but it's the same for both.

I want to use the Drawable approach so the resource can be a ninepatch.

Kevin Krumwiede
  • 9,868
  • 4
  • 34
  • 82

1 Answers1

0

I added this before calling draw(...):

mMaskDrawable.setBounds(0, 0, w, h);

I could've sworn this was one of the first things I tried, but anyhow, it works now. Maybe I did something wrong when I tried to clean and rebuild before.

Kevin Krumwiede
  • 9,868
  • 4
  • 34
  • 82