-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageBase.h
46 lines (43 loc) · 844 Bytes
/
ImageBase.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
43
44
45
46
#pragma once
namespace phoenix {
template<typename T>
class ImageBase {
protected:
T* data;
int width, height;
public:
int Width() const {
return width;
}
int Height() const {
return height;
}
void InitWidth(int width) {
this->width = width;
}
void InitHeight(int height) {
this->height = height;
}
void AllocData() {
data = (T*)malloc(width * height * sizeof(T));
}
void SetPixel(int x, int y, T& color) {
data[y * Width() + x] = color;
}
T GetPixel(int x, int y) const {
return data[y * Width() + x];
}
public:
ImageBase() {
throw;
}
ImageBase(int width, int height) {
InitWidth(width);
InitHeight(height);
AllocData();
}
~ImageBase() {
free(data);
}
};
}