简体   繁体   中英

How to get Original value from RGB in java

I create RGB from 320 number. I got following
output:

-16776896

I wrote this code

Color c=new Color(320);
System.err.println(c.getRGB());
System.out.println(c.getRed()+" "+c.getGreen()+" "+c.getBlue()+" "+c.getAlpha());
System.out.println(c.toString());

Now I want to retrive 320 value from this -16776896 . what should i do?

System.out.println(c.getRGB() & 0x00ffffff);

The input is bitwise OR d with 0xFF000000 in the constructor of Color . This is the inverse operation.

Actually, it is impossible to get the original value if it is negative or bigger than 16777215 .

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