summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-02-27 19:01:41 +0000
committerRobin Watts <robin.watts@artifex.com>2013-02-28 00:28:06 +0000
commit2f8c9375dc0624aff0bac7f5efe4dcbee78453a4 (patch)
treeaffed0191aaca1511b004c5ad4f7b8c9840e1819 /fitz
parenta00b3069c1409a3d24bd3c8998693ac8052d78ef (diff)
downloadmupdf-2f8c9375dc0624aff0bac7f5efe4dcbee78453a4.tar.xz
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.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/image_jpx.c12
1 files changed, 11 insertions, 1 deletions
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;
}