ImageEn, unit imageenview

TImageEnView.LayersRemove

TImageEnView.LayersRemove


Declaration

procedure LayersRemove(LyrIndex: Integer = LYR_SELECTED_LAYERS; SwapBackgroundProps: Boolean = False);


Description

Removes a layer and frees the related bitmap. You can specify the index of a layer of LYR_SELECTED_LAYERS to remove all selected layers.
Parameter Description
idx Index of the layer to remove (0 = background/first layer). You can also specify LYR_SELECTED_LAYERS (-2), or LYR_ALL_LAYERS (-3) to clear all layers
SwapBackgroundProps If the background layer (Layer 0), the new background will inherit the Locked and Selectable properties of the old one

Note:
 At least one layer must be present. Attempting to remove the final layer will empty its content
 Users can also click the Delete key to remove a layer if loKeyboardShortcuts is enabled


Example

// Remove all selected layers
ImageEnView1.LayersRemove();

// Remove the top-most layer
ImageEnView1.LayersRemove( ImageEnView1.LayersCount - 1 );

// Remove any image layers (except background)
ImageEnView1.LockUpdate();
for i := ImageEnView1.LayersCount - 1 downto 1 do
  if ImageEnView1.Layers[ i ] is TIEImageLayer then
    ImageEnView1.LayersRemove( i );
ImageEnView1.UnlockUpdate();

// Remove layer of a specific name
for i := ImageEnView1.LayersCount - 1 downto 1 do
  if SameText( ImageEnView1.Layers[ i ].Name. aDelName ) then
  begin
    ImageEnView1.LayersRemove( i );
    Break;
  end;


See Also

 LayersClear