安卓获取某屏幕某一点RGB值

我现在获取到的是int型的color,如下
int color = (((BitmapDrawable)img.getDrawable()).getBitmap()).getPixel(x, y);
如何获取到RGB分别的R值,G值,B值呢

这个真不知道,我平时都是用网上的转换工具

rgb[0] = (pixel & 0xff0000) >> 16;

rgb[1] = (pixel & 0xff00) >> 8;

rgb[2] = (pixel & 0xff);

pixels[i]=alpha<<24|red<<16|green<<8|blue;

你可以用一个java的知识点,可以获取到屏幕上任意一点的rgba四个属性值,我之前做过一个电脑版本的,挺好用的。代码量也超级少。希望能帮到你哈图片说明

安卓里Color有静态方法.Color.red(int rgb),Color.blue(int rgb),Color.green(int rgb)
Color里还有其它的和颜色相关的静态方法.可以自己查看

利用Color类的静态方法。


 /**
     * Return the red component of a color int. This is the same as saying
     * (color >> 16) & 0xFF
     */
    public static int red(int color) {
        return (color >> 16) & 0xFF;
    }

    /**
     * Return the green component of a color int. This is the same as saying
     * (color >> 8) & 0xFF
     */
    public static int green(int color) {
        return (color >> 8) & 0xFF;
    }

    /**
     * Return the blue component of a color int. This is the same as saying
     * color & 0xFF
     */
    public static int blue(int color) {
        return color & 0xFF;
    }