summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2004-10-28 09:44:45 +0200
committerTor Andersson <tor@ghostscript.com>2004-10-28 09:44:45 +0200
commita512c9192ac6ed8398b8fe9305ae667402162ebf (patch)
tree41d028ed8a3354558783f8bdd60f4f151117c15a
parent0374458df3b631004ddcaf6d8ca416b4390a83ce (diff)
downloadmupdf-a512c9192ac6ed8398b8fe9305ae667402162ebf.tar.xz
devicen colorspace
-rw-r--r--mupdf/colorspace.c28
-rw-r--r--mupdf/image.c9
2 files changed, 26 insertions, 11 deletions
diff --git a/mupdf/colorspace.c b/mupdf/colorspace.c
index d7519593..1b2eff61 100644
--- a/mupdf/colorspace.c
+++ b/mupdf/colorspace.c
@@ -499,7 +499,7 @@ static void separationtoxyz(fz_colorspace *fzcs, float *sep, float *xyz)
fz_error *error;
float alt[32];
- error = pdf_evalfunction(cs->tint, sep, 1, alt, cs->base->n);
+ error = pdf_evalfunction(cs->tint, sep, fzcs->n, alt, cs->base->n);
if (error)
{
fz_warn("separation: %s", error->msg);
@@ -525,11 +525,18 @@ static fz_error *
loadseparation(fz_colorspace **csp, pdf_xref *xref, fz_obj *array)
{
fz_error *error;
- struct separation *sep;
+ struct separation *cs;
+ fz_obj *nameobj = fz_arrayget(array, 1);
fz_obj *baseobj = fz_arrayget(array, 2);
fz_obj *tintobj = fz_arrayget(array, 3);
fz_colorspace *base;
pdf_function *tint;
+ int n;
+
+ if (fz_isarray(nameobj))
+ n = fz_arraylen(nameobj);
+ else
+ n = 1;
error = pdf_resolve(&baseobj, xref);
if (error)
@@ -546,20 +553,22 @@ loadseparation(fz_colorspace **csp, pdf_xref *xref, fz_obj *array)
return error;
}
- sep = fz_malloc(sizeof(struct separation));
- if (!sep)
+ cs = fz_malloc(sizeof(struct separation));
+ if (!cs)
{
pdf_freefunction(tint);
fz_freecolorspace(base);
return fz_outofmem;
}
- initcs((fz_colorspace*)sep, "Separation", 1, separationtoxyz, nil, freeseparation);
+ initcs((fz_colorspace*)cs,
+ n == 1 ? "Separation" : "DeviceN", n,
+ separationtoxyz, nil, freeseparation);
- sep->base = base;
- sep->tint = tint;
+ cs->base = base;
+ cs->tint = tint;
- *csp = (fz_colorspace*)sep;
+ *csp = (fz_colorspace*)cs;
return nil;
}
@@ -723,6 +732,9 @@ printf("\n");
if (!strcmp(fz_toname(name), "Separation"))
return loadseparation(csp, xref, obj);
+
+ if (!strcmp(fz_toname(name), "DeviceN"))
+ return loadseparation(csp, xref, obj);
}
}
diff --git a/mupdf/image.c b/mupdf/image.c
index 44ee499a..019e6129 100644
--- a/mupdf/image.c
+++ b/mupdf/image.c
@@ -72,7 +72,7 @@ static void loadtile8a(pdf_image *src, fz_pixmap *dst)
}
static void
-decodetile(fz_pixmap *pix, int bpc, int a, float *decode)
+decodetile(fz_pixmap *pix, int bpc, int a, float *decode, int scale)
{
unsigned char table[32][256];
float twon = (1 << bpc) - 1;
@@ -85,7 +85,7 @@ decodetile(fz_pixmap *pix, int bpc, int a, float *decode)
float min = decode[k * 2 + 0];
float max = decode[k * 2 + 1];
float f = min + i * (max - min) / twon;
- table[k][i] = f * 255;
+ table[k][i] = f * scale;
}
}
@@ -138,7 +138,10 @@ loadtile(fz_image *img, fz_pixmap *tile)
}
}
- decodetile(tile, src->bpc, src->super.n, src->decode);
+ if (img->cs && !strcmp(img->cs->name, "Indexed"))
+ decodetile(tile, src->bpc, !src->super.a, src->decode, 1);
+ else
+ decodetile(tile, src->bpc, !src->super.a, src->decode, 255);
return nil;
}