Skip to content Skip to sidebar Skip to footer

Android, Check Alpha Of Pixel?

I get the colour of my bitmap under the touch x and y: int myX = (int)event.getX(); int myY = (int)event.getY(); int color = pngTestBM.getPixel(myX,myY); How can I check if the pi

Solution 1:

What about alpha method of Color class?

int transparency = Color.alpha(color);

Solution 2:

The color is a 32 bit ARGB value, and a completely opaque pixel has an Alpha value of 0xff whilst a completely transparent pixel has an alpha value of 0x00.

Assuming you just want to find out if it is completely transparent you can just do:

intcolor= pngTestBM.getPixel(myX, myY);
booleantransparent= (color & 0xff000000) == 0x0;

Solution 3:

Here you are:

int alpha = Color.alpha(pixel);

Post a Comment for "Android, Check Alpha Of Pixel?"