调整自定义gamma参数
This commit is contained in:
parent
89b46cc387
commit
ac6c138fb3
|
@ -26,8 +26,9 @@ hg_scanner::hg_scanner(ScannerSerial serial
|
|||
{
|
||||
paper_size_mm_.cx = 210;
|
||||
paper_size_mm_.cy = 297;
|
||||
for (int i = 0; i < sizeof(custom_gamma_val_); ++i)
|
||||
custom_gamma_val_[i] = i;
|
||||
custom_gamma_val_.pt_count = 0;
|
||||
for (int i = 0; i < ARRAY_SIZE(custom_gamma_val_.table); ++i)
|
||||
custom_gamma_val_.table[i] = i & 0x0ff;
|
||||
|
||||
HG_VLOG_MINI_2(HG_LOG_LEVEL_DEBUG_INFO, "%s(%s) constructed\n", name_.c_str(), hg_log::format_ptr(this).c_str());
|
||||
image_prc_param_.value = 0;
|
||||
|
@ -454,8 +455,9 @@ int hg_scanner::restore(int setting_no)
|
|||
setting_jsn_.at(key).at("name").get_to(val);
|
||||
if (val == KNOWN_OPT_NAME_CUSTOM_GAMMA)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(custom_gamma_val_); ++i)
|
||||
custom_gamma_val_[i] = i;
|
||||
custom_gamma_val_.pt_count = 0;
|
||||
for (int i = 0; i < ARRAY_SIZE(custom_gamma_val_.table); ++i)
|
||||
custom_gamma_val_.table[i] = i & 0x0ff;
|
||||
|
||||
return HG_ERR_OK;
|
||||
}
|
||||
|
@ -1353,16 +1355,9 @@ int hg_scanner::setting_is_custom_gamma(void* data)
|
|||
}
|
||||
int hg_scanner::setting_custom_gamma_data(void* data)
|
||||
{
|
||||
SANE_Int* v = (SANE_Int*)data;
|
||||
int len = 256;
|
||||
SANE_Gamma* gamma = (SANE_Gamma*)data;
|
||||
|
||||
if (image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS ||
|
||||
image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH)
|
||||
{
|
||||
len = 3 * 256;
|
||||
}
|
||||
for (int i = 0; i < len; ++i)
|
||||
custom_gamma_val_[i] = v[i];
|
||||
memcpy(&custom_gamma_val_, gamma, sizeof(custom_gamma_val_));
|
||||
|
||||
return HG_ERR_OK;
|
||||
}
|
||||
|
@ -1903,17 +1898,12 @@ int hg_scanner::get_setting(int setting_no, char* json_txt_buf, int* len)
|
|||
if (is_gamma)
|
||||
{
|
||||
name = "";
|
||||
add = 256;
|
||||
if (image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS ||
|
||||
image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH)
|
||||
{
|
||||
add = 3 * 256;
|
||||
}
|
||||
sprintf(sn, "[%u", custom_gamma_val_[0]);
|
||||
sprintf(sn, "[%u", custom_gamma_val_.table[0]);
|
||||
name += sn;
|
||||
for (int i = 1; i < add; ++i)
|
||||
{
|
||||
sprintf(sn, ",%u", custom_gamma_val_[i]);
|
||||
sprintf(sn, ",%u", custom_gamma_val_.table[i]);
|
||||
name += sn;
|
||||
}
|
||||
name += "]";
|
||||
|
@ -2196,19 +2186,17 @@ int hg_scanner::device_io_control(unsigned long code, void* data, unsigned* len)
|
|||
}
|
||||
else if (code == IO_CTRL_CODE_GET_CUSTOM_GAMMA)
|
||||
{
|
||||
SANE_Int* v = (SANE_Int*)data;
|
||||
int count = *len;
|
||||
for (int i = 0; i < count && i < sizeof(custom_gamma_val_); ++i)
|
||||
v[i] = custom_gamma_val_[i];
|
||||
SANE_Gamma* v = (SANE_Gamma*)data;
|
||||
|
||||
memcpy(v, &custom_gamma_val_, sizeof(custom_gamma_val_));
|
||||
|
||||
return HG_ERR_OK;
|
||||
}
|
||||
else if (code == IO_CTRL_CODE_GET_CUSTOM_GAMMA)
|
||||
else if (code == IO_CTRL_CODE_SET_CUSTOM_GAMMA)
|
||||
{
|
||||
SANE_Int* v = (SANE_Int*)data;
|
||||
int count = *len;
|
||||
for (int i = 0; i < count && i < sizeof(custom_gamma_val_); ++i)
|
||||
custom_gamma_val_[i] = v[i];
|
||||
SANE_Gamma* v = (SANE_Gamma*)data;
|
||||
|
||||
memcpy(&custom_gamma_val_, v, sizeof(custom_gamma_val_));
|
||||
|
||||
return HG_ERR_OK;
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ protected:
|
|||
////////////////////////////////////////////////////////////////
|
||||
// 新增自定义伽玛曲线及扫描区域属性 - 2022-05-05
|
||||
bool custom_gamma_; // 为true时,应用custom_gamma_val_阵列调整图像色彩;为false时,保持原来的处理方式
|
||||
uint8_t custom_gamma_val_[3 * 256]; // 当为RGB或者彩色时,为三组256字节的数据;当为黑白或灰度时,只有一组256字节
|
||||
SANE_Gamma custom_gamma_val_; // 当为RGB或者彩色时,为三组256字节的数据;当为黑白或灰度时,只有一组256字节
|
||||
bool custom_area_; // 是否启用自定义区域,为true时才使用下列4个数据;为false时保持原来的处理方式
|
||||
double custom_area_lt_x_; // 自定义区域左上角x坐标
|
||||
double custom_area_lt_y_; // 自定义区域左上角y坐标
|
||||
|
|
Loading…
Reference in New Issue