diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-03-31 03:18:51 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-03-31 03:18:51 +0200 |
commit | b3f90095897b64f854efc4b2f37df428a71fd508 (patch) | |
tree | 27ad639a052b967e1fdc03f7d58ff63b5b0a8f46 /fitz | |
parent | 4f484b32f3cf8682180ccb9e36f929edff175498 (diff) | |
download | mupdf-b3f90095897b64f854efc4b2f37df428a71fd508.tar.xz |
xps: Clean up image loading code, and handle images with alpha.
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/fitz.h | 1 | ||||
-rw-r--r-- | fitz/res_pixmap.c | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/fitz/fitz.h b/fitz/fitz.h index 72af4532..5d3ba1c1 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -685,6 +685,7 @@ fz_pixmap *fz_keeppixmap(fz_pixmap *pix); void fz_droppixmap(fz_pixmap *pix); void fz_clearpixmap(fz_pixmap *pix); void fz_clearpixmapwithcolor(fz_pixmap *pix, int value); +void fz_premultiplypixmap(fz_pixmap *pix); fz_pixmap *fz_alphafromgray(fz_pixmap *gray, int luminosity); fz_bbox fz_boundpixmap(fz_pixmap *pix); diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c index e70d084d..b37b7a3e 100644 --- a/fitz/res_pixmap.c +++ b/fitz/res_pixmap.c @@ -97,6 +97,24 @@ fz_clearpixmapwithcolor(fz_pixmap *pix, int value) } } +void +fz_premultiplypixmap(fz_pixmap *pix) +{ + unsigned char *s = pix->samples; + unsigned char a; + int k, x, y; + for (y = 0; y < pix->h; y++) + { + for (x = 0; x < pix->w; x++) + { + a = s[pix->n - 1]; + for (k = 0; k < pix->n - 1; k++) + s[k] = fz_mul255(s[k], a); + s += pix->n; + } + } +} + fz_bbox fz_boundpixmap(fz_pixmap *pix) { |