因此 resizeWidth 和 resizeHeight 是以下代码中的 numericUpDown 控件。此外, tempBitmapW 和 tempBitmapH 都是浮点数。
float rW = (float)resizeWidth.Value;
float rH = (float)resizeHeight.Value;
rH = (float)Math.Truncate(tempBitmapH * ((float)rW / tempBitmapW));
int rsW = (int)rW;
int rsH = (int)rH;
resizeWidth.Value = rsW;
resizeHeight.Value = rsH;
现在,当我调试它时,rsW 和 rsH 以及 rW 和 rH 不读为 0,它们都没有。但由于某种原因,numericUpDown 控件会抛出错误,因为值 0 超出了最小值/最大值范围(最小值设置为 1),所以基本上它会将其读取为 0。
我做错了什么?