立思辰客户-军队扫描2.0.exe,在位深、亮度、对比度协议上单独处理,宏:ARMY_SCANNER

This commit is contained in:
gb 2023-08-25 16:02:41 +08:00
parent 9558519cf2
commit c164cedb4d
1 changed files with 36 additions and 15 deletions

View File

@ -1988,6 +1988,12 @@ void huagao_ds::init_support_caps(void)
auto mech = data.currentItem<CapType::IBitDepth>();
if (Msg::Set == msg)
{
#ifdef ARMY_SCANNER
if (mech >= 0 && mech <= 2)
val = mech;
else
val = COLOR_RGB;
#else
if (mech == 1)
val = COLOR_BW;
else if (mech == 8)
@ -1996,6 +2002,7 @@ void huagao_ds::init_support_caps(void)
val = COLOR_RGB;
else
val = COLOR_RGB; // mech;
#endif
}
{
wchar_t info[128] = { 0 };
@ -2653,19 +2660,26 @@ void huagao_ds::init_support_caps(void)
int init = 128, l = 1, u = 255, step = 1, now = 128;
int ret = SCANNER_ERR_OK;
std::vector<int> all;
#ifdef ARMY_SCANNER
float range_l = .0f,
range_h = 100.0f;
#else
float range_l = -1000.0f,
range_h = 1000.0f;
#endif
GET_SANE_OPT_EX(int, scanner_, bright, NULL, &all);
init = all[sane_opts::RANGE_POS_DEFAULT];
now = all[sane_opts::RANGE_POS_CURRENT];
l = all[sane_opts::RANGE_POS_LOWER];
u = all[sane_opts::RANGE_POS_UPPER];
step = all[sane_opts::RANGE_POS_STEP];
float sf = trans_range((float)step, (float)l, (float)u, -1000.0f, 1000.0f, true),
nf = trans_range((float)now, (float)l, (float)u, -1000.0f, 1000.0f),
initf = trans_range((float)init, (float)l, (float)u, -1000.0f, 1000.0f);
float sf = trans_range((float)step, (float)l, (float)u, range_l, range_h, true),
nf = trans_range((float)now, (float)l, (float)u, range_l, range_h),
initf = trans_range((float)init, (float)l, (float)u, range_l, range_h);
switch (msg) {
case Msg::Get:
sf = 333.333f;
data = Capability::createRange<CapType::IBrightness>(Fix32(-1000.0f), Fix32(1000.0f), Fix32(sf), Fix32(nf), Fix32(initf));
//sf = 333.333f;
data = Capability::createRange<CapType::IBrightness>(Fix32(range_l), Fix32(range_h), Fix32(sf), Fix32(nf), Fix32(initf));
return success();
case Msg::GetCurrent:
data = Capability::createOneValue<CapType::IBrightness>(Fix32(nf));
@ -2675,16 +2689,16 @@ void huagao_ds::init_support_caps(void)
return success();
case Msg::Set: {
auto mech = data.currentItem<CapType::IBrightness>();
if (mech > 1000.0f || mech < -1000.0f)
if (mech > range_h || mech < range_l)
return badValue();
initf = mech.toFloat();
}
case Msg::Reset:
now = (int)(trans_range(initf, -1000.0f, 1000.0f, (float)l, (float)u) + .5f);
now = (int)(trans_range(initf, range_l, range_h, (float)l, (float)u) + .5f);
SET_SANE_OPT_EX(ret, scanner_, bright, &now);
if (Msg::Reset == msg)
{
initf = trans_range((float)now, (float)l, (float)u, -1000.0f, 1000.0f, true);
initf = trans_range((float)now, (float)l, (float)u, range_l, range_h, true);
data = Capability::createOneValue<CapType::IBrightness>(Fix32(initf));
}
return ret == SCANNER_ERR_OK ? success() : badValue();
@ -2705,13 +2719,20 @@ void huagao_ds::init_support_caps(void)
l = all[sane_opts::RANGE_POS_LOWER];
u = all[sane_opts::RANGE_POS_UPPER];
step = all[sane_opts::RANGE_POS_STEP];
float sf = trans_range((float)step, (float)l, (float)u, -1000.0f, 1000.0f, true),
nf = trans_range((float)now, (float)l, (float)u, -1000.0f, 1000.0f),
initf = trans_range((float)init, (float)l, (float)u, -1000.0f, 1000.0f);
#ifdef ARMY_SCANNER
float range_l = .0f,
range_h = 100.0f;
#else
float range_l = -1000.0f,
range_h = 1000.0f;
#endif
float sf = trans_range((float)step, (float)l, (float)u, range_l, range_h, true),
nf = trans_range((float)now, (float)l, (float)u, range_l, range_h),
initf = trans_range((float)init, (float)l, (float)u, range_l, range_h);
switch (msg) {
case Msg::Get:
// sf = 333.333f;
data = Capability::createRange<CapType::IContrast>(Fix32(-1000.0f), Fix32(1000.0f), Fix32(sf), Fix32(nf), Fix32(initf));
data = Capability::createRange<CapType::IContrast>(Fix32(range_l), Fix32(range_h), Fix32(sf), Fix32(nf), Fix32(initf));
return success();
case Msg::GetCurrent:
data = Capability::createOneValue<CapType::IContrast>(Fix32(nf));
@ -2721,16 +2742,16 @@ void huagao_ds::init_support_caps(void)
return success();
case Msg::Set: {
auto mech = data.currentItem<CapType::IContrast>();
if (mech > 1000.0f || mech < -1000.0f)
if (mech > range_h || mech < range_l)
return badValue();
initf = mech.toFloat();
}
case Msg::Reset:
now = (int)(trans_range(initf, -1000.0f, 1000.0f, (float)l, (float)u) + .5f);
now = (int)(trans_range(initf, range_l, range_h, (float)l, (float)u) + .5f);
SET_SANE_OPT_EX(ret, scanner_, contrast, &now);
if (Msg::Reset == msg)
{
initf = trans_range((float)now, (float)l, (float)u, -1000.0f, 1000.0f, true);
initf = trans_range((float)now, (float)l, (float)u, range_l, range_h, true);
data = Capability::createOneValue<CapType::IContrast>(Fix32(initf));
}
return ret == SCANNER_ERR_OK ? success() : badValue();