From 0c8272bdb78b0ceabad590544ff408895035ca98 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Tue, 2 Aug 2022 11:14:58 +0800 Subject: [PATCH] =?UTF-8?q?600DPI=E7=BA=B8=E5=BC=A0=E5=8F=8A=E7=94=BB?= =?UTF-8?q?=E8=B4=A8=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hgdriver/hgdev/common_setting.cpp | 2 +- hgdriver/hgdev/hg_scanner.cpp | 76 ++++++++++++++++++++++++++++++- hgdriver/hgdev/hg_scanner.h | 4 +- 3 files changed, 79 insertions(+), 3 deletions(-) diff --git a/hgdriver/hgdev/common_setting.cpp b/hgdriver/hgdev/common_setting.cpp index 56cb2cf..518c218 100644 --- a/hgdriver/hgdev/common_setting.cpp +++ b/hgdriver/hgdev/common_setting.cpp @@ -419,7 +419,7 @@ std::string is_permaeate_string(int permaeate_lv) } std::string is_img_quality(int is_quakuty) { - return INVOKE_STR(g_img_quality, is_quakuty, 0); + return INVOKE_STR(g_img_quality, is_quakuty + 1/*start from -1*/, 0); } int double_paper_flag_from_option_value(std::string& opt_val, bool* exact) diff --git a/hgdriver/hgdev/hg_scanner.cpp b/hgdriver/hgdev/hg_scanner.cpp index 7f6418b..90012e7 100644 --- a/hgdriver/hgdev/hg_scanner.cpp +++ b/hgdriver/hgdev/hg_scanner.cpp @@ -592,6 +592,32 @@ bool hg_scanner::check_range(int setting_no, std::string& val) return false; } +bool hg_scanner::check_paper_and_resolution(int res, int paper) +{ + if (res == 600) + { + if (paper == PAPER_MAX_SIZE || + paper == PAPER_MAX_SIZE_CLIP || + paper == PAPER_TRIGEMINY) + { + VLOG_MINI_2(LOG_LEVEL_WARNING, "resolution '%d' is in-compatible with paper '%s'\n", res, paper_string(paper).c_str()); + return false; + } + } + + return true; +} +bool hg_scanner::check_resolution_and_quality(int res, const char* quality) +{ + if (res == 600 && strcmp(quality, OPTION_VALUE_HZ_SDYX) == 0) + { + VLOG_MINI_2(LOG_LEVEL_WARNING, "resolution '%d' is in-compatible with quality '%s'\n", res, quality); + + return false; + } + + return true; +} int hg_scanner::restore(int setting_no) { char key[20]; @@ -881,7 +907,8 @@ int hg_scanner::invoke_setting_xxx(int(hg_scanner::*func)(int, void*), void* dat { if (it->second == func) { - ret = (this->*it->second)(it->first, data); + ret = set_setting(it->first, data, 0); + // ret = (this->*it->second)(it->first, data); break; } ++it; @@ -1089,6 +1116,16 @@ int hg_scanner::setting_paper(int sn, void* data) old = image_prc_param_.bits.paper; val = image_prc_param_.bits.paper = match_best_paper(paper, NULL); + + // check 600 dpi ... + if (!check_paper_and_resolution(resolution_, val)) + { + image_prc_param_.bits.paper = old; + strcpy((char*)data, paper_string(old).c_str()); + + return SCANNER_ERR_DEVICE_NOT_SUPPORT; + } + sub = on_paper_changed(val); image_prc_param_.bits.paper = val; if (sub == SCANNER_ERR_NOT_EXACT) @@ -1165,6 +1202,35 @@ int hg_scanner::setting_resolution(int sn, void* data) resolution_ = *((int*)data); if (!check_range(sn, resolution_)) ret = SCANNER_ERR_NOT_EXACT; + + // check paper ... + if (!check_paper_and_resolution(resolution_, image_prc_param_.bits.paper)) + { + resolution_ = old; + *((int*)data) = old; + + return SCANNER_ERR_DEVICE_NOT_SUPPORT; + } + if (!check_resolution_and_quality(resolution_, is_img_quality(is_quality_).c_str())) + { + if (resolution_ == 600 && old < 300) + { + char buf[128] = { 0 }; + strcpy(buf, OPTION_VALUE_HZ_HZYX); + resolution_ = old; + invoke_setting_xxx(&hg_scanner::setting_img_quality, buf); + resolution_ = 600; + ret = SCANNER_ERR_CONFIGURATION_CHANGED; + } + else + { + resolution_ = old; + *((int*)data) = old; + + return SCANNER_ERR_DEVICE_NOT_SUPPORT; + } + } + sub = on_resolution_changed(resolution_); if (sub == SCANNER_ERR_NOT_EXACT) ret = sub; @@ -1591,10 +1657,18 @@ int hg_scanner::setting_img_quality(int sn, void *data) std::string str((char*)data); bool exact = check_range(sn, str); int ret = exact ? SCANNER_ERR_OK : SCANNER_ERR_NOT_EXACT; + int old = is_quality_; VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change quality from '%s' to '%s' = %s\n", is_img_quality(is_quality_).c_str() , (char*)data, hg_scanner_err_name(ret)); is_quality_ = match_best_img_quality(str,NULL); + if (!check_resolution_and_quality(resolution_, is_img_quality(is_quality_).c_str())) + { + is_quality_ = old; + strcpy((char*)data, is_img_quality(is_quality_).c_str()); + + return SCANNER_ERR_DEVICE_NOT_SUPPORT; + } return SCANNER_ERR_OK; } diff --git a/hgdriver/hgdev/hg_scanner.h b/hgdriver/hgdev/hg_scanner.h index 9777311..74938a3 100644 --- a/hgdriver/hgdev/hg_scanner.h +++ b/hgdriver/hgdev/hg_scanner.h @@ -55,6 +55,8 @@ class hg_scanner bool check_range(int setting_no, int& val); bool check_range(int setting_no, double& val); bool check_range(int setting_no, std::string& val); + bool check_paper_and_resolution(int res, int paper); + bool check_resolution_and_quality(int res, const char* quality); int restore(int setting_no); bool get_default_value(void* buf, json* jsn); bool is_to_file(void); @@ -209,7 +211,7 @@ protected: int fractate_level_; // 折角检测复杂度 int scan_count_; // 扫描张数,各实例化类在重载set_setting_value中,如果发现该设置项对该参数有影响时,需要对此值作更改 bool is_auto_matic_color;// 自动颜色识别 - int is_quality_; // 画质设置 + int is_quality_; // 画质设置 0 - 速度优先;1 - 画质优先 bool is_color_fill; // 色彩填充 bool is_multiout; // 多流输出