forked from Chlumsky/msdfgen
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBitmap.cpp
77 lines (61 loc) · 1.49 KB
/
Bitmap.cpp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "Bitmap.h"
#include <cstring>
namespace msdfgen {
template <typename T>
Bitmap<T>::Bitmap() : content(NULL), w(0), h(0) { }
template <typename T>
Bitmap<T>::Bitmap(int width, int height) : w(width), h(height) {
content = new T[w*h];
}
template <typename T>
Bitmap<T>::Bitmap(const Bitmap<T> &orig) : w(orig.w), h(orig.h) {
content = new T[w*h];
memcpy(content, orig.content, w*h*sizeof(T));
}
#ifdef MSDFGEN_USE_CPP11
template <typename T>
Bitmap<T>::Bitmap(Bitmap<T> &&orig) : content(orig.content), w(orig.w), h(orig.h) {
orig.content = NULL;
}
#endif
template <typename T>
Bitmap<T>::~Bitmap() {
delete [] content;
}
template <typename T>
Bitmap<T> & Bitmap<T>::operator=(const Bitmap<T> &orig) {
delete [] content;
w = orig.w, h = orig.h;
content = new T[w*h];
memcpy(content, orig.content, w*h*sizeof(T));
return *this;
}
#ifdef MSDFGEN_USE_CPP11
template <typename T>
Bitmap<T> & Bitmap<T>::operator=(Bitmap<T> &&orig) {
delete [] content;
content = orig.content;
w = orig.w, h = orig.h;
orig.content = NULL;
return *this;
}
#endif
template <typename T>
int Bitmap<T>::width() const {
return w;
}
template <typename T>
int Bitmap<T>::height() const {
return h;
}
template <typename T>
T & Bitmap<T>::operator()(int x, int y) {
return content[y*w+x];
}
template <typename T>
const T & Bitmap<T>::operator()(int x, int y) const {
return content[y*w+x];
}
template class Bitmap<float>;
template class Bitmap<FloatRGB>;
}