调整AutoMaticBorderDetection与SupportedSizes协议:将匹配原始尺寸看作独立协议,在TWAIN协议层实现与纸张尺寸兼容
This commit is contained in:
parent
fc972c5c41
commit
a4e5af59be
|
@ -2132,14 +2132,27 @@ void huagao_ds::init_support_caps(void)
|
|||
init = 0;
|
||||
std::vector<int> all;
|
||||
GET_SANE_OPT_EX(int, scanner_, ex_paper, NULL, &all);
|
||||
now = all[sane_opts::RANGE_POS_CURRENT];
|
||||
now = user_auto_paper_size_ ? user_paper_size_ : all[sane_opts::RANGE_POS_CURRENT];
|
||||
init = all[sane_opts::RANGE_POS_DEFAULT];
|
||||
if (user_paper_size_ == -1)
|
||||
user_paper_size_ = init;
|
||||
|
||||
if (msg == Msg::Set || msg == Msg::Reset)
|
||||
{
|
||||
if(msg == Msg::Set)
|
||||
init = (int)data.currentItem<CapType::ISupportedSizes>();
|
||||
else
|
||||
data = Capability::createOneValue<CapType::ISupportedSizes>((Twpp::PaperSize)init);
|
||||
user_paper_size_ = init;
|
||||
|
||||
if (user_auto_paper_size_)
|
||||
{
|
||||
wchar_t info[128] = { 0 };
|
||||
swprintf_s(info, _countof(info) - 1, L"user set paper size to %d, but auto-paper-size is on and ignore this oper.\r\n", user_paper_size_);
|
||||
load_sane_util::log_info(info, 1);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
SET_SANE_OPT_EX(now, scanner_, ex_paper, &init);
|
||||
return now == SCANNER_ERR_OK ? success() : badValue();
|
||||
|
@ -2583,12 +2596,29 @@ void huagao_ds::init_support_caps(void)
|
|||
auto autosize = data.currentItem<CapType::IAutoSize>();
|
||||
bool match = autosize == AutoSize::Auto;
|
||||
int ret = SCANNER_ERR_OK;
|
||||
SET_SANE_OPT_EX(ret, scanner_, ex_auto_paper_size, &match);
|
||||
user_auto_paper_size_ = match;
|
||||
if (user_auto_paper_size_)
|
||||
{
|
||||
SET_SANE_OPT_EX(ret, scanner_, ex_auto_paper_size, &match);
|
||||
}
|
||||
else
|
||||
{
|
||||
// restore to user_paper_size_ ...
|
||||
{
|
||||
wchar_t info[128] = { 0 };
|
||||
swprintf_s(info, _countof(info) - 1, L"disable auto paper size and restore paper to %d\r\n", user_paper_size_);
|
||||
load_sane_util::log_info(info, 1);
|
||||
}
|
||||
int err = 0,
|
||||
val = user_paper_size_;
|
||||
SET_SANE_OPT_EX(err, scanner_, ex_paper, &val);
|
||||
}
|
||||
|
||||
return ret == SCANNER_ERR_OK ? success() : badValue();
|
||||
}
|
||||
std::vector<bool> all;
|
||||
GET_SANE_OPT_EX(bool, scanner_, ex_auto_paper_size, NULL, &all);
|
||||
UInt16 size = all[sane_opts::RANGE_POS_CURRENT] ? (UInt16)AutoSize::Auto : (UInt16)AutoSize::None;
|
||||
//std::vector<bool> all;
|
||||
//GET_SANE_OPT_EX(bool, scanner_, ex_auto_paper_size, NULL, &all);
|
||||
UInt16 size = /*all[sane_opts::RANGE_POS_CURRENT]*/user_auto_paper_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);
|
||||
};
|
||||
|
||||
|
@ -2598,15 +2628,33 @@ void huagao_ds::init_support_caps(void)
|
|||
if (Msg::Set == msg) {
|
||||
auto autodetectborder = data.currentItem<CapType::IAutomaticBorderDetection>();
|
||||
int ret = SCANNER_ERR_OK;
|
||||
SET_SANE_OPT_EX(ret, scanner_, ex_auto_paper_size, (bool*)&autodetectborder);
|
||||
|
||||
user_auto_paper_size_ = (bool)autodetectborder;
|
||||
if (user_auto_paper_size_)
|
||||
{
|
||||
SET_SANE_OPT_EX(ret, scanner_, ex_auto_paper_size, (bool*)&autodetectborder);
|
||||
}
|
||||
else
|
||||
{
|
||||
// restore to user_paper_size_ ...
|
||||
{
|
||||
wchar_t info[128] = { 0 };
|
||||
swprintf_s(info, _countof(info) - 1, L"disable auto paper size and restore paper to %d\r\n", user_paper_size_);
|
||||
load_sane_util::log_info(info, 1);
|
||||
}
|
||||
int err = 0,
|
||||
val = user_paper_size_;
|
||||
SET_SANE_OPT_EX(err, scanner_, ex_paper, &val);
|
||||
}
|
||||
|
||||
return ret == SCANNER_ERR_OK ? success() : badValue();
|
||||
}
|
||||
Bool init = false,
|
||||
erase = false;
|
||||
std::vector<bool> all;
|
||||
GET_SANE_OPT_EX(bool, scanner_, ex_auto_paper_size, NULL, &all);
|
||||
init = (bool)all[sane_opts::RANGE_POS_DEFAULT];
|
||||
erase = (bool)all[sane_opts::RANGE_POS_CURRENT];
|
||||
//std::vector<bool> all;
|
||||
//GET_SANE_OPT_EX(bool, scanner_, ex_auto_paper_size, NULL, &all);
|
||||
init = true; // (bool)all[sane_opts::RANGE_POS_DEFAULT];
|
||||
erase = user_auto_paper_size_; // (bool)all[sane_opts::RANGE_POS_CURRENT];
|
||||
return CapSupGetAllReset<Bool, Bool, CapType::IAutomaticBorderDetection>(msg, data, { false,true }, erase, init, erase ? 1 : 0, 0);
|
||||
};
|
||||
|
||||
|
|
|
@ -59,6 +59,10 @@ class huagao_ds : public Twpp::SourceFromThis<huagao_ds> {
|
|||
bool no_bitdepth_ = false; // ¾ü¶ÓɨÃè2.0.exe set this but sychronize to APP
|
||||
int count_;
|
||||
|
||||
// Æ¥ÅäÔʼ³ß´ç(IAutomaticBorderDetection) & Ö½Õųߴç(ISupportedSizes)
|
||||
int user_paper_size_ = -1;
|
||||
bool user_auto_paper_size_ = false;
|
||||
|
||||
volatile bool notfify_close_ = false;
|
||||
enum {NOTIFY_AUTO = 0, NOTIFY_ALWAYS, NOTIFY_NONE};
|
||||
volatile unsigned notify_close_ = 0; // 0 - auto; 1 - notify always; 2 - no notify
|
||||
|
|
Loading…
Reference in New Issue