使用getRGB()时,负数的含义是什么? [英] What is the meaning of a negative number when using getRGB()?

查看:2317
本文介绍了使用getRGB()时,负数的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的颜色的东西,渲染等,并观看一对夫妇教程视频关于渲染等我的问题是,当我在像素上调用 getRGB 它返回一个负int。这个负数的含义是什么?例如,当我在r:186,g:186,b:186的颜色上调用 getRGB 时,它返回-4539718。这个数字如何与其rgb值相关?我已经进行了几次Google搜索,但没有成功。

I am new to color stuff, rendering etc. and watching a couple tutorial videos about rendering etc. My question is, when I call a getRGB method on a pixel, it returns a negative int. what is the meaning of this negative number? For example, when i call getRGB on a color with r: 186, g: 186, b: 186, it returns -4539718. How is this number related to its rgb value? I've made a couple of google search but was not successful.

推荐答案

getRGB 方法返回一个 int ,其4个字节分别是alpha,红,绿和蓝色分量。假设像素不透明,alpha是255(0xFF)。它是 int 中最重要的字节,第一个位在该值中设置。因为在Java int 中的值是根据 Two's Complement 签署的,该值实际上是负的,因为第一位是开的。

The getRGB method returns an int whose 4 bytes are the alpha, red, green, and blue components in that order. Assuming that the pixel is not transparent, the alpha is 255 (0xFF). It's the most significant byte in the int, and the first bit is set in that value. Because in Java int values are signed according to Two's Complement, the value is actually negative because that first bit is on.

这篇关于使用getRGB()时,负数的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆