使ç¨ASPçæå¾ç彩è²æ ¡éªç
49è¡ä»£ç ,ä¸ä¸ªæ件
Aspæ件ï¼Code.Asp
æ°æ®æ件ï¼body.Fix , Head.Fix
ç¨æ³ï¼<img src="code.asp">
<%
Option Explicit
Response.buffer=true
NumCode
Function NumCode()
Response.Expires = -1
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-ctrol","no-cache"
dim zNum,i,j
dim Ados,Ados1
Randomize timer
zNum = cint(8999*Rnd+1000)
Session("GetCode") = zNum
dim zimg(4),NStr
NStr=cstr(zNum)
For i=0 to 3
zimg(i)=cint(mid(NStr,i+1,1))
Next
dim Pos
set Ados=Server.CreateObject("Adodb.Stream")
Ados.Mode=3
Ados.Type=1
Ados.Open
set Ados1=Server.CreateObject("Adodb.Stream")
Ados1.Mode=3
Ados1.Type=1
Ados1.Open
Ados.LoadFromFile(Server.mappath("body.Fix"))
Ados1.write Ados.read(1280)
for i=0 to 3
Ados.Position=(9-zimg(i))*320
Ados1.Position=i*320
Ados1.write ados.read(320)
next
Ados.LoadFromFile(Server.mappath("head.fix"))
Pos=lenb(Ados.read())
Ados.Position=Pos
for i=0 to 9 step 1
for j=0 to 3
Ados1.Position=i*32+j*320
Ados.Position=Pos+30*j+i*120
Ados.write ados1.read(30)
next
next
Response.ContentType = "image/BMP"
Ados.Position=0
Response.BinaryWrite Ados.read()
Ados.Close:set Ados=nothing
Ados1.Close:set Ados1=nothing
End Function
' Asp code Created by BlueIdea.COM Web Team V37 2003-7-25
%>
代ç 解é:
Response.buffer=true
NumCode
Function NumCode()
Response.Expires = -1
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-ctrol","no-cache"
dim zNum,i,j
dim Ados,Ados1
Randomize timer
çæéæºåä½æ°åï¼
zNum = cint(8999*Rnd+1000)
ä¼ éç»session
Session("GetCode") = zNum
该for循ç¯æ¯å°éæºæ°åæ¾å
¥ä¸ä¸ªä¸æ 3çæ°ç»ï¼ä¾¿äºæä¾ç»åé¢çéµååæ¢
dim zimg(3),NStr
NStr=cstr(zNum)
For i=0 to 3
zimg(i)=cint(mid(NStr,i+1,1))
Next
dim Pos
'å®ä¹äºä¸ª ADODB.Stream binary对象,ä½å¾åæ°æ®æä½ä¹ç¨:
set Ados=Server.CreateObject("Adodb.Stream")
Ados.Mode=3
Ados.Type=1
Ados.Open
set Ados1=Server.CreateObject("Adodb.Stream")
Ados1.Mode=3
Ados1.Type=1
Ados1.Open
'è½½å
¥0~9çæ°åæ°æ®10x100çï¼Gbrçéµåæ°æ®,æ¯ä¸ª320åè,10个æ°å3200byte
'BGRä¸ä¸ªç¹,10x10个ç¹ä¸ä¸ªæ°åï¼ä¸ä¸ªç¹ä¸ä¸ªåè(äºè¿å¶8ä½ï¼16è¿å¶ 00~FF)
'ä¸è¡10ä¸ªç¹ 30åè + è¡ç»ææ è®° 00 00 äºåè 32åèï¼æ以ä¸ä¸ª10x100宽å°äºé¿çå¾åæ¯ä¸ªæ°å10x10æ¯320åè
'é¿å¤§äºå®½çåæ è¡ç»ææ è®° 0000,ç´æ¥æ¯300åè
è¿äºå°±æ¯BMP 24bitçæ°æ®è¯¦ç»ä¿¡æ¯äº
âè³äºå¤´é¨ï¼ä¹å¾ç®åï¼å
å«é¿å®½ï¼å¾åå¼å§æ è®°çç~~æ54åèï¼è¿æ²¡jpgä»ä¹çå¤æ
Ados.LoadFromFile(Server.mappath("body.Fix"))
Ados1.write Ados.read(1280)
'第ä¸ä¸ªfor循ç¯,æçæçéæºæ°å顺åºä» 10X100çæ°åéµåä¸æååºç¸åºçå个æ°å
ä½æ¯ç«æçæ°åéµå
for i=0 to 3
Ados.Position=(9-zimg(i))*320
Ados1.Position=i*320
Ados1.write ados.read(320)
next
'æ¸
空已ç»ç¨å®çADOSçæ°æ®ï¼è°å
¥æ¿æ¢æ°çå¾å头54åèç头æ件
Ados.LoadFromFile(Server.mappath("head.fix"))
Pos=lenb(Ados.read())
Ados.Position=Pos 'æå®Posä½ç½®,å³å¯åå移54åèçä½ç½®æ·»å å¾å½¢æ°æ®
第äºä¸ªfor循ç¯ï¼è¿è¡æ°åçéµååæ¢ï¼ç±ç«æçå转æ¢ä¸ºæ¨ªæçæ°åå
æ¹æ³æ¯é320åèæ½å4次30åèåå
¥ados对象ï¼åæ½åå移第äºè¡çå¾åæ°æ®
30åèæ¯å 为bmp 宽大äºé¿æ¶æ 00 00çè¡ç»ææ è®°
for i=0 to 9 step 1
for j=0 to 3
Ados1.Position=i*32+j*320
Ados.Position=Pos+30*j+i*120
Ados.write ados1.read(30)
next
next
Ados.Position=0
response.BinaryWriteç´æ¥å客æ·ç«¯åéå¾åæ°æ®
Response.ContentType = "image/BMP"
Response.BinaryWrite Ados.read()
Ados.Close:set Ados=nothing
Ados1.Close:set Ados1=nothing
End Function
æ°åååæ¯ç»å并çæå¾ççéªè¯ç 祥解
大家ç»å¸¸å¨ç½ä¸ç»éçæ¶åç»å¸¸ä¼çå°è®©ä½ è¾å
¥éªè¯ç ï¼æçæ¯æåçï¼æçå¢æ¯å¾çï¼æ¯å¦chinaren.comæ ¡åå½ä¸çè¨çæ¶åï¼æ们就ä¼çå°æ°åå¾çéªè¯ç ï¼ç½ä¸å
³äºæ°åæåéªè¯ç å®ç°æ¹æ³çç¸å
³èµæå¾å¤ï¼èæ们è¿éä»ç»çæ¯æ°åååæ¯éæºç»æç并ä¸çæå¾ççéªè¯ç çå®ç°æ¹æ³ãçèµ·æ¥å¾å¤æãå
¶å®å¾ç®åçï¼å¤§å®¶è·çæå¾ä¸çï¼
é¦å
ï¼æ们å
ä»ç»ä¸ä¸è®¾è®¡æè·¯ï¼æ°åååæ¯çéæºç»åçæéªè¯ç ï¼ç¶åå°éªè¯ç çæå¾çï¼è¿éâæ°åååæ¯çç»åâåºè¯¥æ¯éæºååºæ¥çï¼å¦ææ¯ä¸é¨çæ°åéªè¯ç ï¼æ们å¯ä»¥è¿æ ·å®ç°ï¼
ycodenum=4 'éªè¯ç çä½æ°ï¼æè
说æ个æ°
for i=1 to ycodenum
Randomize 'åå§åéæºæ°åçå¨
ycode=ycode&Int((9*Rnd)) 'rndæ¯éæºæ°ï¼ä»0å°1ä¹é´çä»»æå®æ°ï¼è¿éè·å¾0å°9ä¹é´çæ´æ°
next
response.write ycode 'å°±å¯ä»¥è¾åºæ°åéªè¯ç ï¼4ä½ï¼
ç¶èï¼æ们è¦è®©æ°åååæ¯åæ ·éæºçæï¼è¿éæ们å¯ä»¥ç¨å°æ°ç»æ¥å®ç°è¿ç§ææï¼å¦ä¸ï¼
ychar="0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z" 'å°æ°åå大ååæ¯ç»æä¸ä¸ªå符串
yc=split(char,",") 'å°å符串çææ°ç»
ycodenum=4
for i=1 to ycodenum
Randomize
ycode=ycode&yc(Int((35*Rnd))) 'æ°ç»ä¸è¬ä»0å¼å§è¯»åï¼æ以è¿é为35*Rnd
next
response.write ycode
ç°å¨ççè¾åºç»ææ¯ä¸æ¯æ°åååæ¯éæºç»åçå¢ï¼
ä¸é¢ççææ ·çæå¾çï¼è¿ä¸ªä¹è®¸æäºæåç¥éï¼aspä¸è½çæå¾çï¼å¿
须使ç¨aspç»ä»¶ãä¸éï¼æ们è¿é使ç¨çæ¯ASPå¾è±¡ç»ä»¶shotgraphãæä¸ç¹å¤§å®¶æ³¨æï¼æå¡å¨ä¸æ¯èªå·±çä¸è½ç¨å¦ï¼å ä¸ºä½ è£
ä¸äºè¿ç»ä»¶ã
ç»ä»¶çä¸è½½å°åï¼
http://www.csdn.com.cn/download/ShotGraph.rarï¼è³äºæä¹æ³¨åï¼è¿éå°±ä¸å¤è¯´äºï¼ç½ä¸æå¾å¤èµæ
æ们çççæå¾çç代ç ï¼
ychar="0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z" 'å°æ°åå大ååæ¯ç»æä¸ä¸ªå符串
yc=split(char,",") 'å°å符串çææ°ç»
ycodenum=4
for i=1 to ycodenum
Randomize
ycode=ycode&yc(Int((35*Rnd))) 'æ°ç»ä¸è¬ä»0å¼å§è¯»åï¼æ以è¿é为35*Rnd
next
Response.Clear
Response.ContentType="image/gif"
set obj=Server.CreateObject("shotgraph.image")
x=55 'å¾çç宽
y=26 'å¾ççé«
obj.CreateImage x,y,8 '8æ¯å¾ççé¢è²8ä½
obj.SetColor 0,55,126,222
obj.SetColor 1,255,255,255
obj.CreatePen "PS_SOLID",1,0
obj.SetBgColor 0
obj.Rectangle 0,0,x-1,y-1
obj.SetBkMode "TRANSPARENT"
obj.CreateFont "Arial",136,18,1,False,False,False,False
obj.SetTextColor 1
obj.TextOut 5,4,ycode&" "
img=obj.GifImage(-1,1,"")
Response.BinaryWrite (img)
é对以ä¸ä»£ç ä¹å°±æ¯è¯´shotgraphæ®éçç»å¾çåç请åèï¼
http://www.pconline.com.cn/pcedu/empolder/wz/asp/10204/45207.html