Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old December 4th, 2010, 04:57 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2010
Posts: 2
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with transparency in Live Wallpaper

I need to draw a bitmap of a Basketball over other bitmap.
the problem is that (from my understandings) bitmaps doesn't support transparcy, and the background behind the ball is white color.

I tried to use setPixel(x,y,color.transparant) on the white pixels, but when
i send it to draw, it draws black pixels (the color of the android background) instead of transparant pixels.

here is what i try to do:

these are the two bitmaps:
backgroundBitmap = BitmapFactory.decodeResource(getResources(),R.draw able.grass1);
ballBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ball1);


..
..
..
..


void drawWallpaper()
{
final SurfaceHolder sh = getSurfaceHolder();

Canvas canvas = new Canvas();
try
{

canvas = sh.lockCanvas();
if (canvas != null)
{
drawB(canvas);
}
}

finally
{
if (canvas != null)
{
sh.unlockCanvasAndPost(canvas);
}
}

handler.removeCallbacks(runnable);
if (visible == true)
{
handler.postDelayed(runnable, 200);
}

}

void drawB(Canvas canvas)
{

xBall = surfaceRect.right / 2;
yBall = surfaceRect.bottom / 2;
canvas.drawBitmap(backgroundBitmap, null, surfaceRect, paint);
canvas.drawBitmap(ballBitmap, xBall, yBall, paint);

}


as i said, it draws the ball while the background behind is black (instead of transparat - in order to see the backgroundBitmap below)

what should i do?

thanks

Advertisements
itooriziu is offline  
Reply With Quote
sponsored links
Old December 5th, 2010, 05:40 AM   #2 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2010
Posts: 2
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default problem solved

i just found out i can load a png file into Bitmap.
which means:
ballBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ball1); is also working while "ball1" is a png file.

thanks me
itooriziu is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:18 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.