summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/pngcmp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/pngcmp.cpp')
-rw-r--r--src/tools/pngcmp.cpp72
1 files changed, 37 insertions, 35 deletions
diff --git a/src/tools/pngcmp.cpp b/src/tools/pngcmp.cpp
index af104e928b3..480f9fadb14 100644
--- a/src/tools/pngcmp.cpp
+++ b/src/tools/pngcmp.cpp
@@ -8,16 +8,19 @@
****************************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <assert.h>
-#include "osdcore.h"
+#include "corefile.h"
#include "png.h"
+#include "osdfile.h"
+
+#include <cassert>
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <new>
+
/***************************************************************************
CONSTANTS & DEFINES
***************************************************************************/
@@ -73,56 +76,55 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img
bitmap_argb32 finalbitmap;
int width, height, maxwidth;
util::core_file::ptr file;
- osd_file::error filerr;
- png_error pngerr;
+ std::error_condition filerr;
int error = 100;
- bool bitmaps_differ;
- int x, y;
/* open the source image */
filerr = util::core_file::open(imgfile1, OPEN_FLAG_READ, file);
- if (filerr != osd_file::error::NONE)
+ if (filerr)
{
- printf("Could not open %s (%d)\n", imgfile1.c_str(), int(filerr));
+ printf("Could not open %s (%s)\n", imgfile1.c_str(), filerr.message().c_str());
goto error;
}
/* load the source image */
- pngerr = png_read_bitmap(*file, bitmap1);
+ filerr = util::png_read_bitmap(*file, bitmap1);
file.reset();
- if (pngerr != PNGERR_NONE)
+ if (filerr)
{
- printf("Could not read %s (%d)\n", imgfile1.c_str(), pngerr);
+ printf("Could not read %s (%s)\n", imgfile1.c_str(), filerr.message().c_str());
goto error;
}
/* open the source image */
filerr = util::core_file::open(imgfile2, OPEN_FLAG_READ, file);
- if (filerr != osd_file::error::NONE)
+ if (filerr)
{
- printf("Could not open %s (%d)\n", imgfile2.c_str(), int(filerr));
+ printf("Could not open %s (%s)\n", imgfile2.c_str(), filerr.message().c_str());
goto error;
}
/* load the source image */
- pngerr = png_read_bitmap(*file, bitmap2);
+ filerr = util::png_read_bitmap(*file, bitmap2);
file.reset();
- if (pngerr != PNGERR_NONE)
+ if (filerr)
{
- printf("Could not read %s (%d)\n", imgfile2.c_str(), pngerr);
+ printf("Could not read %s (%s)\n", imgfile2.c_str(), filerr.message().c_str());
goto error;
}
/* if the sizes are different, we differ; otherwise start off assuming we are the same */
+ bool bitmaps_differ;
bitmaps_differ = (bitmap2.width() != bitmap1.width() || bitmap2.height() != bitmap1.height());
/* compare scanline by scanline */
- for (y = 0; y < bitmap2.height() && !bitmaps_differ; y++)
+ for (int y = 0; y < bitmap2.height() && !bitmaps_differ; y++)
{
- uint32_t *base = &bitmap1.pix32(y);
- uint32_t *curr = &bitmap2.pix32(y);
+ uint32_t const *base = &bitmap1.pix(y);
+ uint32_t const *curr = &bitmap2.pix(y);
/* scan the scanline */
+ int x;
for (x = 0; x < bitmap2.width(); x++)
if (*base++ != *curr++)
break;
@@ -148,16 +150,16 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img
/* now copy and compare each set of bitmaps */
int curheight = std::max(bitmap1.height(), bitmap2.height());
/* iterate over rows in these bitmaps */
- for (y = 0; y < curheight; y++)
+ for (int y = 0; y < curheight; y++)
{
- uint32_t *src1 = (y < bitmap1.height()) ? &bitmap1.pix32(y) : nullptr;
- uint32_t *src2 = (y < bitmap2.height()) ? &bitmap2.pix32(y) : nullptr;
- uint32_t *dst1 = &finalbitmap.pix32(y);
- uint32_t *dst2 = &finalbitmap.pix32(y, bitmap1.width() + BITMAP_SPACE);
- uint32_t *dstdiff = &finalbitmap.pix32(y, bitmap1.width() + BITMAP_SPACE + maxwidth + BITMAP_SPACE);
+ uint32_t const *src1 = (y < bitmap1.height()) ? &bitmap1.pix(y) : nullptr;
+ uint32_t const *src2 = (y < bitmap2.height()) ? &bitmap2.pix(y) : nullptr;
+ uint32_t *dst1 = &finalbitmap.pix(y);
+ uint32_t *dst2 = &finalbitmap.pix(y, bitmap1.width() + BITMAP_SPACE);
+ uint32_t *dstdiff = &finalbitmap.pix(y, bitmap1.width() + BITMAP_SPACE + maxwidth + BITMAP_SPACE);
/* now iterate over columns */
- for (x = 0; x < maxwidth; x++)
+ for (int x = 0; x < maxwidth; x++)
{
int pix1 = -1, pix2 = -2;
@@ -171,16 +173,16 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img
/* write the final PNG */
filerr = util::core_file::open(outfilename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, file);
- if (filerr != osd_file::error::NONE)
+ if (filerr)
{
- printf("Could not open %s (%d)\n", outfilename.c_str(), int(filerr));
+ printf("Could not open %s (%s)\n", outfilename.c_str(), filerr.message().c_str());
goto error;
}
- pngerr = png_write_bitmap(*file, nullptr, finalbitmap, 0, nullptr);
+ filerr = util::png_write_bitmap(*file, nullptr, finalbitmap, 0, nullptr);
file.reset();
- if (pngerr != PNGERR_NONE)
+ if (filerr)
{
- printf("Could not write %s (%d)\n", outfilename.c_str(), pngerr);
+ printf("Could not write %s (%s)\n", outfilename.c_str(), filerr.message().c_str());
goto error;
}
}