00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "palette.h"
00021
00022 using namespace std;
00023
00024 palette::palette() throw(exception) : _colors(256) {
00025 }
00026
00027 palette::palette(unsigned char * ptr) throw(exception) : _colors(256) {
00028 for(int i = 0; i < 256; i++) {
00029 _colors[i] = color(ptr[3*i+0], ptr[3*i+1], ptr[3*i+2]);
00030 }
00031 }
00032
00033 palette::palette(const palette & p) throw(exception) : _colors(256) {
00034 _colors = p._colors;
00035 }
00036
00037 const color & palette::operator[](int a) const throw(exception) {
00038 return _colors.at(a);
00039 }
00040
00041 color & palette::operator[](int a) throw(exception) {
00042 return _colors.at(a);
00043 }
00044
00045 palette & palette::operator=(const palette & p) throw() {
00046 _colors = p._colors;
00047 return *this;
00048 }
00049
00050 ostream & operator <<(ostream & o, const palette & p) {
00051 o << "PALETTE[" << endl;
00052 for(int i = 0; i < 256; i++)
00053 {
00054 o << "\t" << i << " = " << p[i] << endl;
00055 }
00056 o << "]" << endl;
00057 return o;
00058 }