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

Function bm_iff_alloc_file

bitmap/iff.cpp:502–545  ·  view source on GitHub ↗

Loads an iff into a structure, allocs bitmap memory and converts 8 bit iff file into 16bit bitmap Returns bitmap handle on success, or -1 if failed

Source from the content-addressed store, hash-verified

500// 16bit bitmap
501// Returns bitmap handle on success, or -1 if failed
502int bm_iff_alloc_file(CFILE *ifile) {
503 int ret; // return code
504 iff_bitmap_header bmheader;
505 int src_bm;
506 char cur_sig[4];
507
508 // Ignore FORM and form length
509 cf_ReadInt(ifile);
510 cf_ReadInt(ifile);
511
512 // check if this an ILBM
513
514 for (int i = 0; i < 4; i++)
515 cur_sig[i] = cf_ReadByte(ifile);
516
517 if (strncmp("PBM ", cur_sig, 4)) {
518 mprintf(0, "IFF file isn't a PBM...aborting.\n");
519 return -1;
520 }
521 if (!strncmp("PBM ", cur_sig, 4))
522 bmheader.type = TYPE_PBM;
523 else
524 Int3(); // Huh? Get Jason!
525
526 ret = bm_iff_parse_file(ifile, &bmheader, NULL);
527
528 if (ret != IFF_NO_ERROR) {
529 mprintf(0, "Couldn't load IFF file.\n");
530 return -1;
531 }
532
533 // Alloc our bitmap
534 src_bm = bm_AllocBitmap(bmheader.w, bmheader.h, 0);
535 if (src_bm < 0) {
536 mem_free(bmheader.raw_data);
537 return -1;
538 }
539
540 // Convert our 8 bit bitmap to 16bit
541 bm_iff_convert_8_to_16(src_bm, &bmheader);
542 free(bmheader.raw_data);
543
544 return src_bm;
545}
546
547// returns number of bitmaps or -1 on error
548int bm_iff_read_animbrush(const char *ifilename, int *bm_list) {

Callers 1

bm_AllocLoadFileBitmapFunction · 0.85

Calls 5

cf_ReadIntFunction · 0.85
cf_ReadByteFunction · 0.85
bm_iff_parse_fileFunction · 0.85
bm_AllocBitmapFunction · 0.85
bm_iff_convert_8_to_16Function · 0.85

Tested by

no test coverage detected