Skip to content

Commit

Permalink
Use std::format in PNG code
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Feb 23, 2024
1 parent 6db2d4b commit 7252144
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/jngl/sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,23 @@ Finally Sprite::LoadPNG(std::string_view filename, FILE* const fp, const bool ha
// Read in some of the signature bytes
if (fread(buf, 1, PNG_BYTES_TO_CHECK, fp) != PNG_BYTES_TO_CHECK ||
png_sig_cmp(buf, png_size_t(0), PNG_BYTES_TO_CHECK) != 0) {
throw std::runtime_error(std::string("Error reading signature bytes. (" + filename + ")"));
throw std::runtime_error(std::format("Error reading signature bytes. ({})", filename));
}

png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (!png_ptr) {
throw std::runtime_error(std::string("libpng error while reading (" + filename + ")"));
throw std::runtime_error(std::format("libpng error while reading ({})", filename));
}

png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
throw std::runtime_error(std::string("libpng error while reading (" + filename + ")"));
throw std::runtime_error(std::format("libpng error while reading ({})", filename));
}

if (setjmp(png_jmpbuf(png_ptr))) {
// Free all of the memory associated with the png_ptr and info_ptr
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
throw std::runtime_error(std::string("Error reading file. (" + filename + ")"));
throw std::runtime_error(std::format("Error reading file. ({})", filename));
}
png_init_io(png_ptr, fp);
png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK);
Expand Down

0 comments on commit 7252144

Please sign in to comment.