ImageEn, unit iexLayers

IELayersMerge


Declaration

procedure IELayersMerge(Layer1, Layer2, LayerMask: TIELayer; Destination: TIEBitmap; ZoomFilter: TResampleFilter; Background: TColor; RelativePositions: Boolean);


Description

Merges two layers to the destination bitmap.
ZoomFilter specifies the filter to use when layers needs to be stretched.
Background is the color used to fill empty regions.
LayerMask is the upper layer's mask. This can be 'nil' if no layer mask exists.
If RelativePositions = false the output layer should have posx = 0 and posy = 0 because the required space is added to the destination bitmap.
If ForceCropLayer2 = true, then any parts of Layer 2 lying outside of layer 1 will be cropped. If False, cropping will only occur if Cropped is enabled.


Example

// this merges all layers of ImageEnView1 to tempIE (invisible), then saves to jpeg file
var
  tempIE: TImageEnView;
  tempBMP: TIEBitmap;
  i: Integer;
begin
  tempIE := TImageEnView.Create(nil);
  tempIE.Layers[0].Bitmap.Assign( ImageEnView1.Layers[0].Bitmap );
  tempBMP := TIEBitmap.Create;
  for i := 1 to ImageEnView1.LayersCount-1 do
  begin
    IELayersMerge( tempIE.Layers[0], ImageEnView1.Layers[i], nil, tempBMP, rfNone, clBlack );
    tempIE.Layers[0].Bitmap.Assign( tempBMP );
  end;
  tempBMP.free;

  tempIE.Background := clBlack;
  tempIE.RemoveAlphaChannel(true);
  tempIE.IO.SaveToFile('output.jpg');
  tempIE.free;
end;