From a1ca4f85637a5b35ad7a7da751077e447cba3ab2 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 25 Mar 2016 17:15:06 +0000 Subject: Fix PS output banded mode operation. --- source/fitz/output-ps.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source/fitz') diff --git a/source/fitz/output-ps.c b/source/fitz/output-ps.c index 35c0a333..e80a3f00 100644 --- a/source/fitz/output-ps.c +++ b/source/fitz/output-ps.c @@ -156,10 +156,17 @@ void fz_save_pixmap_as_ps(fz_context *ctx, fz_pixmap *pixmap, char *filename, in void fz_write_ps_band(fz_context *ctx, fz_output *out, fz_ps_output_context *psoc, int w, int h, int n, int band, int bandheight, unsigned char *samples) { int x, y, i, err; - int required_input = w*(n-1)*h; - int required_output = (int)deflateBound(&psoc->stream, required_input); + int required_input; + int required_output; unsigned char *o; + band *= bandheight; + if (band+bandheight >= h) + bandheight = h - band; + + required_input = w*(n-1)*bandheight; + required_output = (int)deflateBound(&psoc->stream, required_input); + if (psoc->input == NULL || psoc->input_size < required_input) { fz_free(ctx, psoc->input); @@ -177,7 +184,7 @@ void fz_write_ps_band(fz_context *ctx, fz_output *out, fz_ps_output_context *pso } o = psoc->input; - for (y = 0; y < h; y++) + for (y = 0; y < bandheight; y++) for (x = 0; x < w; x++) { for (i = n-1; i > 0; i--) -- cgit v1.2.3