From d54763bcd644364c19d3a6a12f889127df583e01 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 12 Jul 2017 21:18:45 +0100 Subject: Update band writer (especially PSD) to cope with spots PSD writer now outputs spot colors. Ensure subtractive colorspaces are stored with proper polarity. The CMYK and spot components need to be 255-X in the PSD format Store PSD format resources using correct Pascal style strings. Photoshop will fail to open if the the ICC profile resource name is not in proper format. (Incorporates fixes from Michael). --- source/fitz/output-pnm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source/fitz/output-pnm.c') diff --git a/source/fitz/output-pnm.c b/source/fitz/output-pnm.c index 2b39899e..2c4d4d30 100644 --- a/source/fitz/output-pnm.c +++ b/source/fitz/output-pnm.c @@ -12,6 +12,9 @@ pnm_write_header(fz_context *ctx, fz_band_writer *writer, const fz_colorspace *c int n = writer->n; int alpha = writer->alpha; + if (writer->s != 0) + fz_throw(ctx, FZ_ERROR_GENERIC, "PNM writer cannot cope with spot colors"); + n -= alpha; if (n != 1 && n != 3) fz_throw(ctx, FZ_ERROR_GENERIC, "pixmap must be grayscale or rgb to write as pnm"); @@ -125,7 +128,7 @@ fz_write_pixmap_as_pnm(fz_context *ctx, fz_output *out, fz_pixmap *pixmap) fz_band_writer *writer = fz_new_pnm_band_writer(ctx, out); fz_try(ctx) { - fz_write_header(ctx, writer, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, 0, 0, 0, pixmap->colorspace); + fz_write_header(ctx, writer, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, 0, 0, 0, pixmap->colorspace, pixmap->seps); fz_write_band(ctx, writer, pixmap->stride, pixmap->h, pixmap->samples); } fz_always(ctx) @@ -145,7 +148,7 @@ fz_save_pixmap_as_pnm(fz_context *ctx, fz_pixmap *pixmap, const char *filename) fz_try(ctx) { writer = fz_new_pnm_band_writer(ctx, out); - fz_write_header(ctx, writer, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, 0, 0, 0, pixmap->colorspace); + fz_write_header(ctx, writer, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, 0, 0, 0, pixmap->colorspace, pixmap->seps); fz_write_band(ctx, writer, pixmap->stride, pixmap->h, pixmap->samples); } fz_always(ctx) @@ -170,6 +173,9 @@ pam_write_header(fz_context *ctx, fz_band_writer *writer, const fz_colorspace *c int n = writer->n; int alpha = writer->alpha; + if (writer->s != 0) + fz_throw(ctx, FZ_ERROR_GENERIC, "PAM writer cannot cope with spot colors"); + fz_write_printf(ctx, out, "P7\n"); fz_write_printf(ctx, out, "WIDTH %d\n", w); fz_write_printf(ctx, out, "HEIGHT %d\n", h); @@ -228,7 +234,7 @@ fz_write_pixmap_as_pam(fz_context *ctx, fz_output *out, fz_pixmap *pixmap) fz_band_writer *writer = fz_new_pam_band_writer(ctx, out); fz_try(ctx) { - fz_write_header(ctx, writer, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, 0, 0, 0, pixmap->colorspace); + fz_write_header(ctx, writer, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, 0, 0, 0, pixmap->colorspace, pixmap->seps); fz_write_band(ctx, writer, pixmap->stride, pixmap->h, pixmap->samples); } fz_always(ctx) @@ -248,7 +254,7 @@ fz_save_pixmap_as_pam(fz_context *ctx, fz_pixmap *pixmap, const char *filename) fz_try(ctx) { writer = fz_new_pam_band_writer(ctx, out); - fz_write_header(ctx, writer, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, 0, 0, 0, pixmap->colorspace); + fz_write_header(ctx, writer, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, 0, 0, 0, pixmap->colorspace, pixmap->seps); fz_write_band(ctx, writer, pixmap->stride, pixmap->h, pixmap->samples); } fz_always(ctx) -- cgit v1.2.3