title: Find color with tolerance in bufferedimage
body: <p>I'm writing a method that will attempt to find a color in a bufferedImage. At the moment, the method works by taking a screencap, and then scanning the image for a specific color. Now I'd like to add some RGB tolerence, so if the user is trying to find color (1, 3, 5) with tolerance 1, any color +-1 R, B or G will return true.</p>
  
  <p>I could solve this by first generating a arrayList of RGB values that work, and then for each pixel I could go through the array and check with each value. The problem is that would probably get VERY slow for high tolerances on large images.</p>
  
  <p>Is there a more efficient or possibly a built in way I can do this? Here is my method as it stands right now. Thank you!</p>
  
  <pre><code>public static Point findColor(Box searchArea, int color){
      System.out.println("Test");
      BufferedImage image = generateScreenCap(searchArea);
      for (int i = 0; i &lt; image.getWidth(); i++) {
          for (int j = 0; j &lt; image.getHeight(); j++) {
              if((image.getRGB(i, j)*-1)==color){
                  return new Point(i + searchArea.x1, j + searchArea.y1);
              }
          }
      }
      return new Point(-1, -1);
  }
  </code></pre>
  
  <p>Edit: I'm using the int RGB values for all comparisons, so instead of Color[1, 1, 1], I use Color.getRGB() which returns a negative int which I convert to positive for end user simplicity.</p>