From 3c655b0a0fdbd08b3e476fd8e25f65af62139276 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 15 Dec 2009 22:14:09 +0000 Subject: [PATCH] apply r1491 + modification for BIG_ENDIAN to from mapnik2 - closes #444 --- include/mapnik/graphics.hpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/include/mapnik/graphics.hpp b/include/mapnik/graphics.hpp index d59d25134..2ef1456e0 100644 --- a/include/mapnik/graphics.hpp +++ b/include/mapnik/graphics.hpp @@ -369,13 +369,12 @@ namespace mapnik unsigned g0 = (rgba0 >> 16 ) & 0xff; unsigned b0 = (rgba0 >> 8) & 0xff; - unsigned a = (a1 * 255 + (255 - a1) * a0 + 127)/255; + r0 = uint8_t(((r1 - r0) * a1 + (r0 << 8)) >> 8); + g0 = uint8_t(((g1 - g0) * a1 + (g0 << 8)) >> 8); + b0 = uint8_t(((b1 - b0) * a1 + (b0 << 8)) >> 8); + a0 = uint8_t((a1 + a0) - ((a1 * a0 + 255) >> 8)); - r0 = (r1*a1 + (((255 - a1) * a0 + 127)/255) * r0 + 127)/a; - g0 = (g1*a1 + (((255 - a1) * a0 + 127)/255) * g0 + 127)/a; - b0 = (b1*a1 + (((255 - a1) * a0 + 127)/255) * b0 + 127)/a; - - row_to[x] = (a)| (b0 << 8) | (g0 << 16) | (r0 << 24) ; + row_to[x] = (a0)| (b0 << 8) | (g0 << 16) | (r0 << 24) ; #else unsigned a1 = int( ((rgba1 >> 24) & 0xff) * opacity ); if (a1 == 0) continue; @@ -388,13 +387,12 @@ namespace mapnik unsigned g0 = (rgba0 >> 8 ) & 0xff; unsigned b0 = (rgba0 >> 16) & 0xff; - unsigned a = (a1 * 255 + (255 - a1) * a0 + 127)/255; - - r0 = (r1*a1 + (((255 - a1) * a0 + 127)/255) * r0 + 127)/a; - g0 = (g1*a1 + (((255 - a1) * a0 + 127)/255) * g0 + 127)/a; - b0 = (b1*a1 + (((255 - a1) * a0 + 127)/255) * b0 + 127)/a; - - row_to[x] = (a << 24)| (b0 << 16) | (g0 << 8) | (r0) ; + r0 = uint8_t(((r1 - r0) * a1 + (r0 << 8)) >> 8); + g0 = uint8_t(((g1 - g0) * a1 + (g0 << 8)) >> 8); + b0 = uint8_t(((b1 - b0) * a1 + (b0 << 8)) >> 8); + a0 = uint8_t((a1 + a0) - ((a1 * a0 + 255) >> 8)); + + row_to[x] = (a0 << 24)| (b0 << 16) | (g0 << 8) | (r0) ; #endif } }