00001 /* colHash - stuff for fast lookup of index given an 00002 * rgb value. */ 00003 #ifndef COLHASH_H 00004 #define COLHASH_H 00005 00006 #define colHashFunc(r,g,b) (r+g+g+b) 00007 00008 struct colHashEl 00009 /* An element in a color hash. */ 00010 { 00011 struct colHashEl *next; /* Next in list. */ 00012 struct rgbColor col; /* Color RGB. */ 00013 int ix; /* Color Index. */ 00014 }; 00015 00016 struct colHash 00017 /* A hash on RGB colors. */ 00018 { 00019 struct colHashEl *lists[4*256]; /* Hash chains. */ 00020 struct colHashEl elBuf[256]; /* Buffer of elements. */ 00021 struct colHashEl *freeEl; /* Pointer to next free element. */ 00022 }; 00023 00024 struct colHash *colHashNew(); 00025 /* Get a new color hash. */ 00026 00027 void colHashFree(struct colHash **pEl); 00028 /* Free up color hash. */ 00029 00030 struct colHashEl *colHashAdd(struct colHash *cHash, 00031 unsigned r, unsigned g, unsigned b, int ix); 00032 /* Add new element to color hash. */ 00033 00034 struct colHashEl *colHashLookup(struct colHash *cHash, 00035 unsigned r, unsigned g, unsigned b); 00036 /* Lookup value in hash. */ 00037 00038 #endif /* COLHASH_H */
1.5.2