diff options
author | Adam Jackson <ajax@nwnk.net> | 2006-04-03 22:06:24 +0000 |
---|---|---|
committer | Adam Jackson <ajax@nwnk.net> | 2006-04-03 22:06:24 +0000 |
commit | c3eb5d737f8281a3c7ffaf592c443d41a47f5c40 (patch) | |
tree | 76e8e26d3722e0aacd7ed83ef727f9209bd6ae38 | |
parent | b7b26fefc1b334672e84a16c8caf5edd2b85f294 (diff) |
Bug #3270: Fix rounding errors.XORG-7_0_99_901
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | xcursorgen.c | 8 |
2 files changed, 10 insertions, 3 deletions
@@ -1,3 +1,8 @@ +2006-04-03 Adam Jackson <ajax@freedesktop.org> + + * xcursorgen.c: + Bug #3270: Fix rounding errors. + 2005-12-14 Kevin E. Martin <kem-at-freedesktop-dot-org> * configure.ac: diff --git a/xcursorgen.c b/xcursorgen.c index 60b2855..863a2e5 100644 --- a/xcursorgen.c +++ b/xcursorgen.c @@ -149,6 +149,8 @@ read_config_file (char *config, struct flist **list) return count; } +#define div_255(x) (((x) + 0x80 + (((x) + 0x80) >> 8)) >> 8) + static void premultiply_data (png_structp png, png_row_infop row_info, png_bytep data) { @@ -163,9 +165,9 @@ premultiply_data (png_structp png, png_row_infop row_info, png_bytep data) unsigned char alpha = base[3]; XcursorPixel p; - red = (unsigned) red * (unsigned) alpha / 255; - green = (unsigned) green * (unsigned) alpha / 255; - blue = (unsigned) blue * (unsigned) alpha / 255; + red = div_255((unsigned)red * (unsigned)alpha); + green = div_255((unsigned)green * (unsigned)alpha); + blue = div_255((unsigned)blue * (unsigned)alpha); p = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); memcpy (base, &p, sizeof (XcursorPixel)); } |