ImageEn, unit imageenview

TImageEnView.SelectionBase

TImageEnView.SelectionBase


Declaration

property SelectionBase: TIESelectionBase;


Description

Specifies the meaning of coordinates used when creating a selection.
If SelectionBase is iesbClientArea, then all coordinates depend upon the actual zoom and window view/scrolling (i.e. pixels on screen). Otherwise, if SelectionBase is iesbBitmap, then all coordinates refer to bitmap pixels.

Default: iesbClientArea

Note: Specify before creating a selection. It has no effect on existing selections.


Examples

// Select a 100 pixel square in the top left corner of the bitmap
ImageEnView1.SelectionBase := iesbBitmap;
ImageEnView1.Select(0, 0, 100, 100);

// Select a 100 pixel square that is displayed in the top left corner of the ImageEnView window (100 x 100 pixels of screen area)
ImageEnView1.SelectionBase := iesbClientArea;
ImageEnView1.Select(0, 0, 100, 100);

Note: When ImageEnView1.Zoom = 100, ImageEnView1.ViewX = 0 and ImageEnView1.ViewY = 0, then both the preceeding examples will provide the same result

// Select 20% of the center of the screen
const
  Selection_Size = 0.2; // 20% of screen area
begin
  ImageEnView1.SelectionBase := iesbClientArea;
  ImageEnView1.Select(Trunc((0.5 - Selection_Size / 2) * ImageEnView1.ClientWidth),
                      Trunc((0.5 - Selection_Size / 2) * ImageEnView1.ClientHeight),
                      Trunc((0.5 + Selection_Size / 2) * ImageEnView1.ClientWidth),
                      Trunc((0.5 + Selection_Size / 2) * ImageEnView1.ClientHeight));
end;

// Make circular selection of entire image and crop
ImageEnView1.SelectionBase := iesbBitmap;
ImageEnView1.SelectEllipse(ImageEnView1.IEBitmap.Width div 2,
                           ImageEnView1.IEBitmap.Height div 2,
                           ImageEnView1.IEBitmap.Width,
                           ImageEnView1.IEBitmap.Height);
ImageEnView1.Proc.CropSel();

// Select whole image and allow user to deselect circular regions
With ImageEnView1 do
begin
  SelectionBase := iesbBitmap;
  Select( 0, 0, IEBitmap.Width, IEBitmap.Height );
  ShiftKeyLock  := [ iessCtrl_SubFromSel ];
  MouseInteractGeneral := [ miSelectCircle ];
end;

// Select a pentagonal area of the image and save it to PNG (with transparent background)
const
  PENT_X1 = 0.21; PENT_Y1 = 0.41;
  PENT_X2 = 0.32; PENT_Y2 = 0.74;
  PENT_X3 = 0.68; PENT_Y3 = 0.74;
  PENT_X4 = 0.79; PENT_Y4 = 0.41;
  PENT_X5 = 0.50; PENT_Y5 = 0.20;
var
  bmp: TIEBitmap;
  bw, bh: Integer;
begin
  ImageEnView1.SelectionBase := iesbBitmap;

  bw := ImageEnView1.IEBitmap.Width;
  bh := ImageEnView1.IEBitmap.Height;

  ImageEnView1.BeginSelect();
  ImageEnView1.AddSelPoint( Round( PENT_X1 * bw ), Round( PENT_Y1 * bh ));
  ImageEnView1.AddSelPoint( Round( PENT_X2 * bw ), Round( PENT_Y2 * bh ));
  ImageEnView1.AddSelPoint( Round( PENT_X3 * bw ), Round( PENT_Y3 * bh ));
  ImageEnView1.AddSelPoint( Round( PENT_X4 * bw ), Round( PENT_Y4 * bh ));
  ImageEnView1.AddSelPoint( Round( PENT_X5 * bw ), Round( PENT_Y5 * bh ));
  ImageEnView1.EndSelect();

  bmp := TIEBitmap.Create();
  ImageEnView1.CopySelectionToBitmap( bmp, False );
  bmp.SaveToFile( 'D:\PentagonalSelection.png' );
  bmp.Free();
end;


See Also

Select
XBmp2Scr
XScr2Bmp
YBmp2Scr
YScr2Bmp