ImageEn, unit imageenview |
|
TImageEnView.AddSelPoint
Declaration
procedure AddSelPoint(x, y: Integer);
Description
Adds a point to the current polygonal selection.
If
SelectionBase is
iesbClientArea (default), all coordinates depend upon actual zoom and scrolling.
Otherwise, if
SelectionBase is
iesbBitmap all coordinates refer to bitmap pixels.
Use
EndSelect to terminate selection by code.
Note: If you are adding many points, you should wrap your code in
LockPaint/
UnlockPaint to limit redraw
// Create a polygon selection from an array of TPoints
ImageEnView1.BeginSelect();
for I := Low( MyPolySelArray ) to High( MyPolySelArray ) do
ImageEnView1.AddSelPoint( MyPolySelArray[ I ].x, MyPolySelArray[ I ].y );
ImageEnView1.EndSelect();
// Add a triangular selection
ImageEnView1.BeginSelect();
ImageEnView1.Deselect();
ImageEnView1.AddSelPoint( 200, 100 );
ImageEnView1.AddSelPoint( 300, 200 );
ImageEnView1.AddSelPoint( 100, 200 );
ImageEnView1.EndSelect();
// 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;
// Convert the current polyline layer to a polygon selection
ImageEnView1.BeginSelect();
ImageEnView1.Deselect();
ImageEnView1.SelectionBase := iesbClientArea;
plyr := TIEPolylineLayer( ImageEnView1.CurrentLayer );
ImageEnView1.LayersCurrent := 0; // Selecting layer 0
for i := 0 to plyr.PointCount - 1 do
begin
xx := Round( plyr.GetPoints( i, iepbClientArea).x );
yy := Round( plyr.GetPoints( i, iepbClientArea).y );
ImageEnView1.AddSelPoint(xx, yy);
end;
ImageEnView1.EndSelect();
ImageEnView1.LayersRemove( plyr.LayerIndex );
See Also
◼AddSelBreak
◼AddSelCurve
◼DelLastSelPoint
◼EndSelect
◼PolySel
◼PolySelPoints