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

How to use GetGraphicClass in ppDBImage

edited June 2002 in General
Hi,

I want to create a report that is capable of displaying in a single
ppDBImage field different types of graphic images, for instance a Bitmap or
a JPEG depending on which one happens to be stored in a Graphic field in any
particular record of a data table.

In the simple example below, every record of the data table has a value for
the field 'graphicclass1' of either 'TBitmap' or 'TJPEGImage'. I have no
problem assigning the appropriate GraphicType to the ppDBImage object,
however when I run the report, the image is always blank. However, if I
remove the onGetPicture event call from the ppDBImage, and set the
GraphicType attribute of the ppDBImage component to Bitmap, for example,
then the report works just fine (as long as I only feed it the records with
Bitmap images -- it errors out if it encounters a JPEG, of course).

Even more interesting, if I then take the "working" report outlined above
and add the call to the OnGetPicture event -- and comment out ALL the code
in the OnGetPicture event -- the image is once again blank when I run the
report. It's almost as though just calling that event causes the image to be
blank.

Any help you could offer would be greatly appreciated! Thanks!
Jason

procedure TReportForm.ppDBImage1GetPicture(Sender: TObject;
aPicture: TPicture);
var
medit: TppDBImage;
mfield: String;
begin
medit := sender as TppDBImage;
mfield := 'graphicclass1';
if ReportSource.dataset.fieldByName(mfield).asString='TJPEGImage'
then medit.graphictype:='JPEG';
if ReportSource.dataset.fieldByName(mfield).asString='TBitmap' then
medit.graphictype:='Bitmap';
end;

Comments

  • edited June 2002
    If the OnGetPicture event is implement it RB does not assign the BLOB to the
    picture. It expect you to do it manually. A better event to use to do this
    is either the Picture's OnPrint or even the detail band's BeforePrint.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited June 2002
    Perfect -- thanks!

    For anyone else reading this thread, all that needs to be done to the code
    snippet below is to place it into the ppDBImage's onPrint method instead of
    the onGetPicture method, and add the line

    medit.LoadPicture;

    (where medit is the instance of ppDBImage)

    Works like a charm.

    Jason


    "Alexander Kramnik (Digital Metaphors)" wrote
This discussion has been closed.