Container for picture data. Data are stored as unsigned char [0,255]. More...
Public Member Functions | |
image () | |
empty constructor | |
image (const unsigned int &N) | |
create square picture of size NxN | |
image (const unsigned int &Nx, const unsigned int &Ny) | |
create picture of size Nx x Ny | |
image (const std::string &filename) | |
import pre-existing picture from file filename | |
const unsigned int & | get_Nx () const |
get the picture width in pixel | |
const unsigned int & | get_Ny () const |
get the picture height in pixel | |
void | resize (const unsigned int &N) |
resize the picture to a square of size NxN | |
void | resize (const unsigned int &Nx, const unsigned int &Ny) |
resize the picture to a square of size Nx x Ny | |
void | reshape (const unsigned int &Nx2) |
try to reshape the picture to a new size | |
bool | check_position (const p2d &u) const |
check if a given pixel (kx,ky) is within the size of the picture | |
const color & | operator() (const p2d &index) const |
Accessor on a pixel. | |
color & | operator() (const p2d &index) |
Accessor on a pixel. | |
void | set (const p2d &index, const color &c) |
Method to set a pixel. | |
void | fill (const color &c) |
fill the entire picture with a given (r,g,b) color | |
void | fill_rectangle (const p2d &u1, const p2d &u2, const color &c) |
fill a rectangle ((x1,y1);(x2,y2)) with a given (r,g,b) color | |
void | export_file (const std::string &filename) |
write the picture into a file | |
Protected Member Functions | |
int | coordinate_to_index (const p2d &u) const |
transform coordinate u=(kx,ky) to index in vector data | |
Private Attributes | |
std::vector< color > | internal_data |
internal data storage as std::vector of unsigned char | |
unsigned int | internal_Nx |
storage of picture width | |
unsigned int | internal_Ny |
storage of picture height |
Container for picture data. Data are stored as unsigned char [0,255].
empty constructor
Referenced by resize().
cpe::image::image | ( | const unsigned int & | N | ) |
create square picture of size NxN
unsigned | int N: size (width & height) of the picture |
References internal_data.
cpe::image::image | ( | const unsigned int & | Nx, |
const unsigned 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::image_io::read_ppm().
bool cpe::image::check_position | ( | const p2d & | 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::p2d::x(), and cpe::p2d::y().
Referenced by fill_rectangle(), operator()(), and set().
int cpe::image::coordinate_to_index | ( | const p2d & | u | ) | const [protected] |
transform coordinate u=(kx,ky) to index in vector data
References internal_Nx, cpe::p2d::x(), and cpe::p2d::y().
Referenced by operator()(), and set().
void cpe::image::export_file | ( | const std::string & | filename | ) |
write the picture into a file
References cpe::image_io::export_ppm().
Referenced by main().
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.
void cpe::image::fill_rectangle | ( | const p2d & | u1, |
const p2d & | u2, | ||
const color & | c | ||
) |
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, cpe::p2d::x(), and cpe::p2d::y().
const unsigned int & cpe::image::get_Nx | ( | ) | const |
get the picture width in pixel
References internal_Nx.
Referenced by cpe::image_io::export_ppm(), and cpe::ray_tracer::trace().
const unsigned int & cpe::image::get_Ny | ( | ) | const |
get the picture height in pixel
References internal_Ny.
Referenced by cpe::image_io::export_ppm(), and cpe::ray_tracer::trace().
Accessor on a pixel.
References check_position(), coordinate_to_index(), and internal_data.
Accessor on a pixel.
References check_position(), coordinate_to_index(), and internal_data.
void cpe::image::reshape | ( | const unsigned int & | Nx2 | ) |
try to reshape the picture to a new size
unsigned | int Nx: the new picture width |
References internal_Nx, and internal_Ny.
void cpe::image::resize | ( | const unsigned int & | N | ) |
resize the picture to a square of size NxN
unsigned | int N: new picture width and height |
References image().
void cpe::image::resize | ( | const unsigned int & | Nx, |
const unsigned int & | Ny | ||
) |
resize the picture to a square of size Nx x Ny
unsigned | int Nx: new picture width |
unsigned | Ny: new picture height |
References image().
void cpe::image::set | ( | const p2d & | index, |
const color & | c | ||
) |
Method to set a pixel.
References check_position(), coordinate_to_index(), and internal_data.
Referenced by cpe::ray_tracer::trace().
std::vector<color> cpe::image::internal_data [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(), operator()(), and set().
unsigned int cpe::image::internal_Nx [private] |
storage of picture width
Referenced by check_position(), coordinate_to_index(), fill_rectangle(), get_Nx(), and reshape().
unsigned int cpe::image::internal_Ny [private] |
storage of picture height
Referenced by check_position(), fill_rectangle(), get_Ny(), and reshape().