Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change background color of bitmap to transparent and background should not drag?

I used:

Bitmap bitmap= Bitmap.createBitmap(255, 255, Bitmap.Config.RGB_565); 
Canvas canvas = new Canvas(bitmap); 

Background color is black....

If I use:

Bitmap.Config.ARGB_8888; 

background color is white...

my question is that How to change background color of bitmap to transparent and background should not drag? only center image have to drag...

plz can anybody say this solution or example....

like image 226
sam786 Avatar asked Nov 03 '12 11:11

sam786


People also ask

Can bitmap image have a transparent background?

Bitmaps (i.e. files with . BMP extension) do not natively support transparency: you need to save as a different format like PNG. Another format that supports transparency is GIF but it is only suitable for simple images with few colours.


2 Answers

Try to add

Bitmap bitmap= Bitmap.createBitmap(255, 255, Bitmap.Config.ARGB_8888);

after that try this line (A is alpha value interval is 0-255 and 0 is fully transparent).

bitmap.eraseColor(Color.argb(AAA,RRR,GGG,BBB));

like image 141
Barış Çırıka Avatar answered Oct 25 '22 18:10

Barış Çırıka


Try to this

 bitmap.eraseColor(getResources().getColor(R.color.thumb));
like image 34
Virani Ashish Avatar answered Oct 25 '22 18:10

Virani Ashish