[英]vb.net multiple pictureBoxes, same width, maintain 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
正確的代碼應該是什么?
我敢打賭,我的數學成績會比你差,但是幸運的是我擅長谷歌搜索。
http://andrew.hedges.name/experiments/aspect_ratio/
原始高度/原始寬度x新寬度=新高度
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.