From e9667e7f8ab7c154d8932916a22c33cf2bad0445 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Mon, 9 Jan 2017 11:09:48 +0000 Subject: Bug 697466: Fix banded PKM/PBM output. When I regularised the band writing interface, I broke PKM and PBM in the banded case. Fixed here. --- source/fitz/bitmap.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/fitz/bitmap.c b/source/fitz/bitmap.c index 046e7aa0..7003a894 100644 --- a/source/fitz/bitmap.c +++ b/source/fitz/bitmap.c @@ -353,12 +353,17 @@ pbm_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta int h = writer->h; int n = writer->n; int bytestride; + int end = band_start + band_height; if (n != 1) fz_throw(ctx, FZ_ERROR_GENERIC, "too many color components in bitmap"); + if (end > h) + end = h; + end -= band_start; + bytestride = (w + 7) >> 3; - while (h--) + while (end--) { fz_write(ctx, out, p, bytestride); p += stride; @@ -373,12 +378,17 @@ pkm_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta int h = writer->h; int n = writer->n; int bytestride; + int end = band_start + band_height; if (n != 4) fz_throw(ctx, FZ_ERROR_GENERIC, "wrong number of color components in bitmap"); + if (end > h) + end = h; + end -= band_start; + bytestride = stride - (w>>1); - while (h--) + while (end--) { int ww = w-1; while (ww > 0) -- cgit v1.2.3