I'd like to save my "screen" in bmp; but a think I'm doing it wrong because this code is really slow:
HDC Win = GetDC(NULL);
for (j = 0; j < y; j++)
for (i = 0; i < x; i++)
img->data[j][i] = GetPixel(Win, i, j);
I'd like to save my "screen" in bmp; but a think I'm doing it wrong because this code is really slow:
HDC Win = GetDC(NULL);
for (j = 0; j < y; j++)
for (i = 0; i < x; i++)
img->data[j][i] = GetPixel(Win, i, j);
CreateDIBSection
to create a bitmap with pointer to raw bits, and BitBlt
from screen into the created bitmap. This works way faster than pixel by pixel queries and you have all the data in memory accessible using regular pointer.
See Performing full screen grab in windows for a code snippet.