Public Class Form1
Dim x As Integer
Dim y As Integer
Dim pt As Point
Dim bmp As Bitmap
Dim count As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim instancecaller As New Threading.Thread(AddressOf countpixel)
instancecaller.Start()
End Sub
Public Sub countpixel()
bmp = Bitmap.FromFile("C:\Documents and Settings\Owner\Desktop\spots2.png")
For x = 0 To bmp.Width - 1
pt.X = x
For y = 0 To bmp.Height - 1
pt.Y = y
Label2.Text = pt.X & "," & pt.Y
Dim mycolor As Color = DirectCast(bmp, Bitmap).GetPixel(pt.X, pt.Y)
ListBox1.Items.Add(mycolor.R & "," & mycolor.G & "," & mycolor.B)
If mycolor.R = 255 And mycolor.G = 255 And mycolor.B = 255 Then
count += 1
End If
Next
Next
Label1.Text = count
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Control.CheckForIllegalCrossThreadCalls = False
End Sub
End Class