Passing a Bitmap from app to report
Please help!!
I have an app that needs to generate a picture for my reports and i need to pass the picture to the reports but i dont want to have to save each file to disk and reload it etc. I have tried the code below but just get an error on my report, help...
Then on my report attached to some data whitch all works fine and has been tested i have a picture object and i have set the onBeforePrint For the Picture to
I know the code is not very elegant yet but i just wanted to get it working firstly, so any advise.
I have an app that needs to generate a picture for my reports and i need to pass the picture to the reports but i dont want to have to save each file to disk and reload it etc. I have tried the code below but just get an error on my report, help...
function TForm1.QRCodeStream(encData: String; x, y: Integer): TStream;
var
  tmpCanvas: tBitMap;
begin
// necessary logic
  result:= TStream.Create;
  tmpCanvas := TBitMap.Create;
  QRCode1.code := encData;
  QRCode1.paintBarcode(tmpCanvas.Canvas);
  tmpcanvas.SaveToStream(result);
  tmpcanvas.Free;
end;
function TForm1.MainReportUserFunction(const MethodName: string;
  var Params: Variant): Variant;
begin
  if MethodName = 'QRCODE' then
    Result := Integer(QRCodeStream(Params[0], Params[1], Params[1]));
end;
//this next lin is in the forms create
  MainReport.AddFunction('function QrCode(encData: String; X, Y: Integer): TStream');
Then on my report attached to some data whitch all works fine and has been tested i have a picture object and i have set the onBeforePrint For the Picture to
Picture2.LoadFromStream(QrCode('This is a tes ' + <Time>,1,1) );
I know the code is not very elegant yet but i just wanted to get it working firstly, so any advise.
Comments
or use TfrxReport.OnBeforePrint event
or use TfrxPictureView(MainReport.FindObject('Picture2')).LoadPictureFromStream function
Mick
Thank you for the help. Unfortunatelly, I can't see the image in the report. A blank page is visualized. No image is transfered.
Yes, I did. In order to be sure if the image was loaded I have included in the form an Image.Bitmap. The image is correct in the form but doesn't appear in the report. Can be something related to image size?
Unfortunately, the problem remains.
Finally I found a way to solve the problem in my computer. See attached file. Thanks.
Thank you, gpi. This response was very helpful to me.