Reputation: 395
I'm working on app that needs user interaction to locate some points in image. because the image apear smaller in the app , I need to transform the points locations to a larger image. so I need the math to do so. to transform points to a larger image.
Upvotes: 0
Views: 167
Reputation: 18875
smaller image dimensions: Ws x Hs
bigger image dimensions: Wb x Hb
user taps smaller image at (Xs,Ys)
appropriate point on the bigger image (Xb,Yb)
would be:
Xb = Xs * (Wb/Ws);
Yb = Ys * (Hb/Hs);
And for the other way around:
Xs = Xb / (Wb/Ws);
Ys = Yb / (Hb/Hs);
Upvotes: 2