summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-colorspace.c
diff options
context:
space:
mode:
authorSimon Bünzli <zeniko@gmail.com>2013-08-30 18:11:28 +0200
committerRobin Watts <robin.watts@artifex.com>2013-09-10 14:09:02 +0100
commitef983195f1c593f8aa01a484cd2e9b26ce7923ae (patch)
treed00176e8ab4a6da6f2035c0a6b6831dffe4007b2 /source/pdf/pdf-colorspace.c
parentfa56dd76da7aa65862ee1db0b1147c899f2e8144 (diff)
downloadmupdf-ef983195f1c593f8aa01a484cd2e9b26ce7923ae.tar.xz
support /Alternate colorspace for ICC based
This progresses among others Bug689803.pdf and Alternate_colorspace_for_ICCBased_not_supported.pdf
Diffstat (limited to 'source/pdf/pdf-colorspace.c')
-rw-r--r--source/pdf/pdf-colorspace.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/source/pdf/pdf-colorspace.c b/source/pdf/pdf-colorspace.c
index e515b30a..de138f90 100644
--- a/source/pdf/pdf-colorspace.c
+++ b/source/pdf/pdf-colorspace.c
@@ -6,17 +6,42 @@ static fz_colorspace *
load_icc_based(pdf_document *doc, pdf_obj *dict)
{
int n;
+ pdf_obj *obj;
+ fz_context *ctx = doc->ctx;
n = pdf_to_int(pdf_dict_gets(dict, "N"));
+ obj = pdf_dict_gets(dict, "Alternate");
+
+ if (obj)
+ {
+ fz_colorspace *cs_alt = NULL;
+
+ fz_try(ctx)
+ {
+ cs_alt = pdf_load_colorspace(doc, obj);
+ if (cs_alt->n != n)
+ {
+ fz_drop_colorspace(ctx, cs_alt);
+ fz_throw(ctx, FZ_ERROR_GENERIC, "ICCBased /Alternate colorspace must have %d components", n);
+ }
+ }
+ fz_catch(ctx)
+ {
+ cs_alt = NULL;
+ }
+
+ if (cs_alt)
+ return cs_alt;
+ }
switch (n)
{
- case 1: return fz_device_gray(doc->ctx);
- case 3: return fz_device_rgb(doc->ctx);
- case 4: return fz_device_cmyk(doc->ctx);
+ case 1: return fz_device_gray(ctx);
+ case 3: return fz_device_rgb(ctx);
+ case 4: return fz_device_cmyk(ctx);
}
- fz_throw(doc->ctx, FZ_ERROR_GENERIC, "syntaxerror: ICCBased must have 1, 3 or 4 components");
+ fz_throw(ctx, FZ_ERROR_GENERIC, "syntaxerror: ICCBased must have 1, 3 or 4 components");
return NULL; /* Stupid MSVC */
}
@@ -155,6 +180,7 @@ load_indexed(pdf_document *doc, pdf_obj *array)
unsigned char *lookup = NULL;
fz_var(base);
+ fz_var(lookup);
fz_try(ctx)
{