From a512c9192ac6ed8398b8fe9305ae667402162ebf Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 28 Oct 2004 09:44:45 +0200 Subject: devicen colorspace --- mupdf/colorspace.c | 28 ++++++++++++++++++++-------- mupdf/image.c | 9 ++++++--- 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; } -- cgit v1.2.3