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).

  • 1
    Not 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
    Commented Jan 12, 2012 at 18:11
  • 1
    @rig the command pattern might have been what you were thinking of. Commented Jan 12, 2012 at 21:13
  • @ConradFrix You got it I believe.
    – Rig
    Commented Jan 12, 2012 at 21:32

4 Answers 4


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.

  • Some modern file systems provide built-in versioning.
    – user1249
    Commented Jan 12, 2012 at 12:42
  • @ThorbjørnRavnAndersen - Can you edit a reference into the answer? That would be useful.
    – ChrisF
    Commented Jan 12, 2012 at 12:43
  • @ChrisF: MacOSX "Versions"
    – MSalters
    Commented Jan 12, 2012 at 15:21

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.


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.


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.