添加自定义GAMMA属性访问接口

This commit is contained in:
gb 2023-05-29 15:51:01 +08:00
parent 6cea8a7632
commit 9efd34e96e
2 changed files with 15 additions and 4 deletions

View File

@ -864,6 +864,9 @@ scanner_err hg_scanner_mgr::hg_scanner_get_parameter(scanner_handle h, const cha
else else
return SCANNER_ERR_ACCESS_DENIED; return SCANNER_ERR_ACCESS_DENIED;
} }
else if (strcmp(SANE_STD_OPT_NAME_CUSTOM_GAMMA, name) == 0)
return (scanner_err)SCAN_PTR(h)->device_io_control(IO_CTRL_CODE_GET_CUSTOM_GAMMA, data, (unsigned int*)len);
if (strcmp(SANE_STD_OPT_NAME_LOGIN, name) == 0 || if (strcmp(SANE_STD_OPT_NAME_LOGIN, name) == 0 ||
strcmp(SANE_STD_OPT_NAME_LOGOUT, name) == 0) strcmp(SANE_STD_OPT_NAME_LOGOUT, name) == 0)
return SCANNER_ERR_DEVICE_NOT_SUPPORT; return SCANNER_ERR_DEVICE_NOT_SUPPORT;
@ -943,6 +946,8 @@ scanner_err hg_scanner_mgr::hg_scanner_set_parameter(scanner_handle h, const cha
return SCANNER_ERR_ACCESS_DENIED; return SCANNER_ERR_ACCESS_DENIED;
} }
else if (strcmp(SANE_STD_OPT_NAME_CUSTOM_GAMMA, name) == 0)
return (scanner_err)SCAN_PTR(h)->device_io_control(IO_CTRL_CODE_SET_CUSTOM_GAMMA, data, (unsigned int*)len);
} }
return (scanner_err)SCAN_PTR(h)->set_setting(name, data, len); return (scanner_err)SCAN_PTR(h)->set_setting(name, data, len);

View File

@ -394,6 +394,8 @@ namespace local_utility
FIX_ID_TO_NAME(DEVICE_IP_ADDR, 255); FIX_ID_TO_NAME(DEVICE_IP_ADDR, 255);
FIX_ID_TO_NAME(DEVICE_MAC_ADDR, 255); FIX_ID_TO_NAME(DEVICE_MAC_ADDR, 255);
FIX_ID_TO_NAME(CUSTOM_GAMMA, sizeof(SANE_Gamma));
return ""; return "";
} }
@ -1357,17 +1359,21 @@ bool hg_sane_middleware::get_current_value(scanner_handle handle, const void* op
if(!name.empty()) if(!name.empty())
{ {
char buf[256] = { 0 }; char *buf = new char[l + 4];
long len = sizeof(buf) - 1; long len = l;
bool ret = false;
memcpy(buf, value, l); memcpy(buf, value, l);
buf[l] = 0;
if (hg_scanner_get_parameter(handle, name.c_str(), buf, &len) == SCANNER_ERR_OK) if (hg_scanner_get_parameter(handle, name.c_str(), buf, &len) == SCANNER_ERR_OK)
{ {
setv(buf, len, value); setv(buf, len, value);
return true; ret = true;
} }
delete[] buf;
return false; return ret;
} }
} }