频道直达 - 学院 - 下载 - 交易 - 特效 - 字库 - 手册 -排名-工具- 繁體
网页教学网站开发 设为首页
加入收藏
联系我们
建站搜索: 常用广告代码   用户注册 | 用户登陆
您当前的位置:中国建站之家 -> 网站开发设计技术教程 -> asp教程 -> 利用ASP获得图象的实际尺寸的示例

利用ASP获得图象的实际尺寸的示例

作者:未知  来源:转载  发布时间:2005-7-28 14:31:51  发布人:acx

减小字体 增大字体

<!--#include virtual="/learn/test/lib_graphicdetect.asp"-->
<html><head>
<TITLE>dbtable.asp</TITLE>
</head>
<body bgcolor="#FFFFFF">
<%
   graphic="images/learnaspiconmain.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>



The library that is included is:

<%
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
%>


将本文收藏到QQ书签与更多好友分享
[打 印]
[] [返回上一页] [收 藏]
下一篇文章:NT 下虚拟域名的实现
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
精彩推荐
热门文章
· 注册码大全二
· 注册码大全四
· 注册码大全一
· 要10G免费网络硬盘的请进..
· 通过google 赶快来赚美金..
· 注册码大全十
· 头像-qq头像(qq新头像)4..
· 让你轻松架设FTP服务器1..
· 注册码大全三
· 梦幻背景图片7
· 卡通动物图片6
· 网页制作素材-按钮素材2..
· 让你轻松架设FTP服务器5..
· 风景图片8
· 注册码大全九
· 让你轻松架设FTP服务器2..
关注此文读者还看过
· 网页制作学习CSS2的打印..
· 搜索引擎巨头角力中国市..
· 深入讲解 ASP+ 验证(四..
· 网站访问量上不去的19个..
· 什么才是提高ASP性能的最..
· 第九城市Q2净利润8430万..
· 构建你的网站新闻自动发..
· 货币格式显示数字
· Java Web层的下一个王者..
· 邮件发送还有问题吗?送..
· ASP注入漏洞全接触(3)
· 一个分页导航类
· 部署ASP.NET的三大技术(..
· 一个PHP+MSSQL分页的例子..
· 如何才能成为一名真正的..
· SQL Server数据库安全规..
相关文章
· 利用Asp.net Ajax异步获取x..
· 利用ASP显示当前在线人数
· 利用ASP存取各种常用类型数..
· 利用ASP制作EXECL报表方法(..
· 利用ASP制作EXECL报表方法(..
· 利用ASP改进文档上载控件
· 利用ASP的文件操作实现用户..
· 利用ASP+XML架设在线考试系..
· 利用ASP和Access数据库制作..
· 利用ASP在客户端注册DLL文件..
· 利用ASP存取各种常用类型数..
· 利用AS控制声音教程
· 利用ASP显示当前在线人数
· 利用ASP在浏览器上打印输出..
· 利用ASP从远程服务器上接收..
· 利用ASP规划聊天室
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 人才招聘
网站合作、内容监督、商务咨询:QQ: 9576619
Copyright ? 2005--2008 中国建站之家版权所有
粤ICP备05092265号