Image Scale Question

Soldato
Joined
7 Apr 2004
Posts
4,212
Hey,

If I have an image, say 400x400 and a point on at (142,138) and that image is now scaled to a new width/height say 200x200 or bigger say 800x800, how do you translate the point (142,138) so it is at the same position in the new scaled image as the old one?

So given a point (x,y) on a image size (width x height) how do I translate the point so it's the same position on a resized image (widthNew x heightNew).

I've tried, the following but it doesn't work correctly, not sure how far off I am.

x = xPos * (1 / (oldWidth / newWidth));
y = yPos * (1 / (oldHeight / newHeight));

Thanks, probably really obvious GCSE level maths :p
 
xNewPos = xOldPos * (newWidth / oldWidth)
yNewPos = yOldPos * (newHeight / oldHeight)

So from 400x400 to 800x800, (142, 138) becomes (284, 276)

Not sure why yours won't work though, it's the correct formula :o
 
Back
Top Bottom