ImageEn, unit imageenview

TImageEnView.LayersInsert

TImageEnView.LayersInsert


Declaration

// General overloads
procedure LayersInsert(Position: Integer; Kind: TIELayerKind = ielkImage; PosX: Integer = -1; PosY: Integer = -1; Width: Integer = 0; Height: Integer = 0); overload;
procedure LayersInsert(Position: Integer; Kind: TIELayerKind; Rect: TRect); overload;

// Blank image overload (creates TIEImageLayer)
procedure LayersInsert(Position: Integer; Width: Integer; Height: Integer; PixelFormat: TIEPixelFormat = ie24RGB; PosX: Integer = 0; PosY: Integer = 0); overload;

// Assign bitmap overload (creates TIEImageLayer)
procedure LayersInsert(Position: Integer; Bitmap: TIEBitmap); overload;

// Loads image overload (creates TIEImageLayer)
procedure LayersInsert(Position: Integer; FileName: String; PosX: Integer = -1; PosY: Integer = -1); overload;

// Line overload (creates TIELineLayer)
procedure LayersInsert(Position: Integer; StartPoint: TPoint; EndPoint: TPoint; LineColor: TColor = clNone; LineWidth: Integer = -1); overload;

// Polyline overloads (creates TIEPolylineLayer)
procedure LayersInsert(Position: Integer; Points: array of TPoint; ClosePolygon: Boolean; LineColor: TColor = clNone; LineWidth: Integer = -1; FillColor: TColor = clNone); overload;
procedure LayersInsert(Position: Integer; Points: array of Integer; ClosePolygon: Boolean; LineColor: TColor = clNone; LineWidth: Integer = -1; FillColor: TColor = clNone); overload;

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

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

// Mask overload (creates TIEShapeLayer with IsMask = True)
procedure LayersInsert(Position: Integer; StartOpacity, EndOpacity: Integer; MaskGradient: TIEGDIPlusGradient; MaskShape: TIEShape = iesRectangle; PosX: Integer = -1; PosY: Integer = -1; Width: Integer = 0; Height: Integer = 0; MaskInverted: Boolean = True); overload;

// Cloning overload
procedure LayersInsert(Position: Integer; Layer: TIELayer; PosX: Integer = -1; PosY: Integer = -1; Width: Integer = 0; Height: Integer = 0); overload;


Description

Inserts a new layer into the layers list at the specified position. 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 (in terms of the background bitmap, e.g. 0,0 would align the new layer with the top-left of Layer[0]). Pass as -1, -1 to use the next available position.

Note: Only a TIEImageLayer can be inserted at position 0 (i.e. as background layer). If you attempt to insert a non-image layer at position 0, it will be inserted at 1


Examples

ImageEnView1.IO.LoadFromFile( 'C:\first.jpg' );    // Load image into first layer (will become background)
ImageEnView1.LayersInsert( 1 );                    // Insert a new layer above the background 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.LayersInsert( 1, 'C:\MyImage.jpg' );


// Insert a text layer
ImageEnView1.LayersInsert( 1, 'My text layer', 14, clBlack, 'Arial' );


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




// Insert an image layer and apply a pink border
ImageEnView1.LayersInsert( 3, ielkImage );             // Insert an image layer after layer 2 (i.e. 3rd layer)
ImageEnView1.IO.LoadFromFile( 'C:\New Zealand.jpg' );  // Load image into the new/active layer
ImageEnView1.CurrentLayer.BorderColor := $008000FF;
ImageEnView1.CurrentLayer.BorderWidth := 3;
ImageEnView1.Update();



// Insert a text layer
ImageEnView1.LayersInsert( 1, 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 mask layer to the background layer which is transparent at the top and opaque at the bottom
ImageEnView1.LayersInsert( 1, 0, 255, gpgVertical );




// Add a star shape mask with 50% opacity to the current layer
ImageEnView1.LayersInsert( ImageEnView1.LayersCurrent + 1, 128, 128, gpgNone, iesStar5 );



// Clone the current layer
ImageEnView1.LayersInsert( ImageEnView1.CurrentLayer.LayerIndex, ImageEnView1.CurrentLayer );


// Insert a polygon (closed polyline) of yellow star with a red border (points are in terms of the bitmap)
ImageEnView1.LayersInsert( 1, [ 125,0, 155,95, 250,95, 175,155, 202,250, 125,193, 48,250, 78,155, 0,95, 98,95 ], True, clRed, 2, clYellow );
ImageEnView1.Update();


// Insert a polyline layer (Triangle)
ImageEnView1.LayersInsert( 1, 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.LayersInsert( 1, 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;




// Add a 5-pointed star polyline layer
var
  pp: array[0..10] of TPoint;
begin
  pp[0]  := Point(175, 50);
  pp[1]  := Point(205, 145);
  pp[2]  := Point(300, 145);
  pp[3]  := Point(225, 205);
  pp[4]  := Point(253, 300);
  pp[5]  := Point(175, 243);
  pp[6]  := Point(98 , 300);
  pp[7]  := Point(128, 205);
  pp[8]  := Point(50 , 145);
  pp[9]  := Point(148, 145);
  pp[10] := Point(175, 50);

  ImageEnView1.LayersInsert( 1, pp, True, clOrangeRed, 3, clYellow );
  ImageEnView1.Update();
end;




See Also

TIELayer
LayersAdd
LayersCreateFromSelection
LayersCreateFromClipboard
LayersCreateFromFile
LayersCreatePolylineFromSelection