1 | |
2 | #pragma once |
3 | |
4 | #include "BitmapRef.hpp" |
5 | |
6 | namespace msdfgen { |
7 | |
8 | /// A 2D image bitmap with N channels of type T. Pixel memory is managed by the class. |
9 | template <typename T, int N = 1> |
10 | class Bitmap { |
11 | |
12 | public: |
13 | Bitmap(); |
14 | Bitmap(int width, int height); |
15 | Bitmap(const BitmapConstRef<T, N> &orig); |
16 | Bitmap(const Bitmap<T, N> &orig); |
17 | #ifdef MSDFGEN_USE_CPP11 |
18 | Bitmap(Bitmap<T, N> &&orig); |
19 | #endif |
20 | ~Bitmap(); |
21 | Bitmap<T, N> & operator=(const BitmapConstRef<T, N> &orig); |
22 | Bitmap<T, N> & operator=(const Bitmap<T, N> &orig); |
23 | #ifdef MSDFGEN_USE_CPP11 |
24 | Bitmap<T, N> & operator=(Bitmap<T, N> &&orig); |
25 | #endif |
26 | /// Bitmap width in pixels. |
27 | int width() const; |
28 | /// Bitmap height in pixels. |
29 | int height() const; |
30 | T * operator()(int x, int y); |
31 | const T * operator()(int x, int y) const; |
32 | #ifdef MSDFGEN_USE_CPP11 |
33 | explicit operator T *(); |
34 | explicit operator const T *() const; |
35 | #else |
36 | operator T *(); |
37 | operator const T *() const; |
38 | #endif |
39 | operator BitmapRef<T, N>(); |
40 | operator BitmapConstRef<T, N>() const; |
41 | |
42 | private: |
43 | T *pixels; |
44 | int w, h; |
45 | |
46 | }; |
47 | |
48 | } |
49 | |
50 | #include "Bitmap.hpp" |
51 | |