From 80ffb60c341a2d01f975ec65bc2a4b0d5e220b06 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Tue, 17 Oct 2023 17:52:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=8C=E5=BC=A0=E6=8F=90=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E5=8F=AA=E5=BC=B9=E7=AC=AC=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sane/scanner.cpp | 19 ++++++++++++++----- sane/scanner.h | 8 ++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sane/scanner.cpp b/sane/scanner.cpp index b2d5711..64e8a8f 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -1588,6 +1588,7 @@ int scanner::set_is_multiout(bool enable) int scanner::thread_start(void) { scan_over_ = false; + double_handle_ = DOUBLE_FEED_NEED_UI; int ret = hg_sane_middleware::instance()->start(handle_, NULL); @@ -3576,15 +3577,23 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len) if (simg->flag.statu && callback::abnormal_image) { - if (callback::abnormal_image(simg) == SANE_Abnormal_Image_Discard) + if (double_handle_ == DOUBLE_FEED_NEED_UI) { - wchar_t info[128] = { 0 }; + if (callback::abnormal_image(simg) == SANE_Abnormal_Image_Discard) + { + wchar_t info[128] = { 0 }; - swprintf_s(info, _countof(info) - 1, L"Discard image %d for the status is: %d\r\n", simg->src_id, simg->flag.statu); - log_info(info, LOG_LEVEL_DEBUG_INFO); + swprintf_s(info, _countof(info) - 1, L"Discard image %d for the status is: %d\r\n", simg->src_id, simg->flag.statu); + log_info(info, LOG_LEVEL_DEBUG_INFO); - return 0; + double_handle_ = DOUBLE_FEED_DISCARD; + } + else + double_handle_ = DOUBLE_FEED_KEEP; } + + if (double_handle_ == DOUBLE_FEED_DISCARD) + return 0; } swprintf_s(name, _countof(name) - 1, L"img_%05u.bmp", ++img_ind_); diff --git a/sane/scanner.h b/sane/scanner.h index 203f239..1cf6b5f 100644 --- a/sane/scanner.h +++ b/sane/scanner.h @@ -40,6 +40,13 @@ class scanner : public ISaneInvoker, virtual public refer int bytes; }SIMPLEOPT; + enum + { + DOUBLE_FEED_NEED_UI = 0, // 需要用户抉择 + DOUBLE_FEED_KEEP, // 用户选择保存 + DOUBLE_FEED_DISCARD, // 用户选择丢弃 + }; + SANE_Handle handle_; SCANNERID id_; int err_; @@ -47,6 +54,7 @@ class scanner : public ISaneInvoker, virtual public refer int prev_start_result_; int dpi_; int fetch_imgs_ = 0; // count for images has fetched by APP + int double_handle_ = DOUBLE_FEED_NEED_UI; // bool is_bIndicator; bool is_show_setting_; unsigned int img_ind_;