diff options
author | Thomas Bernard <miniupnp@free.fr> | 2020-04-03 21:53:49 +0200 |
---|---|---|
committer | Thomas Bernard <miniupnp@free.fr> | 2021-01-15 21:08:23 +0100 |
commit | 3739202651edca42366d2a223a07535dce359f60 (patch) | |
tree | 41de0b329833f111833f611f6701a5a8d01e5fb9 /tools/tiffcmp.c | |
parent | 7a20316754295e7aae63fad50809d405cedfa042 (diff) | |
download | libtiff-git-3739202651edca42366d2a223a07535dce359f60.tar.gz |
tiffcmp: fix comparaison with pixels that are fractional number of bytes
For exemple : 4bits per sample + 3 samples per pixel => 1.5 bytes per pixel
Diffstat (limited to 'tools/tiffcmp.c')
-rw-r--r-- | tools/tiffcmp.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/tiffcmp.c b/tools/tiffcmp.c index 93b535a2..88273e65 100644 --- a/tools/tiffcmp.c +++ b/tools/tiffcmp.c @@ -333,7 +333,6 @@ ContigCompare(int sample, uint32 row, unsigned char* p1, unsigned char* p2, tsize_t size) { uint32 pix; - int ppb = 8 / bitspersample; int samples_to_test; if (memcmp(p1, p2, size) == 0) @@ -345,9 +344,10 @@ ContigCompare(int sample, uint32 row, case 1: case 2: case 4: case 8: { unsigned char *pix1 = p1, *pix2 = p2; + unsigned bits = 0; - for (pix = 0; pix < imagewidth; pix += ppb) { - int s; + for (pix = 0; pix < imagewidth; pix++) { + int s; for(s = 0; s < samples_to_test; s++) { if (*pix1 != *pix2) { @@ -357,8 +357,10 @@ ContigCompare(int sample, uint32 row, PrintIntDiff(row, sample, pix, *pix1, *pix2); } - pix1++; - pix2++; + bits += bitspersample; + pix1 += (bits / 8); + pix2 += (bits / 8); + bits &= 7; } } break; @@ -449,7 +451,7 @@ PrintIntDiff(uint32 row, int sample, uint32 pix, uint32 w1, uint32 w2) if ((w1 & mask2) ^ (w2 & mask2)) { printf( "Scanline %lu, pixel %lu, sample %d: %01x %01x\n", - (unsigned long) row, + (unsigned long) row, (unsigned long) pix, sample, (unsigned int)((w1 >> s) & mask1), |