How to pass a PNG image to the report using LoadFromStream

Hi, I need to pass a PNG image to the frxR_DTE33 report but it is failing with the following error message: "Invalid file format". This is the code:

TMemoryStream *msPNGPicture = new TMemoryStream;

PngImgFl->SaveToStream(msPNGPicture); // msPNGPicture is a TPngImage*

msPNGPicture->Position = 0;

TfrxPictureView *Pic = dynamic_cast <TfrxPictureView *> (frxR_DTE33->FindObject("Picture_TimbreSII"));

Pic->LoadFromStream(msPNGPicture); // Here is failing

What I'm doing wrong? How could I solve this issue?

Comments

  • procedure TrelTeste.RelatorioBeforePrint(Sender: TfrxReportComponent);
    var
      NomeArquivo: String;
      Stream: TMemoryStream;
    begin
      inherited;
    
      if Sender.Name = 'Assinatura' then
        begin
        Stream := TMemoryStream.Create;
        try
          NomeArquivo := 'AssinaturaFile.png';
          Stream.LoadFromFile(NomeArquivo);
    
          TfrxPictureView(Sender).Picture.LoadFromStream(Stream);
        finally
          Stream.Free;
        end;
        end;
    end;
    

    This works for me. But if I'm not mistaken, I think there are some PNG images that not work well, I've already get that issue but I don't remember if it was with FR

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.