Rotate Annotation Image

You must Login before you can answer or comment on any questions.

I need to rotate the image on an annotation. I have tried doing a 2Dmatrix on an ImageView and then doing .toImage() of the imageview for the image property of the annotation, but it doesn't rotate the image, it just shows the image in it's original position.

Anyone have any ideas how this could be done?

Thanks

— asked 10 months ago by Seth Davis
0 Comments

3 Answers

Accepted Answer

did you try animating the view-a that is in container view-b and then doing a toImage() on view-b?

I apologize in advance, I haven't tried this, just thinking out loud

— answered 10 months ago by Aaron Saunders
answer permalink
8 Comments
  • Yeah, I tried animating it before the toImage(). I also tried setting the transform property of the image in the declaration as well. Neither worked. I believe Malcolm's answer may be the reason it's not working.

    — commented 10 months ago by Seth Davis

  • And yes, I tried loading an animated image into a different view and doing a toImage() on the view. That didn't work either.

    — commented 10 months ago by Seth Davis

  • I think you have dont something wrong... try this code, the rotation DOES persist

    // open a single window
    var win = Ti.UI.createWindow({
        backgroundColor : 'white'
    });
    var view = Ti.UI.createView({
        width : 150,
        height : 150,
        backgroundImage : "KS_nav_views.png"
    });
     
    // setup rotate transform matrix
    var t3 = Ti.UI.create2DMatrix();
    t3 = t3.rotate(-180);
     
    var a = Ti.UI.createAnimation({
        transform : t3,
    });
    view.animate(a);
     
    win.add(view);
    win.open();
     
    win.addEventListener("click", function() {
        var win2 = Ti.UI.createWindow({
            backgroundColor : 'white'
        });
        var view2 = Ti.UI.createView({
            width : 150,
            height : 150,
            backgroundImage : win.toImage()
        });
        win2.add(view2);
        win2.open();
    });

    — commented 10 months ago by Aaron Saunders

  • Show 5 more comments

Annotation is not a view and tahts why it is impossible to cal methods of a view. May be you can change the URL of image.

Hi Seth

When you perform an animation on a view it does not affect the original image - only the way the view actually displays, think of it more as rotating the rectangular region the imageView is displayed within.

This is why it does not work with a toImage() directly or even if you try saving the rotated image to the file system - then referencing it.

You will have to use a third-party module/tool to rotate the image at image level, or supply a rotated image to start with - if you are able of course.

Your Answer

Think you can help? Login to answer this question!