Jump to content
Software FX Community

Export chart to jpg?


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?



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


 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);





Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...