TDesignerLayer32

Hierarchy

   |

TLayer32

   |

TCustomDesignerLayer32


TDesignerLayer32 objects can contain just about any kind of visual designer aid, including: background hatched images; grid-line images; and rulers. TDesignerLayer32 also provides a number of designer drawing methods that may be useful for drawing hit-test regions, group bounds, virtual spline control points etc.

TDesignerLayer32 are 'non-clickable', so they won't be returned by calls to TLayeredImage32.GetLayerAt.

Adapted from Examples/LayersAndTransform

uses
  ImagePanels, Image32, Image32_Layers, Image32_BMP, 
  Image32_Draw, Image32_Vector, Image32_Extra, Image32_Transform;

var
  buttonGroupId: Integer;
  splinePts: TPathD;

procedure TForm1.FormCreate(Sender: TObject);
var
  i, firstButtonIdx: integer;
begin
 ...
  layeredImage32 := TLayeredImage32.Create(512, 512);
  
  //layer 0:
  layer := layeredImage32.AddNewLayer(TDesignerLayer32, 'hatched background');
  HatchBackground(layer.Image, clWhite32, $FFE0E0E0);
  
  //Layer 1: stores a hidden master image
  layer := layeredImage32.AddNewLayer(TDesignerLayer32, 'master image');
  layer.image.LoadFromResource('UNION_JACK', 'BMP');
  layer.Visible := false;

  //Layer 2: for the final transformed image
  layeredImage32.AddNewLayer('transformed image');

  //Layer 3: a design layer to show virtual design buttons etc
  layer := layeredImage32.AddNewLayer(TDesignerLayer32, 'design');
  layer.SetSize(512, 512);
      
  splinePts := MakePathI([16,79, 57,116, 89,104, 115,131, 151,162, 198,183]);
  
  buttonGroupId := 
    CreateButtonGroup(layeredImage32, splinePts, clGreen32, DefaultButtonSize, []);
...
end;

procedure TForm1.UpdateLayeredImage;
var
  i, firstButtonIdx: integer;
  pt: TPoint;
  path: TPathD;
begin
  //using splinePts, transform and update the 'transform' layer (index 2)
  with layeredImage32[2] do
  begin
    image.Assign(layeredImage32[1].image); //copy of 'master'
    SplineTransformVert(image, splinePts, stQuadratic, clRed32, false, pt);
    PositionAt(pt);
  end;

  with TDesignerLayer32(layeredImage32[3]) do
    DrawQSplineDesign(splinePts);

  //move the 'button' layers to the splinePts coordinates
  firstButtonIdx := layeredImage32.GetFirstInGroupIdx(buttonGroupId);
  for i := 0 to high(splinePts) do
    with layeredImage32[firstButtonIdx +i] do
      PositionCenteredAt(Point(splinePts[i]));

  //copy the merged layeredImage32 to Panel1
  layeredImage32.MergedImage.CopyToDc(Panel1.Bitmap.Canvas.Handle);
  Panel1.Refresh;
end;
    

Reference

Methods Properties
In TDesignerLayer32:
Create ButtonSize
DrawCSplineDesign PenColor
DrawEllipse PenWidth
DrawGrid
DrawLine
DrawQSplineDesign
DrawRectangle
In TLayer32:
BringForward Bounds
Offset ClientMidPoint
PositionAt CursorId
PositionCenteredAt GroupId
SendBack Height
SetBounds HitTestRegions
SetSize Image
Index
IndexInGroup
Left
MidPoint
Name
Opacity
Owner
Top
Visible
Width

See Also

TLayeredImage32.GetLayerAt