mrotoloni Posted December 17, 2008 Report Share Posted December 17, 2008 We have two servers in which we are generating identical charts, but the DPI on the images are different. This only seems to happen when the chart is set to 3d and the output is a meta file. We're calling Chart.Export(FileFormat.Metafile, sFile). Any thoughts on why this would be happening. Is there any way to control the DPI settings? Quote Link to comment Share on other sites More sharing options...
AndreG Posted December 17, 2008 Report Share Posted December 17, 2008 When the chart is exported, it's DPI will depend on the resolution of the screen of the server exporting it. To insure a constant DPI (or even increase it for better looking charts), you can use the Paint method. Here is the sample code for that (here saving the bitmap as WMF, but you can use whatever format is supported). 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.wmf", ImageFormat.Wmf);g.Dispose(); bmp.Dispose(); Quote Link to comment Share on other sites More sharing options...
mrotoloni Posted December 17, 2008 Author Report Share Posted December 17, 2008 Excellent info! Thanks Andre! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.