艺术迷(fansart.com) 首页 收藏本站 RSS频道
艺术迷首页 -> 网页设计 -> 如何获知页面上的图象的实际尺寸?--asp编程技术
2006-4-21   作者:   来源:互联网
页面功能: 【评论】有错就点】 【字体: 】 【打印】 【关闭【收藏本页】
asp编程技术,如何获知页面上的图象的实际尺寸?

如何获知页面上的图象的实际尺寸?
<!--#include virtual="/intels/chunfeng/graphicdetect.asp"-->
<html>

<head>
<title>千花飞舞之获知图像尺寸</title>
</head>
<body>
<%
graphic="images/intels.gif"
HW = ReadImg(graphic)
Response.Write graphic & " Dimensions: " & HW(0) & "x" & HW(1)
& "<br>"
response.write "<img src=""/" & graphic & """"
response.write height=""" & HW(0) & """
response.write width=""" & HW(0) & "">"
%>
</body></html>

graphicdetect.asp
<%
Dim HW

Function AscAt(s, n)
AscAt = Asc(Mid(s, n, 1))
End Function

Function HexAt(s, n)
HexAt = Hex(AscAt(s, n))
End Function

Function isJPG(fichero)
If inStr(uCase(fichero), ".JPG") <> 0 Then
isJPG = true
Else
isJPG = false
End If
End Function

Function isPNG(fichero)
If inStr(uCase(fichero), ".PNG") <> 0 Then
isPNG = true
Else
isPNG = false
End If
End Function

Function isGIF(fichero)
If inStr(uCase(fichero), ".GIF") <> 0 Then
isGIF = true
Else
isGIF = false
End If
End Function

Function isBMP(fichero)
If inStr(uCase(fichero), ".BMP") <> 0 Then
isBMP = true
Else
isBMP = false
End If
End Function

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

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

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

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


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

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

Function isHex(c)
If inStr("0123456789ABCDEFabcdef", c) <> 0 Then
isHex = true
Else
ishex = false
End If
End Function

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(c) Then
decimal = decimal + ch
Else
decimal = decimal + Asc(uCase(ch)) - Asc("A")
End If
Else
HexToDec = -1
End If
Next
HexToDec = decimal
End Function
%>

页面功能: 【评论】有错就点】 【字体: 】 【打印】 【关闭【收藏本页】
网友评论
发表评论
您的姓名: 匿名发送
电子邮件:
评论内容:
不能超过100个字符



所有留言只代表网友个人观点,不代表本站观点。
请各位遵纪守法并注意语言文明。
新闻搜索
关 键 词:
搜索范围:
全站精华
图文精彩
万科西山庭院.格.沉.尊[图]--平面广告
【2006-4-21 9:08:35】
万科西山庭院.格.沉.尊
泊林花园推广故事绘本(2)[图]--CG插画
【2006-4-20 11:43:23】
泊林花园推广故事绘本(2)
泊林花园推广故事绘本(1)[图]--CG插画
【2006-4-20 11:34:33】
泊林花园推广故事绘本(1)
溯源居广告欣赏--小红人[图]--平面广告
【2006-4-14 14:45:57】
溯源居广告欣赏--小红人
cg插画欣赏[图]--CG插画
【2006-4-14 9:21:18】
cg插画欣赏
yashasi插画作品欣赏[图]--CG插画
【2006-4-13 18:32:29】
yashasi插画作品欣赏
北邦插画欣赏(1)[图]--CG插画
【2006-4-13 9:49:02】
北邦插画欣赏(1)
高傲的玫瑰-温碧霞[图]--摄影艺术
【2006-4-12 8:58:34】
高傲的玫瑰-温碧霞
国粹京剧脸谱表情[图]--界面设计
【2006-4-11 17:51:33】
国粹京剧脸谱表情
回忆紫禁城里那些逝去的[图]--中国艺术
【2006-4-11 16:34:31】
回忆紫禁城里那些逝去的
非常可爱的儿童插画(1)[图]--CG插画
【2006-4-11 15:59:16】
非常可爱的儿童插画(1)
荷兰著名画家Anton
【2006-4-11 15:49:41】
荷兰著名画家Anton Pieck插画
美国插画师kevindart作品[图]--CG插画
【2006-4-11 15:37:32】
美国插画师kevindart作品
美国插画师kevindart作品(1)[图]--CG插画
【2006-4-11 15:34:43】
美国插画师kevindart作品(1)
古典楼书(精品欣赏)(1)[图]--平面广告
【2006-4-5 15:03:08】
古典楼书(精品欣赏)(1)
清风楼书(一)[图]--平面广告
【2006-3-29 10:52:08】
清风楼书(一)
水木清华地产广告欣赏[图]--平面广告
【2006-4-26 9:31:54】
水木清华地产广告欣赏