summaryrefslogtreecommitdiff
path: root/source/fitz/output-pwg.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-05-23 17:45:21 +0100
committerRobin Watts <robin.watts@artifex.com>2016-05-24 12:48:35 +0100
commitd0b78f4166a1503ce522944002b3aab035724cd9 (patch)
treeb8c680dc401db56a28be1110759219c7c175dd8d /source/fitz/output-pwg.c
parent841952db71d6541a2e98fd4d1d49dede284b2cf8 (diff)
downloadmupdf-d0b78f4166a1503ce522944002b3aab035724cd9.tar.xz
fz_pixmap revamp: add stride and make alpha optional
fz_pixmaps now have an explicit stride value. By default no change from before, but code all copes with extra gaps at the end of the line. The alpha data in fz_pixmaps is no longer compulsory. mudraw: use rgb not rgba (ppmraw), cmyk not cmyka (pkmraw). Update halftone code to not expect alpha plane. Update PNG writing to cope with alpha less input. Also hide repeated params within the png output context. ARM code needs updating.
Diffstat (limited to 'source/fitz/output-pwg.c')
-rw-r--r--source/fitz/output-pwg.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/source/fitz/output-pwg.c b/source/fitz/output-pwg.c
index 9302009e..50e25a13 100644
--- a/source/fitz/output-pwg.c
+++ b/source/fitz/output-pwg.c
@@ -91,7 +91,7 @@ void
fz_write_pixmap_as_pwg_page(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap, const fz_pwg_options *pwg)
{
unsigned char *sp;
- int y, x, sn, dn, ss;
+ int y, x, sn, dn, ss, ss2;
if (!out || !pixmap)
return;
@@ -109,17 +109,18 @@ fz_write_pixmap_as_pwg_page(fz_context *ctx, fz_output *out, const fz_pixmap *pi
/* Now output the actual bitmap, using a packbits like compression */
sp = pixmap->samples;
ss = pixmap->w * sn;
+ ss2 = pixmap->stride;
y = 0;
while (y < pixmap->h)
{
int yrep;
- assert(sp == pixmap->samples + y * ss);
+ assert(sp == pixmap->samples + y * ss2);
/* Count the number of times this line is repeated */
for (yrep = 1; yrep < 256 && y+yrep < pixmap->h; yrep++)
{
- if (memcmp(sp, sp + yrep * ss, ss) != 0)
+ if (memcmp(sp, sp + yrep * ss2, ss) != 0)
break;
}
fz_write_byte(ctx, out, yrep-1);
@@ -130,7 +131,7 @@ fz_write_pixmap_as_pwg_page(fz_context *ctx, fz_output *out, const fz_pixmap *pi
{
int d;
- assert(sp == pixmap->samples + y * ss + x * sn);
+ assert(sp == pixmap->samples + y * ss2 + x * sn);
/* How far do we have to look to find a repeated value? */
for (d = 1; d < 128 && x+d < pixmap->w; d++)
@@ -169,7 +170,7 @@ fz_write_pixmap_as_pwg_page(fz_context *ctx, fz_output *out, const fz_pixmap *pi
}
/* Move to the next line */
- sp += ss*(yrep-1);
+ sp += ss2*(yrep-1);
y += yrep;
}
}