diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2023-05-08 17:33:54 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2023-05-08 17:33:54 +0100 |
commit | 0aba05e63294c254b5ff585a47b632fbe63b3ede (patch) | |
tree | a765da9e7a0ceba25d3f64f3a054b9ebd36b4dfc | |
parent | ac98d17c522f0a1e4726d711542e8d95e848cd98 (diff) | |
download | ghostpdl-0aba05e63294c254b5ff585a47b632fbe63b3ede.tar.gz |
gpdl: Support Multipage TIFFs.
This supports the common form of Multipage TIFFs, whereby a single
TIFF has multiple IFDs.
We do not yet support the (much rarer) form of multipage TIFFs
whereby we have a single IFD with sub-ifd's in it.
Those are supposedly used for strange things like multiple subsamplings
of the same image, so are probably not actually what we want anyway.
-rw-r--r-- | gpdl/tifftop.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/gpdl/tifftop.c b/gpdl/tifftop.c index 5e25d8dff..4321eb45e 100644 --- a/gpdl/tifftop.c +++ b/gpdl/tifftop.c @@ -888,12 +888,6 @@ do_tiff_decode(tiff_interp_instance_t *tiff) if (scale * tiff->height * tiff->dev->HWResolution[1] > tiff->dev->height * tiff->yresolution) scale = ((float)tiff->dev->height * tiff->yresolution) / (tiff->height * tiff->dev->HWResolution[1]); - tiff->nulldev = gs_currentdevice(tiff->pgs); - rc_increment(tiff->nulldev); - code = gs_setdevice_no_erase(tiff->pgs, tiff->dev); - if (code < 0) - return code; - code = gs_erasepage(tiff->pgs); if (code < 0) return code; @@ -1108,6 +1102,29 @@ fail_decode: } static int +decode_all_tiffs(tiff_interp_instance_t *tiff) +{ + int code; + + tiff->nulldev = gs_currentdevice(tiff->pgs); + rc_increment(tiff->nulldev); + code = gs_setdevice_no_erase(tiff->pgs, tiff->dev); + if (code < 0) + return code; + + do + { + code = do_tiff_decode(tiff); + if (code < 0) + return code; + } + while (TIFFReadDirectory(tiff->handle)); + + return 0; +} + + +static int do_impl_process(pl_interp_implementation_t * impl, stream_cursor_read * pr, int eof) { tiff_interp_instance_t *tiff = (tiff_interp_instance_t *)impl->interp_client_data; @@ -1209,7 +1226,7 @@ do_impl_process(pl_interp_implementation_t * impl, stream_cursor_read * pr, int &tiff_jpeg_mem_callback); #endif - code = do_tiff_decode(tiff); + code = decode_all_tiffs(tiff); if (code < 0) { tiff->state = ii_state_flush; |