From 1ea5dda99ad28d900d6a11aa5fe0f16caefc65b5 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Sat, 7 Oct 2023 12:41:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sane/scanner.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sane/scanner.cpp b/sane/scanner.cpp index f964640..0be3f70 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -355,6 +355,8 @@ namespace callback int (*apply_given_config)(const char* content, SANE_Handle device, LPSANEAPI api) = NULL; // 閹煎瓨姊婚弫銈夊箰閸パ呮毎闁汇劌瀚伴崢銈囩磾椤曞棛绀塩ontent濞戞挻妞介崢銈囩磾椤旇姤娈堕柟璇″枟? char* (*get_config_content)(const char* dev_name, const char* name) = NULL; void (*twain_ui_free)(void* buf) = NULL; + void (*pump_ui_message)(void* reserved) = NULL; + int (*abnormal_image)(SANE_Image* img) = NULL; // return SANE_Abnormal_Image_Treat static int load_dll(const char* path_dll, HMODULE* dll) @@ -428,6 +430,8 @@ namespace callback GET_API(twain_ui_free); GET_API(apply_given_config); GET_API(get_config_content); + GET_API(pump_ui_message); + GET_API(abnormal_image); } } static void unint_ui(void) @@ -443,6 +447,8 @@ namespace callback twain_ui_free = NULL; apply_given_config = NULL; get_config_content = NULL; + pump_ui_message = NULL; + abnormal_image = NULL; if (hui) { FreeLibrary(hui); @@ -3529,6 +3535,19 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len) scanned_img* img = NULL; wchar_t name[40] = { 0 }; + if (simg->flag.statu && callback::abnormal_image) + { + 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); + + return 0; + } + } + swprintf_s(name, _countof(name) - 1, L"img_%05u.bmp", ++img_ind_); img = new scanned_img(handle_, simg->header, simg->data, simg->bytes, simg->flag.dpi, (tmp_path_ + name).c_str(), xfer_, &img_fmt_); if (img->bytes() /*>= simg->bytes*/)