Get the name of a hex color in Java?

There should be a simple question, let's say I have something like this:

int pink = 0xff00ff;

      

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

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

+3


source to share


1 answer


If they are not an existing library, you may need to create a list of colors and get the closest value.

I think this is a good source for getting started:



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

+1


source







All Articles