Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Photoshop Undo System

The question probably applies to drawing systems in general. I was wondering how the undo functionality is implemented in PS. Does the program take snapshots of the canvas before each operation? If so, wouldn't this lead to huge memory requirements? I've looked into the Command pattern, but I can't quite see how this would be applied to drawing.

Regards, Menno

like image 793
Menno Avatar asked Apr 04 '09 12:04

Menno


1 Answers

It's called the command pattern. It's simple to implement as useful for any sort of editor.

Photoshop applies stacked transformations upon the original image. One opetation one command. It simply unapplies the transformation when you undo. So it just keeps the original and latest versions, but I guess it might cache the last few versions just for performance.

like image 130
Robert Gould Avatar answered Nov 23 '22 11:11

Robert Gould