Mehar Ali
Mehar Ali

Reputation: 79

pixel color detection on system screen

Is there is any way to find color name of pixel on screen under pointer?

              robot=new Robot();
              Point  coord = MouseInfo.getPointerInfo().getLocation(); 
              color = robot.getPixelColor((int)coord.getX(), (int)coord.getY());

              hexString = Integer.toHexString(color.getRGB());
              hexString = hexString.substring(2, hexString.length()); 

now i want color name of this hex value (as blue/green/black etc)... how can i do this?

Upvotes: 0

Views: 818

Answers (1)

Viktor Mellgren
Viktor Mellgren

Reputation: 4506

Compare it with the Color.RED etc, and take the one closest to the input.

Or you could use wolfram alpha API http://products.wolframalpha.com/api/libraries.html

FFF0F5 is for example called Lavender Blush and if you type FFF0F4 it would suggest this as the closest

http://www.wolframalpha.com/input/?i=%23FFF0F5

Upvotes: 2

Related Questions