【发布时间】:2014-01-06 14:32:39
【问题描述】:
我有一个简单的颜色整数,例如 0x8833aacc
如果我现在使用 Color.colorToHSV 创建它的 HSV 值,
然后用Color.HSVToColor 把int 取回来,略有不同!the red value decreases by 1
但它并非每次都这样做,例如使用0x8830aacc时一切正常,为什么?
我的示例代码显示了这一点:
final float[] current_hsv = new float[3];
float current_alpha = 1.0f;
private int GetColor()
{
return Color.HSVToColor((int)(current_alpha * 255.0f), current_hsv);
}
private void SetColor(int color)
{
Color.colorToHSV(color, current_hsv);
current_alpha = (float)Color.alpha(color) / 255.0f;
}
private void Test()
{
int color = 0x8833aacc;
SetColor(color);
int g = GetColor();
//convert to hex, you'll see the red value decreased by 1!!!
Log.i("Test", "color: " + String.format("%08x", color) + " got color: " + String.format("%08x", g));
}
我该如何解决这个问题?
【问题讨论】:
标签: java android colors internal