1) You can save bitmap to the file and keep only it's reference in the
memory
2) You can use RLE enconding (i.e. save differences between  old and
new frame.
3) You can store one original bitmap and put each drawing command into
a linked list (i.e. "set color black", "set pen width 0", "draw line
from x1,y1 to x2,y2"). When you need to undo step N you remove the
last operation from this list, take the original bitmap and apply all
commands from the list sequentially. If the operations are time
consuming you can limit the size of this list. Once it reaches the
limit, you take original bitmap, apply the changes from the first item
in the list, remove this first element and save result as new
"original" bitmap.


On Mar 15, 1:03 pm, Matt M <[email protected]> wrote:
> Hello,
>
> My application includes a drawing feature and I would like the add the
> ability to "undo". The undo feature currently in place simply loads
> the bitmap from the last saved file, so no matter how many changes
> they make to their drawing "undo" will revert it back to the way it
> was before any changes were made.
>
> What I want to do now is make it more like the "undo" feature we are
> used to in modern applications, so that it does not go back to the way
> the file was when we first opened it, rather it goes back in various
> steps during our editing (which can be quite numerous).
>
> My idea is to save the current bitmap in a linked list after every
> occurrence of finger down, finger up. Thus every time the user lifts
> their finger from the screen the bitmap will be added to the linked
> list. Then of course when "undo" is selected the bitmap at the top of
> the stack will be loaded. The only problem is if the user makes 20,
> 30, 40+ changes to their drawing that is a lot of bitmaps to keep
> references to, am I right? I see out of memory errors coming. Any
> ideas for alternatives?
>
> Thank you!
>
> Matt.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to