Solved

Printing BMP with MFC

Posted on 1998-05-11
2
599 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
2 Comments
 
LVL 4

Accepted Solution

by:
piano_boxer earned 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 92
no14 challenge 14 62
building a service to accessed via telnet client, want colors ? 4 80
Excel file not created as expected 7 46
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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 is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

929 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now