diff options
author | Tor Andersson <tor@ghostscript.com> | 2011-02-07 16:09:25 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2011-02-07 16:09:25 +0000 |
commit | 687313e0cbf883019b3db3777a8df1ff0698788e (patch) | |
tree | 245b0cf7ea3b031413145c257012894d1985496d | |
parent | 5ee34c75db2752a656f56c7bbeeb67f67f158519 (diff) | |
download | mupdf-687313e0cbf883019b3db3777a8df1ff0698788e.tar.xz |
Ensure that JPX image colorspace matches what is given in the PDF object.
-rw-r--r-- | mupdf/pdf_image.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/mupdf/pdf_image.c b/mupdf/pdf_image.c index 4252a580..9d59d9b2 100644 --- a/mupdf/pdf_image.c +++ b/mupdf/pdf_image.c @@ -308,12 +308,24 @@ pdf_loadjpximage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict) obj = fz_dictgets(dict, "ColorSpace"); if (obj) { - fz_dropcolorspace(img->colorspace); + fz_colorspace *original = img->colorspace; img->colorspace = nil; error = pdf_loadcolorspace(&img->colorspace, xref, obj); if (error) + { + fz_dropcolorspace(original); return fz_rethrow(error, "cannot load image colorspace"); + } + + if (original->n != img->colorspace->n) + { + fz_warn("jpeg-2000 colorspace (%s) does not match promised colorspace (%s)", original->name, img->colorspace->name); + fz_dropcolorspace(img->colorspace); + img->colorspace = original; + } + else + fz_dropcolorspace(original); if (!strcmp(img->colorspace->name, "Indexed")) { |