about summary refs log tree commit diff
path: root/other/pnmcolormap.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2008-07-11 16:04:31 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2008-07-11 16:04:31 +0000
commit782a4aef6be298d544c506433375cd2db99d4d6d (patch)
tree990d9c70491bf1f5b10587cdf52ef0ff62df035f /other/pnmcolormap.c
parent8fa313dd11896529aaf0a1573c594b5374b5b39d (diff)
downloadnetpbm-mirror-782a4aef6be298d544c506433375cd2db99d4d6d.tar.gz
netpbm-mirror-782a4aef6be298d544c506433375cd2db99d4d6d.tar.xz
netpbm-mirror-782a4aef6be298d544c506433375cd2db99d4d6d.zip
Round instead of truncate in division to compute mean
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@669 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'other/pnmcolormap.c')
-rw-r--r--other/pnmcolormap.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/other/pnmcolormap.c b/other/pnmcolormap.c
index 4faf5ab6..42b03063 100644
--- a/other/pnmcolormap.c
+++ b/other/pnmcolormap.c
@@ -26,11 +26,12 @@
 #include <math.h>
 
 #include "pm_config.h"
-#include "pam.h"
-#include "pammap.h"
-#include "shhopt.h"
+#include "pm_c_util.h"
 #include "mallocvar.h"
 #include "nstring.h"
+#include "shhopt.h"
+#include "pam.h"
+#include "pammap.h"
 
 enum methodForLargest {LARGE_NORM, LARGE_LUM};
 
@@ -380,7 +381,7 @@ averageColors(int          const boxStart,
         for (i = 0; i < boxSize; ++i) 
             sum += colorfreqtable.table[boxStart+i]->tuple[plane];
 
-        newTuple[plane] = sum / boxSize;
+        newTuple[plane] = ROUNDDIV(sum, boxSize);
     }
 }
 
@@ -414,7 +415,7 @@ averagePixels(int          const boxStart,
             sum += colorfreqtable.table[boxStart+i]->tuple[plane]
                 * colorfreqtable.table[boxStart+i]->value;
 
-        newTuple[plane] = sum / n;
+        newTuple[plane] = ROUNDDIV(sum, n);
     }
 }