Pre loader

How to export to the best possible format?

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

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;
MyChart.ZoomExtents();
var bitmap = MyChart.ExportToBitmapSource();

using (MemoryStream stream = new MemoryStream())
{
    BitmapEncoder encoder = new PngBitmapEncoder();
    encoder.Frames.Add(BitmapFrame.Create(bitmap));
    encoder.Save(stream);
    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.

Suggestions?

Version
5.2.1.11757
  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies