ImageEn, unit imageenview |
|
TImageEnView.BeginSelect
Declaration
procedure BeginSelect();
Description
Call before a series of
AddSelPoint and
AddSelBreak calls to limit redrawing.
Note:
◼Unlike
EndSelect,
BeginSelect is
Optional it only serves to prevent paint being called (same as wrapping your code in
LockPaint/
UnlockPaint)
◼If you call
BeginSelect, you
must call
EndSelect
// 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 );