UtiLite
0.3.1
A lite utilities library
|
00001 /* 00002 * utilite is a cross-platform library with 00003 * useful utilities for fast and small developing. 00004 * Copyright (C) 2010 Mathieu Labbe 00005 * 00006 * utilite is free library: you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * utilite is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef COLORTABLE_H 00021 #define COLORTABLE_H 00022 00023 #include "utilite/UtiLiteCvExp.h" // DLL export/import defines 00024 00025 #include <vector> 00026 00031 // 00032 class UTILITECV_EXP UColorTable 00033 { 00034 public: 00035 enum Size{kSize8 = 8, 00036 kSize16 = 16, 00037 kSize32 = 32, 00038 kSize64 = 64, 00039 kSize128 = 128, 00040 kSize256 = 256, 00041 kSize512 = 512, 00042 kSize1024 = 1024, 00043 kSize2048 = 2048, 00044 kSize4096 = 4096, 00045 kSize8192 = 8192, 00046 kSize16384 = 16384, 00047 kSize32768 = 32768, 00048 kSize65536 = 65536, 00049 kSize16777216 = 16777216}; 00050 public: 00051 UColorTable(int size); 00052 virtual ~UColorTable() {} 00053 00054 static unsigned char INDEXED_TABLE_8[24]; 00055 static unsigned char INDEXED_TABLE_16[48]; 00056 static unsigned char INDEXED_TABLE_32[96]; 00057 static unsigned char INDEXED_TABLE_64[192]; 00058 static unsigned char INDEXED_TABLE_128[384]; 00059 static unsigned char INDEXED_TABLE_256[768]; 00060 static unsigned char INDEXED_TABLE_512[1536]; 00061 static unsigned char INDEXED_TABLE_1024[3076]; 00062 static unsigned char INDEXED_TABLE_2048[6144]; 00063 static unsigned char INDEXED_TABLE_4096[12288]; 00064 static unsigned char INDEXED_TABLE_8192[24576]; 00065 static unsigned char INDEXED_TABLE_16384[49152]; 00066 static unsigned char INDEXED_TABLE_32768[98304]; 00067 static unsigned char INDEXED_TABLE_65536[196608]; 00068 00069 int size() const {return _size;} 00070 unsigned int getIndex(unsigned char r, unsigned char g, unsigned char b) const; 00071 void getRgb(unsigned int index, unsigned char & r, unsigned char & g, unsigned char & b) const; 00072 00073 private: 00074 int _size; 00075 std::vector<unsigned short> _rgb2indexed; 00076 unsigned char * _indexedTable; 00077 }; 00078 00079 #endif // COLORTABLE_H