image from chart

4 posts, 0 answers
  1. Nick Adams
    Nick Adams avatar
    6 posts
    Member since:
    Feb 2007

    Posted 27 Aug 2008 Link to this post

    I would like to be able to create an image of a chart created in my application so that i can attach it to an email or save as an image for archiving.  Can I create an image (bitmap,gif,jpeg,etc) object (System.Drawing.Image?) from the RadChart class with a given size or resolution (create an image of the chart scaled to 6"x9")?
  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 28 Aug 2008 Link to this post

    Hello Nick,

    You can save the RadChart in an image, but the chart just dupliacates its image into a bitmap object:
    1 Bitmap bmp = new Bitmap(this.radChart1.Width, this.radChart1.Height, PixelFormat.Format32bppArgb); 
    2  
    3 this.radChart1.DrawToBitmap(bmp, new Rectangle(0, 0, this.radChart1.Width, this.radChart1.Height)); 

    To obtain a larger image, you need to resize the chart to the required size. Dimensions given in inches should be converted to pixels:
    image_width_in_pixels = image_width_in_inches * pixels_per_inch;
    Same is for the height.

    I hope you find this information useful. Should you have further questions, do not hesitate to write us.




    Regards,
    Evtim
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Matt Streit
    Matt Streit avatar
    1 posts
    Member since:
    Apr 2010

    Posted 19 Apr 2010 Link to this post

    Hi,

    I'm trying to take a radchart object and place an image of it on the clipboard. I know I can use the .getBitmap function to get a bitmap, but I'm hoping to either get or convert this to a jpeg. Is there a way to do that?

    Thanks.

  5. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 21 Apr 2010 Link to this post

    Hi Matt Streit,

    In order to place an image into the clipboard, you need only to call Clipboard.SetImage(image). Here is a sample code:
    Bitmap bmp = new Bitmap(this.radChart1.Width, this.radChart1.Height, PixelFormat.Format32bppArgb);
    this.radChart1.DrawToBitmap(bmp, new Rectangle(0, 0, this.radChart1.Width, this.radChart1.Height));
     
    Clipboard.SetImage(bmp);

    There are no file/image formats when putting objects in the Clipboard. You can save the RadChart to image, selecting the image format like that:
    this.radChart1.Save(@"C:\\image.jpg", ImageFormat.Jpeg);

    The supported image formats can be found here: System.Drawing.Imaging.ImageFormat

    All the best,
    Joshua
    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.
Back to Top