Solved

Printing BMP with MFC

Posted on 1998-05-11
2
596 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

707 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

13 Experts available now in Live!

Get 1:1 Help Now