有人能解释一下为什么从RGB到HSV的转换,再从HSV转回RGB时结果不同吗?
int color = Color.rgb(206, 43, 55);
int red = Color.red(color);
int green = Color.green(color);
int blue = Color.blue(color);
System.out.println(red + ", " + green + ", " + blue);
//prints: 206, 43, 55 (as expected)
float[] hsv = new float[3];
Color.RGBToHSV(red, green, blue, hsv);
float hue = hsv[0];
float sat = hsv[1];
float val = hsv[2];
int outputColor = Color.HSVToColor(hsv);
red = Color.red(outputColor);
green = Color.green(outputColor);
blue = Color.blue(outputColor);
System.out.println(red + ", " + green + ", " + blue);
//prints: 206, 42, 54 (green and blue are changed)