title: GetDIBits and loop through pixels using X, Y
body: <p>I'm grabbing a portion of the screen and scanning through the pixels for a certain color range.</p>
  
  <p>I looked at <a href="http://msdn.microsoft.com/en-us/library/dd183402%28v=VS.85%29.aspx" rel="noreferrer">MSDN's Capturing an Image</a> example and know how to use the functions.</p>
  
  <p>I can get the bits into an array, but I'm not sure how to do it in such a way that I can loop through it as I would an image. A pseudo-example (which I'm sure is way off):</p>
  
  <pre><code>for ( x = 1; x &lt;= Image.Width; x += 3 )
  {
      for ( y = 1; y &lt;= Image.Height; y += 3 )
      {
          red = lpPixels[x];
          green = lpPixels[x + 1];
          blue = lpPixels[x + 2];
      }
  }
  </code></pre>
  
  <p>That's basically what I want to do, so if red, blue, and green is a certain color, I'll know what coordinate it's at (x, y) in the image.</p>
  
  <p>I just don't know how to use GetDIBits in such a way, and how to setup the array appropriately to be able to accomplish this.</p>