MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / bm_iff_parse_file

Function bm_iff_parse_file

bitmap/iff.cpp:369–472  ·  view source on GitHub ↗

read an PBM Pass pointer to opened file, and to empty bitmap_header structure, and form length

Source from the content-addressed store, hash-verified

367// read an PBM
368// Pass pointer to opened file, and to empty bitmap_header structure, and form length
369int bm_iff_parse_file(CFILE *ifile, iff_bitmap_header *bmheader, iff_bitmap_header *prev_bm) {
370 uint32_t sig, len;
371 int done = 0;
372
373 while (!done) {
374 if (cfeof(ifile)) {
375 done = 1;
376 continue;
377 }
378
379 sig = bm_iff_get_sig(ifile);
380
381 len = cf_ReadInt(ifile, false);
382
383 switch (sig) {
384 case IFF_SIG_FORM: {
385 int newsig = bm_iff_get_sig(ifile);
386 bmheader->type = TYPE_PBM;
387 break;
388 }
389 case IFF_SIG_BMHD: {
390 int ret;
391
392 ret = bm_iff_parse_bmhd(ifile, len, bmheader);
393 if (ret != IFF_NO_ERROR)
394 return ret;
395 else {
396
397 bmheader->raw_data = (uint8_t *)mem_malloc(bmheader->w * bmheader->h);
398 if (!bmheader->raw_data)
399 return IFF_NO_MEM;
400 }
401
402 } break;
403 case IFF_SIG_ANHD: {
404
405 if (!prev_bm) {
406 Int3();
407 return IFF_CORRUPT;
408 }
409
410 bmheader->w = prev_bm->w;
411 bmheader->h = prev_bm->h;
412 bmheader->type = prev_bm->type;
413 bmheader->raw_data = (uint8_t *)mem_malloc(bmheader->w * bmheader->h);
414
415 if (!bmheader->raw_data)
416 return IFF_NO_MEM;
417
418 memcpy(bmheader->raw_data, prev_bm->raw_data, bmheader->w * bmheader->h);
419
420 if (len & 1)
421 len++;
422 bm_iff_skip_chunk(ifile, len);
423
424 break;
425 }
426

Callers 2

bm_iff_alloc_fileFunction · 0.85
bm_iff_read_animbrushFunction · 0.85

Calls 8

cfeofFunction · 0.85
bm_iff_get_sigFunction · 0.85
cf_ReadIntFunction · 0.85
bm_iff_parse_bmhdFunction · 0.85
bm_iff_skip_chunkFunction · 0.85
cf_ReadByteFunction · 0.85
bm_iff_parse_bodyFunction · 0.85
bm_iff_parse_deltaFunction · 0.85

Tested by

no test coverage detected