1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
void thrDrawScene (unsigned char *drawing_bytes)
{
if ((!window.xSize) || (!window.ySize)) return;
BITMAPINFO info;
info.bmiHeader.biSize = sizeof (info.bmiHeader);
info.bmiHeader.biWidth = window.xSize;
info.bmiHeader.biHeight = window.ySize;
info.bmiHeader.biPlanes = 1;
info.bmiHeader.biBitCount = 24; // 24 bits per pixel - one unsigned char for each pixel
info.bmiHeader.biCompression = BI_RGB;
info.bmiHeader.biSizeImage = 0;
info.bmiHeader.biClrUsed = 0;
info.bmiHeader.biClrImportant = 0;
HDC cDC = CreateCompatibleDC (hdc); // this is the GetDC (hwnd) where hwnd is the
// handle of the window I want to write to
HBITMAP hbmp = CreateCompatibleBitmap (hdc, window.xSize, window.ySize);
SetDIBits (hdc, hbmp, 0, window.ySize, drawing_bytes, &info, DIB_RGB_COLORS);
hbmp = (HBITMAP) SelectObject (cDC, hbmp);
BitBlt (hdc, 0, 0, window.xSize, window.ySize, cDC, 0, 0, SRCCOPY);
DeleteObject (SelectObject(cDC, hbmp));
DeleteDC (cDC);
}
|