asp汉字中文图片验证码的实现代码(25)
Next
Next
ii = 0
For i=0 To yOffSet
If pcd_getDot(ary(i),y1+i,str,UnitWidth) = "0" Then ii = ii + 1
Next
End If
'如未超过有效点上限则跳出循环,执行干扰
If ii <= DotsLimit Then Exit For
Next
If direction = "x" Then
'随机确定在纵轴方向上或下进行移动
If int(Rnd*10) > 4 Then
'变量连线上的点
For i=0 To xOffSet
'遍历移动
For ii=ary(i) To 1 Step -1
Call pcd_setDot(x1+i,ii,str,pcd_getDot(x1+i,ii-1,str,UnitWidth),UnitWidth)
Next
'添补空白
Call pcd_setDot(x1+i,0,str,"1",UnitWidth)
Next
Else
For i=0 To xOffSet
For ii=ary(i) To UnitHeight-2
Call pcd_setDot(x1+i,ii,str,pcd_getDot(x1+i,ii+1,str,UnitWidth),UnitWidth)
Next
Call pcd_setDot(x1+i,UnitHeight-1,str,"1",UnitWidth)
Next
End If
Else
If int(Rnd*10) > 4 Then
For i=0 To yOffSet
For ii=ary(i) To 1 Step -1
Call pcd_setDot(ii,y1+i,str,pcd_getDot(ii-1,y1+i,str,UnitWidth),UnitWidth)
Next
Call pcd_setDot(0,y1+i,str,"1",UnitWidth)
Next
Else
For i=0 To yOffSet
For ii=ary(i) To UnitWidth-2
Call pcd_setDot(ii,y1+i,str,pcd_getDot(ii+1,y1+i,str,UnitWidth),UnitWidth)
Next
Call pcd_setDot(UnitWidth-1,y1+i,str,"1",UnitWidth)
Next
End If
End If
Next
pcd_doubter = str
End Function
Rem 得到某点的字符
Function pcd_getDot(x,y,str,UnitWidth)
pcd_getDot = Mid(str,x+1+y*UnitWidth,1)
End Function
Rem 设置某点的字符
Sub pcd_setDot(x,y,ByRef str,newDot,UnitWidth)
str = Left(str,x+y*UnitWidth) & newDot & Right(str,Len(str)-x-y*UnitWidth-1)
End Sub
Rem 将数字转为bmp需要的格式 lens是目标字节长度
Function Num2ChrB(num,lens)
Dim ret,i
ret = ""
While (num>0)
ret = ret & ChrB(num mod 256)
num = num \ 256
WEnd
For i=Lenb(ret) To lens-1
ret = ret & chrB(0)
Next
Num2ChrB = ret
End Function
%>
打包文件下载