summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-05-20 17:10:56 +0200
committerTor Andersson <tor@ghostscript.com>2010-05-20 17:10:56 +0200
commit30b8e3187fed0ad8f4c879cbe08fdd75f496e693 (patch)
treec7ce9e801b89bde6955c6a096fc422f668769c4b /fitz
parent253bcbad9bfb5237e6b9b2a9f841dc2351ab275f (diff)
downloadmupdf-30b8e3187fed0ad8f4c879cbe08fdd75f496e693.tar.xz
Use more accurate fz_mul255.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/fitz_base.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/fitz/fitz_base.h b/fitz/fitz_base.h
index 9ef1cf46..293b0cc5 100644
--- a/fitz/fitz_base.h
+++ b/fitz/fitz_base.h
@@ -182,7 +182,12 @@ void *fz_hashgetval(fz_hashtable *table, int idx);
*/
/* multiply 8-bit fixpoint (0..1) so that 0*0==0 and 255*255==255 */
-#define fz_mul255(a,b) (((a) * ((b) + ((b) >> 7))) >> 8)
+static inline int fz_mul255(int a, int b)
+{
+ int x = a * b + 0x80;
+ x += x >> 8;
+ return x >> 8;
+}
typedef struct fz_matrix_s fz_matrix;
typedef struct fz_point_s fz_point;