Jump to content
Software FX Community

Weird DPI Inconsistency


Recommended Posts

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?

Link to comment
Share on other sites

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

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...