Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

Printing Bitmaps

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
philsmicronet
Asked:
philsmicronet
1 Solution
 
pjknibbsCommented:
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
 
nutsnutsCommented:
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
 
philsmicronetAuthor Commented:
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
 
pjknibbsCommented:
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
 
chensuCommented:
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Tackle projects and never again get stuck behind a technical roadblock.
Join Now