Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show images on an RDLC report

I have an RDLC report and would like one of the columns in a table on this report to display images. The datasource for my report is a class that has a property called Image of type System.Drawing.Image.

On my report I dragged an image control onto the column and I set the following properties:

MIMEType:  image/png
Source:  Database
Value:  =Fields!Image.Value

When I run my report, I get a broken image.

I'd really appreciate any suggestions!

Thanks in advance :o)

like image 457
Tina Orooji Avatar asked Feb 20 '09 18:02

Tina Orooji


1 Answers

I don't know if this is the best solution, but I got it to work. It looks like the problem was in using System.Drawing.Image.

In my class, I created a new property called ImageByte of type byte[]. I didn't make a setter for ImageByte, but I made a getter that does the following:

MemoryStream ms = new MemoryStream();
Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
return ms.ToArray();

I updated my report to have =Fields!ImageByte.Value for the Value and now everything appears to be working as expected :o)

like image 52
Tina Orooji Avatar answered Sep 30 '22 20:09

Tina Orooji