I have an array defined as:
COLORREF* array = (COLORREF*)malloc(SCR_WIDTH * SCR_HEIGHT * sizeof(COLORREF));
An algorithm updates this array with RGB colors continuously.
I'm just looking for a fast way to display this image on the screen, in particular BitBlt
vs. SetDIBitsToDevice
.
I've been successful using BitBlt
:
map = CreateBitmap(SCR_WIDTH, SCR_HEIGHT, 1, 32, (void*)array);
src = CreateCompatibleDC(hdc);
oldBitmap = SelectObject(src, map);
BitBlt(hdc, 0, 0, SCR_WIDTH, SCR_HEIGHT, src, 0, 0, SRCCOPY);
SelectObject(src, oldBitmap);
DeleteDC(src);
DeleteObject(map);
However, I think that SetDIBitsToDevice
would be faster since you can draw the pixels directly to the screen without the need to create a compatible DC (correct me if I'm wrong).
The problem that I'm having is that SetDIBitsToDevice
needs these two arguments and I can't find how to obtain/create them from the RGB array:
const VOID *lpvBits,
const BITMAPINFO *lpbmi,
Any help is appreciated. I'm also open to suggestions that could work even faster (preferably using WINGDI).
Thanks a lot!