反SPAM新思路—换Z-BLOG的验证码!(5)


    ' Call makeNoise(noiseLine,ImgWidth,ImgHeight)

    ' 位置随机
    ActUnitWidth = Int(ImgWidth / codeLen)
    ImgYuWidth = ImgWidth - ActUnitWidth * codeLen
    ReDim posAry(1,codeLen-1)
    posAry(0,0) = Int((Rnd)*(posX+(ActUnitWidth-UnitWidth)/2))
    posAry(1,0) = Int((ImgHeight-UnitHeight)/2+(1-2*Rnd)*posY)
    For i=1 To codeLen-2
        posAry(0,i) = Int((1-2*Rnd)*(posX+(ActUnitWidth-UnitWidth)/2))
        posAry(1,i) = Int((ImgHeight-UnitHeight)/2+(1-2*Rnd)*posY)
    Next
    If codeLen > 1 Then
        posAry(0,codeLen-1) = Int((Rnd)*(posX+(ActUnitWidth-UnitWidth)/2))
        posAry(1,codeLen-1) = Int((ImgHeight-UnitHeight)/2+(-Rnd)*posY)
    End If

    ' 输出图像数据
    For i = ImgHeight-1 To 0 Step -1    '行
      For ii = 0 To codeLen-1                    '字
          For iii = 0 To ActUnitWidth-1         '字宽
              flag = 0
              If onNoiseLine(noiseLine,ii*ActUnitWidth+iii,i) Then ' 干扰线
                   flag = 1
            ElseIf getUnitDot(posAry,vCode,ii,iii,i,UnitWidth,UnitHeight) = "0" Then
                flag = 1
            ElseIf getUnitDot(posAry,vCode,ii-1,iii+ActUnitWidth,i,UnitWidth,UnitHeight) = "0" Then
                flag = 1
            ElseIf getUnitDot(posAry,vCode,ii+1,iii-ActUnitWidth,i,UnitWidth,UnitHeight) = "0" Then
                flag = 1

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/2942.html