summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2023-04-06 12:52:44 +0100
committerRobin Watts <Robin.Watts@artifex.com>2023-04-06 15:08:28 +0100
commita55801e180934211ca2ce4137b8871d20cc15001 (patch)
tree4043f171283170d797ad5a5941cdaf478f38a733
parent5f4a8894197dd7286f062ddefcf183effab2a27f (diff)
downloadghostpdl-a55801e180934211ca2ce4137b8871d20cc15001.tar.gz
GPDL: Fix endian issues with 16bpc tiffs.
-rw-r--r--gpdl/tifftop.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gpdl/tifftop.c b/gpdl/tifftop.c
index 743a7b99c..e9915e14f 100644
--- a/gpdl/tifftop.c
+++ b/gpdl/tifftop.c
@@ -942,6 +942,20 @@ do_impl_process(pl_interp_implementation_t * impl, stream_cursor_read * pr, int
break;
}
+ switch (tiff->bpc)
+ {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ case 16:
+ /* We can cope with all these. */
+ break;
+ default:
+ code = gs_error_unknownerror;
+ goto fail_decode;
+ }
+
/* Scale to fit, if too large. */
scale = 1.0f;
if (tiff->width * tiff->dev->HWResolution[0] > tiff->dev->width * tiff->xresolution)
@@ -1109,6 +1123,20 @@ do_impl_process(pl_interp_implementation_t * impl, stream_cursor_read * pr, int
row += span;
in_row += span;
}
+ row -= span * tiff->raw_num_comps;
+ }
+
+ if (tiff->bpc == 16)
+ {
+ byte *p = row;
+ int n = tiff->tile_width * tiff->raw_num_comps;
+ while (n--)
+ {
+ byte b = p[0];
+ p[0] = p[1];
+ p[1] = b;
+ p += 2;
+ }
}
if (!tiff->tiled) {