-
Notifications
You must be signed in to change notification settings - Fork 51
/
ppm.h
executable file
·38 lines (33 loc) · 1001 Bytes
/
ppm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//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;
std::vector<char> buff;
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