此代码总是通过算术溢出异常。怎么了 ?简单的一些函数返回“溢出异常”
Function ChannelSum(ByVal C As System.Drawing.Color) As Integer
Dim temp As Integer : temp = (C.R + C.G + C.B)
Return temp
End Function
...
Dim x, y, R, G, B, a As Integer : Dim tmp As Color
bmp = New Bitmap(picBox.Tag.ToString)
xMax = bmp.Width - 1 : yMax = bmp.Height - 1
For x = 0 To xMax Step 1
For y = 0 To yMax Step 1
tmp = bmp.GetPixel(x, y) : a = ChannelSum(tmp)
Next y
Next x
第一次遇到循环会中断!
在哪一行循环中断? – 2012-08-02 14:50:40
第一次遇到循环会中断!当X和Y为0时,但调试器显示X,Y已通过xMax,yMax。我已经复制了所有的代码。 – Sourav 2012-08-02 14:52:10
我敢打赌,你的C.R,C.G,c.B没有像你期望的那样返回一个整数。也许你会需要在每一个这样做。 – Yosem 2012-08-02 14:54:01