ImageEn, unit iexLayers

TIELayer.Bitmap

TIELayer.Bitmap


Declaration

property Bitmap: TIEBitmap;


Description

If the layer is a TIEImageLayer then Bitmap provides read/write access to the image and alpha channel of the layer.
For other TIELayer types, Bitmap provides read-only access to the layer content (e.g. to display an icon for the layer in a TImageEnMView).

Note: Unlike CopyToBitmap, Bitmap supports caching so will provide better performance if called frequently.


Examples

// Replace the image of the current layer with a bitmap
TIEImageLayer( ImageEnView1.CurrentLayer ).Bitmap.Assign( MyBitmap );
ImageEnView1.Update();


// Flip all image layers
ImageEnView1.LockUpdate();
for I := 0 to ImageEnView1.LayersCount - 1 do
  if ImageEnView1.Layers[ I ] is TIEImageLayer then
    ImageEnView1.Layers[ I ].Bitmap.Flip( fdHorizontal );
ImageEnView1.UnlockUpdate();


// Prompt user to load new image into current image layer and log the result
if TIEImageLayer( ImageEnView1.CurrentLayer ).ExecuteOpenDialog() then
  AddToLog( format( 'Loaded image into layer %d: %s', [ ImageEnView1.LayersCurrent, TIEImageLayer( ImageEnView1.CurrentLayer ).Bitmap.Filename ]));

// Show each of the layers as a thumbnail in a TImageEnMView
// NOTE: This is the same as calling TImageEnMView.AssignLayers()
procedure Tfmain.RefreshLayerViewer();
var
  i, idx: integer;
begin
  // Fill ImageEnMView1 with all layers of ImageEnView1
  ImageEnMView1.Clear;
  for i := 0 to ImageEnView1.LayersCount - 1 do
  begin
    idx := ImageEnMView1.AppendImage;
    ImageEnMView1.SetImage( idx, ImageEnView1.Layers[i].Bitmap );
    ImageEnMView1.ImageTopText[i] := 'Layer ' + inttostr(i);
  end;

  // Mark selected layers and highlight the current layer
  ImageEnMView1.BeginSelectImages;
  for i := 0 to ImageEnView1.LayersCount - 1 do
    if ImageEnView1.Layers[ i ].Selected then
      ImageEnMView1.SelectedImage := I;
  ImageEnMView1.SelectedImage := ImageEnView1.LayersCurrent;  // Make it the active image
  ImageEnMView1.EndSelectImages();
end;

// Prompt user to save current layer as an image
fn := ImageEnView1.IO.ExecuteSaveDialog();
if fn <> '' then
  ImageEnView1.CurrentLayer.Bitmap.SaveToFile( fn );