So, as I said in an earlier post I've been trying to write some MFC C++ code to (1) create a CPaintDC, (2) render to it, and (3) save it to file as a BMP or DIB. And I haven't been able to get this to work, surprisingly.
The code I've cobbled together from doc and samples is below, but for some reason it just outputs a black/null square. (I should be drawing a green square.)
Can anyone see any problems with this code?
Thanks *very* much for any help.
dc.FillSolidRect(rc, 0x0000FF00); // aarrggbb ; green
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = rc.Width();
bmi.bmiHeader.biHeight = -rc.Height(); // top-down
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
m_hBmp = CreateDIBSection(dc, &bmi, DIB_RGB_COLORS, (void**)&pBits, NULL, NULL);
MessageBox(L"Done", L"debug", 0);