summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/fitz/bitmap.h2
-rw-r--r--include/mupdf/fitz/output-pnm.h4
-rw-r--r--source/fitz/halftone.c5
-rw-r--r--source/fitz/output-png.c7
-rw-r--r--source/fitz/output-pnm.c14
-rw-r--r--source/tools/mudraw.c8
6 files changed, 18 insertions, 22 deletions
diff --git a/include/mupdf/fitz/bitmap.h b/include/mupdf/fitz/bitmap.h
index 84a624bc..4ba8e9cd 100644
--- a/include/mupdf/fitz/bitmap.h
+++ b/include/mupdf/fitz/bitmap.h
@@ -53,7 +53,7 @@ typedef struct fz_halftone_s fz_halftone;
*/
fz_bitmap *fz_new_bitmap_from_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht);
-fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht, int band, int bandheight);
+fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht, int band_start, int bandheight);
struct fz_bitmap_s
{
diff --git a/include/mupdf/fitz/output-pnm.h b/include/mupdf/fitz/output-pnm.h
index 3226ac4c..65d0f566 100644
--- a/include/mupdf/fitz/output-pnm.h
+++ b/include/mupdf/fitz/output-pnm.h
@@ -14,7 +14,7 @@ void fz_save_pixmap_as_pnm(fz_context *ctx, fz_pixmap *pixmap, char *filename);
void fz_write_pixmap_as_pnm(fz_context *ctx, fz_output *out, fz_pixmap *pixmap);
void fz_write_pnm_header(fz_context *ctx, fz_output *out, int w, int h, int n, int alpha);
-void fz_write_pnm_band(fz_context *ctx, fz_output *out, int w, int h, int n, int alpha, int stride, int band, int bandheight, unsigned char *p);
+void fz_write_pnm_band(fz_context *ctx, fz_output *out, int w, int h, int n, int alpha, int stride, int band_start, int bandheight, unsigned char *p);
/*
fz_save_pixmap_as_pam: Save a pixmap as a PAM image file.
@@ -23,7 +23,7 @@ void fz_save_pixmap_as_pam(fz_context *ctx, fz_pixmap *pixmap, char *filename);
void fz_write_pixmap_as_pam(fz_context *ctx, fz_output *out, fz_pixmap *pixmap);
void fz_write_pam_header(fz_context *ctx, fz_output *out, int w, int h, int n, int alpha);
-void fz_write_pam_band(fz_context *ctx, fz_output *out, int w, int h, int n, int stride, int band, int bandheight, unsigned char *sp);
+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_save_bitmap_as_pbm: Save a bitmap as a PBM image file.
diff --git a/source/fitz/halftone.c b/source/fitz/halftone.c
index 04c3b5f9..eb35dbdf 100644
--- a/source/fitz/halftone.c
+++ b/source/fitz/halftone.c
@@ -511,7 +511,7 @@ static int gcd(int u, int v)
while (1);
}
-fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht, int band, int bandheight)
+fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht, int band_start, int bandheight)
{
fz_bitmap *out = NULL;
unsigned char *ht_line = NULL;
@@ -528,7 +528,6 @@ fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_ha
fz_var(ht_line);
fz_var(out);
- band *= bandheight;
n = pix->n;
switch(n)
@@ -572,7 +571,7 @@ fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_ha
h = pix->h;
x = pix->x;
- y = pix->y + band;
+ y = pix->y + band_start;
w = pix->w;
ostride = out->stride;
pstride = pix->stride;
diff --git a/source/fitz/output-png.c b/source/fitz/output-png.c
index 74f2ca3f..00eaeee8 100644
--- a/source/fitz/output-png.c
+++ b/source/fitz/output-png.c
@@ -130,7 +130,7 @@ fz_write_png_header(fz_context *ctx, fz_output *out, int w, int h, int n, int al
}
void
-fz_write_png_band(fz_context *ctx, fz_output *out, fz_png_output_context *poc, int stride, int band, int bandheight, unsigned char *sp)
+fz_write_png_band(fz_context *ctx, fz_output *out, fz_png_output_context *poc, int stride, int band_start, int bandheight, unsigned char *sp)
{
unsigned char *dp;
int y, x, k, err, finalband;
@@ -144,10 +144,9 @@ fz_write_png_band(fz_context *ctx, fz_output *out, fz_png_output_context *poc, i
n = poc->n;
alpha = poc->alpha;
- band *= bandheight;
- finalband = (band+bandheight >= h);
+ finalband = (band_start+bandheight >= h);
if (finalband)
- bandheight = h - band;
+ bandheight = h - band_start;
if (poc->udata == NULL)
{
diff --git a/source/fitz/output-pnm.c b/source/fitz/output-pnm.c
index e253d96a..99edc24d 100644
--- a/source/fitz/output-pnm.c
+++ b/source/fitz/output-pnm.c
@@ -20,12 +20,11 @@ fz_write_pnm_header(fz_context *ctx, fz_output *out, int w, int h, int n, int al
}
void
-fz_write_pnm_band(fz_context *ctx, fz_output *out, int w, int h, int n, int alpha, int stride, int band, int bandheight, unsigned char *p)
+fz_write_pnm_band(fz_context *ctx, fz_output *out, int w, int h, int n, int alpha, int stride, int band_start, int bandheight, unsigned char *p)
{
char buffer[2*3*4*5*6]; /* Buffer must be a multiple of 2 and 3 at least. */
int len;
- int start = band * bandheight;
- int end = start + bandheight;
+ int end = band_start + bandheight;
if (n-alpha != 1 && n-alpha != 3)
fz_throw(ctx, FZ_ERROR_GENERIC, "pixmap must be grayscale or rgb to write as pnm");
@@ -35,7 +34,7 @@ fz_write_pnm_band(fz_context *ctx, fz_output *out, int w, int h, int n, int alph
if (end > h)
end = h;
- end -= start;
+ end -= band_start;
/* Tests show that writing single bytes out at a time
* is appallingly slow. We get a huge improvement
@@ -135,18 +134,17 @@ fz_write_pam_header(fz_context *ctx, fz_output *out, int w, int h, int n, int al
}
void
-fz_write_pam_band(fz_context *ctx, fz_output *out, int w, int h, int n, int stride, int band, int bandheight, unsigned char *sp)
+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)
{
int y;
- int start = band * bandheight;
- int end = start + bandheight;
+ int end = band_start + bandheight;
if (!out)
return;
if (end > h)
end = h;
- end -= start;
+ end -= band_start;
for (y = 0; y < end; y++)
{
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c
index 2efabcd7..7d17336b 100644
--- a/source/tools/mudraw.c
+++ b/source/tools/mudraw.c
@@ -532,7 +532,7 @@ file_level_trailers(fz_context *ctx)
fz_drop_stext_sheet(ctx, sheet);
}
-static void drawband(fz_context *ctx, fz_page *page, fz_display_list *list, const fz_matrix *ctm, const fz_rect *tbounds, fz_cookie *cookie, int band, fz_pixmap *pix, fz_bitmap **bit)
+static void drawband(fz_context *ctx, fz_page *page, fz_display_list *list, const fz_matrix *ctm, const fz_rect *tbounds, fz_cookie *cookie, int band_start, fz_pixmap *pix, fz_bitmap **bit)
{
fz_device *dev = NULL;
@@ -566,7 +566,7 @@ static void drawband(fz_context *ctx, fz_page *page, fz_display_list *list, cons
fz_unmultiply_pixmap(ctx, pix);
if ((output_format == OUT_PCL && out_cs == CS_MONO) || (output_format == OUT_PBM) || (output_format == OUT_PKM))
- *bit = fz_new_bitmap_from_pixmap_band(ctx, pix, NULL, band, bandheight);
+ *bit = fz_new_bitmap_from_pixmap_band(ctx, pix, NULL, band_start, bandheight);
}
fz_catch(ctx)
{
@@ -903,7 +903,7 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
cookie->errors += w->cookie.errors;
}
else
- drawband(ctx, page, list, &ctm, &tbounds, cookie, band, pix, &bit);
+ drawband(ctx, page, list, &ctm, &tbounds, cookie, band * bandheight, pix, &bit);
if (output)
{
@@ -1303,7 +1303,7 @@ static THREAD_RETURN_TYPE worker_thread(void *arg)
SEMAPHORE_WAIT(me->start);
DEBUG_THREADS(("Worker %d woken for band %d\n", me->num, me->band));
if (me->band >= 0)
- drawband(me->ctx, NULL, me->list, &me->ctm, &me->tbounds, &me->cookie, me->band, me->pix, &me->bit);
+ drawband(me->ctx, NULL, me->list, &me->ctm, &me->tbounds, &me->cookie, me->band * bandheight, me->pix, &me->bit);
DEBUG_THREADS(("Worker %d completed band %d\n", me->num, me->band));
SEMAPHORE_TRIGGER(me->stop);
}