diff --git a/code/base/test_base.cpp b/code/base/test_base.cpp index a053771..f1c7bf0 100644 --- a/code/base/test_base.cpp +++ b/code/base/test_base.cpp @@ -33,6 +33,9 @@ static struct Test_Map {HGPDTTOOLDB_NAME_PLACE_CORRECTION_PAPER ,HGPDTTOOLDB_TITLE_PLACE_CORRECTION_PAPER}, {HGPDTTOOLDB_NAME_AUTO_FLAT_FIELD ,HGPDTTOOLDB_TITLE_AUTO_FLAT_FIELD}, {HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY}, +{HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY}, +{HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY_PHOTO ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_PHOTO }, +{HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY_PHOTO ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_PHOTO }, {HGPDTTOOLDB_NAME_COLORCARD_IMAGEING_QUALITY ,HGPDTTOOLDB_TITLE_COLORCARD_IMAGEING_QUALITY}, {HGPDTTOOLDB_NAME_COLORCARD_BIAS_IMAGEING_QUALITY ,HGPDTTOOLDB_TITLE_COLORCARD_BIAS_IMAGEING_QUALITY}, {HGPDTTOOLDB_NAME_CLARITY_QUALITY ,HGPDTTOOLDB_TITLE_CLARITY_QUALITY}, @@ -422,8 +425,10 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int break; } } - else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY) == 0 - || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY) == 0) + else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY) == 0 || + wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY) == 0 || + wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY_PHOTO) == 0 || + wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY_PHOTO) == 0) { if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0) { @@ -593,6 +598,8 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int ret = h->io_control(IO_CTRL_CODE_SET_MORR, (void*)&isMorr, &l); bool isLongText = false; ret = h->io_control(IO_CTRL_CODE_SET_LONGTEXT, (void*)&isLongText, &l); + bool photoMode = false; + ret = h->io_control(IO_CTRL_CODE_SET_PICTURE_PHOTO_MODE, &photoMode, &l); } break; case SANE_EVENT_ERROR: @@ -612,6 +619,9 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int { if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY) == 0 + || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY) == 0 + || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY_PHOTO) == 0 + || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY_PHOTO) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SCAN_WORKING_STATUS) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SKEW_DETECTION) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY) == 0 @@ -706,6 +716,9 @@ void test::init_test_map_() test_map_[HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY] = &test::test_image_color_quality; test_map_[HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY] = &test::test_image_gray_quality; + test_map_[HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY_PHOTO] = &test::test_image_color_quality_photo; + test_map_[HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY_PHOTO] = &test::test_image_gray_quality_photo; + test_map_[HGPDTTOOLDB_NAME_GET_DISTORTION_VAL] = &test::test_get_auto_distortion; test_map_[HGPDTTOOLDB_NAME_SET_DISTORTION_VAL] = &test::test_set_auto_distortion; test_map_[HGPDTTOOLDB_NAME_CONFIRM_DISTORTION_VAL] = &test::test_confirm_auto_distortion; @@ -1311,6 +1324,82 @@ int test::test_image_gray_quality(void* data) helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &colorlen); return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL); } +int test::test_image_color_quality_photo(void* data) +{ + if (!data) + { + return SCANNER_ERR_DATA_DAMAGED; + } + wchar_t* p = (wchar_t*)data; + std::string str; + int ret = SCANNER_ERR_OK, + dpi = 0; + unsigned int len = sizeof(int); + size_t strl = 0; + ret = wchar_to_char(str, p, &strl); + if (ret == ERROR_INSUFFICIENT_BUFFER) + { + str.resize(strl); + ret = wchar_to_char(str, p, &strl); + if (str.empty()) + { + return SCANNER_ERR_DATA_DAMAGED; + } + dpi = atoi(str.c_str()); + } + if (dpi > 0) + { + ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, &dpi, &len); + bool photoMode = true; + ret = helper_->io_control(IO_CTRL_CODE_SET_PICTURE_PHOTO_MODE, &photoMode, &len); + } + if (ret != SCANNER_ERR_OK) + { + return -1; + } + const char* color = OPTION_VALUE_YSMS_24WCS; + unsigned int colorlen = strlen(color); + helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &colorlen); + return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL); +} +int test::test_image_gray_quality_photo(void* data) +{ + if (!data) + { + return SCANNER_ERR_DATA_DAMAGED; + } + wchar_t* p = (wchar_t*)data; + std::string str; + int ret = SCANNER_ERR_OK, + dpi = 0; + unsigned int len = sizeof(int); + size_t strl = 0; + ret = wchar_to_char(str, p, &strl); + if (ret == ERROR_INSUFFICIENT_BUFFER) + { + str.resize(strl); + ret = wchar_to_char(str, p, &strl); + if (str.empty()) + { + return SCANNER_ERR_DATA_DAMAGED; + } + dpi = atoi(str.c_str()); + } + if (dpi > 0) + { + ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, &dpi, &len); + bool photoMode = true; + ret = helper_->io_control(IO_CTRL_CODE_SET_PICTURE_PHOTO_MODE, &photoMode, &len); + } + if (ret != SCANNER_ERR_OK) + { + return -1; + } + const char* color = OPTION_VALUE_YSMS_256JHD; + unsigned int colorlen = strlen(color); + helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &colorlen); + return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL); +} /* 获取自动计算畸变值 */ int test::test_get_auto_distortion(void* data) { diff --git a/code/base/test_base.h b/code/base/test_base.h index dbf189d..9f095a9 100644 --- a/code/base/test_base.h +++ b/code/base/test_base.h @@ -58,6 +58,8 @@ #define HGPDTTOOLDB_TITLE_REBOOT_DEVICE L"重启设备" /* 扫描图像质量确认 */ #define HGPDTTOOLDB_TITLE_IMAGE_QUALITY L"扫描图像质量确认" +/* 照片模式图像质量确认 */ +#define HGPDTTOOLDB_TITLE_IMAGE_QUALITY_PHOTO L"照片模式图像质量确认" /* 色卡纸成像质量评估 */ #define HGPDTTOOLDB_TITLE_COLORCARD_IMAGEING_QUALITY L"色卡纸成像质量评估" /* 色卡纸偏色成像质量评估 */ @@ -199,6 +201,10 @@ #define HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY L"IMAGE_COLOR_QUALITY" /* 扫描图像灰度质量确认 */ #define HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY L"IMAGE_GRAY_QUALITY" +/* 照片模式图像彩色质量确认 */ +#define HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY_PHOTO L"IMAGE_COLOR_QUALITY_PHOTO" +/* 照片模式图像灰度质量确认 */ +#define HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY_PHOTO L"IMAGE_GRAY_QUALITY_PHOTO" /* 色卡纸成像质量评估 */ #define HGPDTTOOLDB_NAME_COLORCARD_IMAGEING_QUALITY L"COLORCARD_IMAGEING_QUALITY" /* 色卡纸偏色成像质量评估 */ @@ -457,6 +463,10 @@ private: int test_image_color_quality(void* data); /* 扫描图像灰度质量确认 */ int test_image_gray_quality(void* data); + /* 照片模式图像彩色质量确认 */ + int test_image_color_quality_photo(void* data); + /* 照片模式图像灰度质量确认 */ + int test_image_gray_quality_photo(void* data); /* 获取自动计算畸变值 */ int test_get_auto_distortion(void* data); int test_set_auto_distortion(void* data);