forked from freme/raybeam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.h
40 lines (32 loc) · 910 Bytes
/
image.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
39
// image.h
#ifndef _IMAGE_H_
#define _IMAGE_H_ 1
#include <cmath>
#include <string>
#include <fstream>
#include "rgb.h"
// bad idea to use namespace in .h
// using namespace std;
class Image
{
public:
Image();
// init raster to default rgb color
Image(int width, int height);
// init raster to background color
Image(int width, int height, rgb background);
// return false if x or y are out of bounds, else true
bool set(int x, int y, const rgb & color);
void gammaCorrect(float gamma);
// output PPM
void writePPM(std::ostream& out);
void readPPM(std::string file_name);
int width() { return nx; }
int height() { return ny; }
rgb getPixel(int x, int y) {return raster[x][y];}
private:
rgb** raster;
int nx; // width
int ny; // height
};
#endif // _IMAGE_H_