Link to home
Start Free TrialLog in
Avatar of k9
k9

asked on

Printing BMP with MFC

When I'm printing a bitmap that I load from a file on disk, all that gets printed is a black box. Lines and text are printed correctly.

Here is a sample of the code I use....

CPrintDialog dlgPrint(FALSE,PD_ALLPAGES|PD_RETURNDC,NULL);
dlgPrint.DoModal().
CDC *pDC = new CDC;
pDC->Attach(dlgPrint.m_pd.hDC);
pDC->StartDoc("My Document");
pDC->StartPage();
CFont *pFont;
CDC dcImage;
if (dcImage.CreateCompatibleDC(pDC))
{
      CBitmap m_Bmp;
      m_Bmp.LoadBitmap("my_bmp.bmp");
      dcImage.SelectObject(&m_Bmp);
      pDC->BitBlt(x,y,width,height,&dcImage,0,0,SRCCOPY);
      m_Bmp.DeleteObject();
      dcImage.DeleteDC();
}
font.CreateFont(50,0,0,0,FW_BLACK,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,NULL,"Arial");
pFont = pDC->SelectObject(&font);
pDC->TextOut(x,y,"text");

Would appreciate any help with this.
ASKER CERTIFIED SOLUTION
Avatar of piano_boxer
piano_boxer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of k9
k9

ASKER

Thanks for the help!

Seems to be working OK now.