I\'m grabbing a portion of the screen and scanning through the pixels for a certain color range.
I looked at MSDN\'s Capturing an Image example and know how to use t
In the link you post you create a 32-bit bitmap so I'll assume you are reading from a 32-bit bitmap (This assumption may be incorrect).
Therefore changing your loop to the following should work:
char* pCurrPixel = (char*)lpPixels;
for ( y = 0; y < Image.Height; y++ )
{
for ( x = 0; x < Image.Width; x++ )
{
red = pCurrPixel[0];
green = pCurrPixel[1];
blue = pCurrPixel[2];
pCurrPixel += 4;
}
}
Things to bear in mind:
1.Arrays are 0 based in C/C++
2. You were stepping 3 pixels horizontally and vertically each time. Which meant you aren't visiting every pixel.
3. A bitmap is usually organised such that there are "height" spans of "width" pixels. Therefore you should step through each pixel in a span and then move to the next span.
4. As already pointed out make sure you aare reading pixels correctly. in 16-bit mode its more complex