-
Notifications
You must be signed in to change notification settings - Fork 0
/
gd.hpp
56 lines (38 loc) · 1.04 KB
/
gd.hpp
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
#if !defined(GD_HPP_INCLUDED)
#define GD_HPP_INCLUDED
#include <string>
#include <gd.h>
// Minimal C++ wrapper for libgd images with just the functionality we use
namespace gd {
class image {
gdImage *handle;
public:
image(int sx, int sy);
~image();
// Don't allow copy
image(const image&) = delete;
image& operator=(const image&) = delete;
// Allow move
image(image &&) = default;
image& operator=(image&&) = default;
void setPixel(int x, int y, int color);
void writePng(const char *filename, int level=-1);
void writePng(const std::string &filename, int level=-1);
int sx() const;
int sy() const;
};
/* Some function definitions that might be inlined/... */
inline void image::writePng(const std::string &filename, int level) {
writePng(filename.c_str(), level);
}
inline int image::sx() const {
return gdImageSX(handle);
}
inline int image::sy() const {
return gdImageSY(handle);
}
static inline int trueColor(int red, int green, int blue) {
return gdTrueColor(red, green, blue);
}
} // namespace gd
#endif // GD_HPP_INCLUDED