| 241 | } |
| 242 | |
| 243 | static ILboolean load_ilbm(void) |
| 244 | { |
| 245 | SDL_RWops* src = 0; |
| 246 | struct { Uint8 r; Uint8 g; Uint8 b; } scratch_pal[MAXCOLORS]; |
| 247 | ILenum format; /* IL_RGB (ham or 24bit) or IL_COLOUR_INDEX */ |
| 248 | |
| 249 | int start; |
| 250 | Uint8 id[4], pbm, colormap[MAXCOLORS*3], *MiniBuf, *ptr, count, color, msk; |
| 251 | Uint32 size, bytesloaded, nbcolors; |
| 252 | Uint32 i, j, bytesperline, nbplanes, plane, h; |
| 253 | Uint32 remainingbytes; |
| 254 | Uint32 width; |
| 255 | BMHD bmhd; |
| 256 | char *error; |
| 257 | Uint8 flagHAM,flagEHB; |
| 258 | |
| 259 | error = NULL; |
| 260 | MiniBuf = NULL; |
| 261 | |
| 262 | start = SDL_RWtell(src); |
| 263 | if ( !SDL_RWread( src, id, 4, 1 ) ) |
| 264 | { |
| 265 | error=(char*)"error reading IFF chunk"; |
| 266 | goto done; |
| 267 | } |
| 268 | |
| 269 | /* Should be the size of the file minus 4+4 ( 'FORM'+size ) */ |
| 270 | if ( !SDL_RWread( src, &size, 4, 1 ) ) |
| 271 | { |
| 272 | error=(char*)"error reading IFF chunk size"; |
| 273 | goto done; |
| 274 | } |
| 275 | |
| 276 | /* As size is not used here, no need to swap it */ |
| 277 | |
| 278 | if ( memcmp( id, "FORM", 4 ) != 0 ) |
| 279 | { |
| 280 | ilSetError(IL_INVALID_FILE_HEADER); |
| 281 | error=(char*)"not a IFF file"; |
| 282 | goto done; |
| 283 | } |
| 284 | |
| 285 | if ( !SDL_RWread( src, id, 4, 1 ) ) |
| 286 | { |
| 287 | error=(char*)"error reading IFF chunk"; |
| 288 | goto done; |
| 289 | } |
| 290 | |
| 291 | pbm = 0; |
| 292 | |
| 293 | /* File format : PBM=Packed Bitmap, ILBM=Interleaved Bitmap */ |
| 294 | if ( !memcmp( id, "PBM ", 4 ) ) pbm = 1; |
| 295 | else if ( memcmp( id, "ILBM", 4 ) ) |
| 296 | { |
| 297 | ilSetError(IL_INVALID_FILE_HEADER); |
| 298 | error=(char*)"not a IFF picture"; |
| 299 | goto done; |
| 300 | } |
no test coverage detected