Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Printing BMP with MFC

Posted on 1998-05-11
2
Medium Priority
?
627 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:k9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
piano_boxer earned 400 total points
ID: 1309472
You need to convert the bitmap to a DIB and use StretchBlt
Take a look at this sample:

http://support.microsoft.com/support/kb/articles/q97/1/93.asp
0
 

Author Comment

by:k9
ID: 1309473
Thanks for the help!

Seems to be working OK now.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question