asp输出bmp
程序员文章站
2023-10-20 12:19:50
asp输出bmp [ 2005-03-06 12:04:25 | 作者: flashsoft ] 字...
asp输出bmp
[ 2005-03-06 12:04:25 | 作者: flashsoft ]
字体大小: 大 | 中 | 小
<%
call com_creatvalidcode("validcode")
sub com_creatvalidcode(psn)
'author: layen
'qq: 84815733
'e-mail: support@ssaw.net
' 禁止缓存
response.expires = -9999
response.addheader "pragma","no-cache"
response.addheader "cache-ctrol","no-cache"
response.contenttype = "image/bmp"
randomize
dim i, ii, iii
const codds = 8 ' 杂点出现的机率
const camount = 36 ' 文字数量
const ccode = "0123456789abcdefghijklmnopqrstuvwxyz"
' 颜色的数据(字符,背景)
dim vcolordata(1)
vcolordata(0) = chrb(0) & chrb(0) & chrb(0) ' 蓝0,绿0,红0(黑色)
vcolordata(1) = chrb(250) & chrb(236) & chrb(211) ' 蓝250,绿236,红211(浅蓝色)
' 随机产生字符
dim vcode(4), vcodes
for i = 0 to 3
vcode(i) = int(rnd * camount)
vcodes = vcodes & mid(ccode, vcode(i) + 1, 1)
next
session(psn) = vcodes '记录入session
' 字符的数据
dim vnumberdata(35)
vnumberdata(0) = "1110000111110111101111011110111101001011110100101111010010111101001011110111101111011110111110000111"
vnumberdata(1) = "1111011111110001111111110111111111011111111101111111110111111111011111111101111111110111111100000111"
vnumberdata(2) = "1110000111110111101111011110111111111011111111011111111011111111011111111011111111011110111100000011"
vnumberdata(3) = "1110000111110111101111011110111111110111111100111111111101111111111011110111101111011110111110000111"
vnumberdata(4) = "1111101111111110111111110011111110101111110110111111011011111100000011111110111111111011111111000011"
vnumberdata(5) = "1100000011110111111111011111111101000111110011101111111110111111111011110111101111011110111110000111"
vnumberdata(6) = "1111000111111011101111011111111101111111110100011111001110111101111011110111101111011110111110000111"
vnumberdata(7) = "1100000011110111011111011101111111101111111110111111110111111111011111111101111111110111111111011111"
vnumberdata(8) = "1110000111110111101111011110111101111011111000011111101101111101111011110111101111011110111110000111"
vnumberdata(9) = "1110001111110111011111011110111101111011110111001111100010111111111011111111101111011101111110001111"
vnumberdata(10) = "1111011111111101111111101011111110101111111010111111101011111100000111110111011111011101111000100011"
vnumberdata(11) = "1000000111110111101111011110111101110111110000111111011101111101111011110111101111011110111000000111"
vnumberdata(12) = "1110000011110111101110111110111011111111101111111110111111111011111111101111101111011101111110001111"
vnumberdata(13) = "1000001111110111011111011110111101111011110111101111011110111101111011110111101111011101111000001111"
vnumberdata(14) = "1000000111110111101111011011111101101111110000111111011011111101101111110111111111011110111000000111"
vnumberdata(15) = "1000000111110111101111011011111101101111110000111111011011111101101111110111111111011111111000111111"
vnumberdata(16) = "1110000111110111011110111101111011111111101111111110111111111011100011101111011111011101111110001111"
vnumberdata(17) = "1000100011110111011111011101111101110111110000011111011101111101110111110111011111011101111000100011"
vnumberdata(18) = "1100000111111101111111110111111111011111111101111111110111111111011111111101111111110111111100000111"
vnumberdata(19) = "1110000011111110111111111011111111101111111110111111111011111111101111111110111110111011111000011111"
vnumberdata(20) = "1000100011110111011111011011111101011111110001111111010111111101101111110110111111011101111000100011"
vnumberdata(21) = "1000111111110111111111011111111101111111110111111111011111111101111111110111111111011110111000000011"
vnumberdata(22) = "1000100011110010011111001001111100100111110101011111010101111101010111110101011111010101111001010011"
vnumberdata(23) = "1000100011110011011111001101111101010111110101011111010101111101100111110110011111011001111000110111"
vnumberdata(24) = "1110001111110111011110111110111011111011101111101110111110111011111011101111101111011101111110001111"
vnumberdata(25) = "1000000111110111101111011110111101111011110000011111011111111101111111110111111111011111111000111111"
vnumberdata(26) = "1110001111110111011110111110111011111011101111101110111110111011111011101001101111011001111110001011"
vnumberdata(27) = "1000001111110111011111011101111101110111110000111111010111111101101111110110111111011101111000110011"
vnumberdata(28) = "1110000011110111101111011110111101111111111001111111111001111111111011110111101111011110111100000111"
vnumberdata(29) = "1000000011101101101111110111111111011111111101111111110111111111011111111101111111110111111110001111"
vnumberdata(30) = "1000100011110111011111011101111101110111110111011111011101111101110111110111011111011101111110001111"
vnumberdata(31) = "1000100011110111011111011101111101110111111010111111101011111110101111111010111111110111111111011111"
vnumberdata(32) = "1001010011110101011111010101111101010111110101011111001001111110101111111010111111101011111110101111"
vnumberdata(33) = "1000100011110111011111101011111110101111111101111111110111111110101111111010111111011101111000100011"
vnumberdata(34) = "1000100011110111011111011101111110101111111010111111110111111111011111111101111111110111111110001111"
vnumberdata(35) = "1100000011110111011111111101111111101111111110111111110111111111011111111011111111101110111100000011"
' 输出图像文件头
response.binarywrite chrb(66) & chrb(77) & chrb(230) & chrb(4) & chrb(0) & chrb(0) & chrb(0) & chrb(0) &_
chrb(0) & chrb(0) & chrb(54) & chrb(0) & chrb(0) & chrb(0) & chrb(40) & chrb(0) &_
chrb(0) & chrb(0) & chrb(40) & chrb(0) & chrb(0) & chrb(0) & chrb(10) & chrb(0) &_
chrb(0) & chrb(0) & chrb(1) & chrb(0)
' 输出图像信息头
response.binarywrite chrb(24) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(176) & chrb(4) &_
chrb(0) & chrb(0) & 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 = 9 to 0 step -1 ' 历经所有行
for ii = 0 to 3 ' 历经所有字
for iii = 1 to 10 ' 历经所有像素
' 逐行、逐字、逐像素地输出图像数据
if rnd * 99 + 1 < codds then ' 随机生成杂点
response.binarywrite vcolordata(0)
else
response.binarywrite vcolordata(mid(vnumberdata(vcode(ii)), i * 10 + iii, 1))
end if
next
next
next
end sub
%>
[ 2005-03-06 12:04:25 | 作者: flashsoft ]
字体大小: 大 | 中 | 小
<%
call com_creatvalidcode("validcode")
sub com_creatvalidcode(psn)
'author: layen
'qq: 84815733
'e-mail: support@ssaw.net
' 禁止缓存
response.expires = -9999
response.addheader "pragma","no-cache"
response.addheader "cache-ctrol","no-cache"
response.contenttype = "image/bmp"
randomize
dim i, ii, iii
const codds = 8 ' 杂点出现的机率
const camount = 36 ' 文字数量
const ccode = "0123456789abcdefghijklmnopqrstuvwxyz"
' 颜色的数据(字符,背景)
dim vcolordata(1)
vcolordata(0) = chrb(0) & chrb(0) & chrb(0) ' 蓝0,绿0,红0(黑色)
vcolordata(1) = chrb(250) & chrb(236) & chrb(211) ' 蓝250,绿236,红211(浅蓝色)
' 随机产生字符
dim vcode(4), vcodes
for i = 0 to 3
vcode(i) = int(rnd * camount)
vcodes = vcodes & mid(ccode, vcode(i) + 1, 1)
next
session(psn) = vcodes '记录入session
' 字符的数据
dim vnumberdata(35)
vnumberdata(0) = "1110000111110111101111011110111101001011110100101111010010111101001011110111101111011110111110000111"
vnumberdata(1) = "1111011111110001111111110111111111011111111101111111110111111111011111111101111111110111111100000111"
vnumberdata(2) = "1110000111110111101111011110111111111011111111011111111011111111011111111011111111011110111100000011"
vnumberdata(3) = "1110000111110111101111011110111111110111111100111111111101111111111011110111101111011110111110000111"
vnumberdata(4) = "1111101111111110111111110011111110101111110110111111011011111100000011111110111111111011111111000011"
vnumberdata(5) = "1100000011110111111111011111111101000111110011101111111110111111111011110111101111011110111110000111"
vnumberdata(6) = "1111000111111011101111011111111101111111110100011111001110111101111011110111101111011110111110000111"
vnumberdata(7) = "1100000011110111011111011101111111101111111110111111110111111111011111111101111111110111111111011111"
vnumberdata(8) = "1110000111110111101111011110111101111011111000011111101101111101111011110111101111011110111110000111"
vnumberdata(9) = "1110001111110111011111011110111101111011110111001111100010111111111011111111101111011101111110001111"
vnumberdata(10) = "1111011111111101111111101011111110101111111010111111101011111100000111110111011111011101111000100011"
vnumberdata(11) = "1000000111110111101111011110111101110111110000111111011101111101111011110111101111011110111000000111"
vnumberdata(12) = "1110000011110111101110111110111011111111101111111110111111111011111111101111101111011101111110001111"
vnumberdata(13) = "1000001111110111011111011110111101111011110111101111011110111101111011110111101111011101111000001111"
vnumberdata(14) = "1000000111110111101111011011111101101111110000111111011011111101101111110111111111011110111000000111"
vnumberdata(15) = "1000000111110111101111011011111101101111110000111111011011111101101111110111111111011111111000111111"
vnumberdata(16) = "1110000111110111011110111101111011111111101111111110111111111011100011101111011111011101111110001111"
vnumberdata(17) = "1000100011110111011111011101111101110111110000011111011101111101110111110111011111011101111000100011"
vnumberdata(18) = "1100000111111101111111110111111111011111111101111111110111111111011111111101111111110111111100000111"
vnumberdata(19) = "1110000011111110111111111011111111101111111110111111111011111111101111111110111110111011111000011111"
vnumberdata(20) = "1000100011110111011111011011111101011111110001111111010111111101101111110110111111011101111000100011"
vnumberdata(21) = "1000111111110111111111011111111101111111110111111111011111111101111111110111111111011110111000000011"
vnumberdata(22) = "1000100011110010011111001001111100100111110101011111010101111101010111110101011111010101111001010011"
vnumberdata(23) = "1000100011110011011111001101111101010111110101011111010101111101100111110110011111011001111000110111"
vnumberdata(24) = "1110001111110111011110111110111011111011101111101110111110111011111011101111101111011101111110001111"
vnumberdata(25) = "1000000111110111101111011110111101111011110000011111011111111101111111110111111111011111111000111111"
vnumberdata(26) = "1110001111110111011110111110111011111011101111101110111110111011111011101001101111011001111110001011"
vnumberdata(27) = "1000001111110111011111011101111101110111110000111111010111111101101111110110111111011101111000110011"
vnumberdata(28) = "1110000011110111101111011110111101111111111001111111111001111111111011110111101111011110111100000111"
vnumberdata(29) = "1000000011101101101111110111111111011111111101111111110111111111011111111101111111110111111110001111"
vnumberdata(30) = "1000100011110111011111011101111101110111110111011111011101111101110111110111011111011101111110001111"
vnumberdata(31) = "1000100011110111011111011101111101110111111010111111101011111110101111111010111111110111111111011111"
vnumberdata(32) = "1001010011110101011111010101111101010111110101011111001001111110101111111010111111101011111110101111"
vnumberdata(33) = "1000100011110111011111101011111110101111111101111111110111111110101111111010111111011101111000100011"
vnumberdata(34) = "1000100011110111011111011101111110101111111010111111110111111111011111111101111111110111111110001111"
vnumberdata(35) = "1100000011110111011111111101111111101111111110111111110111111111011111111011111111101110111100000011"
' 输出图像文件头
response.binarywrite chrb(66) & chrb(77) & chrb(230) & chrb(4) & chrb(0) & chrb(0) & chrb(0) & chrb(0) &_
chrb(0) & chrb(0) & chrb(54) & chrb(0) & chrb(0) & chrb(0) & chrb(40) & chrb(0) &_
chrb(0) & chrb(0) & chrb(40) & chrb(0) & chrb(0) & chrb(0) & chrb(10) & chrb(0) &_
chrb(0) & chrb(0) & chrb(1) & chrb(0)
' 输出图像信息头
response.binarywrite chrb(24) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(176) & chrb(4) &_
chrb(0) & chrb(0) & 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 = 9 to 0 step -1 ' 历经所有行
for ii = 0 to 3 ' 历经所有字
for iii = 1 to 10 ' 历经所有像素
' 逐行、逐字、逐像素地输出图像数据
if rnd * 99 + 1 < codds then ' 随机生成杂点
response.binarywrite vcolordata(0)
else
response.binarywrite vcolordata(mid(vnumberdata(vcode(ii)), i * 10 + iii, 1))
end if
next
next
next
end sub
%>