summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-06-28 15:01:39 +0100
committerRobin Watts <robin.watts@artifex.com>2016-06-28 15:15:42 +0100
commit5c41dcd3f3458f7e1562a9493b4cba0da83f4188 (patch)
tree3e94316bb611c43d04926b16e8af76397c2e14d3
parent12aa6f724a04f1729513690a14d3a0bdc0725732 (diff)
downloadmupdf-5c41dcd3f3458f7e1562a9493b4cba0da83f4188.tar.xz
Fix inconsistency in band handling.
In an earlier commit, I changed some of the band writing functions to take the band starting offset, rather than the band number. This was done to accomodate the idea of rendering the page in bands of different heights. Sadly, it seems I didn't push this all the way through, and had different band writing functions still taking the band number. Fix all the band writing functions to be consistent.
-rw-r--r--include/mupdf/fitz/output-pcl.h2
-rw-r--r--include/mupdf/fitz/output-png.h2
-rw-r--r--include/mupdf/fitz/output-ps.h2
-rw-r--r--source/fitz/output-pcl.c7
-rw-r--r--source/fitz/output-ps.c7
-rw-r--r--source/tools/mudraw.c10
6 files changed, 14 insertions, 16 deletions
diff --git a/include/mupdf/fitz/output-pcl.h b/include/mupdf/fitz/output-pcl.h
index 053af1e8..a1168211 100644
--- a/include/mupdf/fitz/output-pcl.h
+++ b/include/mupdf/fitz/output-pcl.h
@@ -107,7 +107,7 @@ typedef struct fz_color_pcl_output_context_s fz_color_pcl_output_context;
fz_color_pcl_output_context *fz_write_color_pcl_header(fz_context *ctx, fz_output *out, int w, int h, int n, int xres, int yres, int pagenum, const fz_pcl_options *options);
-void fz_write_color_pcl_band(fz_context *ctx, fz_output *out, fz_color_pcl_output_context *poc, int w, int h, int n, int stride, int band, int bandheight, unsigned char *samples);
+void fz_write_color_pcl_band(fz_context *ctx, fz_output *out, fz_color_pcl_output_context *poc, int w, int h, int n, int stride, int band_start, int bandheight, unsigned char *samples);
void fz_write_color_pcl_trailer(fz_context *ctx, fz_output *out, fz_color_pcl_output_context *pcoc);
diff --git a/include/mupdf/fitz/output-png.h b/include/mupdf/fitz/output-png.h
index 09454fa7..d98d7c7f 100644
--- a/include/mupdf/fitz/output-png.h
+++ b/include/mupdf/fitz/output-png.h
@@ -23,7 +23,7 @@ void fz_write_pixmap_as_png(fz_context *ctx, fz_output *out, const fz_pixmap *pi
typedef struct fz_png_output_context_s fz_png_output_context;
fz_png_output_context *fz_write_png_header(fz_context *ctx, fz_output *out, int w, int h, int n, int alpha);
-void fz_write_png_band(fz_context *ctx, fz_output *out, fz_png_output_context *poc, int stride, int band, int bandheight, unsigned char *samples);
+void fz_write_png_band(fz_context *ctx, fz_output *out, fz_png_output_context *poc, int stride, int band_start, int bandheight, unsigned char *samples);
void fz_write_png_trailer(fz_context *ctx, fz_output *out, fz_png_output_context *poc);
/*
diff --git a/include/mupdf/fitz/output-ps.h b/include/mupdf/fitz/output-ps.h
index f9eb6974..7caed53b 100644
--- a/include/mupdf/fitz/output-ps.h
+++ b/include/mupdf/fitz/output-ps.h
@@ -19,7 +19,7 @@ void fz_write_ps_file_header(fz_context *ctx, fz_output *out);
fz_ps_output_context *fz_write_ps_header(fz_context *ctx, fz_output *out, int w, int h, int n, int xres, int yres, int pagenum);
-void fz_write_ps_band(fz_context *ctx, fz_output *out, fz_ps_output_context *psoc, int w, int h, int n, int stride, int band, int bandheight, unsigned char *samples);
+void fz_write_ps_band(fz_context *ctx, fz_output *out, fz_ps_output_context *psoc, int w, int h, int n, int stride, int band_start, int bandheight, unsigned char *samples);
void fz_write_ps_trailer(fz_context *ctx, fz_output *out, fz_ps_output_context *psoc);
diff --git a/source/fitz/output-pcl.c b/source/fitz/output-pcl.c
index 6d0a24a6..c0858299 100644
--- a/source/fitz/output-pcl.c
+++ b/source/fitz/output-pcl.c
@@ -777,7 +777,7 @@ fz_color_pcl_output_context *fz_write_color_pcl_header(fz_context *ctx, fz_outpu
return pcoc;
}
-void fz_write_color_pcl_band(fz_context *ctx, fz_output *out, fz_color_pcl_output_context *pcoc, int w, int h, int n, int stride, int band, int bandheight, unsigned char *sp)
+void fz_write_color_pcl_band(fz_context *ctx, fz_output *out, fz_color_pcl_output_context *pcoc, int w, int h, int n, int stride, int band_start, int bandheight, unsigned char *sp)
{
int y, ss, ds, seed_valid, fill;
unsigned char *prev;
@@ -796,9 +796,8 @@ void fz_write_color_pcl_band(fz_context *ctx, fz_output *out, fz_color_pcl_outpu
comp = pcoc->compbuf;
seed_valid = pcoc->seed_valid;
- band *= bandheight;
- if (band+bandheight >= h)
- bandheight = h - band;
+ if (band_start+bandheight >= h)
+ bandheight = h - band_start;
y = 0;
while (y < bandheight)
diff --git a/source/fitz/output-ps.c b/source/fitz/output-ps.c
index 1c4f5103..d183adf6 100644
--- a/source/fitz/output-ps.c
+++ b/source/fitz/output-ps.c
@@ -153,16 +153,15 @@ void fz_save_pixmap_as_ps(fz_context *ctx, fz_pixmap *pixmap, char *filename, in
fz_rethrow(ctx);
}
-void fz_write_ps_band(fz_context *ctx, fz_output *out, fz_ps_output_context *psoc, int w, int h, int n, int stride, int band, int bandheight, unsigned char *samples)
+void fz_write_ps_band(fz_context *ctx, fz_output *out, fz_ps_output_context *psoc, int w, int h, int n, int stride, int band_start, int bandheight, unsigned char *samples)
{
int x, y, i, err;
int required_input;
int required_output;
unsigned char *o;
- band *= bandheight;
- if (band+bandheight >= h)
- bandheight = h - band;
+ if (band_start+bandheight >= h)
+ bandheight = h - band_start;
required_input = w*(n-1)*bandheight;
required_output = (int)deflateBound(&psoc->stream, required_input);
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c
index 7e4b40fb..4912bd52 100644
--- a/source/tools/mudraw.c
+++ b/source/tools/mudraw.c
@@ -908,11 +908,11 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
if (output)
{
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);
+ fz_write_pnm_band(ctx, out, pix->w, totalheight, pix->n, pix->alpha, pix->stride, band * bandheight, drawheight, pix->samples);
else if (output_format == OUT_PAM)
- fz_write_pam_band(ctx, out, pix->w, totalheight, pix->n, pix->alpha, pix->stride, band, drawheight, pix->samples);
+ fz_write_pam_band(ctx, out, pix->w, totalheight, pix->n, pix->alpha, pix->stride, band * bandheight, drawheight, pix->samples);
else if (output_format == OUT_PNG)
- fz_write_png_band(ctx, out, poc, pix->stride, band, drawheight, pix->samples);
+ fz_write_png_band(ctx, out, poc, pix->stride, band * bandheight, drawheight, pix->samples);
else if (output_format == OUT_PWG)
fz_write_pixmap_as_pwg(ctx, out, pix, NULL);
else if (output_format == OUT_PCL)
@@ -924,10 +924,10 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
bit = NULL;
}
else
- fz_write_color_pcl_band(ctx, out, pccoc, pix->w, totalheight, pix->n, pix->stride, band, drawheight, pix->samples);
+ fz_write_color_pcl_band(ctx, out, pccoc, pix->w, totalheight, pix->n, pix->stride, band * bandheight, drawheight, pix->samples);
}
else if (output_format == OUT_PS)
- fz_write_ps_band(ctx, out, psoc, pix->w, totalheight, pix->n, pix->stride, band, drawheight, pix->samples);
+ fz_write_ps_band(ctx, out, psoc, pix->w, totalheight, pix->n, pix->stride, band * bandheight, drawheight, pix->samples);
else if (output_format == OUT_PBM)
{
fz_write_pbm_band(ctx, out, bit);