100111111100111001100111001110011111110011100110011100111001111111001110011001110011100111111100111001100111001110011111110000000110000000111001111111001111111001110011100111111101111111111111111110011111111111111111111111111001111111111111111111111111100111111111111111111111111110011111111111111111111111111001111111111111111111111110000111111111111111111111111000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
vNumberData(84) = "1111111111111111111111111111111111111111111111111111111111111110111111111111111000111111111001111111111111100111111111100011111111111110011111111110001111111100111001111100000000000000110011100111111111111111111111001110011111111111111001111100111001111111111111000111110011100111111101111100011111001110011111111111110011111100111001111111110111001111110011100111111111101000111111001110011111111111000111111100111001111111111100011111110011100111111111110001111111001110011111111111000011111100111001111111111001000111110011100111111111101110011111001110011111111101111000111111111001111111101111100011111111100111111111111110001111111110011111111111111101111111000001111111111111111111111110000111111111111111111111111000111111111111111111111111111111111111111111111111111111111111"
'' 随机产生字符
Dim vCodes
ReDim vCode(codeLen-1)
For i = 0 To codeLen-1
vCode(i) = Int(Rnd * cAmount)
vCodes = vCodes & Mid(cCode, vCode(i) + 1, 1)
vCode(i) = pcd_doubter(vNumberData(vCode(i)),UnitWidth,UnitHeight,DotsLimit,tryCount,dbtTimes)
Next
Session("psn") = vCodes ''///////////记录入Session
'' 输出图像文件头
Response.BinaryWrite ChrB(66) & ChrB(77) & Num2ChrB(54+UnitWidth*UnitHeight*CodeLen*3,4) & ChrB(0) & ChrB(0) &_
ChrB(0) & ChrB(0) & ChrB(54) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(40) & ChrB(0) &_
ChrB(0) & ChrB(0) & Num2ChrB(UnitWidth*CodeLen,4) & Num2ChrB(UnitHeight,4) &_
ChrB(1) & ChrB(0)
'' 输出图像信息头
Response.BinaryWrite ChrB(24) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & Num2ChrB(UnitWidth*UnitHeight*CodeLen*3,4) &_
ChrB(18) & ChrB(11) & ChrB(0) & ChrB(0) & ChrB(18) & ChrB(11) &_
ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) &_
ChrB(0) & ChrB(0)
For i = UnitHeight-1 To 0 Step -1 '' 历经所有行
For ii = 0 To codeLen-1 '' 历经所有字
For iii = 1 To UnitWidth '' 历经所有像素
If Rnd * 99 + 1 >= cOdds Then'' 逐行、逐字、逐像素地输出图像数据
Response.BinaryWrite vColorData(Mid(vCode(ii), i * UnitWidth + iii, 1))
Else '' 随机生成杂点
Response.BinaryWrite vColorData(1-CInt(Mid(vCode(ii), i * UnitWidth + iii, 1)))
End If
Next
Next
Next
End Sub
Function pcd_doubter(str,UnitWidth,UnitHeight,DotsLimit,tryCount,dbtTimes)
Randomize
Dim x1,x2,y1,y2,xOffSet,yOffSet,direction,flag,rows,step,yu,yuStr,i,ii,iii,f1,f2
For f1=1 To dbtTimes''干扰次数
For f2=1 To tryCount''避免删除有效点超过上限的尝试次数限制
''随机确定2个端点
x1 = int(Rnd*UnitWidth)
x2 = int(Rnd*UnitWidth)
y1 = int(Rnd*UnitHeight)
y2 = int(Rnd*UnitHeight)
''x,y