Export Chart to Bitmap
SciChart features a number of ways to export the chart to Bitmap.
Export Chart from Screen to Bitmap
SciChart supports export to Bitmap. To take screenshot the current chart on screen and get a Bitmap in memory, call the following code:
// Assume a surface has been created and configured somewhere final Bitmap screenshot = surface.exportToBitmap();
Export Chart to Bitmap in Memory at specific Size
SciChart supports exporting to Bitmap at a specific size without showing chart on screen ( in-memory export ). This method can be used to create a larger or higher resolution image than the chart currently on screen.
To do this, please use the following code:
// create new SciChartSurface final SciChartSurface sciChartSurface = new SciChartSurface(getActivity()); // init it with axes, series etc initSurface(sciChartSurface); // prepare it for export at specified size SciChartSurfaceExportUtil.prepareSurfaceForExport(sciChartSurface, 800, 600); // export it to Bitmap final Bitmap screenshot = sciChartSurface.exportToBitmap();
Export ViewGroup which contains ScichartSurface
By default SciChartSurface can be used with different IRenderSurface implementations. Some of them (e.g. RenderSurfaceGL which uses OpenGL for rendering of its content) won't be visible when you call draw() on parent ViewGroup. So if you need to export ViewGroup which contains SciChartSurface then you need to switch to Canvas based RenderSurface before export: