1

我有一个名为 fWidth 的全局变量,目前为 300。

我正在设置pictureBox.width = fWidth,但后来我想做类似pictureBox.height = calcImgHeight(originalHeight,originalWidth)

这就是问题所在,因为我的数学很糟糕:D

Private Function calcImgHeight(oHeight, oWidth)
    Dim nHeight, ratio As Integer
    ratio = oWidth / fWidth
    nHeight = oHeight / ratio

    Return nHeight
End Function

正确的代码应该是什么?

4

1 回答 1

1

我敢打赌我的数学比你差,但幸运的是我擅长谷歌搜索。

http://andrew.hedges.name/experiments/aspect_ratio/

原始高度 / 原始宽度 x 新宽度 = 新高度

于 2012-11-30T16:19:59.120 回答