ImageEn, unit iexUserInteractions

TIECropToolInteraction.GetBitmapPolygon

TIECropToolInteraction.GetBitmapPolygon


Declaration

procedure GetBitmapPolygon(out Rect: TRect); overload;
procedure GetBitmapPolygon(out Pts: Array of TDPoint); overload;


Description

Gets the area of the image selected for cropping and assigns it to a variable.
The TRect overload should be used if mode is Mode is iectmPERSPECTIVE.
If you use the Pts array, you must pass an array[0..3] of TDPoint (The points will be returned in the following order: TL, TR, BR, BL).

Note: Values are in terms of the bitmap. Use XBmp2Scr and YBmp2Scr to convert screen bitmap to screen values



Example

// Select 80% of image
ARect := Rect( MulDiv( ImageEnView1.IEBitmap.Width, 10, 100 ),
               MulDiv( ImageEnView1.IEBitmap.Height, 10, 100 ),
               MulDiv( ImageEnView1.IEBitmap.Width, 90, 100 ),
               MulDiv( ImageEnView1.IEBitmap.Height, 90, 100 ));
ImageEnView1.CropTool.GetBitmapPolygon( ARect );
ImageEnView1.Invalidate();


Saving Selection Example

var
  fCropSelection: array[0..3] of TDPoint;
  fCropRotation: Double;

// Save current selection
procedure TForm1.SaveCropToolSelection();
begin
  if ImageEnView1.CropTool.Selected = False then
    raise Exception.create( 'Nothing is selected' );

  ImageEnView1.CropTool.GetBitmapPolygon( fCropSelection );
  fCropRotation  := ImageEnView1.CropTool.Rotation;
end;

// Restore a saved selection
procedure TForm1.RestoreCropToolSelection();
begin
  ImageEnView1.CropTool.SetBitmapPolygon( fCropSelection );
  ImageEnView1.CropTool.Rotation := fCropRotation;
  ImageEnView1.Update();
end;


See Also

 SetBitmapPolygon
 BitmapPolygon
 Rotation