summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
Diffstat (limited to 'source/pdf')
-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)
{