Images in report issue

Has there been a change in the current version of Fast Reports (Version 2022.2.12) when dealing with images?

I have had a report that was displaying images based on different parameters for a couple of years, and now they're suddenly not working. Has anyone else run into this?

In my Program Code, I'm setting the images as parameters like this:

//EMail

                               FastReport.Data.Parameter emailParameter = new FastReport.Data.Parameter();

                               //emailParameter.Name = "email";

                               emailParameter.DataType = typeof(Byte[]);

                               report.Dictionary.Parameters.Add(emailParameter);

                               report.SetParameterValue("email", EMail);


And in my FastReport Code I have:

   private void TypePicture_BeforePrint(object sender, EventArgs e)

   {

     //Type

     if (((String)Report.GetColumnValue("Communications.Type")) == "EMail")

     {

       Image image = Report.GetParameterValue("email") as Image;

       TypePicture.Image = image;

     }


I've confirmed that the values are all correct (and they were working before updating to this version from 2022.2.7). Some images are displaying, but most are not. All images are set the same, so if one works, all should work?

I appreciate the help.

Comments

  • Has anyone else noticed this? I can't seem to figure out what's causing it...

    It seems to be completely random.

  • Hello!

    The PictureObject.DataColumn property is designed to be bound to a column in the data source ([Table.ImageCol]); if you pass a Report Parameter name (e.g. DataColumn = ‘ImgA’) without specifying a table, the image will not load!

    To reliably display multiple images in byte[] format passed via report parameters:

    Set the parameter type to typeof(byte[]) and pass a byte array (SetParameterValue).

    In the BeforePrint event of each PictureObject, call SetImageData(bytes) (or use LoadImageFrom / create a separate Bitmap — do not pass the same closed/shared MemoryStream to all objects!):

    private void Pic2_BeforePrint (object sender, EventArgs e)
    {
    if (Report.GetParameterValue(‘ImgB’) is byte[] bytes)
    Pic2.SetImageData(bytes);
    }
    

    Alternatively, you can pass the images as byte[] columns in a DataTable and use DataColumn = ‘MyTable.ImgA’

This discussion has been closed.