Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/msdfgen/core/BitmapRef.hpp
9903 views
1
2
#pragma once
3
4
#include "base.h"
5
6
namespace msdfgen {
7
8
/// Reference to a 2D image bitmap or a buffer acting as one. Pixel storage not owned or managed by the object.
9
template <typename T, int N = 1>
10
struct BitmapRef {
11
12
T *pixels;
13
int width, height;
14
15
inline BitmapRef() : pixels(NULL), width(0), height(0) { }
16
inline BitmapRef(T *pixels, int width, int height) : pixels(pixels), width(width), height(height) { }
17
18
inline T *operator()(int x, int y) const {
19
return pixels+N*(width*y+x);
20
}
21
22
};
23
24
/// Constant reference to a 2D image bitmap or a buffer acting as one. Pixel storage not owned or managed by the object.
25
template <typename T, int N = 1>
26
struct BitmapConstRef {
27
28
const T *pixels;
29
int width, height;
30
31
inline BitmapConstRef() : pixels(NULL), width(0), height(0) { }
32
inline BitmapConstRef(const T *pixels, int width, int height) : pixels(pixels), width(width), height(height) { }
33
inline BitmapConstRef(const BitmapRef<T, N> &orig) : pixels(orig.pixels), width(orig.width), height(orig.height) { }
34
35
inline const T *operator()(int x, int y) const {
36
return pixels+N*(width*y+x);
37
}
38
39
};
40
41
}
42
43