Reputation: 21647
I need to get the color of a pixel in order to compare it with a color from my color.xml file, but all values are negative and this comparison will always return a false result. How to get the proper color value? This color may be transparent. I've read this but I need an answer, not a link to theory.
bmp.getPixel(n.x, n.y)
is returning zero when I'm expecting to return a propper value for color #00FFFFFF
Thanks
Upvotes: 2
Views: 2962
Reputation: 186
You could do something like this:
int pixel = Color.RED; //bmp.getPixel(n.x, n.y);
int a = Color.alpha(pixel);
int r = Color.red(pixel);
int g = Color.green(pixel);
int b = Color.blue(pixel);
String color = String.format("#%02X%02X%02X%02X", a, r, g, b); //#FFFF0000 for RED color
but instead of Color.RED
you can put your bmp.getPixel(...)
method.
Hope that helps
Best Regards
Upvotes: 6