39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
//
|
|
// Created by sfd on 25-9-21.
|
|
//
|
|
|
|
#ifndef DXT_H
|
|
#define DXT_H
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
namespace PKG
|
|
{
|
|
enum class DXTFlags
|
|
{
|
|
DXT1 = 1,
|
|
DXT3 = 1 << 1,
|
|
DXT5 = 1 << 2,
|
|
};
|
|
|
|
|
|
class DXT
|
|
{
|
|
public:
|
|
// public static byte[] DecompressImage(int width, int height, byte[] data, DXTFlags flags)
|
|
|
|
static void DecompressImage(int width, int height, std::vector<uint8_t>& data, DXTFlags flags);
|
|
|
|
private:
|
|
static void Decompress(std::vector<uint8_t>& rgba, std::vector<uint8_t>& block, int blockIndex, DXTFlags flags);
|
|
|
|
static int UnPack565(std::vector<uint8_t>& block, int blockIndex, int packedOffset, std::vector<uint8_t>& color, int colorOffset);
|
|
static void DecompressColor(std::vector<uint8_t>& rgba, std::vector<uint8_t>& block, int blockIndex, bool isDxt1);
|
|
static void DecompressAlphaDxt3(std::vector<uint8_t>& rgba, std::vector<uint8_t>& block, int blockIndex);
|
|
static void DecompressAlphaDxt5(std::vector<uint8_t>& rgba, std::vector<uint8_t>& block, int blockIndex);
|
|
};
|
|
}
|
|
|
|
|
|
#endif //DXT_H
|