修复颜色增强属性BUG

This commit is contained in:
gb 2023-12-27 09:59:34 +08:00
parent 3f8f50e322
commit bf80eb1cbd
1 changed files with 10 additions and 6 deletions

View File

@ -721,6 +721,8 @@ struct
}g_enhance[] = { {Filter::Red, ENHANCE_RED}, {Filter::Green, ENHANCE_GREEN}, {Filter::Blue, ENHANCE_BLUE}, {Filter::None, ENHANCE_NONE} }; }g_enhance[] = { {Filter::Red, ENHANCE_RED}, {Filter::Green, ENHANCE_GREEN}, {Filter::Blue, ENHANCE_BLUE}, {Filter::None, ENHANCE_NONE} };
Filter from_sane_enhance(int sane) Filter from_sane_enhance(int sane)
{ {
return (Filter)sane;
for (int i = 0; i < _countof(g_filter); ++i) for (int i = 0; i < _countof(g_filter); ++i)
{ {
if (g_filter[i].sane == sane) if (g_filter[i].sane == sane)
@ -731,6 +733,8 @@ Filter from_sane_enhance(int sane)
} }
int to_sane_enhance(Filter twain) int to_sane_enhance(Filter twain)
{ {
return (int)twain;
for (int i = 0; i < _countof(g_filter); ++i) for (int i = 0; i < _countof(g_filter); ++i)
{ {
if (g_filter[i].twain == twain) if (g_filter[i].twain == twain)
@ -3201,19 +3205,19 @@ void huagao_ds::init_support_caps(void)
if (Msg::Set == msg || Msg::Reset == msg) { if (Msg::Set == msg || Msg::Reset == msg) {
if (Msg::Set == msg) if (Msg::Set == msg)
def = data.currentItem<UInt32>(); def = data.currentItem<UInt32>();
int ret = SCANNER_ERR_OK; int ret = SCANNER_ERR_OK, val = to_sane_enhance((Filter)def);;
SET_SANE_OPT_EX(ret, scanner_, ex_color_enhance, &def); SET_SANE_OPT_EX(ret, scanner_, ex_color_enhance, &val);
return ret == SCANNER_ERR_OK ? success() : badValue(); return ret == SCANNER_ERR_OK ? success() : badValue();
} }
std::list<Filter> vs; std::list<UInt32> vs;
Filter now = from_sane_filter(cur), init = from_sane_filter(def); UInt32 now = (UInt32)from_sane_enhance(cur), init = (UInt32)from_sane_enhance(def);
UInt32 curInd = distance<int>(vals, cur), defInd = distance<int>(vals, def); UInt32 curInd = distance<int>(vals, cur), defInd = distance<int>(vals, def);
for (size_t i = sane_opts::RANGE_POS_ENUM_BEGIN; i < vals.size(); ++i) for (size_t i = sane_opts::RANGE_POS_ENUM_BEGIN; i < vals.size(); ++i)
vs.push_back(from_sane_filter(vals[i])); vs.push_back((UInt32)from_sane_enhance(vals[i]));
UInt32 val = (UInt32)now; UInt32 val = (UInt32)now;
return CapSupGetAllResetEx<UInt32, Filter, (CapType)CapTypeEx::CAP_TYPE_EX_ENHANCE_COLOR>(msg, data, vs, val, init, curInd, defInd); return CapSupGetAllResetEx<UInt32, UInt32, (CapType)CapTypeEx::CAP_TYPE_EX_ENHANCE_COLOR>(msg, data, vs, val, init, curInd, defInd);
}; };
} }