Given a filename, loads either the bitmap or vclip found in that file. If type is not NULL, sets it to 1 if file is animation, otherwise sets it to zero
| 542 | // Given a filename, loads either the bitmap or vclip found in that file. If type |
| 543 | // is not NULL, sets it to 1 if file is animation, otherwise sets it to zero |
| 544 | int LoadTextureImage(const char *filename, int *type, int texture_size, int mipped, int pageable, int format) { |
| 545 | int anim = 0, bm_handle; |
| 546 | char extension[10]; |
| 547 | int w, h; |
| 548 | |
| 549 | int len = strlen(filename); |
| 550 | |
| 551 | if (len < 4) |
| 552 | return -1; |
| 553 | |
| 554 | strncpy(extension, &filename[len - 3], 5); |
| 555 | |
| 556 | if ((!strnicmp("oaf", extension, 3)) || (!strnicmp("ifl", extension, 3)) || (!strnicmp("abm", extension, 3))) |
| 557 | anim = 1; |
| 558 | |
| 559 | if (type != NULL) |
| 560 | *type = anim; |
| 561 | |
| 562 | if (anim) |
| 563 | bm_handle = AllocLoadVClip(IGNORE_TABLE(filename), texture_size, mipped, pageable, format); |
| 564 | else { |
| 565 | if (pageable) |
| 566 | bm_handle = bm_AllocLoadFileNoMemBitmap(IGNORE_TABLE(filename), mipped, format); |
| 567 | else |
| 568 | bm_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(filename), mipped, format); |
| 569 | |
| 570 | if (bm_handle < 1) |
| 571 | return -1; |
| 572 | |
| 573 | if (texture_size == NORMAL_TEXTURE) { |
| 574 | w = TEXTURE_WIDTH; |
| 575 | h = TEXTURE_HEIGHT; |
| 576 | } else if (texture_size == SMALL_TEXTURE) { |
| 577 | // Make small textures a quarter of the size of normal textures |
| 578 | w = TEXTURE_WIDTH / 2; |
| 579 | h = TEXTURE_HEIGHT / 2; |
| 580 | } else if (texture_size == TINY_TEXTURE) { |
| 581 | // Make these tinys an eigth of the size of normal textures |
| 582 | w = TEXTURE_WIDTH / 4; |
| 583 | h = TEXTURE_HEIGHT / 4; |
| 584 | } else if (texture_size == HUGE_TEXTURE) { |
| 585 | // Make these tinys an eigth of the size of normal textures |
| 586 | w = TEXTURE_WIDTH * 2; |
| 587 | h = TEXTURE_HEIGHT * 2; |
| 588 | } else |
| 589 | return bm_handle; |
| 590 | |
| 591 | // If differing size, resize! |
| 592 | if (!pageable && (w != bm_w(bm_handle, 0) || h != bm_h(bm_handle, 0))) { |
| 593 | int dest_bm; |
| 594 | |
| 595 | mprintf(0, "WARNING: Resizing bitmap %s from %d x %d to %d x %d!\n", GameBitmaps[bm_handle].name, |
| 596 | bm_w(bm_handle, 0), bm_h(bm_handle, 0), w, h); |
| 597 | |
| 598 | dest_bm = bm_AllocBitmap(w, h, mipped * ((w * h * 2) / 3)); |
| 599 | ASSERT(dest_bm >= 0); |
| 600 | |
| 601 | if (mipped) |
no test coverage detected