本文介绍了Java - 了解关于image.getRGB(x,y)输出的二进制项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i use image.getRGB(x,y);其结果是: -16777216



当我将 -16777216 转换为二进制项时,得到结果: / p>

1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 0000 0000 0000 0000 0000 0000



我的问题是,上面的每个二进制的意思是什么? (您可以解释红色,绿色,蓝色,Alpha 没有使用颜色类别)



感谢您的帮助。

解决方案

您不小心转换为64位()而不是32位

 

1111 1111 0000 0000 0000 0000 0000 0000

此值包含4通道:

 合计:1111 1111 0000 0000 0000 0000 0000 0000 
---------- -------------------------------------------
alpha:1111 1111
blue:0000 0000
green:0000 0000
red:0000 0000


$ b b

这意味着这是一个完全不透明的黑色。


i use image.getRGB(x,y); and the result is : -16777216

When i convert -16777216 to binary term, i get result :

1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 0000 0000 0000 0000 0000 0000

My question is, what the meaning for each binary above? (can you explain where is Red, Green, Blue, Alpha without using Color Class)

Thanks for help.

解决方案

You accidentally converted to 64 bit (long) instead of 32 bit (int).

The correct binary representation is

1111 1111 0000 0000 0000 0000 0000 0000

This value contains data for the 4 channels:

combined:     1111 1111 0000 0000 0000 0000 0000 0000
-----------------------------------------------------
alpha:        1111 1111
blue:                   0000 0000
green:                            0000 0000
red:                                        0000 0000

Which means this is a fully opaque black color.

这篇关于Java - 了解关于image.getRGB(x,y)输出的二进制项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 00:37