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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

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.