I am trying to create an animated wallpaper.
Basically my wallpaper has some background picture, and several foreground pictures. I want to swap between the foreground pictures with different backgrounds.
I have a Draw method that looks like this:
protected void onDraw(Canvas canvas){
super.onDraw(canvas);
canvas.drawColor(0);
canvas.drawBitmap(background,0,0,null);
canvas.drawBitmap(foreground,x,y,null);
canvas.save();
}
My foreground picture is a png that has lots of transparent space.
I loaded in my foreground picture like this:
foreground=decodeSampledBitmapFromResource(getResources(), R.drawable.c1, 440,320);
Where the decodeSampledBitmapFromResource method was taken from the tutorial here: https://developer.android.com/training/displaying-bitmaps/load-bitmap.html
My problem is that the foreground will display white color where it should display transparent color and thus covering the background with an ugly white rectangle.
I'm wondering if anyone have any advice for me to make this transparent. I've tried setting options.inPreferredConfig = Bitmap.Config.ARGB_8888; for the BitmapFactory, but it didn't help.
from How to make canvas.drawBitmap transparent?
No comments:
Post a Comment