android Bitmap getPixel

后端 未结 1 1487
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-15 01:49

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 res

相关标签:
1条回答
  • 2021-01-15 02:26

    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

    0 讨论(0)
提交回复
热议问题