This may not be the most efficient way to do it, but I did write some
win32 extensions for my
EasyBMP C++ bitmap library.
The included code sample does a screen capture to a BMP bitmap image. (You can examine the source to determine how it works.) If you want to capture only the desktop, you'd have to find the win32 command to minimize all windows. (
This and
this may get you started.)
Suppose then that you have captured the screen to a BMP object ScreenCap. Then you'd get the (i,j) pixel as follows:
-
cout << "pixel (i,j) is (" << (int) Image(i,j)->Red << ","
-
<< (int) Image(i,j)->Green << ","
-
<< (int) Image(i,j)->Blue << ","
-
<< (int) Image(i,j)->Alpha << ")" << endl;
-
You can combine these red, green, blue, and alpha values as you see fit. For instance, to put them into a 32-bit number, I guess you might do this:
-
int AllTogether = 255*255*255*Image(i,j)->Blue
-
+ 255*255*Image(i,j)->Green
-
+ 255*Image(i,j)->Red
-
+ Image(i,j)->Alpha;
-
(Note that the RGBQUAD data type in win32 stores in order of blue, green, red, alpha). Now, I may have my data reversed, in which case you'd want to reverse my code sample to alpha, red, green, blue.
I hope this gets you started. -- Paul