diff options
Diffstat (limited to 'lib/libpamcolor.c')
-rw-r--r-- | lib/libpamcolor.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/libpamcolor.c b/lib/libpamcolor.c index e11415ca..b64f8963 100644 --- a/lib/libpamcolor.c +++ b/lib/libpamcolor.c @@ -5,12 +5,16 @@ that deal with colors in the PAM image format. -----------------------------------------------------------------------------*/ -/* See libpbm.c for the complicated explanation of this 32/64 bit file +/* See pmfileio.c for the complicated explanation of this 32/64 bit file offset stuff. */ #define _FILE_OFFSET_BITS 64 #define _LARGE_FILES +#define _BSD_SOURCE 1 /* Make sure strdup() is in string.h */ +#define _XOPEN_SOURCE 500 /* Make sure strdup() is in string.h */ + +#include <string.h> #include <limits.h> #include "pm_c_util.h" @@ -44,6 +48,34 @@ pnm_parsecolor(const char * const colorname, +const char * +pnm_colorname(struct pam * const pamP, + tuple const color, + int const hexok) { + + const char * retval; + pixel colorp; + char * colorname; + + if (pamP->depth < 3) + PPM_ASSIGN(colorp, color[0], color[0], color[0]); + else + PPM_ASSIGN(colorp, + color[PAM_RED_PLANE], + color[PAM_GRN_PLANE], + color[PAM_BLU_PLANE]); + + colorname = ppm_colorname(&colorp, pamP->maxval, hexok); + + retval = strdup(colorname); + if (retval == NULL) + pm_error("Couldn't get memory for color name string"); + + return retval; +} + + + double pnm_lumin_factor[3] = {PPM_LUMINR, PPM_LUMING, PPM_LUMINB}; void |