-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage.h
More file actions
51 lines (36 loc) · 896 Bytes
/
image.h
File metadata and controls
51 lines (36 loc) · 896 Bytes
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
43
44
45
46
47
48
49
50
51
#ifndef IMAGE_H
#define IMAGE_H
class image {
public:
image(int w, int h);
~image();
uint32_t& operator [] (int index);
uint32_t operator [] (int index) const;
uint32_t& operator () (int x, int y);
uint32_t operator () (int x, int y) const;
public:
uint32_t* pixels;
int width;
int height;
};
inline image::image(int w, int h): width(w), height(h) {
pixels = new uint32_t[w*h];
for (int i = 0; i < w*h; ++i)
pixels[i] = 0x00000000;
}
inline image::~image() {
delete[] pixels;
}
inline uint32_t& image::operator [] (int index) {
return pixels[index];
}
inline uint32_t image::operator [] (int index) const {
return pixels[index];
}
inline uint32_t& image::operator () (int x, int y) {
return pixels[y*width + x];
}
inline uint32_t image::operator () (int x, int y) const {
return pixels[y*width + x];
}
#endif