Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
245
Adding Images to Report
posted

Hi,

I am trying to create a report in our Silverlight application and add an image to that report but for some reason, when ever I create the Image (Infragistics.Documents.Reports.Graphics) object, my Data, Width and Height are always 0. even though I pass in a byte array with data in it.

The image I am trying to add to the report is an image of the xamWebChart.

Here's the code:

Report report = new Report();
ISection reportSection = report.AddSection();
IBand reportBand = reportSection.AddBand();

//this would have some content in it.
XamWebChart chart = new XamWebChart();
WriteableBitmap
 bitmap = new WriteableBitmap(chart, null); byte[] imageByte = bitmap.ToByteArray(); using (MemoryStream stream = new MemoryStream(imageByte)) {    Image image = new Image(System.Drawing.Image.FromStream(stream), true); var reportImage = reportBand.AddImage(image); reportImage.KeepRatio = true; }

The .ToByteArray() method basically converts that WriteableBitmap into a byte[]:

public static byte[] ToByteArray(this WriteableBitmap bmp)
{
   int[] p = bmp.Pixels;
   int len = p.Length << 2;
   byte[] result = new byte[len];
   Buffer.BlockCopy(p, 0, result, 0, len);
   return result;
}

Is there a proper way to add an image to the report in silverlight?  Thanks!

Parents Reply Children
No Data