summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2016-10-26 00:14:15 +0800
committerSebastian Rasmussen <sebras@gmail.com>2016-10-26 22:36:00 +0800
commit32ba1eb92200c4c8ea2e32a31f926adf473d822d (patch)
tree55c3f0108ac7bb703707767b5a2772000a186d06 /source
parente7875fcd16a80d880c33b49c9142bce1d870e9a0 (diff)
downloadmupdf-32ba1eb92200c4c8ea2e32a31f926adf473d822d.tar.xz
tiff: Always set colorspace when reading image info.
Commit 3059b6908208fbb9547e6876332a5b42a6406d1a accidentally caused colorspace to not be set when reading image information.
Diffstat (limited to 'source')
-rw-r--r--source/fitz/load-tiff.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c
index bab1d5e7..56afbdc6 100644
--- a/source/fitz/load-tiff.c
+++ b/source/fitz/load-tiff.c
@@ -931,7 +931,7 @@ tiff_swap_byte_order(unsigned char *buf, int n)
}
static void
-tiff_decode_header(fz_context *ctx, struct tiff *tiff, unsigned char *buf, size_t len)
+tiff_read_header(fz_context *ctx, struct tiff *tiff, unsigned char *buf, size_t len)
{
unsigned version;
@@ -1011,7 +1011,7 @@ tiff_seek_ifd(fz_context *ctx, struct tiff *tiff, int subimage)
}
static void
-tiff_decode_ifd(fz_context *ctx, struct tiff *tiff)
+tiff_read_ifd(fz_context *ctx, struct tiff *tiff)
{
unsigned offset;
unsigned count;
@@ -1055,7 +1055,7 @@ tiff_ycc_to_rgb(fz_context *ctx, struct tiff *tiff)
}
static void
-tiff_decode_samples(fz_context *ctx, struct tiff *tiff)
+tiff_decode_ifd(fz_context *ctx, struct tiff *tiff)
{
unsigned i;
@@ -1143,9 +1143,6 @@ tiff_decode_samples(fz_context *ctx, struct tiff *tiff)
tiff->yresolution = 96;
}
- tiff->samples = fz_malloc_array(ctx, tiff->imagelength, tiff->stride);
- memset(tiff->samples, 0x55, tiff->imagelength * tiff->stride);
-
if (tiff->rowsperstrip > tiff->imagelength)
tiff->rowsperstrip = tiff->imagelength;
@@ -1190,6 +1187,15 @@ tiff_decode_samples(fz_context *ctx, struct tiff *tiff)
tiff->stripbytecountslen = 0;
}
}
+}
+
+static void
+tiff_decode_samples(fz_context *ctx, struct tiff *tiff)
+{
+ unsigned i;
+
+ tiff->samples = fz_malloc_array(ctx, tiff->imagelength, tiff->stride);
+ memset(tiff->samples, 0x55, tiff->imagelength * tiff->stride);
if (tiff->tilelength && tiff->tilewidth && tiff->tileoffsets && tiff->tilebytecounts)
tiff_decode_tiles(ctx, tiff);
@@ -1256,11 +1262,12 @@ fz_load_tiff_subimage(fz_context *ctx, unsigned char *buf, size_t len, int subim
fz_try(ctx)
{
- tiff_decode_header(ctx, &tiff, buf, len);
+ tiff_read_header(ctx, &tiff, buf, len);
tiff_seek_ifd(ctx, &tiff, subimage);
- tiff_decode_ifd(ctx, &tiff);
+ tiff_read_ifd(ctx, &tiff);
/* Decode the image data */
+ tiff_decode_ifd(ctx, &tiff);
tiff_decode_samples(ctx, &tiff);
/* Expand into fz_pixmap struct */
@@ -1331,8 +1338,10 @@ fz_load_tiff_info_subimage(fz_context *ctx, unsigned char *buf, size_t len, int
fz_try(ctx)
{
- tiff_decode_header(ctx, &tiff, buf, len);
+ tiff_read_header(ctx, &tiff, buf, len);
tiff_seek_ifd(ctx, &tiff, subimage);
+ tiff_read_ifd(ctx, &tiff);
+
tiff_decode_ifd(ctx, &tiff);
*wp = tiff.imagewidth;
@@ -1369,7 +1378,7 @@ fz_load_tiff_subimage_count(fz_context *ctx, unsigned char *buf, size_t len)
unsigned subimage_count = 0;
struct tiff tiff = { 0 };
- tiff_decode_header(ctx, &tiff, buf, len);
+ tiff_read_header(ctx, &tiff, buf, len);
offset = tiff.ifd_offset;