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

image from chart

3 Answers 216 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nick Adams
Top achievements
Rank 1
Nick Adams asked on 27 Aug 2008, 01:32 PM
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")?

3 Answers, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 28 Aug 2008, 12:07 PM
Hello Nick,

You can save the RadChart in an image, but the chart just dupliacates its image into a bitmap object:
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)); 

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.
0
Matt Streit
Top achievements
Rank 1
answered on 19 Apr 2010, 10:42 PM

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.

0
Dwight
Telerik team
answered on 21 Apr 2010, 02:19 PM
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.
Tags
Chart (obsolete as of Q1 2013)
Asked by
Nick Adams
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Matt Streit
Top achievements
Rank 1
Share this question
or