资源描述:
《asp获取图片宽度和高度类》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、asp获取图片宽度和高度的类<%'获取图片宽度和高度的类,支持JPG,GIF,PNG,BMPClassImgWHInfoDimASOPrivateSubClass_InitializeSetASO=Server.CreateObject("ADODB.Stream")ASO.Mode=3ASO.Type=1ASO.OpenEndSubPrivateSubClass_TerminateErr.ClearSetASO=NothingEndSubPrivateFunctionBin2Str(Bin)DimI,StrForI=1To
2、LenB(Bin)clow=MidB(Bin,I,1)IfASCB(clow)<128ThenStr=Str&Chr(ASCB(clow))ElseI=I+1IfI<=LenB(Bin)ThenStr=Str&Chr(ASCW(MidB(Bin,I,1)&clow))EndIfNextBin2Str=StrEndFunctionPrivateFunctionNum2Str(Num,Base,Lens)DimRetRet=""While(Num>=Base)Ret=(NumModBase)&RetNum=(Num-NumMod
3、Base)/BaseWendNum2Str=Right(String(Lens,"0")&Num&Ret,Lens)EndFunctionPrivateFunctionStr2Num(Str,Base)DimRet,IRet=0ForI=1ToLen(Str)Ret=Ret*base+Cint(Mid(Str,I,1))NextStr2Num=RetEndFunctionPrivateFunctionBinVal(Bin)DimRet,IRet=0ForI=LenB(Bin)To1Step-1Ret=Ret*256+AscB
4、(MidB(Bin,I,1))NextBinVal=RetEndFunctionPrivateFunctionBinVal2(Bin)DimRet,IRet=0ForI=1ToLenB(Bin)Ret=Ret*256+AscB(MidB(Bin,I,1))NextBinVal2=RetEndFunctionPrivateFunctionGetImageSize(filespec)DimbFlagDimRet(3)ASO.LoadFromFile(filespec)bFlag=ASO.Read(3)SelectCaseHex(
5、binVal(bFlag))Case"4E5089":ASO.Read(15)ret(0)="PNG"ret(1)=BinVal2(ASO.Read(2))ASO.Read(2)ret(2)=BinVal2(ASO.Read(2))Case"464947":ASO.read(3)ret(0)="gif"ret(1)=BinVal(ASO.Read(2))ret(2)=BinVal(ASO.Read(2))Case"535746":ASO.read(5)binData=ASO.Read(1)sConv=Num2Str(ascb
6、(binData),2,8)nBits=Str2Num(left(sConv,5),2)sConv=mid(sConv,6)While(len(sConv)7、(Abs(Str2Num(Mid(sConv,3*nBits+1,nBits),2)-Str2Num(Mid(sConv,2*nBits+1,nBits),2))/20)Case"FFD8FF":DoDo:p1=binVal(ASO.Read(1)):LoopWhilep1=255AndNotASO.EOSIfp1>191Andp1<196ThenExitDoElseASO.read(binval2(ASO.Read(2))-2)Do:p1=binVal(ASO.Read(1)):LoopWhilep1<255AndNotA
8、SO.EOSLoopWhileTrueASO.Read(3)ret(0)="JPG"ret(2)=binval2(ASO.Read(2))ret(1)=binval2(ASO.Read(2))CaseElse:Ifleft(Bin2Str(bFlag),2)="BM"ThenASO.Rea