Solved

Printing Bitmaps

Posted on 2000-02-20
5
264 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…

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

14 Experts available now in Live!

Get 1:1 Help Now