VOXCONVERT: allow to create a palette from input file

master
Martin Gerhardy 2022-03-17 10:14:37 +01:00
parent 35247e96b5
commit 852a5457b9
1 changed files with 15 additions and 0 deletions

View File

@ -168,6 +168,21 @@ app::AppState VoxConvert::onInit() {
if (!outfile.empty()) {
Log::info("* output files: - %s", outfile.c_str());
}
if (io::isImage(outfile) && infiles.size() == 1) {
voxel::Palette palette;
if (!voxelutil::importPalette(infiles[0], palette)) {
Log::error("Failed to import the palette from %s", infiles[0].c_str());
return app::AppState::InitFailure;
}
if (palette.save(outfile.c_str())) {
Log::info("Saved palette with %i colors to %s", palette.colorCount, outfile.c_str());
return state;
}
Log::error("Failed to write %s", outfile.c_str());
return app::AppState::InitFailure;
}
core::String scriptParameters;
if (hasArg("--script")) {
scriptParameters = getArgVal("--script");