summaryrefslogtreecommitdiff
path: root/source/fitz/pixmap.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-07-21 11:35:36 +0100
committerRobin Watts <robin.watts@artifex.com>2017-07-27 12:32:56 +0100
commit4fad9fb0b65bd5a96dfd3ef13f66ccbf442490a3 (patch)
treeeaa6862e530fc08186415267aa8da86a319513e5 /source/fitz/pixmap.c
parent292e73cd878d39d0c643a8302db644091502ad43 (diff)
downloadmupdf-4fad9fb0b65bd5a96dfd3ef13f66ccbf442490a3.tar.xz
Fix clearing of cmyk + spots pixmaps.
Diffstat (limited to 'source/fitz/pixmap.c')
-rw-r--r--source/fitz/pixmap.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c
index 30ec27d5..1c4ea52b 100644
--- a/source/fitz/pixmap.c
+++ b/source/fitz/pixmap.c
@@ -276,7 +276,7 @@ clear_cmyka_bitmap_ARM(uint32_t *samples, int c, int value)
#endif
static void
-clear_cmyk_bitmap(unsigned char *samples, int w, int h, int stride, int value, int alpha)
+clear_cmyk_bitmap(unsigned char *samples, int w, int h, int spots, int stride, int value, int alpha)
{
uint32_t *s = (uint32_t *)(void *)samples;
uint8_t *t;
@@ -284,6 +284,25 @@ clear_cmyk_bitmap(unsigned char *samples, int w, int h, int stride, int value, i
if (w < 0 || h < 0)
return;
+ if (spots)
+ {
+ int x, i;
+ spots += 4;
+ stride -= w * (spots + alpha);
+ for (; h > 0; h--)
+ {
+ for (x = w; x > 0; x--)
+ {
+ for (i = spots; i > 0; i--)
+ *samples++ = value;
+ if (alpha)
+ *samples++ = 255;
+ }
+ samples += stride;
+ }
+ return;
+ }
+
if (alpha)
{
int c = w;
@@ -449,6 +468,8 @@ fz_clear_pixmap(fz_context *ctx, fz_pixmap *pix)
}
}
+/* This function is horrible, and should be removed from the
+ * API and replaced with a less magic one. */
void
fz_clear_pixmap_with_value(fz_context *ctx, fz_pixmap *pix, int value)
{
@@ -464,7 +485,7 @@ fz_clear_pixmap_with_value(fz_context *ctx, fz_pixmap *pix, int value)
/* CMYK needs special handling (and potentially any other subtractive colorspaces) */
if (fz_colorspace_n(ctx, pix->colorspace) == 4)
{
- clear_cmyk_bitmap(pix->samples, w, h, pix->stride, 255-value, pix->alpha);
+ clear_cmyk_bitmap(pix->samples, w, h, pix->s, pix->stride, 255-value, pix->alpha);
return;
}