diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-11-28 21:54:26 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-11-28 21:54:26 +0000 |
commit | 71a1131902da7e7f41566eb67cae3cad60bb14f4 (patch) | |
tree | 9900a5be346d04d811ec2282a35be3d37e5b6951 /fitz | |
parent | d63dc50e7d0ac6f1adccd9507b41410e0cbb0faf (diff) | |
download | mupdf-71a1131902da7e7f41566eb67cae3cad60bb14f4.tar.xz |
Support luminosity softmask background colors.
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/dev_draw.c | 36 | ||||
-rw-r--r-- | fitz/fitz.h | 3 | ||||
-rw-r--r-- | fitz/res_font.c | 2 | ||||
-rw-r--r-- | fitz/res_pixmap.c | 25 |
4 files changed, 47 insertions, 19 deletions
diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c index e321eaf4..aef2ee1e 100644 --- a/fitz/dev_draw.c +++ b/fitz/dev_draw.c @@ -135,8 +135,8 @@ fz_drawclippath(void *user, fz_path *path, int evenodd, fz_matrix ctm) mask = fz_newpixmapwithrect(nil, bbox); dest = fz_newpixmapwithrect(model, bbox); - fz_clearpixmap(mask, 0); - fz_clearpixmap(dest, 0); + fz_clearpixmap(mask); + fz_clearpixmap(dest); fz_scanconvert(dev->gel, dev->ael, evenodd, bbox, mask, nil); @@ -181,8 +181,8 @@ fz_drawclipstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matr mask = fz_newpixmapwithrect(nil, bbox); dest = fz_newpixmapwithrect(model, bbox); - fz_clearpixmap(mask, 0); - fz_clearpixmap(dest, 0); + fz_clearpixmap(mask); + fz_clearpixmap(dest); if (!fz_isemptyrect(bbox)) fz_scanconvert(dev->gel, dev->ael, 0, bbox, mask, nil); @@ -353,8 +353,8 @@ fz_drawcliptext(void *user, fz_text *text, fz_matrix ctm, int accumulate) mask = fz_newpixmapwithrect(nil, bbox); dest = fz_newpixmapwithrect(model, bbox); - fz_clearpixmap(mask, 0); - fz_clearpixmap(dest, 0); + fz_clearpixmap(mask); + fz_clearpixmap(dest); dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].mask = mask; @@ -420,8 +420,8 @@ fz_drawclipstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matr mask = fz_newpixmapwithrect(nil, bbox); dest = fz_newpixmapwithrect(model, bbox); - fz_clearpixmap(mask, 0); - fz_clearpixmap(dest, 0); + fz_clearpixmap(mask); + fz_clearpixmap(dest); dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].mask = mask; @@ -496,7 +496,7 @@ fz_drawfillshade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) if (alpha < 1) { dest = fz_newpixmapwithrect(dev->dest->colorspace, bbox); - fz_clearpixmap(dest, 0); + fz_clearpixmap(dest); } if (shade->usebackground) @@ -718,8 +718,8 @@ fz_drawclipimagemask(void *user, fz_pixmap *image, fz_matrix ctm) mask = fz_newpixmapwithrect(nil, bbox); dest = fz_newpixmapwithrect(model, bbox); - fz_clearpixmap(mask, 0); - fz_clearpixmap(dest, 0); + fz_clearpixmap(mask); + fz_clearpixmap(dest); #ifdef SMOOTHSCALE dx = sqrtf(ctm.a * ctm.a + ctm.b * ctm.b); @@ -799,9 +799,15 @@ fz_drawbeginmask(void *user, fz_rect rect, int luminosity, fz_colorspace *colors dest = fz_newpixmapwithrect(fz_devicegray, bbox); if (luminosity) - fz_clearpixmap(dest, 255); + { + float bc; + if (!colorspace) + colorspace = fz_devicegray; + fz_convertcolor(colorspace, colorfv, fz_devicegray, &bc); + fz_clearpixmapwithcolor(dest, bc * 255); + } else - fz_clearpixmap(dest, 0); + fz_clearpixmap(dest); dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].dest = dev->dest; @@ -842,7 +848,7 @@ fz_drawendmask(void *user) /* create new dest scratch buffer */ bbox = fz_boundpixmap(temp); dest = fz_newpixmapwithrect(dev->dest->colorspace, bbox); - fz_clearpixmap(dest, 0); + fz_clearpixmap(dest); /* push soft mask as clip mask */ dev->stack[dev->top].scissor = dev->scissor; @@ -872,7 +878,7 @@ fz_drawbegingroup(void *user, fz_rect rect, int isolated, int knockout, fz_blend bbox = fz_intersectbbox(bbox, dev->scissor); dest = fz_newpixmapwithrect(model, bbox); - fz_clearpixmap(dest, 0); + fz_clearpixmap(dest); dev->stack[dev->top].alpha = alpha; dev->stack[dev->top].blendmode = blendmode; diff --git a/fitz/fitz.h b/fitz/fitz.h index 57161305..ac3bf00f 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -599,7 +599,8 @@ fz_pixmap * fz_newpixmapwithrect(fz_colorspace *, fz_bbox bbox); fz_pixmap * fz_newpixmap(fz_colorspace *, int x, int y, int w, int h); fz_pixmap *fz_keeppixmap(fz_pixmap *pix); void fz_droppixmap(fz_pixmap *pix); -void fz_clearpixmap(fz_pixmap *pix, int value); +void fz_clearpixmap(fz_pixmap *pix); +void fz_clearpixmapwithcolor(fz_pixmap *pix, int value); void fz_gammapixmap(fz_pixmap *pix, float gamma); fz_pixmap *fz_alphafromgray(fz_pixmap *gray, int luminosity); fz_bbox fz_boundpixmap(fz_pixmap *pix); diff --git a/fitz/res_font.c b/fitz/res_font.c index fd3bbe3f..26d7267f 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -475,7 +475,7 @@ fz_rendert3glyph(fz_font *font, int gid, fz_matrix trm) fz_freedevice(dev); glyph = fz_newpixmap(fz_devicegray, bbox.x0-1, bbox.y0-1, bbox.x1 - bbox.x0 + 1, bbox.y1 - bbox.y0 + 1); - fz_clearpixmap(glyph, 0); + fz_clearpixmap(glyph); cache = fz_newglyphcache(); dev = fz_newdrawdevice(cache, glyph); diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c index 4826502e..7455338a 100644 --- a/fitz/res_pixmap.c +++ b/fitz/res_pixmap.c @@ -70,9 +70,30 @@ fz_droppixmap(fz_pixmap *pix) } void -fz_clearpixmap(fz_pixmap *pix, int value) +fz_clearpixmap(fz_pixmap *pix) { - memset(pix->samples, value, pix->w * pix->h * pix->n); + memset(pix->samples, 0, pix->w * pix->h * pix->n); +} + +void +fz_clearpixmapwithcolor(fz_pixmap *pix, int value) +{ + if (value == 255) + memset(pix->samples, 255, pix->w * pix->h * pix->n); + else + { + int k, x, y; + unsigned char *s = pix->samples; + for (y = 0; y < pix->h; y++) + { + for (x = 0; x < pix->w; x++) + { + for (k = 0; k < pix->n - 1; k++) + *s++ = value; + *s++ = 255; + } + } + } } fz_bbox |