From 2f8c9375dc0624aff0bac7f5efe4dcbee78453a4 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 27 Feb 2013 19:01:41 +0000 Subject: Force colorspaces to match with JPX images. If the colorspace given in the dictionary of a JPX image differs from the colorspace given in the image itself, decode to the native image format, then convert. This goes a long way towards fixing "1439 - color softmask fails to draw jpx image.pdf" (aka hivemind.pdf). The lack of transfer function support hopefully explains the rest. --- fitz/image_jpx.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'fitz') diff --git a/fitz/image_jpx.c b/fitz/image_jpx.c index 04bcfecd..0b3df098 100644 --- a/fitz/image_jpx.c +++ b/fitz/image_jpx.c @@ -24,6 +24,7 @@ fz_pixmap * fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *defcs, int indexed) { fz_pixmap *img; + fz_colorspace *origcs; opj_event_mgr_t evtmgr; opj_dparameters_t params; opj_dinfo_t *info; @@ -98,6 +99,7 @@ fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *defcs else if (n > 4) { n = 4; a = 1; } else { a = 0; } + origcs = defcs; if (defcs) { if (defcs->n == n) @@ -150,6 +152,8 @@ fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *defcs } } + opj_image_destroy(jpx); + if (a) { if (n == 4) @@ -162,7 +166,13 @@ fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *defcs fz_premultiply_pixmap(ctx, img); } - opj_image_destroy(jpx); + if (origcs != defcs) + { + fz_pixmap *tmp = fz_new_pixmap(ctx, origcs, w, h); + fz_convert_pixmap(ctx, tmp, img); + fz_drop_pixmap(ctx, img); + img = tmp; + } return img; } -- cgit v1.2.3