diff --git a/code/base/test_base.cpp b/code/base/test_base.cpp index c007464..050d3d3 100644 --- a/code/base/test_base.cpp +++ b/code/base/test_base.cpp @@ -872,27 +872,46 @@ public: /* 扫描图像质量确认 */ int test_image_quality(void *data) { + if (!data) + { + return SCANNER_ERR_DATA_DAMAGED; + } + unsigned int len = 0; + int ret = SCANNER_ERR_OK; + + ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, data, &len); + if (ret != SCANNER_ERR_OK) + { + return -1; + } return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL); } /* 获取自动计算畸变值 */ int test_get_auto_distortion(void *data) { + if (!data ) + { + return SCANNER_ERR_DATA_DAMAGED; + } int ret = SCANNER_ERR_OK, val = 0; SANE_Bool type = true; unsigned int len = sizeof(SANE_Bool), llen = sizeof(int); + ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, &data, &len); + ret = helper_->io_control(IO_CTRL_CODE_SET_DISTORTION_IMAGE, &type, &len); if (ret != SCANNER_ERR_OK) { return ret; } int cnt = 0; + SANE_DISTORTION_VAL dis; while (ret == SCANNER_ERR_OK) { if (is_distortion_get_image ) { - ret = helper_->io_control(IO_CTRL_CODE_GET_DISTORTION_CHECK_VAL, &val, &llen); + ret = helper_->io_control(IO_CTRL_CODE_GET_DISTORTION_CHECK_VAL, &dis, &llen); break; } else if (cnt == 10) @@ -903,10 +922,9 @@ public: Sleep(1000); cnt++; } - if (val > 0) + if (dis.h > 0) { - float f = *(float*)&val; - helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_DISTORTION_VAL, (void *)&f, true); + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_DISTORTION_VAL, (void *)&dis, true); } else {