我有一个ARGB颜色(看起来像255 200 200 000
)。我尝试使用以下代码将其转换为十六进制格式:
String col = "#" + Integer.toString(Color.alpha(img.getPixel(j, i)), 16) +
Integer.toString(Color.red(img.getPixel(j, i)), 16) +
Integer.toString(Color.green(img.getPixel(j, i)), 16) +
Integer.toString(Color.blue(img.getPixel(j, i)), 16);
但实际上我得到的是 (#FFC8C8
) 而不是 (#FFC8C800
)。所以所有小于10的数字都没有写成带零的形式。如何修复这个代码,使其正常工作?
注:请原谅我的英语