int main(int argc, char **argv) { const char *inFile = 0; const char *outFile = 0; LevelMode mode = ONE_LEVEL; LevelRoundingMode roundingMode = ROUND_DOWN; Compression compression = ZIP_COMPRESSION; int tileSizeX = 64; int tileSizeY = 64; set<string> doNotFilter; Extrapolation extX = CLAMP; Extrapolation extY = CLAMP; bool verbose = false; // // Parse the command line. // if (argc < 2) usageMessage (argv[0], true); int i = 1; int partnum = 0; while (i < argc) { if (!strcmp (argv[i], "-o")) { // // generate a ONE_LEVEL image // mode = ONE_LEVEL; i += 1; } else if (!strcmp (argv[i], "-m")) { // // Generate a MIPMAP_LEVELS image // mode = MIPMAP_LEVELS; i += 1; } else if (!strcmp (argv[i], "-r")) { // // Generate a RIPMAP_LEVELS image // mode = RIPMAP_LEVELS; i += 1; } else if (!strcmp (argv[i], "-f")) { // // Don't low-pass filter the specified image channel // if (i > argc - 2) usageMessage (argv[0]); doNotFilter.insert (argv[i + 1]); i += 2; } else if (!strcmp (argv[i], "-e")) { // // Set x and y extrapolation method // if (i > argc - 3) usageMessage (argv[0]); extX = getExtrapolation (argv[i + 1]); extY = getExtrapolation (argv[i + 2]); i += 3; } else if (!strcmp (argv[i], "-t")) { // // Set tile size // if (i > argc - 3) usageMessage (argv[0]); tileSizeX = strtol (argv[i + 1], 0, 0); tileSizeY = strtol (argv[i + 2], 0, 0); if (tileSizeX <= 0 || tileSizeY <= 0) { cerr << "Tile size must be greater than zero." << endl; return 1; } i += 3; } else if (!strcmp (argv[i], "-d")) { // // Round down // roundingMode = ROUND_DOWN; i += 1; } else if (!strcmp (argv[i], "-u")) { // // Round down // roundingMode = ROUND_UP; i += 1; } else if (!strcmp (argv[i], "-z")) { // // Set compression method // if (i > argc - 2) usageMessage (argv[0]); compression = getCompression (argv[i + 1]); i += 2; } else if (!strcmp (argv[i], "-v")) { // // Verbose mode // verbose = true; i += 1; } else if (!strcmp (argv[i], "-h")) { // // Print help message // usageMessage (argv[0], true); } else if (!strcmp (argv[i], "-p")) { getPartNum (argc, argv, i, &partnum); } else { // // Image file name // if (inFile == 0) inFile = argv[i]; else outFile = argv[i]; i += 1; } } if (inFile == 0 || outFile == 0) usageMessage (argv[0]); if (!strcmp (inFile, outFile)) { cerr << "Input and output cannot be the same file." << endl; return 1; } // // Load inFile, and save a tiled version in outFile. // int exitStatus = 0; // // check input // { MultiPartInputFile input (inFile); int parts = input.parts(); if (partnum < 0 || partnum >= parts){ cerr << "ERROR: you asked for part " << partnum << " in " << inFile; cerr << ", which only has " << parts << " parts\n"; exit(1); } Header h = input.header (partnum); if (h.type() == DEEPTILE || h.type() == DEEPSCANLINE) { cerr << "Cannot make tile for deep data" << endl; exit(1); } } try { makeTiled (inFile, outFile, partnum, mode, roundingMode, compression, tileSizeX, tileSizeY, doNotFilter, extX, extY, verbose); } catch (const exception &e) { cerr << e.what() << endl; exitStatus = 1; } return exitStatus; }