Rotation in Android

We are looking to develop an application in android for images tagging.

However when we tag an image in potrait mode and then view it in landscape mode, the locations of those tags in the image changes

This is becuase to maintain the aspect ratio black padding it inserted ( in black ) by android.

How can we know how much padding has been done, so that we include that in our calculation to show the tags as well.

Please help

jbajajAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jrd326Commented:
I cannot guarantee that this will work in all cases, but you could probably use some simple math if the screen resolution of the device is known.  

For example, if you have a device with 800x400 screen resolution and the picture takes the full 800x400 screen while in landscape mode, when the phone changes into portrait mode, the picture would change to 400x200.  This would give you 300x400 pixels of black padding at the top and bottom of the screen.  This formula would work in any case.

Screen height (pixels) = SH  (800 in the example)
Screen width (pixels) = SW  (400 in the example)
Landscape mode Picture Height (pixels) = PH (400 in example)
Landscape mode Picture Width (pixels) = PW (800 in the example)


PW/PH = X/SW  where X = the height of the picture in portrait mode

You can get the value of X through cross multiplication.

At this point, since you have the height of the picture in portrait mode, considering the black padding is equal above and below the picture, you can use the following equation to get the height of the black padding above and below the picture:

(SH - X)/2 = Height of Black Padding


I hope this helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Android

From novice to tech pro — start learning today.