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

Archived

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

×
×
  • Create New...