Not a Member Yet,
Click here to Register
How do you like the new design?

ID: 347
Viewed: 2724
Added: Aug 19, 2002
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo

User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

reads the gif header and gets the information from it

Highlight all by clicking in box

Highlight All
Width As Long
Height As Long
End Type

Public Function GetGIFInfo(ByVal FileName As String) As BITMAPINFO
Dim bChar As Byte
Dim i As Integer
Dim DotPos As Integer
Dim Header As String
Dim blExit As Boolean
Dim a As String, b As String
Dim ImgWidth As Integer
Dim ImgHeight As Integer
Dim ImgSize As String
Dim fnum As Integer

On Error Resume Next
fnum = FreeFile
Open FileName For Binary As #fnum

ImgSize = LOF(fnum) / 1024

DotPos = InStr(ImgSize, ",")
ImgSize = Left(ImgSize, DotPos - 1) '& "," _
& Left(Right(ImgSize,Len(ImgSize) - DotPos), 2)

For i = 0 To 5
Get #fnum, , bChar
Header = Header + Chr(bChar)
Next i

If Left(Header, 3) <> "GIF" Then
MsgBox FileName & ": not a GIF file"
Close #fnum
Exit Function
End If

Get #fnum, , bChar
a = a + Chr(bChar)
Get #fnum, , bChar
a = a + Chr(bChar)

ImgWidth = CInt(Asc(Left(a, 1)) + 256 * Asc(Right(a, 1)))

Get #fnum, , bChar
b = b + Chr(bChar)
Get #fnum, , bChar
b = b + Chr(bChar)

ImgHeight = CInt(Asc(Left(b, 1)) + 256 * Asc(Right(b, 1)))

Close #fnum

With ImageInfo
.Width = ImgWidth
.Height = ImgHeight
End With

GetGIFInfo = ImageInfo
End Function;

No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2018 All Rights Reserved. Conditions