How to calculate the same position on different bitmaps?

I have 2 photos, one is size 300x300

and the other is 1200x1200

. I have drawn one text at a position A = (50, 40)

in the image 300x300

.

How can I calculate the same A position in the image 1200x1200

?

UPDATE 2:

IF size is not round (e.g. 523 x 412 ...) - x, y after multiplication will deviate

+3


source to share


2 answers


you can go with relative position calculation as follows.

AAx = (50/300)*1200; 

AAy = (50/300)*1200;

      



so your new position will be AA = (200,200)

+2


source


The scaling factor for x and y is 1200/300 = 4

.
Then just multiply x and y by 4

(your scaling factor).

int scaleFactor = 1200 / 300;
int newX = oldX * scaleFactor;
int newY = oldY * scaleFactor;

      



So, given that oldX = 50 and oldY = 40, the expectex values ​​for newX and newY are 200 and 160, respectively.

+2


source







All Articles