same thing in vb.net
Code:
Public Function docaptcha(ByVal myBitmap As Bitmap) As Point
Dim lowestbrightness As Single = 1000000
Dim Height As Int32 = myBitmap.Width
Dim Width As Int32 = myBitmap.Height
Dim lowestbrightness_x As Integer
Dim lowestbrightness_y As Integer
For y = 0 To Width - 1 Step 4
For x = 1 To Height - 1 Step 4
If x >= Height Then Exit For 'Debug shouldnt hit this
If y >= Width Then Exit For 'Debug shouldnt hit this
'myBitmap.SetPixel(x, y, Color.ForestGreen) 'Draw scan points
Dim pixelbright As Single = myBitmap.GetPixel(x, y).GetBrightness
If pixelbright < lowestbrightness Then
lowestbrightness = pixelbright
lowestbrightness_x = x
lowestbrightness_y = y
End If
Next x
Next y
Return New Point(lowestbrightness_x, lowestbrightness_y)
End Function
implementation e.g;
Dim newimage As Bitmap = thewrapper.getimage(captchaurl, thewrapper.LastPage)
Dim ocrpoint As New Point
ocrpoint = abhandler.docaptcha(newimage)
strhtml = thewrapper.Request("POST", "http://www.neopets.com/haggle.phtml?current_offer=" & tempprice & "&x=" & ocrpoint.X & "&y=" & ocrpoint.Y, currentitemurl)
If strhtml.Contains("I accept your") = True Then
'Item bought
buylog.Add("Bought item - " & currentitemname)
End If