• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    一個取圖片尺寸的類,支持jpg,gif,png

    發布: 2007-7-14 19:37 | 作者: 佚名    | 來源: 網絡轉載     | 查看: 27次 | 進入軟件測試論壇討論

    領測軟件測試網 'I have released this source code into the public domain. You may use it
    'with no strings attached.
    'Just call GetImageSize with a string containing the filename, and
    'it will return a user defined type 'ImageSize' (see below)
    'Return values of 0 indicate an error of some sort. The error handling
    'in this module is limited. There is *NO* error handling on the test
    'form. This routine is limited to X or Y sizes of 32767 pixels, but that
    'should not be a problem.

    'Check back athttp://www.qtm.net/~davidc
    'I may add support for more file types.

    'supported in this version:
    'JPEG
    'GIF
    'PNG

    'This routine does not require any royalty fees for Unisys as it
    'does nothing with the compressed part of GIF files. It simply reads
    '4 bytes to determine image size.

    Option Explicit
    Public WImg As Long
    Public HImg As Long
    Public Type ImageSize
    Width As Long
    Height As Long
    End Type

    Public Sub GetImageSize(sFileName As String)
    On Error Resume Next 'you'll want to change this
    Dim iFN As Integer
    Dim bTemp(3) As Byte
    Dim lFlen As Long
    Dim lPos As Long
    Dim bHmsb As Byte
    Dim bHlsb As Byte
    Dim bWmsb As Byte
    Dim bWlsb As Byte
    Dim bBuf(7) As Byte
    Dim bDone As Byte
    Dim iCount As Integer

    lFlen = FileLen(sFileName)
    iFN = FreeFile
    Open sFileName For Binary As iFN
    Get #iFN, 1, bTemp()

    'PNG file
    If bTemp(0) = &H89 And bTemp(1) = &H50 And bTemp(2) = &H4E _
    And bTemp(3) = &H47 Then
    Get #iFN, 19, bWmsb
    Get #iFN, 20, bWlsb
    Get #iFN, 23, bHmsb
    Get #iFN, 24, bHlsb
    'GetImageSize.Width = CombineBytes(bWlsb, bWmsb)
    'GetImageSize.Height = CombineBytes(bHlsb, bHmsb)
    WImg = CombineBytes(bWlsb, bWmsb)
    HImg = CombineBytes(bHlsb, bHmsb)
    End If

    'GIF file
    If bTemp(0) = &H47 And bTemp(1) = &H49 And bTemp(2) = &H46 _
    And bTemp(3) = &H38 Then
    Get #iFN, 7, bWlsb
    Get #iFN, 8, bWmsb
    Get #iFN, 9, bHlsb
    Get #iFN, 10, bHmsb
    'GetImageSize.Width = CombineBytes(bWlsb, bWmsb)
    'GetImageSize.Height = CombineBytes(bHlsb, bHmsb)
    WImg = CombineBytes(bWlsb, bWmsb)
    HImg = CombineBytes(bHlsb, bHmsb)
    End If


    'JPEG file
    If bTemp(0) = &HFF And bTemp(1) = &HD8 And bTemp(2) = &HFF Then
    Debug.Print "JPEG"
    lPos = 3
    Do
    Do
    Get #iFN, lPos, bBuf(1)
    Get #iFN, lPos + 1, bBuf(2)
    lPos = lPos + 1
    Loop Until (bBuf(1) = &HFF And bBuf(2) <> &HFF) Or lPos > lFlen

    For iCount = 0 To 7
    Get #iFN, lPos + iCount, bBuf(iCount)
    Next iCount
    If bBuf(0) >= &HC0 And bBuf(0) <= &HC3 Then
    bHmsb = bBuf(4)
    bHlsb = bBuf(5)
    bWmsb = bBuf(6)
    bWlsb = bBuf(7)
    bDone = 1
    Else
    lPos = lPos + (CombineBytes(bBuf(2), bBuf(1))) + 1
    End If
    Loop While lPos < lFlen And bDone = 0
    'GetImageSize.Width = CombineBytes(bWlsb, bWmsb)
    'GetImageSize.Height = CombineBytes(bHlsb, bHmsb)
    WImg = CombineBytes(bWlsb, bWmsb)
    HImg = CombineBytes(bHlsb, bHmsb)
    End If
    Close iFN

    End Sub
    Private Function CombineBytes(lsb As Byte, msb As Byte) As Long
    CombineBytes = CLng(lsb + (msb * 256))
    End Function


    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備2023014753號-2
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>