ReadGIF
In Class PicGIF
53 Private Function ReadGIF(ByVal GIFFilename As String) As Boolean
54 ' Reads a GIF file and retrieves image information
55 ' [GIFFilename] Name of file to read
56 ' Return value:
57 ' True - GIF file was read and information retrieved
58 ' False - Error or invalid file
59
60 Dim ColorResolution As Integer ' Number of color bits in the file (1..8)
61 Dim FileNr As Integer ' Number of open data file
62
63 StoredFilename = GIFFilename ' Store Filename for later retrieval
64 FileOK = False ' Clear the FileOK flag until we have successfully read a valid .gif file
65
66 ' Open the .gif file for binary read access
67 FileNr = FreeFile
68 Open GIFFilename For Binary Access Read Lock Write As #FileNr
69
70 If LOF(FileNr) > Len(Signature) + Len(LogicalScreenDescriptor) Then
71 ' The file size is "enough"
72
73 ' Read 6 GIF signature bytes, which must be either GIF87a or GIF89a in ASCII
74 Get #FileNr, 1, Signature
75 If Signature = "GIF87a" Or Signature = "GIF89a" Then
76 ' Signature bytes OK
77
78 ' Read logical screen descriptor, which contains picture size and color info
79 Get #FileNr, , LogicalScreenDescriptor
80
81 ' Determine max number of colors
82 ColorResolution = (LogicalScreenDescriptor.Packed And (64 + 32 + 16)) \ 16 + 1
83 MaxColors = 2 ^ ColorResolution
84
85 FileOK = True
86 ReadGIF = True
87 End If
88 End If
89 Close FileNr
Assigned value not used: FileNr - Integer
90 FileNr = 0
91
92 End Function
93
94
95
Called by
– IPicInfo_ReadFile