下面是一段VB的识别验证码代码,有谁能将其翻译为delphi的,谢谢。
Function getCode() As String
Dim strTem As String
BmpClear
strTem = BmpToCode(2, 1) & BmpToCode(12, 1) & BmpToCode(22, 1) & BmpToCode(32, 1)
getCode = strTem
End Function
'验证码识别
'** :
Function BmpClear()
Dim i As Long
Dim i1 As Long
For i = 0 To Picture1.ScaleWidth
For i1 = 0 To Picture1.ScaleHeight
If Picture1.Point(i, i1) = "&HC0C0C0" Then
Picture1.Line (i, i1)-(i + 1, i1 + 1), vbWhite ', BF
ElseIf Picture1.Point(i, i1) <> "&HFFFFFF" Then
Picture1.Line (i, i1)-(i + 1, i1 + 1), vbBlack ', BF
End If
Next
Next
End Function
Function BmpToCode(X As Long, Y As Long, Optional ByVal ErrCount As Long = 5) As Long
Dim x1 As Long
Dim y1 As Long
Dim i As Long
Dim Code As Long
Dim tErrCount As Long
Dim tLng As Long
Code = -1
For i = 0 To 9
tErrCount = 0
For x1 = 0 To 5
For y1 = 0 To 8
If Picture1.Point(X + x1, Y + y1) <> _
ModePic.Point(i * 6 + x1, y1) Then tErrCount = tErrCount + 1
Next
Next
A1:
If tErrCount <= tLng Then
Code = i
GoTo Out
Else
If tLng < ErrCount Then
tLng = tLng + 1
Debug.Print "tLng=" & CStr(tLng) & " | tErrCount=" & CStr(tErrCount)
GoTo A1
End If
End If
Next
Out:
BmpToCode = Code
End Function