From 64295f44db7f320db0008f587f2456cbd4ca39d6 Mon Sep 17 00:00:00 2001 From: lltcggie Date: Sat, 6 Jun 2015 15:36:19 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=8A=E3=81=99=E3=81=99=E3=82=81=E3=81=AECr?= =?UTF-8?q?opSize=E3=82=92crop=5Fsize=5Flist.txt=E3=81=8B=E3=82=89?= =?UTF-8?q?=E8=AA=AD=E3=81=BF=E8=BE=BC=E3=82=80=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- waifu2x-caffe-gui/Source.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) 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)