diff options
author | 2021-10-05 03:34:45 +1100 | |
---|---|---|
committer | 2021-10-05 03:34:45 +1100 | |
commit | aeb9eae87469e67bc6a91caf3840c34c11d959fc (patch) | |
tree | 45bffedf374dbce47caca633ad7bda547592e6c9 /src/tools/pngcmp.cpp | |
parent | 33723892a3f06e678d817b36aef84364c32848ec (diff) |
util: Further API cleanups: (#8661)
* Turned `core_file` into an implementation of `random_read_write`.
* Turned PNG errors into a standard error category.
* Added a helper for generating what look like derived classes on-the-fly.
Diffstat (limited to 'src/tools/pngcmp.cpp')
-rw-r--r-- | src/tools/pngcmp.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/tools/pngcmp.cpp b/src/tools/pngcmp.cpp index 624023425af..480f9fadb14 100644 --- a/src/tools/pngcmp.cpp +++ b/src/tools/pngcmp.cpp @@ -8,16 +8,19 @@ ****************************************************************************/ +#include "corefile.h" +#include "png.h" + +#include "osdfile.h" + +#include <cassert> +#include <cctype> #include <cstdio> #include <cstdlib> #include <cstring> -#include <cctype> -#include <cassert> -#include "osdfile.h" -#include "png.h" - #include <new> + /*************************************************************************** CONSTANTS & DEFINES ***************************************************************************/ @@ -74,7 +77,6 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img int width, height, maxwidth; util::core_file::ptr file; std::error_condition filerr; - util::png_error pngerr; int error = 100; /* open the source image */ @@ -86,11 +88,11 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img } /* load the source image */ - pngerr = util::png_read_bitmap(*file, bitmap1); + filerr = util::png_read_bitmap(*file, bitmap1); file.reset(); - if (pngerr != util::png_error::NONE) + if (filerr) { - printf("Could not read %s (%d)\n", imgfile1.c_str(), int(pngerr)); + printf("Could not read %s (%s)\n", imgfile1.c_str(), filerr.message().c_str()); goto error; } @@ -103,11 +105,11 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img } /* load the source image */ - pngerr = util::png_read_bitmap(*file, bitmap2); + filerr = util::png_read_bitmap(*file, bitmap2); file.reset(); - if (pngerr != util::png_error::NONE) + if (filerr) { - printf("Could not read %s (%d)\n", imgfile2.c_str(), int(pngerr)); + printf("Could not read %s (%s)\n", imgfile2.c_str(), filerr.message().c_str()); goto error; } @@ -176,11 +178,11 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img printf("Could not open %s (%s)\n", outfilename.c_str(), filerr.message().c_str()); goto error; } - pngerr = util::png_write_bitmap(*file, nullptr, finalbitmap, 0, nullptr); + filerr = util::png_write_bitmap(*file, nullptr, finalbitmap, 0, nullptr); file.reset(); - if (pngerr != util::png_error::NONE) + if (filerr) { - printf("Could not write %s (%d)\n", outfilename.c_str(), int(pngerr)); + printf("Could not write %s (%s)\n", outfilename.c_str(), filerr.message().c_str()); goto error; } } |