mirror of
https://github.com/Pixinn/Rgb2Hires.git
synced 2024-06-02 07:41:33 +00:00
Enhancing command parsing
This commit is contained in:
parent
ff08549ef1
commit
a33c95d6c0
|
@ -75,21 +75,18 @@ int main( int argc, char *argv[] )
|
||||||
}
|
}
|
||||||
|
|
||||||
//Parsing command line
|
//Parsing command line
|
||||||
TCLAP::CmdLine cmd("Picture - by Christophe Meneboeuf <christophe@xtof.info>", ' ', "0");
|
TCLAP::CmdLine cmd("Picture - by Christophe Meneboeuf <christophe@xtof.info>", ' ', "0.1");
|
||||||
TCLAP::ValueArg<string> imagePath("i", "image", "Source image path", true, "", "path_to_image");
|
TCLAP::ValueArg<string> imagePath("i", "image", "Source image path", true, "", "path_to_image");
|
||||||
TCLAP::ValueArg<string> outputPath("o", "output", "Output path", true, "", "path_to_output");
|
TCLAP::ValueArg<string> outputPath("o", "output", "Output path to write the HIRES file", true, "", "path_to_output");
|
||||||
|
TCLAP::SwitchArg preview("p", "preview", "Open a window to display a live preview.");
|
||||||
TCLAP::SwitchArg assembly("a", "asm", "Output asm format");
|
TCLAP::SwitchArg assembly("a", "asm", "Output asm format");
|
||||||
TCLAP::SwitchArg preview("p", "preview", "Open a window to display a preview.");
|
|
||||||
cmd.add(imagePath);
|
cmd.add(imagePath);
|
||||||
cmd.add(outputPath);
|
cmd.xorAdd(outputPath, preview); // live preview or output to disk
|
||||||
cmd.add(assembly);
|
cmd.add(assembly);
|
||||||
cmd.add(preview);
|
|
||||||
cmd.parse(argc, argv);
|
cmd.parse(argc, argv);
|
||||||
|
|
||||||
if (imagePath.getValue().size() == 0 || outputPath.getValue().size() == 0) {
|
if (imagePath.getValue().size() == 0) {
|
||||||
std::cout << "No input or output path provided." << std::endl;
|
ExitOnError("No input path provided.\n");
|
||||||
IMG_Quit();
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,12 +104,23 @@ int main( int argc, char *argv[] )
|
||||||
}
|
}
|
||||||
const ImageQuantized imageHiRes{ surfaceRgb };
|
const ImageQuantized imageHiRes{ surfaceRgb };
|
||||||
|
|
||||||
if (preview.getValue()) {
|
// Preview
|
||||||
|
if (preview.getValue())
|
||||||
|
{
|
||||||
|
if (assembly.getValue() == true)
|
||||||
|
{
|
||||||
|
std::cout << "\nIgnoring --asm option.\n";
|
||||||
|
}
|
||||||
const auto bytes = imageHiRes.getHiresBuffer();
|
const auto bytes = imageHiRes.getHiresBuffer();
|
||||||
Display::Window::GetInstance()->display(filepath, bytes->data());
|
Display::Window::GetInstance()->display(filepath, bytes->data());
|
||||||
}
|
}
|
||||||
|
// Convertion to disk
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (outputPath.getValue().size() == 0) {
|
||||||
|
ExitOnError("No output path provided.\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (assembly.getValue() == true) { //Ouput in ASM
|
if (assembly.getValue() == true) { //Ouput in ASM
|
||||||
ofstream output(outputPath.getValue());
|
ofstream output(outputPath.getValue());
|
||||||
output << imageHiRes.getHiresAsm();
|
output << imageHiRes.getHiresAsm();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user