00001 #ifndef __ColorPaletteEvaluator__ 00002 #define __ColorPaletteEvaluator__ 00003 00024 #include "AnImage.hpp" 00025 00026 class ColorPaletteEvaluator 00027 { 00028 private: 00029 00030 int nsize; 00031 00032 bool* active; 00033 int* entry; 00034 int* rank; 00035 00036 int n, nmax; 00037 00038 protected: 00039 00040 int getKey(int rgb); 00041 int getKey(int r, int g, int b){ return getKey( r << 16 | g << 8 | b ); } 00042 00043 public: 00044 ColorPaletteEvaluator(int nentries=256); 00045 ~ColorPaletteEvaluator(){delete[] active; delete[] rank; delete[] entry;} 00046 00047 void init(); 00048 00049 bool addEntry(int r, int g, int b); 00050 00051 bool evaluate(AnImage* colorIm); 00052 int numberOfEntries(){return n;} 00053 00054 bool isActive(int index){return active[index];} 00055 int getEntry(int index){return entry[index];} 00056 int getRank(int index){return rank[index];} 00057 00058 int getIndex(int rgb); 00059 int getIndex(int r, int g, int b){ return getIndex( r << 16 | g << 8 | b ); } 00060 00061 int getValue(int iposition); 00062 00063 int getRed(int iposition); 00064 int getGreen(int iposition); 00065 int getBlue(int iposition); 00066 00067 int getPaletteIndex(int r, int g, int b); 00068 }; 00069 00070 00071 #endif