Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Printing Bitmaps

Posted on 2000-02-20
5
Medium Priority
?
287 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
[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
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 200 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…

722 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