From 7514dd26ce5ab558c7ebbca5d5bd3dce689a55d3 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Wed, 27 Mar 2024 17:34:26 +0000 Subject: cleanup git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4888 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- lib/libppmcmap.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/libppmcmap.c') 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) { -- cgit 1.4.1