1.修复裁切算法bug(驱动中传入noise默认值不正确);

2.修复红色增强协议bug;
This commit is contained in:
lovelyyoung 2021-06-28 11:58:54 +08:00
parent 75d3cb941b
commit 9ae4e27f3e
9 changed files with 205 additions and 191 deletions

View File

@ -42,7 +42,7 @@ BOOL CAdvancedDLG::OnInitDialog()
CTabPageSSL::OnInitDialog(); CTabPageSSL::OnInitDialog();
m_Edit_noise.SetSlideLink(this, IDC_SLIDER_NOISE); m_Edit_noise.SetSlideLink(this, IDC_SLIDER_NOISE);
m_Edit_noise.SetParams(30, 50, 2); m_Edit_noise.SetParams(5, 50, 2);
m_Edit_noise.SetValue(noise); m_Edit_noise.SetValue(noise);
m_Edit_indent.SetSlideLink(this, IDC_SLIDER_INDENT); m_Edit_indent.SetSlideLink(this, IDC_SLIDER_INDENT);

View File

@ -39,7 +39,7 @@ CImageProcPage::CImageProcPage(CWnd* pParent /*=nullptr*/)
, m_ckbDetachNoise(FALSE) , m_ckbDetachNoise(FALSE)
, m_ckbHSVCorrect(FALSE) , m_ckbHSVCorrect(FALSE)
, indent(5) , indent(5)
, noise(40) , noise(8)
,threshold(40) ,threshold(40)
,is_bw(false) ,is_bw(false)
{ {
@ -130,7 +130,7 @@ BOOL CImageProcPage::OnInitDialog()
m_edit_hole.SetValue(0.10); m_edit_hole.SetValue(0.10);
m_edit_detachnoise.SetSlideLink(this, IDC_SLIDERDETACHNOISE); m_edit_detachnoise.SetSlideLink(this, IDC_SLIDERDETACHNOISE);
m_edit_detachnoise.SetParams(10, 50, 10); m_edit_detachnoise.SetParams(0, 50, 10);
m_edit_detachnoise.SetValue(detachnoise); m_edit_detachnoise.SetValue(detachnoise);
((CButton*)GetDlgItem(IDC_CHECKDETACHNOISE))->SetCheck(is_detachnoise); ((CButton*)GetDlgItem(IDC_CHECKDETACHNOISE))->SetCheck(is_detachnoise);

View File

@ -752,11 +752,11 @@ USBCB GScanO200::Get_Scanner_Status()
if (m_usb.get() && m_usb->is_connected()) if (m_usb.get() && m_usb->is_connected())
m_usb->read_bulk(&usbcb, sizeof(usbcb)); m_usb->read_bulk(&usbcb, sizeof(usbcb));
if (usbcb.u32_CMD != GET_DSP_STATUS) //if (usbcb.u32_CMD != GET_DSP_STATUS)
{ //{
FileTools::writelog(log_ERROR, "get dsp status usb bulk error"); // FileTools::writelog(log_ERROR, "get dsp status usb bulk error");
return { NO_COMMAND,USB_BULK_ERROR,0 }; // return { NO_COMMAND,USB_BULK_ERROR,0 };
} //}
return usbcb; return usbcb;
} }

View File

@ -424,6 +424,10 @@ void ImageMatQueue::proc()
fwb.Close(); fwb.Close();
remove(path.c_str()); remove(path.c_str());
} }
else
{
FileTools::writelog(log_ERROR, "error while opening filename:" + path);
}
} }
else else
FileTools::writelog(log_ERROR, "open file error filename:" + path); FileTools::writelog(log_ERROR, "open file error filename:" + path);

View File

@ -69,7 +69,7 @@ GScanCap GscanJsonConfig::GetDefaultGscancapValue()
gcap.is_backrotate180 = FALSE; gcap.is_backrotate180 = FALSE;
gcap.AutoCrop_threshold = 40; gcap.AutoCrop_threshold = 40;
gcap.is_convex = TRUE; gcap.is_convex = TRUE;
gcap.noise = 40; gcap.noise = 8;
gcap.indent = 5; gcap.indent = 5;
gcap.is_dogeardetection = FALSE; gcap.is_dogeardetection = FALSE;
gcap.scannum = -1;//ĬÈÏÁ¬ÐøɨÃè gcap.scannum = -1;//ĬÈÏÁ¬ÐøɨÃè
@ -843,7 +843,7 @@ json GscanJsonConfig::GetDefaultJson()
"dogeardetection": false , "dogeardetection": false ,
"bScrewDetect": true , "bScrewDetect": true ,
"iScrewLevel": 3 , "iScrewLevel": 3 ,
"Noise": 40 , "Noise": 8 ,
"Indent": 5 , "Indent": 5 ,
"AutoCrop_Threshold": 40 , "AutoCrop_Threshold": 40 ,
"isConvex": true , "isConvex": true ,

View File

@ -37,7 +37,7 @@ public:
* noise [in]:noise宽度的背景竖条纹干扰40 * noise [in]:noise宽度的背景竖条纹干扰40
* indent [in]:indent像素5 * indent [in]:indent像素5
*/ */
CImageApplyAutoCrop(bool isCrop, bool isDesaskew, bool isFillBlank, const cv::Size& fixedSize, bool isConvex = true, bool isFillColor = false, double threshold = 40, int noise = 40, int indent = 5); CImageApplyAutoCrop(bool isCrop, bool isDesaskew, bool isFillBlank, const cv::Size& fixedSize, bool isConvex = true, bool isFillColor = false, double threshold = 40, int noise = 8, int indent = 5);
virtual ~CImageApplyAutoCrop(); virtual ~CImageApplyAutoCrop();

View File

@ -19,7 +19,15 @@
class CImageApplyDetachNoise : public CImageApply class CImageApplyDetachNoise : public CImageApply
{ {
public: public:
CImageApplyDetachNoise(int noise = 1); CImageApplyDetachNoise(int
= 1);
inline int getNoise() { return m_noise; } inline int getNoise() { return m_noise; }

View File

@ -12,7 +12,7 @@
#include "resource.h" #include "resource.h"
#include "CTwainUI.h" #include "CTwainUI.h"
#include "CIndicatorDlg.h" #include "CIndicatorDlg.h"
#include "Cmsgbox.h" //#include "Cmsgbox.h"
#include "Device/PublicFunc.h" #include "Device/PublicFunc.h"
#include "Device/GScanO200.h" #include "Device/GScanO200.h"
#include "Device/GScanO400.h" #include "Device/GScanO400.h"
@ -45,7 +45,7 @@ enum class CapTypeEx : unsigned short {
TwEx_Sharpen = 0x8022, TwEx_Sharpen = 0x8022,
TwEx_DBAreaNum = 0x8027, TwEx_DBAreaNum = 0x8027,
TwEx_DBDevnMax = 0x8028, TwEx_DBDevnMax = 0x8028,
TwEx_EnFold=0x8037, TwEx_EnFold = 0x8037,
TwEx_StableDetectEnable = 0x8090, TwEx_StableDetectEnable = 0x8090,
TwEx_UVModel = 0x8093, TwEx_UVModel = 0x8093,
TwEx_SwitchFrontBack = 0x8094, TwEx_SwitchFrontBack = 0x8094,
@ -53,13 +53,13 @@ enum class CapTypeEx : unsigned short {
TwEx_DogEarDelection = 0x8096, TwEx_DogEarDelection = 0x8096,
TwEx_FillBackgroundMode = 0x8097, TwEx_FillBackgroundMode = 0x8097,
TwEx_CroporDesaskewIndent = 0x8098, TwEx_CroporDesaskewIndent = 0x8098,
TwEx_CropNoise=0x8099, TwEx_CropNoise = 0x8099,
TwEx_CroporDesaskewThreshold=0x8100, TwEx_CroporDesaskewThreshold = 0x8100,
TwEx_IDetachNoise = 0x8101, TwEx_IDetachNoise = 0x8101,
TwEx_IDetachNoiseValue = 0x8102, TwEx_IDetachNoiseValue = 0x8102,
TwEx_SizeDetect=0x8103, TwEx_SizeDetect = 0x8103,
TwEx_LowPowerMode=0x8104, TwEx_LowPowerMode = 0x8104,
TwEx_ENCODE=0x8105, TwEx_ENCODE = 0x8105,
}; };
enum class PaperSizeEx : unsigned short { enum class PaperSizeEx : unsigned short {
@ -98,69 +98,69 @@ static constexpr const Identity srcIdent(
#endif #endif
#ifdef G200 #ifdef G200
#ifdef ISG100 #ifdef ISG100
#ifdef LANXUM #ifdef LANXUM
"G62S Series", "G62S Series",
#else // ISG100 #else // ISG100
"G100 Series", "G100 Series",
#endif #endif
#else // ISG100 #else // ISG100
#ifdef LANXUM #ifdef LANXUM
"G73S Series", "G73S Series",
#else // ISG100 #else // ISG100
"G200 Series", "G200 Series",
#endif #endif
#endif #endif
#elif defined(G300) // G200 #elif defined(G300) // G200
#ifdef LANXUM #ifdef LANXUM
"G42S Series", "G42S Series",
#else // ISG100 #else // ISG100
"G300 Series", "G300 Series",
#endif #endif
#elif defined(G400) // G200 #elif defined(G400) // G200
#ifdef LANXUM #ifdef LANXUM
"G52S Series", "G52S Series",
#else // ISG100 #else // ISG100
"G400 Series", "G400 Series",
#endif #endif
#endif #endif
#ifdef G200 #ifdef G200
#ifdef ISG100 #ifdef ISG100
#ifdef MAKEHUAGAO #ifdef MAKEHUAGAO
"HUAGOSCAN G100 TWAIN" "HUAGOSCAN G100 TWAIN"
#elif defined LANXUM //!LANXUM #elif defined LANXUM //!LANXUM
"LANXUMSCAN G62S TWAIN" "LANXUMSCAN G62S TWAIN"
#else // !MAKEHUAGAO #else // !MAKEHUAGAO
"ZhibenScan G100 TWAIN" "ZhibenScan G100 TWAIN"
#endif #endif
#else // ISG100 #else // ISG100
#ifdef MAKEHUAGAO #ifdef MAKEHUAGAO
"HUAGOSCAN G200 TWAIN" "HUAGOSCAN G200 TWAIN"
#elif defined LANXUM //!LANXUM #elif defined LANXUM //!LANXUM
"LANXUMSCAN G73S TWAIN" "LANXUMSCAN G73S TWAIN"
#else // !MAKEHUAGAO #else // !MAKEHUAGAO
"ZhibenScan G200 TWAIN" "ZhibenScan G200 TWAIN"
#endif #endif
#endif #endif
#elif defined G300 // G200 #elif defined G300 // G200
#ifdef MAKEHUAGAO #ifdef MAKEHUAGAO
"HUAGOSCAN G300 TWAIN" "HUAGOSCAN G300 TWAIN"
#elif defined LANXUM //!LANXUM #elif defined LANXUM //!LANXUM
"LANXUMSCAN G42S TWAIN" "LANXUMSCAN G42S TWAIN"
#else // !MAKEHUAGAO #else // !MAKEHUAGAO
"ZhibenScan G300 TWAIN" "ZhibenScan G300 TWAIN"
#endif #endif
#elif defined(G400) // G200 #elif defined(G400) // G200
#ifdef MAKEHUAGAO #ifdef MAKEHUAGAO
"HUAGOSCAN G400 TWAIN" "HUAGOSCAN G400 TWAIN"
#elif defined LANXUM //!LANXUM #elif defined LANXUM //!LANXUM
"LANXUMSCAN G52S TWAIN" "LANXUMSCAN G52S TWAIN"
#else // !MAKEHUAGAO #else // !MAKEHUAGAO
"ZhibenScan G400 TWAIN" "ZhibenScan G400 TWAIN"
#endif #endif
#endif #endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
@ -273,20 +273,20 @@ static std::map<WORD, WORD> DeviceID{
static void DeleteWnd(CDialog* pWnd) { static void DeleteWnd(CDialog* pWnd) {
if (pWnd && pWnd->GetSafeHwnd()) { if (pWnd && pWnd->GetSafeHwnd()) {
if(pWnd->m_hWnd) if (pWnd->m_hWnd)
DestroyWindow(pWnd->m_hWnd); DestroyWindow(pWnd->m_hWnd);
} }
} }
static std::unique_ptr<CTwainUI, void(*)(CDialog*)> guiTwain(nullptr, DeleteWnd); static std::unique_ptr<CTwainUI, void(*)(CDialog*)> guiTwain(nullptr, DeleteWnd);
static std::unique_ptr<Cmsgbox> msgbox; //static std::unique_ptr<Cmsgbox> msgbox;
#if TWPP_DETAIL_OS_WIN #if TWPP_DETAIL_OS_WIN
static std::unique_ptr<CDialog, void(*)(CDialog*)> guiBridge(nullptr, DeleteWnd); static std::unique_ptr<CDialog, void(*)(CDialog*)> guiBridge(nullptr, DeleteWnd);
#endif #endif
//static std::unique_ptr<CIndicatorDlg, void(*)(CDialog*)> guiIndicator(nullptr, DeleteWnd); //static std::unique_ptr<CIndicatorDlg, void(*)(CDialog*)> guiIndicator(nullptr, DeleteWnd);
static CIndicatorDlg* guiIndicator =NULL; static CIndicatorDlg* guiIndicator = NULL;
//#define HG_VIRTUAL //#define HG_VIRTUAL
#ifndef HG_VIRTUAL #ifndef HG_VIRTUAL
static std::unique_ptr<IScanner> scanner; //(new GScanO200()); static std::unique_ptr<IScanner> scanner; //(new GScanO200());
@ -302,7 +302,7 @@ static std::unique_ptr<IScanner> scanner(new GScanVirtual());
static std::once_flag oc; static std::once_flag oc;
HuagaoDs::HuagaoDs() HuagaoDs::HuagaoDs()
: m_scanparam(new GScanCap) : m_scanparam(new GScanCap)
,bmpData(new std::vector<unsigned char>) , bmpData(new std::vector<unsigned char>)
, hMutex(NULL) , hMutex(NULL)
{ {
std::call_once(oc, [&]() { log4cplus::Initializer(); }); std::call_once(oc, [&]() { log4cplus::Initializer(); });
@ -360,23 +360,23 @@ void HuagaoDs::showmsg(std::string caption, std::string text, int retcode)
num = scanner->get_aquire_image_count() * 2 - scanner->get_updata_image_count(); num = scanner->get_aquire_image_count() * 2 - scanner->get_updata_image_count();
} }
if ((losemun != 0) || (num != 0)) { if ((losemun != 0) || (num != 0)) {
text += "进纸"+to_string(scanner->get_lose_image_num()+scanner->get_aquire_image_count())+ text += "进纸" + to_string(scanner->get_lose_image_num() + scanner->get_aquire_image_count()) +
",扫描"+to_string(scanner->get_aquire_image_count()) +",上传"+to_string(scanner->get_updata_image_count())+ ",扫描" + to_string(scanner->get_aquire_image_count()) + ",上传" + to_string(scanner->get_updata_image_count()) +
",扫描相差"+to_string(losemun) + "份文件,上传相差"+to_string(num)+"份文件!"; ",扫描相差" + to_string(losemun) + "份文件,上传相差" + to_string(num) + "份文件!";
scanner->set_lose_image_num(0); scanner->set_lose_image_num(0);
} }
} }
ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString((text+" "+caption).c_str()), NULL, SW_HIDE); ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString((text + " " + caption).c_str()), NULL, SW_HIDE);
} }
HuagaoDs::~HuagaoDs() HuagaoDs::~HuagaoDs()
{ {
if (memoryinfo.get()){ if (memoryinfo.get()) {
m_memoryfalg = false; m_memoryfalg = false;
if (memoryinfo->joinable()) if (memoryinfo->joinable())
memoryinfo->join(); memoryinfo->join();
} }
if(scanner.get()) if (scanner.get())
scanner.reset(); scanner.reset();
} }
@ -392,7 +392,7 @@ Result HuagaoDs::call(const Identity& origin, DataGroup dg, Dat dat, Msg msg, vo
return Base::call(origin, dg, dat, msg, data); return Base::call(origin, dg, dat, msg, data);
} }
catch (const CapabilityException& e) { catch (const CapabilityException& e) {
FileTools::writelog(log_ERROR,e.what()); FileTools::writelog(log_ERROR, e.what());
return badValue(); return badValue();
} }
} }
@ -632,7 +632,7 @@ Result CapSupGetAllReset(Msg msg, Capability& data, std::initializer_list<T2> va
return { ReturnCode::Failure, ConditionCode::CapBadOperation }; return { ReturnCode::Failure, ConditionCode::CapBadOperation };
} }
} }
template<typename T1,typename T2 ,Twpp::CapType cap> template<typename T1, typename T2, Twpp::CapType cap>
Result CapSupGetAllReset(Msg msg, Capability& data, T1& currvalue, T2 defaultvalue) { Result CapSupGetAllReset(Msg msg, Capability& data, T1& currvalue, T2 defaultvalue) {
switch (msg) { switch (msg) {
case Msg::Get: case Msg::Get:
@ -655,12 +655,12 @@ Result CapSupGetAllResetEx(Msg msg, Capability& data, std::initializer_list<T2>
data = Capability::createEnumeration<T2>(cap, values, currindex, defaultindex); data = Capability::createEnumeration<T2>(cap, values, currindex, defaultindex);
return { ReturnCode::Success, ConditionCode::Success }; return { ReturnCode::Success, ConditionCode::Success };
case Msg::GetCurrent: case Msg::GetCurrent:
data = Capability::createOneValue<T2>(cap,(T2)currvalue); data = Capability::createOneValue<T2>(cap, (T2)currvalue);
return { ReturnCode::Success, ConditionCode::Success }; return { ReturnCode::Success, ConditionCode::Success };
case Msg::Reset: case Msg::Reset:
case Msg::GetDefault: case Msg::GetDefault:
currvalue = (T1)defaultvalue; currvalue = (T1)defaultvalue;
data = Capability::createOneValue<T2>(cap,defaultvalue); data = Capability::createOneValue<T2>(cap, defaultvalue);
return { ReturnCode::Success, ConditionCode::Success }; return { ReturnCode::Success, ConditionCode::Success };
default: default:
return { ReturnCode::Failure, ConditionCode::CapBadOperation }; return { ReturnCode::Failure, ConditionCode::CapBadOperation };
@ -671,12 +671,12 @@ Result CapSupGetAllResetEx(Msg msg, Capability& data, T1& currvalue, T2 defaultv
switch (msg) { switch (msg) {
case Msg::Get: case Msg::Get:
case Msg::GetCurrent: case Msg::GetCurrent:
data = Capability::createOneValue<T2>(cap,(T2)currvalue); data = Capability::createOneValue<T2>(cap, (T2)currvalue);
return { ReturnCode::Success, ConditionCode::Success }; return { ReturnCode::Success, ConditionCode::Success };
case Msg::Reset: case Msg::Reset:
case Msg::GetDefault: case Msg::GetDefault:
currvalue = (T1)defaultvalue; currvalue = (T1)defaultvalue;
data = Capability::createOneValue<T2>(cap,defaultvalue); data = Capability::createOneValue<T2>(cap, defaultvalue);
return { ReturnCode::Success, ConditionCode::Success }; return { ReturnCode::Success, ConditionCode::Success };
default: default:
return { ReturnCode::Failure, ConditionCode::CapBadOperation }; return { ReturnCode::Failure, ConditionCode::CapBadOperation };
@ -762,7 +762,7 @@ void HuagaoDs::dogear_callback(int indexpaper)
CString text; CString text;
text.Format(_T("74 %d"), indexpaper); text.Format(_T("74 %d"), indexpaper);
//ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), text, NULL, SW_HIDE); //ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), text, NULL, SW_HIDE);
showmsg("警告",""+to_string(indexpaper)+"检测到折角!"); showmsg("警告", "" + to_string(indexpaper) + "检测到折角!");
scanner->Stop_scan(); scanner->Stop_scan();
//scanner->reset(); //scanner->reset();
scanner->ResetScanner(); scanner->ResetScanner();
@ -779,7 +779,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
showmsg("警告", msgs[(UsbSupported)202]); showmsg("警告", msgs[(UsbSupported)202]);
return { ReturnCode::Failure, ConditionCode::CapBadOperation }; return { ReturnCode::Failure, ConditionCode::CapBadOperation };
} }
auto usblist= UsbScan_List::find_all_usb(); auto usblist = UsbScan_List::find_all_usb();
if (!usblist.empty()) if (!usblist.empty())
{ {
for each (auto & usb in usblist) for each (auto & usb in usblist)
@ -799,7 +799,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
} }
} }
} }
FileTools::writelog(log_INFO, "open ds find device vid="+to_string(vid)+"\tpid="+to_string(pid)); FileTools::writelog(log_INFO, "open ds find device vid=" + to_string(vid) + "\tpid=" + to_string(pid));
m_haveError = false; m_haveError = false;
updataGscanCap(); updataGscanCap();
bmpData->resize(sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)); bmpData->resize(sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER));
@ -842,7 +842,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
// caps -> has handler for each specific cap // caps -> has handler for each specific cap
m_query[CapType::SupportedCaps] = msgSupportGetAll; m_query[CapType::SupportedCaps] = msgSupportGetAll;
m_caps[CapType::SupportedCaps] = [this](Msg msg, Capability& data) { m_caps[CapType::SupportedCaps] = [this](Msg msg, Capability& data) {
if ((msg == Msg::Get) || (Msg::GetCurrent == msg) || (Msg::GetDefault == msg)){ if ((msg == Msg::Get) || (Msg::GetCurrent == msg) || (Msg::GetDefault == msg)) {
data = Capability::createArray<CapType::SupportedCaps>(m_caps.size()); data = Capability::createArray<CapType::SupportedCaps>(m_caps.size());
auto arr = data.array<CapType::SupportedCaps>(); auto arr = data.array<CapType::SupportedCaps>();
UInt32 i = 0; UInt32 i = 0;
@ -878,7 +878,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_caps[CapType::XferCount] = [this](Msg msg, Capability& data) -> Result { m_caps[CapType::XferCount] = [this](Msg msg, Capability& data) -> Result {
if (msg == Msg::Set) { if (msg == Msg::Set) {
auto item = data.currentItem<Int16>(); auto item = data.currentItem<Int16>();
if (item > 65535 || item < -1||item == 0) { if (item > 65535 || item < -1 || item == 0) {
return badValue(); return badValue();
} }
m_scanparam->scannum = item; m_scanparam->scannum = item;
@ -911,9 +911,9 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_query[CapType::IBitDepth] = msgSupportGetAllSetReset; m_query[CapType::IBitDepth] = msgSupportGetAllSetReset;
m_caps[CapType::IBitDepth] = [this](Msg msg, Capability& data) -> Result { m_caps[CapType::IBitDepth] = [this](Msg msg, Capability& data) -> Result {
if( Msg::Set==msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<CapType::IBitDepth>(); auto mech = data.currentItem<CapType::IBitDepth>();
if (((mech == 1) && (m_scanparam->pixtype == 0))|| ((mech == 8) && (m_scanparam->pixtype == 1)) || ((mech == 24) && (m_scanparam->pixtype == 2))) { if (((mech == 1) && (m_scanparam->pixtype == 0)) || ((mech == 8) && (m_scanparam->pixtype == 1)) || ((mech == 24) && (m_scanparam->pixtype == 2))) {
m_iBitdepth = (UINT16)mech; m_iBitdepth = (UINT16)mech;
return success(); return success();
} }
@ -939,17 +939,17 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_query[CapType::IPixelType] = msgSupportGetAllSetReset; m_query[CapType::IPixelType] = msgSupportGetAllSetReset;
m_caps[CapType::IPixelType] = [this](Msg msg, Capability& data) -> Result { m_caps[CapType::IPixelType] = [this](Msg msg, Capability& data) -> Result {
if( Msg::Set==msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<CapType::IPixelType>(); auto mech = data.currentItem<CapType::IPixelType>();
if (mech == PixelType::Rgb || mech == PixelType::Gray || mech == PixelType::BlackWhite) if (mech == PixelType::Rgb || mech == PixelType::Gray || mech == PixelType::BlackWhite)
{ {
m_scanparam->pixtype = (int)mech; m_scanparam->pixtype = (int)mech;
if (m_scanparam->pixtype == (int)PixelType::Rgb){ if (m_scanparam->pixtype == (int)PixelType::Rgb) {
m_scanparam->filter = (BYTE)Filter::None; m_scanparam->filter = (BYTE)Filter::None;
m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_None; m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_None;
m_scanparam->automaticcolor = FALSE; m_scanparam->automaticcolor = FALSE;
} }
else{ else {
m_scanparam->multi_output_red = 0;//非彩色模式下多流输出不可用 m_scanparam->multi_output_red = 0;//非彩色模式下多流输出不可用
//if (m_scanparam->pixtype == (int)PixelType::BlackWhite) //if (m_scanparam->pixtype == (int)PixelType::BlackWhite)
// m_scanparam->sharpen = SharpenBlur::Sharpen_None; // m_scanparam->sharpen = SharpenBlur::Sharpen_None;
@ -975,7 +975,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_caps[CapType::IAutomaticColorEnabled] = [this](Msg msg, Capability& data)->Result { m_caps[CapType::IAutomaticColorEnabled] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<CapType::IAutomaticColorEnabled>(); auto mech = data.currentItem<CapType::IAutomaticColorEnabled>();
if (mech){ if (mech) {
m_scanparam->automaticcolor = TRUE; m_scanparam->automaticcolor = TRUE;
m_scanparam->filter = (BYTE)Filter::None; m_scanparam->filter = (BYTE)Filter::None;
m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_None; m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_None;
@ -993,8 +993,8 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_caps[CapType::IAutomaticColorNonColorPixelType] = [this](Msg msg, Capability& data)->Result { m_caps[CapType::IAutomaticColorNonColorPixelType] = [this](Msg msg, Capability& data)->Result {
if (msg == Msg::Set) { if (msg == Msg::Set) {
auto mech = data.currentItem<CapType::IAutomaticColorNonColorPixelType>(); auto mech = data.currentItem<CapType::IAutomaticColorNonColorPixelType>();
if (m_scanparam->automaticcolor == TRUE){ if (m_scanparam->automaticcolor == TRUE) {
if ((UInt16)mech == 0 || (UInt16)mech == 1){ if ((UInt16)mech == 0 || (UInt16)mech == 1) {
m_scanparam->automaticcolortype = (UInt16)mech; m_scanparam->automaticcolortype = (UInt16)mech;
return success(); return success();
} }
@ -1072,23 +1072,23 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_query[CapType::ISupportedSizes] = msgSupportGetAllSetReset; m_query[CapType::ISupportedSizes] = msgSupportGetAllSetReset;
m_caps[CapType::ISupportedSizes] = [this](Msg msg, Capability& data) { m_caps[CapType::ISupportedSizes] = [this](Msg msg, Capability& data) {
if (Msg::Set == msg) { if (Msg::Set == msg) {
if(m_scanparam->is_autocrop) if (m_scanparam->is_autocrop)
return success(); return success();
auto paper = data.currentItem<UInt16>(); auto paper = data.currentItem<UInt16>();
if (std::distance(paperSizeList.begin(), std::find(paperSizeList.begin(), paperSizeList.end(), paper)) == paperSizeList.size()) if (std::distance(paperSizeList.begin(), std::find(paperSizeList.begin(), paperSizeList.end(), paper)) == paperSizeList.size())
return badValue(); return badValue();
else { else {
m_scanparam->papertype = (BYTE)paper; m_scanparam->papertype = (BYTE)paper;
if (paper == (BYTE)PaperSize::None || paper == (BYTE)PaperSize::UsStatement){ if (paper == (BYTE)PaperSize::None || paper == (BYTE)PaperSize::UsStatement) {
m_scanparam->paperAlign = PaperAlign::Rot0; m_scanparam->paperAlign = PaperAlign::Rot0;
m_scanparam->en_sizecheck = 0; m_scanparam->en_sizecheck = 0;
} }
if (paper == (BYTE)PaperSize::UsStatement){ if (paper == (BYTE)PaperSize::UsStatement) {
m_autosize = (UInt16)AutoSize::None; m_autosize = (UInt16)AutoSize::None;
m_autoboarderdetcet = false; m_autoboarderdetcet = false;
m_scanparam->is_autocrop = 0; m_scanparam->is_autocrop = 0;
} }
else{ else {
m_autosize = (paper == (BYTE)PaperSize::None) ? (UInt16)AutoSize::Auto : (UInt16)AutoSize::None; m_autosize = (paper == (BYTE)PaperSize::None) ? (UInt16)AutoSize::Auto : (UInt16)AutoSize::None;
m_autoboarderdetcet = paper == (BYTE)PaperSize::None; m_autoboarderdetcet = paper == (BYTE)PaperSize::None;
m_scanparam->is_autocrop = paper == (BYTE)PaperSize::None ? 1 : 0; m_scanparam->is_autocrop = paper == (BYTE)PaperSize::None ? 1 : 0;
@ -1108,7 +1108,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
(PaperSize)PaperSizeEx::K8,(PaperSize)PaperSizeEx::K16,(PaperSize)PaperSizeEx::Trigeminy (PaperSize)PaperSizeEx::K8,(PaperSize)PaperSizeEx::K16,(PaperSize)PaperSizeEx::Trigeminy
#endif #endif
#endif // #endif //
},m_scanparam->papertype, PaperSize::None, }, m_scanparam->papertype, PaperSize::None,
std::distance(paperSizeList.begin(), std::find(paperSizeList.begin(), paperSizeList.end(), m_scanparam->papertype)) == paperSizeList.size() ? 0 : std::distance(paperSizeList.begin(), std::distance(paperSizeList.begin(), std::find(paperSizeList.begin(), paperSizeList.end(), m_scanparam->papertype)) == paperSizeList.size() ? 0 : std::distance(paperSizeList.begin(),
std::find(paperSizeList.begin(), paperSizeList.end(), m_scanparam->papertype)), std::find(paperSizeList.begin(), paperSizeList.end(), m_scanparam->papertype)),
std::distance(paperSizeList.begin(), std::find(paperSizeList.begin(), paperSizeList.end(), 0))); std::distance(paperSizeList.begin(), std::find(paperSizeList.begin(), paperSizeList.end(), 0)));
@ -1118,7 +1118,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
#ifndef ISG100 #ifndef ISG100
m_query[(CapType)(CapTypeEx::TwEx_SizeDetect)] = msgSupportGetAllSetReset; m_query[(CapType)(CapTypeEx::TwEx_SizeDetect)] = msgSupportGetAllSetReset;
m_caps[(CapType)(CapTypeEx::TwEx_SizeDetect)] = [this](Msg msg, Capability& data)->Result { m_caps[(CapType)(CapTypeEx::TwEx_SizeDetect)] = [this](Msg msg, Capability& data)->Result {
if( Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<Bool>(); auto mech = data.currentItem<Bool>();
m_scanparam->en_sizecheck = mech; m_scanparam->en_sizecheck = mech;
return success(); return success();
@ -1130,7 +1130,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_query[CapType::IOrientation] = msgSupportGetAllSetReset; m_query[CapType::IOrientation] = msgSupportGetAllSetReset;
m_caps[CapType::IOrientation] = [this](Msg msg, Capability& data) -> Result { m_caps[CapType::IOrientation] = [this](Msg msg, Capability& data) -> Result {
if( Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<CapType::IOrientation>(); auto mech = data.currentItem<CapType::IOrientation>();
if (mech == Orientation::Landscape || mech == Orientation::Portrait) { if (mech == Orientation::Landscape || mech == Orientation::Portrait) {
m_scanparam->paperAlign = (PaperAlign)mech; m_scanparam->paperAlign = (PaperAlign)mech;
@ -1143,11 +1143,11 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_query[CapType::IRotation] = msgSupportGetAllSetReset; m_query[CapType::IRotation] = msgSupportGetAllSetReset;
m_caps[CapType::IRotation] = [this](Msg msg, Capability& data) -> Result { m_caps[CapType::IRotation] = [this](Msg msg, Capability& data) -> Result {
if( Msg::Set == msg){ if (Msg::Set == msg) {
auto res = data.currentItem<Fix32>(); auto res = data.currentItem<Fix32>();
if (std::distance(imageRotateList.begin(), std::find(imageRotateList.begin(), imageRotateList.end(), res)) == imageRotateList.size()) if (std::distance(imageRotateList.begin(), std::find(imageRotateList.begin(), imageRotateList.end(), res)) == imageRotateList.size())
return badValue(); return badValue();
else{ else {
m_scanparam->imageRotateDegree = (float)res; m_scanparam->imageRotateDegree = (float)res;
if (res != 0.0f) if (res != 0.0f)
m_scanparam->is_autotext = 0; m_scanparam->is_autotext = 0;
@ -1155,7 +1155,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
} }
} }
return CapSupGetAllReset<float, Fix32, CapType::IRotation>(msg, data, { Fix32(0.0f),Fix32(90.0f),Fix32(180.0f),Fix32(270.0f) }, m_scanparam->imageRotateDegree, Fix32(0.0), return CapSupGetAllReset<float, Fix32, CapType::IRotation>(msg, data, { Fix32(0.0f),Fix32(90.0f),Fix32(180.0f),Fix32(270.0f) }, m_scanparam->imageRotateDegree, Fix32(0.0),
std::distance(imageRotateList.begin(), std::find(imageRotateList.begin(), imageRotateList.end(), m_scanparam->imageRotateDegree)),0); std::distance(imageRotateList.begin(), std::find(imageRotateList.begin(), imageRotateList.end(), m_scanparam->imageRotateDegree)), 0);
}; };
#ifndef G200 #ifndef G200
@ -1184,7 +1184,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
//m_caps[(CapType)(CapTypeEx::TwEx_HardwareVersion)] = std::bind(oneValGetString, _1, _2, scanner->GetFWVersion()); //m_caps[(CapType)(CapTypeEx::TwEx_HardwareVersion)] = std::bind(oneValGetString, _1, _2, scanner->GetFWVersion());
m_caps[(CapType)(CapTypeEx::TwEx_ENCODE)] = [this](Msg msg, Capability& data)->Result { m_caps[(CapType)(CapTypeEx::TwEx_ENCODE)] = [this](Msg msg, Capability& data)->Result {
Str255 str; Str255 str;
str.setData(scanner->get_scannercode().c_str(),32); str.setData(scanner->get_scannercode().c_str(), 32);
return CapSupGetAllEx<Str255, (CapType)CapTypeEx::TwEx_ENCODE>(msg, data, str, str); return CapSupGetAllEx<Str255, (CapType)CapTypeEx::TwEx_ENCODE>(msg, data, str, str);
}; };
#endif #endif
@ -1195,7 +1195,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_query[CapType::Indicators] = msgSupportGetAllSetReset; m_query[CapType::Indicators] = msgSupportGetAllSetReset;
m_caps[CapType::Indicators] = [this](Msg msg, Capability& data) -> Result { m_caps[CapType::Indicators] = [this](Msg msg, Capability& data) -> Result {
if (Msg::Set == msg){ if (Msg::Set == msg) {
auto show = data.currentItem<CapType::Indicators>(); auto show = data.currentItem<CapType::Indicators>();
m_bIndicator = show; m_bIndicator = show;
return success(); return success();
@ -1252,7 +1252,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
}; };
m_query[CapType::IImageFileFormat] = msgSupportGetAllSetReset; m_query[CapType::IImageFileFormat] = msgSupportGetAllSetReset;
m_caps[CapType::IImageFileFormat] = [this](Msg msg, Capability& data) -> Result { m_caps[CapType::IImageFileFormat] = [this](Msg msg, Capability& data) -> Result {
if (Msg::Set == msg){ if (Msg::Set == msg) {
auto mech = data.currentItem<CapType::IImageFileFormat>(); auto mech = data.currentItem<CapType::IImageFileFormat>();
if (mech == ImageFileFormat::Bmp || if (mech == ImageFileFormat::Bmp ||
mech == ImageFileFormat::Tiff || mech == ImageFileFormat::Tiff ||
@ -1263,8 +1263,8 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
else else
return badValue(); return badValue();
} }
return CapSupGetAllReset < ImageFileFormat, ImageFileFormat , CapType::IImageFileFormat> (msg, data, { ImageFileFormat::Bmp, ImageFileFormat::Tiff,ImageFileFormat::Jfif }, return CapSupGetAllReset < ImageFileFormat, ImageFileFormat, CapType::IImageFileFormat>(msg, data, { ImageFileFormat::Bmp, ImageFileFormat::Tiff,ImageFileFormat::Jfif },
m_capImageFileFormat, ImageFileFormat::Bmp,m_capImageFileFormat == ImageFileFormat::Bmp ? 0 : (m_capImageFileFormat == ImageFileFormat::Tiff ? 1 : 2), 0); m_capImageFileFormat, ImageFileFormat::Bmp, m_capImageFileFormat == ImageFileFormat::Bmp ? 0 : (m_capImageFileFormat == ImageFileFormat::Tiff ? 1 : 2), 0);
}; };
//custom define //custom define
@ -1275,7 +1275,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_scanparam->autodescrew = (bool)atuodsw; m_scanparam->autodescrew = (bool)atuodsw;
return success(); return success();
} }
return CapSupGetAllReset<BYTE, bool, CapType::IAutomaticDeskew>(msg,data, m_scanparam->autodescrew,true); return CapSupGetAllReset<BYTE, bool, CapType::IAutomaticDeskew>(msg, data, m_scanparam->autodescrew, true);
}; };
m_query[(CapType)(CapTypeEx::TwEx_SwitchFrontBack)] = msgSupportGetAllSetReset; m_query[(CapType)(CapTypeEx::TwEx_SwitchFrontBack)] = msgSupportGetAllSetReset;
@ -1320,19 +1320,19 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_caps[CapType::IAutoSize] = [this](Msg msg, Capability& data)->Result { m_caps[CapType::IAutoSize] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto autosize = data.currentItem<CapType::IAutoSize>(); auto autosize = data.currentItem<CapType::IAutoSize>();
if (autosize == AutoSize::Auto){ if (autosize == AutoSize::Auto) {
if(m_scanparam->papertype==(BYTE)PaperSize::UsStatement){ if (m_scanparam->papertype == (BYTE)PaperSize::UsStatement) {
m_scanparam->is_autocrop = 0; m_scanparam->is_autocrop = 0;
m_autoboarderdetcet = false; m_autoboarderdetcet = false;
} }
else{ else {
m_scanparam->is_autocrop = 1; m_scanparam->is_autocrop = 1;
m_scanparam->papertype = (BYTE)Twpp::PaperSize::None; m_scanparam->papertype = (BYTE)Twpp::PaperSize::None;
m_scanparam->paperAlign = PaperAlign::Rot0; m_scanparam->paperAlign = PaperAlign::Rot0;
m_autoboarderdetcet = true; m_autoboarderdetcet = true;
} }
} }
else{ else {
m_autoboarderdetcet = false; m_autoboarderdetcet = false;
m_scanparam->is_autocrop = 0; m_scanparam->is_autocrop = 0;
} }
@ -1346,15 +1346,15 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_caps[CapType::IAutomaticBorderDetection] = [this](Msg msg, Capability& data)->Result { m_caps[CapType::IAutomaticBorderDetection] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto autodetectborder = data.currentItem<CapType::IAutomaticBorderDetection>(); auto autodetectborder = data.currentItem<CapType::IAutomaticBorderDetection>();
if (autodetectborder){ if (autodetectborder) {
if(m_scanparam->papertype!=(BYTE)PaperSize::UsStatement){ if (m_scanparam->papertype != (BYTE)PaperSize::UsStatement) {
m_scanparam->is_autocrop = true; m_scanparam->is_autocrop = true;
m_scanparam->papertype = (BYTE)Twpp::PaperSize::None; m_scanparam->papertype = (BYTE)Twpp::PaperSize::None;
m_scanparam->paperAlign = PaperAlign::Rot0; m_scanparam->paperAlign = PaperAlign::Rot0;
m_autosize = (UInt16)AutoSize::Auto; m_autosize = (UInt16)AutoSize::Auto;
} }
} }
else{ else {
m_autosize = (UInt16)AutoSize::None; m_autosize = (UInt16)AutoSize::None;
} }
m_autoboarderdetcet = autodetectborder; m_autoboarderdetcet = autodetectborder;
@ -1383,14 +1383,14 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto autocrop = data.currentItem<Int32>(); auto autocrop = data.currentItem<Int32>();
m_scanparam->en_fold = (Int32)autocrop; m_scanparam->en_fold = (Int32)autocrop;
if ((UInt16)autocrop != 0){ if ((UInt16)autocrop != 0) {
m_scanparam->is_duplex = 1; m_scanparam->is_duplex = 1;
m_scanparam->autodescrew = 1;//合并可用时 默认自动纠偏 m_scanparam->autodescrew = 1;//合并可用时 默认自动纠偏
m_scanparam->is_autodiscradblank_normal = m_scanparam->is_autodiscradblank_vince = 0; m_scanparam->is_autodiscradblank_normal = m_scanparam->is_autodiscradblank_vince = 0;
} }
return success(); return success();
} }
return CapSupGetAllResetEx<BYTE, Int32, (CapType)CapTypeEx::TwEx_EnFold>(msg, data, { 0,1 }, m_scanparam->en_fold, 0,m_scanparam->en_fold ? 1 : 0, 0); return CapSupGetAllResetEx<BYTE, Int32, (CapType)CapTypeEx::TwEx_EnFold>(msg, data, { 0,1 }, m_scanparam->en_fold, 0, m_scanparam->en_fold ? 1 : 0, 0);
}; };
m_query[CapType::IAutoDiscardBlankPages] = msgSupportGetAllSetReset; m_query[CapType::IAutoDiscardBlankPages] = msgSupportGetAllSetReset;
@ -1477,7 +1477,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_scanparam->noise = mech; m_scanparam->noise = mech;
return success(); return success();
} }
return CapSupGetAllResetEx<int, UInt8, (CapType)CapTypeEx::TwEx_CropNoise>(msg, data, m_scanparam->noise, 40); return CapSupGetAllResetEx<int, UInt8, (CapType)CapTypeEx::TwEx_CropNoise>(msg, data, m_scanparam->noise, 8);
}; };
//自动裁切和纠偏的二值化阀值 //自动裁切和纠偏的二值化阀值
m_query[(CapType)(CapTypeEx::TwEx_CroporDesaskewThreshold)] = msgSupportGetAllSetReset; m_query[(CapType)(CapTypeEx::TwEx_CroporDesaskewThreshold)] = msgSupportGetAllSetReset;
@ -1580,7 +1580,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
auto mech = data.currentItem<CapType::IFilter>(); auto mech = data.currentItem<CapType::IFilter>();
if (mech == Filter::None || mech == Filter::Red || mech == Filter::Green || mech == Filter::Blue) { if (mech == Filter::None || mech == Filter::Red || mech == Filter::Green || mech == Filter::Blue) {
m_scanparam->filter = (BYTE)mech; m_scanparam->filter = (BYTE)mech;
if (mech != Filter::None){ if (mech != Filter::None) {
m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_None; m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_None;
} }
return success(); return success();
@ -1595,28 +1595,30 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_caps[(CapType)(CapTypeEx::TwEx_IEnhanceColor)] = [this](Msg msg, Capability& data)->Result { m_caps[(CapType)(CapTypeEx::TwEx_IEnhanceColor)] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<Int16>(); auto mech = data.currentItem<Int16>();
if (m_scanparam->pixtype == (BYTE)PixelType::Rgb){ if (m_scanparam->pixtype == (int)PixelType::Rgb)
{
m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_None; m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_None;
m_scanparam->filter = (BYTE)Filter::None;
return badValue();
} }
else{ else
{
if (mech == Enchace_Color::Enhance_None || mech == Enchace_Color::Enhance_Red || mech == Enchace_Color::Enhance_Green || mech == Enchace_Color::Enhance_Blue) if (mech == Enchace_Color::Enhance_None || mech == Enchace_Color::Enhance_Red || mech == Enchace_Color::Enhance_Green || mech == Enchace_Color::Enhance_Blue)
{ {
m_scanparam->enhance_color = (BYTE)mech; m_scanparam->enhance_color = (BYTE)mech;
if (mech != (BYTE)Enchace_Color::Enhance_None) if (mech != (BYTE)Enchace_Color::Enhance_None)
m_scanparam->filter = (BYTE)Filter::None; m_scanparam->filter = (BYTE)Filter::None;
if (m_scanparam->pixtype == (int)PixelType::BlackWhite) if (m_scanparam->pixtype == (int)PixelType::BlackWhite)//黑白默认开启红色增强 其他增强不生效
{ {
if (m_scanparam->filter == (BYTE)Filter::None && m_scanparam->enhance_color == (BYTE)Enchace_Color::Enhance_None) if (m_scanparam->enhance_color == (BYTE)Enchace_Color::Enhance_None)
{ {
m_scanparam->filter = (BYTE)Filter::None;
m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_Red; m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_Red;
} }
} }
return success(); return success();
} }
} }
return badValue();
} }
return CapSupGetAllResetEx<BYTE, Enchace_Color, (CapType)CapTypeEx::TwEx_IEnhanceColor>(msg, data, { Enchace_Color::Enhance_None,Enchace_Color::Enhance_Red,Enchace_Color::Enhance_Green,Enchace_Color::Enhance_Blue }, m_scanparam->enhance_color, Enchace_Color::Enhance_None, m_scanparam->enhance_color, 0); return CapSupGetAllResetEx<BYTE, Enchace_Color, (CapType)CapTypeEx::TwEx_IEnhanceColor>(msg, data, { Enchace_Color::Enhance_None,Enchace_Color::Enhance_Red,Enchace_Color::Enhance_Green,Enchace_Color::Enhance_Blue }, m_scanparam->enhance_color, Enchace_Color::Enhance_None, m_scanparam->enhance_color, 0);
}; };
@ -1804,7 +1806,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_caps[(CapType)(CapTypeEx::TwEx_DogEarDelection)] = [this](Msg msg, Capability& data)->Result { m_caps[(CapType)(CapTypeEx::TwEx_DogEarDelection)] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<Bool>(); auto mech = data.currentItem<Bool>();
m_scanparam->is_dogeardetection= mech; m_scanparam->is_dogeardetection = mech;
return success(); return success();
} }
return CapSupGetAllResetEx<BYTE, Bool, (CapType)CapTypeEx::TwEx_DogEarDelection>(msg, data, m_scanparam->is_dogeardetection, FALSE); return CapSupGetAllResetEx<BYTE, Bool, (CapType)CapTypeEx::TwEx_DogEarDelection>(msg, data, m_scanparam->is_dogeardetection, FALSE);
@ -1852,7 +1854,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
} }
return CapSupGetAllResetEx<LowPowerMode, BYTE, (CapType)CapTypeEx::TwEx_LowPowerMode>(msg, data, return CapSupGetAllResetEx<LowPowerMode, BYTE, (CapType)CapTypeEx::TwEx_LowPowerMode>(msg, data,
{ LowPowerMode::Min_None,LowPowerMode::Min_5,LowPowerMode::Min_10,LowPowerMode::Min_20, LowPowerMode::Min_30, LowPowerMode::Min_60, LowPowerMode::Min_120, LowPowerMode::Min_240 }, { LowPowerMode::Min_None,LowPowerMode::Min_5,LowPowerMode::Min_10,LowPowerMode::Min_20, LowPowerMode::Min_30, LowPowerMode::Min_60, LowPowerMode::Min_120, LowPowerMode::Min_240 },
m_scanparam->hardwarecaps.lowpowermode, LowPowerMode::Min_30,(BYTE)m_scanparam->hardwarecaps.lowpowermode, 4); m_scanparam->hardwarecaps.lowpowermode, LowPowerMode::Min_30, (BYTE)m_scanparam->hardwarecaps.lowpowermode, 4);
}; };
#endif // LANXUM #endif // LANXUM
return success(); return success();
@ -1900,7 +1902,7 @@ Result HuagaoDs::pendingXfersEnd(const Identity&, PendingXfers& data) {
if (guiIndicator->GetSafeHwnd()) if (guiIndicator->GetSafeHwnd())
guiIndicator->ShowWindow(SW_HIDE); guiIndicator->ShowWindow(SW_HIDE);
if (ret != -1) { if (ret != -1) {
showmsg("警告", msgs[(UsbSupported)ret],ret); showmsg("警告", msgs[(UsbSupported)ret], ret);
FileTools::writelog(log_ERROR, msgs[(UsbSupported)ret]); FileTools::writelog(log_ERROR, msgs[(UsbSupported)ret]);
#ifndef G200 #ifndef G200
scanner->clear_hwerror(); scanner->clear_hwerror();
@ -1968,11 +1970,11 @@ Result HuagaoDs::setupMemXferGet(const Identity&, SetupMemXfer& data) {
} }
Result HuagaoDs::userInterfaceDisable(const Identity&, UserInterface& ui) { Result HuagaoDs::userInterfaceDisable(const Identity&, UserInterface& ui) {
if(guiTwain.get()) if (guiTwain.get())
guiTwain.reset(); guiTwain.reset();
#if TWPP_DETAIL_OS_WIN #if TWPP_DETAIL_OS_WIN
if(guiBridge.get()) if (guiBridge.get())
guiBridge.reset(); guiBridge.reset();
#endif #endif
@ -1993,7 +1995,7 @@ Result HuagaoDs::userInterfaceEnable(const Identity&, UserInterface& ui) {
if (MessageBox(NULL, L"检测到无纸,请添加纸张", L"提示", MB_YESNO | MB_SYSTEMMODAL) == IDNO) if (MessageBox(NULL, L"检测到无纸,请添加纸张", L"提示", MB_YESNO | MB_SYSTEMMODAL) == IDNO)
return seqError(); return seqError();
} }
//#endif // !G200 //#endif // !G200
auto ret = startScan(); auto ret = startScan();
@ -2018,7 +2020,7 @@ Result HuagaoDs::userInterfaceEnableUiOnly(const Identity&, UserInterface& ui) {
Result HuagaoDs::imageInfoGet(const Identity&, ImageInfo& data) { Result HuagaoDs::imageInfoGet(const Identity&, ImageInfo& data) {
// our image does not change // our image does not change
if (m_pendingXfers == 0|| bmpData->size()==0) if (m_pendingXfers == 0 || bmpData->size() == 0)
return success(); return success();
auto dib = header(); auto dib = header();
data.setBitsPerPixel(static_cast<Int16>(dib->biBitCount)); data.setBitsPerPixel(static_cast<Int16>(dib->biBitCount));
@ -2102,14 +2104,14 @@ Result HuagaoDs::imageMemXferGet(const Identity& origin, ImageMemXfer& data) {
if (m_compression == Compression::Group4) if (m_compression == Compression::Group4)
{ {
mat = cv::imdecode(*bmpData.get(), cv::IMREAD_GRAYSCALE); mat = cv::imdecode(*bmpData.get(), cv::IMREAD_GRAYSCALE);
G4Tiff gt(mat,G4Tiff::Mode::MemoryMode,"",120,m_scanparam->resolution_dst); G4Tiff gt(mat, G4Tiff::Mode::MemoryMode, "", 120, m_scanparam->resolution_dst);
gt.GetCompressedData(cmpdata); gt.GetCompressedData(cmpdata);
} }
data.setBytesPerRow(bpl); data.setBytesPerRow(bpl);
data.setColumns(static_cast<UInt32>(dib->biWidth)); data.setColumns(static_cast<UInt32>(dib->biWidth));
data.setRows(rows); data.setRows(rows);
data.setBytesWritten(m_compression==Compression::None?bpl*rows: cmpdata.size()); data.setBytesWritten(m_compression == Compression::None ? bpl * rows : cmpdata.size());
data.setXOffset(0); data.setXOffset(0);
data.setYOffset(m_memXferYOff); data.setYOffset(m_memXferYOff);
data.setCompression(m_compression); data.setCompression(m_compression);
@ -2172,7 +2174,7 @@ Result HuagaoDs::imageNativeXferGet(const Identity& id, ImageNativeXfer& data) {
bmpData.reset(new std::vector<unsigned char>); bmpData.reset(new std::vector<unsigned char>);
//FileTools::write_log("正在上传图片 ===> Twain transfered num of " + to_string(++xtfer) + " images"); //FileTools::write_log("正在上传图片 ===> Twain transfered num of " + to_string(++xtfer) + " images");
FileTools::writelog(log_INFO,"正在上传图片 ===> Twain transfered num of " + to_string(++xtfer) + " images"); FileTools::writelog(log_INFO, "正在上传图片 ===> Twain transfered num of " + to_string(++xtfer) + " images");
return { ReturnCode::XferDone, ConditionCode::Success }; return { ReturnCode::XferDone, ConditionCode::Success };
} }
@ -2259,7 +2261,7 @@ Twpp::Result HuagaoDs::imageFileXferGet(const Twpp::Identity& origin)
cv::Mat ims = cv::imdecode(*bmpData.get(), decodetype); cv::Mat ims = cv::imdecode(*bmpData.get(), decodetype);
if (m_compression == Compression::Group4&& m_fileXfer.format()==ImageFileFormat::Tiff) if (m_compression == Compression::Group4 && m_fileXfer.format() == ImageFileFormat::Tiff)
{ {
if (!ims.empty() && ims.channels() == 3) if (!ims.empty() && ims.channels() == 3)
cvtColor(ims, ims, cv::COLOR_BGR2GRAY); cvtColor(ims, ims, cv::COLOR_BGR2GRAY);
@ -2469,7 +2471,7 @@ Twpp::Result HuagaoDs::startScan()
//info += "\n\t m_scanparam->AutoCrop_threshold :" + to_string(m_scanparam->AutoCrop_threshold); //info += "\n\t m_scanparam->AutoCrop_threshold :" + to_string(m_scanparam->AutoCrop_threshold);
//info += "\n\t m_scanparam->is_convex :" + to_string(m_scanparam->is_convex); //info += "\n\t m_scanparam->is_convex :" + to_string(m_scanparam->is_convex);
//FileTools::write_log("D:\\1.txt",info); //FileTools::write_log("D:\\1.txt",info);
FileTools::writelog(log_INFO,"start scan"); FileTools::writelog(log_INFO, "start scan");
#ifndef G200 #ifndef G200
scanner->notifyscan(); scanner->notifyscan();
scanner->clear_hwerror(); scanner->clear_hwerror();
@ -2481,7 +2483,7 @@ Twpp::Result HuagaoDs::startScan()
if (m_bIndicator) { if (m_bIndicator) {
//!< cancel button push //!< cancel button push
auto stopFunc = [this]() { auto stopFunc = [this]() {
if(scanner.get()) if (scanner.get())
scanner->Stop_scan(); scanner->Stop_scan();
//guiIndicator.reset();//取消扫描 关闭进度指示器 //guiIndicator.reset();//取消扫描 关闭进度指示器
if (guiTwain.get()) { if (guiTwain.get()) {
@ -2530,7 +2532,7 @@ Twpp::Result HuagaoDs::startScan()
((CTwainUI*)(guiTwain.get()))->EnableID_OKorID_Cancel(true); ((CTwainUI*)(guiTwain.get()))->EnableID_OKorID_Cancel(true);
} }
if (retCode == 2) if (retCode == 2)
return { ReturnCode::Failure, ConditionCode::NoMedia};//无纸 return { ReturnCode::Failure, ConditionCode::NoMedia };//无纸
return seqError(); return seqError();
} }

Binary file not shown.