How can i get a larger area of pixels for the Robot.getPixelColor(x, y) method?
<p>My current code, pasted below, will obviously only get the color of the pixels(x, y) <code>1,1</code>,        <code>2, 2</code>, <code>3,3</code> and so on until it finds a color with the same RGB values as <code>targetColor</code> and if it doesn't find a match stop at <code>1000,1000</code> pixels. What is a better way of doing this, so i am not only getting the colors of the pixel co-ordiantes <code>1,1</code>, <code>2,2</code> and so on. ?</p>

<p>AND I need to use the <code>getPixelColor(x, y)</code> method, because I need the co-ordiantes of the color, so I can click the color location.</p>

<pre><code>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() &amp;&amp; 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();
    }
}
</code></pre>

<p>If I was not clear in what i asked, just say and i will try to explain in more depth or a more understandable way.</p>
