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
 convert iekbox to polyline

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
pierrotsc Posted - Nov 29 2018 : 14:33:14
I have a rough time trying to convert the iekbox code (Looks like it's becoming obsolete) to a polyline.

This is the code i use.
ImageEnVect.AddNewObject(iekBOX,
Rect(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(i) +
'_Left').AsInteger, Embeddeddm.nxTable_Tablet.FieldByName('Square00' +
IntToStr(i) + '_Top').AsInteger,
Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(i) +
'_Right').AsInteger, Embeddeddm.nxTable_Tablet.FieldByName('Square00'
+ IntToStr(i) + '_Bottom').AsInteger), Mainform.PenColor.colorvalue);

I tried that but I guess that is not it :)

SetLength(iShapePoints, 4);
iShapePoints[0] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Left').AsInteger, Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Top').AsInteger);
iShapePoints[1] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Top').AsInteger, Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Right').AsInteger);
iShapePoints[2] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Right').AsInteger, Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Bottom').AsInteger);
iShapePoints[3] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Bottom').AsInteger, Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Left').AsInteger);
ilayer := Mainform.ImageEnVect.LayersAdd(ielkPolyline);
TIEPolylineLayer(Mainform.ImageEnVect.Layers[ilayer]).LineWidth := 3;
TIEPolylineLayer(Mainform.ImageEnVect.Layers[ilayer]).LineColor := clred;
TIEPolylineLayer(Mainform.ImageEnVect.Layers[ilayer]).PolylineClosed := True;

TIEPolylineLayer(Mainform.ImageEnVect.Layers[ilayer]).SetPoints(iShapePoints, True);
Mainform.ImageEnVect.Update();

Any guru out there that can help me?
Thanks
20   L A T E S T    R E P L I E S    (Newest First)
pierrotsc Posted - Dec 01 2018 : 16:59:50
never mind. i think i finally got it to work..the manual was a big help..
pierrotsc Posted - Dec 01 2018 : 13:43:45
Ok, Nigel, i think i am getting there but it is not working. i modified the layers demo but in a nutshell, this is what i am doing. i am loading an image, then i press a button that adds 3 polyline layers. They are 100x100 squares. Then i am trying to select the layer 1 size, and average the points of the background within this selection. nothing is happening. here's the simple code
ImageEnView1.LayersAdd(iesRectangle, Rect(5, 5, 100, 100), clRed, 3, clNone);
ImageEnView1.Update();
ImageEnView1.LayersAdd(iesRectangle, Rect(105, 5, 205, 100), clRed, 3, clNone);
ImageEnView1.Update();
ImageEnView1.LayersAdd(iesRectangle, Rect(210, 5, 310, 100), clRed, 3, clNone);
ImageEnView1.Update();

ImageEnView1.Deselect;
ImageEnView1.LayersCurrent := 0;
ImageEnView1.SelectionBase := iesbClientArea;
lyr1Rect := ImageEnView1.Layers[1].ClientAreaBox;
ImageEnView1.Select(lyr1Rect.Left, lyr1Rect.Top, lyr1Rect.Right, lyr1Rect.Bottom);
ImageEnView1.Update();
ImageEnView1.Proc.Fill(ImageEnView1.Proc.CalcAverageRGB());
ImageEnView1.Update();

Do you see what the issue is ?
Thanks
Best
Pierre
pierrotsc Posted - Nov 30 2018 : 21:00:03
i will. i think i need to start from scratch first to see if i can reproduce it. right now, i am mixing vectors and polylines.
Best
xequte Posted - Nov 30 2018 : 20:05:38
Try to create a sequence to reproduce the bug and let me know the steps.



Nigel
Xequte Software
www.imageen.com
pierrotsc Posted - Nov 30 2018 : 19:51:31
ok..will play with it tomorrow. thanks for the code sample...
something i noticed when i created all the polyline layers is sometimes when i click on one layer in the thumbnail of imageenmview, i get 2 selected. for example layer 2 and 5 get selected when i click on layer 2. not sure what is happening.
will try a clean project from scratch in the morning.
xequte Posted - Nov 30 2018 : 19:47:26
> I may have to look at clientareabox though. if i have 2 rectangular polyline
> in one layer, how do i differentiate one from another ?

ClientAreaBox returns the area of the whole layer (rectangular area that fits all polylines within.

> Also, if i merge all, do they all rasterize or could i keep all the polylines
> in one layer ?

Two polyline layers cannot be merged into one polyline layer. As a polyline layer supports only one "line"

Merging converts the polyline layer into a bitmap.



Nigel
Xequte Software
www.imageen.com
pierrotsc Posted - Nov 30 2018 : 19:26:55
I see. so i would have to go through each layers. That should work. I will try to code something small and see what I get. Thank you Nigel.
Best
Pierre

I may have to look at clientareabox though. if i have 2 rectangular polyline in one layer, how do i differentiate one from another ?
Also, if i merge all, do they all rasterize or could i keep all the polylines in one layer ? that may not be posible though. just thinking as i am typing.
xequte Posted - Nov 30 2018 : 19:00:51
Hi Pierre

It should be something like:

// Select in background layer the area of layer 1
ImageEnView1.LayersCurrent := 0;
ImageEnView1.SelectionBase := iesbClientArea;
lyr1Rect := ImageEnView1.ClientAreaBox;
ImageEnView1.Select( lyr1Rect.Left, lyr1Rect.Top, lyr1Rect.Right, lyr1Rect.Bottom );


Nigel
Xequte Software
www.imageen.com
pierrotsc Posted - Nov 30 2018 : 09:32:27
Thank you Nigel, that works. But before I strat modifying all my code, i would like to know if the following code will still work. What i have is an image with some gray patches. i create boxes in these patches and i average the gray values.
Now that i use layers, i guess i can merge all layers or maybe not before i run the following command. if i merge all layers, do they rasterize ?
This is what i run right now.

Mainform.ImageEnVect.Select(Mainform.ImageEnVect.ObjLeft[i], Mainform.ImageEnVect.ObjTop[i], Mainform.ImageEnVect.ObjLeft[i] + Mainform.ImageEnVect.ObjWidth[i], Mainform.ImageEnVect.ObjTop[i] + Mainform.ImageEnVect.ObjHeight[i], iespReplace);
Mainform.Calibration.Select((i * 100), 0, (i * 100) + 100, 100, iespReplace);
Mainform.Calibration.Proc.Fill(Mainform.ImageEnVect.Proc.CalcAverageRGB());

Best
Pierre
xequte Posted - Nov 29 2018 : 19:49:23
Hi

A Polyline layer, by nature, requires an array of points (i.e. the polyline layer doesn't know what the shape is). So for a rect (given you have leftX,topY and rightX,bottomY) the four points would be:

leftX,topY
rightX,topY
rightX,bottomY
leftX,bottomY

Otherwise you can use a TIEShapeLayer with a rectangle shape:

ImageEnView1.LayersAdd( iesRectangle, Rect(leftX, topY, rightX, bottomY), clRed, 3, clNone );

https://www.imageen.com/help/TImageEnView.LayersAdd.html

Nigel
Xequte Software
www.imageen.com
pierrotsc Posted - Nov 29 2018 : 18:35:18
No, this is not what i meant :) rect function only give you 2 points. the top/left (X,Y) that is the first point and the bottom right (X,Y) that is the second point. i have 4 values, they are X,Y for the first point and X,Y for the second point. so you really need only 2 points to draw a rectangle. can polyline do that ?
xequte Posted - Nov 29 2018 : 17:32:32
Hi

Naturally, a rectangle requires 4 points, which you can generate from the Top,Left and Bottom,Right coordinates.

Nigel
Xequte Software
www.imageen.com
pierrotsc Posted - Nov 29 2018 : 16:51:30
That does not work. it does not give me a square.I get a weird shape. I looked again at the rect function. the rect function gives me 2 points. the top left and the bottom right. these are the coordinates i have. so can i draw a square with only 2 Tpoints using polyline ?
xequte Posted - Nov 29 2018 : 15:12:00
So your code would be something like:

SetLength(ShapePoints, 4);
ShapePoints[0] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Left').AsInteger,
                        Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Top').AsInteger);
ShapePoints[1] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Top').AsInteger,
                        Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Right').AsInteger);
ShapePoints[2] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Right').AsInteger,
                        Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Bottom').AsInteger);
ShapePoints[3] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Bottom').AsInteger,
                        Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Left').AsInteger);

Mainform.ImageEnVect.LayersAdd(ielkPolyline);

polyLayer := TIEPolylineLayer(Mainform.ImageEnVect.CurrentLayer);
polyLayer.LineWidth := 3;
polyLayer.LineColor := clRed;
polyLayer.SetPoints(ShapePoints, True);

Mainform.ImageEnVect.Update();


Nigel
Xequte Software
www.imageen.com
xequte Posted - Nov 29 2018 : 15:06:56
Hi

Then it should work if you use:

TIEPolylineLayer(Mainform.ImageEnVect.Layers[ilayer]).SetPoints(iShapePoints, True, iepbBitmap);

Nigel
Xequte Software
www.imageen.com
pierrotsc Posted - Nov 29 2018 : 15:05:29
Yes, i use bitmap coordinates of the background image. The boxes create a template. then i average the grayscale values inside each box.
xequte Posted - Nov 29 2018 : 15:02:36
> corner coordinates of the box

Relative to what? The bitmap, the screen or some range?

Nigel
Xequte Software
www.imageen.com
pierrotsc Posted - Nov 29 2018 : 14:59:19
Yes, the copyallobjects should work but i am trying to convert all the code as it looks like imageenvect is becoming obsolete.
pierrotsc Posted - Nov 29 2018 : 14:53:41
The values are in a nexusDB database. they are the coordinates of each square to create a template. So they are the corner coordinates of the box.
xequte Posted - Nov 29 2018 : 14:51:41

Also, have you seen this section for other tips:

https://www.imageen.com/help/TImageEnVect%20vs%20TIELayers.html

And you can copy all objects as layers to a TImageEnView using:

https://www.imageen.com/help/TImageEnVect.CopyAllObjectsTo.html


Nigel
Xequte Software
www.imageen.com