Jump to content
Software FX Community

How to paint chart with high DPI


W.D

Recommended Posts

Hi, I need to write chart into PDF. What I'm doing now is to create a Chart object dynamically and then Export chart to Bitmap and then import the bitmap to PDF using iText.

But the quality of the image is not good enough. The DPI is 96. I read some the post saying use Paint() will help to increase DPI. But I'm not quite sure how to do this programtically. Is there any sample code?

Thanks,

 W.D

Link to comment
Share on other sites

The follwoing code exports the chart to a 300 x 300 DPI bitmap:

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

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\cfxdpi.bmp");

g.Dispose();

bmp.Dispose();

Link to comment
Share on other sites

  • 3 years later...

Hey,

I'm using the above code to add a 300 dpi image to a PDF. Everythings great other than the file size.

The PDF is over 2mb in size. When I previously used the chart fx png export it was under 100k.

I am aware the image is now larger, so a file size increase would be expected, but this is way too big.

If I copy this image from the PDF and paste it into fireworks, it's 2700 x 1800 pixels. A quick export preview as gif gives a file size of still under 100k.

Please can you advise me how to output a 300 dpi PNG file?

Thanks

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.

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