about summary refs log tree commit diff
path: root/lib/libppmcmap.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2024-03-27 17:34:26 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2024-03-27 17:34:26 +0000
commit7514dd26ce5ab558c7ebbca5d5bd3dce689a55d3 (patch)
tree1d2e59b1e61d5232877e672c5963e4c7172b8e1b /lib/libppmcmap.c
parent6c23074f55ef954ee803262e3d452ccc6fd6af01 (diff)
downloadnetpbm-mirror-7514dd26ce5ab558c7ebbca5d5bd3dce689a55d3.tar.gz
netpbm-mirror-7514dd26ce5ab558c7ebbca5d5bd3dce689a55d3.tar.xz
netpbm-mirror-7514dd26ce5ab558c7ebbca5d5bd3dce689a55d3.zip
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4888 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/libppmcmap.c')
-rw-r--r--lib/libppmcmap.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libppmcmap.c b/lib/libppmcmap.c
index 0f6439ae..24302c6a 100644
--- a/lib/libppmcmap.c
+++ b/lib/libppmcmap.c
@@ -784,17 +784,23 @@ int
 ppm_findclosestcolor(const pixel * const colormap,
                      int           const ncolors,
                      const pixel * const pP) {
+/*----------------------------------------------------------------------------
+  The index in colormap[] (which has 'ncolors' entries) of the color that is
+  closest to color *pP.
 
-    /* Search colormap for closest match.       */
+  Where two entries in colormap[] are identical, return the lesser of their
+  two indices.
 
-    int i;
+  Iff there are no colors in the amp ('ncolors' is zero), return -1.
+-----------------------------------------------------------------------------*/
+    unsigned int i;
     int ind;
     unsigned int bestDist;
 
     bestDist = UINT_MAX;
     ind = -1;
 
-    for(i = 0; i < ncolors && bestDist > 0; ++i) {
+    for (i = 0; i < ncolors && bestDist > 0; ++i) {
         unsigned int const dist = PPM_DISTANCE(*pP, colormap[i]);
 
         if (dist < bestDist ) {
@@ -806,6 +812,7 @@ ppm_findclosestcolor(const pixel * const colormap,
 }
 
 
+
 void
 ppm_colorrowtomapfile(FILE *ofp, pixel *colormap, int ncolors, pixval maxval)
 {