ExportToImage, border

3 posts, 0 answers
  1. Richard Alvarez
    Richard Alvarez avatar
    11 posts
    Member since:
    May 2005

    Posted 27 Apr 2011 Link to this post

    I'm exporting a chart to png using ExportToImage and the PngBitmapEncoder.  Is there any way of getting rid of the border around the resulting image?
  2. Missing user
    Missing user avatar

    Posted 03 May 2011 Link to this post

    Hi Richard,

    I made a local test in order to reproduce this issue, but I didn't get an unexpected border around the chart. If you mean the default RadChart border, you can remove it before exporting and restore it after that. For example:
    private void ButtonExportChartToImage_Click(object sender, RoutedEventArgs e)
    {
        //remove the default RadChart border before export
        radChart.BorderThickness = new Thickness(0);
     
        SaveFileDialog dialog = new SaveFileDialog();
        dialog.DefaultExt = "png";
        dialog.Filter = string.Format("{1} File (*.{0}) | *.{0}", "png", "PNG");
     
        if (!(bool)dialog.ShowDialog())
            return;
     
        Stream fileStream = dialog.OpenFile();
        radChart.ExportToImage(fileStream, new PngBitmapEncoder());
     
        fileStream.Close();
         
        //restore the default RadChart border after export
        radChart.BorderThickness = new Thickness(1);
    }

    I hope this helps.

    Regards,
    Polina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Richard Alvarez
    Richard Alvarez avatar
    11 posts
    Member since:
    May 2005

    Posted 03 May 2011 Link to this post

    That did help.  I did some more experimenting, and found that the problem only occurred when I set the width of the chart, which is strange because that is the constraining proportion for the area I'm putting the image of the chart in.  So instead, I calculate the height I think I need, set that, and let width go unassigned.
Back to Top