我有一个 PictureBox 控件。当我单击控件上的图像时,事件处理程序被触发。
这是事件处理程序:
Private Sub pbImageHolder_Click(ByVal sender As Object, _
ByVal e As EventArgs) Handles pbImageHolder.Click
Dim clickPoint As Point = MousePosition
Dim img As Bitmap = New Bitmap(pbImageHolder.Image)
pixelColor = img.GetPixel(clickPoint.X, clickPoint.Y)
For i As Integer = 0 To img.Width
For j As Integer = 0 To img.Height
Next
Next
End Sub
问题是我进入了这一行:
pixelColor = img.GetPixel(clickPoint.X, clickPoint.Y)
这是一个例外:
System.ArgumentOutOfRangeException 未处理
消息=参数必须为正且 < 宽度。参数名称:x
ParamName=x
Source=System.Drawing
知道如何修复代码吗?