简体   繁体   English

JAVA:getRGB()从透明像素返回什么值?

[英]JAVA: What values does getRGB() return from a transparent pixel?

If i were to int RGB = image.getRGB(x,y) , where x and y were the coordinates of a transparent pixel of image , what would the value of RGB be? 如果我将int RGB = image.getRGB(x,y) ,其中x和y是image的透明像素的坐标,那么RGB的值是多少? Null? 空值?

It can be basically anything. 基本上可以是任何东西。 The alpha component does not correlate with the RGB component. alpha分量与RGB分量不相关。

So for example if you have an ARGB object with (0, 45, 34, 23) and one with (0, 56, 78, 89) then they are both transparent so you don't have to care about color. 因此,例如,如果您有一个( 0,45,34,23)的ARGB对象和一个( 0,56,78,89)的ARGB对象,那么它们都是透明的,因此您不必关心颜色。

But if they are (10, 45, 34, 23), (10, 56, 78, 89) then the difference is visible. 但是,如果它们是(10,45,34,23),(10,56,78,89),则可以看到差异。 Alpha( A ) tells how opaque/transparent is something. Alpha( A )表示不透明/透明的东西。 The rest ( RGB ) tells the color of it. 其余部分( RGB )指示其颜色。

假设您正在使用Alpha RGB BufferedImage处理图像,则应使用getAlpha()

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

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