-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage.hpp
More file actions
56 lines (46 loc) · 1.7 KB
/
image.hpp
File metadata and controls
56 lines (46 loc) · 1.7 KB
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
#ifndef IMAGE_H
#define IMAGE_H
#include <Nostalgia/things/resources/resource.hpp>
#include <Nostalgia/rendering/common.hpp>
class Image : public Resource
{
public:
static Shared<Image> CreateEmpty(int inWidth, int inHeight, DataFormat inFormat = DATA_FORMAT_SRGB_ALPHA);
static Shared<Image> CreateFromData(const uchar* inImageData, int inImageDataSize, DataFormat inFormat = DATA_FORMAT_SRGB_ALPHA);
static void GetInfo(Farg<Shared<FileData>> inFile, int* outWidth, int* outHeight, int* outChannels);
SET_SUPER(Resource)
SET_TYPEID(ThingType::Image)
SET_VARIABLES_OVERRIDE
GET_VARIABLES_OVERRIDE
SHUTDOWN_OVERRIDE
virtual ~Image() noexcept;
Error Import();
Error LoadFile(Sarg inFilePath);
void SetData(const uchar* inData, int inSize, DataFormat inFormat = DATA_FORMAT_SRGB_ALPHA);
const uchar* raw_data() const;
uchar* raw_data();
int size() const;
bool UseMipmaps() const;
void SetUseMipmaps(bool inUseMipmaps);
DataFormat Format() const;
void SetFormat(DataFormat inFormat);
int Width() const;
int Height() const;
int Channels() const;
protected:
Shared<FileData> m_pFileData{MakeShared<FileData>()};
uchar* m_pImage{nullptr};
int mSize{0};
DataFormat mFormat{DATA_FORMAT_SRGB_ALPHA};
bool mUseMipmaps{true};
int mWidth{1},
mHeight{1},
/*
* Channels is the number of 8-bit components per pixel and is directly related to the format.
* As an example, if `mChannels` is 4, that would require `mFormat` to be one of the formats where the components are
* floating-point numbers, which are 32 bits (32 / 4 == 8).
*/
mChannels{1};
void free();
};
#endif // IMAGE_H