ImageEn, unit imageenview

TImageEnView.CalcSelectionLen

TImageEnView.CalcSelectionLen

Declaration

function CalcSelectionLen(Units: TIEUnits = ieuPixels): double;

Description

Returns the length (perimeter) of current selection.
If the selection is composed of only two points, the line length is returned. If the selection is composed of three or more points, the perimeter is returned.

Note:
This method will not work with mask selections
For units other than ieuPixels, the value will be calculated using the image DPI

Demo

Demo  Demos\ImageEditing\EveryMethod\EveryMethod.dpr

Example

// Show statistics while making a selection
procedure TfrmMain.ImageEnView1SelectionChanging(Sender: TObject);
const
  Units = ieuPixels;
var
  uS: string;
begin
  uS := IEGlobalSettings().MeasureUnits[ Units ];

  Label1.Caption := format( 'Area: %.2f %sē', [ ImageEnView1.CalcSelectionArea( Units ), uS ]);
  Label2.Caption := format( 'Perimeter: %.2f %s',[ ImageEnView1.CalcSelectionLen( Units ), uS ]);
  Label3.Caption := format( 'Centroid: %d,%d', [ ImageEnView1.CalcSelectionCentroid.X, ImageEnView1.CalcSelectionCentroid.Y ]);
end;

See Also

CalcSelectionArea
CalcSelectionCentroid
MeasureUnits