Graphics to Image

G

Guest

How do I save or transform a System.Drawing.Graphics object into an Image
object ?
What I need is to save a Graphics on which I have drawn several shapes to a
JPG or PNG file.
Thanx.

_____
Marco
 
T

Tim Wilson

If you're in control of the creation of the Graphics object then you can do
something like this.

Bitmap b = new Bitmap(100, 100);
Graphics g = Graphics.FromImage(b);
// Draw on the image using g.DrawEllipse(...), g.DrawLine(...), etc.
b.Save(...);
g.Dispose();
b.Dispose();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top