00001 #pragma ident "$Id: ColorMap.hpp 1644 2009-01-27 19:26:14Z ckiesch $"
00002
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef VDRAW_COLORMAP_H
00028 #define VDRAW_COLORMAP_H
00029
00030 #include <algorithm>
00031
00032 #include "Color.hpp"
00033 #include "Palette.hpp"
00034
00035 #include "InterpolatedColorMap.hpp"
00036
00037 namespace vdraw
00038 {
00041
00045 class ColorMap
00046 {
00047 public:
00049 ColorMap()
00050 {
00051 cols=rows=0;
00052 c=0;
00053 }
00054
00056 ColorMap(const ColorMap &o);
00057
00059 ColorMap(const InterpolatedColorMap &o);
00060
00062
00063
00065 ColorMap(const Palette &p, double dir=90, int num=256)
00066 {
00067
00068
00069
00070 if(num<=0) num = 256;
00071
00072 init(1,num);
00073
00074 for(int row=0;row<rows;row++)
00075 for(int col=0;col<cols;col++)
00076 c[row][col] = p.getColor((1.0*row)/rows);
00077 }
00078
00085 ColorMap(int icols, int irows, const Color &base=Color::BLACK);
00086
00088 ~ColorMap() { reset(); }
00089
00106 ColorMap& operator=(ColorMap o);
00107
00109 inline void setColor(int row, int col, const Color& color) { c[row][col]=color; }
00110
00112 inline Color get(int row, int col) const { return c[row][col]; }
00113
00115 inline int getCols() const { return cols; }
00116
00118 inline int getRows() const { return rows; }
00119
00120 protected:
00122 void init(int icols, int irows);
00123
00125 void reset();
00126
00128 int cols;
00129
00131 int rows;
00132
00134 Color **c;
00135 };
00136
00138
00139 }
00140
00141 #endif // VDRAW_COLORMAP_H
00142