[Resources] Properly encode soh textures and remove raw load (#2548)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "Main.h"
|
||||
#include "Exporter.h"
|
||||
#include "BackgroundExporter.h"
|
||||
#include "TextureExporter.h"
|
||||
#include "RoomExporter.h"
|
||||
@@ -120,13 +121,23 @@ static void ExporterProgramEnd()
|
||||
splitPath.pop_back();
|
||||
std::string afterPath = std::accumulate(splitPath.begin(), splitPath.end(), std::string(""));
|
||||
if (extension == "png" && (format == "rgba32" || format == "rgb5a1" || format == "i4" || format == "i8" || format == "ia4" || format == "ia8" || format == "ia16" || format == "ci4" || format == "ci8")) {
|
||||
ZTexture tex(nullptr);
|
||||
Globals::Instance->buildRawTexture = true;
|
||||
Globals::Instance->BuildAssetTexture(item, ZTexture::GetTextureTypeFromString(format), afterPath);
|
||||
Globals::Instance->buildRawTexture = false;
|
||||
|
||||
auto fileData = File::ReadAllBytes(afterPath);
|
||||
tex.FromPNG(item, ZTexture::GetTextureTypeFromString(format));
|
||||
printf("otrArchive->AddFile(%s)\n", StringHelper::Split(afterPath, "Extract/")[1].c_str());
|
||||
otrArchive->AddFile(StringHelper::Split(afterPath, "Extract/")[1], (uintptr_t)fileData.data(), fileData.size());
|
||||
|
||||
auto exporter = new OTRExporter_Texture();
|
||||
MemoryStream* stream = new MemoryStream();
|
||||
BinaryWriter writer(stream);
|
||||
|
||||
exporter->Save(&tex, "", &writer);
|
||||
|
||||
std::string src = tex.GetBodySourceCode();
|
||||
writer.Write((char*) src.c_str(), src.size());
|
||||
|
||||
std::vector<char> fileData = stream->ToVector();
|
||||
otrArchive->AddFile(StringHelper::Split(afterPath, "Extract/assets/")[1], (uintptr_t)fileData.data(), fileData.size());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,10 @@ void OTRExporter_Texture::Save(ZResource* res, const fs::path& outPath, BinaryWr
|
||||
|
||||
writer->Write((uint32_t)tex->GetRawDataSize());
|
||||
|
||||
auto data = tex->parent->GetRawData();
|
||||
|
||||
writer->Write((char*)data.data() + tex->GetRawDataIndex(), tex->GetRawDataSize());
|
||||
if (tex->parent != nullptr) {
|
||||
auto data = tex->parent->GetRawData();
|
||||
writer->Write((char*)data.data() + tex->GetRawDataIndex(), tex->GetRawDataSize());
|
||||
}
|
||||
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
size_t diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
||||
|
||||
Reference in New Issue
Block a user