Reads a bitmap header from fp into header. Returns 0 on EOF or invalid * header, or nonzero on success. */
| 207 | * header, or nonzero on success. |
| 208 | */ |
| 209 | static int ReadHeader(bmp_header * header, FILE * fp) |
| 210 | { |
| 211 | if(!ReadUint8(&header->magic[0], fp)) return 0; |
| 212 | if(!ReadUint8(&header->magic[1], fp)) return 0; |
| 213 | |
| 214 | /* If it doesn't look like a bitmap header, don't even bother. */ |
| 215 | if(header->magic[0] != 0x42 /* 'B' */) return 0; |
| 216 | if(header->magic[1] != 0x4d /* 'M' */) return 0; |
| 217 | |
| 218 | if(!ReadLittleUint32(&header->file_size, fp)) return 0; |
| 219 | if(!ReadLittleUint32(&header->unused, fp)) return 0; |
| 220 | if(!ReadLittleUint32(&header->data_offset, fp)) return 0; |
| 221 | |
| 222 | return 1; |
| 223 | } |
| 224 | |
| 225 | /* How many bytes in the file are occupied by a header, by definition in the |
| 226 | * spec. Note that even though our definition logically matches the spec's, C |