Printing 256 colors images drawn in a memory DC
Posted on 1997-04-21
I am currently trying to transfer a memory DC (m_dcMem) toward a printer DC by overriding CView::OnPrint(), but whereas everything is OK in Print-Preview Mode, the resulting hardcopy is black and white (without the expected grey-levels). I must precise that m_dcMem is one of my class view members and is initialized with :
Thus, m_dcMem is compatible with a display context, and then I draw a 256 colors image in it (and I visualize the result by transferring m_dcMem to the screen in CView::OnDraw) : the transfer to a Display Context is successfull but the transfer to a Printer DC fails partially (this printer can print grey levels).
Here is the extract of the source code that produce a black and white hard-copy instead of a grey level one :
void CPolytraceView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
// pPal is the logical palette associated with the
// image drawn in m_dcMem.
pOldPal = pDC->SelectPalette(pPal, TRUE);
Moreover, I tried to use an intermediate memory DC (dcPrinter) between m_dcMem and the printer. dcPrinter was made compatible with the printer DC, and I tried to transfer m_dcMem to dcPrinter with BitBlt, but to do so, I had to create a bitmap and select it into dcPrinter : SelectObject fails if this bitmap is not a monochrome bitmap ! Furthermore, I tried to do m_dcMem local in OnPrint (initialized with "CClientDC ClientDC(this);
dcMem.CreateCompatibleDC(&ClientDC);"), but the result didn't change at all...
Now, I have no more ideas and feel very disappointed not to be able to solve such a classical problem : I need your help and I thank you in advance.