diff --git a/bin/lang/english.json b/bin/lang/english.json index 1f80abb..6099803 100644 --- a/bin/lang/english.json +++ b/bin/lang/english.json @@ -5,7 +5,8 @@ "IDC_STATIC_OUTPUT_PATH":"Output path", "IDC_STATIC_TANS_EXT_LIST":"Input file extensions", "IDC_STATIC_OUTPUT_EXT":"Output extension", -"IDC_STATIC_OUTPUT_QUALITY":"Output quality (1~100)", +"IDC_STATIC_OUTPUT_QUALITY":"Output quality", +"IDC_STATIC_OUTPUT_DEPTH":"Output depth bits", "IDC_STATIC_QUALITY_PROCESS_SETTING":"Convert Image quality && Processing Settings", "IDC_STATIC_TRANS_MODE":"Conversion Mode", "IDC_RADIO_MODE_NOISE_SCALE":"Denoise && Magnify", @@ -41,6 +42,9 @@ "MessageOutputPathCheckError":"Please specify the output path", "MessageOutputExtCheckError":"Please specify the output extension", "MessageInputCheckError":"Input file or folder does not exist", +"MessageOutputExtentionCheckError":"Please select the output extension", +"MessageOutputQualityCheckError":"Output quality is out of range", +"MessageOutputDepthCheckError":"Output depth bits is incorrect", "MessageCudaNotFindError":"Input can not be converted by GPU\r\nThe CUDA driver may not have been installed. \r\nPlease install the CUDA driver", "MessageCudaOldVersionError":"Input can not be converted by GPU\r\nThe CUDA driver version may be old \r\nPlease update the CUDA driver", "MessageTransSuccess":"Successful converted", diff --git a/bin/lang/japanese.json b/bin/lang/japanese.json index e55e4d2..b0df903 100644 --- a/bin/lang/japanese.json +++ b/bin/lang/japanese.json @@ -5,7 +5,8 @@ "IDC_STATIC_OUTPUT_PATH":"出力パス", "IDC_STATIC_TANS_EXT_LIST":"フォルダ内の変換する拡張子", "IDC_STATIC_OUTPUT_EXT":"出力拡張子", -"IDC_STATIC_OUTPUT_QUALITY":"出力画質設定(1~100)", +"IDC_STATIC_OUTPUT_QUALITY":"出力画質設定", +"IDC_STATIC_OUTPUT_DEPTH":"出力深度ビット数", "IDC_STATIC_QUALITY_PROCESS_SETTING":"変換画質・処理設定", "IDC_STATIC_TRANS_MODE":"変換モード", "IDC_RADIO_MODE_NOISE_SCALE":"ノイズ除去と拡大", @@ -41,6 +42,9 @@ "MessageOutputPathCheckError":"出力パスを指定して下さい", "MessageOutputExtCheckError":"出力拡張子を指定して下さい", "MessageInputCheckError":"入力ファイル/フォルダが存在しません", +"MessageOutputExtentionCheckError":"出力拡張子を選択してください", +"MessageOutputQualityCheckError":"出力画質設定の値が範囲外です", +"MessageOutputDepthCheckError":"出力深度ビット数が不正な値です", "MessageCudaNotFindError":"GPUで変換出来ません。\r\nCUDAドライバーがインストールされていない可能性があります。\r\nCUDAドライバーをインストールして下さい。", "MessageCudaOldVersionError":"GPUで変換出来ません。\r\nCUDAドライバーのバージョンが古い可能性があります。\r\nCUDAドライバーを更新して下さい。", "MessageTransSuccess":"変換に成功しました", diff --git a/common/waifu2x.cpp b/common/waifu2x.cpp index 66eedf3..5a04fa5 100644 --- a/common/waifu2x.cpp +++ b/common/waifu2x.cpp @@ -123,6 +123,21 @@ static std::once_flag waifu2x_once_flag; static std::once_flag waifu2x_cudnn_once_flag; static std::once_flag waifu2x_cuda_once_flag; +const std::vector Waifu2x::OutputExtentionList = +{ + { L".png", { 8, 16 }, boost::optional(), boost::optional(), boost::optional(), boost::optional() }, + { L".bmp", { 8 }, boost::optional(), boost::optional(), boost::optional(), boost::optional() }, + { L".jpg", { 8 }, 0, 100, 95, cv::IMWRITE_JPEG_QUALITY }, + { L".jp2", { 8, 16 }, boost::optional(), boost::optional(), boost::optional(), boost::optional() }, + { L".sr", { 8 }, boost::optional(), boost::optional(), boost::optional(), boost::optional() }, + { L".tif", { 8, 16, 32 }, boost::optional(), boost::optional(), boost::optional(), boost::optional() }, + { L".hdr", { 8, 16, 32 }, boost::optional(), boost::optional(), boost::optional(), boost::optional() }, + { L".exr", { 8, 16, 32 }, boost::optional(), boost::optional(), boost::optional(), boost::optional() }, + { L".ppm", { 8, 16 }, boost::optional(), boost::optional(), boost::optional(), boost::optional() }, + { L".webp", { 8 }, 1, 100, 100, cv::IMWRITE_WEBP_QUALITY }, + { L".tga", { 8 }, boost::optional(), boost::optional(), boost::optional(), boost::optional() }, +}; + #ifndef CUDA_CHECK_WAIFU2X #define CUDA_CHECK_WAIFU2X(condition) \ do { \ @@ -1108,7 +1123,7 @@ Waifu2x::eWaifu2xError Waifu2x::ReconstructImage(boost::shared_ptr OutputQuality, const int OutputDepth, const bool UseTTA, const int CropSize, const int BatchSize) { Waifu2x::eWaifu2xError ret; @@ -1127,6 +1142,9 @@ Waifu2x::eWaifu2xError Waifu2x::init(int argc, char** argv, const std::string &M process = Process; use_tta = UseTTA; + output_quality = OutputQuality; + output_depth = OutputDepth; + crop_size = CropSize; batch_size = BatchSize; @@ -1331,8 +1349,28 @@ Waifu2x::eWaifu2xError Waifu2x::WriteMat(const cv::Mat &im, const boost::filesys try { + const boost::filesystem::path op(output_file); + const boost::filesystem::path opext(op.extension()); + + std::vector params; + + const auto &OutputExtentionList = Waifu2x::OutputExtentionList; + for (const auto &elm : OutputExtentionList) + { + if (elm.ext == opext) + { + if (elm.imageQualitySettingVolume && output_quality) + { + params.push_back(*elm.imageQualitySettingVolume); + params.push_back(*output_quality); + } + + break; + } + } + std::vector buf; - cv::imencode(ext, im, buf); + cv::imencode(ext, im, buf, params); if (writeFile(output_file, buf)) return eWaifu2xError_OK; diff --git a/common/waifu2x.h b/common/waifu2x.h index 326cc76..34dfbe3 100644 --- a/common/waifu2x.h +++ b/common/waifu2x.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #define CUDNN_DLL_NAME "cudnn64_4.dll" @@ -56,6 +57,18 @@ public: typedef std::function waifu2xCancelFunc; + struct stOutputExtentionElement + { + std::wstring ext; + std::vector depthList; + boost::optional imageQualityStart; + boost::optional imageQualityEnd; + boost::optional imageQualityDefault; + boost::optional imageQualitySettingVolume; + }; + + const static std::vector OutputExtentionList; + private: bool is_inited; @@ -97,6 +110,9 @@ private: bool use_tta; + boost::optional output_quality; + int output_depth; + private: static eWaifu2xError LoadMat(cv::Mat &float_image, const boost::filesystem::path &input_file); static eWaifu2xError LoadMatBySTBI(cv::Mat &float_image, const std::vector &img_data); @@ -130,7 +146,7 @@ public: // mode: noise or scale or noise_scale or auto_scale // process: cpu or gpu or cudnn eWaifu2xError init(int argc, char** argv, const std::string &mode, const int noise_level, const double scale_ratio, const boost::filesystem::path &model_dir, const std::string &process, - const bool use_tta = false, const int crop_size = 128, const int batch_size = 1); + const boost::optional output_quality = boost::optional(), const int output_depth = 8, const bool use_tta = false, const int crop_size = 128, const int batch_size = 1); void destroy(); diff --git a/waifu2x-caffe-gui/Resource.rc b/waifu2x-caffe-gui/Resource.rc index 44e8d6b..335976e 100644 Binary files a/waifu2x-caffe-gui/Resource.rc and b/waifu2x-caffe-gui/Resource.rc differ diff --git a/waifu2x-caffe-gui/Source.cpp b/waifu2x-caffe-gui/Source.cpp index 678ac76..7acc5b7 100644 --- a/waifu2x-caffe-gui/Source.cpp +++ b/waifu2x-caffe-gui/Source.cpp @@ -126,6 +126,9 @@ private: bool use_tta; + int output_quality; + int output_depth; + int crop_size; int batch_size; @@ -205,6 +208,8 @@ private: addstr += TEXT("(tta)"); if (mode.find("scale") != mode.npos) addstr += TEXT("(x") + to_tstring(scale_ratio) + TEXT(")"); + if (output_depth != 8) + addstr += TEXT("(") + boost::lexical_cast(output_depth) + TEXT("bit)"); return addstr; } @@ -276,13 +281,41 @@ private: } { - TCHAR buf[AR_PATH_MAX] = TEXT(""); - GetWindowText(GetDlgItem(dh, IDC_EDIT_OUT_EXT), buf, _countof(buf)); - buf[_countof(buf) - 1] = TEXT('\0'); + const auto &OutputExtentionList = Waifu2x::OutputExtentionList; - outputExt = buf; - if (outputExt.length() > 0 && outputExt[0] != TEXT('.')) - outputExt = TEXT(".") + outputExt; + const int cur = SendMessage(GetDlgItem(dh, IDC_COMBO_OUT_EXT), CB_GETCURSEL, 0, 0); + if (cur < 0 || cur >= OutputExtentionList.size()) + MessageBox(dh, langStringList.GetString(L"MessageOutputExtentionCheckError").c_str(), langStringList.GetString(L"MessageTitleError").c_str(), MB_OK | MB_ICONERROR); + else + { + const auto elm = OutputExtentionList[cur]; + + outputExt = elm.ext; + + TCHAR buf[AR_PATH_MAX] = TEXT(""); + + GetWindowText(GetDlgItem(dh, IDC_EDIT_OUT_QUALITY), buf, _countof(buf)); + buf[_countof(buf) - 1] = TEXT('\0'); + + if (elm.imageQualityStart && elm.imageQualityEnd) + { + TCHAR *ptr = nullptr; + output_quality = _tcstol(buf, &ptr, 10); + if (!ptr || *ptr != '\0' || output_quality < *elm.imageQualityStart || output_quality > *elm.imageQualityEnd) + { + output_quality = 8; + ret = false; + + MessageBox(dh, langStringList.GetString(L"MessageOutputQualityCheckError").c_str(), langStringList.GetString(L"MessageTitleError").c_str(), MB_OK | MB_ICONERROR); + } + } + + const int curDepth = SendMessage(GetDlgItem(dh, IDC_COMBO_OUTPUT_DEPTH), CB_GETCURSEL, 0, 0); + if (curDepth < 0 || curDepth >= elm.depthList.size()) + MessageBox(dh, langStringList.GetString(L"MessageOutputQualityCheckError").c_str(), langStringList.GetString(L"MessageTitleError").c_str(), MB_OK | MB_ICONERROR); + else + output_depth = elm.depthList[curDepth]; + } } if (SendMessage(GetDlgItem(dh, IDC_RADIO_MODE_CPU), BM_GETCHECK, 0, 0)) @@ -534,7 +567,7 @@ private: Waifu2x::eWaifu2xError ret; Waifu2x w; - ret = w.init(__argc, __argv, mode, noise_level, scale_ratio, model_dir, process, use_tta, crop_size, batch_size); + ret = w.init(__argc, __argv, mode, noise_level, scale_ratio, model_dir, process, output_quality, output_depth, use_tta, crop_size, batch_size); if(ret != Waifu2x::eWaifu2xError_OK) SendMessage(dh, WM_ON_WAIFU2X_ERROR, (WPARAM)&ret, 0); else @@ -671,7 +704,6 @@ private: tstring tScale; tstring tmode; tstring tprcess; - tstring toutputExt; tScale = to_tstring(scale_ratio); @@ -689,13 +721,9 @@ private: else tprcess = TEXT("cpu"); - toutputExt = outputExt; - if (toutputExt.length() > 0 && toutputExt[0] == TEXT('.')) - toutputExt.erase(0, 1); - WritePrivateProfileString(TEXT("Setting"), TEXT("LastScale"), tScale.c_str(), getTString(SettingFilePath).c_str()); - WritePrivateProfileString(TEXT("Setting"), TEXT("LastOutputExt"), toutputExt.c_str(), getTString(SettingFilePath).c_str()); + WritePrivateProfileString(TEXT("Setting"), TEXT("LastOutputExt"), outputExt.c_str(), getTString(SettingFilePath).c_str()); WritePrivateProfileString(TEXT("Setting"), TEXT("LastInputFileExt"), inputFileExt.c_str(), getTString(SettingFilePath).c_str()); @@ -708,6 +736,10 @@ private: WritePrivateProfileString(TEXT("Setting"), TEXT("LastModel"), to_tstring(modelType).c_str(), getTString(SettingFilePath).c_str()); WritePrivateProfileString(TEXT("Setting"), TEXT("LastUseTTA"), to_tstring(use_tta ? 1 : 0).c_str(), getTString(SettingFilePath).c_str()); + + WritePrivateProfileString(TEXT("Setting"), TEXT("LastOutputQuality"), boost::lexical_cast(output_quality).c_str(), getTString(SettingFilePath).c_str()); + + WritePrivateProfileString(TEXT("Setting"), TEXT("LastOutputDepth"), boost::lexical_cast(output_depth).c_str(), getTString(SettingFilePath).c_str()); } // o̓pXI @@ -780,8 +812,8 @@ private: public: DialogEvent() : dh(nullptr), mode("noise_scale"), noise_level(1), scale_ratio(2.0), model_dir(TEXT("models/anime_style_art_rgb")), - process("gpu"), outputExt(TEXT("png")), inputFileExt(TEXT("png:jpg:jpeg:tif:tiff:bmp:tga")), - use_tta(false), crop_size(128), batch_size(1), isLastError(false) + process("gpu"), outputExt(TEXT(".png")), inputFileExt(TEXT("png:jpg:jpeg:tif:tiff:bmp:tga")), + use_tta(false), output_quality(100), output_depth(8), crop_size(128), batch_size(1), isLastError(false) { } @@ -953,6 +985,7 @@ public: SET_WINDOW_TEXT(IDC_STATIC_TANS_EXT_LIST); SET_WINDOW_TEXT(IDC_STATIC_OUTPUT_EXT); SET_WINDOW_TEXT(IDC_STATIC_OUTPUT_QUALITY); + SET_WINDOW_TEXT(IDC_STATIC_OUTPUT_DEPTH); SET_WINDOW_TEXT(IDC_STATIC_QUALITY_PROCESS_SETTING); SET_WINDOW_TEXT(IDC_STATIC_TRANS_MODE); SET_WINDOW_TEXT(IDC_RADIO_MODE_NOISE_SCALE); @@ -981,6 +1014,76 @@ public: #undef SET_WINDOW_TEXT } + void SetDepthAndQuality() + { + HWND hout = GetDlgItem(dh, IDC_COMBO_OUT_EXT); + HWND houtDepth = GetDlgItem(dh, IDC_COMBO_OUTPUT_DEPTH); + + const int cur = SendMessage(hout, CB_GETCURSEL, 0, 0); + if (cur < 0) + return; + + const auto &OutputExtentionList = Waifu2x::OutputExtentionList; + if (cur >= OutputExtentionList.size()) + return; + + const auto elm = OutputExtentionList[cur]; + + int oldDepth = 0; + { + TCHAR oldDepthStr[100] = TEXT(""); + GetWindowText(houtDepth, oldDepthStr, _countof(oldDepthStr)); + + if (_tcslen(oldDepthStr) > 0) + oldDepth = boost::lexical_cast(oldDepthStr); + } + + // [x̃Xg + while (SendMessage(houtDepth, CB_GETCOUNT, 0, 0) != 0) + SendMessage(houtDepth, CB_DELETESTRING, 0, 0); + + // [x̃Xglj + size_t defaultIndex = 0; + for (size_t i = 0; i < elm.depthList.size(); i++) + { + const auto depth = elm.depthList[i]; + + const auto str = boost::lexical_cast(depth); + const auto index = SendMessage(houtDepth, CB_ADDSTRING, 0, (LPARAM)str.c_str()); + + if (depth == oldDepth) + defaultIndex = i; + } + + SendMessage(houtDepth, CB_SETCURSEL, defaultIndex, 0); + + if (elm.depthList.size() == 1) + EnableWindow(houtDepth, FALSE); + else + EnableWindow(houtDepth, TRUE); + + if (!elm.imageQualityStart || !elm.imageQualityEnd || !elm.imageQualityDefault) // 掿ݒ͖ + { + EnableWindow(GetDlgItem(dh, IDC_EDIT_OUT_QUALITY), FALSE); + SetWindowTextW(GetDlgItem(dh, IDC_EDIT_OUT_QUALITY), L""); + + SetWindowTextW(GetDlgItem(dh, IDC_STATIC_OUTPUT_QUALITY), langStringList.GetString(L"IDC_STATIC_OUTPUT_QUALITY").c_str()); + } + else + { + HWND hedit = GetDlgItem(dh, IDC_EDIT_OUT_QUALITY); + + EnableWindow(hedit, TRUE); + SetWindowText(hedit, boost::lexical_cast(*elm.imageQualityDefault).c_str()); + + const auto wstr = langStringList.GetString(L"IDC_STATIC_OUTPUT_QUALITY"); + + const auto addstr = std::wstring(L" (") + boost::lexical_cast(*elm.imageQualityStart) + + L"`" + boost::lexical_cast(*elm.imageQualityEnd) + L")"; + SetWindowTextW(GetDlgItem(dh, IDC_STATIC_OUTPUT_QUALITY), (wstr + addstr).c_str()); + } + } + void Create(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData) { dh = hWnd; @@ -1028,6 +1131,20 @@ public: SendMessage(hlang, CB_SETCURSEL, defaultListIndex, 0); } + { + HWND houtext = GetDlgItem(dh, IDC_COMBO_OUT_EXT); + + const auto &OutputExtentionList = Waifu2x::OutputExtentionList; + for (const auto &elm : OutputExtentionList) + { + SendMessageW(houtext, CB_ADDSTRING, 0, (LPARAM)elm.ext.c_str()); + } + + SendMessage(houtext, CB_SETCURSEL, 0, 0); + + SetDepthAndQuality(); + } + const boost::filesystem::path CropSizeListPath(exeDir / CropSizeListName); std::ifstream ifs(CropSizeListPath.wstring()); if (ifs) @@ -1100,6 +1217,10 @@ public: modelType = (eModelType)GetPrivateProfileInt(TEXT("Setting"), TEXT("LastModel"), 0, getTString(SettingFilePath).c_str()); use_tta = GetPrivateProfileInt(TEXT("Setting"), TEXT("LastUseTTA"), 0, getTString(SettingFilePath).c_str()) != 0; + + output_quality = GetPrivateProfileInt(TEXT("Setting"), TEXT("LastOutputQuality"), output_quality, getTString(SettingFilePath).c_str()); + + output_depth = GetPrivateProfileInt(TEXT("Setting"), TEXT("LastOutputDepth"), output_depth, getTString(SettingFilePath).c_str()); } TCHAR *ptr = nullptr; @@ -1107,8 +1228,8 @@ public: if (!ptr || *ptr != TEXT('\0') || tempScale <= 0.0) tScale = TEXT("2.00"); - if (outputExt.length() > 0 && outputExt[0] == TEXT('.')) - outputExt.erase(0, 1); + if (outputExt.length() > 0 && outputExt[0] != TEXT('.')) + outputExt = L"." + outputExt; if (!(1 <= noise_level && noise_level <= 2)) noise_level = 1; @@ -1197,10 +1318,31 @@ public: SendMessage(GetDlgItem(hWnd, IDC_CHECK_TTA), BM_SETCHECK, BST_UNCHECKED, 0); SetWindowText(GetDlgItem(hWnd, IDC_EDIT_SCALE_RATIO), tScale.c_str()); - SetWindowText(GetDlgItem(hWnd, IDC_EDIT_OUT_EXT), outputExt.c_str()); SetWindowText(GetDlgItem(hWnd, IDC_EDIT_INPUT_EXT_LIST), inputFileExt.c_str()); EnableWindow(GetDlgItem(dh, IDC_BUTTON_CANCEL), FALSE); + + // O̊gqݒ֘A𕜌 + HWND houtext = GetDlgItem(dh, IDC_COMBO_OUT_EXT); + + size_t defaultIndex = 0; + const auto &OutputExtentionList = Waifu2x::OutputExtentionList; + for (size_t i = 0; i < OutputExtentionList.size(); i++) + { + const auto &elm = OutputExtentionList[i]; + if (elm.ext == outputExt) + { + defaultIndex = i; + break; + } + } + + SendMessage(houtext, CB_SETCURSEL, defaultIndex, 0); + + SetWindowText(GetDlgItem(hWnd, IDC_EDIT_OUT_QUALITY), boost::lexical_cast(output_quality).c_str()); + SetWindowText(GetDlgItem(hWnd, IDC_COMBO_OUTPUT_DEPTH), boost::lexical_cast(output_depth).c_str()); + + SetDepthAndQuality(); } void Cancel(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData) @@ -1209,7 +1351,7 @@ public: EnableWindow(GetDlgItem(dh, IDC_BUTTON_CANCEL), FALSE); } - void RadioButtom(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData) + void UpdateAddString(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData) { ReplaceAddString(); } @@ -1441,6 +1583,16 @@ public: SetWindowTextLang(); } + + void OutExtChange(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData) + { + if (HIWORD(wParam) != CBN_SELCHANGE) + return; + + SetDepthAndQuality(); + + ReplaceAddString(); + } }; int WINAPI WinMain(HINSTANCE hInstance, @@ -1470,7 +1622,6 @@ int WINAPI WinMain(HINSTANCE hInstance, CControl cControlInput(IDC_EDIT_INPUT); CControl cControlOutput(IDC_EDIT_OUTPUT); CControl cControlScale(IDC_EDIT_SCALE_RATIO); - CControl cControlOutExt(IDC_EDIT_OUT_EXT); // o^֐܂Ƃ߂ꂽNX // O[o֐g΃NXɂ܂Ƃ߂Kv͂Ȃ̕@𗧂‚Ƃ͂ @@ -1482,36 +1633,35 @@ int WINAPI WinMain(HINSTANCE hInstance, cControlInput.SetEventCallBack(SetClassCustomFunc(DialogEvent::DropInput, &cDialogEvent), NULL, WM_DROPFILES); cControlOutput.SetEventCallBack(SetClassCustomFunc(DialogEvent::DropOutput, &cDialogEvent), NULL, WM_DROPFILES); cControlScale.SetEventCallBack(SetClassCustomFunc(DialogEvent::TextInput, &cDialogEvent), NULL, WM_CHAR); - cControlOutExt.SetEventCallBack(SetClassCustomFunc(DialogEvent::TextInput, &cDialogEvent), NULL, WM_CHAR); // Rg[̃TuNXo^ cDialog.AddControl(&cControlInput); cDialog.AddControl(&cControlOutput); cDialog.AddControl(&cControlScale); - cDialog.AddControl(&cControlOutExt); // eRg[̃CxgŎs֐̓o^ cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::Exec, &cDialogEvent), NULL, IDC_BUTTON_EXEC); cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::Cancel, &cDialogEvent), NULL, IDC_BUTTON_CANCEL); cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::InputRef, &cDialogEvent), NULL, IDC_BUTTON_INPUT_REF); - cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIO_MODE_NOISE); - cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIO_MODE_SCALE); - cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIO_MODE_NOISE_SCALE); - cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIO_AUTO_SCALE); - cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIONOISE_LEVEL1); - cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIONOISE_LEVEL2); - cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIO_MODE_CPU); - cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIO_MODE_GPU); - cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIO_MODEL_RGB); - cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIO_MODEL_PHOTO); - cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIO_MODEL_Y); - - cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_CHECK_TTA); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_RADIO_MODE_NOISE); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_RADIO_MODE_SCALE); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_RADIO_MODE_NOISE_SCALE); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_RADIO_AUTO_SCALE); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_RADIONOISE_LEVEL1); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_RADIONOISE_LEVEL2); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_RADIO_MODE_CPU); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_RADIO_MODE_GPU); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_RADIO_MODEL_RGB); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_RADIO_MODEL_PHOTO); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_RADIO_MODEL_Y); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_CHECK_TTA); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::UpdateAddString, &cDialogEvent), NULL, IDC_COMBO_OUTPUT_DEPTH); cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::CheckCUDNN, &cDialogEvent), NULL, IDC_BUTTON_CHECK_CUDNN); cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::LangChange, &cDialogEvent), NULL, IDC_COMBO_LANG); + cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::OutExtChange, &cDialogEvent), NULL, IDC_COMBO_OUT_EXT); // _CAÕCxgŎs֐̓o^ cDialog.SetEventCallBack(SetClassFunc(DialogEvent::Create, &cDialogEvent), NULL, WM_INITDIALOG); diff --git a/waifu2x-caffe-gui/resource.h b/waifu2x-caffe-gui/resource.h index 60d7bfb..1b02423 100644 Binary files a/waifu2x-caffe-gui/resource.h and b/waifu2x-caffe-gui/resource.h differ diff --git a/waifu2x-caffe/Source.cpp b/waifu2x-caffe/Source.cpp index 9e0142d..873c996 100644 --- a/waifu2x-caffe/Source.cpp +++ b/waifu2x-caffe/Source.cpp @@ -112,6 +112,14 @@ int main(int argc, char** argv) TCLAP::ValueArg cmdProcess("p", "process", "process mode", false, "gpu", &cmdProcessConstraint, cmd); + TCLAP::ValueArg cmdOutputQuality("q", "output_quality", + "output image quality", false, + -1, "int", cmd); + + TCLAP::ValueArg cmdOutputDepth("d", "output_depth", + "output image chaneel depth bit", false, + 8, "int", cmd); + TCLAP::ValueArg cmdCropSizeFile("c", "crop_size", "input image split size", false, 128, "int", cmd); @@ -272,8 +280,9 @@ int main(int argc, char** argv) Waifu2x::eWaifu2xError ret; Waifu2x w; - ret = w.init(argc, argv, cmdMode.getValue(), cmdNRLevel.getValue(), cmdScaleRatio.getValue(), cmdModelPath.getValue(), cmdProcess.getValue(), use_tta, - cmdCropSizeFile.getValue(), cmdBatchSizeFile.getValue()); + ret = w.init(argc, argv, cmdMode.getValue(), cmdNRLevel.getValue(), cmdScaleRatio.getValue(), cmdModelPath.getValue(), cmdProcess.getValue(), + cmdOutputQuality.getValue() == -1 ? boost::optional() : cmdOutputQuality.getValue(), cmdOutputDepth.getValue(), use_tta, cmdCropSizeFile.getValue(), + cmdBatchSizeFile.getValue()); switch (ret) { case Waifu2x::eWaifu2xError_InvalidParameter: