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
 Issues copying vector objects to bitmap (suggested enhancement)

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
DavidMartel Posted - Feb 18 2022 : 11:21:08
I am looking to either get a little advice on how to better work around an issue, or else to suggest an enhancement that would make this easier.

I am using a number of vector objects in enhanced for to put measurements on images. So in the screen shot below I have calibrated the image and want to see the size of the square feature (quite small!).




I make use of the OnAfterDrawObject() call back to put the dimension label. It all works rather nicely. As long as the user keeps things as vector objects all is fine. However we have to give them the option to use simple bitmap images and so we use the useful ImageEn feature CopyObjectsToBack(). The problem we have is that the extra text falls outside of the normal bounds of the rectangle and the label gets cut off (or partially cut off).

This is clearly not unknow even to the Xecute programmers as my current bodge/fix is to manually edit in ievect.pas just below a comment that shows you have a similar problem with truncating Arrows

The comment is

// Temporary fix for truncation of arrows


So for now I am simply turning off the optimization of using a smaller ROI for (setting copyingBack:= false for all cases).

This is not a very nice fix, and obviously I will have to remember to re-apply it every time I get a new version of your excellent components...

So. Is there a better way? (I can't see anything obvious)


A suggestion would be some form of event handler a bit like the OnAfterDraw, but for the private method GetObjectBoundingBox()


Thanks
6   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Feb 21 2022 : 20:25:23
Hi

Do you still need that user data in the objects after the transfer?

If not, can you just iterate through the objects after the CopyAllObjectsTo:

Lyr.UserData        := Obj^.UserData;
Lyr.UserDataLen     := Obj^.UserDataLength;
Obj^.UserData       := nil;
Obj^.UserDataLength := 0;


If you email me you can use the new "move" parameter, which transfers the object data then removes the object.


var
  i, hobj: Integer;
begin
  // Move the content of a TImageEnVect (with Objects) to a TImageEnView (as layers)

  // Clear existing content
  ImageEnView1.ClearAll();

  // Copy background image
  ImageEnView1.IEBitmap.Assign( ImageEnVect1.IEBitmap );

  // Add objects as layers
  for i := ImageEnVect1.ObjectsCount - 1 downto 0 do
  begin
    hobj := ImageEnVect1.GetObjFromIndex(i);
    ImageEnVect1.CopyObjectTo( hobj, ImageEnView1, True );  // User data also transferred
  end;
end;


Nigel
Xequte Software
www.imageen.com
DavidMartel Posted - Feb 21 2022 : 05:54:40
One question.

We make use of UserData to extend some of the vector objects (seems this would have been one of the reasons to have userdata available). Userdata is also available in the new TIELayer based objects.

When trying to use a TIEImageEnView instead of TIEImageEnVect I am using the example code of creating a temporary TIEImageEnVect and then doing

// Add objects as layers
ImageEnVect1.CopyAllObjectsTo( ImageEnView1 );


Problem is that the user data does not transfer. I looked in the code and it is specifically disabled.


      // Do not copy user data (UserData may contain objects or memory buffer that will never get freed)
      // Lyr.UserData       := Obj^.UserData;
      // Lyr.UserDataLen    := Obj^.UserDataLen;
      Lyr.UserDataLen       := 0;


I understand there could be potential pitfalls with trying to enable this, particularly if the userdata is a pointer to an object. In our case we folowed the examples and are using record based data so could do this quite safely.

I am just after a idea on whether there is a clean/expected solution I have missed...

or do I need to follow up the call to CopyAllObjectsTo(), with a specific iteration of all vector objects and copying any userdata found? (I think I can use userdatalen() and UserData()^)
DavidMartel Posted - Feb 20 2022 : 04:48:12
Thanks for the link to the information. Perfect. I will read up on that later

Thank you
xequte Posted - Feb 19 2022 : 20:38:50
Hi Dave

Moving to the layer model allowed us to resolve many of the design and other limitations of the older object functionality. However it may be difficult to transition if you have a lot of code invested in TImageEnVect.

Transition information is detailed at:

https://www.imageen.com/help/TImageEnVect_vs_TIELayers.html

Nigel
Xequte Software
www.imageen.com
DavidMartel Posted - Feb 19 2022 : 03:54:21
Nigel,

Thanks for the reply.

Turning off optimized drawing with a property (and not having to make custom code changes) would definitely be a better option, though of course it is always better to have optimized on if possible for ultimate performance... who doesn't like speed?

I guess I am not sure at this point what the newer layer functionality allows, and what changes I would need to make. Could you point me at any link to documentation or blog posts etc that would help me to understand?

Dave
xequte Posted - Feb 18 2022 : 22:25:00
Hi

I assume your project is too far along to transition to the new layer functionality?

In the next update you can disable ROI drawing by setting:

ImageEnView1.OptimizedDrawing := False;


Nigel
Xequte Software
www.imageen.com