Issue
I'm using a bitmap resource to mask another image using DST_IN
transfer mode. This is the bitmap:
(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.
Solution
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.
Answered By - Kevin Krumwiede
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.