Export chart from screen to bitmap
Posted by Admin - on 08 February 2019 05:45 PM
|
|
It is required sometimes to save a Chart to an image file. SciChart provides the Export API for that. The available options are to export a Chart as a Bitmap or to export in the XPS (Vector) format. Also it is possible to export a Chart into an image with higher resolution. Export as a BitmapThis feature support exporting to several image formats, like PNG, JPEG and BMP. To export a Chart as a bitmap, you need to call SciChartSurface.ExportToBitmapSource() or SciChartSurface.ExportToFile() specifying flag useXamlRenderSurface = False. Export as VectorTo export in the XPS format, please call SciChartSurface.ExportToBitmapSource() or SciChartSurface.ExportToFile() specifying flag useXamlRenderSurface = True. Export at Specific ResolutionTo export to an image with higher resolution, specify the desired size when calling SciChartSurface.ExportToBitmapSource() or SciChartSurface.ExportToFile(). NOTE: Please note that SciChart relies on the Serialization to export in the XPS format or export at resolution other than the original chart size. Using the Export APITo show how to use the Export API, we are going to create a Custom Modifier which will export and store a Chart as an image on Right Mouse Button click. And Left Double-Click will copy the Chart to Clipboard. In order to achieve this, we have to derive from the ChartModifierBase class and override the OnModifierDoubleClick() and OnModifierMouseDown() methods as shown below: public class ExportToBitmapModifier : ChartModifierBase { // Make a chart screenshot on double-click public override void OnModifierDoubleClick(ModifierMouseArgs e) { base.OnModifierDoubleClick(e); Further ReadingFor further info and more detailed explanation of how the Export feature works please see our documentation:
Also there is an example available in SciChart Examples Suite that demonstrate Export / Printing capabilities:
| |
|