public static int getR(int c) {
return (c & R) >> 16;
}
public static int getG(int c) {
return (c & G) >> 8;
}
public static int getB(int c) {
return c & B;
}
private static float[] buf = new float[3];
public static float[] getHSVvalues(int c) {
Color.RGBtoHSB(getR(c), getG(c), getB(c), buf);
return buf;
}
public static int hsv(float h, float s, float v) {
if (s > 1)
s = 1;
if (v > 1)
v = 1;
return Color.getHSBColor(h, s, v).getRGB();
}
public static float getHue(int c) {
Color.RGBtoHSB(getR(c), getG(c), getB(c), buf);
return buf[0];
}
public static float getSaturation(int c) {
Color.RGBtoHSB(getR(c), getG(c), getB(c), buf);
return buf[1];
}
public static float getValue(int c) {
Color.RGBtoHSB(getR(c), getG(c), getB(c), buf);
return buf[2];
}
to set the hue to red (for example) use:
int c; //some color
float[] v=getHSVvalues(c);
c=hsv(0,f[1],f[2]);
edit: this is for ARGB, change it so it suits your RGBA
public static final int
R=0x00ff0000,
G=0x0000ff00,
B=0x000000ff;