ImageEn, unit imageenproc




procedure SaveUndo(Source: TIEUndoSource = ieuImage; ClearRedo: Boolean = false); overload;
procedure SaveUndo(const Caption: String; Source: TIEUndoSource = ieuImage; ClearRedo: Boolean = false; Operation: Integer = 0; UndoBmp: TIEBitmap = nil); overload;


Saves the current image to the Undo stack (i.e. after the next change, calling Undo will return us to this state).

Parameter Description
Caption Description of the saved undo (which will be assigned to UndoCaptions)
Source Specifies what to save (see below)
ClearRedo When true ClearAllRedo is called to reset the redo list (which is standard behavior for application Undo)
Operation An optional value that allows you to locate a specific undo (via GetUndoInfo). It can be zero or an Undo Constant
UndoBmp Optionally a bitmap can be specified as the undo image (i.e. the image the user will return to if Undo is called. Source must be ieuImage

Values for Source:
ieuImage The bitmap (of the current layer, if there are multiple layers)
ieuSelection The area the user has selected (Not the bitmap content within the selection, just the selection dimensions)
ieuObject All objects of a TImageEnVect
ieuLayer Properties of all current layers (position, size, etc, but not the layer bitmaps)
ieuFullLayer Same as ieuLayer but also saves the layer bitmaps
ieuObjectsAndLayers Saves complete state: Properties and bitmaps of all layers (TImageEnView) or objects (TImageEnVect)

- You do not need to manually call SaveUndo if you have enabled AutoUndo
- ieuLayer and ieuFullLayer do not restore removed layers, or redact added layers. Use ieuObjectsAndLayers instead
- For TImageEnVect, ieuObject and ieuObjectsAndLayers are the same, except that ieuObjectsAndLayers also saves the background image


// Allow undo of Negative

// Allow undo of Negative&Contrast
ImageEnView1.Proc.SaveUndo( 'Negative and contrast' );
ImageEnView1.Proc.Contrast( 5 );

// Save undo before removing a layer (TImageEnView)
ImageEnView1.Proc.SaveUndo( 'Delete Layer', ieuObjectsAndLayers );
ImageEnView1.LayersRemove( ImageEnView1.LayersCurrent );

// Save undo before removing an object (TImageEnVect)
ImageEnVect1.Proc.SaveUndo( 'Delete Object', ieuObject ); // or ieuObjectsAndLayers
ImageEnVect1.RemoveObject( IEV_ALL_SELECTED_OBJECTS );

// Save undo before shifting all layers
ImageEnView1.Proc.SaveUndo( 'Move all Layers', ieuLayer );
ImageEnView1.LayersRepositionAll( -50, -50 );

// Save undo before flipping all image layers
ImageEnView1.Proc.SaveUndo( 'Flip All Layers', ieuFullLayers );
for I := 0 to ImageEnView1.LayersCount - 1 do
  if ImageEnView1.Layers[ I ] is TIEImageLayer then
    ImageEnView1.Layers[ I ].Bitmap.Flip( fdHorizontal );

// Save undo before adding a new layer
// Note: Use ieuObjectsAndLayers, not ieuLayer or ieuFullLayers (which only support existing layers)
ImageEnView1.Proc.SaveUndo('Add Image Layer' + IntToStr(ImageEnView1.LayersCount-1), ieuObjectsAndLayers);
ImageEnView1.LayersAppend( ielkImage );

See Also

Published Property  AutoUndo
Public Property  UndoCount
Published Property  UndoLimit
Public Method  Undo
Public Method  SaveRedo