/ * DibReadHeader: Read the initial bitmap information from the given file handle * into the given Bitmaps structure. Set shrink to the shrink factor. * Return True on success. */
| 173 | * Return True on success. |
| 174 | */ |
| 175 | Bool DibReadHeader(file_node *f, Bitmaps *b, BYTE *shrink) |
| 176 | { |
| 177 | int i, temp; |
| 178 | BYTE byte; |
| 179 | |
| 180 | // Check magic number |
| 181 | for (i=0; i < 4; i++) |
| 182 | if (MappedFileRead(f, &byte, 1) != 1 || byte != magic[i]) |
| 183 | return False; |
| 184 | |
| 185 | // Check version |
| 186 | if (MappedFileRead(f, &version, 4) != 4 || version < BGF_VERSION) |
| 187 | { |
| 188 | dprintf("Bad BGF version %d\n", version); |
| 189 | return False; |
| 190 | } |
| 191 | |
| 192 | // Read bitmap name |
| 193 | if (MappedFileRead(f, &b->name, MAX_BITMAPNAME) != MAX_BITMAPNAME) |
| 194 | return False; |
| 195 | |
| 196 | // Read # of bitmaps |
| 197 | if (MappedFileRead(f, &b->num_bitmaps, 4) != 4) |
| 198 | return False; |
| 199 | |
| 200 | // Read # of bitmap groups |
| 201 | if (MappedFileRead(f, &b->num_groups, 4) != 4) |
| 202 | return False; |
| 203 | |
| 204 | // Read max # of indices in a group |
| 205 | if (MappedFileRead(f, &b->max_indices, 4) != 4) |
| 206 | return False; |
| 207 | b->max_indices++; // Leave room to store the # of indices actually present in a group |
| 208 | |
| 209 | // Read "shrink factor" of bitmaps |
| 210 | if (MappedFileRead(f, &temp, 4) != 4) |
| 211 | return False; |
| 212 | *shrink = (BYTE) temp; |
| 213 | if (*shrink == 0) |
| 214 | *shrink = 1; // Avoid divide by zero errors elsewhere |
| 215 | |
| 216 | return True; |
| 217 | } |
| 218 | /************************************************************************/ |
| 219 | /* |
| 220 | * DibReadBits: Read bits of an image into the given PDIB. The file pointer |
no test coverage detected