开发者

Scan screen for color

开发者 https://www.devze.com 2023-01-03 03:16 出处:网络
I would like, in Java, to scan the screen for a particular color. Any idea how to do开发者_运维技巧 that?Robot robot = new Robot();

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

Any idea how to do开发者_运维技巧 that?


    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;
    // ...


Use Java.awt.Robot to take a screenshot as an Image and proceess that.

0

精彩评论

暂无评论...
验证码 换一张
取 消