根据产品名称,更改对应的标识符

This commit is contained in:
gb 2022-05-17 15:57:43 +08:00
parent 3d2f54f113
commit 6e2d9cb992
5 changed files with 130 additions and 115 deletions

View File

@ -189,7 +189,7 @@ std::string usb_device::parent_hub_path_name(int vid, int pid, int *addr)
} }
if (addr) if (addr)
*addr = port; *addr = port;
HG_VLOG_MINI_4(HG_LOG_LEVEL_DEBUG_INFO, "Parent hub for %04X:%04X is: %s (+%d)\r\n", vid, pid, ret.c_str(), port); HG_VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "Parent hub for %04X:%04X is: %s (+%d)\r\n", vid, pid, ret.c_str(), port);
return ret; return ret;
} }

View File

@ -329,7 +329,7 @@ int sane_invoker::handle_sane_event(SANE_Handle hdev, int code, void* data, unsi
MessageBoxW(NULL, msg.c_str(), L"Error", MB_OK); MessageBoxW(NULL, msg.c_str(), L"Error", MB_OK);
} }
return HG_ERR_OK; return SCANNER_ERR_OK;
} }
void sane_invoker::get_online_devices(std::vector<SANEDEV>& devs) void sane_invoker::get_online_devices(std::vector<SANEDEV>& devs)
{ {
@ -365,7 +365,7 @@ scanner* sane_invoker::open(const char* name, int* err)
if (it == devices_.end()) if (it == devices_.end())
{ {
if (err) if (err)
*err = HG_ERR_DEVICE_NOT_FOUND; *err = SCANNER_ERR_DEVICE_NOT_FOUND;
return NULL; return NULL;
} }
@ -498,7 +498,7 @@ std::wstring sane_invoker::ansi2u(const char* ansi)
void sane_invoker::log_debug_info(const char* info) void sane_invoker::log_debug_info(const char* info)
{ {
if (sane_invoker::inst_) if (sane_invoker::inst_)
sane_invoker::inst_->log_(HG_LOG_LEVEL_DEBUG_INFO, info); sane_invoker::inst_->log_(LOG_LEVEL_DEBUG_INFO, info);
else else
OutputDebugStringA(info); OutputDebugStringA(info);
} }
@ -520,7 +520,7 @@ void __cdecl sane_invoker::log_debug_info(int bytes, const char* fmt, ...)
SANE_Status sane_invoker::invoke_sane_init(SANE_Int* version_code, SANE_Auth_Callback authorize) SANE_Status sane_invoker::invoke_sane_init(SANE_Int* version_code, SANE_Auth_Callback authorize)
{ {
if (!sane_invoker::inst_) if (!sane_invoker::inst_)
return (SANE_Status)HG_ERR_NOT_OPEN; return (SANE_Status)SCANNER_ERR_NOT_OPEN;
if (!sane_invoker::inst_->real_sane_init_) if (!sane_invoker::inst_->real_sane_init_)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
@ -535,7 +535,7 @@ void sane_invoker::invoke_sane_exit(void)
SANE_Status sane_invoker::invoke_sane_get_devices(const SANE_Device*** device_list, SANE_Bool local_only) SANE_Status sane_invoker::invoke_sane_get_devices(const SANE_Device*** device_list, SANE_Bool local_only)
{ {
if (!sane_invoker::inst_) if (!sane_invoker::inst_)
return (SANE_Status)HG_ERR_NOT_OPEN; return (SANE_Status)SCANNER_ERR_NOT_OPEN;
if (!sane_invoker::inst_->real_sane_get_devices_) if (!sane_invoker::inst_->real_sane_get_devices_)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
@ -545,7 +545,7 @@ SANE_Status sane_invoker::invoke_sane_get_devices(const SANE_Device*** device_li
SANE_Status sane_invoker::invoke_sane_open(SANE_String_Const devicename, SANE_Handle* handle) SANE_Status sane_invoker::invoke_sane_open(SANE_String_Const devicename, SANE_Handle* handle)
{ {
if (!sane_invoker::inst_) if (!sane_invoker::inst_)
return (SANE_Status)HG_ERR_NOT_OPEN; return (SANE_Status)SCANNER_ERR_NOT_OPEN;
if (!sane_invoker::inst_->real_sane_open_) if (!sane_invoker::inst_->real_sane_open_)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
@ -570,7 +570,7 @@ const SANE_Option_Descriptor* sane_invoker::invoke_sane_get_option_descriptor(SA
SANE_Status sane_invoker::invoke_sane_control_option(SANE_Handle handle, SANE_Int option, SANE_Action action, void* value, SANE_Int* info) SANE_Status sane_invoker::invoke_sane_control_option(SANE_Handle handle, SANE_Int option, SANE_Action action, void* value, SANE_Int* info)
{ {
if (!sane_invoker::inst_) if (!sane_invoker::inst_)
return (SANE_Status)HG_ERR_NOT_OPEN; return (SANE_Status)SCANNER_ERR_NOT_OPEN;
if (!sane_invoker::inst_->real_sane_control_option_) if (!sane_invoker::inst_->real_sane_control_option_)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
@ -580,7 +580,7 @@ SANE_Status sane_invoker::invoke_sane_control_option(SANE_Handle handle, SANE_In
SANE_Status sane_invoker::invoke_sane_get_parameters(SANE_Handle handle, SANE_Parameters* params) SANE_Status sane_invoker::invoke_sane_get_parameters(SANE_Handle handle, SANE_Parameters* params)
{ {
if (!sane_invoker::inst_) if (!sane_invoker::inst_)
return (SANE_Status)HG_ERR_NOT_OPEN; return (SANE_Status)SCANNER_ERR_NOT_OPEN;
if (!sane_invoker::inst_->real_sane_get_parameters_) if (!sane_invoker::inst_->real_sane_get_parameters_)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
@ -590,7 +590,7 @@ SANE_Status sane_invoker::invoke_sane_get_parameters(SANE_Handle handle, SANE_Pa
SANE_Status sane_invoker::invoke_sane_start(SANE_Handle handle) SANE_Status sane_invoker::invoke_sane_start(SANE_Handle handle)
{ {
if (!sane_invoker::inst_) if (!sane_invoker::inst_)
return (SANE_Status)HG_ERR_NOT_OPEN; return (SANE_Status)SCANNER_ERR_NOT_OPEN;
if (!sane_invoker::inst_->real_sane_start_) if (!sane_invoker::inst_->real_sane_start_)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
@ -600,7 +600,7 @@ SANE_Status sane_invoker::invoke_sane_start(SANE_Handle handle)
SANE_Status sane_invoker::invoke_sane_read(SANE_Handle handle, SANE_Byte* data, SANE_Int max_length, SANE_Int* length) SANE_Status sane_invoker::invoke_sane_read(SANE_Handle handle, SANE_Byte* data, SANE_Int max_length, SANE_Int* length)
{ {
if (!sane_invoker::inst_) if (!sane_invoker::inst_)
return (SANE_Status)HG_ERR_NOT_OPEN; return (SANE_Status)SCANNER_ERR_NOT_OPEN;
if (!sane_invoker::inst_->real_sane_read_) if (!sane_invoker::inst_->real_sane_read_)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
@ -615,7 +615,7 @@ void sane_invoker::invoke_sane_cancel(SANE_Handle handle)
SANE_Status sane_invoker::invoke_sane_set_io_mode(SANE_Handle handle, SANE_Bool non_blocking) SANE_Status sane_invoker::invoke_sane_set_io_mode(SANE_Handle handle, SANE_Bool non_blocking)
{ {
if (!sane_invoker::inst_) if (!sane_invoker::inst_)
return (SANE_Status)HG_ERR_NOT_OPEN; return (SANE_Status)SCANNER_ERR_NOT_OPEN;
if (!sane_invoker::inst_->real_sane_set_io_mode_) if (!sane_invoker::inst_->real_sane_set_io_mode_)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
@ -625,7 +625,7 @@ SANE_Status sane_invoker::invoke_sane_set_io_mode(SANE_Handle handle, SANE_Bool
SANE_Status sane_invoker::invoke_sane_get_select_fd(SANE_Handle handle, SANE_Int* fd) SANE_Status sane_invoker::invoke_sane_get_select_fd(SANE_Handle handle, SANE_Int* fd)
{ {
if (!sane_invoker::inst_) if (!sane_invoker::inst_)
return (SANE_Status)HG_ERR_NOT_OPEN; return (SANE_Status)SCANNER_ERR_NOT_OPEN;
if (!sane_invoker::inst_->real_sane_get_select_fd_) if (!sane_invoker::inst_->real_sane_get_select_fd_)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
@ -642,7 +642,7 @@ SANE_String_Const sane_invoker::invoke_sane_strstatus(SANE_Status status)
SANE_Status sane_invoker::invoke_sane_init_ex(SANE_Int* version_code, sane_callback cb, void* param) SANE_Status sane_invoker::invoke_sane_init_ex(SANE_Int* version_code, sane_callback cb, void* param)
{ {
if (!sane_invoker::inst_) if (!sane_invoker::inst_)
return (SANE_Status)HG_ERR_NOT_OPEN; return (SANE_Status)SCANNER_ERR_NOT_OPEN;
if (!sane_invoker::inst_->real_sane_init_ex_) if (!sane_invoker::inst_->real_sane_init_ex_)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
@ -652,7 +652,7 @@ SANE_Status sane_invoker::invoke_sane_init_ex(SANE_Int* version_code, sane_callb
SANE_Status sane_invoker::invoke_sane_io_control(SANE_Handle h, unsigned long code, void* data, unsigned* len) SANE_Status sane_invoker::invoke_sane_io_control(SANE_Handle h, unsigned long code, void* data, unsigned* len)
{ {
if (!sane_invoker::inst_) if (!sane_invoker::inst_)
return (SANE_Status)HG_ERR_NOT_OPEN; return (SANE_Status)SCANNER_ERR_NOT_OPEN;
if (!sane_invoker::inst_->real_sane_io_control_) if (!sane_invoker::inst_->real_sane_io_control_)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
@ -699,7 +699,7 @@ scanner* sane_invoker::open_scanner(const char* name, int* err)
if (!sane_invoker::inst_) if (!sane_invoker::inst_)
{ {
if (err) if (err)
*err = HG_ERR_NOT_OPEN; *err = SCANNER_ERR_NOT_OPEN;
return NULL; return NULL;
} }
@ -728,7 +728,7 @@ scanner::scanner(sane_invoker* host, struct _dev& dev) : host_(host), hdev_(NULL
, opt_ind_dpi_(-1), opt_ind_color_mode_(-1), opt_ind_paper_(-1), opt_ind_scann_count_(-1) , opt_ind_dpi_(-1), opt_ind_color_mode_(-1), opt_ind_paper_(-1), opt_ind_scann_count_(-1)
, jpeg_quality_(80), opt_ind_text_direction_(-1), opt_ind_page_(-1), img_fmt_(SANE_IMAGE_TYPE_BMP) , jpeg_quality_(80), opt_ind_text_direction_(-1), opt_ind_page_(-1), img_fmt_(SANE_IMAGE_TYPE_BMP)
, opt_ind_auto_descrew_(-1), opt_ind_erase_black_frame_(-1), opt_ind_filter_(-1), opt_ind_bright_(-1) , opt_ind_auto_descrew_(-1), opt_ind_erase_black_frame_(-1), opt_ind_filter_(-1), opt_ind_bright_(-1)
, opt_ind_contrast_(-1), opt_ind_gamma_(-1), opt_ind_ultrasonic_(-1), err_(HG_ERR_OK), desc_("") , opt_ind_contrast_(-1), opt_ind_gamma_(-1), opt_ind_ultrasonic_(-1), err_(SCANNER_ERR_OK), desc_("")
, compression_(SANE_COMPRESSION_NONE), opt_ind_flip_(-1), auto_crop_(false), opt_ind_rotate_bkg_(-1) , compression_(SANE_COMPRESSION_NONE), opt_ind_flip_(-1), auto_crop_(false), opt_ind_rotate_bkg_(-1)
, opt_ind_fill_blank_bkg_(-1), opt_ind_edge_ident_(-1), opt_ind_threshold_(-1), opt_ind_bkg_filling_method_(-1) , opt_ind_fill_blank_bkg_(-1), opt_ind_edge_ident_(-1), opt_ind_threshold_(-1), opt_ind_bkg_filling_method_(-1)
, opt_ind_fill_hole_(-1), opt_ind_fill_hole_ratio_(-1), opt_ind_noise_(-1), opt_ind_noise_threshold_(-1) , opt_ind_fill_hole_(-1), opt_ind_fill_hole_ratio_(-1), opt_ind_noise_(-1), opt_ind_noise_threshold_(-1)
@ -815,7 +815,16 @@ void scanner::load_options(void)
op.ind = i; op.ind = i;
op.desc = desc; op.desc = desc;
if (desc->type == SANE_Value_Type::SANE_TYPE_BOOL) if (desc->name == KNOWN_OPT_NAME_CUSTOM_GAMMA)
{
SANE_Int afterdo = 0;
SANE_Int *v = new SANE_Int[3 * 256];
sane_invoker::invoke_sane_control_option(hdev_, i, SANE_ACTION_GET_VALUE, v, &afterdo);
op.val.iv = 0;
delete[] v;
}
else if (desc->type == SANE_Value_Type::SANE_TYPE_BOOL)
op.val.bv = get_boolean(i); op.val.bv = get_boolean(i);
else if (desc->type == SANE_Value_Type::SANE_TYPE_FIXED) else if (desc->type == SANE_Value_Type::SANE_TYPE_FIXED)
op.val.dv = get_double(i); op.val.dv = get_double(i);
@ -978,11 +987,11 @@ int scanner::close(void)
hdev_ = NULL; hdev_ = NULL;
} }
return HG_ERR_OK; return SCANNER_ERR_OK;
} }
int scanner::start(void) int scanner::start(void)
{ {
int ret = HG_ERR_NOT_OPEN; int ret = SCANNER_ERR_NOT_OPEN;
ResetEvent(wait_img_); ResetEvent(wait_img_);
if (hdev_) if (hdev_)
@ -997,7 +1006,7 @@ int scanner::stop(void)
if (hdev_) if (hdev_)
sane_invoker::invoke_sane_cancel(hdev_); sane_invoker::invoke_sane_cancel(hdev_);
return HG_ERR_OK; return SCANNER_ERR_OK;
} }
void scanner::set_event_callback(void(*cb)(int, void*, unsigned int*, void*), void* param) void scanner::set_event_callback(void(*cb)(int, void*, unsigned int*, void*), void* param)
{ {
@ -1241,24 +1250,24 @@ bool scanner::get_value(int sn, float& now, float& init, float* lower, float* up
int scanner::set_value(int sn, std::string val) int scanner::set_value(int sn, std::string val)
{ {
if (sn <= 0 || sn >= option_count_) if (sn <= 0 || sn >= option_count_)
return HG_ERR_OUT_OF_RANGE; return SCANNER_ERR_OUT_OF_RANGE;
std::vector<SANEOPTION>::iterator it = std::find(options_.begin(), options_.end(), sn); std::vector<SANEOPTION>::iterator it = std::find(options_.begin(), options_.end(), sn);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NO_DATA; return SCANNER_ERR_NO_DATA;
if (scanner::type(it->desc->type) != "string" || if (scanner::type(it->desc->type) != "string" ||
val.length() > it->desc->size) val.length() > it->desc->size)
return HG_ERR_INVALID_PARAMETER; return SCANNER_ERR_INVALID_PARAMETER;
char* buf = new char[it->desc->size + 20]; char* buf = new char[it->desc->size + 20];
int ret = HG_ERR_OK; int ret = SCANNER_ERR_OK;
SANE_Int afterdo = 0; SANE_Int afterdo = 0;
memset(buf, 0, it->desc->size + 20); memset(buf, 0, it->desc->size + 20);
strcpy(buf, val.c_str()); strcpy(buf, val.c_str());
ret = sane_invoker::invoke_sane_control_option(hdev_, sn, SANE_ACTION_SET_VALUE, buf, &afterdo); ret = sane_invoker::invoke_sane_control_option(hdev_, sn, SANE_ACTION_SET_VALUE, buf, &afterdo);
if (sn == opt_ind_paper_ && (ret == HG_ERR_OK || ret == HG_ERR_NOT_EXACT)) if (sn == opt_ind_paper_ && (ret == SCANNER_ERR_OK || ret == SCANNER_ERR_NOT_EXACT))
{ {
auto_crop_ = paper::is_auto_crop(buf); auto_crop_ = paper::is_auto_crop(buf);
} }
@ -1269,17 +1278,17 @@ int scanner::set_value(int sn, std::string val)
int scanner::set_value(int sn, bool val) int scanner::set_value(int sn, bool val)
{ {
if (sn <= 0 || sn >= option_count_) if (sn <= 0 || sn >= option_count_)
return HG_ERR_OUT_OF_RANGE; return SCANNER_ERR_OUT_OF_RANGE;
std::vector<SANEOPTION>::iterator it = std::find(options_.begin(), options_.end(), sn); std::vector<SANEOPTION>::iterator it = std::find(options_.begin(), options_.end(), sn);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NO_DATA; return SCANNER_ERR_NO_DATA;
if (scanner::type(it->desc->type) != "bool" && if (scanner::type(it->desc->type) != "bool" &&
scanner::type(it->desc->type) != "button") scanner::type(it->desc->type) != "button")
return HG_ERR_INVALID_PARAMETER; return SCANNER_ERR_INVALID_PARAMETER;
int ret = HG_ERR_OK; int ret = SCANNER_ERR_OK;
SANE_Int afterdo = 0; SANE_Int afterdo = 0;
SANE_Bool v = val; SANE_Bool v = val;
@ -1290,16 +1299,16 @@ int scanner::set_value(int sn, bool val)
int scanner::set_value(int sn, int val) int scanner::set_value(int sn, int val)
{ {
if (sn <= 0 || sn >= option_count_) if (sn <= 0 || sn >= option_count_)
return HG_ERR_OUT_OF_RANGE; return SCANNER_ERR_OUT_OF_RANGE;
std::vector<SANEOPTION>::iterator it = std::find(options_.begin(), options_.end(), sn); std::vector<SANEOPTION>::iterator it = std::find(options_.begin(), options_.end(), sn);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NO_DATA; return SCANNER_ERR_NO_DATA;
if (scanner::type(it->desc->type) != "int") if (scanner::type(it->desc->type) != "int")
return HG_ERR_INVALID_PARAMETER; return SCANNER_ERR_INVALID_PARAMETER;
int ret = HG_ERR_OK; int ret = SCANNER_ERR_OK;
SANE_Int afterdo = 0; SANE_Int afterdo = 0;
SANE_Int v = val; SANE_Int v = val;
@ -1310,19 +1319,19 @@ int scanner::set_value(int sn, int val)
int scanner::set_value(int sn, double val) int scanner::set_value(int sn, double val)
{ {
if (sn <= 0 || sn >= option_count_) if (sn <= 0 || sn >= option_count_)
return HG_ERR_OUT_OF_RANGE; return SCANNER_ERR_OUT_OF_RANGE;
std::vector<SANEOPTION>::iterator it = std::find(options_.begin(), options_.end(), sn); std::vector<SANEOPTION>::iterator it = std::find(options_.begin(), options_.end(), sn);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NO_DATA; return SCANNER_ERR_NO_DATA;
if (scanner::type(it->desc->type) != "float") if (scanner::type(it->desc->type) != "float")
return HG_ERR_INVALID_PARAMETER; return SCANNER_ERR_INVALID_PARAMETER;
if (sn == opt_ind_fill_hole_ratio_) if (sn == opt_ind_fill_hole_ratio_)
val /= 100.0f; val /= 100.0f;
int ret = HG_ERR_OK; int ret = SCANNER_ERR_OK;
SANE_Int afterdo = 0; SANE_Int afterdo = 0;
SANE_Fixed v = SANE_FIX(val); SANE_Fixed v = SANE_FIX(val);
@ -1337,10 +1346,10 @@ int scanner::twain_set_resolution(float dpi)
if(opt_ind_dpi_ == -1 || if(opt_ind_dpi_ == -1 ||
!get_value(opt_ind_dpi_, n, i, &l, &u)) !get_value(opt_ind_dpi_, n, i, &l, &u))
return dpi >= 200.0f && dpi <= 600.0f ? HG_ERR_OK : HG_ERR_INVALID_PARAMETER; return dpi >= 200.0f && dpi <= 600.0f ? SCANNER_ERR_OK : SCANNER_ERR_INVALID_PARAMETER;
if (dpi <= l || dpi >= u) if (dpi <= l || dpi >= u)
return HG_ERR_INVALID_PARAMETER; return SCANNER_ERR_INVALID_PARAMETER;
std::vector<SANEOPTION>::iterator it = std::find(options_.begin(), options_.end(), opt_ind_dpi_); std::vector<SANEOPTION>::iterator it = std::find(options_.begin(), options_.end(), opt_ind_dpi_);
SANE_Fixed v = it->desc->type == SANE_TYPE_FIXED ? SANE_FIX(dpi) : dpi; SANE_Fixed v = it->desc->type == SANE_TYPE_FIXED ? SANE_FIX(dpi) : dpi;
@ -1393,7 +1402,7 @@ float scanner::twain_get_resolution(float* init, std::vector<float>* values, val
int scanner::twain_set_color_mode(int twain_pixel_type) int scanner::twain_set_color_mode(int twain_pixel_type)
{ {
int ret = HG_ERR_DEVICE_NOT_SUPPORT; int ret = SCANNER_ERR_DEVICE_NOT_SUPPORT;
for (const auto& v : options_) for (const auto& v : options_)
{ {
@ -1411,7 +1420,7 @@ int scanner::twain_set_color_mode(int twain_pixel_type)
break; break;
} }
return HG_ERR_OK; return SCANNER_ERR_OK;
} }
int scanner::twain_get_color_mode(int* init, std::vector<int>* values, value_limit* limit) int scanner::twain_get_color_mode(int* init, std::vector<int>* values, value_limit* limit)
{ {
@ -1473,12 +1482,12 @@ int scanner::twain_set_paper_lateral(bool lateral)
{ {
FIND_OPTION(opt_ind_paper_); FIND_OPTION(opt_ind_paper_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_INVALID_PARAMETER; return SCANNER_ERR_INVALID_PARAMETER;
std::list<std::string> vals; std::list<std::string> vals;
std::string now(get_string(opt_ind_paper_, it->desc->size)); std::string now(get_string(opt_ind_paper_, it->desc->size));
size_t pos = now.find(paper::lateral_title()); size_t pos = now.find(paper::lateral_title());
int ret = HG_ERR_OK; int ret = SCANNER_ERR_OK;
if (lateral) if (lateral)
{ {
@ -1487,7 +1496,7 @@ int scanner::twain_set_paper_lateral(bool lateral)
now += paper::lateral_title(); now += paper::lateral_title();
sane_trans::get_value_list(it->desc, &vals); sane_trans::get_value_list(it->desc, &vals);
if (std::find(vals.begin(), vals.end(), now) == vals.end()) if (std::find(vals.begin(), vals.end(), now) == vals.end())
ret = HG_ERR_INVALID_PARAMETER; ret = SCANNER_ERR_INVALID_PARAMETER;
else else
{ {
ret = set_string(opt_ind_paper_, now, it->desc->size); ret = set_string(opt_ind_paper_, now, it->desc->size);
@ -1524,7 +1533,7 @@ int scanner::twain_set_paper_auto_match_size(bool match)
{ {
FIND_OPTION(opt_ind_paper_); FIND_OPTION(opt_ind_paper_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
std::string val(match ? paper::auto_size_title() : *it->val.sv); std::string val(match ? paper::auto_size_title() : *it->val.sv);
@ -1543,7 +1552,7 @@ bool scanner::twain_is_paper_auto_match_size(void)
int scanner::twain_set_scan_count(int count) int scanner::twain_set_scan_count(int count)
{ {
int ret = HG_ERR_DEVICE_NOT_SUPPORT; int ret = SCANNER_ERR_DEVICE_NOT_SUPPORT;
if (opt_ind_scann_count_ != -1) if (opt_ind_scann_count_ != -1)
{ {
@ -1607,12 +1616,12 @@ int scanner::twain_set_final_format(SANE_ImageType type, void* param)
{ {
SANE_FinalImgFormat fmt; SANE_FinalImgFormat fmt;
unsigned int len = sizeof(fmt); unsigned int len = sizeof(fmt);
int ret = HG_ERR_OK; int ret = SCANNER_ERR_OK;
fmt.img_format = type; fmt.img_format = type;
fmt.detail = param; fmt.detail = param;
ret = sane_invoker::invoke_sane_io_control(hdev_, IO_CTRL_CODE_SET_FINAL_IMAGE_FORMAT, &fmt, &len); ret = sane_invoker::invoke_sane_io_control(hdev_, IO_CTRL_CODE_SET_FINAL_IMAGE_FORMAT, &fmt, &len);
if (ret == HG_ERR_OK) if (ret == SCANNER_ERR_OK)
{ {
if (type == SANE_IMAGE_TYPE_JPG) if (type == SANE_IMAGE_TYPE_JPG)
jpeg_quality_ = (int)param; jpeg_quality_ = (int)param;
@ -1634,13 +1643,13 @@ int scanner::twain_set_final_compression(int compression)
{ {
SANE_Compression compr; SANE_Compression compr;
unsigned int len = sizeof(compr); unsigned int len = sizeof(compr);
int ret = HG_ERR_OK; int ret = SCANNER_ERR_OK;
compr.compression = (SANE_CompressionType)compression; compr.compression = (SANE_CompressionType)compression;
compr.detail = NULL; compr.detail = NULL;
ret = sane_invoker::invoke_sane_io_control(hdev_, IO_CTRL_CODE_SET_FINAL_COMPRESSION, &compr, &len); ret = sane_invoker::invoke_sane_io_control(hdev_, IO_CTRL_CODE_SET_FINAL_COMPRESSION, &compr, &len);
if (ret == HG_ERR_OK || ret == HG_ERR_NOT_EXACT) if (ret == SCANNER_ERR_OK || ret == SCANNER_ERR_NOT_EXACT)
compression_ = compr.compression; compression_ = compr.compression;
return ret; return ret;
@ -1653,7 +1662,7 @@ int scanner::twain_get_final_compression(int* init, std::vector<int>* values)
unsigned int len = _countof(vals) - 4; unsigned int len = _countof(vals) - 4;
int ret = sane_invoker::invoke_sane_io_control(hdev_, IO_CTRL_CODE_GET_FINAL_COMPRESSION, vals, &len); int ret = sane_invoker::invoke_sane_io_control(hdev_, IO_CTRL_CODE_GET_FINAL_COMPRESSION, vals, &len);
if (ret == HG_ERR_OK) if (ret == SCANNER_ERR_OK)
{ {
if (init) if (init)
*init = vals[1]; *init = vals[1];
@ -1671,7 +1680,7 @@ int scanner::twain_get_final_compression(int* init, std::vector<int>* values)
int scanner::twain_set_text_direction(double degree) int scanner::twain_set_text_direction(double degree)
{ {
int ret = HG_ERR_INVALID_PARAMETER; int ret = SCANNER_ERR_INVALID_PARAMETER;
std::string val(text_direction::from_twain_angle(degree)); std::string val(text_direction::from_twain_angle(degree));
if (val.length()) if (val.length())
@ -1715,7 +1724,7 @@ int scanner::twain_set_text_auto_matic(bool am)
{ {
FIND_OPTION(opt_ind_text_direction_); FIND_OPTION(opt_ind_text_direction_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
std::string val(am ? text_direction::auto_val() : text_direction::from_twain_angle(0)); std::string val(am ? text_direction::auto_val() : text_direction::from_twain_angle(0));
@ -1736,7 +1745,7 @@ int scanner::twain_set_page_duplex(bool dup)
FIND_OPTION(opt_ind_page_); FIND_OPTION(opt_ind_page_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
return set_string(opt_ind_page_, val, it->desc->size); return set_string(opt_ind_page_, val, it->desc->size);
} }
@ -1756,7 +1765,7 @@ int scanner::twain_set_page_discarding_blank_page(bool discard, bool receipt)
FIND_OPTION(opt_ind_page_); FIND_OPTION(opt_ind_page_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
return set_string(opt_ind_page_, val, it->desc->size); return set_string(opt_ind_page_, val, it->desc->size);
} }
@ -1776,7 +1785,7 @@ int scanner::twain_set_page_fold(bool fold)
FIND_OPTION(opt_ind_page_); FIND_OPTION(opt_ind_page_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
return set_string(opt_ind_page_, val, it->desc->size); return set_string(opt_ind_page_, val, it->desc->size);
} }
@ -1795,7 +1804,7 @@ int scanner::twain_set_auto_descrew(bool enable)
{ {
FIND_OPTION(opt_ind_auto_descrew_); FIND_OPTION(opt_ind_auto_descrew_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
SANE_Bool v = enable; SANE_Bool v = enable;
SANE_Int after = 0; SANE_Int after = 0;
@ -1811,7 +1820,7 @@ int scanner::twain_set_erase_black_frame(bool erase)
{ {
FIND_OPTION(opt_ind_erase_black_frame_); FIND_OPTION(opt_ind_erase_black_frame_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
SANE_Bool v = erase; SANE_Bool v = erase;
SANE_Int after = 0; SANE_Int after = 0;
@ -1834,7 +1843,7 @@ int scanner::twain_set_filter(int tw_filter, bool enhance)
{ {
FIND_OPTION(opt_ind_filter_); FIND_OPTION(opt_ind_filter_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
std::string val(filter::from_filter_type(tw_filter, enhance)); std::string val(filter::from_filter_type(tw_filter, enhance));
@ -1844,7 +1853,7 @@ int scanner::twain_get_filter(bool enhance)
{ {
FIND_OPTION(opt_ind_filter_); FIND_OPTION(opt_ind_filter_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
std::string val(get_string(opt_ind_filter_, it->desc->size)); std::string val(get_string(opt_ind_filter_, it->desc->size));
@ -1855,7 +1864,7 @@ int scanner::twain_set_bright(double bright)
{ {
FIND_OPTION(opt_ind_bright_); FIND_OPTION(opt_ind_bright_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
SANE_Fixed v = SANE_FIX(bright); SANE_Fixed v = SANE_FIX(bright);
SANE_Int after = 0; SANE_Int after = 0;
@ -1882,7 +1891,7 @@ int scanner::twain_set_contrast(double bright)
{ {
FIND_OPTION(opt_ind_contrast_); FIND_OPTION(opt_ind_contrast_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
SANE_Fixed v = SANE_FIX(bright); SANE_Fixed v = SANE_FIX(bright);
SANE_Int after = 0; SANE_Int after = 0;
@ -1909,7 +1918,7 @@ int scanner::twain_set_gamma(double bright)
{ {
FIND_OPTION(opt_ind_gamma_); FIND_OPTION(opt_ind_gamma_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
SANE_Fixed v = SANE_FIX(bright); SANE_Fixed v = SANE_FIX(bright);
SANE_Int after = 0; SANE_Int after = 0;
@ -1936,7 +1945,7 @@ int scanner::twain_set_ultrasonic_check(bool check)
{ {
FIND_OPTION(opt_ind_ultrasonic_); FIND_OPTION(opt_ind_ultrasonic_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
SANE_Bool v = check; SANE_Bool v = check;
SANE_Int after = 0; SANE_Int after = 0;
@ -1978,7 +1987,7 @@ int scanner::twain_set_sharpen(int sharpen)
std::string val(sharpen::from_type(sharpen)); std::string val(sharpen::from_type(sharpen));
FIND_OPTION(opt_ind_sharpen_); FIND_OPTION(opt_ind_sharpen_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
return set_string(opt_ind_sharpen_, val, it->desc->size); return set_string(opt_ind_sharpen_, val, it->desc->size);
} }
@ -2084,7 +2093,7 @@ int scanner::twain_set_multioutput_type(int type)
{ {
FIND_OPTION(opt_ind_multi_out_); FIND_OPTION(opt_ind_multi_out_);
if (it == options_.end()) if (it == options_.end())
return HG_ERR_NOT_OPEN; return SCANNER_ERR_NOT_OPEN;
std::string val(multi_out::from_twain_type(type)); std::string val(multi_out::from_twain_type(type));

View File

@ -559,31 +559,31 @@ Result huagao_ds::selectIdentity(Twpp::Identity& ident) noexcept {
} }
Twpp::ConditionCode huagao_ds::condition_code_from_hg_error(int hgerr) Twpp::ConditionCode huagao_ds::condition_code_from_hg_error(int hgerr)
{ {
if (hgerr == HG_ERR_OK) if (hgerr == SCANNER_ERR_OK)
return Twpp::ConditionCode::Success; return Twpp::ConditionCode::Success;
if (hgerr == HG_ERR_DEVICE_NOT_FOUND) if (hgerr == SCANNER_ERR_DEVICE_NOT_FOUND)
return Twpp::ConditionCode::CheckDeviceOnline; return Twpp::ConditionCode::CheckDeviceOnline;
if (hgerr == HG_ERR_IO) if (hgerr == SCANNER_ERR_IO)
return Twpp::ConditionCode::OperationError; return Twpp::ConditionCode::OperationError;
if(hgerr == HG_ERR_OUT_OF_RANGE) if(hgerr == SCANNER_ERR_OUT_OF_RANGE)
return Twpp::ConditionCode::BadCap; return Twpp::ConditionCode::BadCap;
if(hgerr == HG_ERR_DEVICE_NOT_SUPPORT) if(hgerr == SCANNER_ERR_DEVICE_NOT_SUPPORT)
return Twpp::ConditionCode::BadProtocol; return Twpp::ConditionCode::BadProtocol;
if(hgerr == HG_ERR_INVALID_PARAMETER) if(hgerr == SCANNER_ERR_INVALID_PARAMETER)
return Twpp::ConditionCode::BadValue; return Twpp::ConditionCode::BadValue;
if(hgerr == HG_ERR_ACCESS_DENIED) if(hgerr == SCANNER_ERR_ACCESS_DENIED)
return Twpp::ConditionCode::Denied; return Twpp::ConditionCode::Denied;
if(hgerr == HG_ERR_OPEN_FILE_FAILED) if(hgerr == SCANNER_ERR_OPEN_FILE_FAILED)
return Twpp::ConditionCode::FileNotFound; return Twpp::ConditionCode::FileNotFound;
if (hgerr == HG_ERR_DEVICE_PAPER_JAMMED) if (hgerr == SCANNER_ERR_DEVICE_PAPER_JAMMED)
return Twpp::ConditionCode::PaperJam; return Twpp::ConditionCode::PaperJam;
if (hgerr == HG_ERR_DEVICE_DOUBLE_FEEDING) if (hgerr == SCANNER_ERR_DEVICE_DOUBLE_FEEDING)
return Twpp::ConditionCode::PaperDoubleFeed; return Twpp::ConditionCode::PaperDoubleFeed;
if (hgerr == HG_ERR_WRITE_FILE_FAILED) if (hgerr == SCANNER_ERR_WRITE_FILE_FAILED)
return Twpp::ConditionCode::FileWriteError; return Twpp::ConditionCode::FileWriteError;
if (hgerr == HG_ERR_DEVICE_DOGEAR) if (hgerr == SCANNER_ERR_DEVICE_DOGEAR)
return Twpp::ConditionCode::DamagedCorner; return Twpp::ConditionCode::DamagedCorner;
if (hgerr == HG_ERR_DEVICE_NO_PAPER) if (hgerr == SCANNER_ERR_DEVICE_NO_PAPER)
return Twpp::ConditionCode::NoMedia; return Twpp::ConditionCode::NoMedia;
return (Twpp::ConditionCode)((int)Twpp::ConditionCode::CustomBase + hgerr); return (Twpp::ConditionCode)((int)Twpp::ConditionCode::CustomBase + hgerr);
@ -759,7 +759,7 @@ Result huagao_ds::userInterfaceEnable(const Identity&, UserInterface& ui)
{ {
if (m_bIndicator) if (m_bIndicator)
ui_->show_main_ui(sane_invoker::get_api()); ui_->show_main_ui(sane_invoker::get_api());
return scanner_->start() == HG_ERR_OK ? success() : seqError(); return scanner_->start() == SCANNER_ERR_OK ? success() : seqError();
} }
return showTwainUI(ui); return showTwainUI(ui);
@ -1006,7 +1006,7 @@ void huagao_ds::init_support_caps(void)
if (item > 65535 || item < -1 || item == 0) { if (item > 65535 || item < -1 || item == 0) {
return badValue(); return badValue();
} }
return scanner_->twain_set_scan_count(item) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_scan_count(item) == SCANNER_ERR_OK ? success() : badValue();
} }
Int16 tmp_count = scanner_->twain_get_scan_count(); Int16 tmp_count = scanner_->twain_get_scan_count();
return oneValGetSet<Int16>(msg, data, tmp_count, -1); return oneValGetSet<Int16>(msg, data, tmp_count, -1);
@ -1045,7 +1045,7 @@ void huagao_ds::init_support_caps(void)
int mech = (int)data.currentItem<CapType::ICompression>(); int mech = (int)data.currentItem<CapType::ICompression>();
if (msg == Msg::Reset) if (msg == Msg::Reset)
scanner_->twain_get_final_compression(&mech); scanner_->twain_get_final_compression(&mech);
return scanner_->twain_set_final_compression(mech) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_final_compression(mech) == SCANNER_ERR_OK ? success() : badValue();
} }
std::vector<int> values; std::vector<int> values;
std::list<Compression> vals; std::list<Compression> vals;
@ -1068,14 +1068,14 @@ void huagao_ds::init_support_caps(void)
m_caps[CapType::IBitDepth] = [this](Msg msg, Capability& data) -> Result { m_caps[CapType::IBitDepth] = [this](Msg msg, Capability& data) -> Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<CapType::IBitDepth>(); auto mech = data.currentItem<CapType::IBitDepth>();
int ret = HG_ERR_INVALID_PARAMETER; int ret = SCANNER_ERR_INVALID_PARAMETER;
if (mech == 1) if (mech == 1)
ret = scanner_->twain_set_color_mode((int)PixelType::BlackWhite); ret = scanner_->twain_set_color_mode((int)PixelType::BlackWhite);
else if(mech == 8) else if(mech == 8)
ret = scanner_->twain_set_color_mode((int)PixelType::Gray); ret = scanner_->twain_set_color_mode((int)PixelType::Gray);
else if(mech == 24) else if(mech == 24)
ret = scanner_->twain_set_color_mode((int)PixelType::Rgb); ret = scanner_->twain_set_color_mode((int)PixelType::Rgb);
return ret == HG_ERR_OK ? success() : badValue(); return ret == SCANNER_ERR_OK ? success() : badValue();
} }
UINT16 twpt = scanner_->twain_get_color_mode(); UINT16 twpt = scanner_->twain_get_color_mode();
if (twpt == (int)PixelType::BlackWhite) if (twpt == (int)PixelType::BlackWhite)
@ -1139,7 +1139,7 @@ void huagao_ds::init_support_caps(void)
data = Capability::createOneValue<CapType::IXResolution>(Fix32(init)); data = Capability::createOneValue<CapType::IXResolution>(Fix32(init));
case Msg::Set: { case Msg::Set: {
auto mech = data.currentItem<CapType::IXResolution>(); auto mech = data.currentItem<CapType::IXResolution>();
return scanner_->twain_set_resolution((float)mech) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_resolution((float)mech) == SCANNER_ERR_OK ? success() : badValue();
} }
default: default:
return capBadOperation(); return capBadOperation();
@ -1224,7 +1224,7 @@ void huagao_ds::init_support_caps(void)
} }
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<CapType::IPixelType>(); auto mech = data.currentItem<CapType::IPixelType>();
return scanner_->twain_set_color_mode((int)mech) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_color_mode((int)mech) == SCANNER_ERR_OK ? success() : badValue();
} }
std::vector<int> values; std::vector<int> values;
value_limit limit = VAL_LIMIT_NONE; value_limit limit = VAL_LIMIT_NONE;
@ -1277,7 +1277,7 @@ void huagao_ds::init_support_caps(void)
auto mech = data.currentItem<CapType::IAutomaticColorNonColorPixelType>(); auto mech = data.currentItem<CapType::IAutomaticColorNonColorPixelType>();
if (scanner_->twain_get_color_mode() == TWPT_AUTOMATIC_COLOR) { if (scanner_->twain_get_color_mode() == TWPT_AUTOMATIC_COLOR) {
if ((UInt16)mech == 0 || (UInt16)mech == 1) { if ((UInt16)mech == 0 || (UInt16)mech == 1) {
if (scanner_->twain_set_auto_color_type((int)mech) == HG_ERR_OK) if (scanner_->twain_set_auto_color_type((int)mech) == SCANNER_ERR_OK)
{ {
automaticcolortype_ = (UInt16)mech; automaticcolortype_ = (UInt16)mech;
return success(); return success();
@ -1295,7 +1295,7 @@ void huagao_ds::init_support_caps(void)
auto mech = data.currentItem<CapType::IJpegQuality>(); auto mech = data.currentItem<CapType::IJpegQuality>();
if ((int)mech <= 0 || (int)mech > 100) if ((int)mech <= 0 || (int)mech > 100)
return badValue(); return badValue();
return scanner_->twain_set_final_format(SANE_IMAGE_TYPE_JPG, (void*)mech) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_final_format(SANE_IMAGE_TYPE_JPG, (void*)mech) == SCANNER_ERR_OK ? success() : badValue();
} }
unsigned short q = scanner_->twain_get_jpeg_quality(); unsigned short q = scanner_->twain_get_jpeg_quality();
return CapSupGetAllResetEx<unsigned short, UInt16, CapType::IJpegQuality>(msg, data, q, 80); return CapSupGetAllResetEx<unsigned short, UInt16, CapType::IJpegQuality>(msg, data, q, 80);
@ -1316,7 +1316,7 @@ void huagao_ds::init_support_caps(void)
m_caps[CapType::IRotation] = [this](Msg msg, Capability& data) -> Result { m_caps[CapType::IRotation] = [this](Msg msg, Capability& data) -> Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto res = data.currentItem<Fix32>(); auto res = data.currentItem<Fix32>();
return scanner_->twain_set_text_direction(res.toFloat()) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_text_direction(res.toFloat()) == SCANNER_ERR_OK ? success() : badValue();
} }
double init = .0f, now = .0f; double init = .0f, now = .0f;
std::list<double> values; std::list<double> values;
@ -1358,7 +1358,7 @@ void huagao_ds::init_support_caps(void)
m_caps[CapType::DuplexEnabled] = [this](Msg msg, Capability& data) -> Result { m_caps[CapType::DuplexEnabled] = [this](Msg msg, Capability& data) -> Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
bool mech = data.currentItem<CapType::DuplexEnabled>(); bool mech = data.currentItem<CapType::DuplexEnabled>();
return scanner_->twain_set_page_duplex(mech) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_page_duplex(mech) == SCANNER_ERR_OK ? success() : badValue();
} }
BYTE dup = scanner_->twain_is_page_duplex(); BYTE dup = scanner_->twain_is_page_duplex();
return CapSupGetAllReset<BYTE, Bool, CapType::DuplexEnabled>(msg, data, dup, Bool(true)); return CapSupGetAllReset<BYTE, Bool, CapType::DuplexEnabled>(msg, data, dup, Bool(true));
@ -1388,7 +1388,7 @@ void huagao_ds::init_support_caps(void)
type = SANE_IMAGE_TYPE_JFIF; type = SANE_IMAGE_TYPE_JFIF;
else else
return badValue(); return badValue();
return scanner_->twain_set_final_format(type, NULL) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_final_format(type, NULL) == SCANNER_ERR_OK ? success() : badValue();
} }
ImageFileFormat fmt = ImageFileFormat::Bmp; ImageFileFormat fmt = ImageFileFormat::Bmp;
SANE_ImageType type = scanner_->get_final_format(); SANE_ImageType type = scanner_->get_final_format();
@ -1404,7 +1404,7 @@ void huagao_ds::init_support_caps(void)
m_caps[CapType::IAutomaticDeskew] = [this](Msg msg, Capability& data)->Result { m_caps[CapType::IAutomaticDeskew] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto atuodsw = data.currentItem<CapType::IAutomaticDeskew>(); auto atuodsw = data.currentItem<CapType::IAutomaticDeskew>();
return scanner_->twain_set_auto_descrew((bool)atuodsw) == HG_ERR_OK ? success() : seqError(); return scanner_->twain_set_auto_descrew((bool)atuodsw) == SCANNER_ERR_OK ? success() : seqError();
} }
BYTE ato = scanner_->twain_is_auto_descrew(); BYTE ato = scanner_->twain_is_auto_descrew();
return CapSupGetAllReset<BYTE, bool, CapType::IAutomaticDeskew>(msg, data, ato, true); return CapSupGetAllReset<BYTE, bool, CapType::IAutomaticDeskew>(msg, data, ato, true);
@ -1414,7 +1414,7 @@ void huagao_ds::init_support_caps(void)
m_caps[CapType::IAutomaticRotate] = [this](Msg msg, Capability& data)->Result { m_caps[CapType::IAutomaticRotate] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<CapType::IAutomaticRotate>(); auto mech = data.currentItem<CapType::IAutomaticRotate>();
return scanner_->twain_set_text_auto_matic(mech) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_text_auto_matic(mech) == SCANNER_ERR_OK ? success() : badValue();
} }
BYTE am = scanner_->twain_is_text_auto_matic(); BYTE am = scanner_->twain_is_text_auto_matic();
return CapSupGetAllReset<BYTE, bool, CapType::IAutomaticRotate>(msg, data, am, false); return CapSupGetAllReset<BYTE, bool, CapType::IAutomaticRotate>(msg, data, am, false);
@ -1442,7 +1442,7 @@ void huagao_ds::init_support_caps(void)
CapabilityPrintf(msg, enum2str(CapType::IAutoSize), msg == Msg::Set ? to_string((int)data.currentItem<CapType::IAutoSize>()) : ""); CapabilityPrintf(msg, enum2str(CapType::IAutoSize), msg == Msg::Set ? to_string((int)data.currentItem<CapType::IAutoSize>()) : "");
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto autosize = data.currentItem<CapType::IAutoSize>(); auto autosize = data.currentItem<CapType::IAutoSize>();
return scanner_->twain_set_paper_auto_match_size(autosize == AutoSize::Auto) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_paper_auto_match_size(autosize == AutoSize::Auto) == SCANNER_ERR_OK ? success() : badValue();
} }
UInt16 size = scanner_->twain_is_paper_auto_match_size() ? (UInt16)AutoSize::Auto : (UInt16)AutoSize::None; UInt16 size = scanner_->twain_is_paper_auto_match_size() ? (UInt16)AutoSize::Auto : (UInt16)AutoSize::None;
return CapSupGetAllReset<UInt16, AutoSize, CapType::IAutoSize>(msg, data, { AutoSize::None, AutoSize::Auto }, size, AutoSize::None, (size == (UInt16)AutoSize::Auto) ? 1 : 0, 0); return CapSupGetAllReset<UInt16, AutoSize, CapType::IAutoSize>(msg, data, { AutoSize::None, AutoSize::Auto }, size, AutoSize::None, (size == (UInt16)AutoSize::Auto) ? 1 : 0, 0);
@ -1452,7 +1452,7 @@ void huagao_ds::init_support_caps(void)
m_caps[CapType::IAutomaticBorderDetection] = [this](Msg msg, Capability& data)->Result { m_caps[CapType::IAutomaticBorderDetection] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto autodetectborder = data.currentItem<CapType::IAutomaticBorderDetection>(); auto autodetectborder = data.currentItem<CapType::IAutomaticBorderDetection>();
return scanner_->twain_set_erase_black_frame((bool)autodetectborder) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_erase_black_frame((bool)autodetectborder) == SCANNER_ERR_OK ? success() : badValue();
} }
bool val = false; bool val = false;
Bool init = false, Bool init = false,
@ -1465,7 +1465,7 @@ void huagao_ds::init_support_caps(void)
m_caps[CapType::IAutoDiscardBlankPages] = [this](Msg msg, Capability& data)->Result { m_caps[CapType::IAutoDiscardBlankPages] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<CapType::IAutoDiscardBlankPages>(); auto mech = data.currentItem<CapType::IAutoDiscardBlankPages>();
return scanner_->twain_set_page_discarding_blank_page(mech == DiscardBlankPages::Auto, false) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_page_discarding_blank_page(mech == DiscardBlankPages::Auto, false) == SCANNER_ERR_OK ? success() : badValue();
} }
DiscardBlankPages autodiscradblank = scanner_->twain_is_page_discarding_blank_page(false) ? DiscardBlankPages autodiscradblank = scanner_->twain_is_page_discarding_blank_page(false) ?
DiscardBlankPages::Auto : DiscardBlankPages::Disabled; DiscardBlankPages::Auto : DiscardBlankPages::Disabled;
@ -1476,7 +1476,7 @@ void huagao_ds::init_support_caps(void)
m_caps[(CapType)CAP_TYPE_EX_DISCARD_BLANK_RECEIPT] = [this](Msg msg, Capability& data)->Result { m_caps[(CapType)CAP_TYPE_EX_DISCARD_BLANK_RECEIPT] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<DiscardBlankPages>(); auto mech = data.currentItem<DiscardBlankPages>();
return scanner_->twain_set_page_discarding_blank_page(mech == DiscardBlankPages::Auto, true) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_page_discarding_blank_page(mech == DiscardBlankPages::Auto, true) == SCANNER_ERR_OK ? success() : badValue();
} }
DiscardBlankPages autodiscradblank = scanner_->twain_is_page_discarding_blank_page(true) ? DiscardBlankPages autodiscradblank = scanner_->twain_is_page_discarding_blank_page(true) ?
DiscardBlankPages::Auto : DiscardBlankPages::Disabled; DiscardBlankPages::Auto : DiscardBlankPages::Disabled;
@ -1487,7 +1487,7 @@ void huagao_ds::init_support_caps(void)
m_caps[CapType::IFilter] = [this](Msg msg, Capability& data)->Result { m_caps[CapType::IFilter] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<CapType::IFilter>(); auto mech = data.currentItem<CapType::IFilter>();
return scanner_->twain_set_filter((int)mech, false) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_filter((int)mech, false) == SCANNER_ERR_OK ? success() : badValue();
} }
BYTE f = (BYTE)scanner_->twain_get_filter(false); BYTE f = (BYTE)scanner_->twain_get_filter(false);
UInt32 ind = 3; UInt32 ind = 3;
@ -1504,7 +1504,7 @@ void huagao_ds::init_support_caps(void)
m_caps[(CapType)CapTypeEx::CAP_TYPE_EX_ENHANCE_COLOR] = [this](Msg msg, Capability& data)->Result { m_caps[(CapType)CapTypeEx::CAP_TYPE_EX_ENHANCE_COLOR] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<Filter>(); auto mech = data.currentItem<Filter>();
return scanner_->twain_set_filter((int)mech, true) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_filter((int)mech, true) == SCANNER_ERR_OK ? success() : badValue();
} }
BYTE f = (BYTE)scanner_->twain_get_filter(true); BYTE f = (BYTE)scanner_->twain_get_filter(true);
UInt32 ind = 3; UInt32 ind = 3;
@ -1536,7 +1536,7 @@ void huagao_ds::init_support_caps(void)
auto mech = data.currentItem<CapType::IBrightness>(); auto mech = data.currentItem<CapType::IBrightness>();
if (mech > u || mech < -l) if (mech > u || mech < -l)
return badValue(); return badValue();
return scanner_->twain_set_bright(mech.toFloat()) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_bright(mech.toFloat()) == SCANNER_ERR_OK ? success() : badValue();
} }
default: default:
return capBadOperation(); return capBadOperation();
@ -1562,7 +1562,7 @@ void huagao_ds::init_support_caps(void)
auto mech = data.currentItem<CapType::IContrast>(); auto mech = data.currentItem<CapType::IContrast>();
if (mech > u || mech < -l) if (mech > u || mech < -l)
return badValue(); return badValue();
return scanner_->twain_set_contrast(mech.toFloat()) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_contrast(mech.toFloat()) == SCANNER_ERR_OK ? success() : badValue();
} }
default: default:
return capBadOperation(); return capBadOperation();
@ -1588,7 +1588,7 @@ void huagao_ds::init_support_caps(void)
auto mech = data.currentItem<CapType::IGamma>(); auto mech = data.currentItem<CapType::IGamma>();
if (mech > u || mech < l) if (mech > u || mech < l)
return badValue(); return badValue();
return scanner_->twain_set_gamma(mech.toFloat()) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_gamma(mech.toFloat()) == SCANNER_ERR_OK ? success() : badValue();
} }
default: default:
return capBadOperation(); return capBadOperation();
@ -1604,7 +1604,7 @@ void huagao_ds::init_support_caps(void)
m_caps[CapType::DoubleFeedDetection] = [this](Msg msg, Capability& data)->Result { m_caps[CapType::DoubleFeedDetection] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto atuodsw = data.currentItem<CapType::DoubleFeedDetection>(); auto atuodsw = data.currentItem<CapType::DoubleFeedDetection>();
return scanner_->twain_set_ultrasonic_check((bool)atuodsw) == HG_ERR_OK ? success() : seqError(); return scanner_->twain_set_ultrasonic_check((bool)atuodsw) == SCANNER_ERR_OK ? success() : seqError();
} }
DoubleFeedDetection init = DoubleFeedDetection::Ultrasonic; DoubleFeedDetection init = DoubleFeedDetection::Ultrasonic;
BYTE ato = scanner_->twain_is_ultrasonic_check(); BYTE ato = scanner_->twain_is_ultrasonic_check();
@ -1639,7 +1639,7 @@ void huagao_ds::init_support_caps(void)
auto fold = data.currentItem<Int32>(); auto fold = data.currentItem<Int32>();
if (msg == Msg::Reset) if (msg == Msg::Reset)
fold = false; fold = false;
return scanner_->twain_set_page_fold(fold) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_page_fold(fold) == SCANNER_ERR_OK ? success() : badValue();
} }
BYTE fold = scanner_->twain_is_page_fold(); BYTE fold = scanner_->twain_is_page_fold();
return CapSupGetAllResetEx<BYTE, Int32, (CapType)CapTypeEx::CAP_TYPE_EX_FOLD>(msg, data, fold, 0); return CapSupGetAllResetEx<BYTE, Int32, (CapType)CapTypeEx::CAP_TYPE_EX_FOLD>(msg, data, fold, 0);
@ -1649,7 +1649,7 @@ void huagao_ds::init_support_caps(void)
m_caps[(CapType)CapTypeEx::CAP_TYPE_EX_SHARPEN] = [this](Msg msg, Capability& data)->Result { m_caps[(CapType)CapTypeEx::CAP_TYPE_EX_SHARPEN] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<BYTE>(); auto mech = data.currentItem<BYTE>();
return scanner_->twain_set_sharpen((int)mech) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_sharpen((int)mech) == SCANNER_ERR_OK ? success() : badValue();
} }
BYTE f = (BYTE)scanner_->twain_get_sharpen(); BYTE f = (BYTE)scanner_->twain_get_sharpen();
return CapSupGetAllResetEx<BYTE, BYTE, (CapType)CapTypeEx::CAP_TYPE_EX_SHARPEN>(msg, data, { 0, 1, 2, 3, 4}, f, 0, f, 0); return CapSupGetAllResetEx<BYTE, BYTE, (CapType)CapTypeEx::CAP_TYPE_EX_SHARPEN>(msg, data, { 0, 1, 2, 3, 4}, f, 0, f, 0);
@ -1661,7 +1661,7 @@ void huagao_ds::init_support_caps(void)
auto mech = data.currentItem<UInt32>(); auto mech = data.currentItem<UInt32>();
if (mech < 10 || mech > 300) if (mech < 10 || mech > 300)
return badValue(); return badValue();
return scanner_->twain_set_dogear_distance(mech) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_dogear_distance(mech) == SCANNER_ERR_OK ? success() : badValue();
} }
UInt32 init = 50, UInt32 init = 50,
now = scanner_->twain_get_dogear_distance(); now = scanner_->twain_get_dogear_distance();
@ -1688,7 +1688,7 @@ void huagao_ds::init_support_caps(void)
auto mech = data.currentItem<UInt32>(); auto mech = data.currentItem<UInt32>();
if (msg == Msg::Reset) if (msg == Msg::Reset)
mech = -1; mech = -1;
return scanner_->twain_set_multioutput_type((int)mech) == HG_ERR_OK ? success() : badValue(); return scanner_->twain_set_multioutput_type((int)mech) == SCANNER_ERR_OK ? success() : badValue();
} }
UInt32 f = (UInt32)scanner_->twain_get_multioutput_type(); UInt32 f = (UInt32)scanner_->twain_get_multioutput_type();
return CapSupGetAllResetEx<UInt32, UInt32, (CapType)CapTypeEx::CAP_TYPE_EX_MULTI_OUT_TYPE>(msg, data, { (UInt32)-1, 0, 1, 2, 3 }, f, -1, 0, 0); return CapSupGetAllResetEx<UInt32, UInt32, (CapType)CapTypeEx::CAP_TYPE_EX_MULTI_OUT_TYPE>(msg, data, { (UInt32)-1, 0, 1, 2, 3 }, f, -1, 0, 0);
@ -1700,7 +1700,7 @@ void huagao_ds::init_support_caps(void)
auto tobe = data.currentItem<Int32>(); auto tobe = data.currentItem<Int32>();
if (msg == Msg::Reset) if (msg == Msg::Reset)
tobe = false; tobe = false;
return scanner_->twain_set_to_be_scan(tobe) == HG_ERR_OK ? success() : seqError(); return scanner_->twain_set_to_be_scan(tobe) == SCANNER_ERR_OK ? success() : seqError();
} }
BYTE tobe = scanner_->twain_get_to_be_scan(); BYTE tobe = scanner_->twain_get_to_be_scan();
return CapSupGetAllResetEx<BYTE, Int32, (CapType)CapTypeEx::CAP_TYPE_EX_TO_BE_SCAN>(msg, data, tobe, 0); return CapSupGetAllResetEx<BYTE, Int32, (CapType)CapTypeEx::CAP_TYPE_EX_TO_BE_SCAN>(msg, data, tobe, 0);
@ -1712,7 +1712,7 @@ void huagao_ds::init_support_caps(void)
auto tobe = data.currentItem<Int32>(); auto tobe = data.currentItem<Int32>();
if (msg == Msg::Reset) if (msg == Msg::Reset)
tobe = false; tobe = false;
return scanner_->twain_set_scan_with_hole(tobe) == HG_ERR_OK ? success() : seqError(); return scanner_->twain_set_scan_with_hole(tobe) == SCANNER_ERR_OK ? success() : seqError();
} }
BYTE tobe = scanner_->twain_get_scan_with_hole(); BYTE tobe = scanner_->twain_get_scan_with_hole();
return CapSupGetAllResetEx<BYTE, Int32, (CapType)CapTypeEx::CAP_TYPE_EX_SCAN_WITH_HOLE>(msg, data, tobe, 0); return CapSupGetAllResetEx<BYTE, Int32, (CapType)CapTypeEx::CAP_TYPE_EX_SCAN_WITH_HOLE>(msg, data, tobe, 0);
@ -1720,7 +1720,7 @@ void huagao_ds::init_support_caps(void)
char code[256] = { 0 }; char code[256] = { 0 };
unsigned int len = _countof(code); unsigned int len = _countof(code);
if (scanner_->twain_get_device_code(code, len) == HG_ERR_OK) if (scanner_->twain_get_device_code(code, len) == SCANNER_ERR_OK)
{ {
m_query[(CapType)(CapTypeEx::CAP_TYPE_EX_ENCODE)] = msgSupportGetAll; m_query[(CapType)(CapTypeEx::CAP_TYPE_EX_ENCODE)] = msgSupportGetAll;
m_caps[(CapType)(CapTypeEx::CAP_TYPE_EX_ENCODE)] = [this](Msg msg, Capability& data)->Result { m_caps[(CapType)(CapTypeEx::CAP_TYPE_EX_ENCODE)] = [this](Msg msg, Capability& data)->Result {
@ -1808,7 +1808,7 @@ void huagao_ds::init_support_caps_ex(void)
if(msg == Msg::Set) { \ if(msg == Msg::Set) { \
ctype item; \ ctype item; \
copy_type(item, data.currentItem<ttype>()); \ copy_type(item, data.currentItem<ttype>()); \
return scanner_->set_value(sn, item) == HG_ERR_OK ? success() : badValue(); \ return scanner_->set_value(sn, item) == SCANNER_ERR_OK ? success() : badValue(); \
} \ } \
std::list<ctype> org; \ std::list<ctype> org; \
ctype now, init; \ ctype now, init; \
@ -1834,7 +1834,7 @@ void huagao_ds::init_support_caps_ex(void)
return seqError(); \ return seqError(); \
if(msg == Msg::Set) { \ if(msg == Msg::Set) { \
ctype item = (ctype)data.currentItem<ttype>(); \ ctype item = (ctype)data.currentItem<ttype>(); \
return scanner_->set_value(sn, item) == HG_ERR_OK ? success() : badValue(); \ return scanner_->set_value(sn, item) == SCANNER_ERR_OK ? success() : badValue(); \
} \ } \
ctype now, init, lower, upper, step; \ ctype now, init, lower, upper, step; \
ttype Now, Init, Lower, Upper, Step; \ ttype Now, Init, Lower, Upper, Step; \
@ -1853,7 +1853,7 @@ void huagao_ds::init_support_caps_ex(void)
return seqError(); \ return seqError(); \
if(msg == Msg::Set) { \ if(msg == Msg::Set) { \
auto item = data.currentItem<Bool>(); \ auto item = data.currentItem<Bool>(); \
return scanner_->set_value(sn, (bool)item) == HG_ERR_OK ? success() : badValue(); \ return scanner_->set_value(sn, (bool)item) == SCANNER_ERR_OK ? success() : badValue(); \
} \ } \
bool init = false, now = false; \ bool init = false, now = false; \
std::list<bool> vals; \ std::list<bool> vals; \
@ -1869,7 +1869,7 @@ void huagao_ds::init_support_caps_ex(void)
return seqError(); \ return seqError(); \
if(msg == Msg::Set) { \ if(msg == Msg::Set) { \
ctype item = (ctype)data.currentItem<ttype>(); \ ctype item = (ctype)data.currentItem<ttype>(); \
return scanner_->set_value(sn, item) == HG_ERR_OK ? success() : badValue(); \ return scanner_->set_value(sn, item) == SCANNER_ERR_OK ? success() : badValue(); \
} \ } \
ctype now, init; \ ctype now, init; \
ttype Now, Init; \ ttype Now, Init; \

View File

@ -216,6 +216,9 @@ move /Y "$(OutDirFullPath)$(ProjectName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$
<ItemGroup> <ItemGroup>
<None Include="sane.def" /> <None Include="sane.def" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Text Include="..\..\code_device\hgsane\CMakeLists.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -77,4 +77,7 @@
<Filter>源文件</Filter> <Filter>源文件</Filter>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Text Include="..\..\code_device\hgsane\CMakeLists.txt" />
</ItemGroup>
</Project> </Project>