您收到以下信息:
width = 1920
height = 1080
area = 2073600
ratio = width / height =~ 1.77778
现在,假设您想在区域缩小到当前大小的 25% 时计算新的宽度和高度。那么我们知道以下几点:
area = 0.25 * 2073600 = 518400
height = h (Variable, because it is unknown at the moment)
width = w (Variable, because it is unknown at the moment)
ratio = 1.77778 (Ratio should stay the same or image becomes warped/stretched)
所以你有了
w / h = 1.77778 (Your unknown new width divided by unknown height equals ratio)
w * h = 518400 (Your unknown width times unknown height equals area)
现在你可以相对容易地用数学方法解决它。它只是具有两个变量的两个方程。
w = 1.77778 * h (from first equation)
(1.77778 * h) * h) = 518400 (by plugging above into second equation)
h =~ 540
w =~ 960
那有意义吗?