* @brief Utility to generate a slice file name from a pattern. * * Convert "foo/bar.png" into "foo/bar_ .png" * * @param basename The base pattern; must contain a file extension. * @param index The slice index. * @param error Set to false on success, true on error (no extension found). * * @return The slice file name. */
| 309 | * @return The slice file name. |
| 310 | */ |
| 311 | static std::string get_slice_filename( |
| 312 | const std::string& basename, |
| 313 | unsigned int index, |
| 314 | bool& error |
| 315 | ) { |
| 316 | size_t sep = basename.find_last_of('.'); |
| 317 | if (sep == std::string::npos) |
| 318 | { |
| 319 | error = true; |
| 320 | return ""; |
| 321 | } |
| 322 | |
| 323 | std::string base = basename.substr(0, sep); |
| 324 | std::string ext = basename.substr(sep); |
| 325 | std::string name = base + "_" + std::to_string(index) + ext; |
| 326 | error = false; |
| 327 | return name; |
| 328 | } |
| 329 | |
| 330 | /** |
| 331 | * @brief Load a non-astc image file from memory. |