summaryrefslogtreecommitdiff
path: root/source/fitz/load-tiff.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-06-14 13:01:57 +0100
committerRobin Watts <robin.watts@artifex.com>2016-06-14 13:06:02 +0100
commit44d65838233baef2c16397847dca3061cde7ec4e (patch)
tree711862be21c83e7a6fd8dbe22ee5329335eadfd9 /source/fitz/load-tiff.c
parent24c55cc6c823a8d6d76ee3c7a41e5832d8031385 (diff)
downloadmupdf-44d65838233baef2c16397847dca3061cde7ec4e.tar.xz
Add TIFF SGI LUV decoding.
Diffstat (limited to 'source/fitz/load-tiff.c')
-rw-r--r--source/fitz/load-tiff.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c
index 3df9f7c8..297d71dc 100644
--- a/source/fitz/load-tiff.c
+++ b/source/fitz/load-tiff.c
@@ -154,6 +154,29 @@ fz_decode_tiff_packbits(fz_context *ctx, struct tiff *tiff, fz_stream *chain, un
fz_drop_stream(ctx, stm);
}
+fz_decode_tiff_sgilog16(fz_context *ctx, struct tiff *tiff, fz_stream *chain, unsigned char *wp, int wlen, int w)
+{
+ fz_stream *stm = fz_open_sgilog16(ctx, chain, w);
+ fz_read(ctx, stm, wp, wlen);
+ fz_drop_stream(ctx, stm);
+}
+
+static void
+fz_decode_tiff_sgilog24(fz_context *ctx, struct tiff *tiff, fz_stream *chain, unsigned char *wp, int wlen, int w)
+{
+ fz_stream *stm = fz_open_sgilog24(ctx, chain, w);
+ fz_read(ctx, stm, wp, wlen);
+ fz_drop_stream(ctx, stm);
+}
+
+static void
+fz_decode_tiff_sgilog32(fz_context *ctx, struct tiff *tiff, fz_stream *chain, unsigned char *wp, int wlen, int w)
+{
+ fz_stream *stm = fz_open_sgilog32(ctx, chain, w);
+ fz_read(ctx, stm, wp, wlen);
+ fz_drop_stream(ctx, stm);
+}
+
static void
fz_decode_tiff_lzw(fz_context *ctx, struct tiff *tiff, fz_stream *chain, unsigned char *wp, int wlen, int old_tiff)
{
@@ -390,6 +413,16 @@ fz_decode_tiff_strips(fz_context *ctx, struct tiff *tiff)
/* it's probably a jpeg ... we let jpeg convert to rgb */
tiff->colorspace = fz_device_rgb(ctx);
break;
+ case 32844: /* SGI CIE Log 2 L (16bpp Greyscale) */
+ tiff->colorspace = fz_device_gray(ctx);
+ tiff->bitspersample = 8;
+ tiff->stride >>= 1;
+ break;
+ case 32845: /* SGI CIE Log 2 L, u, v (24bpp or 32bpp) */
+ tiff->colorspace = fz_device_rgb(ctx);
+ tiff->bitspersample = 8;
+ tiff->stride >>= 1;
+ break;
default:
fz_throw(ctx, FZ_ERROR_GENERIC, "unknown photometric: %d", tiff->photometric);
}
@@ -471,6 +504,15 @@ fz_decode_tiff_strips(fz_context *ctx, struct tiff *tiff)
case 32773:
fz_decode_tiff_packbits(ctx, tiff, stm, wp, wlen);
break;
+ case 34676:
+ if (tiff->photometric == 32845)
+ fz_decode_tiff_sgilog32(ctx, tiff, stm, wp, wlen, tiff->imagewidth);
+ else
+ fz_decode_tiff_sgilog16(ctx, tiff, stm, wp, wlen, tiff->imagewidth);
+ break;
+ case 34677:
+ fz_decode_tiff_sgilog24(ctx, tiff, stm, wp, wlen, tiff->imagewidth);
+ break;
default:
fz_throw(ctx, FZ_ERROR_GENERIC, "unknown TIFF compression: %d", tiff->compression);
}