Board index » delphi » Bitmap Image Printing

Bitmap Image Printing

I have never tried to print a bitmap image using Delphi.  From the online
manual, I found instructions using the following code:

Bitmap1:=TBitmap.Create;
Bitmap1.LoadFromFile('filename');
with Printer do
    begin  
    Printer.BeginDoc;
    Printer.Canvas.Draw(0,0,Bitmap1);
    Printer.EndDoc;
end;

I only get a blank page output without printing the bitmap image.  What am
I doing wrong?

Thanks

 

Re:Bitmap Image Printing


Quote
GE MADISON wrote:

> I have never tried to print a bitmap image using Delphi.  From the online
> manual, I found instructions using the following code:

> Bitmap1:=TBitmap.Create;
> Bitmap1.LoadFromFile('filename');
> with Printer do
>     begin
>     Printer.BeginDoc;
>     Printer.Canvas.Draw(0,0,Bitmap1);
>     Printer.EndDoc;
> end;

Your 'with Printer do' is redundant.  You are using Printer.BeginDoc
inside the with block when you should just use BeginDoc.

Re:Bitmap Image Printing


Quote
GE MADISON wrote:

> I have never tried to print a bitmap image using Delphi.  From the online
> manual, I found instructions using the following code:

> Bitmap1:=TBitmap.Create;
> Bitmap1.LoadFromFile('filename');
> with Printer do
>     begin
>     Printer.BeginDoc;
>     Printer.Canvas.Draw(0,0,Bitmap1);
>     Printer.EndDoc;
> end;

> I only get a blank page output without printing the bitmap image.  What am
> I doing wrong?

> Thanks

You will need to get the image bits in Device Independet format using
the GetDiBits fucntion, then use the StretchDiBits function to transfer
the bits to the printer's canvas dc. There is a TI at our web site
that discusses doing this with a form. THis code could be adapted to
use with an image:

     TI3155 - A Better Way To Print a Form

--
Joe C. Hecht
Borland Delphi Developer Support Group
http://www.borland.com

Re:Bitmap Image Printing


Hello,

Printer resolution is more important than screen so your btmap is very
small
try to use the StretchDraw function, it should work fine :-)
--
Jean-Luc Mattei
jl...@club-internet.fr

GE MADISON <gemadi...@aol.com> wrote in article
<19970223202001.PAA03...@ladder02.news.aol.com>...

Quote
> I have never tried to print a bitmap image using Delphi.  From the online
> manual, I found instructions using the following code:

> Bitmap1:=TBitmap.Create;
> Bitmap1.LoadFromFile('filename');
> with Printer do
>     begin  
>     Printer.BeginDoc;
>     Printer.Canvas.Draw(0,0,Bitmap1);
>     Printer.EndDoc;
> end;

> I only get a blank page output without printing the bitmap image.  What
am
> I doing wrong?

> Thanks

Other Threads