T O P I C R E V I E W |
HMArnold |
Posted - Sep 15 2024 : 15:27:48 I'm trying to draw simple shapes using the new TImageEnView environment in response to mouse movement.
In the old TImageEnVect you could add as many shapes or lines as you wanted, each with a handle that could be erased individually.
With the new TImageEnView, this code...
if TrgtC1 <> 0 then Image.LayersRemove(TrgtC1); if TrgtC2 <> 0 then Image.LayersRemove(TrgtC2);
Rect.Create(Point(Vrtx.X-10,Vrtx.y-10),Point(Vrtx.X+10,Vrtx.Y+10)); TrgtC1 := Image.LayersAdd(iesEllipse, Rect, clRed, 3);
Rect.Create(Point(Vrtx.X-2,Vrtx.y-2),Point(Vrtx.X+2,Vrtx.Y+2)); TrgtC2 := Image.LayersAdd(iesEllipse, Rect, clBlue, 1);
Produces two concentric circles, but only erases one as the mouse moves.
Is there a single shape layer and all your shapes goes on that or is there supposed to be a different layer for each shape?
How do you add objects that have individually erasable handles?
I find lots of examples and demos with a single object, but none with two or more
Thanks
HM Arnold |
9 L A T E S T R E P L I E S (Newest First) |
xequte |
Posted - Dec 19 2024 : 18:28:27
I see there is a "Image.Layers[x].Bitmap.Canvas" which would allow to use multiple canvas drawing tools (LineTo, Ellipse, etc) to draw any number of lines, circles, polygons, etc on a single layer.
Yes, you can draw onto an image canvas if that suits your requirements, but they will no longer be vectors (i.e. quality will be lost if you resize the layer).
A similar method is as mentioned earlier, custom drawing the layer. You could then output your shapes (using the standard canvas tools) each time the layer is drawn so they remain "vectors".
Of course, you would need some way of storing all the drawing information for each layer, e.g. Layer.UserData:
http://www.imageen.com/help/TIELayer.UserData.html
Is there a special kind of layer that will allow that kind of drawing?
If you are going to custom draw a layer or draw to it canvas, you need to use an ImageLayer.
Here is an example of custom drawing shapes and text:
procedure Tfmain.ImageEnView1DrawLayer(Sender: TObject; Dest: TIEBitmap; LayerIndex: Integer; LayerRect: TRect);
var
rw, rh: Integer;
textX, textY: Integer;
sz: TSize;
begin
if LayerIndex = 0 then
exit;
rw := LayerRect.Right - LayerRect.Left;
rh := LayerRect.Bottom - LayerRect.Top;
// Draw ellipse
Dest.IECanvas.Brush.Style := bsClear;
Dest.IECanvas.Pen.Color := clYellow;
Dest.IECanvas.Pen.Style := psSolid;
Dest.IECanvas.Pen.Width := 5;
Dest.IECanvas.Ellipse( LayerRect.Left, LayerRect.Top, LayerRect.Right, LayerRect.Bottom );
// Text
Dest.IECanvas.Font.Size := 20;
Dest.IECanvas.Font.Style := [fsBold];
Dest.IECanvas.Font.Color := clRed;
sz := Dest.IECanvas.TextExtent( 'ImageEn!' );
textX := LayerRect.Left + ( rw - sz.cx ) div 2;
textY := LayerRect.Top + ( rh - sz.cy ) div 2;
// Draw Rect around text
Dest.IECanvas.Brush.Color := clWhite;
Dest.IECanvas.Brush.Style := bsSolid;
Dest.IECanvas.Brush.Transparency := 128;
Dest.IECanvas.FillRect( Rect( textX, textY, textX + sz.cx, textY + sz.cy ));
Dest.IECanvas.TextOut( textX, textY, 'ImageEn!' );
end;
Nigel Xequte Software www.imageen.com
|
HMArnold |
Posted - Dec 19 2024 : 04:38:13 Thanks again
Grouping objects might be a path forward for me, allowing a single group to be deleted and redrawn without having to redraw all the polygons and nodes in a picture, but it will require hundreds of groups and thousands of layers.
I see there is a "Image.Layers[x].Bitmap.Canvas" which would allow to use multiple canvas drawing tools (LineTo, Ellipse, etc) to draw any number of lines, circles, polygons, etc on a single layer. Assuming that would work, it would allow each polygon/node group to be redrawn or deleted individually.
Is there a special kind of layer that will allow that kind of drawing? The only one I have found that shows through is on the base image "Bitmap.Canvas" or "ieBitmap.Canvas". That won't help because you would still have to redraw all the polygons and nodes for a single change.
Thanks
HM Arnold |
xequte |
Posted - Dec 18 2024 : 20:05:13 Hi
It is not possible to have multiple vector objects on a single layer, unless you custom draw them yourself or use complex paths (but that doesn't support ellipses):
http://www.imageen.com/help/TIEPolylineLayer.EnableComplexPath.html
Basically, with ImageEn, each object should be its only layer (you can group them if necessary to make it easier to match particular objects when setting properties, etc).
There is an example of custom drawn layers at:
\Demos\LayerEditing\Layers_CustomDraw\LayersDraw.dpr
Nigel Xequte Software www.imageen.com
|
HMArnold |
Posted - Dec 16 2024 : 19:23:02 Thanks
I'll try that, but there are several things I'm hoping to do eventually.
Are there any demos that show how to put more than one visual object (line, ellipse, polygon) on a single layer?
If I could put one polygon and it's associated nodes (up to 20 ellipses) on a single layer, it would be very easy to work with them as a group - clear them, redraw them, change colors upon selection, etc.
Is there a way to use canvas drawing commands on any layer other then the base image?
Any demos showing how to define such a layer and draw on it?
Thanks again
HM Arnold |
xequte |
Posted - Dec 16 2024 : 16:58:56 Hi
Do you mean the styling of the layer grips? You can set that using:
https://www.imageen.com/help/TImageEnView.SetLayersGripStyle.html
Nigel Xequte Software www.imageen.com
|
HMArnold |
Posted - Dec 11 2024 : 20:27:33 I appreciate your response back when, but I needed to finish something and went back to TImageEnVect for that project.
Trying to upgrade again, now.
I can draw closed polygons in a ielkPolyline layer, but I would like to enhance the nodes (vertices) to be larger than what is available using the standard ImageEnView. (If there is a way to make them larger, to be seen on a large, high resolution monitor, please let me know)
The only way I can get a polygon with enhanced nodes to work is with one layer for the polygon, then one each for every node using separate iesEllipse layers.
I have up to 1000 polygons (birds in an image) to display) with an average of 12 nodes each.
It works, but that is a lot of layers to work with, each needing a distinct name to be able to edit/delete them later on.
You answer above hints at a way I could have a single layer for each bird that contains the lines of the polygon and the vertex circles on a single layer by using the layer Bitmap.Canvas for drawing.
What is the best way to generate a new layer with multiple visible line/ellipse objects?
Defining an ielkImage layer without another copy of the base image clears the screen to white, but using Bitmap.Canvas drawing commands on the same ielkImage as the polygon doesn't seem to show anything.
Are there any demo examples that show multiple lines/ellipses on the same layer?
Thanks in advance
HM Arnold |
xequte |
Posted - Sep 17 2024 : 00:54:19 Hi
Not sure what you mean by a triangle being three layers. A triangle only requires one TIEShapeLayer or TIEPolylineLayer. If you need multiple shapes on a single layer, you could create a TIEPolylineLayer with a complex path (SVG type path with MoveTo, LineTo, CurveTo, etc):
http://www.imageen.com/help/TIEPolylineLayer.EnableComplexPath.html
Alternatively, you could use a "virtual layer", i.e. just draw the layer as required. Take a look at:
\Demos\LayerEditing\Layers_CustomDraw\LayersDraw.dpr
Or painted as it is sized:
\Demos\LayerEditing\SVGVectorLayers\SVGLayers.dpr
You can easily output your shapes to the Layer.Bitmap.IECanvas using the TIECanvas methods like:
http://www.imageen.com/help/TIECanvas.AdvancedDrawShape.html
Nigel Xequte Software www.imageen.com
|
HMArnold |
Posted - Sep 16 2024 : 07:14:16 Thanks very much.
My use of two layers is because I haven't found anything about adding multiple objects to a single layer. Is there a way to do that?
If so, I can put everything on that layer and work with it all at once, even moving the entire layer with a MouseMove hopefully.
Is that possible?
If not, a triangle is always 3 layers with 3 names?
HM Arnold |
xequte |
Posted - Sep 15 2024 : 23:08:52 Hi
The result of LayersAdd() is an index, so you shouldn't pass that to LayersRemove() if the indexes of your layers may change.
You should identify your layers in some way, e.g. with a name:
if TrgtC1 <> '' then
begin
ImageEnView1.LayersRemove( ImageEnView1.LayersNameToIndex( TrgtC1 ));
TrgtC1 := '';
end;
if TrgtC2 <> '' then
begin
ImageEnView1.LayersRemove( ImageEnView1.LayersNameToIndex( TrgtC2 ));
TrgtC2 := '';
end;
Rect.Create(Point(Vrtx.X-10,Vrtx.y-10),Point(Vrtx.X+10,Vrtx.Y+10));
ImageEnView1.LayersAdd( iesEllipse, Rect, clRed, 3 );
TrgtC1 := 'TempLayer_' + IntToStr( Random( 10000 ));
ImageEnView1.CurrentLayer.Name := TrgtC1;
Rect.Create(Point(Vrtx.X-2,Vrtx.y-2),Point(Vrtx.X+2,Vrtx.Y+2));
ImageEnView1.LayersAdd(iesEllipse, Rect, clBlue, 1);
TrgtC2 := 'TempLayer_' + IntToStr( Random( 10000 ));
ImageEnView1.CurrentLayer.Name := TrgtC2;
Nigel Xequte Software www.imageen.com
|
|
|