This is a migrated thread and some comments may be shown as answers.

Using ExportToImage extension with define the size of image

3 Answers 189 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
CS
Top achievements
Rank 1
CS asked on 26 Dec 2017, 06:16 AM

Hi,

How can I use the ExportToImage extension with define the size (Width and Height) of the image. I do not wish to change the size of my framework element (RadCartesianChart ) in so that the image generated will be bigger in size.

This is the line of code to export to image:

                Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(CartesianChart, Path.GetFullPath(fileName), new PngBitmapEncoder());

Thanks in advanced.

Regards,

CS

3 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Stoyanov
Telerik team
answered on 28 Dec 2017, 02:31 PM
Hello,

The ExportToImage method takes a FrameworkElement parameter. The size of the image is the same as the size of that element. If you don't want to change the size of the RadCartesianChart I can propose the following: when a chart needs to be exported, have a button that creates a new window and insert the chart into the window. You can then resize this window as you please. This window will have an export button which will export the chart. When you have finished with exporting the element, you can remove it from the window and insert it back where it was originally.

Another possible option is to change the size before exporting the chart and then change it back. Please find a sample project attached demonstrating both approaches. Do let me know if you find any of them suitable for you.

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
CS
Top achievements
Rank 1
answered on 02 Jan 2018, 01:33 AM

Hi, 

Thank you for the suggestion. Since I need a ExportToImage function that will automatically save the chart as image after chart is updated (save once for every 10 update), the second option will be more suitable. What is the default horizontal dpi and vertical dpi for ExportToImage method? Because the chart will be updated continuously, so the time need to generate the Image is a concern. I need an above average clear image and quick generate of image.

Regards,

CS

0
Vladimir Stoyanov
Telerik team
answered on 03 Jan 2018, 02:03 PM
Hello,

The default horizontal and vertical dpi is 96. However, the ExportToImage method has an overload where you can pass different values as parameters. 

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ChartView
Asked by
CS
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
CS
Top achievements
Rank 1
Share this question
or