diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-06-17 13:22:27 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-06-17 13:25:22 +0100 |
commit | 5e5d9490984b1424751687fd6d96ef81d76180e5 (patch) | |
tree | 8fac588a6bce397d4acd86ebc2034833e5ce8acd /source | |
parent | f653eac3bac807f13ecba3e8463c4de3689da090 (diff) | |
download | mupdf-5e5d9490984b1424751687fd6d96ef81d76180e5.tar.xz |
Fix fz_write_pam code.
It was incorrectly missing the alpha in the header writing code.
Diffstat (limited to 'source')
-rw-r--r-- | source/fitz/output-pnm.c | 11 | ||||
-rw-r--r-- | source/tools/mudraw.c | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/source/fitz/output-pnm.c b/source/fitz/output-pnm.c index 99edc24d..b2bc2387 100644 --- a/source/fitz/output-pnm.c +++ b/source/fitz/output-pnm.c @@ -125,16 +125,16 @@ fz_write_pam_header(fz_context *ctx, fz_output *out, int w, int h, int n, int al fz_printf(ctx, out, "DEPTH %d\n", n); fz_printf(ctx, out, "MAXVAL 255\n"); if (n == 1) fz_printf(ctx, out, "TUPLTYPE GRAYSCALE\n"); - else if (n == 2) fz_printf(ctx, out, "TUPLTYPE GRAYSCALE_ALPHA\n"); + else if (n == 1 && alpha) fz_printf(ctx, out, "TUPLTYPE GRAYSCALE_ALPHA\n"); else if (n == 3) fz_printf(ctx, out, "TUPLTYPE RGB\n"); - else if (n == 4 && alpha) fz_printf(ctx, out, "TUPLTYPE RGB_ALPHA\n"); + else if (n == 3 && alpha) fz_printf(ctx, out, "TUPLTYPE RGB_ALPHA\n"); else if (n == 4 && !alpha) fz_printf(ctx, out, "TUPLTYPE CMYK\n"); else if (n == 5) fz_printf(ctx, out, "TUPLTYPE CMYK_ALPHA\n"); fz_printf(ctx, out, "ENDHDR\n"); } void -fz_write_pam_band(fz_context *ctx, fz_output *out, int w, int h, int n, int stride, int band_start, int bandheight, unsigned char *sp) +fz_write_pam_band(fz_context *ctx, fz_output *out, int w, int h, int n, int alpha, int stride, int band_start, int bandheight, unsigned char *sp) { int y; int end = band_start + bandheight; @@ -142,6 +142,7 @@ fz_write_pam_band(fz_context *ctx, fz_output *out, int w, int h, int n, int stri if (!out) return; + n += alpha; if (end > h) end = h; end -= band_start; @@ -157,7 +158,7 @@ void fz_write_pixmap_as_pam(fz_context *ctx, fz_output *out, fz_pixmap *pixmap) { fz_write_pam_header(ctx, out, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha); - fz_write_pam_band(ctx, out, pixmap->w, pixmap->h, pixmap->n, pixmap->stride, 0, pixmap->h, pixmap->samples); + fz_write_pam_band(ctx, out, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, pixmap->stride, 0, pixmap->h, pixmap->samples); } void @@ -167,7 +168,7 @@ fz_save_pixmap_as_pam(fz_context *ctx, fz_pixmap *pixmap, char *filename) fz_try(ctx) { fz_write_pam_header(ctx, out, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha); - fz_write_pam_band(ctx, out, pixmap->w, pixmap->h, pixmap->n, pixmap->stride, 0, pixmap->h, pixmap->samples); + fz_write_pam_band(ctx, out, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, pixmap->stride, 0, pixmap->h, pixmap->samples); } fz_always(ctx) fz_drop_output(ctx, out); diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c index 7d17336b..6c27fc28 100644 --- a/source/tools/mudraw.c +++ b/source/tools/mudraw.c @@ -910,7 +910,7 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in if (output_format == OUT_PGM || output_format == OUT_PPM || output_format == OUT_PNM) fz_write_pnm_band(ctx, out, pix->w, totalheight, pix->n, pix->alpha, pix->stride, band, drawheight, pix->samples); else if (output_format == OUT_PAM) - fz_write_pam_band(ctx, out, pix->w, totalheight, pix->n, pix->stride, band, drawheight, pix->samples); + fz_write_pam_band(ctx, out, pix->w, totalheight, pix->n, pix->alpha, pix->stride, band, drawheight, pix->samples); else if (output_format == OUT_PNG) fz_write_png_band(ctx, out, poc, pix->stride, band, drawheight, pix->samples); else if (output_format == OUT_PWG) |