[英]RGB Integer Values to Color Values
I have RGB integer values as -16776961
and -16121651
. 我的RGB整数值为
-16776961
和-16121651
。
How can I get the Color values of the Integers as java.awt.Color[r=0,g=0,b=205]
and java.awt.Color[r=10,g=0,b=205]
如何获取整数的Color值,例如
java.awt.Color[r=0,g=0,b=205]
和java.awt.Color[r=10,g=0,b=205]
Just use the Color
constructor that takes an int
as parameter (the alpha value is defaulted to 255). 只需使用将
int
作为参数的Color
构造函数(alpha值默认为255)。
Color c = new Color(-16121651); //java.awt.Color[r=10,g=0,b=205]
Then you can just call getBlue()
, getRed()
or getGreen()
to get the specific value of the color you want. 然后,您可以只调用
getBlue()
, getRed()
或getGreen()
来获取所需颜色的特定值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.