diff --git a/twain/twain/huagaods.cpp b/twain/twain/huagaods.cpp index f73cec7..9c3584b 100644 --- a/twain/twain/huagaods.cpp +++ b/twain/twain/huagaods.cpp @@ -1028,6 +1028,22 @@ Result huagao_ds::identityOpenDs(const Identity& id) } load_sane_util::to_log(1, L"Double check mode = %d\r\n", double_check_mode_); + int nobd = get_config_number(L"twain-app", L"no-bitdepth", 0, -1); + if (nobd == -1) + { + wchar_t pe[MAX_PATH] = { 0 }, * name = NULL; + GetModuleFileNameW(NULL, pe, _countof(pe) - 1); + name = wcsrchr(pe, L'\\'); + if (name++ == NULL) + name = pe; + if (wcsicmp(name, L"\u519B\u961F\u626B\u63CF2.0.exe") == 0) // 军队扫描2.0.exe + nobd = 1; + else + nobd = 0; + } + no_bitdepth_ = nobd == 1; + load_sane_util::to_log(1, L"BitDepth protocol enabled = %d\r\n", nobd); + m_compression = Compression::None; init_support_caps(); m_fileXfer.setFormat(ImageFileFormat::Bmp); @@ -1938,6 +1954,8 @@ void huagao_ds::init_support_caps(void) int val = 0; GET_SANE_OPT_EX(int, scanner_, ex_color_mode, NULL, &all); if (Msg::Set == msg || Msg::Reset == msg) { + if (no_bitdepth_) + return success(); int ret = SCANNER_ERR_INVALID_PARAMETER; val = all[sane_opts::RANGE_POS_DEFAULT]; auto mech = data.currentItem(); diff --git a/twain/twain/huagaods.hpp b/twain/twain/huagaods.hpp index 6b54bcc..3bae343 100644 --- a/twain/twain/huagaods.hpp +++ b/twain/twain/huagaods.hpp @@ -56,6 +56,7 @@ class huagao_ds : public Twpp::SourceFromThis { bool app_trigger_event_; bool bUiOnly_; bool show_setting_; + bool no_bitdepth_ = false; // ɨ2.0.exe set this but sychronize to APP int count_; volatile bool notfify_close_ = false; @@ -79,7 +80,7 @@ class huagao_ds : public Twpp::SourceFromThis { void init_support_caps_ex(void); std::wstring get_config_file(void); std::wstring get_config_value(const wchar_t* sec, const wchar_t* key); - DWORD get_config_number(const wchar_t* sec, const wchar_t* key); + DWORD get_config_number(const wchar_t* sec, const wchar_t* key, DWORD def = 0, DWORD empty = 0); int handle_scanner_event(int ev, bool from_event_proc = true); int get_scanned_image_count(DWORD timeout); void trigger_ProcessEvent(Twpp::DataGroup dg, Twpp::Dat dat, Twpp::Msg msg);