diff options
Diffstat (limited to 'lib/ppm.h')
-rw-r--r-- | lib/ppm.h | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/lib/ppm.h b/lib/ppm.h index 9fc90bb3..9fa547fe 100644 --- a/lib/ppm.h +++ b/lib/ppm.h @@ -161,6 +161,36 @@ ppm_colorname(const pixel* const colorP, pixval const maxval, int const hexok); +typedef struct { + unsigned int version; + const char ** name; + /* malloced, and each entry malloced. Has space for at least 'size' + entries. May be null if size == 0 + */ + pixel * color; /* malloced */ + /* malloced. Has space for at least 'size' entries. May be null if + size == 0 + */ + unsigned int size; + /* allocated size of 'name' and 'color'. At least 'count' */ + unsigned int count; + /* number of entries used.*/ + colorhash_table cht; + /* Hash table mapping name[] to color[] */ +} ppm_ColorDict; + +ppm_ColorDict * +ppm_colorDict_new(const char * const fileName, + int const mustOpen); + +void +ppm_colorDict_destroy(ppm_ColorDict * colorDictP); + +void +ppm_readcolordict2(const char * const fileName, + int const mustOpen, + ppm_ColorDict ** const colorDictP); + void ppm_readcolordict(const char * const fileName, int const mustOpen, @@ -185,9 +215,9 @@ ppm_freecolornames(const char ** const colornames); #define PPM_DEPTH(newp,p,oldmaxval,newmaxval) \ PPM_ASSIGN( (newp), \ - ( (int) PPM_GETR(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \ - ( (int) PPM_GETG(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \ - ( (int) PPM_GETB(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval) ) + ( (int) PPM_GETR(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \ + ( (int) PPM_GETG(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \ + ( (int) PPM_GETB(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval) ) #define PPM_SQR(x) (x)*(x) |