summaryrefslogtreecommitdiff
path: root/source/fitz/output-pnm.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-01-06 17:49:19 +0000
committerRobin Watts <robin.watts@artifex.com>2017-01-06 18:04:32 +0000
commit16911233da82601e2df6b0af49fc2136db38535d (patch)
treee140bc4262105641a2a32f9522ce605ee86ebcb2 /source/fitz/output-pnm.c
parentcb91a7732e2e2475f4bcd5cea8ac847a78e24a66 (diff)
downloadmupdf-16911233da82601e2df6b0af49fc2136db38535d.tar.xz
Fix /dev/null slowdown.
In commit 80308eae9964e71b66a18f3de6ebcd2ebf0d306b ("Regularize band writer interface"), I inadvertently slowed down outputting to /dev/null. Fixed here. Also take the opportunity to speed ppm/pnm files writing in general if we don't need to collate.
Diffstat (limited to 'source/fitz/output-pnm.c')
-rw-r--r--source/fitz/output-pnm.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/fitz/output-pnm.c b/source/fitz/output-pnm.c
index 3a605524..68f25bcb 100644
--- a/source/fitz/output-pnm.c
+++ b/source/fitz/output-pnm.c
@@ -39,6 +39,9 @@ pnm_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta
if (n-alpha != 1 && n-alpha != 3)
fz_throw(ctx, FZ_ERROR_GENERIC, "pixmap must be grayscale or rgb to write as pnm");
+ if (!out)
+ return;
+
if (end > h)
end = h;
end -= band_start;
@@ -78,6 +81,9 @@ pnm_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta
break;
}
case 3:
+ fz_write(ctx, out, p, num_written*3);
+ p += num_written*3;
+ break;
case 4:
{
char *o = buffer;
@@ -188,6 +194,9 @@ pam_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta
int y;
int end = band_start + band_height;
+ if (!out)
+ return;
+
if (end > h)
end = h;
end -= band_start;