[英]Convert int colours to argb
public static int getARGB(final int red, final int green, final int blue, final int alpha) {
int argb = (alpha<<24)|(red<<16)|(green<<8)|blue;
return argb;
}
So I have to convert the different colour ints to an argb value.所以我必须将不同的颜色整数转换为 argb 值。 Is the way I have done correct?
我的做法是否正确?
You should also add a mask to each input to make sure they are not greater than 0xFF
:您还应该为每个输入添加一个掩码,以确保它们不大于
0xFF
:
int argb = (0xFF & alpha) << 24 | (0xFF & red) << 16 | (0xFF & green) << 8 | (0xFF & blue)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.