Solved

Printing BMP with MFC

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
unable to delete all specified values regedit 38 386
bigDiff challenge 17 104
How to convert MFC::CString to UTF8 wchar_t* 10 201
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 93
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

18 Experts available now in Live!

Get 1:1 Help Now