ImageEn, unit imageenview

TImageEnView.LayersAdd

TImageEnView.LayersAdd


Declaration


// General overloads
function LayersAdd(Kind: TIELayerKind = ielkImage; PosX: Integer = -1; PosY: Integer = -1; Width: Integer = 0; Height: Integer = 0): integer; overload;
function LayersAdd(Kind: TIELayerKind; Rect: TRect): integer; overload;

// Blank image overload (creates TIEImageLayer)
function LayersAdd(Width: Integer; Height: Integer; PixelFormat: TIEPixelFormat = ie24RGB; PosX: Integer = -1; PosY: Integer = -1): Integer; overload;

// Assign bitmap overload (creates TIEImageLayer)
function LayersAdd(Bitmap: TIEBitmap): integer; overload;

// Load image overload (creates TIEImageLayer)
function LayersAdd(FileName: String; PosX: Integer = -1; PosY: Integer = -1): integer; overload;

// Line overload (creates TIELineLayer)
function LayersAdd(StartPoint: TPoint; EndPoint: TPoint): integer; overload;

// Shape overloads (creates TIEShapeLayer)
function LayersAdd(Shape: TIEShape; PosX: Integer = -1; PosY: Integer = -1; Width: Integer = 0; Height: Integer = 0): integer; overload;
function LayersAdd(Shape: TIEShape; Rect: TRect; BorderColor: TColor = clBlack; BorderWidth: Integer = 1; FillColor: TColor = clNone): integer; overload;

// Text overload (creates TIETextLayer)
function LayersAdd(Text: String; FontSize : Integer; FontColor : TColor; FontName : string; FontStyle : TFontStyles = []; PosX: Integer = -1; PosY: Integer = -1): integer; overload;

// Clone overload
function LayersAdd(Layer: TIELayer; PosX: Integer = -1; PosY: Integer = -1; Width: Integer = 0; Height: Integer = 0): Integer; overload;


Description


Appends a new layer to the layers list. The new layer will become the current layer.
If the size and pixel format are not specified then the new layer assumes that of the current layer.
You can specify PosX and PosY for the destination position of the layer. Pass as -1, -1 to use the next available position.
Result is the index of the added layer.


Examples


ImageEnView1.IO.LoadFromFile( 'C:\first.jpg' ); // Load image into first layer (or current layer)
ImageEnView1.LayersAdd(); // Append a new layer
ImageEnView1.IO.LoadFromFile( 'C:\second.jpg' ); // Load image into the new layer (now the current layer)


// Load an image from file and add it as a layer
ImageEnView1.LayersAdd( 'C:\MyImage.jpg' );


// Apply a "Paid" stamp to image
with ImageEnView1 do
begin
  LayersAdd( 'PAID', 42, clRed, 'Arial Black', [fsBold] );
  CurrentLayer.Rotate := 30;
  TIETextLayer( CurrentLayer ).SizeToText();
  CurrentLayer.PosX := IELayer_Pos_HCenter;
  CurrentLayer.PosY := IELayer_Pos_VCenter;
  LayersMergeAll();
end;


// Add a yellow explosion shape layer at size 220 x 120
ImageEnView1.LayersAdd( iesExplosion, 50, 50, 220, 120 );
ImageEnView1.CurrentLayer.FillColor := clYellow;
ImageEnView1.CurrentLayer.BorderWidth := 0;
ImageEnView1.Update();




// Append an image layer and assign a pink border
ImageEnView1.LayersAdd( ielkImage ); // Append an image layer
ImageEnView1.IO.LoadFromFile('C:\New Zealand.jpg'); // Load image into the new/active layer
ImageEnView1.CurrentLayer.BorderColor := $008000FF;
ImageEnView1.CurrentLayer.BorderWidth := 3;




// Append a text layer
ImageEnView1.LayersAdd( ielkText );
TIETextLayer( ImageEnView1.CurrentLayer ).Text := 'This is a Text Layer';
TIETextLayer( ImageEnView1.CurrentLayer ).BorderColor := clBlack;
TIETextLayer( ImageEnView1.CurrentLayer ).BorderWidth := 1;
TIETextLayer( ImageEnView1.CurrentLayer ).FillColor := clWhite;
ImageEnView1.Update();




// Add a clone of the current layer
ImageEnView1.LayersAdd( ImageEnView1.CurrentLayer );


// Add a red box at rect (100, 100, 1000, 1000)
ImageEnView1.LayersAdd( iesRectangle, Rect(100, 100, 1000, 1000), clRed, 2 );


// Add a red box with text at rect (100, 100, 1000, 1000)
ImageEnView1.LayersAdd( ielkText, Rect(100, 100, 1000, 1000) );
with TIETextLayer( ImageEnView1.CurrentLayer ) do
begin
  BorderColor := clRed;
  BorderWidth := 5;
  FillColor := clWhite;
  Opacity := 0.66;
  Font.Height := 24;
  Font.Color := clRed;
  WordWrap := False;
  Alignment := iejCenter;
  Text := 'My Red Box';
  TextOverflow := ieoShrink;
end;


// Add a polyline layer (Triangle)
ImageEnView1.LayersAdd( ielkPolyline, Rect(100, 100, 1000, 1000) );
TIEPolylineLayer( ImageEnView1.CurrentLayer ).SetPoints( [ Point(500, 0), Point(1000, 1000), Point(0, 1000) ], True );
TIEPolylineLayer( ImageEnView1.CurrentLayer ).BorderWidth := 3;
TIEPolylineLayer( ImageEnView1.CurrentLayer ).BorderColor := clRed;
TIEPolylineLayer( ImageEnView1.CurrentLayer ).FillColor := clWhite;
ImageEnView1.Update();




// Add an angle layer
ImageEnView1.LayersAdd( ielkAngle );
with TIEAngleLayer( ImageEnView1.CurrentLayer ) do
begin
  LineWidth := 2;
  LineColor := clDkGray;
  LabelFont.Color := clBlue;
  LabelFont.Style := [fsBold];

  // Set by points on bitmap
  SetPoints( [ Point( xx + 130, yy + 0 ), Point( xx + 0, yy + 130 ), Point( xx + 130, yy + 0 ), iepbBitmap );
end;




See Also


-TIELayer
-LayersInsert
-LayersCreateFromSelection
-LayersCreateFromClipboard
-LayersCreateFromFile
-LayersCreatePolylineFromSelection