Board index » delphi » Problem loading and printing a large bitmap

Problem loading and printing a large bitmap

I made a small Delphi 4.0 program to load a bitmap into an image
(LoadFromFile) and I try to print it on the default printer using
Printer.BeginDoc, Printer.Canvas.StretchDraw, Printer.EndDoc

It works most of the times with most bitmaps.  I particularly have
problems with larger bitmaps.  When loading a 22 Megs bitmap (5300 x
4500, 256 colors), I do not get any errors, but the bitmap is not
displayed in my image (stretch = TRUE).  When I try to print it, I get
a IO error on my laser printer, if I try to enlarge it (by printing by
bitmap on 4 pages instead of 1), it works.

HELP! Is this a Delphi bug?  My machine has 64 Megs of memory.

I can send you the source if your want, it's only 13K

Jacques Lebrun (jacques.leb...@sisca.com)

Sent via Deja.com http://www.deja.com/
Before you buy.

 

Re:Problem loading and printing a large bitmap


"Jacques Lebrun" <jacques.leb...@sisca.com> skrev i en meddelelse
news:913eao$tgf$1@nnrp1.deja.com...

Quote
> I made a small Delphi 4.0 program to load a bitmap into an image
> (LoadFromFile) and I try to print it on the default printer using
> Printer.BeginDoc, Printer.Canvas.StretchDraw, Printer.EndDoc

Argh!
StretchDraw is guaranteed *not* to work with printers.
It's only pure luck that it works sometimes.
You have to use StretchDIBIts to print bitmaps.
Here is an example. It's not perfect but it's a start.
http://community.borland.com/article/0,1410,16412,00.html

Finn Tolderlund

Re:Problem loading and printing a large bitmap


In article <8akZ5.4$7i2.8496...@superman.mobilixnet.dk>,
  "Finn Tolderlund" <XnospamYfinn.tolderlu...@Ymobilixnet.dkXnospamY>
wrote:
Quote

> "Jacques Lebrun" <jacques.leb...@sisca.com> skrev i en meddelelse
> news:913eao$tgf$1@nnrp1.deja.com...
> > I made a small Delphi 4.0 program to load a bitmap into an image
> > (LoadFromFile) and I try to print it on the default printer using
> > Printer.BeginDoc, Printer.Canvas.StretchDraw, Printer.EndDoc

> Argh!
> StretchDraw is guaranteed *not* to work with printers.
> It's only pure luck that it works sometimes.
> You have to use StretchDIBIts to print bitmaps.
> Here is an example. It's not perfect but it's a start.
> http://community.borland.com/article/0,1410,16412,00.html

> Finn Tolderlund

Is this available with the standard edition of Delphi 4.0?  I don't see
it anywhere in the help screens.

Sent via Deja.com
http://www.deja.com/

Re:Problem loading and printing a large bitmap


"Jacques Lebrun" <jacques.leb...@sisca.com> skrev i en meddelelse
news:918n4q$82l$1@nnrp1.deja.com...

Quote
> In article <8akZ5.4$7i2.8496...@superman.mobilixnet.dk>,
>   "Finn Tolderlund" <XnospamYfinn.tolderlu...@Ymobilixnet.dkXnospamY>
> wrote:
> > StretchDraw is guaranteed *not* to work with printers.
> > It's only pure luck that it works sometimes.
> > You have to use StretchDIBIts to print bitmaps.
> > Here is an example. It's not perfect but it's a start.
> > http://community.borland.com/article/0,1410,16412,00.html

> Is this available with the standard edition of Delphi 4.0?  I don't see
> it anywhere in the help screens.

What do you mean by "this" and "it"?
What are you refering to?

Finn Tolderlund

Re:Problem loading and printing a large bitmap


...

Quote
> > Is this available with the standard edition of Delphi 4.0?  I don't
see
> > it anywhere in the help screens.

> What do you mean by "this" and "it"?
> What are you refering to?

> Finn Tolderlund

Sorry, I was searching for StretchDiBits in Delphi's help and could not
find any references.  Obviously, the only way to find a reference to an
ObjectWindow function is to type it in the editor and press F1 to get
its description!

Jacques Lebrun

Sent via Deja.com
http://www.deja.com/

Re:Problem loading and printing a large bitmap


"Jacques Lebrun" <jacques.leb...@sisca.com> skrev i en meddelelse
news:91aqs1$tt5$1@nnrp1.deja.com...

Quote
> > What do you mean by "this" and "it"?
> > What are you refering to?

> Sorry, I was searching for StretchDiBits in Delphi's help and could not
> find any references.  Obviously, the only way to find a reference to an
> ObjectWindow function is to type it in the editor and press F1 to get
> its description!

No, it's not the only way.
You just have to realize that StretchDiBits is a Windows API and it is
therefore not explained in the Delphi help. It is explained in the Win32
help (from MS) which Borland is so nice to supply together with Delphi.
If you open the win32 help file directly and look for StretchDiBits then you
will find it at once.

Finn Tolderlund

Re:Problem loading and printing a large bitmap


In article <8akZ5.4$7i2.8496...@superman.mobilixnet.dk>,
  "Finn Tolderlund" <XnospamYfinn.tolderlu...@Ymobilixnet.dkXnospamY>
wrote:

Quote

> "Jacques Lebrun" <jacques.leb...@sisca.com> skrev i en meddelelse
> news:913eao$tgf$1@nnrp1.deja.com...
> > I made a small Delphi 4.0 program to load a bitmap into an image
> > (LoadFromFile) and I try to print it on the default printer using
> > Printer.BeginDoc, Printer.Canvas.StretchDraw, Printer.EndDoc

> Argh!
> StretchDraw is guaranteed *not* to work with printers.
> It's only pure luck that it works sometimes.
> You have to use StretchDIBIts to print bitmaps.
> Here is an example. It's not perfect but it's a start.
> http://community.borland.com/article/0,1410,16412,00.html

> Finn Tolderlund

You can download TPrintService demo with Screenshot printing example.
http://www.greatis.com/prnservdemo.zip
See more details on:
http://www.greatis.com/prnserv.htm

Dmitry Vasiliev.

Sent via Deja.com
http://www.deja.com/

Other Threads