Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef IMAGE_HPP
00023 #define IMAGE_HPP
00024
00025 #include <iostream>
00026 #include <vector>
00027 #include <exception_cpe.hpp>
00028 #include <color.hpp>
00029
00030
00031
00032 namespace cpe
00033 {
00034
00035 class p2d;
00036
00038 class image
00039 {
00040 public:
00041
00042
00043
00044
00045
00046
00047
00049 image();
00053 image(const unsigned int& N);
00058 image(const unsigned int& Nx,const unsigned int& Ny);
00062 image(const std::string& filename);
00063
00064
00065
00066
00067
00068
00069
00070
00072 const unsigned int& get_Nx() const;
00074 const unsigned int& get_Ny() const;
00075
00079 void resize(const unsigned int& N);
00084 void resize(const unsigned int& Nx,const unsigned int& Ny);
00085
00090 void reshape(const unsigned int& Nx2);
00091
00096 bool check_position(const p2d& u) const;
00097
00098
00099
00100
00101
00102
00103
00104
00106 const color& operator()(const p2d& index) const;
00108 color& operator()(const p2d& index);
00109
00111 void set(const p2d& index,const color& c);
00112
00113
00114
00115
00116
00117
00118
00119
00123 void fill(const color& c);
00129 void fill_rectangle(const p2d& u1,const p2d& u2,const color& c);
00130
00131
00132
00133
00134
00135
00136
00137
00139 void export_file(const std::string& filename);
00140
00141
00142
00143 protected:
00144
00146 int coordinate_to_index(const p2d& u) const;
00147
00148 private:
00149
00150
00151
00152
00153
00154
00155
00156
00161 std::vector<color> internal_data;
00163 unsigned int internal_Nx;
00165 unsigned int internal_Ny;
00166
00167
00168 };
00169
00170
00172 class exception_image : public exception_cpe
00173 {
00174 public:
00175
00177 exception_image():exception_cpe(){}
00179 exception_image(const std::string& msg,const std::string& file,const std::string& caller,const int& line):exception_cpe(msg,file,caller,line){}
00180 };
00181 }
00182
00183 #endif