Container for picture data. Data are stored as unsigned char [0,255]. More...
Collaboration diagram for cpe::image:Public Member Functions | |
| image () | |
| empty constructor More... | |
| image (int N) | |
| create square picture of size NxN More... | |
| image (int Nx, int Ny) | |
| create picture of size Nx x Ny More... | |
| image (const std::string &filename) | |
| import pre-existing picture from file filename More... | |
| int | Nx () const |
| get the picture width in pixel More... | |
| int | Ny () const |
| get the picture height in pixel More... | |
| void | reshape (int Nx2) |
| try to reshape the picture to a new size More... | |
| bool | check_position (const pos2 &u) const |
| check if a given pixel (kx,ky) is within the size of the picture More... | |
| const color & | operator() (const pos2 &index) const |
| Accessor on a pixel. More... | |
| color & | operator() (const pos2 &index) |
| Accessor on a pixel. More... | |
| void | fill (const color &c) |
| fill the entire picture with a given (r,g,b) color More... | |
| void | fill_rectangle (const pos2 &u1, const pos2 &u2, const color &c) |
| fill a rectangle ((x1,y1);(x2,y2)) with a given (r,g,b) color More... | |
| void | export_file (const std::string &filename) |
| write the picture into a file More... | |
Protected Member Functions | |
| void | assert_position (const pos2 &u) const |
| Ensure a position is within the size of the image, otherwise throw exception. More... | |
| int | coordinate_to_index (const pos2 &u) const |
| transform coordinate u=(kx,ky) to index in vector data More... | |
Private Attributes | |
| std::vector< color > | internal_data |
| internal data storage as std::vector of unsigned char More... | |
| int | internal_Nx |
| storage of picture width More... | |
| int | internal_Ny |
| storage of picture height More... | |
Container for picture data. Data are stored as unsigned char [0,255].
| cpe::image::image | ( | ) |
empty constructor
| cpe::image::image | ( | int | N | ) |
create square picture of size NxN
| unsigned | int N: size (width & height) of the picture |
References internal_data.
| cpe::image::image | ( | int | Nx, |
| int | Ny | ||
| ) |
create picture of size Nx x Ny
| unsigned | int Nx: picture width |
| unsigned | int Ny: picture height |
References internal_data.
| cpe::image::image | ( | const std::string & | filename | ) |
import pre-existing picture from file filename
| std::string | filename: path to the file to load |
References cpe::read_ppm().
Here is the call graph for this function:
|
protected |
Ensure a position is within the size of the image, otherwise throw exception.
References check_position(), MACRO_EXCEPTION_PARAMETER, Nx(), and Ny().
Referenced by operator()().
Here is the call graph for this function:| bool cpe::image::check_position | ( | const pos2 & | u | ) | const |
check if a given pixel (kx,ky) is within the size of the picture
| p2d | u: current (kx,ky)-coordinate |
References internal_Nx, internal_Ny, cpe::pos2::x(), and cpe::pos2::y().
Referenced by assert_position(), and fill_rectangle().
Here is the call graph for this function:
|
protected |
transform coordinate u=(kx,ky) to index in vector data
References internal_Nx, cpe::pos2::x(), and cpe::pos2::y().
Referenced by operator()().
Here is the call graph for this function:| void cpe::image::export_file | ( | const std::string & | filename | ) |
write the picture into a file
References cpe::export_ppm().
Referenced by main().
Here is the call graph for this function:| void cpe::image::fill | ( | const color & | c | ) |
fill the entire picture with a given (r,g,b) color
| color | c: (red,green,blue) value |
References internal_data.
fill a rectangle ((x1,y1);(x2,y2)) with a given (r,g,b) color
| p2d | u1: (x,y)-coordinate of starting point |
| p2d | u2: (x,y)-coordinate of ending point |
| color | c: (r,g,b) value |
References check_position(), internal_Nx, internal_Ny, MACRO_EXCEPTION_PARAMETER, cpe::pos2::x(), and cpe::pos2::y().
Here is the call graph for this function:| int cpe::image::Nx | ( | ) | const |
get the picture width in pixel
References internal_Nx.
Referenced by assert_position(), cpe::export_ppm(), and cpe::render().
| int cpe::image::Ny | ( | ) | const |
get the picture height in pixel
References internal_Ny.
Referenced by assert_position(), cpe::export_ppm(), and cpe::render().
Accessor on a pixel.
References assert_position(), coordinate_to_index(), and internal_data.
Here is the call graph for this function:Accessor on a pixel.
References assert_position(), coordinate_to_index(), and internal_data.
Here is the call graph for this function:| void cpe::image::reshape | ( | int | Nx2 | ) |
try to reshape the picture to a new size
| unsigned | int Nx: the new picture width |
References internal_Nx, internal_Ny, and MACRO_EXCEPTION_PARAMETER.
|
private |
internal data storage as std::vector of unsigned char
Picture is stored as (color_0 , color_1 , ...) vector size is therefore 3 Nx Ny
Referenced by fill(), image(), and operator()().
|
private |
storage of picture width
Referenced by check_position(), coordinate_to_index(), fill_rectangle(), Nx(), and reshape().
|
private |
storage of picture height
Referenced by check_position(), fill_rectangle(), Ny(), and reshape().