Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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

share|improve this question
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 Jan 12 '12 at 18:11
1  
@rig the 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
add comment

4 Answers

up vote 6 down vote accepted

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.

share|improve this answer
    
Some modern file systems provide built-in versioning. –  user1249 Jan 12 '12 at 12:42
    
@ThorbjørnRavnAndersen - Can you edit a reference into the answer? That would be useful. –  ChrisF Jan 12 '12 at 12:43
    
@ChrisF: MacOSX "Versions" –  MSalters Jan 12 '12 at 15:21
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.