summaryrefslogtreecommitdiff
path: root/source/fitz
diff options
context:
space:
mode:
Diffstat (limited to 'source/fitz')
-rw-r--r--source/fitz/output-ps.c13
1 files changed, 10 insertions, 3 deletions
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--)