From ecb8cce5b83bd06b6ea89a81691d194d57a611fc Mon Sep 17 00:00:00 2001 From: "mo1027728827@qq.com" Date: Thu, 2 Jun 2022 11:47:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=A4=9A=E7=95=99=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E5=AF=BC=E8=87=B4=E9=A2=9C=E8=89=B2=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=87=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hgdriver/hgdev/common_setting.cpp | 3 +-- hgdriver/hgdev/common_setting.h | 1 - hgdriver/hgdev/hg_scanner.cpp | 36 ++++++++++++++++++++++--------- hgdriver/hgdev/hg_scanner.h | 1 + hgdriver/hgdev/hg_scanner_200.cpp | 8 +++++-- hgdriver/hgdev/hg_scanner_239.cpp | 12 +++++++---- hgdriver/hgdev/hg_scanner_300.cpp | 8 +++++-- hgdriver/hgdev/hg_scanner_400.cpp | 8 +++++-- 8 files changed, 54 insertions(+), 23 deletions(-) diff --git a/hgdriver/hgdev/common_setting.cpp b/hgdriver/hgdev/common_setting.cpp index 815461c..470564c 100644 --- a/hgdriver/hgdev/common_setting.cpp +++ b/hgdriver/hgdev/common_setting.cpp @@ -16,7 +16,6 @@ g_color_mode[] = }, g_multi_out[] = { - {OPTION_VALUE_DLSC_W, MULTI_OUT_NOT}, {OPTION_VALUE_DLSC_CS_HD_HB, MULTI_OUT_ALL}, {OPTION_VALUE_DLSC_CS_HD, MULTI_COLOR_AND_GRAY}, {OPTION_VALUE_DLSC_CS_HB, MULTI_COLOR_AND_BW}, @@ -182,7 +181,7 @@ int match_best_multi_out(std::string& val, bool* exact) bool yes = true; int ind = INVOKE_MATCH(g_multi_out, val, yes); - SET_DEFAULT_ON_FAIL(g_multi_out, ind, val, MULTI_OUT_NOT); + SET_DEFAULT_ON_FAIL(g_multi_out, ind, val, MULTI_OUT_ALL); if (exact) *exact = yes; diff --git a/hgdriver/hgdev/common_setting.h b/hgdriver/hgdev/common_setting.h index 8286c80..1ce8a62 100644 --- a/hgdriver/hgdev/common_setting.h +++ b/hgdriver/hgdev/common_setting.h @@ -143,7 +143,6 @@ std::string color_mode_string(int clr_mode); //#define HUAGAO_SETTING_STR_MULTI_GRAY_ADN_BW "灰度+黑白" enum { - MULTI_OUT_NOT = -1, MULTI_OUT_ALL = 0, MULTI_COLOR_AND_GRAY, MULTI_COLOR_AND_BW, diff --git a/hgdriver/hgdev/hg_scanner.cpp b/hgdriver/hgdev/hg_scanner.cpp index 93a9753..e4fe0cd 100644 --- a/hgdriver/hgdev/hg_scanner.cpp +++ b/hgdriver/hgdev/hg_scanner.cpp @@ -91,7 +91,7 @@ hg_scanner::hg_scanner(ScannerSerial serial , bright_(128), contrast_(4), gamma_(1.0f), threshold_(40), anti_noise_(8), margin_(5) , fractate_level_(50), ui_ev_cb_(ui_default_callback), scan_life_(NULL) , notify_setting_result_(false), user_cancel_(false), cb_mem_(true), test_1_paper_(false) - , setting_count_(0),img_type_(""), online_(false),is_quality_(-1),is_color_fill(false),is_multiout(false) + , setting_count_(0),img_type_(""), online_(false),is_quality_(-1),is_color_fill(false),is_multiout(false),save_multiout(OPTION_VALUE_DLSC_CS_HD_HB) { final_path_ = hg_log::ini_get("paths", "final_img"); if(final_path_.empty()) @@ -934,29 +934,33 @@ int hg_scanner::setting_color_mode(void* data) int hg_scanner::setting_multi_out(void *data) { is_multiout = *((bool*)data); + int val = image_prc_param_.bits.color_mode; + + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "image_prc_param_.bits.multi_out %d ", image_prc_param_.bits.multi_out); + + if (!is_multiout) + on_color_mode_changed(val); + return SCANNER_ERR_OK; } int hg_scanner::setting_multi_out_type(void *data) { int ret = SCANNER_ERR_OK; - if(image_prc_param_.bits.color_mode != 2) - { - ret = SCANNER_ERR_INVALID_PARAMETER; - return ret; - } - std::string str((char*)data); + std::string str((char*)data); + bool exact = check_range(setting_map_[HG_BASE_SETTING_INDEX_MULTI_OUT], str); int color; image_prc_param_.bits.multi_out = match_best_multi_out(str,NULL); + + save_multiout = str; VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "set multi_out type from %s to %s = %s\n", multi_out_string(image_prc_param_.bits.multi_out).c_str(), (char*)data, hg_scanner_err_name(ret)); if (image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW) color = COLOR_MODE_256_GRAY; - else color = COLOR_MODE_24_BITS; - + on_color_mode_changed(color); return ret; } @@ -1797,7 +1801,19 @@ int hg_scanner::save_final_image(hg_imgproc::LPIMGHEAD head, void* buf) std::string bw(""); final_img_index_++; - if (image_prc_param_.bits.color_mode == COLOR_MODE_BLACK_WHITE) + bool is_1bit = false; + if (image_prc_param_.bits.multi_out == MULTI_OUT_ALL && is_multiout) + { + if(final_img_index_%3 == 0) + is_1bit = true; + } + else if ((image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_BW) && is_multiout) + { + if(final_img_index_%2 == 0) + is_1bit = true; + } + + if (img_conf_.pixtype == 0 || (is_1bit && is_multiout)) { int old = head->line_bytes; bw = bmp_821((unsigned char*)buf, head->width, head->height, &head->line_bytes, async_io_); diff --git a/hgdriver/hgdev/hg_scanner.h b/hgdriver/hgdev/hg_scanner.h index 7dfc6f0..a92a2e2 100644 --- a/hgdriver/hgdev/hg_scanner.h +++ b/hgdriver/hgdev/hg_scanner.h @@ -100,6 +100,7 @@ class hg_scanner { bool notify_setting_result_; std::string name_; + std::string save_multiout; //保存多留输出类型 sane_callback ui_ev_cb_; do_when_born_and_dead* scan_life_; diff --git a/hgdriver/hgdev/hg_scanner_200.cpp b/hgdriver/hgdev/hg_scanner_200.cpp index 40e285e..6ee8cfa 100644 --- a/hgdriver/hgdev/hg_scanner_200.cpp +++ b/hgdriver/hgdev/hg_scanner_200.cpp @@ -771,7 +771,7 @@ void hg_scanner_200::image_process(std::shared_ptr& buffer) //HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"图像拆分开启\r\n"); } - if (!image_prc_param_.bits.split || !image_prc_param_.bits.rid_red || !image_prc_param_.bits.multi_out) + if (!image_prc_param_.bits.split || !image_prc_param_.bits.rid_red || !is_multiout) { if(img_conf_.automaticcolor) { @@ -1137,10 +1137,14 @@ else ic.multiOutput = MultiOutput::Unused; ic.fadeback = false; } - if (image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW && (image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS)) + if (image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW && is_multiout) { ic.pixtype = 1; } + else if ((image_prc_param_.bits.multi_out == MULTI_OUT_ALL ||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_GRAY||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_BW) && is_multiout) + { + ic.pixtype = 2; + } img_conf_ = ic; agreement(); diff --git a/hgdriver/hgdev/hg_scanner_239.cpp b/hgdriver/hgdev/hg_scanner_239.cpp index 27903e7..cc69e9a 100644 --- a/hgdriver/hgdev/hg_scanner_239.cpp +++ b/hgdriver/hgdev/hg_scanner_239.cpp @@ -674,7 +674,7 @@ void hg_scanner_239::image_process(std::shared_ptr& buff) ,img_conf_.is_duplex); } - if (!image_prc_param_.bits.split || !image_prc_param_.bits.rid_red || !image_prc_param_.bits.multi_out) + if (!image_prc_param_.bits.split || !image_prc_param_.bits.rid_red || !is_multiout) { if(img_conf_.automaticcolor) { @@ -891,10 +891,16 @@ else ic.multiOutput = MultiOutput::Unused; ic.fadeback = false; } - if (image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW && (image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS)) + //多留输出的处理 + if (image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW && is_multiout) { ic.pixtype = 1; } + else if ((image_prc_param_.bits.multi_out == MULTI_OUT_ALL ||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_GRAY||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_BW) && is_multiout) + { + ic.pixtype = 2; + } + { std::lock_guard lock(io_lock_); @@ -1173,7 +1179,6 @@ int hg_scanner_239::on_color_mode_changed(int& color_mode) { dev_conf_.g200params.color = 1; } - HGSCANCONF d = dev_conf_; if (image_prc_param_.bits.rid_color != RID_COLOR_NONE @@ -1198,7 +1203,6 @@ int hg_scanner_239::on_color_mode_changed(int& color_mode) } if(color_mode == -1) ret = writedown_device_configuration(&d); - return ret; } int hg_scanner_239::on_paper_changed(int& paper) diff --git a/hgdriver/hgdev/hg_scanner_300.cpp b/hgdriver/hgdev/hg_scanner_300.cpp index da10384..2477d5b 100644 --- a/hgdriver/hgdev/hg_scanner_300.cpp +++ b/hgdriver/hgdev/hg_scanner_300.cpp @@ -736,7 +736,7 @@ void hg_scanner_300::image_process(std::shared_ptr& buffer) //HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"图像拆分开启\r\n"); } - if (!image_prc_param_.bits.split || !image_prc_param_.bits.rid_red || !image_prc_param_.bits.multi_out) + if (!image_prc_param_.bits.split || !image_prc_param_.bits.rid_red || !is_multiout) { if(img_conf_.automaticcolor) { @@ -1055,10 +1055,14 @@ else ic.multiOutput = MultiOutput::Unused; ic.fadeback = false; } - if (image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW && (image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS)) + if (image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW && is_multiout) { ic.pixtype = 1; } + else if ((image_prc_param_.bits.multi_out == MULTI_OUT_ALL ||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_GRAY||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_BW) && is_multiout) + { + ic.pixtype = 2; + } img_conf_ = ic; diff --git a/hgdriver/hgdev/hg_scanner_400.cpp b/hgdriver/hgdev/hg_scanner_400.cpp index 043e848..3238a34 100644 --- a/hgdriver/hgdev/hg_scanner_400.cpp +++ b/hgdriver/hgdev/hg_scanner_400.cpp @@ -733,7 +733,7 @@ void hg_scanner_400::image_process(std::shared_ptr& buffer) //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "图像拆分开启:%s\n",hg_scanner_err_name(ret)); } - if (!image_prc_param_.bits.split || !image_prc_param_.bits.rid_red || !image_prc_param_.bits.multi_out) + if (!image_prc_param_.bits.split || !image_prc_param_.bits.rid_red || !is_multiout) { if(img_conf_.automaticcolor) { @@ -1071,10 +1071,14 @@ void hg_scanner_400::writedown_image_configuration(void) ic.multiOutput = MultiOutput::Unused; ic.fadeback = false; } - if (image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW && (image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS)) + if (image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW && is_multiout) { ic.pixtype = 1; } + else if ((image_prc_param_.bits.multi_out == MULTI_OUT_ALL ||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_GRAY||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_BW) && is_multiout) + { + ic.pixtype = 2; + } img_conf_ = ic; int ret = agreement((TwSS)img_conf_.papertype,img_conf_.paperAlign);