[mapserver-commits] r11220 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Fri Mar 18 10:11:16 EDT 2011
Author: warmerdam
Date: 2011-03-18 07:11:16 -0700 (Fri, 18 Mar 2011)
New Revision: 11220
Modified:
trunk/mapserver/maputil.c
Log:
avoid integer division where possible
Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c 2011-03-18 14:07:45 UTC (rev 11219)
+++ trunk/mapserver/maputil.c 2011-03-18 14:11:16 UTC (rev 11220)
@@ -1913,21 +1913,21 @@
/* -------------------------------------------------------------------- */
if(!alpha_dst || *alpha_dst == 255)
{
- int weight_dst = 255 - alpha_src;
+ int weight_dst = 256 - alpha_src;
- *red_dst = (255 * red_src + *red_dst * weight_dst) / 255;
- *green_dst = (255 * green_src + *green_dst * weight_dst) / 255;
- *blue_dst = (255 * blue_src + *blue_dst * weight_dst) / 255;
+ *red_dst = (256 * red_src + *red_dst * weight_dst) >> 8;
+ *green_dst = (256 * green_src + *green_dst * weight_dst) >> 8;
+ *blue_dst = (256 * blue_src + *blue_dst * weight_dst) >> 8;
}
else
{
- int weight_dst = (255 - alpha_src);
+ int weight_dst = (256 - alpha_src);
- *red_dst = (255 * red_src + *red_dst * weight_dst) / 255;
- *green_dst = (255 * green_src + *green_dst * weight_dst) / 255;
- *blue_dst = (255 * blue_src + *blue_dst * weight_dst) / 255;
+ *red_dst = (256 * red_src + *red_dst * weight_dst) >> 8;
+ *green_dst = (256 * green_src + *green_dst * weight_dst) >> 8;
+ *blue_dst = (256 * blue_src + *blue_dst * weight_dst) >> 8;
- *alpha_dst = (alpha_src * 255 + *alpha_dst * weight_dst) / 255;
+ *alpha_dst = (256 * alpha_src + *alpha_dst * weight_dst) >> 8;
}
}
@@ -1976,21 +1976,21 @@
/* -------------------------------------------------------------------- */
if(!alpha_dst || *alpha_dst == 255)
{
- int weight_dst = 255 - alpha_src;
+ int weight_dst = 256 - alpha_src;
- *red_dst = (255 * red_src + *red_dst * weight_dst) / 255;
- *green_dst = (255 * green_src + *green_dst * weight_dst) / 255;
- *blue_dst = (255 * blue_src + *blue_dst * weight_dst) / 255;
+ *red_dst = (256 * red_src + *red_dst * weight_dst) >> 8;
+ *green_dst = (256 * green_src + *green_dst * weight_dst) >> 8;
+ *blue_dst = (256 * blue_src + *blue_dst * weight_dst) >> 8;
}
else
{
- int weight_dst = (255 - alpha_src);
+ int weight_dst = (256 - alpha_src);
- *red_dst = (255 * red_src + *red_dst * weight_dst) / 255;
- *green_dst = (255 * green_src + *green_dst * weight_dst) / 255;
- *blue_dst = (255 * blue_src + *blue_dst * weight_dst) / 255;
+ *red_dst = (256 * red_src + *red_dst * weight_dst) >> 8;
+ *green_dst = (256 * green_src + *green_dst * weight_dst) >> 8;
+ *blue_dst = (256 * blue_src + *blue_dst * weight_dst) >> 8;
- *alpha_dst = (alpha_src * 255 + *alpha_dst * weight_dst) / 255;
+ *alpha_dst = (256 * alpha_src + *alpha_dst * weight_dst) >> 8;
}
}
More information about the mapserver-commits
mailing list