简体   繁体   中英

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. It is returning a -1 and I'm not sure why. I just want to see whether a pixel is black or white.

a -1 probably means 0xFFFFFF which is white?

Also see this question Java BufferedImage getRGB method and Color class to convert an RBG int value into a Color instance

Firstly, you need to know that for java 4 bytes are needed to store int;

Secondly, the getRGB method returns alpha, red, green, and blue components of RGB, each occupies 1 bytes and one byte means 8 bits.

Thirdly, you might need to know alpha means the degree of opaque (means not transparent)

And, -1 in Two's Complement is 11111111 11111111 11111111 11111111 (int 32 bits as mentioned above)

Finally now you know that the alpha part is 255, so as red, green, blue. which mean, the color is not transparent and white.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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