See header for documentation. */
| 2689 | |
| 2690 | /* See header for documentation. */ |
| 2691 | int store_cimage( |
| 2692 | const astc_compressed_image& img, |
| 2693 | const char* filename |
| 2694 | ) { |
| 2695 | astc_header hdr; |
| 2696 | hdr.magic[0] = ASTC_MAGIC_ID & 0xFF; |
| 2697 | hdr.magic[1] = (ASTC_MAGIC_ID >> 8) & 0xFF; |
| 2698 | hdr.magic[2] = (ASTC_MAGIC_ID >> 16) & 0xFF; |
| 2699 | hdr.magic[3] = (ASTC_MAGIC_ID >> 24) & 0xFF; |
| 2700 | |
| 2701 | hdr.block_x = static_cast<uint8_t>(img.block_x); |
| 2702 | hdr.block_y = static_cast<uint8_t>(img.block_y); |
| 2703 | hdr.block_z = static_cast<uint8_t>(img.block_z); |
| 2704 | |
| 2705 | hdr.dim_x[0] = img.dim_x & 0xFF; |
| 2706 | hdr.dim_x[1] = (img.dim_x >> 8) & 0xFF; |
| 2707 | hdr.dim_x[2] = (img.dim_x >> 16) & 0xFF; |
| 2708 | |
| 2709 | hdr.dim_y[0] = img.dim_y & 0xFF; |
| 2710 | hdr.dim_y[1] = (img.dim_y >> 8) & 0xFF; |
| 2711 | hdr.dim_y[2] = (img.dim_y >> 16) & 0xFF; |
| 2712 | |
| 2713 | hdr.dim_z[0] = img.dim_z & 0xFF; |
| 2714 | hdr.dim_z[1] = (img.dim_z >> 8) & 0xFF; |
| 2715 | hdr.dim_z[2] = (img.dim_z >> 16) & 0xFF; |
| 2716 | |
| 2717 | std::ofstream file(filename, std::ios::out | std::ios::binary); |
| 2718 | if (!file) |
| 2719 | { |
| 2720 | print_error("ERROR: File open failed '%s'\n", filename); |
| 2721 | return 1; |
| 2722 | } |
| 2723 | |
| 2724 | file.write(reinterpret_cast<char*>(&hdr), sizeof(astc_header)); |
| 2725 | file.write(reinterpret_cast<const char*>(img.data.data()), img.data.size()); |
| 2726 | return 0; |
| 2727 | } |
no test coverage detected