Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scan screen for color

I would like, in Java, to scan the screen for a particular color.

Any idea how to do that?

like image 466
Rok Povsic Avatar asked Jun 13 '10 19:06

Rok Povsic


People also ask

Is there a colored scan?

Depending on the configuration of the machine, a scanner can produce images that are black and white or color. In a color scanner the digital color image consists of three gray-scale images. These images are often called layers.


1 Answers

    Robot robot = new Robot();
    Rectangle captureSize = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
    BufferedImage bufferedImage = robot.createScreenCapture(captureSize);
    // ...

    int color = image.getRGB(x, y);

    int  red = (color & 0x00ff0000) >> 16;
    int  green = (color & 0x0000ff00) >> 8;
    int  blue = color & 0x000000ff;
    // ...
like image 153
Romain Hippeau Avatar answered Sep 23 '22 14:09

Romain Hippeau