This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
proceduralcity/include/ppm.h
2016-12-05 11:06:41 -06:00

37 lines
No EOL
973 B
C++

//Process a binary PPM file
#include <vector>
#include <string>
#ifndef PPM_H
#define PPM_H
class ppm {
void init();
//info about the PPM file (height and width)
unsigned int nr_lines;
unsigned int nr_columns;
public:
//arrays for storing the R,G,B values
std::vector<unsigned char> r;
std::vector<unsigned char> g;
std::vector<unsigned char> b;
//
unsigned int height;
unsigned int width;
unsigned int max_col_val;
//total number of elements (pixels)
unsigned int size;
ppm();
//create a PPM object and fill it with data stored in fname
ppm(const std::string &fname);
//create an "epmty" PPM image with a given width and height;the R,G,B arrays are filled with zeros
ppm(const unsigned int _width, const unsigned int _height);
//read the PPM image from fname
void read(const std::string &fname);
//write the PPM image in fname
void write(const std::string &fname);
};
#endif