1 Commits
main ... 0.1.2

Author SHA1 Message Date
ccc98bdf62 Implement GIF conversion 2025-09-27 14:06:57 +08:00
8 changed files with 29 additions and 51 deletions

7
.gitignore vendored
View File

@ -1,9 +1,8 @@
# idea
.idea/
cmake-build-*/
# build
build/
cmake-build-debug/
cmake-build-release/
cmake-build-minsizerel/
# vs
.vs/

View File

@ -7,17 +7,11 @@ file(GLOB_RECURSE SRC_SOURCE src/**.cpp vendor/gif-h/gif.h)
file(GLOB STB_SOURCE vendor/stb/*.cpp)
if(MSVC)
add_compile_options(/utf-8)
endif()
# static
add_library(expkg-static STATIC
${SRC_SOURCE}
${STB_SOURCE}
)
target_link_libraries(expkg-static PRIVATE lz4)
target_include_directories(expkg-static PRIVATE vendor/stb vendor/gif-h)

View File

@ -43,10 +43,10 @@ namespace PKG
return result;
}
float BinaryReader::ReadSingle()
float_t BinaryReader::ReadSingle()
{
float result = 0;
m_File.read(reinterpret_cast<char*>(&result), sizeof(float));
float_t result = 0;
m_File.read(reinterpret_cast<char*>(&result), sizeof(float_t));
return result;
}
@ -54,6 +54,7 @@ namespace PKG
{
char result;
m_File.read(&result, sizeof(char));
pos_type a = m_File.tellg();
return result;
}
@ -78,15 +79,6 @@ namespace PKG
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::vector<uint8_t> result;

View File

@ -25,11 +25,10 @@ namespace PKG
int32_t ReadInt32();
uint32_t ReadUInt32();
float ReadSingle();
float_t ReadSingle();
char ReadChar();
std::string ReadString(uint32_t length);
std::string ReadNString(int32_t maxLength = -1);
std::string ReadStringFileData(uint32_t length);
void ReadData(std::string& data, uint32_t length);
void ReadData(std::vector<uint8_t>& data, uint32_t length);

View File

@ -51,7 +51,7 @@ namespace PKG
TexMipMap mipmap;
switch (container.imageContainerVersion)
switch (container.ImageContainerVersion)
{
case ImageContainerVersion::VERSION1:
mipmap = ReadMipMapV1(reader); break;
@ -114,11 +114,11 @@ namespace PKG
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++)

View File

@ -6,7 +6,6 @@
#define CORE_H
#ifdef PKG_SHARED
#ifdef __WIN32__
#ifdef PKG_BUILD_DLL
#define PKG_API __declspec(dllexport)
#else
@ -15,9 +14,6 @@
#else
#define PKG_API
#endif
#else
#define PKG_API
#endif
#endif //CORE_H

View File

@ -57,13 +57,11 @@ example:
EXPKG::EXPKG(const std::string& filePath, const std::string& outDir)
{
m_Reader = std::make_shared<BinaryReader>(std::filesystem::u8path(filePath));
m_OutDir = std::filesystem::u8path(outDir);
m_Reader = std::make_shared<BinaryReader>(filePath);
m_OutDir = outDir;
m_OutDir = m_OutDir.make_preferred();
if (m_Reader)
if (!m_Reader)
Run();
}
@ -148,15 +146,15 @@ example:
if (entry.Type == ".tex")
{
std::filesystem::path texPath = m_OutDir / entry.FullPath;
{
BinaryWriter writer(texPath, std::ios::binary);
std::string texdata;
m_Reader->ReadData(texdata, entry.Length);
writer.WriteBytes(texdata.data(), texdata.size());
writer.close();
}
ExtractTex(texPath);
}
@ -176,7 +174,7 @@ example:
else
{
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;
break;
default:
std::cerr << "raw mipmap meybe compressed" << std::endl;
break;
}
}

View File

@ -22,8 +22,7 @@ namespace PKG
public:
std::string Magic;
FreeImageFormat ImageFormat{};
// name conflict
ImageContainerVersion imageContainerVersion;
ImageContainerVersion ImageContainerVersion;
std::vector<TexImage> Images;
};