|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
专业性的服务。有的ASP商提供垂直型的应用服务,针对某一特定行业提供应用服务。无组件|考证码<%
OptionExplicit显现声明
ClassCom_GifCode_Class
Author:Layensupport@ssaw.net84815733(QQ)
Thanks:Laomi,Laomiao,NetRube
2006-01-02
PublicNoisy,Count,Width,Height,Angle,Offset,Border
PrivateGraph(),Margin(3)
PrivateSubClass_Initialize()
Randomize
Noisy=16搅扰点呈现的几率
Count=4字符数目
Width=80图片宽度
Height=20图片高度
Angle=2角度随机变更量
Offset=20偏移随机变更量
Border=1边框巨细
EndSub
PublicFunctionCreate()
ConstcCharSet="123456789"
Dimi,x,y
DimvValidCode:vValidCode=""
DimvIndex
ReDimGraph(Width-1,Height-1)
Fori=0ToCount-1
vIndex=Int(Rnd*Len(cCharSet))
vValidCode=vValidCode+Mid(cCharSet,vIndex+1,1)
SetDrawvIndex,i
Next
Create=vValidCode
EndFunction
SubSetDot(pX,pY)
IfpX*(Width-pX-1)>=0AndpY*(Height-pY-1)>=0Then
Graph(pX,pY)=1
EndIf
EndSub
PublicSubSetDraw(pIndex,pNumber)
字符数据
DimDotData(8)
DotData(0)=Array(30,15,50,1,50,100)
DotData(1)=Array(1,34,30,1,71,1,100,34,1,100,93,100,100,86)
DotData(2)=Array(1,1,100,1,42,42,100,70,50,100,1,70)
DotData(3)=Array(100,73,6,73,75,6,75,100)
DotData(4)=Array(100,1,1,1,1,50,50,35,100,55,100,80,50,100,1,95)
DotData(5)=Array(100,20,70,1,20,1,1,30,1,80,30,100,70,100,100,80,100,60,70,50,30,50,1,60)
DotData(6)=Array(6,26,6,6,100,6,53,100)
DotData(7)=Array(100,30,100,20,70,1,30,1,1,20,1,30,100,70,100,80,70,100,30,100,1,80,1,70,100,30)
DotData(8)=Array(1,80,30,100,80,100,100,70,100,20,70,1,30,1,1,20,1,40,30,50,70,50,100,40)
DimvExtent:vExtent=Width/Count
Margin(0)=Border+vExtent*(Rnd*Offset)/100+Margin(1)
Margin(1)=vExtent*(pNumber+1)-Border-vExtent*(Rnd*Offset)/100
Margin(2)=Border+Height*(Rnd*Offset)/100
Margin(3)=Height-Border-Height*(Rnd*Offset)/100
DimvStartX,vEndX,vStartY,vEndY
DimvWidth,vHeight,vDX,vDY,vDeltaT
DimvAngle,vLength
vWidth=Int(Margin(1)-Margin(0))
vHeight=Int(Margin(3)-Margin(2))
肇端坐标
vStartX=Int((DotData(pIndex)(0)-1)*vWidth/100)
vStartY=Int((DotData(pIndex)(1)-1)*vHeight/100)
Dimi,j
Fori=1ToUBound(DotData(pIndex),1)/2
IfDotData(pIndex)(2*i-2)0AndDotData(pIndex)(2*i)0Then
尽头坐标
vEndX=(DotData(pIndex)(2*i)-1)*vWidth/100
vEndY=(DotData(pIndex)(2*i+1)-1)*vHeight/100
横向差异
vDX=vEndX-vStartX
纵向差异
vDY=vEndY-vStartY
倾斜角度
IfvDX=0Then
vAngle=Sgn(vDY)*3.14/2
Else
vAngle=Atn(vDY/vDX)
EndIf
两坐标间隔
IfSin(vAngle)=0Then
vLength=vDX
Else
vLength=vDY/Sin(vAngle)
EndIf
随机动弹角度
vAngle=vAngle+(Rnd-0.5)*2*Angle*3.14*2/100
vDX=Int(Cos(vAngle)*vLength)
vDY=Int(Sin(vAngle)*vLength)
IfAbs(vDX)>Abs(vDY)ThenvDeltaT=Abs(vDX)ElsevDeltaT=Abs(vDY)
Forj=1TovDeltaT
SetDotMargin(0)+vStartX+j*vDX/vDeltaT,Margin(2)+vStartY+j*vDY/vDeltaT
Next
vStartX=vStartX+vDX
vStartY=vStartY+vDY
EndIf
Next
EndSub
PublicSubOutput()
Response.Expires=-9999
Response.AddHeader"pragma","no-cache"
Response.AddHeader"cache-ctrol","no-cache"
Response.ContentType="image/gif"
文件范例
Response.BinaryWriteChrB(Asc("G"))&ChrB(Asc("I"))&ChrB(Asc("F"))
版本信息
Response.BinaryWriteChrB(Asc("8"))&ChrB(Asc("9"))&ChrB(Asc("a"))
逻辑屏幕宽度
Response.BinaryWriteChrB(WidthMod256)&ChrB((Width256)Mod256)
逻辑屏幕高度
Response.BinaryWriteChrB(HeightMod256)&ChrB((Height256)Mod256)
Response.BinaryWriteChrB(128)&ChrB(0)&ChrB(0)
全局色彩列表
Response.BinaryWriteChrB(255)&ChrB(255)&ChrB(255)
Response.BinaryWriteChrB(0)&ChrB(85)&ChrB(255)
图像标识符
Response.BinaryWriteChrB(Asc(","))
Response.BinaryWriteChrB(0)&ChrB(0)&ChrB(0)&ChrB(0)
图像宽度
Response.BinaryWriteChrB(WidthMod256)&ChrB((Width256)Mod256)
图像高度
Response.BinaryWriteChrB(HeightMod256)&ChrB((Height256)Mod256)
Response.BinaryWriteChrB(0)&ChrB(7)&ChrB(255)
Dimx,y,i:i=0
Fory=0ToHeight-1
Forx=0ToWidth-1
IfRnd<Noisy/100Then
Response.BinaryWriteChrB(1-Graph(x,y))
Else
Ifx*(x-Width)=0Ory*(y-Height)=0Then
Response.BinaryWriteChrB(Graph(x,y))
Else
IfGraph(x-1,y)=1OrGraph(x,y)OrGraph(x,y-1)=1Then
Response.BinaryWriteChrB(1)
Else
Response.BinaryWriteChrB(0)
EndIf
EndIf
EndIf
If(y*Width+x+1)Mod126=0Then
Response.BinaryWriteChrB(128)
i=i+1
EndIf
If(y*Width+x+i+1)Mod255=0Then
If(Width*Height-y*Width-x-1)>255Then
Response.BinaryWriteChrB(255)
Else
Response.BinaryWriteChrB(Width*HeightMod255)
EndIf
EndIf
Next
Next
Response.BinaryWriteChrB(128)&ChrB(0)&ChrB(129)&ChrB(0)&ChrB(59)
EndSub
EndClass
DimmCode
SetmCode=NewCom_GifCode_Class
Session("GetCode")=mCode.Create()
mCode.Output()
SetmCode=Nothing
%>
大家可以自己去看一看.可以说看得想呕吐.以前有次下了个动网来看.里面连基本内置函数的保护措施(函数没防御性)都没有.难怪经常补这个补那个了.可能现在.NET版会好点吧 |
|