SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components


I have a requirement to save a chart as an image to a Crystal Report. I can pass a byte[] of the image using ExportToBitmapSource() and then converting this to a byte array using a MemoryStream. However, quality is significantly lost in the process. Here is an example of my source.

MyChart.RenderPriority = RenderPriority.Immediate;
var bitmap = MyChart.ExportToBitmapSource();

using (MemoryStream stream = new MemoryStream())
    BitmapEncoder encoder = new PngBitmapEncoder();
    byte[] bytes = stream.ToArray();

Later on I set the value of a blob field of the dataset passed to the Crystal Report to this byte array.

Quality of the image is pretty good when I save directly to file, but most important when I use the MyChart.ExportToFile() I actually lose some of the markup annotations when I set the “useXamlRenderSurface” to true. I.e. I have custom text markups that show a border and the border doesn’t get saved with the image.

The thing about the Crystal Report is that our report designer can set the actual size of the image to be shown in terms of inches. If I am able to save/export the chart image in those same proportions I believe the image would look fine since it wouldn’t be getting stretched in the report.


  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.