Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Problem with printing images

edited April 2004 in General
Howzit,
Using Delphi 7, RB 7.03.
Getting a Range Check Error when trying to print a report. Narrowed it down
to this:

This is an except of code from unit ppUtils, procedure
ppDrawTransparentDIBitmapUsingStretchBlt

{draw the bmp to the mem canvas}
ppDrawDIBitmap(lMemCanvas, Rect(0 ,0, liBitmapWidth, liBitmapHeight),
aBitmap, cmSrcCopy);

{create a mask bmp}
lMaskBmp := TBitmap.Create;
lMaskBmp.Assign(aBitmap);

At the end of ppDrawDIBitmap, it calls DeleteObject which frees the
resources of aBitmap which causes lMaskBmp to gain an invalid handle on
"lMaskBmp.Assign(aBitmap);". This, in turn causes the line:

aBitmapInfoHeader.biBitCount := lBitmapDescription.bmBitsPixel *
lBitmapDescription.bmPlanes;
in procedure ppGetDIBitmapInfo to return a value out of the range of
datatype Word. Changing the code to:

{create a mask bmp}
lMaskBmp := TBitmap.Create;
lMaskBmp.Assign(aBitmap);

{draw the bmp to the mem canvas}
ppDrawDIBitmap(lMemCanvas, Rect(0 ,0, liBitmapWidth, liBitmapHeight),
aBitmap, cmSrcCopy);

with the assign before the call to ppDrawDIBitmap, solves the problem.

Am I doing something else wrong to cause this problem, or is there a problem
in ppUtils? Either way, how to fix it (besides me making this change to the
code).

Regards,
Gilbert Grant
Cura Risk Management Software

Comments

  • edited April 2004
    Hi Gilbert,

    There is a patch available that should fix this issue. Please send an email
    to support@digital-metaphors.com requesting the ppUtils patch and we'll send
    it right out to you.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.