Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

Cannot Rotate an Annotation Layer

Last post 17 Mar 2008, 8:57 AM by DMann. 11 replies.
Sort Posts: Previous Next
  •  26 Dec 2007, 6:19 PM 12915

    Cannot Rotate an Annotation Layer

    The following code was working with prior releases but no longer works with 5.0d.

    for (int i = 0; i < this.m_annotationController.Layers.Count; i++)

    {

    locked = this.m_annotationController.Layers[i].Data.Security.Locked;

    if (locked)

    this.m_annotationController.Layers[i].Data.Security.Unlock();

    this.m_annotationController.Layers[i].Data.Rotate(degrees);

    if (locked)

    this.m_annotationController.Layers[i].Data.Security.Lock();

    }

    I noticed that the CanRotate property is false for the layer and I don't know how to set it true. 

    Any help would be appreciated.

    Thanks,

    Bill

  •  30 Dec 2007, 9:54 PM 12920 in reply to 12915

    Re: Cannot Rotate an Annotation Layer

    I don't believe that ever should have worked.  You can only rotate a layer by using the AnnotationController's RotateDocument method, passing in the layer index or the LayerAnnotation itself.

    Glenn Chittenden Jr.
    Atalasoft Development Team
  •  07 Jan 2008, 10:15 AM 12934 in reply to 12920

    Re: Cannot Rotate an Annotation Layer

    Thanks for the response Glenn.  I have attempted to use the RotateDocument method and the results are not what I expected.  I am attempting to rotate the layer as the document rotates.  When I use the RotateDocument(DocumentRotation.Rotate90, layerIndex), the annotations move but never rotate.  Their movement doesn't relate to the correct position on the document so I don't know what is wrong.  Are there any samples available that I can review?

  •  08 Jan 2008, 3:03 PM 12940 in reply to 12934

    Re: Cannot Rotate an Annotation Layer

    If you are trying to rotate the annotations with the image, using the RotateDocument method on the viewer will do this automatically.

    Run our AnnotationDemo, load an image and add a few annotations.  The click the File -> RotateDocument menu item to rotate it.  In my tests, the annotations rotate correctly.

    I should note that highlighter style annotations, with the Translucent property set to true, do not rotate.


    Glenn Chittenden Jr.
    Atalasoft Development Team
  •  09 Jan 2008, 11:24 AM 12943 in reply to 12940

    Re: Cannot Rotate an Annotation Layer

    Thanks again Glen but we are not using the AnnotationViewer class.  We use the AnnotationController and implement the IAnnotate interface.  There are no examples of this that I can find.  However, what I have discovered that if I use the code to return the DocumentBounds for IAnnotate as follows:

    public RectangleF DocumentBounds

    {

    get

    {

    if (this.m_contentDrawer.RotateDegress != 0)

    return new RectangleF(0f, 0f, this.m_renderControl.Height, this.m_renderControl.Width);

    else

    return new RectangleF(0f, 0f, this.m_renderControl.Width, this.m_renderControl.Height);

    }

    }

    it will work the first time I rotate from 0 to 90 to 180 to 270.  When I rotate from 270 to 0 the annotations move to the right as if the Height is correct but the width is not.  This relationship will remain the same when I rotate to 90 to 180 to 270 but when I go from 270 to 0 the annotation agains move right like some kind of delta is maintained from the previous DocumentBounds.

    In my opinion, the DocumentBounds should simply be set as:

    if (this.m_contentDrawer.RotateDegress == 0 || this.m_contentDrawer.RotateDegress == 180)

    return new RectangleF(0f, 0f, this.m_renderControl.Height, this.m_renderControl.Width);

    else

    return new RectangleF(0f, 0f, this.m_renderControl.Width, this.m_renderControl.Height);

    These settings will only work for 0 and 90.  For 180 and 270 the width is off, the height is handled correctly and it does correct itself when I rotate from 270 to 0.

    I don't know what settings to use or what I am missing.  The AnnotationViewer class is not an option for us.  The documentation to use the IAnnotate interface is non-existent.  We had this all working before 5.0 but now it doesn't.  Please direct me to where I can get information on the use of IAnnotate and the AnnotationController or I will need to open a support case to solve this issue.

  •  30 Jan 2008, 12:32 PM 13055 in reply to 12943

    Re: Cannot Rotate an Annotation Layer

    Attachment: images.zip

    Hi Glenn and Bill

    I thought it important that I should add my bit of experience with rotation to this document. We have been trying to rotate a page of annotations by rotating the document, and then rotating the layer on which the documents are placed. However because we are using our own methods for saving, we are having difficulty getting the annotations to redisplay correctly once the document is closed and re-opened.

    Although we are currently having problems with the storage and redisplay of our annotations (using our own bespoke methods), I can confirm that I have tried document rotation with the Annotation Demo, and it doesn't perform the task correctly. We are using the AnnotationViewer component, and using Version 5.0f of the Atalasoft components.

    To replicate this please take a document (we have been using a simple A4 TIF), and add an annotation tight in the top left corner so that it's near but not quite touching the edge of the top and left of the image (so you can detect whether it has moved or not).

    Now select the rotate document option from the File menu, and look at the results afterwards. In my example screenshots (please see attached), after the rotation there is now a large gap above the highlight square. If you look at the two intersecting lines, these don't appear to have rotated at all as the longer of the two lines is still intersecting horizontally through the shorter, vertical one.

    Annotation is extremely important to the application we are writing, so I have launched this problem as a job with Atalasoft support. I have also attached the two screenshots (before and after rotation), and also the source image we used which is a 300x300 dpi TIF which has the extension .001. These are all in the attached zip file.

    Do you have any suggestions or workarounds for this problem?

  •  30 Jan 2008, 3:21 PM 13059 in reply to 13055

    Re: Cannot Rotate an Annotation Layer

    You should be aware that translucent annotations do not rotate.  RotateDocument will change the location of a translucent annotation but will not rotate it.  You will probably also notice that there is no rotation grip when the translucent property is set to true.  This is a limitation of the translucent functionality.


    Glenn Chittenden Jr.
    Atalasoft Development Team
  •  01 Feb 2008, 4:20 AM 13079 in reply to 13059

    Re: Cannot Rotate an Annotation Layer

    Attachment: images.zip
    Glenn:

    You should be aware that translucent annotations do not rotate.  RotateDocument will change the location of a translucent annotation but will not rotate it.  You will probably also notice that there is no rotation grip when the translucent property is set to true.  This is a limitation of the translucent functionality.

    My apologies; I used the wrong type of annotation. I should have used a rectangle with an alpha-channelled yellow background to implement a fairly simple highlight annotation that can be rotated. This fixes the problems of some annotations not rotating at all.

    However; by using your sample application 'Atalasoft DotAnnotate Demo' that comes with version 5.0f of your product, I can still replicate the problem where the annotations move from their origins on documents that do not have square DPI resolutions (e.g. 204x196 dpi - fax images). To replicate the issue I did the following.

    1. From the attached ZIP file, extract 'Atalasoft Test Image.TIF' (204x196 dpi test image).

    2. Load this file into the Atalasoft DotAnnotate demo application.

    3. Draw some rectangle annotations on the document - I recommend one of these tight in the top-left to make life easy when spotting changes with regards to positioning.

    4. Take note of the annotation positions in relation to elements of the image.

    5. Go to the 'File' menu and select 'Rotate Document'.

    6. Now review the positioning of the annotations. You'll find that they have shifted upwards vertically!

    We noticed this in our own application and spent a considerable amount of time ensuring that it wasn't our application that was at fault. It was only when we tried it in the demo applications that we realised that we could replicate the issue on the same images, and obviously this doesn't use our code but uses the same components. If the image uses a square resolution (such as 300x300 dpi for example), the annotation shift doesn't occur.

    Can you try replicating this and let me know how you get on please? As I said before I have also reported this issue to Atalasoft support, who I am just going to update.

    Cheers.

    Andy.

  •  01 Feb 2008, 3:45 PM 13085 in reply to 13079

    Re: Cannot Rotate an Annotation Layer

    This is a known limitation.  If you need to rotate an image with mixed X and Y resolution values you will have to correct the image before rotating.  The main reason is that DotAnnotate doesn't know an image even exists; it's just drawing onto a Graphics object which has the screen resolution. 

    Even if we have the image resolution there's the issue of knowing if the image resolution is going to be changed because of the rotation.  DotImage does not change the resolution values when you rotate an image, but you should swap the values if doing a 90 or 270 degree rotation to keep the image rendering correctly.


    Glenn Chittenden Jr.
    Atalasoft Development Team
  •  06 Feb 2008, 5:59 AM 13125 in reply to 13085

    Re: Cannot Rotate an Annotation Layer

    Glenn:

    This is a known limitation.  If you need to rotate an image with mixed X and Y resolution values you will have to correct the image before rotating.  The main reason is that DotAnnotate doesn't know an image even exists; it's just drawing onto a Graphics object which has the screen resolution. 

    Even if we have the image resolution there's the issue of knowing if the image resolution is going to be changed because of the rotation.  DotImage does not change the resolution values when you rotate an image, but you should swap the values if doing a 90 or 270 degree rotation to keep the image rendering correctly.

    Hi Glenn

    This is what I suspected, given that it was only affecting images with uneven X,Y resolutions.

    We have now implemented some of the resolution correction code, and I'm happy to say that we are successfully keeping annotations in place when a document is rotated, even with uneven resolution values. However we still have one little issue regarding this which I'm hoping you will be able to help us with.

    As a sample we took a fax document (uneven resolution), which contained a large table. This allowed us to draw annotations in specific locations and observe any 'wandering' after the document was rotated. However when we ran the code to make the x,y resolutions equal, the document lost it's anti-aliased appearance and became very fragmented in appearance. Some of the lines which made up the table appeared broken with gaps, and the quality of the text was substantially reduced. At certain zoom levels the document became completely unreadable post-rotation, although I'm pleased to say that the annotations remained firmly in their original positions in relation to the table cells. The only way to regain the anti-aliasing was to reload the document into the viewer, which in turn resulted in a mismatch between the x,y resolutions again.

    Is there an easy way to reinstate the anti-aliased appearance of the document after the resolution correction (and without reloading), so that the images remain fairly readable at all zoom levels in the viewer?

    Thanks in advance.

  •  08 Feb 2008, 8:19 AM 13158 in reply to 13125

    Re: Cannot Rotate an Annotation Layer

    Since this is a 1-bit document, I'd have to assume the anti-aliased look was created because we performed a scale-to-gray on it.  If you have a Document Imaging license, try using ResampleDocumentCommand when you resize to perform a scale-to-gray resample.


    Glenn Chittenden Jr.
    Atalasoft Development Team
  •  17 Mar 2008, 8:57 AM 13493 in reply to 13158

    Re: Cannot Rotate an Annotation Layer

    Sort of related question here:
     

    Does the WebForms version of the AnnotationController support RotateDocument?  Or is there a different approach that should be used in that instance?

     Thanks!

     

    --David
     

View as RSS news feed in XML