Let $A$ and $B$ be two rectangles of the plane located at $(X_A, Y_A)$ and $(X_B, Y_B)$ respectively.
Let $w_A$, $h_A$, $w_B$, $h_B$ be the widths and heights of these rectangles.

To transform a point $(x, y)$ from $A$ to $B$ you first have to express the point coordinates in rectangle $A$ space.
$$x_A = x - X_A$$
$$y_A = Y_A - y$$
Then, compute the ratio of the point position (in rectangle $A$ space) by the rectangle side.
$$r_x = \frac{x_A}{w_A}$$
$$r_y = \frac{y_A}{h_A}$$
Then, scale it by the side of the destination rectangle $B$ to get the position relative to $(x_B, y_B)$ :
$$x'_B = w_B \times r_x$$
$$y'_B = h_B \times r_y$$
Finally, translate it to the position of the destination rectangle $(x_B, y_B)$ :
$$x' = X_B + x'_B$$
$$y' = Y_B - y'_B$$
The final coordinates of the transformed point are :
$$x' = X_B + w_B\frac{x - X_A}{w_A}$$
$$y' = Y_B - h_B\frac{Y_A - y}{h_A}$$
Hope it helped...