⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib_graphicdetect.asp

📁 同样是一个在ASP.NET+SQL基础环境下开发的网上BBS系统
💻 ASP
字号:
<%
Dim HW
'将字符转换成ASCII码
Function AscAt(s, n)
AscAt = Asc(Mid(s, n, 1))
End Function
'将ASCII转换成16进制
Function HexAt(s, n)
HexAt = Hex(AscAt(s, n))
End Function
'判断是否为JPG图象
Function isJPG(fichero)
If inStr(uCase(fichero), ".JPG") <> 0 Then
    		isJPG = true
    	Else
    		isJPG = false
    	End If
End Function
'判断是否为PNG文件
Function isPNG(fichero)
If inStr(uCase(fichero), ".PNG") <> 0 Then
    		isPNG = true
Else
    		isPNG = false
    	End If
End Function
'判断是否为GIF文件
Function isGIF(fichero)
If inStr(uCase(fichero), ".GIF") <> 0 Then
    		isGIF = true
    	Else
    		isGIF = false
    	End If
End Function
'判断是否为BMP文件
Function isBMP(fichero)
    	If inStr(uCase(fichero), ".BMP") <> 0 Then
    		isBMP = true
    	Else
    		isBMP = false
End If
End Function
'判断是否为WMF文件
Function isWMF(fichero)
If inStr(uCase(fichero), ".WMF") <> 0 Then
isWMF = true
Else
isWMF = false
End If
End Function
'判断是否为浏览器支持文件文件
Function isWebImg(f)
If isGIF(f) Or isJPG(f) Or isPNG(f) Or isBMP(f) Or isWMF(f) Then
isWebImg = true
Else
isWebImg = true
End If
End Function
'读取图片
Function ReadImg(fichero)
If isGIF(fichero) Then
ReadImg = ReadGIF(fichero)
Else
If isJPG(fichero) Then
ReadImg = ReadJPG(fichero)
Else
If isPNG(fichero) Then
ReadImg = ReadPNG(fichero)
Else
If isBMP(fichero) Then
ReadImg = ReadPNG(fichero)
Else
If isWMF(fichero) Then
ReadImg = ReadWMF(fichero)
Else
ReadImg = Array(0,0)
End If
End If
End If
End If
End If
End Function
'获得JPG文件属性
Function ReadJPG(fichero)
    Dim fso, ts, s, HW, nbytes
HW = Array("","")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath(fichero), 1)
s = Right(ts.Read(167), 4)
HW(0) = HexToDec(HexAt(s,3) & HexAt(s,4))
HW(1) = HexToDec(HexAt(s,1) & HexAt(s,2))
ts.Close
    ReadJPG = HW
End Function
'获得PNG文件属性
Function ReadPNG(fichero)
Dim fso, ts, s, HW, nbytes
HW = Array("","")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath(fichero), 1)
s = Right(ts.Read(24), 8)
HW(0) = HexToDec(HexAt(s,3) & HexAt(s,4))
HW(1) = HexToDec(HexAt(s,7) & HexAt(s,8))
ts.Close
    ReadPNG = HW
End Function
'获得GIF文件属性
Function ReadGIF(fichero)
Dim fso, ts, s, HW, nbytes
HW = Array("","")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath(fichero), 1)
s = Right(ts.Read(10), 4)
HW(0) = HexToDec(HexAt(s,2) & HexAt(s,1))
HW(1) = HexToDec(HexAt(s,4) & HexAt(s,3))
ts.Close
    ReadGIF = HW
End Function
'获得WMF文件属性
Function ReadWMF(fichero)
    Dim fso, ts, s, HW, nbytes
HW = Array("","")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath(fichero), 1)
s = Right(ts.Read(14), 4)
HW(0) = HexToDec(HexAt(s,2) & HexAt(s,1))
HW(1) = HexToDec(HexAt(s,4) & HexAt(s,3))
ts.Close
    ReadWMF = HW
End Function
'获得BMP文件属性
Function ReadBMP(fichero)
    Dim fso, ts, s, HW, nbytes
HW = Array("","")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath(fichero), 1)
s = Right(ts.Read(24), 8)
HW(0) = HexToDec(HexAt(s,4) & HexAt(s,3))
HW(1) = HexToDec(HexAt(s,8) & HexAt(s,7))
ts.Close
    ReadBMP = HW
End Function
'判断是否为数字
Function isDigit(c)
If inStr("0123456789", c) <> 0 Then
isDigit = true
Else
isDigit = false
End If
End Function
'判断是否为16进制数字
Function isHex(c)
If inStr("0123456789ABCDEFabcdef", c) <> 0 Then
isHex = true
Else
ishex = false
End If
End Function
'将16进制转换成10进制
Function HexToDec(cadhex)
Dim n, I, ch, decimal
decimal = 0
n = Len(cadhex)
For I=1 To n
ch = Mid(cadhex, I, 1)
If isHex(ch) Then
decimal = decimal * 16
If isDigit(ch) Then
       			decimal = decimal + ch
Else
decimal = decimal + Asc(uCase(ch)) - Asc("A")
End If
Else
HexToDec = -1
End If
Next
HexToDec = decimal
End Function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -