ImageEn, unit imageenview

TImageEnView.LayersRect

TImageEnView.LayersRect


Declaration

function LayersRect(SelOnly: Boolean = False; ExcludeLayer0: Boolean = False): TIERectangle;


Description

Returns the coverage area of all or selected layers.
The result will include any layers outside the background layer (if LayersCropped and Cropped are not set).
If ExcludeLayer0 is True, then the background layer is not included in the result.

Note:
If layers extend to the left or above the background layer, then Result.X/Y will be less than PosX/Y of Layer 0
If layers extend to the right or below the background layer, then Result.Width/Height may be greater than the dimensions of IEBitmap


Example 1

// Center layers around point, pt

// Get position of all layers
layersRect := ImageEnView1.LayersRect( False, True );

// Find center point of layers
hCtr := layersRect.x + layersRect.Width div 2;
vCtr := layersRect.y + layersRect.Height div 2;

// Move layers to new center point
ImageEnView1.LayersRepositionAll( -hCtr + pt.X, -vCtr + pt.Y );


Example 2

// Zoom so layers fill entire view area

// Make IEView consider all layers when calculating image bounds
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [loDynamicCanvas];

// Position layers so origin is 0,0
rect := ImageEnView1.LayersRect(False, True);
ImageEnView1.LayersRepositionAll(-rect.X, - rect.Y);

// Adjust zoom so all layers fill the view area
ImageEnView1.Fit();


See Also

MaxLayerWidth
MaxLayerHeight