Hello. That question is asked — how to correctly save the history in a graphic editor (like GIMP) for use in UNDO/REDO. He can see three options:
1. Keep a list of actions.
For example, draw a line a certain color in such coordinates, applied the filter "blur", turned image. In the case of using the UNDO pass all the action from the first to the necessary.
Advantage: Takes up very little space in memory. When you save the project, you can easily restore the entire story. If you want you can even store the entire tree (for example, made the action A, B, C, D, E, back to C, made F, G. the Resulting path ABCFG happened, but in the version control system to store and branch DE)
Drawback: When using Undo or loading a previously saved image goes all the way, and this can be a significant time and if the usual simple editing such a passage may take some 100-200 MS, which is not critical, as when using heavy filters may slow to tens of seconds.
2. Save a full dump of the project to bitmap
Every action whole picture we store in memory as a finished drawing.
Advantage: Very fast. Made undo/redo and just showed out of memory the picture that we had (already rendered). Even the heavy filter anything.
Disadvantage: Takes up a lot of space in memory. Suppose we have a drawing the size of 1k*1k. In each pixel we store 32 bits of information (8 bits per r,g,b, and 8 bits for the alpha channel), that is 4 bytes, that is, a bitmap, we will have to take ideally 4 meters, and the story of the 64 action — 64*4 = 256 MB of memory. And assuming that we have graphics editor supports layers and let them be at least five... Likewise, projects with a story to keep hard.
Gimp
In Ghimpu on circumstantial evidence, I operedelit that uses the second approach. The symptoms are:
1. The history is limited
2. Heavy filters, undo, redo, return the status quo very quickly.
3. A combined approach
Of course, there is an alternative. Keep a record of the first method, and the latter, for example, 8 actions stored by the second method, because it is rarely used so far undo. Save on the screw can be only the actions for which the project many changes will be a long time to open, but is allowed to weigh. Or even add the latest map date.
The advantages of both approaches
The disadvantage of a much heavier application logic. Actually — it is necessary to implement two mechanisms of history.
Topic for discussion
What do you say? Maybe there is another approach. If not, which approach would you prefer (in an ideal case and in the case of very tight deadlines)? Why?