Mercurial > mercurial > hgweb_golang.cgi
comparison src/kaigo/horori/console/jpg2tif.cpp @ 57:05f3d51ad966
add fwgo.
| author | pyon@macmini |
|---|---|
| date | Wed, 15 Jul 2020 18:18:24 +0900 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 56:7396e7407abd | 57:05f3d51ad966 |
|---|---|
| 1 /* console.cpp | |
| 2 * Last Change: 2020-04-27 月 09:24:25. | |
| 3 * by T.Mutoh | |
| 4 */ | |
| 5 #include "wx/wxprec.h" | |
| 6 | |
| 7 #include <wx/wx.h> | |
| 8 #include <wx/app.h> | |
| 9 #include <wx/cmdline.h> | |
| 10 | |
| 11 static const wxCmdLineEntryDesc cmdLineDesc[] = | |
| 12 { | |
| 13 {wxCMD_LINE_SWITCH, "h", "help", "show this help message", | |
| 14 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP}, | |
| 15 {wxCMD_LINE_SWITCH, "d", "dummy", "a dummy switch", | |
| 16 wxCMD_LINE_VAL_NONE, 0}, | |
| 17 {wxCMD_LINE_SWITCH, "s", "secret", "a secret switch", | |
| 18 wxCMD_LINE_VAL_NONE, wxCMD_LINE_HIDDEN}, | |
| 19 // ... your other command line options here... | |
| 20 | |
| 21 wxCMD_LINE_DESC_END | |
| 22 }; | |
| 23 | |
| 24 int main(int argc, char **argv) | |
| 25 { | |
| 26 wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program"); | |
| 27 | |
| 28 wxInitializer initializer; | |
| 29 if (!initializer) { | |
| 30 fprintf(stderr, "Failed to initialize the wxWidgets library, aborting."); | |
| 31 return -1; | |
| 32 } | |
| 33 | |
| 34 /* | |
| 35 wxCmdLineParser parser(cmdLineDesc, argc, argv); | |
| 36 switch (parser.Parse()) { | |
| 37 case -1: | |
| 38 // help was given, terminating | |
| 39 break; | |
| 40 | |
| 41 case 0: | |
| 42 // everything is ok; proceed | |
| 43 if (parser.Found("d")) { | |
| 44 wxPrintf("Dummy switch was given...\n"); | |
| 45 | |
| 46 while (1) { | |
| 47 wxChar input[128]; | |
| 48 wxPrintf("Try to guess the magic number (type 'quit' to escape): "); | |
| 49 if ( !wxFgets(input, WXSIZEOF(input), stdin) ) | |
| 50 break; | |
| 51 | |
| 52 // kill the last '\n' | |
| 53 input[wxStrlen(input) - 1] = 0; | |
| 54 | |
| 55 if (wxStrcmp(input, "quit") == 0) | |
| 56 break; | |
| 57 | |
| 58 long val; | |
| 59 if (!wxString(input).ToLong(&val)) { | |
| 60 wxPrintf("Invalid number...\n"); | |
| 61 continue; | |
| 62 } | |
| 63 | |
| 64 if (val == 42) | |
| 65 wxPrintf("You guessed!\n"); | |
| 66 else | |
| 67 wxPrintf("Bad luck!\n"); | |
| 68 } | |
| 69 } | |
| 70 if (parser.Found("s")) { | |
| 71 wxPrintf("Secret switch was given...\n"); | |
| 72 } | |
| 73 | |
| 74 break; | |
| 75 | |
| 76 default: | |
| 77 break; | |
| 78 } | |
| 79 | |
| 80 if (argc == 1) { | |
| 81 wxPrintf("Welcome to the wxWidgets 'console' sample!\n"); | |
| 82 wxPrintf("For more information, run it again with the --help option\n"); | |
| 83 } | |
| 84 */ | |
| 85 | |
| 86 // do something useful here | |
| 87 wxImage::AddHandler(new wxJPEGHandler); | |
| 88 wxImage::AddHandler(new wxTIFFHandler ); | |
| 89 | |
| 90 wxImage img(argv[1], wxBITMAP_TYPE_JPEG); | |
| 91 img.SetOption(wxIMAGE_OPTION_TIFF_COMPRESSION, 5); | |
| 92 img.SetOption(wxIMAGE_OPTION_TIFF_BITSPERSAMPLE, 1); | |
| 93 img.SaveFile(argv[2]); | |
| 94 | |
| 95 return 0; | |
| 96 } | |
| 97 |
