diff options
-rw-r--r-- | fitz/fitz.h | 6 | ||||
-rw-r--r-- | fitz/res_colorspace.c | 6 | ||||
-rw-r--r-- | pdf/pdf_image.c | 7 |
3 files changed, 16 insertions, 3 deletions
diff --git a/fitz/fitz.h b/fitz/fitz.h index 0c71a7a0..b0de1f41 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -1417,6 +1417,12 @@ typedef struct fz_colorspace_s fz_colorspace; fz_colorspace *fz_find_device_colorspace(fz_context *ctx, char *name); /* + fz_colorspace_is_indexed: Return true, iff a given colorspace is + indexed. +*/ +int fz_colorspace_is_indexed(fz_colorspace *cs); + +/* fz_device_gray: Abstract colorspace representing device specific gray. */ diff --git a/fitz/res_colorspace.c b/fitz/res_colorspace.c index 2076f348..a2ce19b8 100644 --- a/fitz/res_colorspace.c +++ b/fitz/res_colorspace.c @@ -194,6 +194,12 @@ fz_find_device_colorspace(fz_context *ctx, char *name) return NULL; } +int +fz_colorspace_is_indexed(fz_colorspace *cs) +{ + return (cs && !strcmp(cs->name, "Indexed")); +} + /* Fast pixmap color conversions */ static void fast_gray_to_rgb(fz_pixmap *dst, fz_pixmap *src) diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c index 7801e7c5..b6795456 100644 --- a/pdf/pdf_image.c +++ b/pdf/pdf_image.c @@ -177,7 +177,6 @@ decomp_image_from_stream(fz_context *ctx, fz_stream *stm, pdf_image *image, int conv = pdf_expand_indexed_pixmap(ctx, tile); fz_drop_pixmap(ctx, tile); tile = conv; - image->base.bpc = 8; } else { @@ -260,6 +259,7 @@ pdf_image_get_pixmap(fz_context *ctx, fz_image *image_, int w, int h) int l2factor; pdf_image_key key; int native_l2factor; + int indexed; /* Check for 'simple' images which are just pixmaps */ if (image->buffer == NULL) @@ -299,7 +299,8 @@ pdf_image_get_pixmap(fz_context *ctx, fz_image *image_, int w, int h) native_l2factor = l2factor; stm = fz_open_image_decomp_stream(ctx, image->buffer, &native_l2factor); - return decomp_image_from_stream(ctx, stm, image, 0, 0, l2factor, native_l2factor, 1); + indexed = fz_colorspace_is_indexed(image->base.colorspace); + return decomp_image_from_stream(ctx, stm, image, 0, indexed, l2factor, native_l2factor, 1); } static pdf_image * @@ -443,7 +444,7 @@ pdf_load_image_imp(pdf_document *xref, pdf_obj *rdb, pdf_obj *dict, fz_stream *c image->imagemask = imagemask; image->usecolorkey = usecolorkey; image->base.mask = mask; - if (!indexed && !cstm) + if (!cstm) { /* Just load the compressed image data now and we can * decode it on demand. */ |