mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-22 00:55:45 +00:00
49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
#include "AssetDumperGfxImage.h"
|
|
|
|
#include <cassert>
|
|
|
|
#include "ObjWriting.h"
|
|
#include "Image/IwiWriter27.h"
|
|
#include "Image/DdsWriter.h"
|
|
|
|
using namespace T5;
|
|
|
|
AssetDumperGfxImage::AssetDumperGfxImage()
|
|
{
|
|
switch (ObjWriting::Configuration.ImageOutputFormat)
|
|
{
|
|
case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS:
|
|
m_writer = std::make_unique<DdsWriter>();
|
|
break;
|
|
case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI:
|
|
m_writer = std::make_unique<iwi27::IwiWriter>();
|
|
break;
|
|
default:
|
|
assert(false);
|
|
m_writer = nullptr;
|
|
break;
|
|
}
|
|
}
|
|
|
|
bool AssetDumperGfxImage::ShouldDump(XAssetInfo<GfxImage>* asset)
|
|
{
|
|
const auto* image = asset->Asset();
|
|
return image->loadedSize > 0;
|
|
}
|
|
|
|
bool AssetDumperGfxImage::CanDumpAsRaw()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
std::string AssetDumperGfxImage::GetFileNameForAsset(Zone* zone, XAssetInfo<GfxImage>* asset)
|
|
{
|
|
return "images/" + asset->m_name + m_writer->GetFileExtension();
|
|
}
|
|
|
|
void AssetDumperGfxImage::DumpRaw(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream)
|
|
{
|
|
const auto* image = asset->Asset();
|
|
m_writer->DumpImage(stream, image->texture.texture);
|
|
}
|