diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-05-20 17:10:56 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-05-20 17:10:56 +0200 |
commit | 30b8e3187fed0ad8f4c879cbe08fdd75f496e693 (patch) | |
tree | c7ce9e801b89bde6955c6a096fc422f668769c4b /draw | |
parent | 253bcbad9bfb5237e6b9b2a9f841dc2351ab275f (diff) | |
download | mupdf-30b8e3187fed0ad8f4c879cbe08fdd75f496e693.tar.xz |
Use more accurate fz_mul255.
Diffstat (limited to 'draw')
-rw-r--r-- | draw/porterduff.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/draw/porterduff.c b/draw/porterduff.c index c6b3dc9b..64fa842f 100644 --- a/draw/porterduff.c +++ b/draw/porterduff.c @@ -264,13 +264,14 @@ static void path_w4i1o4(byte * restrict argb, byte * restrict src, byte cov, int byte b = argb[3]; while (len--) { - byte ca; + byte ca, cca; cov += *src; *src = 0; src++; ca = fz_mul255(cov, alpha); + cca = 255 - ca; dst[0] = ca + fz_mul255(dst[0], 255 - ca); - dst[1] = fz_mul255((short)r - dst[1], ca) + dst[1]; - dst[2] = fz_mul255((short)g - dst[2], ca) + dst[2]; - dst[3] = fz_mul255((short)b - dst[3], ca) + dst[3]; + dst[1] = fz_mul255(r, ca) + fz_mul255(dst[1], cca); + dst[2] = fz_mul255(g, ca) + fz_mul255(dst[2], cca); + dst[3] = fz_mul255(b, ca) + fz_mul255(dst[3], cca); dst += 4; } } @@ -323,10 +324,11 @@ static void text_w4i1o4(byte * restrict argb, byte * restrict src0, int srcw, by while (w--) { byte ca = fz_mul255(src[0], alpha); + byte cca = 255 - ca; dst[0] = ca + fz_mul255(dst[0], 255 - ca); - dst[1] = fz_mul255((short)r - dst[1], ca) + dst[1]; - dst[2] = fz_mul255((short)g - dst[2], ca) + dst[2]; - dst[3] = fz_mul255((short)b - dst[3], ca) + dst[3]; + dst[1] = fz_mul255(r, ca) + fz_mul255(dst[1], cca); + dst[2] = fz_mul255(g, ca) + fz_mul255(dst[2], cca); + dst[3] = fz_mul255(b, ca) + fz_mul255(dst[3], cca); src ++; dst += 4; } |