Jump to content
Software FX Community

Export chart to jpg?


mhowes

Recommended Posts

 Export doesn't have jpg as part of the FileFormats

 I also tried saving the chart as a jpg doing it myself by using DrawToBitmap but that doesn't seem to work either

 is there a way to get the chart to save as a jpg?

thanks

mike

PS Here is the code I tried to use to do it myself

  Bitmap bitmapChart = new Bitmap(this.chartFx.Width, this.chartFx.Height);     chartFx.DrawToBitmap(bitmapChart, new Rectangle(0, 0, chartFx.Width, chartFx.Height));   if (!System.IO.Directory.Exists(FilePath))   System.IO.Directory.CreateDirectory(FilePath);   bitmapChart.Save(FilePath, System.Drawing.Imaging.ImageFormat.Jpeg);

 

Link to comment
Share on other sites

Mike,

 Here is a sample code for saving the chart as a JPG. This sample also allows you to select a higher resolution for your chart (in this case, 300dpi).

 

Rectangle r = new Rectangle (0, 0, (chart1.Width * 300) / 96, (chart1.Height * 300) / 96);

Bitmap bmp = new Bitmap (r.Width, r.Height);

bmp.SetResolution(300, 300);

Graphics g = Graphics .FromImage(bmp);

chart1.Paint(g, r, PaintStyles .Background | PaintStyles .Border | PaintStyles .Print);

bmp.Save( @"c:\temp\cfx.jpg" , ImageFormat .Jpeg);

g.Dispose();

bmp.Dispose();

 

AndreG

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...