image.hpp
Go to the documentation of this file.
1 
20 #ifndef IMAGE_HPP
21 #define IMAGE_HPP
22 
23 #include <color.hpp>
24 
25 #include <vector>
26 
27 
28 namespace cpe
29 {
34 class image
35 {
36 public:
37 
38  // ********************************************* //
39  // ********************************************* //
40  // CONSTRUCTORS
41  // ********************************************* //
42  // ********************************************* //
43 
45  image();
47  image(unsigned int Nx,unsigned int Ny);
51  image(unsigned int Nx,unsigned int Ny,const std::vector<color> data);
52 
53  // ********************************************* //
54  // ********************************************* //
55  // Size of image
56  // ********************************************* //
57  // ********************************************* //
58 
60  void resize(unsigned int Nx,unsigned int Ny);
61 
63  unsigned int Nx() const;
65  unsigned int Ny() const;
66 
67 
68  // ********************************************* //
69  // ********************************************* //
70  // Color access in picture
71  // ********************************************* //
72  // ********************************************* //
73 
75  void fill(const color& c);
79  void fill_bloc(unsigned int kx,unsigned int ky,unsigned int size_bloc,const color& c);
80 
83  const color& get(const unsigned int kx,const unsigned ky) const;
84 
87  void set(const unsigned int kx,const unsigned ky,const color& c);
88 
89 
90 
93  const color& operator()(const unsigned int kx,const unsigned int ky) const;
96  color& operator()(const unsigned int kx,const unsigned int ky);
97 
98 
99  // ********************************************* //
100  // ********************************************* //
101  // Transfert of color from other image
102  // ********************************************* //
103  // ********************************************* //
104 
107  static void copy_bloc(unsigned int kx_source,unsigned int ky_source,const image& image_source,
108  unsigned int kx_destination,unsigned int ky_destination,image* image_destination,
109  unsigned int size_bloc);
110 
111 
112  // ********************************************* //
113  // ********************************************* //
114  // Raw access to the data
115  // ********************************************* //
116  // ********************************************* //
117 
121  void set_raw_data(const std::vector<octet>& raw_data);
123  std::vector<octet> to_raw_data_rgba() const;
125  std::vector<octet> to_raw_data_rgb() const;
126 
127 
128 
129 
130 private:
132  unsigned int size_Nx;
134  unsigned int size_Ny;
135 
139  std::vector<color> data;
140 };
141 }
142 
143 #endif