How to save a Drawing?

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

Herfried K. Wagner [MVP]

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.
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top