Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / April 2005

Tip: Looking for answers? Try searching our database.

How do I print to a PNG-file?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LarsJ - 22 Mar 2005 11:11 GMT
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.
Signature

Regards,
Lars Jönson

Morten Wennevik - 22 Mar 2005 11:41 GMT
Hi Lars,

First store your output to a Bitmap (using Graphics.FromImage),
then simply save the file using Image.Save(filename, ImageFormat.Png)

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

Signature

Happy Coding!
Morten Wennevik [C# MVP]

LarsJ - 22 Mar 2005 14:33 GMT
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?

> Hi Lars,
>
[quoted text clipped - 5 lines]
> > 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.
Morten Wennevik - 22 Mar 2005 16:49 GMT
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.

> Hi!
> I have existing printings to paper with mixed drawings and 3rd party  
[quoted text clipped - 22 lines]
>> Happy Coding!
>> Morten Wennevik [C# MVP]

Signature

Happy Coding!
Morten Wennevik [C# MVP]

LarsJ - 01 Apr 2005 08:09 GMT
Thanks, I got it working!

> Create a Bitmap, typically the size of your display control.
>
[quoted text clipped - 31 lines]
> >> Happy Coding!
> >> Morten Wennevik [C# MVP]

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.