BitBlt turns entire image black?
Ok, I have the following code in my window processes function (where you would expect it in the switch-case block):
Code:
case WM_PAINT:
{
PAINTSTRUCT Ps;
HDC hDC = BeginPaint(hwnd, &Ps);
HBITMAP graph = CreateCompatibleBitmap(hDC, 400, 300);
int x, y;
SelectObject(hDC, graph);
for( x = 0; x < 400; x++)
for( y = 0; y < 300; y++)
SetPixel(hDC, x, y, RGB(255, 0, 0));
EndPaint(hwnd, &Ps);
break;
}
And it does exactly what I expect it to, draw a big red rectangle in the window.
However, if I do the following:
Code:
case WM_PAINT:
{
PAINTSTRUCT Ps;
HDC hDC = BeginPaint(hwnd, &Ps);
HDC testbit = CreateCompatibleDC(hDC);
HBITMAP graph = CreateCompatibleBitmap(testbit, 400, 300);
int x, y;
SelectObject(testbit, graph);
for( x = 0; x < 400; x++)
for( y = 0; y < 300; y++)
SetPixel(testbit, x, y, RGB(255, 0, 0));
BitBlt(hDC,0,0,400,300,testbit,0,0,SRCCOPY);
DeleteDC(testbit);
EndPaint(hwnd, &Ps);
break;
}
The rectangle I get is black. Can anybody tell me why this is?