00001 #pragma ident "$Id: ColorMap.cpp 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 #include "ColorMap.hpp"
00028
00029 namespace vdraw
00030 {
00031 ColorMap::ColorMap(const ColorMap &o)
00032 {
00033 init(o.getCols(),o.getRows());
00034
00035 for(int row=0;row<rows;row++)
00036 for(int col=0;col<cols;col++)
00037 c[row][col] = o.get(row,col);
00038 }
00039
00040 ColorMap::ColorMap(const InterpolatedColorMap &o)
00041 {
00042 init(o.getCols(),o.getRows());
00043
00044 for(int row=0;row<rows;row++)
00045 for(int col=0;col<cols;col++)
00046 c[row][col] = o.get(row,col);
00047 }
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 ColorMap::ColorMap(int icols, int irows, const Color &base)
00059 {
00060 init(icols,irows);
00061
00062 for(int row=0;row<rows;row++)
00063 for(int col=0;col<cols;col++)
00064 c[row][col] = base;
00065 }
00066
00067 ColorMap& ColorMap::operator=(ColorMap o)
00068 {
00069
00070 std::swap(rows,o.rows);
00071 std::swap(cols,o.cols);
00072 std::swap(c,o.c);
00073
00074 return *this;
00075 }
00076
00077 void ColorMap::init(int icols, int irows)
00078 {
00079 if(icols == 0 || irows == 0)
00080 {
00081 cols = rows = 0;
00082 c = 0;
00083 return;
00084 }
00085
00086 cols = icols;
00087 rows = irows;
00088
00089
00090 c = new Color*[rows];
00091
00092 for(int row=0;row<rows;row++)
00093 c[row] = new Color[cols];
00094 }
00095
00096 void ColorMap::reset()
00097 {
00098 if(c)
00099 {
00100 for(int row=0;row<rows;row++)
00101 delete[] c[row];
00102 delete[] c;
00103 }
00104
00105 cols=rows=0;
00106 c=0;
00107 }
00108
00109 }