vb.net多个pictureBoxes,宽度相同,保持宽高比

时间:2012-11-30 16:15:24

标签: vb.net math picturebox aspect-ratio

我有一个名为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

正确的代码应该是什么?

1 个答案:

答案 0 :(得分:1)

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

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

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

相关问题