X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=tools%2Fif2img.cpp;h=d17409e29f75e6dcb95d26437f0b9be95fc264f3;hp=b00c1775f9f03093c8864d66a505b03ce53bc01e;hb=1e88cf0f7fa4f690ea9f110e8ed3f2b5338d0a10;hpb=1fd4f7cc977b9f1499716de10d15656bd50f4816 diff --git a/tools/if2img.cpp b/tools/if2img.cpp index b00c177..d17409e 100644 --- a/tools/if2img.cpp +++ b/tools/if2img.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: if2img.cpp,v 1.1 2000/07/13 07:01:35 kevin Exp $ +** $Id: if2img.cpp,v 1.6 2000/08/25 15:59:13 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -48,6 +48,8 @@ static struct option my_options[] = {0, 0, 0, 0} }; +static const char* g_szIdStr = "$Id: if2img.cpp,v 1.6 2000/08/25 15:59:13 kevin Exp $"; + enum { O_AUTO_FULL, O_AUTO_STD0_1, O_AUTO_STD0_5, O_AUTO_STD1, O_AUTO_STD2, O_AUTO_STD3 }; static const char O_AUTO_FULL_STR[]="full"; static const char O_AUTO_STD0_1_STR[]="std0.1"; @@ -56,9 +58,10 @@ static const char O_AUTO_STD1_STR[]="std1"; static const char O_AUTO_STD2_STR[]="std2"; static const char O_AUTO_STD3_STR[]="std3"; -enum { O_CENTER_MEAN, O_CENTER_MODE }; +enum { O_CENTER_MEDIAN, O_CENTER_MEAN, O_CENTER_MODE }; static const char O_CENTER_MEAN_STR[]="mean"; static const char O_CENTER_MODE_STR[]="mode"; +static const char O_CENTER_MEDIAN_STR[]="median"; enum { O_FORMAT_GIF, O_FORMAT_PNG, O_FORMAT_PNG16, O_FORMAT_PGM, O_FORMAT_PGMASC, O_FORMAT_DISP }; static const char O_FORMAT_GIF_STR[]="gif"; @@ -88,7 +91,8 @@ if2img_usage (const char *program) #endif cout << " disp Display on screen" << endl; cout << " --center Center of window" << endl; - cout << " mode Mode is center of window (default)" << endl; + cout << " median Median is center of window (default)" << endl; + cout << " mode Mode is center of window" << endl; cout << " mean Mean is center of window" << endl; cout << " --auto Set auto window" << endl; cout << " full Use full window (default)" << endl; @@ -122,7 +126,7 @@ if2img_main (int argc, char *const argv[]) int opt_set_min = 0; int opt_stats = 0; int opt_debug = 0; - int opt_center = O_CENTER_MODE; + int opt_center = O_CENTER_MEDIAN; int opt_format = O_FORMAT_PGM; int opt_labels = 0; @@ -190,7 +194,9 @@ if2img_main (int argc, char *const argv[]) } break; case O_CENTER: - if (strcmp(optarg, O_CENTER_MEAN_STR) == 0) + if (strcmp(optarg, O_CENTER_MEDIAN_STR) == 0) + opt_center = O_CENTER_MEDIAN; + else if (strcmp(optarg, O_CENTER_MEAN_STR) == 0) opt_center = O_CENTER_MEAN; else if (strcmp(optarg, O_CENTER_MODE_STR) == 0) opt_center = O_CENTER_MODE; @@ -238,7 +244,7 @@ if2img_main (int argc, char *const argv[]) break; case O_VERSION: #ifdef VERSION - cout << "Version " << VERSION; + cout << "Version " << VERSION << endl << g_szIdStr << endl; #else cout << "Unknown version number" << endl; #endif @@ -253,12 +259,16 @@ if2img_main (int argc, char *const argv[]) } } +#if HAVE_SGP + if (optind + 1 == argc) + opt_format = O_FORMAT_DISP; // display image if no options +#endif + if ((opt_format == O_FORMAT_DISP && optind + 1 != argc) - || (opt_format != O_FORMAT_DISP && optind + 2 != argc)) - { - if2img_usage(argv[0]); - return (1); - } + || (opt_format != O_FORMAT_DISP && optind + 2 != argc)) { + if2img_usage(argv[0]); + return (1); + } in_file = argv[optind]; @@ -318,7 +328,9 @@ if2img_main (int argc, char *const argv[]) if (opt_auto != O_AUTO_FULL) { double center; - if (opt_center == O_CENTER_MODE) + if (opt_center == O_CENTER_MEDIAN) + center = median; + else if (opt_center == O_CENTER_MODE) center = mode; else if (opt_center == O_CENTER_MEAN) center = mean; @@ -357,7 +369,6 @@ if2img_main (int argc, char *const argv[]) im.displayScaling (opt_scale, densmin, densmax); cout << "Press enter to continue\n"; cio_kb_getc(); - sgp2_close(sgp2_get_active_win()); #endif } else