#include "cmdline.h" #include #include int main(int argc, char *argv[]) { // parse options cmdline::parser a; a.add("input", 'i', "Input png image", true, ""); a.add("output", 'o', "Output png image", true, ""); a.add("palette", 'p', "Palette (.png or .gpl)", false, ""); a.add("dither", 'd', "Dither map 2/4/8 (2x2/4x4/8x8)", false, 4); a.parse_check(argc, argv); // get options auto infile = a.get("input").c_str(); auto outfile = a.get("output").c_str(); auto palette = a.get("palette").c_str(); auto dither = a.get("dither"); if (0) { std::cout << "input : " << infile << std::endl; std::cout << "output : " << outfile << std::endl; std::cout << "palette : " << palette << std::endl; std::cout << "dither : " << dither << std::endl; } else { printf("input : [%s]\n", infile); printf("output : [%s]\n", outfile); printf("palette : [%s]\n", palette); printf("dither : %d\n", dither); } if (strlen(infile) == 0 || strlen(outfile) == 0) { // Not set infile or outfile printf("%s\n", a.usage().c_str()); return 1; } if (strlen(palette) == 0) { // Not set palette printf("Use default palette\n"); } if (!(dither == 2 || dither == 4 || dither == 8)) { printf("Error : Unknown dither mode = %d\n\n", dither); printf("%s\n", a.usage().c_str()); return 1; } return 0; }