From eb59849a8f9c2b677052c1b76174a3c60f840e2b Mon Sep 17 00:00:00 2001 From: 13038267101 Date: Tue, 4 Apr 2023 17:37:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=AE=BE=E7=BD=AE=E5=9B=BE?= =?UTF-8?q?=E5=83=8F=E6=95=B0=E9=87=8F=E7=9A=84=E6=97=B6=E5=80=99=20?= =?UTF-8?q?=E6=98=AF=E6=8C=87=E5=9B=BE=E5=83=8F=E9=A1=B5=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- twain/twain/huagaods.cpp | 45 ++++++++++++++++++++++++++++++++++++++-- twain/twain/huagaods.hpp | 1 + 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/twain/twain/huagaods.cpp b/twain/twain/huagaods.cpp index 9e88274..232b016 100644 --- a/twain/twain/huagaods.cpp +++ b/twain/twain/huagaods.cpp @@ -853,7 +853,7 @@ static const SCANNERID scanner_guid = MAKE_SCANNER_ID(PRODUCT_PID, PRODUCT_VID); static std::once_flag oc; -huagao_ds::huagao_ds() : cur_head_(NULL), dpi_(200), xfer_ready_failed_(false), log_all_triple_(false), scanner_status_(SCANNER_STATUS_NOT_INIT) +huagao_ds::huagao_ds() : cur_head_(NULL), dpi_(200), xfer_ready_failed_(false), log_all_triple_(false), scanner_status_(SCANNER_STATUS_NOT_INIT),count_(-1) { //std::call_once(oc, [&]() { log4cplus::Initializer(); }); } @@ -1742,7 +1742,17 @@ void huagao_ds::init_support_caps(void) return badValue(); } int ret = SCANNER_ERR_OK; - int count = item; + int count = count_ = item; + + BYTE dup = 1; + std::vector all; + GET_SANE_OPT(bool, scanner_, ex_duplex, NULL, &all); + dup = all[sane_opts::RANGE_POS_CURRENT]; + + if (dup && count >= 2) + { + count /= 2; + } SET_SANE_OPT(ret, scanner_, scan_count, &count); return ret == SCANNER_ERR_OK ? success() : badValue(); } @@ -1750,6 +1760,16 @@ void huagao_ds::init_support_caps(void) Int16 tmp_count = 0; GET_SANE_OPT(int, scanner_, scan_count, NULL, &count); tmp_count = count[sane_opts::RANGE_POS_CURRENT]; + + BYTE dup = 1; + std::vector all; + GET_SANE_OPT(bool, scanner_, ex_duplex, NULL, &all); + dup = all[sane_opts::RANGE_POS_CURRENT]; + if (dup && tmp_count > 0 && tmp_count < 65535) + { + tmp_count *= 2; + } + return oneValGetSet(msg, data, tmp_count, -1); }; @@ -2234,14 +2254,35 @@ void huagao_ds::init_support_caps(void) log_attr_access((int)CapType::DuplexEnabled, (int)msg); if (Msg::Set == msg) { bool mech = data.currentItem(); + int ret = SCANNER_ERR_OK; SET_SANE_OPT(ret, scanner_, ex_duplex, &mech); + + int count = count_; + if (mech && count_ >= 2) + { + count /= 2; + SET_SANE_OPT(ret, scanner_, scan_count, &count); + } + else if (!mech && count_ >= 2) + SET_SANE_OPT(ret, scanner_, scan_count, &count); + return ret == SCANNER_ERR_OK ? success() : badValue(); } BYTE dup = 1; std::vector all; GET_SANE_OPT(bool, scanner_, ex_duplex, NULL, &all); dup = all[sane_opts::RANGE_POS_CURRENT]; + int ret = SCANNER_ERR_OK; + int count = count_; + if (dup && count_ >= 2) + { + count /= 2; + SET_SANE_OPT(ret, scanner_, scan_count, &count); + } + else if (!dup && count_ >= 2) + SET_SANE_OPT(ret, scanner_, scan_count, &count) + return CapSupGetAllReset(msg, data, dup, Bool(true)); }; diff --git a/twain/twain/huagaods.hpp b/twain/twain/huagaods.hpp index f1b9b98..546775e 100644 --- a/twain/twain/huagaods.hpp +++ b/twain/twain/huagaods.hpp @@ -55,6 +55,7 @@ class huagao_ds : public Twpp::SourceFromThis { bool log_all_triple_; bool app_trigger_event_; + int count_; static std::string get_hidedlg_path(void); static void showmsg(const char* msg, int err); static int __stdcall on_scanner_event(int ev, void* param);