Recent

Author Topic: FPReport: how to load images using TFPReportUserData  (Read 321 times)

apeoperaio

  • Sr. Member
  • ****
  • Posts: 282
FPReport: how to load images using TFPReportUserData
« on: January 22, 2025, 09:43:43 am »
I am trying to load images using TFPReportUserData. Is it possible?

I defined the field type as rfkStream, is it correct?

Code: Pascal  [Select][+][-]
  1. procedure TForm1.rptUserDataGetFieldKind(Sender: TObject; aName: String;
  2.   var AKind: TFPReportFieldKind);
  3. begin
  4.   if aName = 'img' then
  5.     AKind:= rfkStream;
  6. end;  
  7.  

Then how should I use the OnGetValue?

Code: Pascal  [Select][+][-]
  1. procedure TForm1.rptUserDataGetValue(Sender: TObject;
  2.   const AValueName: string; var AValue: variant);
  3. var
  4.   img: TPortableNetworkGraphic;
  5.   imgstream: TMemoryStream;
  6. begin
  7.   if AValueName = 'img' then begin
  8.     img:= TPortableNetworkGraphic.Create;
  9.     img.LoadFromFile('myimage.png');
  10.     imgstream:= TMemoryStream.Create;
  11.     img.SaveToStream(imgstream);
  12.     // AValue:= imgstream; // how can I assign the image to the AValue?
  13.     img.Free;
  14.   end;
  15. end;  
  16.  

Any suggestions?

 

TinyPortal © 2005-2018