Solved

Printing Bitmaps

Posted on 2000-02-20
5
279 Views
Last Modified: 2013-12-03
I have a xerox postscript laser. I am using the Loading a bitmap using the NViewLib functions that have been recommended before at this site. When I try to print them, I am not getting any output.

The following code is used
                                        lpProc=GetProcAddress(hLib "NViewLibLoad);
hBitmap = (HBITMAP)lpProc("BitMap.bmp", FALSE);
GetObject(hBitmap, sizeof(BITMAP),&bitmap);
hDCMemory = CreateCompatibleDC(hPrinterDC);
hOldBitmap = SelectObject(hDCMemory,hBitmap);               StretchBlt(hPrinterDC, X, Y, l, h, hDCMemory, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);

SelectObject(hDCMemory,hOldBitmap);
DeleteObject(hBitmap);               DeleteDC(hDCMemory);
0
Comment
Question by:philsmicronet
5 Comments
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2542638
I'm not familiar with the NViewLib stuff, but personally I'd load the bitmap file directly as a device-independent bitmap, then call StretchDIBits() to print it. Having come across printer drivers which claimed to support certain functions but manifestly didn't, I think this is probably the safest way to go.
0
 
LVL 1

Expert Comment

by:nutsnuts
ID: 2542850
What's your bitmap's width and height? Please notice the printer DC has much higher resolution than the normal window DC. So if you destination bitmap on printer DC is too large, it may be failed in the StretchBlt function for insuffient memory to create the bitmap.
0
 
LVL 1

Author Comment

by:philsmicronet
ID: 2545319
How do I make it a device independent bitmap. The nviewlib stuff just loads any type of picture from a file (gif, jpg, bmp, dib). You get a handle to it.

How can I use StretchDIBits()
0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2545352
If the file on disk is a BMP, it's already a device-independent bitmap. If it's some other format, you'd have to convert it yourself. I assumed you were using BMPs--if I was wrong, I apologise.
0
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 2562730
Thank you.


As per our email,

>chensu:

Based on the information you have given, there are two possibilities I can think of.

1. hDIB is an invalid handle.
2. hDIB is allocated by GlobalAlloc with the GMEM_FIXED or GPTR flags, in which case the return value of GlobalAlloc is a pointer instead of a handle. You don't have to GlobalLock it. You may use the pointer directly.

>philsmicronet:

The handle seems to be valid in the I can use GetObject on the handle and it successfully returns info on the bitmap. Have you got any idea how to print the bitmap you get back from NVIEWLIB. I am using BitBlt and StretchBlt to display it on a screen successully, however I cannot make it print it to a printer. Your help would be very much appreciated.

>chensu:

Since you mentioned that you could use GetObject on the handle, it means
that the handle is of type HBITMAP. However, the StretchDIBBlt function
expects a memory handle, which is allocated by GlobalAlloc. They are
different. Take a look at some samples on DIBs.

>philsmicronet:

Thanks heaps for that. I have a question on Experts Exchange on this subject if you want to supply an answer. I converted the BMP to a DIB using the function in SEEDIB and it worked like a gem. Thanks very much for you help
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

829 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