cpe::image Class Reference

Container for picture data. Data are stored as unsigned char [0,255]. More...

Inheritance diagram for cpe::image:
Inheritance graph
[legend]
Collaboration diagram for cpe::image:
Collaboration graph
[legend]

List of all members.

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
void set_pixel (const p2d &u, const color &c)
 set a given pixel with (r,g,b) color
void get_pixel (const p2d &u, color *c) const
 get the current color from a given pixel
const unsigned char & get_r (const p2d &u) const
 get the current red color for pixel (kx,ky)
const unsigned char & get_g (const p2d &u) const
 get the current green color for pixel (kx,ky)
const unsigned char & get_b (const p2d &u) const
 get the current blue color for pixel (kx,ky)
const std::vector< unsigned
char > & 
get_data () const
 get internal data format
std::vector< unsigned char > & get_data ()
 get internal data format
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_ppm (const std::string &filename)
 Export the picture into ppm format (ascii).

Protected Member Functions

int coordinate_to_index (const p2d &u) const
 transform coordinate u=(kx,ky) to index in vector data

Static Private Member Functions

static image read_ppm (const std::string &filename)
 read a ppm picture format

Private Attributes

std::vector< unsigned char > 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

Detailed Description

Container for picture data. Data are stored as unsigned char [0,255].


Constructor & Destructor Documentation

cpe::image::image (  ) 

empty constructor

Referenced by resize().

cpe::image::image ( const unsigned int &  N  ) 

create square picture of size NxN

Parameters:
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

Parameters:
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

Parameters:
std::string filename: path to the file to load

References read_ppm().

Here is the call graph for this function:


Member Function Documentation

bool cpe::image::check_position ( const p2d u  )  const [inline]

check if a given pixel (kx,ky) is within the size of the picture

Parameters:
p2d u: current (kx,ky)-coordinate
Returns:
true if (kx,ky) is within the picture, false otherwise

References internal_Nx, internal_Ny, cpe::p2d::x(), and cpe::p2d::y().

Referenced by fill_rectangle(), get_b(), get_g(), get_pixel(), get_r(), cpe::image_drawable_zbuffer::line(), cpe::image_drawable::line(), and set_pixel().

Here is the call graph for this function:

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().

Here is the call graph for this function:

void cpe::image::export_ppm ( const std::string &  filename  ) 

Export the picture into ppm format (ascii).

Parameters:
std::string filename: file to store the picture

References internal_data, internal_Nx, and internal_Ny.

Referenced by main().

void cpe::image::fill ( const color c  ) 

fill the entire picture with a given (r,g,b) color

Parameters:
color c: (red,green,blue) value

References cpe::color::b(), cpe::color::g(), internal_data, internal_Nx, internal_Ny, and cpe::color::r().

Referenced by main().

Here is the call graph for this function:

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

Parameters:
p2d u1: (x,y)-coordinate of starting point
p2d u2: (x,y)-coordinate of ending point
color c: (r,g,b) value

References cpe::color::b(), check_position(), cpe::color::g(), internal_data, internal_Nx, internal_Ny, cpe::color::r(), cpe::p2d::x(), and cpe::p2d::y().

Here is the call graph for this function:

const unsigned char & cpe::image::get_b ( const p2d u  )  const

get the current blue color for pixel (kx,ky)

Parameters:
p2d u: current (x,y)-coordinate

References check_position(), internal_data, internal_Nx, internal_Ny, cpe::p2d::x(), and cpe::p2d::y().

Here is the call graph for this function:

std::vector< unsigned char > & cpe::image::get_data (  ) 

get internal data format

References internal_data.

const std::vector< unsigned char > & cpe::image::get_data (  )  const

get internal data format

References internal_data.

Referenced by read_ppm().

const unsigned char & cpe::image::get_g ( const p2d u  )  const

get the current green color for pixel (kx,ky)

Parameters:
p2d u: current (x,y)-coordinate

References check_position(), internal_data, internal_Nx, internal_Ny, cpe::p2d::x(), and cpe::p2d::y().

Here is the call graph for this function:

const unsigned int & cpe::image::get_Nx (  )  const
const unsigned int & cpe::image::get_Ny (  )  const

get the picture height in pixel

References internal_Ny.

Referenced by cpe::image_drawable_zbuffer::image_drawable_zbuffer().

void cpe::image::get_pixel ( const p2d u,
color c 
) const

get the current color from a given pixel

Parameters:
p2d u: current (x,y)-coordinate
color* c: (r,g,b) color value (pointer)

References cpe::color::b(), check_position(), cpe::color::g(), internal_data, internal_Nx, internal_Ny, cpe::color::r(), cpe::p2d::x(), and cpe::p2d::y().

Here is the call graph for this function:

const unsigned char & cpe::image::get_r ( const p2d u  )  const

get the current red color for pixel (kx,ky)

Parameters:
p2d u: current (x,y)-coordinate

References check_position(), internal_data, internal_Nx, internal_Ny, cpe::p2d::x(), and cpe::p2d::y().

Here is the call graph for this function:

image cpe::image::read_ppm ( const std::string &  filename  )  [static, private]

read a ppm picture format

Parameters:
std::string filename: path of the file to read

References get_data().

Referenced by image().

Here is the call graph for this function:

void cpe::image::reshape ( const unsigned int &  Nx2  ) 

try to reshape the picture to a new size

Parameters:
unsigned int Nx: the new picture width
Note:
Nx x Ny / Nx2 must be integer

References internal_Nx, and internal_Ny.

void cpe::image::resize ( const unsigned int &  Nx,
const unsigned int &  Ny 
)

resize the picture to a square of size Nx x Ny

Parameters:
unsigned int Nx: new picture width
unsigned Ny: new picture height

References image().

Here is the call graph for this function:

void cpe::image::resize ( const unsigned int &  N  ) 

resize the picture to a square of size NxN

Parameters:
unsigned int N: new picture width and height

References image().

Here is the call graph for this function:

void cpe::image::set_pixel ( const p2d u,
const color c 
)

set a given pixel with (r,g,b) color

Parameters:
p2d u: current (x,y)-coordinate
color c: (r,g,b) color value

References cpe::color::b(), check_position(), cpe::color::g(), internal_data, internal_Nx, internal_Ny, cpe::color::r(), cpe::p2d::x(), and cpe::p2d::y().

Referenced by cpe::image_drawable_zbuffer::line(), and cpe::image_drawable::line().

Here is the call graph for this function:


Member Data Documentation

std::vector<unsigned char> cpe::image::internal_data [private]

internal data storage as std::vector of unsigned char

Picture is stored as (r0,b0,g0,a0 , r1,b1,g1,a1 , ...) vector size is therefore 4 Nx Ny

Referenced by export_ppm(), fill(), fill_rectangle(), get_b(), get_data(), get_g(), get_pixel(), get_r(), image(), and set_pixel().

unsigned int cpe::image::internal_Nx [private]
unsigned int cpe::image::internal_Ny [private]

The documentation for this class was generated from the following files:
Generated on Mon Apr 18 20:43:34 2011 by  doxygen 1.6.3