Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using TCanvas.StretchDraw on Printer.Canvas

499 views
Skip to first unread message

Thomas Munk

unread,
Feb 16, 1998, 3:00:00 AM2/16/98
to

I have a very simple print job defined as the following:

Printer.BeginDoc;
Printer.Canvas.StretchDraw(Rect,Image1.Picture.Bitmap);
Printer.EndDoc;

On my local (LPT1) HP DeskJet this works just fine. But on two different
networked laser printers nothing is written (at least a blank page). In this
case, the print job is also very small (13 KB) where the image itself is 1
MB. If I'm working offline from the network and set the laser-drivers
offline a job of more than 1 MB is put in the queue. Is this a
Delphi-related problem? Does StretchDraw work on "all" printers?
GetDeviceCaps/RC_STRETCHDIB says yes.

I guess that, from my Delphi-programming-point-of-view, there should be no
difference on making a print job for either an LPT-connected printer or a
printer on a network destination?

Peter Below

unread,
Feb 16, 1998, 3:00:00 AM2/16/98
to

> I have a very simple print job defined as the following:
>
> Printer.BeginDoc;
> Printer.Canvas.StretchDraw(Rect,Image1.Picture.Bitmap);
> Printer.EndDoc;
>
> On my local (LPT1) HP DeskJet this works just fine. But on two different
> networked laser printers nothing is written (at least a blank page). In this
> case, the print job is also very small (13 KB) where the image itself is 1
> MB. If I'm working offline from the network and set the laser-drivers
> offline a job of more than 1 MB is put in the queue. Is this a
> Delphi-related problem? Does StretchDraw work on "all" printers?
> GetDeviceCaps/RC_STRETCHDIB says yes.
>
Thomas,

the problem is that you print a device-dependent bitmap in the screen format.
For that to work the video driver and printer driver need to work out some
method to translate the bitmap to the printers device-dependent format. Not
all are smart enough to do this. The proper way to print a bitmap is to
convert it to a device-independent bitmap (DIB) first and then print it with
StretchDIBits. The Delphi 1 MANUALS.TXT file has an example near the end. If
you have D2 or 3 search for the file on your CD in the Delphi 1 runimage
directory tree.

Peter Below (TeamB) 10011...@compuserve.com)


Earl F. Glynn

unread,
Feb 16, 1998, 3:00:00 AM2/16/98
to

Thomas Munk wrote in message <6c9adf$mr...@forums.borland.com>...

>I have a very simple print job defined as the following:
>
> Printer.BeginDoc;
> Printer.Canvas.StretchDraw(Rect,Image1.Picture.Bitmap);
> Printer.EndDoc;
>
>On my local (LPT1) HP DeskJet this works just fine. But on two different
>networked laser printers nothing is written (at least a blank page). In
this
>case, the print job is also very small (13 KB) where the image itself is 1
>MB. If I'm working offline from the network and set the laser-drivers
>offline a job of more than 1 MB is put in the queue. Is this a
>Delphi-related problem? Does StretchDraw work on "all" printers?
>GetDeviceCaps/RC_STRETCHDIB says yes.


I don't remember all the details here, but I think the problem is somehow
you're printing a DDB (device dependent bitmap) instead of a DIB (device
independent bitmap). To solve your problem, use the API call
StetchDIBits.

For an example, see my "Printer Demo" on the "Delphi and Other Project"
page of my Computer Lab web site. See URL below. Note that items
4, 5, and 6 in the demo show the difference between Draw, StetchDraw
and StretchDIBits.

efg
____________________________________________
E-Mail: Earl...@att.net
Personal Web Site: http://infomaster.net/external/efg

Earl F. Glynn
MedTech Research Corporation, Lenexa, KS 66219 USA


0 new messages