GDI + only outputs monochrome to DC memory

I am trying to double-buffer in an MFC application and am trying to use DC memory with GDI +. However, although I called CreateCompatibleDC (), I only get a monochrome image. Here is the code:

CDC bufferDC;
CBitmap bufferBitmap;
bufferDC.CreateCompatibleDC(&dc);
bufferBitmap.CreateCompatibleBitmap(&bufferDC, 300, 300);
bufferDC.SelectObject(bufferBitmap);
Graphics g(bufferDC);
g.Clear(Color::Green);
dc.BitBlt(0, 0, 300, 300, &bufferDC, 0, 0, SRCCOPY);

Instead of a green patch, I see a rectangle with fading black and white dots. I even tried saving the bitmap to disk after calling g.Clear (). This is really a 1-bit depth file.

Any ideas what went wrong? Thank.

+5
source share
3 answers

. DC , , . , DC, . , DC, .

DC, DC .

+10

bitnmap bufferDC dc ( , ), ... DC.

&dc CreateCopmpatibleBitmap.

0

, dc. This, , , . . NULL CreateCompatibleDC, , , , , .

0

All Articles