Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, June 27, 2006 2:46:57 PM(UTC)


Groups: Registered
Posts: 51


when I add programmaticaly an AnnStampObject (but probably also other annotation) at specific coordinates using the following code, I have a problem:

Dim pic As New AnnPicture(System.Drawing.Image.FromFile(filename))

pic.TransparentMode = AnnPictureTransparentMode.UseColor

pic.TransparentColor = Color.Black

obj = New AnnImageObject

obj.Picture = pic

obj.Visible = True

obj.Bounds = New AnnRectangle(5 * i, 5 * i, pic.Image.Width / 4, pic.Image.Height / 4, AnnUnit.Pixel)


obj.Name = filename


If  I move the object and then in the MouseMove event of the imageviewer  using the HitTest method  I select the object and I inspect with the debugger the value of the bounds or the BoundingRectangle properties, the value of the X Y coordinates are always the same of when I add the object in the container also if I continue to move the annotation. This problem cause a malfunction of the IntersectWith method to see if two or more annotation are one over another. Is this a bug ?



Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, June 29, 2006 3:06:06 AM(UTC)


Groups: Manager, Tech Support
Posts: 367

For most annotation objects, when you transform an object either by manipulating the Transform property manually or when you use the UI (which does the same thing), the object points do not change, instead, only the Transform matrix is updated.

The BoundingRectangle property will return the untransformed coordinates always, to transform these you need to multiply the rectangle points by the current object Transform matrix.  Here you can use the Leadtools.Annotations.AnnTransformer helper class to achieve that.  This mechanism is used to support rotation and sharing of objects such as rectangles that cannot be obtained by simply transforming the points.

Note, few objects such as the AnnEncryptObject and AnnRedactionObject always change the points themselves.  This is done since these objects do not support shearing/rotation.  For more information, refer to the AnnObject.TransformObjectMode property.

Follow is a function that takes into consideration the object’s Transform:

' helper function to calculate the transformed object bounding rectangle
Private Function GetObjectRealBoundingRectangle(ByVal obj As AnnObject) As AnnRectangle
   ' get the un-transformed bounding rectangle
   Dim rc As AnnRectangle = obj.BoundingRectangle

   ' apply the object transformation to this rectangle
   Dim t As New AnnTransformer(obj.Container.UnitConverter, obj.Transform)
   rc = t.RectangleToPhysical(rc)
   Return rc
End Function

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
#3 Posted : Wednesday, March 13, 2013 5:21:37 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

For LEADTOOLS v17.5 and earlier, the above information is correct. It is related to Leadtools.Annotations, which is deprecated in LEADTOOLS v18.

For v18 customers, the following online help topic contains a sample code that converts from Annotations units to Image units:

If you are using Annotations Automations, you just need to change the code as follows:
// Get the rectangle in annotations units
LeadRectD rc = _automation.CurrentEditObject.Bounds;
MessageBox.Show("Annotations units: " + rc.X + "," + rc.Y + "," + rc.Width + "," + rc.Height);
// Convert it to image coordinates
rc = _automation.Container.Mapper.RectFromContainerCoordinates(rc, AnnFixedStateOperations.None);
MessageBox.Show("Image units (pixels): " + rc.X + "," + rc.Y + "," + rc.Width + "," + rc.Height);

// If this container is used with an image, you can use the pixels values above to find the exact value on the image

// Convert it to back to annotations units
rc = _automation.Container.Mapper.RectToContainerCoordinates(rc);
MessageBox.Show("Original units: " + rc.X + "," + rc.Y + "," + rc.Width + "," + rc.Height);

I am attaching a small C# WinForms 2010 project using the new LEADTOOLS 18 Annotations classes (Leadtools.Annotations.Core) that shows how you can draw an object and then get it's coordinates in different units (including Image coordinates).

Maen Badwan
LEADTOOLS Technical Support
File Attachment(s):
CsNewAnn_v18.zip (20kb) downloaded 40 time(s).
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.074 seconds.