summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-08-18 22:50:49 +0000
committerTor Andersson <tor@ghostscript.com>2010-08-18 22:50:49 +0000
commit3639ae4cac339a0f09152b80ffcf337b2c01e4e3 (patch)
treeb24fd4bf279e60a6b8d6c749bb771541aa4e6bad
parent575707186d519303704f37cd958e530e20cf2c84 (diff)
downloadmupdf-3639ae4cac339a0f09152b80ffcf337b2c01e4e3.tar.xz
Let PDF specified colorspace override the built-in colorspace in JPX images.
-rw-r--r--mupdf/pdf_image.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/mupdf/pdf_image.c b/mupdf/pdf_image.c
index d8e327ba..c0a59584 100644
--- a/mupdf/pdf_image.c
+++ b/mupdf/pdf_image.c
@@ -269,7 +269,7 @@ pdf_loadjpximage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict)
fz_error error;
fz_buffer *buf;
fz_pixmap *img;
- fz_obj *obj;
+ fz_obj *obj, *res;
pdf_logimage("jpeg2000\n");
@@ -297,6 +297,32 @@ pdf_loadjpximage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict)
}
}
+ obj = fz_dictgets(dict, "ColorSpace");
+ if (obj)
+ {
+ if (fz_isname(obj))
+ {
+ res = fz_dictget(fz_dictgets(rdb, "ColorSpace"), obj);
+ if (res)
+ obj = res;
+ }
+
+ fz_dropcolorspace(img->colorspace);
+ img->colorspace = nil;
+
+ error = pdf_loadcolorspace(&img->colorspace, xref, obj);
+ if (error)
+ return fz_rethrow(error, "cannot load image colorspace");
+
+ if (!strcmp(img->colorspace->name, "Indexed"))
+ {
+ fz_pixmap *conv;
+ conv = pdf_expandindexedpixmap(img);
+ fz_droppixmap(img);
+ img = conv;
+ }
+ }
+
*imgp = img;
return fz_okay;
}