diff options
author | Thomas Bernard <miniupnp@free.fr> | 2020-04-05 01:19:10 +0200 |
---|---|---|
committer | Thomas Bernard <miniupnp@free.fr> | 2020-04-05 01:19:10 +0200 |
commit | aa9d52ac2b02ad32b23232b7406b889673ebbb16 (patch) | |
tree | ad243de0a6354cbfaa0daca002de3b8b166b8a51 /tools/tiffinfo.c | |
parent | 691427ea8dd175db1671c77d496385e1c4760712 (diff) | |
download | libtiff-git-aa9d52ac2b02ad32b23232b7406b889673ebbb16.tar.gz |
tiffinfo: showdata for tiled images
Diffstat (limited to 'tools/tiffinfo.c')
-rw-r--r-- | tools/tiffinfo.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/tiffinfo.c b/tools/tiffinfo.c index a15894b9..30b3d3ba 100644 --- a/tools/tiffinfo.c +++ b/tools/tiffinfo.c @@ -459,6 +459,50 @@ static void TIFFReadRawDataTiled(TIFF* tif, int bitrev) { const char* what = "Tile"; + uint32 ntiles = TIFFNumberOfTiles(tif); + uint64 *tilebc; + + TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &tilebc); + if (tilebc != NULL && ntiles > 0) { + uint64 bufsize = 0; + tdata_t buf = NULL; + uint32 t; + + for (t = 0; t < ntiles; t++) { + if (buf == NULL || tilebc[t] > bufsize) { + buf = _TIFFrealloc(buf, (tmsize_t)tilebc[t]); + bufsize = tilebc[t]; + } + if (buf == NULL) { + fprintf(stderr, + "Cannot allocate buffer to read tile %lu\n", + (unsigned long) t); + break; + } + if (TIFFReadRawTile(tif, t, buf, (tmsize_t)tilebc[t]) < 0) { + fprintf(stderr, "Error reading tile %lu\n", + (unsigned long) t); + if (stoponerr) + break; + } else if (showdata) { + if (bitrev) { + TIFFReverseBits(buf, (tmsize_t)tilebc[t]); + printf("%s %lu: (bit reversed)\n ", + what, (unsigned long) t); + } else { + printf("%s %lu:\n ", what, + (unsigned long) t); + } + if (showwords) { + ShowRawWords((uint16*) buf, (uint32)(tilebc[t]>>1)); + } else { + ShowRawBytes((unsigned char*) buf, (uint32) tilebc[t]); + } + } + } + if (buf != NULL) + _TIFFfree(buf); + } } void |