From a17169a406e141ac8acdf7819ec75c9b7c65f385 Mon Sep 17 00:00:00 2001 From: "Ignacio R. Morelle" Date: Thu, 9 Apr 2015 22:48:39 -0300 Subject: [PATCH] Make image::save_image() return the success state --- src/image.cpp | 11 +++++------ src/image.hpp | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/image.cpp b/src/image.cpp index 1f83f7e1088c..767281f5f549 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -1256,27 +1256,26 @@ bool precached_file_exists(const std::string& file) return false; } -void save_image(const locator & i_locator, const std::string & filename) +bool save_image(const locator & i_locator, const std::string & filename) { - save_image(get_image(i_locator), filename); + return save_image(get_image(i_locator), filename); } -void save_image(const surface & surf, const std::string & filename) +bool save_image(const surface & surf, const std::string & filename) { #ifdef HAVE_LIBPNG if (!filesystem::ends_with(filename, ".bmp")) { LOG_DP << "Writing a png image to " << filename << std::endl; surface tmp = SDL_PNGFormatAlpha(surf.get()); - SDL_SavePNG(tmp, filename.c_str()); //SDL_SavePNG_RW(tmp, filesystem::load_RWops(filename), 1); //1 means to close the file (RWops) when we finish //^ This doesn't work, load_RWops is only for reading not writing - return; + return SDL_SavePNG(tmp, filename.c_str()) == 0; } #endif LOG_DP << "Writing a bmp image to " << filename << std::endl; - SDL_SaveBMP(surf, filename.c_str()); + return SDL_SaveBMP(surf, filename.c_str()) == 0; } std::string describe_versions() diff --git a/src/image.hpp b/src/image.hpp index adb5cbc89a86..65ee25e5607d 100644 --- a/src/image.hpp +++ b/src/image.hpp @@ -251,8 +251,8 @@ namespace image { /// initialize any private data, e.g. algorithm choices from preferences bool update_from_preferences(); - void save_image(const locator& i_locator, const std::string& outfile); - void save_image(const surface& surf, const std::string& outfile); + bool save_image(const locator& i_locator, const std::string& outfile); + bool save_image(const surface& surf, const std::string& outfile); } #endif