See header for documentation. */
| 2535 | |
| 2536 | /* See header for documentation. */ |
| 2537 | bool store_ncimage( |
| 2538 | const astcenc_image* output_image, |
| 2539 | const char* filename, |
| 2540 | int y_flip |
| 2541 | ) { |
| 2542 | const char* eptr = strrchr(filename, '.'); |
| 2543 | if (!eptr) |
| 2544 | { |
| 2545 | eptr = ".ktx"; // use KTX file format if we don't have an ending. |
| 2546 | } |
| 2547 | |
| 2548 | // Scan through descriptors until a matching storer is found |
| 2549 | image_storer storer { nullptr }; |
| 2550 | for (size_t i = 0; i < storer_descr_count; i++) |
| 2551 | { |
| 2552 | if (strcmp(eptr, storer_descs[i].ending1) == 0 |
| 2553 | || strcmp(eptr, storer_descs[i].ending2) == 0) |
| 2554 | { |
| 2555 | storer = storer_descs[i].storer_func; |
| 2556 | break; |
| 2557 | } |
| 2558 | } |
| 2559 | |
| 2560 | // Should never fail this, get_output_filename_enforced_bitness should have |
| 2561 | // acted as a preflight check |
| 2562 | if (!storer) |
| 2563 | { |
| 2564 | return false; |
| 2565 | } |
| 2566 | |
| 2567 | return storer(output_image, filename, y_flip); |
| 2568 | } |
| 2569 | |
| 2570 | /* ============================================================================ |
| 2571 | ASTC compressed file loading |
no outgoing calls
no test coverage detected