From 363f51b35f351009c1eabffeee6a410ba1f38e14 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Tue, 28 Jun 2016 18:56:01 +0200 Subject: Output only as many components for PAM as exist. --- source/fitz/output-pnm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/fitz/output-pnm.c b/source/fitz/output-pnm.c index 8310de9b..0721c08d 100644 --- a/source/fitz/output-pnm.c +++ b/source/fitz/output-pnm.c @@ -124,6 +124,9 @@ fz_write_pam_header(fz_context *ctx, fz_output *out, int w, int h, int n, int al fz_printf(ctx, out, "HEIGHT %d\n", h); fz_printf(ctx, out, "DEPTH %d\n", n); fz_printf(ctx, out, "MAXVAL 255\n"); + + n -= alpha; + if (n == 1 && !alpha) fz_printf(ctx, out, "TUPLTYPE GRAYSCALE\n"); else if (n == 1 && alpha) fz_printf(ctx, out, "TUPLTYPE GRAYSCALE_ALPHA\n"); else if (n == 3 && !alpha) fz_printf(ctx, out, "TUPLTYPE RGB\n"); @@ -142,7 +145,6 @@ fz_write_pam_band(fz_context *ctx, fz_output *out, int w, int h, int n, int alph if (!out) return; - n += alpha; if (end > h) end = h; end -= band_start; -- cgit v1.2.3