From ccdd41e0deba4d5c070e352567f33393540fdc67 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Tue, 25 Jul 2023 08:54:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86APP=E8=AE=BE=E7=BD=AEBitDepth?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E6=97=B6=E6=9C=AA=E5=90=8C=E6=AD=A5=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E6=AD=A4=E7=A7=8D=E5=BA=94=E7=94=A8=E4=B8=8B=E5=B1=8F?= =?UTF-8?q?=E8=94=BD=E8=AF=A5=E5=8D=8F=E8=AE=AE=E3=80=82twain-app/no-bitde?= =?UTF-8?q?pth=E9=85=8D=E7=BD=AE=E5=8F=AF=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- twain/twain/huagaods.cpp | 18 ++++++++++++++++++ twain/twain/huagaods.hpp | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) 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);