-
Notifications
You must be signed in to change notification settings - Fork 1
/
Image.h
42 lines (33 loc) · 1006 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
40
41
42
#ifndef MIRO_IMAGE_H_INCLUDED
#define MIRO_IMAGE_H_INCLUDED
#include "Vector3.h"
class Image
{
public:
struct Pixel
{
unsigned char r, g, b;
Pixel(unsigned char ir, unsigned char ig, unsigned char ib) {set(ir, ig, ib);}
Pixel() : r(0), g(0), b(0) {}
void set(unsigned char ir, unsigned char ig, unsigned char ib) {r = ir; g = ig; b = ib;}
};
Image();
~Image();
void resize(int width, int height);
void setPixel(int x, int y, const Vector3& p);
void setPixel(int x, int y, const Pixel& p);
void draw();
void drawScanline(int y);
void clear(const Vector3& c);
void writePPM(char* pcFile); // write data to a ppm image file
void writePPM(char *pcName, unsigned char *data, int width, int height);
unsigned char* getCharPixels() {return (unsigned char*)m_pixels;}
int width() const {return m_width;}
int height() const {return m_height;}
private:
Pixel* m_pixels;
int m_width;
int m_height;
};
extern Image* g_image;
#endif // MIRO_IMAGE_H_INCLUDED