diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-07-17 01:41:20 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-07-17 01:41:20 +0000 |
commit | 3ac42a2ad5c49724d4972bac4f729d1a2ed57423 (patch) | |
tree | cf685c23608d4d06df7b93f2391da97a012f8009 /fitz/res_pixmap.c | |
parent | 2c79e6f2ccb72e8115aa51089f69be2560603016 (diff) | |
download | mupdf-3ac42a2ad5c49724d4972bac4f729d1a2ed57423.tar.xz |
Support SMasks for general graphics (incomplete).
Diffstat (limited to 'fitz/res_pixmap.c')
-rw-r--r-- | fitz/res_pixmap.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c index e1184fff..4599fb0c 100644 --- a/fitz/res_pixmap.c +++ b/fitz/res_pixmap.c @@ -51,11 +51,22 @@ fz_droppixmap(fz_pixmap *pix) } void -fz_clearpixmap(fz_pixmap *pix, unsigned char value) +fz_clearpixmap(fz_pixmap *pix, int value) { memset(pix->samples, value, pix->w * pix->h * pix->n); } +fz_bbox +fz_boundpixmap(fz_pixmap *pix) +{ + fz_bbox bbox; + bbox.x0 = pix->x; + bbox.y0 = pix->y; + bbox.x1 = pix->x + pix->w; + bbox.y1 = pix->y + pix->h; + return bbox; +} + void fz_gammapixmap(fz_pixmap *pix, float gamma) { @@ -72,6 +83,31 @@ fz_gammapixmap(fz_pixmap *pix, float gamma) } } +fz_pixmap * +fz_alphafromgray(fz_pixmap *gray, int luminosity) +{ + fz_pixmap *alpha; + unsigned char *sp, *dp; + int len; + + assert(gray->n == 2); + + alpha = fz_newpixmap(nil, gray->x, gray->y, gray->w, gray->h); + dp = alpha->samples; + sp = gray->samples; + if (!luminosity) + sp ++; + + len = gray->w * gray->h; + while (len--) + { + *dp++ = sp[0]; + sp += 2; + } + + return alpha; +} + /* * Write pixmap to PNM file (without alpha channel) */ |