-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextureFile.hpp
76 lines (62 loc) · 1.71 KB
/
TextureFile.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once
#include <iostream>
#include <vector>
#include <filesystem>
#include <map>
class MipMap {
public:
std::filesystem::path inputPath;
uint16_t width{ 0 };
uint16_t height{ 0 };
std::vector<char> data;
bool verboseLog = false;
uint16_t getRealSize() const {
return width & 0x7fff;
}
bool isCompressed() const {
return width & 0x8000;
}
bool readMipmap(std::istream& input, uint32_t expectedDataSize = 0);
void writeMipmap(std::ostream& output);
};
enum class PAAType : uint16_t {
def,
DXT1 = 0xFF01,
DXT3 = 0xFF03,
DXT5 = 0xFF05,
ARGB4444 = 0x4444,
ARGB1555 = 0x1555,
AI88 = 0x8080,
invalid
};
inline std::string_view TypeToString(PAAType t) {
switch (t) {
case PAAType::def: return "default";
case PAAType::DXT1: return "DXT1";
case PAAType::DXT3: return "DXT3";
case PAAType::DXT5: return "DXT5";
case PAAType::ARGB4444: return "ARGB4444";
case PAAType::ARGB1555: return "ARGB1555";
case PAAType::AI88: return "AI88";
case PAAType::invalid: return "invalid";
default: return "default";
}
}
class TextureFile {
public:
void readFromStream(std::istream& input);
void readFromFile(std::filesystem::path path);
void writeToFile(std::filesystem::path path);
std::shared_ptr<TextureFile> copyNoMipmap();
std::filesystem::path inputPath;
bool isAlpha = false;
bool isTransparent = false;
PAAType type;
uint32_t avgColor{ 0xff802020 };
uint32_t maxColor{ 0xffffffff };
std::map<std::string, std::string> tags;
std::vector<char> paletteData;
std::vector<std::shared_ptr<MipMap>> mipmaps;
bool verboseLog = false;
bool doLogging = true;
};