Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ccc98bdf62 |
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,9 +1,8 @@
|
|||||||
# idea
|
# idea
|
||||||
.idea/
|
.idea/
|
||||||
cmake-build-*/
|
cmake-build-debug/
|
||||||
|
cmake-build-release/
|
||||||
# build
|
cmake-build-minsizerel/
|
||||||
build/
|
|
||||||
|
|
||||||
# vs
|
# vs
|
||||||
.vs/
|
.vs/
|
||||||
|
|||||||
@ -7,17 +7,11 @@ file(GLOB_RECURSE SRC_SOURCE src/**.cpp vendor/gif-h/gif.h)
|
|||||||
|
|
||||||
file(GLOB STB_SOURCE vendor/stb/*.cpp)
|
file(GLOB STB_SOURCE vendor/stb/*.cpp)
|
||||||
|
|
||||||
if(MSVC)
|
|
||||||
add_compile_options(/utf-8)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
# static
|
# static
|
||||||
add_library(expkg-static STATIC
|
add_library(expkg-static STATIC
|
||||||
${SRC_SOURCE}
|
${SRC_SOURCE}
|
||||||
${STB_SOURCE}
|
${STB_SOURCE}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(expkg-static PRIVATE lz4)
|
target_link_libraries(expkg-static PRIVATE lz4)
|
||||||
|
|
||||||
target_include_directories(expkg-static PRIVATE vendor/stb vendor/gif-h)
|
target_include_directories(expkg-static PRIVATE vendor/stb vendor/gif-h)
|
||||||
|
|||||||
@ -43,10 +43,10 @@ namespace PKG
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float BinaryReader::ReadSingle()
|
float_t BinaryReader::ReadSingle()
|
||||||
{
|
{
|
||||||
float result = 0;
|
float_t result = 0;
|
||||||
m_File.read(reinterpret_cast<char*>(&result), sizeof(float));
|
m_File.read(reinterpret_cast<char*>(&result), sizeof(float_t));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +54,7 @@ namespace PKG
|
|||||||
{
|
{
|
||||||
char result;
|
char result;
|
||||||
m_File.read(&result, sizeof(char));
|
m_File.read(&result, sizeof(char));
|
||||||
|
pos_type a = m_File.tellg();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,15 +79,6 @@ namespace PKG
|
|||||||
return std::filesystem::u8path(std::string(reinterpret_cast<const char*>(result.data()), length)).string();
|
return std::filesystem::u8path(std::string(reinterpret_cast<const char*>(result.data()), length)).string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string BinaryReader::ReadStringFileData(const uint32_t length)
|
|
||||||
{
|
|
||||||
std::vector<uint8_t> result;
|
|
||||||
result.resize(length);
|
|
||||||
|
|
||||||
m_File.read(reinterpret_cast<char*>(result.data()), length);
|
|
||||||
return std::string(reinterpret_cast<const char*>(result.data()), length);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string BinaryReader::ReadNString(const int32_t maxLength)
|
std::string BinaryReader::ReadNString(const int32_t maxLength)
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> result;
|
std::vector<uint8_t> result;
|
||||||
|
|||||||
@ -25,11 +25,10 @@ namespace PKG
|
|||||||
|
|
||||||
int32_t ReadInt32();
|
int32_t ReadInt32();
|
||||||
uint32_t ReadUInt32();
|
uint32_t ReadUInt32();
|
||||||
float ReadSingle();
|
float_t ReadSingle();
|
||||||
char ReadChar();
|
char ReadChar();
|
||||||
std::string ReadString(uint32_t length);
|
std::string ReadString(uint32_t length);
|
||||||
std::string ReadNString(int32_t maxLength = -1);
|
std::string ReadNString(int32_t maxLength = -1);
|
||||||
std::string ReadStringFileData(uint32_t length);
|
|
||||||
void ReadData(std::string& data, uint32_t length);
|
void ReadData(std::string& data, uint32_t length);
|
||||||
void ReadData(std::vector<uint8_t>& data, uint32_t length);
|
void ReadData(std::vector<uint8_t>& data, uint32_t length);
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ namespace PKG
|
|||||||
|
|
||||||
TexMipMap mipmap;
|
TexMipMap mipmap;
|
||||||
|
|
||||||
switch (container.imageContainerVersion)
|
switch (container.ImageContainerVersion)
|
||||||
{
|
{
|
||||||
case ImageContainerVersion::VERSION1:
|
case ImageContainerVersion::VERSION1:
|
||||||
mipmap = ReadMipMapV1(reader); break;
|
mipmap = ReadMipMapV1(reader); break;
|
||||||
@ -114,11 +114,11 @@ namespace PKG
|
|||||||
|
|
||||||
int version = std::stoi(container.Magic.substr(4, 4));
|
int version = std::stoi(container.Magic.substr(4, 4));
|
||||||
|
|
||||||
container.imageContainerVersion = (ImageContainerVersion)version;
|
container.ImageContainerVersion = (ImageContainerVersion)version;
|
||||||
|
|
||||||
if (container.imageContainerVersion == ImageContainerVersion::VERSION4 && container.ImageFormat != FreeImageFormat::FIF_MP4)
|
if (container.ImageContainerVersion == ImageContainerVersion::VERSION4 && container.ImageFormat != FreeImageFormat::FIF_MP4)
|
||||||
{
|
{
|
||||||
container.imageContainerVersion = ImageContainerVersion::VERSION3;
|
container.ImageContainerVersion = ImageContainerVersion::VERSION3;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < imageCount; i++)
|
for (int i = 0; i < imageCount; i++)
|
||||||
|
|||||||
@ -6,14 +6,10 @@
|
|||||||
#define CORE_H
|
#define CORE_H
|
||||||
|
|
||||||
#ifdef PKG_SHARED
|
#ifdef PKG_SHARED
|
||||||
#ifdef __WIN32__
|
#ifdef PKG_BUILD_DLL
|
||||||
#ifdef PKG_BUILD_DLL
|
#define PKG_API __declspec(dllexport)
|
||||||
#define PKG_API __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define PKG_API __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#define PKG_API
|
#define PKG_API __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define PKG_API
|
#define PKG_API
|
||||||
|
|||||||
@ -57,13 +57,11 @@ example:
|
|||||||
|
|
||||||
EXPKG::EXPKG(const std::string& filePath, const std::string& outDir)
|
EXPKG::EXPKG(const std::string& filePath, const std::string& outDir)
|
||||||
{
|
{
|
||||||
|
m_Reader = std::make_shared<BinaryReader>(filePath);
|
||||||
|
m_OutDir = outDir;
|
||||||
m_Reader = std::make_shared<BinaryReader>(std::filesystem::u8path(filePath));
|
|
||||||
m_OutDir = std::filesystem::u8path(outDir);
|
|
||||||
m_OutDir = m_OutDir.make_preferred();
|
m_OutDir = m_OutDir.make_preferred();
|
||||||
|
|
||||||
if (m_Reader)
|
if (!m_Reader)
|
||||||
Run();
|
Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,15 +146,15 @@ example:
|
|||||||
|
|
||||||
if (entry.Type == ".tex")
|
if (entry.Type == ".tex")
|
||||||
{
|
{
|
||||||
std::filesystem::path texPath = m_OutDir / entry.FullPath;
|
|
||||||
{
|
|
||||||
BinaryWriter writer(texPath, std::ios::binary);
|
|
||||||
|
|
||||||
std::string texdata;
|
std::filesystem::path texPath = m_OutDir / entry.FullPath;
|
||||||
m_Reader->ReadData(texdata, entry.Length);
|
BinaryWriter writer(texPath, std::ios::binary);
|
||||||
writer.WriteBytes(texdata.data(), texdata.size());
|
|
||||||
writer.close();
|
std::string texdata;
|
||||||
}
|
m_Reader->ReadData(texdata, entry.Length);
|
||||||
|
writer.WriteBytes(texdata.data(), texdata.size());
|
||||||
|
writer.close();
|
||||||
|
|
||||||
|
|
||||||
ExtractTex(texPath);
|
ExtractTex(texPath);
|
||||||
}
|
}
|
||||||
@ -176,7 +174,7 @@ example:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
BinaryWriter writer(m_OutDir / entry.FullPath);
|
BinaryWriter writer(m_OutDir / entry.FullPath);
|
||||||
writer.WriteString(m_Reader->ReadStringFileData(entry.Length));
|
writer.WriteString(m_Reader->ReadString(entry.Length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,6 +247,7 @@ example:
|
|||||||
mipmap.Format = MipmapFormat::RGBA8888; format = MipmapFormat::RGBA8888;
|
mipmap.Format = MipmapFormat::RGBA8888; format = MipmapFormat::RGBA8888;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
std::cerr << "raw mipmap meybe compressed" << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,8 +22,7 @@ namespace PKG
|
|||||||
public:
|
public:
|
||||||
std::string Magic;
|
std::string Magic;
|
||||||
FreeImageFormat ImageFormat{};
|
FreeImageFormat ImageFormat{};
|
||||||
// name conflict
|
ImageContainerVersion ImageContainerVersion;
|
||||||
ImageContainerVersion imageContainerVersion;
|
|
||||||
|
|
||||||
std::vector<TexImage> Images;
|
std::vector<TexImage> Images;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user