I getpixel from my picturebox2 and save pixel data at array xx , yy and then i want to plot the chart from array xx and yy
I don't have error code but when run ,it's going to be
"An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll"
"Additional information: Enumeration already finished"
My englise is not good. I am sorry for that. but I hope you will understand me.
Help me please :)
Private Sub Runbotton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Runbotton.Click
Dim MH As Integer
Dim MW As Integer
MH = PictureBox2.Height
MW = PictureBox2.Width
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = MW
Dim xx(MW) As Integer
Dim yy(MH) As Integer
Dim co As Integer = 0
For co = 0 To MW
xx(co) = 0
Next
For co = 0 To MH
yy(co) = 0
Next
Dim img As Bitmap = New Bitmap(PictureBox2.Image)
Dim c As Color
Dim i As Integer
For i = 0 To MW
Dim j As Integer
For j = 0 To MH
c = img.GetPixel(i, j)
Dim r As Integer = 0
r = Convert.ToInt32(c.R)
Dim g As Integer = 0
g = Convert.ToInt32(c.G)
Dim b As Integer = 0
b = Convert.ToInt32(c.B)
Dim ans As Integer = r + g + b
If (ans > 50) Then
yy(j) = yy(j) + 1
End If
xx(i) = xx(i) + i
Next
ProgressBar1.Value = i
Next
MessageBox.Show("Successfully")
Dim x() As Integer = {1, 2, 3, 4, 5}
Chart1.Series(0).Points.DataBindXY(xx, yy)
End Sub
No comments:
Post a Comment