Image32_Layers

This unit contains the TLayeredImage32 class that provides a relatively easy way to layer multiple images that will at some stage be merged into a single image.

Each TLayer32 in a TLayeredImage32 object represents a single image. The index of each layer determines the order that each layered image is merged into the final image, with lower indexed layers being below or behind layers with higher indexes.

Layers can be positioned anywhere, but only those portions of layers that are within their owner TLayeredImage32 bounds will be merged with other layers (see TLayeredImage32.GetMergedImage)

There are 3 principle layer classes: the generic (unspecialised) TLayer32 class; the TDesignerLayer32 class; and theTButtonDesignerLayer32 class.

  1. TLayer32 - this generic class will typically be included in the final layered (merged) image, and it's usually there when designing too;
  2. TDesignerLayer32 - are easily filtered (excluded) from the final merged image. This layered class is intended for images that aid in design rather than be a part of the final image. Examples include: hatched backgrounds (commonly used to indicate background transparency); grids; and design guide lines. TDesignerLayer32 are also 'unclickable' in that they won't be returned by TLayeredImage32.GetLayerAt method calls.
  3. TButtonDesignerLayer32 - is a hybrid of TLayer32 and TDesignerLayer32. Like TDesignerLayer32, it's easily stripped from merged images; yet it's still 'clickable' (ie can be returned by TLayeredImage32.GetLayerAt method calls). As its name implies, this class is intended for button controls that dynamically move, size, rotate or reshape images.



From Examples/SimpleLayers

uses 
  Image32, Image32_Layers, Image32_Extra, ImagePanels,
  Image32_BMP, Image32_PNG, Image32_JPG, Image32_Draw, 
  Image32_Vector, Image32_Text;


type
  TForm1 = class(TForm)  
  private
...
    layeredImage32: TLayeredImage32;
...    
  end;
  
procedure TForm1.FormCreate(Sender: TObject);
var  
  rec: TRect;
  layer: TLayer32;
begin
  ...
  rec := Panel1.InnerClientRect;
  layeredImage32 := 
    TLayeredImage32.Create(rec.Width, rec.Height);
    
  //we don't need to worry about BackgroundColor here as 
  //we're using a hatched image for the background instead.
  layer := layeredImage32.AddNewLayer(TDesignerLayer32, '');
  //layer.SetSize() is the same as layer.image.SetSize()
  layer.SetSize(layeredImage32.Width, layeredImage32.Height);
  HatchBackground(layer.Image, $FFF0F0F0, clWhite32);
  ...
end;

function TForm1.AddEllipse(const pt: TPoint): TLayer32;
  paths: TLayer32;
begin
  Result := layeredImage32.AddNewLayer('ellipse');
  SizeAndDrawLayer(Result, 192, 150);
  Result.PositionCenteredAt(pt);
end;

procedure TForm1.PaintLayeredImage;
begin
  with layeredImage32 do
  begin
    Panel1.Bitmap.SetSize(Width, Height);
    GetMergedImage(false).CopyToDc(Panel1.Bitmap.Canvas.Handle);
  end;
  Panel1.Refresh;
end;
      

Contents

Types Classes Routines Variables Constants
TLayer32Class TButtonDesignerLayer32 AddToButtonGroup Image32_Layers Image32_Layers
TSizingStyle TCustomDesignerLayer32 CreateButtonGroup
TDesignerLayer32 CreateSizingBtnsGroup
TLayer32 StartButtonGroup
TLayeredImage32 UpdateSizingGroup

See Also

TButtonDesignerLayer32, TDesignerLayer32, TLayer32, TLayeredImage32, TLayeredImage32.AddNewLayer, TLayeredImage32.GetLayerAt, TLayeredImage32.GetMergedImage