#ifndef _BSPTREE_RGBTREE_HPP_ #define _BSPTREE_RGBTREE_HPP_ #ifndef _COMMON_PALETTEENTRY_HPP_ #include #endif #ifndef _COMMON_ARRAY_HPP_ #include #endif #ifndef _COMMON_SMARTPOINTER_HPP_ #include #endif #ifndef _BSPTREE_BTREE_HPP_ #include #endif #ifndef _BSPTREE_RGBNDX_HPP_ #include #endif #ifndef _BSPTREE_COLORKEY_HPP_ #include #endif #ifndef _BSPTREE_RGBSTACK_HPP_ #include #endif //#ifndef _COMMON_PVECTOR_TPP_ //#include //#endif #ifndef _BSPTREE_BTREE_TPP_ #include #endif class RGBTree : public BTree, private RGBStack { public: enum SearchType{SearchExact,SearchNearest}; RGBTree(void); virtual ~RGBTree(); WORD insertItems(Array &rgbItems); WORD insertItem(const RGBIndex &rgbItem); WORD insertItem(const RGBColor &rgbItem); WORD insertItem(const PaletteEntry &paletteEntryItem); BOOL searchItem(RGBIndex &rgbItem,SearchType searchType=SearchExact); BOOL searchItem(RGBColor &rgbColor,SearchType searchType=SearchExact); BOOL searchItem(RGBIndex &rgbItem,SmartPointer &rgbIndex,SearchType searchType=SearchExact); void setThreshold(WORD threshold); void deleteTree(void); private: enum {DefaultThreshold=10,MaxThreshold=255,CenterColor=128}; TreeNode *insertNode(TreeNode *lpRootNode,TreeNode *lpCurrentNode,const RGBIndex &rgbItem); RGBIndex *searchNodeExact(TreeNode *lpRootNode,const RGBIndex &rgbItem); RGBIndex *searchNodeNearest(TreeNode *lpRootNode,const RGBIndex &rgbItem); WORD middleIndex(Array &rgbItems)const; Array mVectoredColors; ColorKey mColorKey; WORD mThreshold; }; inline RGBTree::RGBTree(void) : mThreshold(DefaultThreshold) { } inline RGBTree::~RGBTree() { } inline void RGBTree::setThreshold(WORD threshold) { mThreshold=threshold; } inline void RGBTree::deleteTree(void) { remove(); } inline WORD RGBTree::insertItem(const RGBColor &rgbItem) { RGBIndex rgbIndex(rgbItem); return insertItem(rgbIndex); } inline WORD RGBTree::insertItem(const PaletteEntry &paletteEntryItem) { RGBIndex rgbIndex; rgbIndex.red(paletteEntryItem.red()); rgbIndex.green(paletteEntryItem.green()); rgbIndex.blue(paletteEntryItem.blue()); return insertItem(rgbIndex); } #endif