Question undo in graphics

charu

New member
Joined
May 4, 2009
Messages
1
Programming Experience
Beginner
hi
please help me

my project is in vb.net

i am having a picture box in which i have displayed an image
and apllying points and curves on it.
now i want to undo that.
please reply.

thank you.:)
 
Hello churu,

If you simply want to return the image to the original state, keep a copy of the original in memory and re-apply to the picturebox as needed.

For instance, you could declare the original as a global variable.
Dim Original As Image

Load the image as such.
Original = Image.FromFile("filepath")

When you need to revert...
Picturebox.Image = Original.Clone

This only allows you revert back to the original. If you want more control over the undo, you will need to devise a scheme to keep copies of the image as you edit. Maybe store the images in an ImageList for retrieval.

Another method is to keep track of the edits and re-apply all but the last when undo is selected.

Both of these methods are certainly more complex, but infinitely more flexiable.
 
Check [ame="http://www.vbforums.com/showthread.php?t=426684"]this[/ame] out. It uses the same method to first draw on the PictureBox, which is temporary and easily removed, and on the Image itself, which is permanent. You should do the same. By storing your drawn items in a list you easily clear that list, or simply remove one item from it, and then Refresh the PictureBox to update the drawing. Once you're ready to commit you draw onto the Image itself and discard your list of drawn items.
 

Latest posts

Back
Top