PPMImage Class Reference

#include <PPMImage.h>

List of all members.

Public Member Functions

 PPMImage ()
 PPMImage (const char *fileName)
 PPMImage (FILE *file)
 PPMImage (GLint w, GLint h)
 PPMImage (const PPMImage *image)
 ~PPMImage ()
void load (const char *fileName)
void load (FILE *file)
void reset (GLint w, GLint h)
void fill (GLubyte r, GLubyte g, GLubyte b)
void setPixel (GLint x, GLint y, GLubyte r, GLubyte g, GLubyte b)
void addToPixel (GLint x, GLint y, GLubyte r, GLubyte g, GLubyte b)
void addToPixel (GLint x, GLint y, int r, int g, int b)
void subFromPixel (GLint x, GLint y, int r, int g, int b)
void getPixel (GLint x, GLint y, GLubyte *value) const
GLubyte getRed (GLint x, GLint y) const
GLubyte getGreen (GLint x, GLint y) const
GLubyte getBlue (GLint x, GLint y) const
GLubyte getComponent (GLint i, GLint x, GLint y) const
GLint getWidth () const
GLint getHeight () const
const GLubyte * getByteArray () const
void save (const char *fileName)
void checkers (GLubyte cr=0, GLubyte cg=0, GLubyte cb=0)

Friends

ostream & operator<< (ostream &os, const PPMImage &image)


Detailed Description

This class loads and saves ppm image files.

It was adapted from the pixelmap class provided by Dr. Faramarz Samavati for the CPSC453 (Introduction to Computer Graphics) course assignement at the University of Calgary (Assignment 3, Winter 2007) and found at: http://pages.cpsc.ucalgary.ca/~samavati/cpsc453/documents/assign3/ppm/

Author:
Fabricio Anastacio - fabriciocfa@yahoo.com (adaptation)
Since:
June 19, 2007


Constructor & Destructor Documentation

PPMImage::PPMImage (  ) 

Constructs an empty ppm image.

PPMImage::PPMImage ( const char *  fileName  ) 

Constructs an image from the ppm image file in the given path.

Parameters:
fileName the path to the ppm file to be loaded.

PPMImage::PPMImage ( FILE *  file  ) 

Constructs an image from a file.

Parameters:
file the file to load.

PPMImage::PPMImage ( GLint  w,
GLint  h 
)

Constructs an empty image with the given width and height.

Parameters:
w the width of the image.
h the height of the image.

PPMImage::PPMImage ( const PPMImage image  ) 

Constructs an image from another PPMImage object.

Parameters:
image the PPMImage object to be copied.

PPMImage::~PPMImage (  ) 

Destructs this PPMImage object.


Member Function Documentation

void PPMImage::load ( const char *  fileName  ) 

Loads a ppm file.

Parameters:
fileName the path to the file to be loaded

void PPMImage::load ( FILE *  file  ) 

Loads a ppm file.

Parameters:
file the file to be loaded

void PPMImage::reset ( GLint  w,
GLint  h 
)

Resets the image byte array to the specified dimensions.

Parameters:
w the new image width
h the new image height

void PPMImage::fill ( GLubyte  r,
GLubyte  g,
GLubyte  b 
)

Fills the whole image with the given color.

Parameters:
r the red component of the filling color
g the green component of the filling color
b the blue component of the filling color

void PPMImage::setPixel ( GLint  x,
GLint  y,
GLubyte  r,
GLubyte  g,
GLubyte  b 
) [inline]

Sets the value of a given pixel in the image.

Parameters:
x the x-coordinate of the pixel
y the y-coordinate of the pixel
r the red value of the pixel
g the green value of the pixel
b the blue value of the pixel

void PPMImage::addToPixel ( GLint  x,
GLint  y,
GLubyte  r,
GLubyte  g,
GLubyte  b 
) [inline]

Adds the given values to the rgb channels of the given pixel.

Parameters:
x the x-coordinate of the pixel
y the y-coordinate of the pixel
r the red value to be added to the pixel
g the green value to be added to the pixel
b the blue value to be added to the pixel

void PPMImage::addToPixel ( GLint  x,
GLint  y,
int  r,
int  g,
int  b 
) [inline]

Adds the given values to the rgb channels of the given pixel.

Parameters:
x the x-coordinate of the pixel
y the y-coordinate of the pixel
r the red value to be added to the pixel
g the green value to be added to the pixel
b the blue value to be added to the pixel

void PPMImage::subFromPixel ( GLint  x,
GLint  y,
int  r,
int  g,
int  b 
) [inline]

Subtracts the given values from the rgb channels of the given pixel.

Parameters:
x the x-coordinate of the pixel
y the y-coordinate of the pixel
r the red value to be added to the pixel
g the green value to be added to the pixel
b the blue value to be added to the pixel

void PPMImage::getPixel ( GLint  x,
GLint  y,
GLubyte *  value 
) const

Returns the value of the given pixel

Parameters:
x the x-coordinate of the pixel
y the y-coordinate of the pixel
value the returned value for the given pixel

GLubyte PPMImage::getRed ( GLint  x,
GLint  y 
) const

Returns the value of the red component of the given pixel

Parameters:
x the x-coordinate of the pixel
y the y-coordinate of the pixel
Returns:
the value of the red component of the given pixel

GLubyte PPMImage::getGreen ( GLint  x,
GLint  y 
) const

Returns the value of the green component of the given pixel

Parameters:
x the x-coordinate of the pixel
y the y-coordinate of the pixel
Returns:
the value of the green component of the given pixel

GLubyte PPMImage::getBlue ( GLint  x,
GLint  y 
) const

Returns the value of the blue component of the given pixel

Parameters:
x the x-coordinate of the pixel
y the y-coordinate of the pixel
Returns:
the value of the blue component of the given pixel

GLubyte PPMImage::getComponent ( GLint  i,
GLint  x,
GLint  y 
) const

Returns the value of the specified component of the given pixel

Parameters:
i the index for the color component (0: red, 1: green, 2: blue)
x the x-coordinate of the pixel
y the y-coordinate of the pixel
Returns:
the value of the specified component of the given pixel

GLint PPMImage::getWidth (  )  const [inline]

Returns the image width.

Returns:
the image width

GLint PPMImage::getHeight (  )  const [inline]

Returns the image height.

Returns:
the image height

const GLubyte* PPMImage::getByteArray (  )  const [inline]

Returns a reference the image byte array.

Returns:
the reference to the image byte array

void PPMImage::save ( const char *  fileName  ) 

Saves the contents of this image to the specified ppm file.

Parameters:
fileName the path and name of the ppm file to be created with the current data

void PPMImage::checkers ( GLubyte  cr = 0,
GLubyte  cg = 0,
GLubyte  cb = 0 
)

Define a checkers patter. It is only for testing.


Friends And Related Function Documentation

ostream& operator<< ( ostream &  os,
const PPMImage image 
) [friend]

Outputs the image data to the associated output stream (usually a file in a ofstream).


The documentation for this class was generated from the following files:
Generated on Fri Dec 21 17:42:28 2007 for IBuffer by  doxygen 1.5.2