简体   繁体   中英

Get the name of a hexadecimal colour in Java?

Should be a straightforward question, say I have something like this:

int pink = 0xff00ff;

How can I convert this integer to find out what colour it is? So basically an algorithm of some sort that will take a colour and print out it's name. It doesn't matter if it's a light or dark pink, it just needs to tell me that it is pink. Is this possible? I'm using Java, if this helps.

edit: Also, I don't mind if I have to use a library.

Unless their is an existing library, you might have to create the list of colours and get the closest value.

I think this is the good source to get started:

https://gist.github.com/XiaoxiaoLi/8031146

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