Hi. Just to let you all know, we are working on a DLL to return a string containing pixel data from an area of the screen. It's very simple, cycles through a for loop and returns a single string, with each color seperated by a " ".
Now, I am very bad at C++, but I managed to get it to work with GetPixel. But that is very slow, so I want to use DIB functions. Unfortunately that is very complicated...
Here is the code we have so far (Yes I know there is a potential memory problem, but it works.)
#define GMString extern "C" __declspec(dllexport) char*
#include <string>
#include <stdlib.h>
#include <windows.h>
usingnamespace std;
GMString getPixels(double x, double y, double w, double h) {
COLORREF c;
HDC hDC;
hDC = GetDC(NULL);
string stri;
double size = (w)*(h);
int size2 = int(size);
char temp1[size2];
string stri2;
int x2 = int (x);
int y2 = int (y);
int w2 = int (w);
int h2 = int (h);
int i = 0;
for (int xx=x2; xx<x+w2; xx++) {
for (int yy=y2; yy<y+h2; yy++) {
c=(GetPixel(hDC, xx, yy));
itoa(c, temp1, 10);
stri += temp1;
stri += " ";
i+=1;
}
}
ReleaseDC(GetDesktopWindow(), hDC);
returnconst_cast<char *>(stri.c_str());
}
Now I tried adding the DIB stuff with no luck. I have no idea if I'm using the right DIB functions, and I don't have a clue what the stuff on MSDN means (such as tydef structs and what I'm supposed to do with GetDIBits.
The experimental code is this but I get an error on the line with &PBITMAPINFO,