Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw a bitmap with transparency

Tags:

android

bitmap

How to draw a bitmap with a given color set as transparent?
For example I want all white pixels to be transparent.

like image 797
Tomek Tarczynski Avatar asked Dec 02 '22 03:12

Tomek Tarczynski


2 Answers

You need to set the Alpha value for the paint you're passing to the Bitmap.

http://developer.android.com/reference/android/graphics/Paint.html#setAlpha%28int%29

Values vary from 0-255

EDIT:

Paint p = new Paint();
//Set Blue Color
p.setColor(Color.WHITE);
//Set transparency roughly at 50%
p.setAlpha(125);
like image 106
Manish Burman Avatar answered Dec 26 '22 20:12

Manish Burman


you need to check every pixel of image and change its color. you will get your answer in this Post

like image 34
Saurabh Pareek Avatar answered Dec 26 '22 20:12

Saurabh Pareek