diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-10 01:24:01 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-10 01:24:01 +0200 |
commit | d914e3415af1c9c7d8644dfa50fdcf9a79cc01d5 (patch) | |
tree | 42b1abdc4ebe58dd008d9f8906db24fa5187324d /draw/draw_blend.c | |
parent | e8e507b38b8c4429abd6e7b32fe8e3029bfab065 (diff) | |
download | mupdf-d914e3415af1c9c7d8644dfa50fdcf9a79cc01d5.tar.xz |
Make blendmode opaque.
Diffstat (limited to 'draw/draw_blend.c')
-rw-r--r-- | draw/draw_blend.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/draw/draw_blend.c b/draw/draw_blend.c index 2d68758a..ef9d8c7c 100644 --- a/draw/draw_blend.c +++ b/draw/draw_blend.c @@ -4,7 +4,30 @@ typedef unsigned char byte; -const char *fz_blendmode_names[] = +enum +{ + /* PDF 1.4 -- standard separable */ + FZ_BLEND_NORMAL, + FZ_BLEND_MULTIPLY, + FZ_BLEND_SCREEN, + FZ_BLEND_OVERLAY, + FZ_BLEND_DARKEN, + FZ_BLEND_LIGHTEN, + FZ_BLEND_COLOR_DODGE, + FZ_BLEND_COLOR_BURN, + FZ_BLEND_HARD_LIGHT, + FZ_BLEND_SOFT_LIGHT, + FZ_BLEND_DIFFERENCE, + FZ_BLEND_EXCLUSION, + + /* PDF 1.4 -- standard non-separable */ + FZ_BLEND_HUE, + FZ_BLEND_SATURATION, + FZ_BLEND_COLOR, + FZ_BLEND_LUMINOSITY, +}; + +static const char *fz_blendmode_names[] = { "Normal", "Multiply", @@ -22,9 +45,24 @@ const char *fz_blendmode_names[] = "Saturation", "Color", "Luminosity", - NULL }; +int fz_find_blendmode(char *name) +{ + int i; + for (i = 0; i < nelem(fz_blendmode_names); i++) + if (!strcmp(name, fz_blendmode_names[i])) + return i; + return FZ_BLEND_NORMAL; +} + +char *fz_blendmode_name(int blendmode) +{ + if (blendmode >= 0 && blendmode < nelem(fz_blendmode_names)) + return (char*)fz_blendmode_names[blendmode]; + return "Normal"; +} + /* Separable blend modes */ static inline int fz_screen_byte(int b, int s) @@ -218,7 +256,7 @@ fz_hue_rgb(int *rr, int *rg, int *rb, int br, int bg, int bb, int sr, int sg, in /* Blending loops */ void -fz_blend_separable(byte * restrict bp, byte * restrict sp, int n, int w, fz_blendmode blendmode) +fz_blend_separable(byte * restrict bp, byte * restrict sp, int n, int w, int blendmode) { int k; int n1 = n - 1; @@ -266,7 +304,7 @@ fz_blend_separable(byte * restrict bp, byte * restrict sp, int n, int w, fz_blen } void -fz_blend_nonseparable(byte * restrict bp, byte * restrict sp, int w, fz_blendmode blendmode) +fz_blend_nonseparable(byte * restrict bp, byte * restrict sp, int w, int blendmode) { while (w--) { @@ -316,7 +354,7 @@ fz_blend_nonseparable(byte * restrict bp, byte * restrict sp, int w, fz_blendmod } void -fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode) +fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, int blendmode) { unsigned char *sp, *dp; fz_bbox bbox; |