您的位置:首页 > 编程语言 > ASP

ASP adodb.stream 取 .png 图片完整文件头信息 By shawl.qiu

2006-09-17 17:52 906 查看

ASP adodb.stream 取 .png 图片完整文件头信息 By shawl.qiu

摘要:
主要目的为取 .png文件 的高宽度信息, 使用ASP完成(不用外建组件).
进一步了解请查看相关文章.

作用:
本文使用 ASP 的内置组件 adodb.stream 取得 .png 的头部信息, 包括高宽度信息.

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

2. ASP adodb.stream 取 .gif 图片完整文件头&描述信息 By shawl.qiu
URL:   http://blog.csdn.net/btbtd/archive/2006/09/17/1232530.aspx

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

附: 测试图片 

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

1. 主内容: 完整例子
linenum
<%
    dim file:file=server.MapPath("a.png")
    dim temp
    dim stm
    set stm=createObject("adodb.stream")
        with stm
            .type = 1
            .open
            .loadFromFile file
            temp=.read
            .close
        end with    
    set stm=nothing
        response.write "png file info:<br/>"
        response.write "<br/>#2-4/3 Header Signature: "&binToStr(midB(temp,2,3))
        response.write "<br/>#12-16/4 First chunk(IHDR): "&binToStr(midB(temp,12,5))
        response.write "<br/>#17-20/4 Width: "&binToNumPng(midB(temp,17,4))
        response.write "<br/>#21-24/4 Height: "&binToNumPng(midB(temp,21,4))
        response.write "<br/>#25-25/1 Bit depth: "&binToNumPng(midB(temp,25,1))
        response.write "<br/>#26-26/1 ColorType: "&binToNumPng(midB(temp,26,1))
        response.write "<br/>#27-27/1 Compression method: "&binToNumPng(midB(temp,17,1))
        response.write "<br/>#28-28/1 Filter method: "&binToNumPng(midB(temp,28,1))
        response.write "<br/>#29-29/1 Interlace method: "&binToNumPng(midB(temp,29,1))
 
    private function binToNumPng(bin)
    '二进制转为 Numeric (png)
        dim i:binToNumPng=0
        for i=1 to lenB(bin)
            binToNumPng=binToNumPng*256+ascB(midB(bin,i,1))
        next 'shawl.qiu'
    end function
    
    private function binToStr(bin)
    '二进制转为 string (bmp|gif|png)
        dim i, iByt, sByt, bLen:bLen=lenB(bin)
        for i=1 to bLen
            sByt=midB(bin,i,1):iByt=ascB(sByt)
            if iByt<128 then
                binToStr=binToStr&chr(iByt)
            else:i=i+1
                if i<=bLen then binToStr=binToStr&chr(ascW(sByt&sByt))
            end if
        next 'shawl.qiu'
    end function
%>

2. 参考文献
PNG File Format Summary
URL:   http://www.fileformat.info/format/png/

3. 预览
png file info:

#2-4/3 Header Signature: PNG
#12-16/4 First chunk(IHDR): IHDR
#17-20/4 Width: 120
#21-24/4 Height: 146
#25-25/1 Bit depth: 8
#26-26/1 ColorType: 3
#27-27/1 Compression method: 0
#28-28/1 Filter method: 0
#29-29/1 Interlace method: 0

附: 测试图片 


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息