How do I print to a PNG-file?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!
A have developed a windows app in VB.NET that has some printing of charts
and such stuff. Is there an easy way to save the outprint in an PNG-file
instead? I want exactly the same look in the image as in the outprint.
 
Hi Lars,

First store your output to a Bitmap (using Graphics.FromImage),
then simply save the file using Image.Save(filename, ImageFormat.Png)
 
Hi!
I have existing printings to paper with mixed drawings and 3rd party charts.
I want the same outprint to an image instead of paper. I would like an easy
way to redirect the printer graphics to an image.
You suggest Graphics.FromImage() which creates a graphics from an existing
image. I want the opposite: create an image from the graphics, but
unfortunately there is no Graphics.ToImage(). Or did I miss something?
 
Create a Bitmap, typically the size of your display control.

Graphics g = Graphics.FromImage(Bitmap);

Use this graphics object for drawing (pass it to an OnPaint, PrintPage
event etc). Instead of drawing to screen the drawing will be stored in
the Bitmap. The procedure is the same as you would do when printing to
paper.
 
Thanks, I got it working!

Morten Wennevik said:
Create a Bitmap, typically the size of your display control.

Graphics g = Graphics.FromImage(Bitmap);

Use this graphics object for drawing (pass it to an OnPaint, PrintPage
event etc). Instead of drawing to screen the drawing will be stored in
the Bitmap. The procedure is the same as you would do when printing to
paper.
 
Back
Top