diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-06-04 21:14:45 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-06-04 21:14:45 +0100 |
commit | 6e94848aec5d42eed5f9e1f5548ade26915ce90b (patch) | |
tree | b6cf5bc39f7da4c8853491da4008c29406b135f3 /gfx/image.cpp | |
parent | Tidy of glRef (diff) | |
download | ilt-6e94848aec5d42eed5f9e1f5548ade26915ce90b.tar.bz2 ilt-6e94848aec5d42eed5f9e1f5548ade26915ce90b.tar.xz ilt-6e94848aec5d42eed5f9e1f5548ade26915ce90b.zip |
Tidy many stringy messes with std::format
Diffstat (limited to 'gfx/image.cpp')
-rw-r--r-- | gfx/image.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gfx/image.cpp b/gfx/image.cpp index fb86cb6..3b63054 100644 --- a/gfx/image.cpp +++ b/gfx/image.cpp @@ -1,5 +1,6 @@ #include "image.h" #include <cstddef> +#include <format> #include <stb/stb_image.h> #include <stdexcept> @@ -13,7 +14,7 @@ Image::Image(const char * fileName, int flags) : width {}, height {}, numCompone numComponents = static_cast<unsigned int>(nc); if (!bytes) { - throw std::runtime_error {std::string {"Unable to load image: "} + fileName}; + throw std::runtime_error {std::format("Unable to load image: {}", fileName)}; } data = {bytes, static_cast<size_t>(width * height * numComponents)}; @@ -29,7 +30,8 @@ Image::Image(std::span<unsigned char> buffer, int flags) numComponents = static_cast<unsigned int>(nc); if (!bytes) { - throw std::runtime_error {"Unable to load image from memory buffer "}; + throw std::runtime_error {std::format("Unable to load image from memory buffer @ {} ({} bytes)", + static_cast<void *>(buffer.data()), buffer.size_bytes())}; } data = {bytes, static_cast<size_t>(width * height * numComponents)}; |