ImageEn, unit iexLayers

TIELayer.RestoreAspectRatio

TIELayer.RestoreAspectRatio


Declaration

procedure RestoreAspectRatio(PreferredOnly: Boolean = True);


Description

Sizes the layer to restore its preferred or original aspect ratio (i.e. the ratio of Height:Width).
Some layer types look best at their original aspect ratio. This is particularly true of images and some shapes.
Calling RestoreAspectRatio will resize it (reducing its display size) to display it correctly.

If PreferredOnly = True then it is only sized if it has a PreferredAspectRatio.
If PreferredOnly = False and it does not have a PreferredAspectRatio then it is restored to its design size.

Note: Resizing layers using mouse interaction will update the aspect ratio.


Example

// Fix the aspect ratio for the selected layer if it is an image
if ImageEnView1.CurrentLayer is TIEImageLayer then
  ImageEnView1.CurrentLayer.RestoreAspectRatio();
ImageEnView1.Update();

// Create a layer at 50,50 and display an image (maintaining its aspect ratio)
ImageEnView1.LockUpdate();
ImageEnView1.LayersAdd( 100, 100, ie24RGB, 50, 50 );
ImageEnView1.IO.LoadFromFile( 'D:\image.jpeg' );
ImageEnView1.CurrentLayer.RestoreAspectRatio();
ImageEnView1.UnlockUpdate();


See Also

 RestoreSize
 AspectRatioLocked
 PreferredAspectRatio
 LayersResizeAspectRatio