I get the colour of my bitmap under th开发者_如何学编程e 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 pixel is transparent?
What about alpha method of Color class?
int transparency = Color.alpha(color);
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:
int color = pngTestBM.getPixel(myX, myY);
boolean transparent = (color & 0xff000000) == 0x0;
Here you are:
int alpha = Color.alpha(pixel);
精彩评论