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

Image - LoadFromStream problem

edited September 2015 in General
Hi,

RB 14.08 with Delphi 2010

I use the onPrint event of a TppImage control to load an image from a
database for each record.

This is my code:

procedure TExportForm.ppImageScanPagePrint(Sender: TObject);
var
MyStream: TMemoryStream;
begin
MyStream := TMemoryStream.Create;
try
ScansTableBinary.SaveToStream(MyStream);
MyStream.Position := 0;
ppImageScanPage.Picture.Graphic.LoadFromStream(MyStream);
finally
MyStream.Free;
end;
end;

Generally that works fine, but the printed image is the same (1st one)
for all records. I checked the MemoryStream: it's different as expected.

Is there any kind of "reset" necessary to force the image component to
load the graphic from the stream?

Thanks and regards

Uli

Comments

  • edited September 2015
    Hi Uli,

    Is there a reason you're not using TppDBImage?

    Try loading the stream into a local lGraphic and assign it to the
    Picture.Graphic like this..

    lGraphic := TJpegImage.Create;

    lGraphic.LoadFromStream(lStream);

    ppImage.Picture.Graphic := lGraphic

    lGraphic.Free;


    If you still have an issue, please provide a simple example project that I
    can build and run in the debugger. Please use standard Delphi components and
    RB. Copy the data to TClientDataSets. Send in zip format - include only
    .dpr, .pas, .dfm. Send to support@




    Best regards,

    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited September 2015
    Nard,


    Yes, the images in my database are .tif and .jpeg images from a scanner.
    TppDBImage doesn't load the .tif images.


    Since I don't know the type of the image, I can't use that, or is there
    another way?

    Thanks and regards Uli
  • edited September 2015
    Hi,

    any idea on that?

    Thanks Uli
This discussion has been closed.