简体   繁体   English

这个RGB值是什么意思

[英]What does this RGB value mean

I am working with the method image.getRGB() and I am not sure what the int value i am getting means. 我正在使用image.getRGB()方法,但不确定我得到的int值是什么意思。 It is returning a -1 and I'm not sure why. 它返回-1,但我不确定为什么。 I just want to see whether a pixel is black or white. 我只想查看像素是黑色还是白色。

a -1 probably means 0xFFFFFF which is white? -1可能意味着0xFFFFFF是白色?

Also see this question Java BufferedImage getRGB method and Color class to convert an RBG int value into a Color instance 另请参见此问题Java BufferedImage getRGB方法和Color类 ,将RBG int值转换为Color实例

Firstly, you need to know that for java 4 bytes are needed to store int; 首先,您需要知道对于Java,需要4个字节来存储int;

Secondly, the getRGB method returns alpha, red, green, and blue components of RGB, each occupies 1 bytes and one byte means 8 bits. 其次,getRGB方法返回RGB的alpha,红色,绿色和蓝色分量,每个分量占用1个字节,一个字节表示8位。

Thirdly, you might need to know alpha means the degree of opaque (means not transparent) 第三,您可能需要知道alpha表示不透明的程度(意味着不透明)

And, -1 in Two's Complement is 11111111 11111111 11111111 11111111 (int 32 bits as mentioned above) 并且,二进制补码中的 -1是11111111 11111111 11111111 11111111(如上所述,int为32位)

Finally now you know that the alpha part is 255, so as red, green, blue. 最后,现在您知道Alpha部分为255,如红色,绿色,蓝色。 which mean, the color is not transparent and white. 这意味着颜色不透明和白色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM