Class PPM

Nested Relationships

Nested Types

Class Documentation

class PPM

Load and save .ppm files - “portable pixmap format” an image file formats designed to be easily exchanged between platforms.

Public Functions

PPM() = default
inline PPM(const char *filename)
void loadFile(const char *filename)

Load a .ppm file. Throw an exception in case of an error.

void saveFile(const char *filename)

Save image data to a .ppm file. Throw an exception in case of an error.

inline unsigned int getWidth() const

Get the width of the loaded image.

inline unsigned int getHeight() const

Get the height of the loaded image.

inline void setWidth(unsigned int width)

Set the width for the loaded image. This must eventually match the number of pixels, if saveFile() gets called.

inline void setHeight(unsigned int height)

Set the height for the loaded image. This must eventually match the number of pixels, if saveFile() gets called.

inline const std::vector<Color> &getPixels() const

Get read-only access to the pixels in the image. To access a pixel at coordinate (row,col), use getPixels()[row * getWidth() + col].

inline std::vector<Color> &getPixels()

Get write access to the pixels in the image. To access a pixel at coordinate (row,col), use getPixels()[row * getWidth() + col]. This must eventually match the width & height set by setWidth() and setHeight().

inline const Color &getPixel(const int row, const int col) const

Directly access a pixel in the image.

inline Color &getPixel(const int row, const int col)

Directly access a pixel in the image.

struct Color

Public Functions

inline bool operator==(const Color c)

Public Members

unsigned char red
unsigned char green
unsigned char blue