summaryrefslogtreecommitdiff
path: root/source/fitz/output-pnm.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-07-12 21:18:45 +0100
committerRobin Watts <robin.watts@artifex.com>2017-07-19 19:41:23 +0100
commitd54763bcd644364c19d3a6a12f889127df583e01 (patch)
tree379843a30fbb263e811ac6cbe3d2a4abe13b6fb3 /source/fitz/output-pnm.c
parentd541fc4b9eced1b788377df8c7edfd9b8dea4094 (diff)
downloadmupdf-d54763bcd644364c19d3a6a12f889127df583e01.tar.xz
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).
Diffstat (limited to 'source/fitz/output-pnm.c')
-rw-r--r--source/fitz/output-pnm.c14
1 files changed, 10 insertions, 4 deletions
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)