diff --git a/waifu2x-caffe-gui/Source.cpp b/waifu2x-caffe-gui/Source.cpp index 9104ed8..4341037 100644 --- a/waifu2x-caffe-gui/Source.cpp +++ b/waifu2x-caffe-gui/Source.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include #include @@ -26,6 +28,8 @@ const size_t AR_PATH_MAX(1024); const int MinCommonDivisor = 50; const int DefaultCommonDivisor = 128; +const char * const CropSizeListName = "crop_size_list.txt"; + // http://stackoverflow.com/questions/10167382/boostfilesystem-get-relative-path boost::filesystem::path relativePath(const boost::filesystem::path &path, const boost::filesystem::path &relative_to) @@ -93,6 +97,8 @@ class DialogEvent private: HWND dh; + std::vector CropSizeList; + std::string input_str; std::string output_str; std::string mode; @@ -304,10 +310,10 @@ private: SendMessageA(hcrop, CB_ADDSTRING, 0, (LPARAM)"-----------------------"); - // 2の累乗を適当に追加していく - for (int i = 64; i <= 512; i *= 2) + // CropSizeListの値を追加していく + for (const auto n : CropSizeList) { - std::string str(std::to_string(i)); + std::string str(std::to_string(n)); SendMessageA(hcrop, CB_ADDSTRING, 0, (LPARAM)str.c_str()); } @@ -679,6 +685,19 @@ public: SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT_SCALE_RATIO), text); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT_OUT_EXT), outputExt.c_str()); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT_INPUT_EXT_LIST), inputFileExt.c_str()); + + std::ifstream ifs(CropSizeListName); + if (ifs) + { + std::string str; + while (getline(ifs, str)) + { + char *ptr = nullptr; + const long n = strtol(str.c_str(), &ptr, 10); + if (ptr && *ptr == '\0') + CropSizeList.push_back(n); + } + } } void Cancel(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData)