#include <PPMImage.h>
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) |
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/
PPMImage::PPMImage | ( | ) |
Constructs an empty ppm image.
PPMImage::PPMImage | ( | const char * | fileName | ) |
Constructs an image from the ppm image file in the given path.
fileName | the path to the ppm file to be loaded. |
PPMImage::PPMImage | ( | FILE * | file | ) |
Constructs an image from a file.
file | the file to load. |
PPMImage::PPMImage | ( | GLint | w, | |
GLint | h | |||
) |
Constructs an empty image with the given width and height.
w | the width of the image. | |
h | the height of the image. |
PPMImage::PPMImage | ( | const PPMImage * | image | ) |
PPMImage::~PPMImage | ( | ) |
Destructs this PPMImage object.
void PPMImage::load | ( | const char * | fileName | ) |
Loads a ppm file.
fileName | the path to the file to be loaded |
void PPMImage::load | ( | FILE * | file | ) |
Loads a ppm file.
file | the file to be loaded |
void PPMImage::reset | ( | GLint | w, | |
GLint | h | |||
) |
Resets the image byte array to the specified dimensions.
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.
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.
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.
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.
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.
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
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
x | the x-coordinate of the pixel | |
y | the y-coordinate of the pixel |
GLubyte PPMImage::getGreen | ( | GLint | x, | |
GLint | y | |||
) | const |
Returns the value of the green component of the given pixel
x | the x-coordinate of the pixel | |
y | the y-coordinate of the pixel |
GLubyte PPMImage::getBlue | ( | GLint | x, | |
GLint | y | |||
) | const |
Returns the value of the blue component of the given pixel
x | the x-coordinate of the pixel | |
y | the y-coordinate of the pixel |
GLubyte PPMImage::getComponent | ( | GLint | i, | |
GLint | x, | |||
GLint | y | |||
) | const |
Returns the value of the specified component of the given pixel
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 |
GLint PPMImage::getWidth | ( | ) | const [inline] |
Returns the image width.
GLint PPMImage::getHeight | ( | ) | const [inline] |
Returns the image height.
const GLubyte* PPMImage::getByteArray | ( | ) | const [inline] |
Returns a reference the image byte array.
void PPMImage::save | ( | const char * | fileName | ) |
Saves the contents of this image to the specified ppm file.
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.
ostream& operator<< | ( | ostream & | os, | |
const PPMImage & | image | |||
) | [friend] |
Outputs the image data to the associated output stream (usually a file in a ofstream).