How to save a Drawing?

  • Thread starter Thread starter ham Come>
  • Start date Start date
H

ham Come>

I have an application with has some drawing operations
the code is sth like this:

For i as integer = 0 to 100
dim g as graphics
g = me.pictureBox1.CreateGraphics
g.Draw sth... ...
Next i

I just don't know how to save the final drawings to a file ( i mean the
total drawings).

Any help is greatly appreciated.
 
ham Come> said:
I have an application with has some drawing operations
the code is sth like this:

For i as integer = 0 to 100
dim g as graphics
g = me.pictureBox1.CreateGraphics
g.Draw sth... ...

\\\
g.Dispose()
///

But I would create the 'Graphics' object only once, not in every iteration
of the loop.
Next i

I just don't know how to save the final drawings to a file (
i mean the total drawings).

Instead of drawing onto the picturebox, create a 'Bitmap' object of
appropriate size and use 'Graphics.FromImage' to obtain a 'Graphics' object
for the bitmap. Then use this object to draw onto the bitmap. Then you can
either assign the bitmap to the picturebox's 'Image' property or draw it
onto the picturebox's surface in its 'Paint' event handler or 'OnPaint'
method. Simply call the 'Bitmap' object's 'Save' method to persist it to
disk.
 
Back
Top