Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How can i get a larger area of pixels for the Robot.getPixelColor(x, y) method?
- import java.awt.Color;
- import java.awt.Robot;
- public class Colour
- {
- int x, y;
- int n = 0;
- int m = 0;
- int i = 0;
- public Colour()
- {
- try
- {
- Robot robot = new Robot();
- Color targetColor = new Color(255, 25, 255);
- Color color = robot.getPixelColor(n, n);
- while (color.getRGB() != targetColor.getRGB() && i != 1000)
- {
- color = robot.getPixelColor(n, n);
- System.out.println("color = " + color);
- n++;
- i++;
- if (color.getRGB() == targetColor.getRGB())
- {
- i = 1000;
- System.out.println("colour found" + n + " " + n);
- }
- }
- }
- catch (Exception e)
- {
- }
- }
- public static void main(String[] args)
- {
- Colour color = new Colour();
- }
- }
- for(int i=0;i<=1000;i++){
- for(int j=0;j<=1000;j++){
- color = robot.getPixelColor(i, j);
- System.out.println("color = " + color);
- if(color.getRGB() == targetColor.getRGB()){
- System.out.println("colour found" + i + " " + j);
- i=1000;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment