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_;