I was thinking about how would a paint software works. Firstly I thought that it might not use any database but when I started thinking about the undo function I realized that it might be that the data is somehow stored in the database. Can anyone please help me out by telling me how the images are stored in a normal paint program(say MS-PAINT of Windows).
-
1Not an answer but I could definitely see a case for an in memory database for a paint program. Still, most cases you would use it could be satisfied by a stack or perhaps some design pattern that escapes me at the moment (but could reference :) ) – Rig Jan 12 '12 at 18:11
-
1@rig the [command pattern](http://en.wikipedia.org/wiki/Command_pattern) might have been what you were thinking of. – Conrad Frix Jan 12 '12 at 21:13
-
@ConradFrix You got it I believe. – Rig Jan 12 '12 at 21:32
4 Answers
Images aren't usually stored in a database (assuming you mean something like an SQL database) as the format isn't suited to image data.
Images are usually stored as files in folders - just as Word, Excel, OpenOffice documents are.
When you manipulate the data the program keeps a record of your changes in memory (usually) so that you can undo and redo modifications. Sometimes when you save the file the undo stack is cleared so you can only undo to last version on the hard drive.
Some file formats allow revision information to be stored in the file itself - but this isn't usually the case for images. What you have on disk is the only version of the file. If you want to keep a revision history then you need to either keep manual backups or store the file in a version control system, unless the underlying file system supports this natively. An example of the latter is ZFS under OpenSolaris, which allow for a "look back in time" functionality with Time Slider - http://java.dzone.com/news/killer-feature-opensolaris-200. Unfortunately, Solaris is heading in a different direction these days.

- 38,878
- 11
- 125
- 168
-
-
@ThorbjørnRavnAndersen - Can you edit a reference into the answer? That would be useful. – ChrisF Jan 12 '12 at 12:43
-
You could look at the implementations of the undo functionality in some open source programs. Perhaps the The GIMP or Version 3.36 or earlier of Paint.NET (when it was still open source) might provide you with some inspiration. However, the Command and Memento design patterns are commonly cited as good ways to implement the undo/redo functionality.

- 79,623
- 18
- 192
- 283
If I name the filesystem as non-relational database - then probably - yes, else - depends what and how do you painting and how do your paintings organized.

- 101
- 2
CSLA for .NET serializes a copy of the object that you wish to save undo-history on and stores it in a stack of undo's... so you can keep popping back through history (Might be a little off on how it's stored, but fairly confident in the overall method)...
No database needed, infact, it's overkill to have a database to save "undo" information. Just find a way to store "instances" of your data (paint info) and be able to recall them.

- 249
- 1
- 3