Link to home
Start Free TrialLog in
Avatar of mikepj
mikepjFlag for Canada

asked on

Problem with StretchDraw to a printer canvas

Hi,

I have a small problem using StretchDraw to the printer canvas.  The problem is that the image is not visible when the report is printed on the printer or printed to Acrobat.  This section of the code has been newly written.  This has been seen on different computers with the same results.

The size and position are correct (I only know this because if I use CopyMode cmBlackness, the correct image size and location are evident.  I know that the image was successfully loaded because I did a test StretchDraw to a TImage canvas (using different DrawRect) after the StretchDraw to the printer canvas and the image was visible.

I have tried various CopyModes without success.  This has been primarily tested under Windows 98.

What is happening?

Thank you,
MP

    LogoBitmap:=TBitmap.Create;

    With Printer.Canvas Do
      Try
        Try
          LogoBitmap.LoadFromFile(Cfg.LogoName);
        Except
          ShowMessage('Error reading logo:  '+Cfg.LogoName);
          Exit;
        End;

        DrawRect:=...

        CopyMode:=cmSrcCopy;
        StretchDraw(DrawRect,LogoBitmap);
      Finally
        LogoBitmap.Free;
      End;

Avatar of Epsylon
Epsylon

try this..

b := tbitmap.create;
b.loadfromfile('whatever');
drawrect := rect(0, 0, 100, 100);
printer.begindoc;
printer.canvas.stretchdraw(drawrect, b);
printer.enddoc;
b.free;

This might work.. try it out..

..-=ViKtOr=-..
Avatar of mikepj

ASKER

Thank you for your message.

This was basically what I was doing.  Epsylon's suggestion fixed the problem.  VERY interesting!

If Epsylon could submit the comment as an answer, I would be pleased to accept the answer.

Thank you for your help!
MP

Thanks Mikepj, glad my suggestion helped you     :o)

Cheers,

Epsylon.
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial