当前位置: 首页 > 图文教程 > 网页制作 > Dreamweaver > 用ASP生成XBM数字图片(可用来生成验证码)

Dreamweaver
Dreamweaver 限制访问的BUG
Dreamweaver 数据库路径的使用
用Dreamweaver做搜索表单
Dreamweaver 事件简述
[Dreamweaver教程]Meta标签详解
提高 Dreamweaver行为全接触(5)
提高 Dreamweaver行为全接触(1)
提高 Dreamweaver行为全接触(3)
提高 Dreamweaver行为全接触(2)
提高 Dreamweaver行为全接触(4)
Dreamweaver MX2004视频宝典教程(7) Dreamweaver安装与启动
Dreamweaver MX2004视频宝典教程(9) 工作区结构
Dreamweaver MX2004视频宝典教程(5) 配色原则
Dreamweaver MX2004视频宝典教程(4) 网页布局
Dreamweaver MX2004视频宝典教程(8) Dreamweaver文档使用
Dreamweaver MX2004视频宝典教程(10) 菜单概述
Dreamweaver MX2004视频宝典教程(3) 网页的基本元素
Dreamweaver MX2004视频宝典教程(6) HTML与渲染
Dreamweaver MX2004视频宝典教程(1) 课程简介
Dreamweaver MX2004视频宝典教程(2) 网站与网页的概述

Dreamweaver 中的 用ASP生成XBM数字图片(可用来生成验证码)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-23   浏览: 81 ::
收藏到网摘: n/a

本文为软晨学习网合作伙伴印象特别供稿,转载必须取得授权

 [b][color=Red][center]示例图片:[img]http://www.china-oil.com/test/count.asp[/img][/center][/color][/b]
XBM图片是一个纯文本的文件,可以用ASP来自动生成。可以用它来使用网站登陆的验证码;
我们用记事本打开该文件进行分析:
其文件结构为:
[color=Blue]#define counter_width 48
#define counter_height 9
static unsigned char counter_bits[]={7c,3c,7c,3c,70,3c,fe,7c,fe,7c,78,7c,ee,ee,ee,ee,7c,ee,e0,ee,60,ee,74,ee,70,fe,30,fe,70,fe,38,ec,e0,ec,70,ec,1c,e0,ee,e0,70,e0,fe,7e,fe,7e,70,7e,fe,3c,7c,3c,70,3c}[/color]

文件扩展名为:.xbm

[color=Blue]#define counter_width 48 [color=Red]''这儿定义的是图片的宽度,一般为8的倍数[/color]
#define counter_height 9 [color=Red]''这儿定义的是图片的高度,是任意的。[/color]
static unsigned char counter_bits[]={7c,3c,7c,3c,70,3c,fe,7c,fe,7c,78,7c,ee,ee,ee,ee,7c,ee,e0,ee,60,ee,74,ee,70,fe,30,fe,70,fe,38,ec,e0,ec,70,ec,1c,e0,ee,e0,70,e0,fe,7e,fe,7e,70,7e,fe,3c,7c,3c,70,3c} [color=Red]''这儿是图片用来显示内容的十六进制的代码[/color][/color]

正如static unsigned char英文意思为静态的,无符号的,烧焦的。它只能用来显示黑白两种颜色。二进制中的1将来用显示为黑色,0为白色。

下面为0~9数字的二进制数组(其中的图片样式仅试用于本例。如果需要别的0~9数字样式,请另自行生成)

[color=Blue]''此处声明0~9绘图用数组[/color]
[color=Red]
dim num(9,8)
''数字0
num(0,0)="0x38"
num(0,1)="0x7c"
num(0,2)="0xee"
num(0,3)="0xee"
num(0,4)="0xee"
num(0,5)="0xee"
num(0,6)="0xee"
num(0,7)="0x7c"
num(0,8)="0x38"
''数字1
num(1,0)="0x70"
num(1,1)="0x78"
num(1,2)="0x7c"
num(1,3)="0x74"
num(1,4)="0x70"
num(1,5)="0x70"
num(1,6)="0x70"
num(1,7)="0x70"
num(1,8)="0x70"
''数字2
num(2,0)="0x7c"
num(2,1)="0xfe"
num(2,2)="0xee"
num(2,3)="0xe0"
num(2,4)="0x70"
num(2,5)="0x38"
num(2,6)="0x1c"
num(2,7)="0xfe"
num(2,8)="0xfe"
''数字3
num(3,0)="0x7c"
num(3,1)="0xfe"
num(3,2)="0xee"
num(3,3)="0x60"
num(3,4)="0x30"
num(3,5)="0xe0"
num(3,6)="0xee"
num(3,7)="0xfe"
num(3,8)="0x7c"
''数字4
num(4,0)="0x70"
num(4,1)="0x78"
num(4,2)="0x7c"
num(4,3)="0x76"
num(4,4)="0x77"
num(4,5)="0xff"
num(4,6)="0xff"
num(4,7)="0x70"
num(4,8)="0x70"
''数字5
num(5,0)="0xfc"
num(5,1)="0xfc"
num(5,2)="0x0c"
num(5,3)="0x7e"
num(5,4)="0xfe"
num(5,5)="0xe0"
num(5,6)="0xee"
num(5,7)="0xfe"
num(5,8)="0x7c"
''数字6
num(6,0)="0x78"
num(6,1)="0xfc"
num(6,2)="0x0e"
num(6,3)="0x6e"
num(6,4)="0xfe"
num(6,5)="0xee"
num(6,6)="0xee"
num(6,7)="0xfc"
num(6,8)="0x78"
''数字7
num(7,0)="0xfe"
num(7,1)="0xfe"
num(7,2)="0x60"
num(7,3)="0x70"
num(7,4)="0x38"
num(7,5)="0x38"
num(7,6)="0x18"
num(7,7)="0x1c"
num(7,8)="0x1c"
''数字8
num(8,0)="0x7c"
num(8,1)="0xfe"
num(8,2)="0xee"
num(8,3)="0x7c"
num(8,4)="0x7c"
num(8,5)="0xee"
num(8,6)="0xee"
num(8,7)="0xfe "
num(8,8)="0x7c"
''数字9
num(9,0)="0x3c"
num(9,1)="0x7c"
num(9,2)="0xee"
num(9,3)="0xee"
num(9,4)="0xfe"
num(9,5)="0xec"
num(9,6)="0xe0"
num(9,7)="0x7e"
num(9,8)="0x3c"[/color]

 

下面实现这个的代码,把上面的数字数组(红色的)保存为funNum.asp
下面的文件部分,单独保存为一个ASP页
[color=Navy]<%
response.Buffer=true
response.ExpiresAbsolute=now()-1
response.expires=0
response.CacheControl="no-cache"
%>
<!--#include file="funNum.asp"-->


<!--funNum.asp就是教程里那几个数组//-->
<%
const countHeight=9 ''图片的高度
const countlength=6 ''图片里数字的位数
const numBinBit=8 ''这是数字数组里的二进制位数,好象只能使用八位以下的即11111111
const countWidth=48 ''countlength*numBinBit得到
const imgtype="image/x-xbitmap"
dim countBody ''图片信息
dim tmpcountbody ''用于存放后面生成的图片数据
tmpcountbody=""
countBody="#define js_counter_width " & countWidth & vbCrLf
countBody=c