-
Notifications
You must be signed in to change notification settings - Fork 41
/
blp.h
96 lines (72 loc) · 2.44 KB
/
blp.h
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef _BLP_H_
#define _BLP_H_
#include <stdint.h>
#include <stdio.h>
#include <string>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
# ifdef blp_EXPORTS
# define MODULE_API __declspec(dllexport)
# else
# define MODULE_API
# endif
#else
# define MODULE_API
#endif
struct tBGRAPixel
{
uint8_t b;
uint8_t g;
uint8_t r;
uint8_t a;
};
// Opaque type representing a BLP file
typedef void* tBLPInfos;
enum tBLPEncoding
{
BLP_ENCODING_UNCOMPRESSED = 1,
BLP_ENCODING_DXT = 2,
BLP_ENCODING_UNCOMPRESSED_RAW_BGRA = 3
};
enum tBLPAlphaDepth
{
BLP_ALPHA_DEPTH_0 = 0,
BLP_ALPHA_DEPTH_1 = 1,
BLP_ALPHA_DEPTH_4 = 4,
BLP_ALPHA_DEPTH_8 = 8,
};
enum tBLPAlphaEncoding
{
BLP_ALPHA_ENCODING_DXT1 = 0,
BLP_ALPHA_ENCODING_DXT3 = 1,
BLP_ALPHA_ENCODING_DXT5 = 7,
};
enum tBLPFormat
{
BLP_FORMAT_JPEG = 0,
BLP_FORMAT_PALETTED_NO_ALPHA = (BLP_ENCODING_UNCOMPRESSED << 16) | (BLP_ALPHA_DEPTH_0 << 8),
BLP_FORMAT_PALETTED_ALPHA_1 = (BLP_ENCODING_UNCOMPRESSED << 16) | (BLP_ALPHA_DEPTH_1 << 8),
BLP_FORMAT_PALETTED_ALPHA_4 = (BLP_ENCODING_UNCOMPRESSED << 16) | (BLP_ALPHA_DEPTH_4 << 8),
BLP_FORMAT_PALETTED_ALPHA_8 = (BLP_ENCODING_UNCOMPRESSED << 16) | (BLP_ALPHA_DEPTH_8 << 8),
BLP_FORMAT_RAW_BGRA = (BLP_ENCODING_UNCOMPRESSED_RAW_BGRA << 16),
BLP_FORMAT_DXT1_NO_ALPHA = (BLP_ENCODING_DXT << 16) | (BLP_ALPHA_DEPTH_0 << 8) | BLP_ALPHA_ENCODING_DXT1,
BLP_FORMAT_DXT1_ALPHA_1 = (BLP_ENCODING_DXT << 16) | (BLP_ALPHA_DEPTH_1 << 8) | BLP_ALPHA_ENCODING_DXT1,
BLP_FORMAT_DXT3_ALPHA_4 = (BLP_ENCODING_DXT << 16) | (BLP_ALPHA_DEPTH_4 << 8) | BLP_ALPHA_ENCODING_DXT3,
BLP_FORMAT_DXT3_ALPHA_8 = (BLP_ENCODING_DXT << 16) | (BLP_ALPHA_DEPTH_8 << 8) | BLP_ALPHA_ENCODING_DXT3,
BLP_FORMAT_DXT5_ALPHA_8 = (BLP_ENCODING_DXT << 16) | (BLP_ALPHA_DEPTH_8 << 8) | BLP_ALPHA_ENCODING_DXT5,
};
MODULE_API tBLPInfos blp_processFile(FILE* pFile);
MODULE_API void blp_release(tBLPInfos blpInfos);
MODULE_API uint8_t blp_version(tBLPInfos blpInfos);
MODULE_API tBLPFormat blp_format(tBLPInfos blpInfos);
MODULE_API unsigned int blp_width(tBLPInfos blpInfos, unsigned int mipLevel = 0);
MODULE_API unsigned int blp_height(tBLPInfos blpInfos, unsigned int mipLevel = 0);
MODULE_API unsigned int blp_nbMipLevels(tBLPInfos blpInfos);
MODULE_API tBGRAPixel* blp_convert(FILE* pFile, tBLPInfos blpInfos, unsigned int mipLevel = 0);
#ifdef __cplusplus
}
#endif
std::string blp_asString(tBLPFormat format);
#endif