ASP adodb.stream 取 .gif 图片完整文件头&描述信息 By shawl.qiu

ASP adodb.stream 取 .gif 图片完整文件头&描述信息 By shawl.qiu


摘要:
主要是想 用 ASP 取 .gif 的高宽度(不用外建组件), 不过既然要了解, 也就了解多一点.
GIF 的头部信息并不包括高宽度, 但接下去的逻辑画面描述就有包括高宽度信息.

作用:
本文使用 ASP 的内置组件 adodb.stream 取得 .gif 的头部信息和高宽信息.

附: 相关文章
ASP adodb.stream 取 Win32 .bmp 图片完整文件头信息 By shawl.qiu
URL:    http://blog.csdn.net/btbtd/archive/2006/09/16/1228908.aspx

目录:
1. 主内容: 完整例子
2. 参考文献
3. 预览

附: 测试图片

shawl.qiu
2006-09-17
  http://blog.csdn.net/btbtd

1. 主内容: 完整例子
  1. linenum
  2. <%
  3.     dim file:file=server.MapPath("a.gif")
  4.     dim temp
  5.     dim stm
  6.     set stm=createObject("adodb.stream")
  7.         with stm
  8.             .type = 1
  9.             .open
  10.             .loadFromFile file
  11.             temp=.read
  12.             .close
  13.         end with    
  14.     set stm=nothing
  15.         response.write "gif file info:<br/>"
  16.         response.write "<br/>#1-3/3 Header Signature: "&binToStr(midB(temp,1,3))
  17.         response.write "<br/>#4-6/3 GIF format version(""87a"" or ""89a""): "&binToStr(midB(temp,4,3))
  18.         response.write "<br/>#7-8/2 Width of Display Screen in Pixels: "&binToNum(midB(temp,7,2))
  19.         response.write "<br/>#9-10/2 Height of Display Screen in Pixels: "&binToNum(midB(temp,9,2))
  20.         response.write "<br/>#11-11/1 BYTE Packed: "&binToNum(midB(temp,11,1))
  21.         response.write "<br/>#12-12/1 BYTE BackgroundColor: "&binToNum(midB(temp,12,1))
  22.         response.write "<br/>#13-13/1 BYTE AspectRatio: "&binToNum(midB(temp,13,1))
  23.     
  24.     private function binToNum(bin)
  25.     '二进制转为 Numeric
  26.         dim i:binToNum=0
  27.         for i=lenB(bin) to 1 step -1
  28.             binToNum=binToNum*256+ascB(midB(bin,i,1))
  29.         next 'shawl.qiu code'
  30.     end function
  31.     
  32.     private function binToStr(bin)
  33.     '二进制转为 string
  34.         dim i, iByt, sByt, bLen:bLen=lenB(bin)
  35.         for i=1 to bLen
  36.             sByt=midB(bin,i,1):iByt=ascB(sByt)
  37.             if iByt<128 then
  38.                 binToStr=binToStr&chr(iByt)
  39.             else:i=i+1
  40.                 if i<=bLen then binToStr=binToStr&chr(ascW(sByt&sByt))
  41.             end if
  42.         next 'shawl.qiu'
  43.     end function
  44. %>


2. 参考文献

2.1 Description of logical screen in file GIF
  http://semmix.pl/color/exgraf/eeg13.htm

2.2 GIF File Format Summary
  http://www.fileformat.info/format/gif/

3. 预览
gif file info:

#1-3/3 Header Signature: GIF
#4-6/3 GIF format version("87a" or "89a"): 89a
#7-8/2 Width of Display Screen in Pixels: 150
#9-10/2 Height of Display Screen in Pixels: 109
#11-11/1 BYTE Packed: 247
#12-12/1 BYTE BackgroundColor: 233
#13-13/1 BYTE AspectRatio: 0

附: 测试图片
gi_photo

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值