title: java Buffered Image : Detecting black pixels
body: <p>I have this simple code to go through a 24bit color windows bmp file</p>
  <pre><code>BufferedImage mapa = BMPDecoder.read(new File(&quot;maps/map.bmp&quot;));
      
  final int xmin = mapa.getMinX();
  final int ymin = mapa.getMinY();
      
  final int ymax = ymin + mapa.getHeight();
  final int xmax = xmin + mapa.getWidth();
  
  
  for (int i = xmin;i&lt;xmax;i++)
  {
     for (int j = ymin;j&lt;ymax;j++)
     {
                  
      int pixel = mapa.getRGB(i, j);
          
      if (pixel == 0)
      {
          System.out.println(&quot;black at &quot;+i+&quot;,&quot;+j);
      }
     }
  }
  </code></pre>
  <p>However, when testing on a completely black image, I get this value at pixel : <code>-16777216</code>.</p>
  <p>I was hoping to get a 0x0.</p>
  <p>How can I test for black pixels (or any other color for that reason) ?</p>
  <h1>update</h1>
  <p>Im testing against <code>((pixel &amp; 0xff) == 0)</code>. Is this right?
  Thanks in advance.</p>