一聚教程网:一个值得你收藏的教程网站

热门教程

如何获得jpg文件的实际尺寸呢?

时间:2022-06-30 11:11:31 编辑:袖梨 来源:一聚教程网

网上找的一段代码,把它编译成组件就可以用了,还支持png





'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 at http://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

热门栏目