Using ExportToImage extension with define the size of image

4 posts, 1 answers
  1. CS
    CS avatar
    7 posts
    Member since:
    Nov 2016

    Posted 26 Dec 2017 Link to this post

    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

  2. Answer
    Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    217 posts

    Posted 28 Dec 2017 Link to this post

    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.
  3. CS
    CS avatar
    7 posts
    Member since:
    Nov 2016

    Posted 01 Jan in reply to Vladimir Stoyanov Link to this post

    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

  4. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    217 posts

    Posted 03 Jan Link to this post

    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.
Back to Top