Jan 9, 2012 at 12:16 AM
Edited Jan 9, 2012 at 12:16 AM

Hey i am developing small paint application. Can someone give me a clue how to create Undo/Redo options with at least 10 steps ??

I were thinking about using array of "pixels" (position and colour) as a container of modified pixels, but i think that it can be difficult to implement considering flood fill, drawing shapes ( i need to catch all modified pixels ).

Another aproach is to keep in memory whole writeableBitmap as one step. It will be easier but what about performance ??


Regards :)

Jan 31, 2012 at 8:00 AM

If you take a look at Paint.NET, it supports seemingly unlimited undo/redo even for complex operations on large layered bitmaps. I doubt it's holding all that information in memory so would assume that somewhere it is caching to disk.

Would it not be easier to maintain a stack of images in PNG format (lossless compression) on disk which is cleaned up when the application exits? Depending on size the last two or three images could be held in memory, after which they are buffered to/from temporary files.