diff options
Diffstat (limited to 'src/tools/pngcmp.cpp')
-rw-r--r-- | src/tools/pngcmp.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/tools/pngcmp.cpp b/src/tools/pngcmp.cpp index eb56d4a7ee7..714700a3824 100644 --- a/src/tools/pngcmp.cpp +++ b/src/tools/pngcmp.cpp @@ -74,10 +74,8 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img int width, height, maxwidth; util::core_file::ptr file; osd_file::error filerr; - png_error pngerr; + util::png_error pngerr; int error = 100; - bool bitmaps_differ; - int x, y; /* open the source image */ filerr = util::core_file::open(imgfile1, OPEN_FLAG_READ, file); @@ -88,11 +86,11 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img } /* load the source image */ - pngerr = png_read_bitmap(*file, bitmap1); + pngerr = util::png_read_bitmap(*file, bitmap1); file.reset(); - if (pngerr != PNGERR_NONE) + if (pngerr != util::png_error::NONE) { - printf("Could not read %s (%d)\n", imgfile1.c_str(), pngerr); + printf("Could not read %s (%d)\n", imgfile1.c_str(), int(pngerr)); goto error; } @@ -105,24 +103,26 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img } /* load the source image */ - pngerr = png_read_bitmap(*file, bitmap2); + pngerr = util::png_read_bitmap(*file, bitmap2); file.reset(); - if (pngerr != PNGERR_NONE) + if (pngerr != util::png_error::NONE) { - printf("Could not read %s (%d)\n", imgfile2.c_str(), pngerr); + printf("Could not read %s (%d)\n", imgfile2.c_str(), int(pngerr)); 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 +148,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; @@ -176,11 +176,11 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img printf("Could not open %s (%d)\n", outfilename.c_str(), int(filerr)); goto error; } - pngerr = png_write_bitmap(*file, nullptr, finalbitmap, 0, nullptr); + pngerr = util::png_write_bitmap(*file, nullptr, finalbitmap, 0, nullptr); file.reset(); - if (pngerr != PNGERR_NONE) + if (pngerr != util::png_error::NONE) { - printf("Could not write %s (%d)\n", outfilename.c_str(), pngerr); + printf("Could not write %s (%d)\n", outfilename.c_str(), int(pngerr)); goto error; } } |