Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Printing Bitmaps

Posted on 1998-06-01
5
Medium Priority
?
268 Views
Last Modified: 2013-11-19
I'm currently working on a project in Visual C++ 1.52 on a Windows for Workgroups 3.11 system.  I am trying to print a bitmap image to a thermal receipt printer.  I know the printer has the capabilities to print graphics because I can print the image from Paintbrush.  I know the basics of output of an image an am confused as to why it won't work in this situation.  I have the following code in my OnDraw function in my View class (derived from CFormView):

// Display the bitmap
CDC* pDisplayMemDC = new CDC;
CBitmap *pBitmap = new CBitmap;                            pBitmap->LoadBitmap(IDB_DEPART_BITMAP);         pDisplayMemDC->CreateCompatibleDC(pDC);
pDisplayMemDC->SelectObject(pBitmap);
pDC->BitBlt( 0, 0, 5000, 5000, pDisplayMemDC, 0, 0,                     SRCCOPY);

When I try to print nothing is output.  When I put the same code in the OnDraw but don't condition before it with "if (IsPrinting)" I have no problem.  It comes right up on screen.  Any help would be appreciated.
      delete pDisplayMemDC;
      delete pBitmap;
0
Comment
Question by:jstephe1
[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
  • 3
5 Comments
 
LVL 2

Accepted Solution

by:
SamratAshok earned 200 total points
ID: 1315867
You cannot print a bitmap directly. You have to convert it into
DIB (Device Indepedant Bitmap) and then render it using StretchBlt API function to render it on printer device.

If you have MFC example code, look for application like Diblook
or something like that.

Hope this helps
0
 
LVL 23

Expert Comment

by:chensu
ID: 1315868
You can print a bitmap (DDB) directly. A printer DC is just like a screen DC.
0
 
LVL 2

Expert Comment

by:SamratAshok
ID: 1315869
Well Chensu.

I tried a lot for that. My application had something like 60 to 70 bitmaps
and I had to do convert each one of them to DDB before producing acceptable
output on paper.

Eventually, I used to saved the convert bitmaps as DDB files in order to make code a bit faster and less resource consuming.

I even dug up some microsoft references, but all seemed
to say the same.
0
 

Author Comment

by:jstephe1
ID: 1315870
I tried the same code and displaying it on screen was no problem.  I know I have a pointer to the print device since I can output text.  How do I take a file (test.bmp) and make it print?  Does anyone have sample code?
0
 
LVL 2

Expert Comment

by:SamratAshok
ID: 1315871
If you have sample examples, look under sample called DIBLOOK. Iam not sure if
it comes with VC 1.52. You will have to mess around with code a bit, to get what you
want, but it is not too difficult.

If not, please post your email address where I can send you
the code. (There are about 4 to 5 files involved)


0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

647 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