ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Polygon Selection Rotate

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AndyColmes Posted - Dec 05 2011 : 16:30:59
I would like to rotate an existing polygon selection?

Thanks.
12   L A T E S T    R E P L I E S    (Newest First)
AndyColmes Posted - Dec 18 2011 : 21:07:59
Solved my issue. I made a mistake here:

ImageEnVect1.Select( ImageEnVect1.ObjLeft[0], ImageEnVect1.ObjTop[0], (ImageEnVect1.ObjWidth[0]-ImageEnVect1.ObjLeft[0]), (ImageEnVect1.ObjHeight[0]-ImageEnVect1.ObjTop[0]), iespReplace );

when it should be:

ImageEnVect1.Select( ImageEnVect1.ObjLeft[0], ImageEnVect1.ObjTop[0], (ImageEnVect1.ObjWidth[0]+ImageEnVect1.ObjLeft[0]), (ImageEnVect1.ObjHeight[0]+ImageEnVect1.ObjTop[0]), iespReplace );

Thanks again.
AndyColmes Posted - Dec 18 2011 : 19:55:23
In my code, I set my ImageEnVect1 with SelectionBase iesbBitmap and it works for the polyline, but not for the IEKBOX where I do the Select. Where is my problem?

Please help. Thanks.
AndyColmes Posted - Dec 18 2011 : 08:43:19
I have a problem with my code where the image showing from the coordinates of the selection is wrong.

Basically, I load an annotation file IEV and after loading, I would read the object's info to create a preview. The preview is a cut-out image from the selection created from the object.

Can you help? I have a feeling it has to do with SelectionBase. My current ImageEnVect is using iesbClientArea.

procedure TfrmForm.CreatePreview;
var
x: Integer;
Bmp: TIEBitmap;
begin
if (ImageEnVect1.ObjKind[0] = IEKPolyLine) or (ImageEnVect1.ObjKind[0] = IEKEllipse) then begin
ImageEnVect1.SelectionBase := iesbBitmap;
ImageEnVect1.LockPaint();
for x:=0 to ImageEnVect1.ObjPolylinePointsCount[0]-1 do
ImageEnVect1.AddSelPoint( ImageEnVect1.ObjPolylinePoints[0, x].x, ImageEnVect1.ObjPolylinePoints[0, x].y );
ImageEnVect1.EndSelect();
ImageEnVect1.UnLockPaint();
ImageEnVect1.SelectionBase := iesbClientArea;
end;
if (ImageEnVect1.ObjKind[0] = IEKBOX) then begin
ImageEnVect1.Select( ImageEnVect1.ObjLeft[0], ImageEnVect1.ObjTop[0], (ImageEnVect1.ObjWidth[0]-ImageEnVect1.ObjLeft[0]), (ImageEnVect1.ObjHeight[0]-ImageEnVect1.ObjTop[0]), iespReplace );
end;
ImageEnVect1.Update;

Bmp := TIEBitmap.Create;
try
ImageEnVect1.CopySelectionToIEBitmap( Bmp, True );
ImageEnView1.IEBitmap.Assign( Bmp );
ImageEnView1.Update;

//My preview of the cut-out image
ImageEnView2.IEBitmap.Assign( Bmp );
ImageEnView2.Update;
finally
Bmp.Free;
end;

ImageEnVect1.Deselect;
end;
AndyColmes Posted - Dec 06 2011 : 04:33:58
Thank you Fabrizio.
fab Posted - Dec 06 2011 : 03:18:11
quote:
How do I create a selection from a IEKPolyLine object or "cut" the image to a TIEBitmap from the polygon object?


You should create a selection point by point, reading each point from the polyline and add it to selection.
For example, assuming hobj is your iekPolyLine object:

ImageEnVect1.SelectionBase := iesbBitmap;
ImageEnVect1.LockPaint();
for i:=0 to ImageEnVect1.ObjPolylinePointsCount[hobj]-1 do
    ImageEnVect1.AddSelPoint( ImageEnVect1.ObjPolylinePoints[hobj, i].x, ImageEnVect1.ObjPolylinePoints[hobj, i].y );
ImageEnVect1.EndSelect();
ImageEnVect1.UnLockPaint();



Of course you can cut (fill or make it transparent) the selected area with ImageEnVect1.Proc.Fill or ImageEnVect1. SetSelectedAreaAlpha methods.
AndyColmes Posted - Dec 06 2011 : 02:56:10
Thanks Fabrizio. How do I create a selection from a IEKPolyLine object or "cut" the image to a TIEBitmap from the polygon object?
fab Posted - Dec 06 2011 : 01:51:50
You can create a polygon object (iekPolyLine) using CreatePolygonsFromSelection.
AndyColmes Posted - Dec 06 2011 : 01:27:23
I used to be able to convert a selection (rectangle) to an IEKBOX object (for re-displaying purposes) and on a later time in the code, using the object coordinates, I was able to create a selection from the object and "cut" out the image to a new TIEBitmap.

But how would I do this with polygon? I know there is an object type IEKPolyLine, but not sure how to apply it using the method above for rectangles.

Please help. Thanks Fabrizio.
fab Posted - Dec 06 2011 : 01:20:12
"Cut" must be divided in two operations. The first one is to create the new layer with LayersCreateFromSelection. The next step is to remove (fill?) the selected area. For example you could make it transparent with SetSelectedAreaAlpha(0):

// create layer from selection
ImageEnVect1.LayersCreateFromSelection(); 

// select layer 0 and set selected area of that layer to be transparent
ImageEnVect1.LayersCurrent := 0;
ImageEnVect1.SetSelectedAreaAlpha(0);

// select layer 1 to allow user to move or rotate the area
ImageEnVect1.LayersCurrent := 1;
ImageEnVect1.MouseInteract := ImageEnVect1.MouseInteract + [miRotateLayers];
ImageEnVect1.DeSelect();



Of course you can get points of the selection using PolySelPoints, PolySel and PolySelCount.
AndyColmes Posted - Dec 06 2011 : 01:08:44
I would like to use the polygon selection coordinates to "cut" out the image and copy it to a TIEBitmap. How would I do this with layers?

Thanks Fabrizio.
fab Posted - Dec 06 2011 : 00:45:47
I suggest to use layers instead of vectorial objects:

// Create a layer from current selection
ImageEnVect1.LayersCreateFromSelection();

// Remove selection
ImageEnVect1.DeSelect();

// Allow user to rotate the new layer
ImageEnVect1.MouseInteract := ImageEnVect1.MouseInteract + [miRotateLayers];

When finished you can merge the new layer with the background image.
AndyColmes Posted - Dec 06 2011 : 00:14:07
Or can I do the following instead:

1. Make a polygon selection
2. Convert the selection to an object
3. Rotate the object
4. Use th object boundaries to copy out the bitmap

How would I do this correctly in code?

Thanks.