Use an image (streamed) in an rdlc file RRS feed

  • Question

  • How can I use a System.Drawing.Image object in an rdlc file?

    We have an image that must be dynamically determined which one to use.  The image options are located in a non-web browsable directory.  Using other reporting tools we were able to load the image using System.Drawing.Image.FromFile and then assign the to the report's image source.  How can this be done in Reporting Services?

    Can it be streamed in through a parameter?  Or something else? 
      Embedding all of the images is not a great choice.  The data comes from a single DataRow or parameters (haven't decided which)

    Friday, May 2, 2008 11:59 PM


  • I was able to do this by adding a column to the datatable that is the report source of type System.Byte[].  Then I used the following code to stream the image into the row:

    Code Snippet

    // Add in column for the actual iamge
    records.Columns.Add("ImageBytes", typeof(System.Byte[]));

    // Add the image to the DataRow record
    using(MemoryStream imageMemStream = new MemoryStream())
       System.Drawing.Image.FromFile(WebConfigurationManager.AppSettings["NonBrowsableDirectory"] + records.Rows[0]["ImageFile"].ToString()).Save(imageMemStream, ImageFormat.Png);
        records.Rows[0]["ImageBytes"] = imageMemStream.ToArray();

    Then I just send in that DataRow and select source = "Database" in the rdlc file
    Monday, May 5, 2008 5:56 PM