diff --git a/huagao/CAdvancedDLG.cpp b/huagao/CAdvancedDLG.cpp index cceb98fc..b5218f7f 100644 --- a/huagao/CAdvancedDLG.cpp +++ b/huagao/CAdvancedDLG.cpp @@ -42,7 +42,7 @@ BOOL CAdvancedDLG::OnInitDialog() CTabPageSSL::OnInitDialog(); m_Edit_noise.SetSlideLink(this, IDC_SLIDER_NOISE); - m_Edit_noise.SetParams(5, 50, 2); + m_Edit_noise.SetParams(1, 10, 1); m_Edit_noise.SetValue(noise); m_Edit_indent.SetSlideLink(this, IDC_SLIDER_INDENT); diff --git a/huagao/CFeedPaperPage.cpp b/huagao/CFeedPaperPage.cpp index c23128a4..d3c3e2ca 100644 --- a/huagao/CFeedPaperPage.cpp +++ b/huagao/CFeedPaperPage.cpp @@ -92,6 +92,7 @@ BEGIN_MESSAGE_MAP(CFeedPaperPage, CTabPageSSL) ON_BN_CLICKED(IDC_RDCONSISTSCAN, &CFeedPaperPage::OnBnClickedScanMode) ON_BN_CLICKED(IDC_RDSPECIFYSCANNUM, &CFeedPaperPage::OnBnClickedScanMode) ON_BN_CLICKED(IDC_CKSKEWDETECT, &CFeedPaperPage::OnBnClickedCkskewdetect) + ON_CBN_SELCHANGE(IDC_CMBORENTATION, &CFeedPaperPage::OnCbnSelchangeCmborentation) END_MESSAGE_MAP() BOOL CFeedPaperPage::PreTranslateMessage(MSG* pMsg) @@ -131,6 +132,16 @@ void CFeedPaperPage::FeedPaperPageUpdate(int val) // m_tempBtn->SetCheck(0); //BOOL enable = (val == 0 || val == 4); //m_tempBtn->EnableWindow(!enable); + comboxduplux = val; + if ((val > 0) && (val < 4) && (m_cmBoxOrentation.GetCurSel() != 4)) + { + ((CButton*)(GetDlgItem(IDC_CKBACKROTATION)))->EnableWindow(TRUE); + } + else + { + ((CButton*)(GetDlgItem(IDC_CKBACKROTATION)))->EnableWindow(FALSE); + ((CButton*)(GetDlgItem(IDC_CKBACKROTATION)))->SetCheck(FALSE); + } } void CFeedPaperPage::FeedAutoDescrewUpdate(int val) @@ -160,3 +171,10 @@ void CFeedPaperPage::OnBnClickedCkskewdetect() m_sldSkrewDetecttion.SetPos(3); m_sldSkrewDetecttion.EnableWindow(m_cbSkew); } + + +void CFeedPaperPage::OnCbnSelchangeCmborentation() +{ + // TODO: 在此添加控件通知处理程序代码 + FeedPaperPageUpdate(comboxduplux); +} diff --git a/huagao/CFeedPaperPage.h b/huagao/CFeedPaperPage.h index 4103edcb..53241242 100644 --- a/huagao/CFeedPaperPage.h +++ b/huagao/CFeedPaperPage.h @@ -42,6 +42,9 @@ protected: private: virtual BOOL PreTranslateMessage(MSG* pMsg); + int comboxduplux; /*std::function m_datachange;*/ +public: + afx_msg void OnCbnSelchangeCmborentation(); }; diff --git a/huagao/CImageProcPage.cpp b/huagao/CImageProcPage.cpp index ac507c3c..9a9cbde3 100644 --- a/huagao/CImageProcPage.cpp +++ b/huagao/CImageProcPage.cpp @@ -50,8 +50,10 @@ CImageProcPage::~CImageProcPage() { } -void CImageProcPage::ImageProcPageUpdate(int val,bool is_Crop) +void CImageProcPage::ImageProcPageUpdate(int val,int twss, int cmduplexsel,bool is_Crop) { + this->twss = twss; + this->cmduplexsel = cmduplexsel; CComboBox* m_temp = (CComboBox*)(GetDlgItem(IDC_CMBFILTER)); CButton* t_chMultiOutput = (CButton*)(GetDlgItem(IDC_CKMULTIOUTPUT)); CComboBox* m_temp_sharpen = (CComboBox*)(GetDlgItem(IDC_CMBSHARPEN)); @@ -63,6 +65,12 @@ void CImageProcPage::ImageProcPageUpdate(int val,bool is_Crop) { ((CButton*)GetDlgItem(IDC_ADVANCEDSET))->EnableWindow(false); } + if (val == 0) + GetDlgItem(IDC_CKHSVCORRECT)->EnableWindow(TRUE); + else { + GetDlgItem(IDC_CKHSVCORRECT)->EnableWindow(FALSE); + ((CButton*)GetDlgItem(IDC_CKHSVCORRECT))->SetCheck(FALSE); + } if (0 == val||val==3)//彩色 { m_temp->SetCurSel(0); @@ -88,11 +96,18 @@ void CImageProcPage::ImageProcPageUpdate(int val,bool is_Crop) m_edit_detachnoise.EnableWindow(false); m_slider_detachnoise.EnableWindow(false); } - //bool enabele = ival <= 1;//彩色或灰度 - //if (!enabele) { - // m_temp_sharpen->SetCurSel(0); - //} - //m_temp_sharpen->EnableWindow(enabele); +#ifndef G300 + if (twss == 19 || twss == 20 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck()) +#else + if (twss == 8 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck()) +#endif // !G300 + { + ((CButton*)GetDlgItem(IDC_CKCROPMODEL))->SetCheck(false); + ((CButton*)GetDlgItem(IDC_CKCROPMODEL))->EnableWindow(false); + } + else + ((CButton*)GetDlgItem(IDC_CKCROPMODEL))->EnableWindow(true); + } void CImageProcPage::ImageAutoDescrewUpdate(int val) @@ -130,7 +145,7 @@ BOOL CImageProcPage::OnInitDialog() m_edit_hole.SetValue(0.10); m_edit_detachnoise.SetSlideLink(this, IDC_SLIDERDETACHNOISE); - m_edit_detachnoise.SetParams(0, 50, 10); + m_edit_detachnoise.SetParams(10, 50, 10); m_edit_detachnoise.SetValue(detachnoise); ((CButton*)GetDlgItem(IDC_CHECKDETACHNOISE))->SetCheck(is_detachnoise); @@ -222,6 +237,17 @@ void CImageProcPage::OnBnClickedCkfillblackrect() { ((CButton*)GetDlgItem(IDC_ADVANCEDSET))->EnableWindow(false); } +#ifndef G300 + if (twss == 19 || twss == 20 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck()) +#else + if (twss == 8|| (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck()) +#endif // !G300 + { + ((CButton*)GetDlgItem(IDC_CKCROPMODEL))->SetCheck(false); + ((CButton*)GetDlgItem(IDC_CKCROPMODEL))->EnableWindow(false); + } + else + ((CButton*)GetDlgItem(IDC_CKCROPMODEL))->EnableWindow(true); } @@ -234,6 +260,17 @@ void CImageProcPage::OnBnClickedCkautodeskrew() { ((CButton*)GetDlgItem(IDC_ADVANCEDSET))->EnableWindow(false); } +#ifndef G300 + if (twss == 19 || twss == 20 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck()) +#else + if (twss == 8 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck()) +#endif // !G300 + { + ((CButton*)GetDlgItem(IDC_CKCROPMODEL))->SetCheck(false); + ((CButton*)GetDlgItem(IDC_CKCROPMODEL))->EnableWindow(false); + } + else + ((CButton*)GetDlgItem(IDC_CKCROPMODEL))->EnableWindow(true); } diff --git a/huagao/CImageProcPage.h b/huagao/CImageProcPage.h index 56bf947a..c0f9c6fa 100644 --- a/huagao/CImageProcPage.h +++ b/huagao/CImageProcPage.h @@ -27,7 +27,7 @@ public: BOOL m_ckbRemoveHole; BOOL m_ckbHSVCorrect; BOOL m_ckbDetachNoise; - void ImageProcPageUpdate(int val, bool is_Crop); + void ImageProcPageUpdate(int val,int twss,int cmduplexsel, bool is_Crop); void ImageAutoDescrewUpdate(int val); void EnableOutHoleCheckChanged(BOOL enable); void SetOutHoleValue(int value); @@ -36,6 +36,8 @@ public: int indent; int noise; int threshold; + int twss; + int cmduplexsel; bool is_convex; bool is_crop; bool is_bw; diff --git a/huagao/CTwainUI.cpp b/huagao/CTwainUI.cpp index 94d722aa..36b5eb57 100644 --- a/huagao/CTwainUI.cpp +++ b/huagao/CTwainUI.cpp @@ -60,7 +60,7 @@ BOOL CTwainUI::OnInitDialog() this->SetWindowText(TWAIN_NAME); auto dataChangeFunction = [this]() { - m_pageImageProc->ImageProcPageUpdate(m_pageBasic->m_cmBoxColorMode->GetCurSel(), + m_pageImageProc->ImageProcPageUpdate(m_pageBasic->m_cmBoxColorMode->GetCurSel(),m_pageBasic->m_cmBoxSS->GetCurSel(),m_pageBasic->m_cmBoxDuplex->GetCurSel(), (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel())== TwSS::USStatement)||(getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::None)); m_pageFeedPaper->FeedPaperPageUpdate(m_pageBasic->m_cmBoxDuplex->GetCurSel()); m_pageImageProc->ImageAutoDescrewUpdate(m_pageBasic->m_cmBoxSS->GetCurSel()); @@ -186,9 +186,16 @@ void CTwainUI::UpdateUI() m_pageImageProc->is_convex = settings->is_convex; m_pageBasic->discardblank_percent = settings->discardblank_percent; + ((CButton*)m_pageImageProc->GetDlgItem(IDC_CKCROPMODEL))->SetCheck(settings->normalCrop); m_pageImageProc->m_ckbFillBlack = settings->fillbackground==TRUE ? TRUE : FALSE;//填充黑框 m_pageImageProc->m_ckbAutoDeskrew = settings->autodescrew ? TRUE : FALSE;//自动纠偏 UpdateFilterCmbx(); + if (settings->fillbackground || settings->autodescrew || settings->is_autocrop) { + m_pageImageProc->GetDlgItem(IDC_ADVANCEDSET)->EnableWindow(TRUE); + } + else { + m_pageImageProc->GetDlgItem(IDC_ADVANCEDSET)->EnableWindow(FALSE); + } m_pageImageProc->m_cmBoxSharpen.SetCurSel(settings->sharpen); //UpdateSharpenCmbx(); m_pageImageProc->m_ckbRemoveHole = settings->fillhole.is_fillhole==TRUE?TRUE:FALSE;//除穿孔可用性 @@ -206,11 +213,15 @@ void CTwainUI::UpdateUI() m_pageImageProc->m_ckbMultioutput = FALSE;//多流除红 m_pageImageProc->m_ckbHSVCorrect = settings->hsvcorrect == TRUE ? TRUE : FALSE;//答题卡除红 m_pageImageProc->GetDlgItem(IDC_CKMULTIOUTPUT)->EnableWindow(settings->pixtype == 2);//彩色可用 + ((CButton*)m_pageImageProc->GetDlgItem(IDC_CKMULTIOUTPUT))->SetCheck(settings->pixtype == 2); m_pageImageProc->UpdateData(FALSE); m_pageFeedPaper->dogear.SetCheck(settings->is_dogeardetection); //!< Page feed paper - if(settings->is_duplex==TRUE) - m_pageFeedPaper->m_cbRotation = settings->is_backrotate180==TRUE ? TRUE : FALSE;//背面旋转180 + if (settings->is_duplex || settings->is_autodiscradblank_normal ||settings->is_autodiscradblank_vince) + { + m_pageFeedPaper->m_cbRotation = settings->is_backrotate180 == TRUE ? TRUE : FALSE;//背面旋转180 + m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(settings->is_autotext ? FALSE : TRUE); + } else { m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(FALSE); @@ -241,6 +252,8 @@ void CTwainUI::UpdateUI() m_pageFeedPaper->UpdateData(FALSE); m_pageBasic->updateCmbDuplex(TRUE); + m_pageImageProc->ImageProcPageUpdate(m_pageBasic->m_cmBoxColorMode->GetCurSel(), m_pageBasic->m_cmBoxSS->GetCurSel(), m_pageBasic->m_cmBoxDuplex->GetCurSel(), + (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::USStatement) || (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::None)); } void CTwainUI::UpdateFilterCmbx() @@ -469,6 +482,7 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs) settings->contrast = configItem->Contrast; settings->brightness = (configItem->Brightness); settings->gamma = (configItem->Gamma); + settings->normalCrop = ((CButton*)m_pageImageProc->GetDlgItem(IDC_CKCROPMODEL))->GetCheck(); settings->is_autocrop = paper.Paper == TwSS::None; settings->is_duplex = configItem->Duplex >= 1; settings->is_autodiscradblank_normal = configItem->Duplex == 2; @@ -541,13 +555,13 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs) settings->resolution_native = 200.0f; #endif if (settings->pixtype == TWPT_BW) - { - if (settings->filter == 3 && settings->enhance_color <=1) - { - settings->enhance_color = Enchace_Color::Enhance_Red; - settings->filter = 3;//none - } - } + //{ + // if (settings->filter == 3 && settings->enhance_color <=1) + // { + // settings->enhance_color = Enchace_Color::Enhance_Red; + // settings->filter = 3;//none + // } + //} UpdateUi(); } @@ -587,18 +601,25 @@ void CTwainUI::UpdateUi() m_pageImageProc->m_cmBoxFilter.EnableWindow((m_pageBasic->m_cmBoxColorMode->GetCurSel() != 0) && (m_pageBasic->m_cmBoxColorMode->GetCurSel() != 3)); INT dupindex = m_pageBasic->m_cmBoxDuplex->GetCurSel(); BOOL enableback = dupindex == 0 || dupindex == 4; - if (enableback) + if ((dupindex==0)||(dupindex==4)) { - ((CButton*)(m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)))->SetCheck(!enableback); - if (dupindex == 4) { - ((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->SetCheck(dupindex == 4 ? TRUE : FALSE); - } + ((CButton*)(m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)))->SetCheck(FALSE); + m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(FALSE); } - ((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->EnableWindow(!(dupindex == 4)); - m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(!enableback); + else + m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(m_pageFeedPaper->m_cmBoxOrentation.GetCurSel()==4? FALSE:TRUE); + if (dupindex == 4) { + ((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->SetCheck(TRUE); + ((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->EnableWindow(FALSE); + } + else + ((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->EnableWindow(TRUE); + m_pageImageProc->GetDlgItem(IDC_SLDOUTHOLE)->EnableWindow(((CButton*)m_pageImageProc->GetDlgItem(IDC_CKREMOVEHOLE))->GetCheck() == TRUE); m_pageFeedPaper->GetDlgItem(IDC_SLDDETECTLEVEL)->EnableWindow(((CButton*)m_pageFeedPaper->GetDlgItem(IDC_CKSKEWDETECT))->GetCheck() == TRUE); m_pageImageProc->GetDlgItem(IDC_CKMULTIOUTPUT)->EnableWindow(m_pageBasic->m_cmBoxColorMode->GetCurSel() == 0); + if(m_pageBasic->m_cmBoxColorMode->GetCurSel() != 0) + ((CButton*)m_pageImageProc->GetDlgItem(IDC_CKMULTIOUTPUT))->SetCheck(FALSE); } void CTwainUI::setvisable_size(bool flag) diff --git a/huagao/Device/GScan.h b/huagao/Device/GScan.h index 26ac153c..a3ce9455 100644 --- a/huagao/Device/GScan.h +++ b/huagao/Device/GScan.h @@ -139,7 +139,16 @@ public: virtual ~IScanner() { } - + /// + /// ñɨ + /// + /// + void set_scannum(int val) { scannum = val; }; + /// + /// ȡɨ + /// + /// + int get_scannum() { return scannum; }; /// /// ȡPCȡͼҳ /// @@ -238,6 +247,7 @@ protected: int imgreadednum; int imgtransfered; int roller_num; + int scannum; int lose_image_num; bool is_AndroidOrLinux; diff --git a/huagao/Device/GScanO1003399.cpp b/huagao/Device/GScanO1003399.cpp index 4f094ca8..fbe9c5db 100644 --- a/huagao/Device/GScanO1003399.cpp +++ b/huagao/Device/GScanO1003399.cpp @@ -2,6 +2,7 @@ #include "ImageProcess/ImageApplyHeaders.h" #include "ImageMultiOutput.h" #include "scn_config.h" +#include "UsbScanEx.h" #include "PaperSize.h" #include "GScan.h" @@ -45,8 +46,6 @@ GScanO1003399::~GScanO1003399() m_usbthread->join(); m_usbthread.reset(); } - if (fu_rx.valid()) - fu_rx.wait(); } void GScanO1003399::open(int vid, int pid) @@ -59,7 +58,8 @@ void GScanO1003399::open(int vid, int pid) //} if (m_usb.get()&&m_usb->is_connected()) return; - auto lsusb = CyUsbList::find_all(); + //auto lsusb = CyUsbList::find_all(); + auto lsusb = UsbScan_List::find_vid_pid(0x3072, 0x0139); if (!lsusb.empty()) { m_usb = *lsusb.begin(); @@ -81,12 +81,14 @@ int GScanO1003399::aquire_bmpdata(std::vector& bmpdata) StopWatch sw; while (true) { - if ((m_imagedata.Size() < 1)&&(!is_runing())) + if ((image==0)&&(!is_runing())&&(!scanflag)) { DoEvents(); this_thread::sleep_for(chrono::milliseconds(1)); if (!is_runing()) { + int roller_num_new= count(); + set_scannum(abs(roller_num_new - roller_num)); if (devState == DEV_WRONG) return get_ErrorCode(); return -1; @@ -94,10 +96,10 @@ int GScanO1003399::aquire_bmpdata(std::vector& bmpdata) if (sw.elapsed_s() > 30.0) { devState = DEV_STOP; - if (fu_rx.valid()) - fu_rx.wait(); Stop_scan(); ResetScanner(); + int roller_num_new = count(); + set_scannum(abs(roller_num_new - roller_num)); return AQUIRE_IMAGE_TIMEOUT; } } @@ -108,6 +110,7 @@ int GScanO1003399::aquire_bmpdata(std::vector& bmpdata) FileTools::writelog(log_INFO, "aquire_bmpdata num =" + to_string(aquirenum++)); bmpdata = *(m_imagedata.Take()); UpdateScanInfo(get_imgnReaded(), countNTransfered()); + image--; return 0; } DoEvents(); @@ -165,12 +168,13 @@ bool GScanO1003399::is_scan() BOOL GScanO1003399::Get_Scanner_PaperOn() { - return scanner_read_reg(m_usb, SR_PAPER_READY); + //return scanner_read_reg(m_usb, SR_PAPER_READY); + return true; } int GScanO1003399::Get_Roller_num() { - return 0; + return count(); } void GScanO1003399::config_params(GScanCap& param) @@ -269,12 +273,13 @@ void GScanO1003399::config_params(GScanCap& param) void GScanO1003399::Scanner_StartScan(UINT16 count) { - + roller_num = this->count(); scanflag = true; Set_ErrorCode(0); getimgnum = 0; aquirenum = 0; - + image = 0; + keeplastimg = true; reset(); devState = DEV_ISRUNNING; if (scan_mode()) @@ -299,13 +304,11 @@ void GScanO1003399::Scanner_StartScan(UINT16 count) void GScanO1003399::Stop_scan() { - if (devState != DEV_ISRUNNING) - return; stop(); scanflag = false; - if (fu_rx.valid()) - fu_rx.wait(); - devState == DEV_ISRUNNING ? devState = DEV_STOP : devState = DEV_WRONG; + if ((devState == DEV_WRONG) || (devState == DEV_STOP)) + return; + devState = DEV_STOP; } int GScanO1003399::notifyscan() @@ -376,13 +379,16 @@ void GScanO1003399::usb_run() auto length = m_usb->read_int(buff, sizeof(buff)); if (((length) == sizeof(buff)) || im_dev_count()) { + if (im_dev_count()) //ȡͼϢǰֹδյimgϢȡͼ³޷˳ 2021.7.16 + if (is_runing()) + im_rx(); HGEIntInfo info = *(HGEIntInfo*)&buff; switch (info.From) { - case IMG: - if (is_runing()) - im_rx(); - break; + //case IMG: + // if (is_runing()) + // im_rx(); + // break; case MtBoard: FileTools::writelog(log_ERROR, "Got MotorBoard error code = " + to_string(info.Code)); break; @@ -392,19 +398,37 @@ void GScanO1003399::usb_run() case V4L2: FileTools::writelog(log_ERROR, "Got V4L2 Error code = " + to_string(info.Code)); break; + case STOPSCAN: + FileTools::writelog(log_INFO, "StopScan"); + break; default: FileTools::writelog(log_ERROR, "Got Unkown error code ! From =" + to_string(info.From) + " Code = " + to_string(info.Code)); break; } if ((codeconvter(info) != 0)) { + if (info.Code==0x10||info.Code==0x20||info.Code==0x40) + { + while (scanner_read_reg(m_usb, SR_STATUS) & 0x1) + this_thread::sleep_for(chrono::microseconds(10)); + if (m_param.is_duplex) + pop_dev_im(); + pop_dev_im(); + } + else + { + keeplastimg = false; + im_rx(); + } scanflag = false; - devState = codeconvter(info) == -1 ? DEV_STOP : DEV_WRONG; + if ((devState != DEV_WRONG) && (codeconvter(info) < 0)) + devState = DEV_STOP; + else if ((devState != DEV_WRONG) && (codeconvter(info) > 0)) + devState = DEV_WRONG; } if (codeconvter(info) > 0) { Set_ErrorCode(codeconvter(info)); - stop(); } this_thread::sleep_for(chrono::microseconds(10)); } @@ -424,7 +448,8 @@ void GScanO1003399::stop() bool GScanO1003399::is_runing() { - return scanner_read_reg(m_usb, SR_STATUS) & 0x01; + int val = scanner_read_reg(m_usb, SR_STATUS) & 0x3; + return (val > 0) && (val < 4); } int GScanO1003399::scan_mode() @@ -473,9 +498,18 @@ void GScanO1003399::im_rx() if (!is_rx() && !is_dev_tx()) { fu_rx = m_imgthread.enqueue([this] { - do - { + while (im_dev_count()){ /* code */ + if (keeplastimg) + { + this_thread::sleep_for(chrono::microseconds(10)); + if (m_param.is_duplex) { + if(im_dev_count()<3) + continue; + } + if(im_dev_count()<2) + continue; + } auto &buffi = im_data; int count = front_datasize(); buffi->resize(count); @@ -485,9 +519,13 @@ void GScanO1003399::im_rx() pop_dev_im(); vector mats; auto& buffs = G400Decode(buffi).getImageBuffs(); + if (m_param.multi_output_red) + image += 2; + else + image++; UpdateScanInfo(countNReaded(), get_imgTransfered()); - imgproce(buffs); - } while (im_dev_count()); + imgproce(buffs); + } }); } } @@ -526,25 +564,24 @@ int GScanO1003399::im_dev_count() void GScanO1003399::imgproce(std::vector>>& buffs) { vector mats; + bool isbwimg = false; for (auto& buf : buffs) { - cv::ImreadModes rmc; - //int rm; - if (m_param.filter != 3 || m_param.enhance_color || m_param.hsvcorrect) { - rmc = cv::IMREAD_COLOR; - //rm = 1; - } - else { - rmc = m_param.pixtype == 2 ? cv::IMREAD_COLOR : cv::IMREAD_GRAYSCALE; - //rm = scanParam.pixtype == 2 ? 1 : 6; - } + cv::ImreadModes rmc = m_param.pixtype == 2 ? cv::IMREAD_COLOR : cv::IMREAD_GRAYSCALE; try { + if (buf->at(0) == -119 && buf->at(1) == 0x50 && buf->at(2) == 0x4e && buf->at(3) == 0x47) + { + isbwimg = true; + rmc = cv::IMREAD_GRAYSCALE; + } cv::Mat mat = cv::imdecode(*buf, rmc); if (mat.empty()) { FileTools::writelog(log_ERROR, "decode image data error"); continue; } buf.reset(); + //if (isbwimg) + // cv::flip(mat, mat, 0); mats.push_back(mat); FileTools::writelog(log_INFO, "push_back image num= " + to_string(getimgnum++)); } @@ -558,7 +595,6 @@ void GScanO1003399::imgproce(std::vector>>& bu if (m_param.automaticcolor) { CImageApplyColorRecognition(m_param.automaticcolortype == 1 ? CImageApplyColorRecognition::ColorRecognitionMode::Color_Gray : CImageApplyColorRecognition::ColorRecognitionMode::Color_Mono).apply(mats,m_param.is_duplex); - } for (int i = 0; i < mats.size(); i++) { //if (!m_param.is_duplex && i == 1) { @@ -570,7 +606,7 @@ void GScanO1003399::imgproce(std::vector>>& bu if (m_param.pixtype == 1 && m_param.hsvcorrect) if (mats[i].channels() == 3) cvtColor(mats[i], mats[i], cv::COLOR_BGR2GRAY); - idata = (m_param.pixtype == 0 || (((m_param.automaticcolortype == 0) && (m_param.automaticcolor == true)) && (mats[i].channels() == 1))) ? (IMat2Bmp)Mat2BmpBw(mats[i], m_param.resolution_dst) : Mat2Bmp(mats[i], m_param.resolution_dst); + idata = (isbwimg|| m_param.pixtype == 0 || (((m_param.automaticcolortype == 0) && (m_param.automaticcolor == true)) && (mats[i].channels() == 1))) ? (IMat2Bmp)Mat2BmpBw(mats[i], m_param.resolution_dst) : Mat2Bmp(mats[i], m_param.resolution_dst); //if (!m_param.multi_output_red) // mats[i].release(); @@ -647,6 +683,7 @@ int GScanO1003399::codeconvter(HGEIntInfo code) break; } } - + if (code.From == HGType::STOPSCAN) + return -1; return 0; } diff --git a/huagao/Device/GScanO1003399.h b/huagao/Device/GScanO1003399.h index 58941b8e..23d55f70 100644 --- a/huagao/Device/GScanO1003399.h +++ b/huagao/Device/GScanO1003399.h @@ -72,6 +72,7 @@ private: volatile int devState; volatile int Error_Code; volatile bool scanflag; + volatile bool keeplastimg; GScanCap m_param; std::shared_ptr m_usb; volatile bool b_usbthread; @@ -80,6 +81,7 @@ private: std::shared_ptr m_usbthread; std::shared_ptr> im_data; BlockingQueue>> m_imagedata; + std::atomic_int image; }; diff --git a/huagao/Device/GScanO200.cpp b/huagao/Device/GScanO200.cpp index 4537d1d8..893d83fd 100644 --- a/huagao/Device/GScanO200.cpp +++ b/huagao/Device/GScanO200.cpp @@ -220,12 +220,13 @@ int GScanO200::aquire_bmpdata(std::vector& bmpdata) Stop_scan();//ֹͣɨ ResetScanner(); auto rollernew = Get_Roller_num(); - if (get_imgnReaded() != (rollernew - roller_num)) - set_lose_image_num(std::abs((rollernew - roller_num) - get_imgnReaded())); + set_scannum(abs(rollernew - roller_num)); return HARDWARE_ERROR; } if (!is_scan()) { + auto rollernew = Get_Roller_num(); + set_scannum(abs(rollernew - roller_num)); if (devState == DEV_WRONG) { return get_ErrorCode(); } @@ -631,13 +632,6 @@ void GScanO200::usbmain() { m_pImages->setscanflags(false); std::this_thread::sleep_for(std::chrono::milliseconds(1500)); - auto rollernew= Get_Roller_num(); - if (get_imgnReaded() != (rollernew - roller_num)) - { - Set_ErrorCode(LOSE_IMAGE); - set_lose_image_num(std::abs((rollernew - roller_num) - get_imgnReaded())); - haveError = true; - } devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP; //m_pImages->setscanflags(false); //devState = DEV_STOP; diff --git a/huagao/Device/GScanO400.cpp b/huagao/Device/GScanO400.cpp index 3d3a79b2..bab9393c 100644 --- a/huagao/Device/GScanO400.cpp +++ b/huagao/Device/GScanO400.cpp @@ -212,6 +212,7 @@ int GScanO400::aquire_bmpdata(std::vector& bmpdata) this_thread::sleep_for(chrono::milliseconds(1)); if (sw.elapsed_s() > 30.00) { + int roller_num_new = Get_Roller_num(); if (m_threadUsb && m_threadUsb->joinable()) { devState = DEV_STOP; m_threadUsb->join(); @@ -220,10 +221,13 @@ int GScanO400::aquire_bmpdata(std::vector& bmpdata) } Stop_scan();//ֹͣɨ ResetScanner(); + set_scannum(abs(roller_num_new - roller_num)); return HARDWARE_ERROR; } if (!is_scan()) { + int roller_num_new = Get_Roller_num(); + set_scannum(abs(roller_num_new - roller_num)); if (devState == DEV_WRONG) { return get_ErrorCode(); } @@ -680,13 +684,6 @@ void GScanO400::usbmain() { m_pImages->setscanflags(false); std::this_thread::sleep_for(std::chrono::milliseconds(1500)); - auto rollernew = Get_Roller_num(); - if (get_imgnReaded() != (rollernew - roller_num)) - { - Set_ErrorCode(LOSE_IMAGE); - set_lose_image_num(std::abs((rollernew - roller_num) - get_imgnReaded())); - haveError = true; - } devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP; break; } diff --git a/huagao/Device/IConfig.h b/huagao/Device/IConfig.h index 3715fa70..25962d0c 100644 --- a/huagao/Device/IConfig.h +++ b/huagao/Device/IConfig.h @@ -24,15 +24,16 @@ static std::map SupPaperTyps = { {{TwSS::B6,PaperAlign::Rot0},10}, {{TwSS::B6,PaperAlign::Rot270},11}, {{TwSS::USLetter,PaperAlign::Rot0},14}, - {{TwSS::USLetter,PaperAlign::Rot270},15}, {{TwSS::USLedger,PaperAlign::Rot0},12}, {{TwSS::USLegal,PaperAlign::Rot0},13}, {{TwSS::None,PaperAlign::Rot0},0}, #ifdef G1003399 + {{TwSS::USLetter,PaperAlign::Rot270},14}, {{TwSS::USStatement,PaperAlign::Rot0},17}, {{TwSS::MaxSize,PaperAlign::Rot0},19}, {{TwSS::Trigeminy,PaperAlign::Rot0},17} #else + { {TwSS::USLetter,PaperAlign::Rot270},15}, {{TwSS::USStatement,PaperAlign::Rot0},16}, {{TwSS::MaxSize,PaperAlign::Rot0},16}, {{TwSS::Trigeminy,PaperAlign::Rot0},16} @@ -118,6 +119,7 @@ enum HGType FPGA, V4L2, IMG, + AutoCorrect, STOPSCAN, }; @@ -161,7 +163,13 @@ enum Scanner_Reg_Defs SR_GET_SERIALNUM, SR_SET_SERIALNUM, SR_CONFIF_IMGPROCPARAM, - SR_PAPER_READY, + SC_AUTOCORRECT, + SR_KEEP_LAST_IMG, + SR_UPDATA_START = 0x100, + SR_UPDATA_STAUTUS = 0x101, + SR_UPDATA_MD5_RELUST = 0x102, + SR_UPDATA_RECOVERY = 0x103, + SR_UPDATA_REBOOT = 0x104, }; enum Scanner_Cmd_Defs diff --git a/huagao/Device/ImageMatQueue.cpp b/huagao/Device/ImageMatQueue.cpp index c6da8ab5..235e77df 100644 --- a/huagao/Device/ImageMatQueue.cpp +++ b/huagao/Device/ImageMatQueue.cpp @@ -173,8 +173,9 @@ void ImageMatQueue::setparam(const GScanCap& param) #else // REAL300DPI fixedSize = papersize.GetPaperSize(param.papertype, 200.0f, param.paperAlign); #endif + bool normalCrop = ((param.autodescrew) || (islongcustomcrop ? islongcustomcrop : param.is_autocrop)||(param.fillbackground)) ? false : param.normalCrop; m_iaList.push_back(shared_ptr(new CImageApplyAutoCrop(islongcustomcrop ? islongcustomcrop : param.is_autocrop, - param.autodescrew, param.fillbackground, cv::Size(fixedSize.cx, fixedSize.cy), param.is_convex,param.AutoCrop_threshold,param.noise,param.indent))); + param.autodescrew, param.fillbackground, cv::Size(fixedSize.cx, fixedSize.cy), param.is_convex,false,param.AutoCrop_threshold,param.noise,param.indent,normalCrop))); /* m_iaList.push_back(shared_ptr(new CImageApplyAutoCrop(true, param.autodescrew, param.fillbackground, cv::Size(fixedSize.cx, fixedSize.cy), param.is_convex, false, param.AutoCrop_threshold, param.noise, param.indent))); if(!(islongcustomcrop ? islongcustomcrop : param.is_autocrop)) diff --git a/huagao/Device/PublicFunc.h b/huagao/Device/PublicFunc.h index 4e2f315f..2522e748 100644 --- a/huagao/Device/PublicFunc.h +++ b/huagao/Device/PublicFunc.h @@ -54,6 +54,7 @@ const std::string GAMMA_ = "dGamma"; // 0) { - cv::Mat element = getStructuringElement(cv::MORPH_RECT, cv::Size(m_noise, m_noise)); + cv::Mat element = getStructuringElement(cv::MORPH_RECT, cv::Size(m_noise, 1)); cv::morphologyEx(thre, thre, cv::MORPH_OPEN, element); } std::vector hierarchy; @@ -55,6 +62,12 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side) if (m_maxContour.size() == 0) { thre.release(); + //ǹ̶棬뷵زкijߴ + if (!m_isCrop) + pDib = pDib(cv::Rect((pDib.cols - m_fixedSize.width) / 2, (pDib.rows - m_fixedSize.height) / 2, m_fixedSize.width, m_fixedSize.height) & cv::Rect(0, 0, pDib.cols, pDib.rows)).clone(); +#ifdef LOG + FileTools::write_log("imgprc.txt", "exit CImageApplyAutoCrop apply"); +#endif // LOG return; } thre.release(); @@ -96,6 +109,8 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side) m_maxContour.push_back(cv::Point(dst.cols, -1)); m_maxContour.push_back(cv::Point(dst.cols, dst.rows)); + + cv::Scalar autoBGColor; if (m_isFillBlank) { cv::Mat thre_dst; @@ -129,7 +144,8 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side) contours[contours.size() - 1].push_back(cv::Point(dst.cols, -1)); contours[contours.size() - 1].push_back(cv::Point(dst.cols, dst.rows)); - hg::fillPolys(dst, contours, m_isFillColor ? getBackGroudColor(pDib, rect.size.area()) : cv::Scalar(255, 255, 255)); + autoBGColor = m_isFillColor ? getBackGroudColor(pDib, rect.size.area()) : cv::Scalar(255, 255, 255); + hg::fillPolys(dst, contours, autoBGColor); } pDib.release(); @@ -137,7 +153,7 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side) pDib = dst.clone(); else { - pDib = cv::Mat(m_fixedSize, dst.type(), m_isFillBlank ? cv::Scalar(255, 255, 255) : cv::Scalar(0, 0, 0)); + pDib = cv::Mat(m_fixedSize, dst.type(), m_isFillBlank ? autoBGColor : cv::Scalar(0, 0, 0)); cv::Rect roi; roi.x = dst.cols > pDib.cols ? (dst.cols - pDib.cols) / 2 : 0; @@ -154,12 +170,9 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side) void CImageApplyAutoCrop::apply(std::vector& mats, bool isTwoSide) { - m_rects.clear(); if (mats.empty()) return; if (!mats[0].empty()) { apply(mats[0], 0); - m_rects.push_back(m_rect); - //cv::imwrite("1.bmp", mats[0]); } if (isTwoSide && mats.size() > 1) @@ -167,11 +180,8 @@ void CImageApplyAutoCrop::apply(std::vector& mats, bool isTwoSide) cv::Size dSize = m_fixedSize; if (!mats[0].empty()) m_fixedSize = mats[0].size(); - if (!mats[1].empty()) { apply(mats[1], 1); - m_rects.push_back(m_rect); - //cv::imwrite("1.bmp", mats[0]); } if (!mats[0].empty()) diff --git a/huagao/ImageProcess/ImageApplyAutoCrop.h b/huagao/ImageProcess/ImageApplyAutoCrop.h index 41a78827..7c8b80bf 100644 --- a/huagao/ImageProcess/ImageApplyAutoCrop.h +++ b/huagao/ImageProcess/ImageApplyAutoCrop.h @@ -26,6 +26,7 @@ class CImageApplyAutoCrop : public CImageApply public: CImageApplyAutoCrop(); + /* * isCrop [in]:自动幅面裁剪使能,true自动裁剪,false为固定裁剪 * isDesaskew [in]:自动纠偏使能,true自动纠偏,false为不纠偏 @@ -34,10 +35,12 @@ public: * isConvex [in]:黑底填充时的填充方式,true为凸多边形填充,false为凹多边形填充,默认true * isFillColor [in]:黑底填充时采用自适应色彩填充,false为白色填充,true为自适应文稿底色填充,默认false * threshold [in]:二值化阈值,取值范围(0, 255),默认40 - * noise [in]:除噪像素,能够消除noise宽度的背景竖条纹干扰,默认40 + * noise [in]:除噪像素,能够消除noise宽度的背景竖条纹干扰,默认2 * indent [in]:轮廓缩进,裁剪、纠偏或者黑底填充时,对探索到的纸张轮廓进行缩进indent像素,默认5 + * normalCrop [in]:为true且m_isCrop m_isDesaskew m_isFillBlank均为false时生效,固定裁切采用最传统的裁切方式,默认false */ - CImageApplyAutoCrop(bool isCrop, bool isDesaskew, bool isFillBlank, const cv::Size& fixedSize, bool isConvex = true, double threshold = 40, int noise = 8, 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, bool normalCrop = false); virtual ~CImageApplyAutoCrop(); @@ -98,6 +101,7 @@ private: double m_threshold; int m_noise; int m_indent; + bool m_normalCrop; //为true且m_isCrop m_isDesaskew m_isFillBlank均为false时生效,固定裁切采用最传统的裁切方式 cv::Size m_fixedSize; cv::RotatedRect m_rect; std::vector m_maxContour; diff --git a/huagao/huagaods.cpp b/huagao/huagaods.cpp index 8f4f59dd..e7c52c7c 100644 --- a/huagao/huagaods.cpp +++ b/huagao/huagaods.cpp @@ -59,6 +59,7 @@ enum class CapTypeEx : unsigned short { TwEx_SizeDetect = 0x8103, TwEx_LowPowerMode = 0x8104, TwEx_ENCODE = 0x8105, + TwEx_CropModel=0x8106, }; enum class PaperSizeEx : unsigned short { @@ -86,7 +87,7 @@ using namespace std::placeholders; TWPP_ENTRY_MFC(HuagaoDs) static constexpr const Identity srcIdent( - Version(3, 3, Language::English, Country::China, "v3.3.5.0"), + Version(3, 3, Language::English, Country::China, "v3.3.5.1"), DataGroup::Image, #ifdef MAKEHUAGAO "HUAGO", @@ -344,36 +345,40 @@ HuagaoDs::HuagaoDs() void HuagaoDs::showmsg(std::string caption, std::string text, int retcode) { if (scanner.get()) { - int losemun = scanner->get_lose_image_num(); - int num = 0; - bool is_duplex = m_scanparam->is_duplex; + int num = scanner->get_scannum() * (m_scanparam->is_duplex ? 2 : 1) * (m_scanparam->multi_output_red ? 2 : 1) / (m_scanparam->en_fold ? 2 : 1); #ifdef G1003399 - is_duplex = false; + int readnum =scanner->get_scannum()* (m_scanparam->is_duplex ? 2 : 1) / (m_scanparam->en_fold ? 2 : 1); +#else + int readnum = scanner->get_scannum(); #endif // G1003399 - if ((retcode == 64 || retcode == 8 || retcode == 16) && losemun > 0)//64 ->SStop - losemun--; + if (!(m_scanparam->is_autodiscradblank_normal || m_scanparam->is_autodiscradblank_vince)) { - if (is_duplex && m_scanparam->en_fold && m_scanparam->multi_output_red) - num = scanner->get_imgnReaded() * 2 - scanner->get_imgTransfered(); - else if (is_duplex && m_scanparam->en_fold) - num = scanner->get_imgnReaded() - scanner->get_imgTransfered(); - else if (is_duplex && m_scanparam->multi_output_red) - num = scanner->get_imgnReaded() * 4 - scanner->get_imgTransfered(); - else if ((!is_duplex) && m_scanparam->multi_output_red) - num = scanner->get_imgnReaded() * 2 - scanner->get_imgTransfered(); - else if (!is_duplex) - num = scanner->get_imgnReaded() - scanner->get_imgTransfered(); - else - num = scanner->get_imgnReaded() * 2 - scanner->get_imgTransfered(); - } - if ((losemun != 0) || (num != 0)) { - text += "ֽ" + to_string(scanner->get_lose_image_num() + scanner->get_imgnReaded()) + - "ɨ" + to_string(scanner->get_imgnReaded()) + "ϴ" + to_string(scanner->get_imgTransfered()) + - "ɨ" + to_string(losemun) + "ļϴ" + to_string(num) + "ļ"; - scanner->set_lose_image_num(0); - } + if ((retcode == 64 || retcode == 8 || retcode == 16)) { + num = (scanner->get_scannum()-1) * (m_scanparam->is_duplex ? 2 : 1) * (m_scanparam->multi_output_red ? 2 : 1) / (m_scanparam->en_fold ? 2 : 1); +#ifdef G1003399 + int readnum = (scanner->get_scannum() -1)* (m_scanparam->is_duplex ? 2 : 1) / (m_scanparam->en_fold ? 2 : 1); +#else + int readnum = scanner->get_scannum()-1; +#endif // G1003399 + if (((num - scanner->get_imgTransfered()) > 0)||((readnum-scanner->get_imgnReaded())>0)) { + text += "ֽ" + to_string(scanner->get_scannum()-1) + + "ɨ" + to_string(scanner->get_imgnReaded()) + "ϴ" + to_string(scanner->get_imgTransfered()) + + "ɨ" + to_string(readnum - scanner->get_imgnReaded()) + "ļϴ" + to_string(num - scanner->get_imgTransfered()) + "ļ"; + scanner->set_lose_image_num(0); + } + } + else{ + if (((num - scanner->get_imgTransfered()) != 0) || ((readnum - scanner->get_imgnReaded()) != 0)) { + text += "ֽ" + to_string(scanner->get_scannum()) + + "ɨ" + to_string(scanner->get_imgnReaded()) + "ϴ" + to_string(scanner->get_imgTransfered()) + + "ɨ" + to_string(readnum - scanner->get_imgnReaded()) + "ļϴ" + to_string(num - scanner->get_imgTransfered()) + "ļ"; + scanner->set_lose_image_num(0); + } + } + + } } ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString((text + " " + caption).c_str()), NULL, SW_HIDE); } @@ -766,6 +771,18 @@ void HuagaoDs::SetResoluton(const char* path, int resolution) delete[]buf; } +void HuagaoDs::dogear_callback(int indexpaper) +{ + CString text; + text.Format(_T("74 %d"), indexpaper); + //ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), text, NULL, SW_HIDE); + showmsg("",""+to_string(indexpaper)+"⵽۽ǣ"); + scanner->Stop_scan(); + //scanner->reset(); + scanner->ResetScanner(); + onDeviceEvent(DOG_EAR); +} + Result HuagaoDs::identityOpenDs(const Identity&) { hMutex = CreateMutex(NULL, FALSE, _T("LookitApp")); @@ -951,33 +968,34 @@ Result HuagaoDs::identityOpenDs(const Identity&) { m_query[CapType::IPixelType] = msgSupportGetAllSetReset; m_caps[CapType::IPixelType] = [this](Msg msg, Capability& data) -> Result { - if (Msg::Set == msg) { - auto mech = data.currentItem(); - if (mech == PixelType::Rgb || mech == PixelType::Gray || mech == PixelType::BlackWhite) - { - m_scanparam->pixtype = (int)mech; - if (m_scanparam->pixtype == (int)PixelType::Rgb) { - m_scanparam->filter = (BYTE)Filter::None; - m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_None; - m_scanparam->automaticcolor = FALSE; - } - else { - m_scanparam->multi_output_red = 0;//Dzɫģʽ¶ - //if (m_scanparam->pixtype == (int)PixelType::BlackWhite) - // m_scanparam->sharpen = SharpenBlur::Sharpen_None; - if (m_scanparam->pixtype == (int)PixelType::BlackWhite) - { - if (m_scanparam->filter == 3 && m_scanparam->enhance_color == 0) - { - m_scanparam->filter = (BYTE)Filter::None; - m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_Red; - } - } - } - m_iBitdepth = mech == PixelType::Rgb ? 24 : (mech == PixelType::Gray ? 8 : 1); - return success(); + if( Msg::Set==msg) { + auto mech = data.currentItem(); + if (mech == PixelType::Rgb || mech == PixelType::Gray || mech == PixelType::BlackWhite) + { + m_scanparam->pixtype = (int)mech; + if (m_scanparam->pixtype == (int)PixelType::Rgb){ + m_scanparam->filter = (BYTE)Filter::None; + m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_None; + m_scanparam->automaticcolor = FALSE; } - return badValue(); + else{ + m_scanparam->multi_output_red = 0;//Dzɫģʽ¶ + //if (m_scanparam->pixtype == (int)PixelType::BlackWhite) + // m_scanparam->sharpen = SharpenBlur::Sharpen_None; + + //if (m_scanparam->pixtype == (int)PixelType::BlackWhite) + //{ + // if (m_scanparam->filter == 3 && m_scanparam->enhance_color == 0) + // { + // m_scanparam->filter = (BYTE)Filter::None; + // m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_Red; + // } + //} + } + m_iBitdepth = mech == PixelType::Rgb ? 24 : (mech == PixelType::Gray ? 8 : 1); + return success(); + } + return badValue(); } return CapSupGetAllReset(msg, data, { PixelType::BlackWhite,PixelType::Gray,PixelType::Rgb }, m_scanparam->pixtype, PixelType::Rgb, m_scanparam->pixtype == (int)PixelType::Rgb ? 2 : (m_scanparam->pixtype == (int)PixelType::Gray ? 1 : 0), 2); @@ -1499,7 +1517,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) { m_caps[(CapType)(CapTypeEx::TwEx_CropNoise)] = [this](Msg msg, Capability& data)->Result { if (Msg::Set == msg) { auto mech = data.currentItem(); - if ((mech > 50 || mech < 0) && ((bool)m_scanparam->is_autocrop == true)) + if ((mech > 10 || mech < 0) && ((bool)m_scanparam->is_autocrop == true)) return badValue(); m_scanparam->noise = mech; return success(); @@ -1640,13 +1658,13 @@ Result HuagaoDs::identityOpenDs(const Identity&) { if (mech != (BYTE)Enchace_Color::Enhance_None) m_scanparam->filter = (BYTE)Filter::None; - if (m_scanparam->pixtype == (int)PixelType::BlackWhite)//ڰĬϿɫǿ ǿЧ - { - if (m_scanparam->enhance_color == (BYTE)Enchace_Color::Enhance_None) - { - m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_Red; - } - } + //if (m_scanparam->pixtype == (int)PixelType::BlackWhite) + //{ + // if (m_scanparam->enhance_color == (BYTE)Enchace_Color::Enhance_None) + // { + // m_scanparam->enhance_color = (BYTE)Enchace_Color::Enhance_Red; + // } + //} return success(); } } @@ -1843,6 +1861,22 @@ Result HuagaoDs::identityOpenDs(const Identity&) { }; #endif // LANXUM + m_query[(CapType)(CapTypeEx::TwEx_CropModel)] = msgSupportGetAllSetReset; + m_caps[(CapType)(CapTypeEx::TwEx_CropModel)] = [this](Msg msg, Capability& data)->Result { + if (Msg::Set == msg) { + auto mech = data.currentItem(); + if (m_scanparam->fillbackground || + m_scanparam->autodescrew || + m_scanparam->is_autocrop || + m_scanparam->en_fold) + { + return badValue(); + } + m_scanparam->normalCrop = (bool)mech; + return success(); + } + return CapSupGetAllResetEx(msg, data, m_scanparam->normalCrop, false); + }; #ifdef UV m_query[(CapType)(CapTypeEx::TwEx_UVModel)] = msgSupportGetAllSetReset; m_caps[(CapType)(CapTypeEx::TwEx_UVModel)] = [this](Msg msg, Capability& data)->Result { @@ -1925,25 +1959,8 @@ Result HuagaoDs::pendingXfersEnd(const Identity&, PendingXfers& data) { { if (!(m_scanparam->is_autodiscradblank_normal || m_scanparam->is_autodiscradblank_vince)) { - int num = 0; - bool is_duplex = m_scanparam->is_duplex; -#ifdef G1003399 - is_duplex = false; -#endif // G1003399 - - if (is_duplex && m_scanparam->en_fold && m_scanparam->multi_output_red) - num = scanner->get_imgnReaded() * 2 - scanner->get_imgTransfered(); - else if (is_duplex && m_scanparam->en_fold) - num = scanner->get_imgnReaded() - scanner->get_imgTransfered(); - else if (is_duplex && m_scanparam->multi_output_red) - num = scanner->get_imgnReaded() * 4 - scanner->get_imgTransfered(); - else if ((!is_duplex) && m_scanparam->multi_output_red) - num = scanner->get_imgnReaded() * 2 - scanner->get_imgTransfered(); - else if (!is_duplex) - num = scanner->get_imgnReaded() - scanner->get_imgTransfered(); - else - num = scanner->get_imgnReaded() * 2 - scanner->get_imgTransfered(); - if (num != 0) + int num = scanner->get_scannum() * (m_scanparam->is_duplex ? 2 : 1) * (m_scanparam->multi_output_red ? 2 : 1) / (m_scanparam->en_fold ? 2 : 1); + if ((num - scanner->get_imgTransfered()) != 0) { showmsg("", msgs[LOSE_IMAGE]); FileTools::writelog(log_ERROR, msgs[LOSE_IMAGE]); @@ -2519,7 +2536,6 @@ Twpp::Result HuagaoDs::startScan() if (guiTwain.get()) { ((CTwainUI*)(guiTwain.get()))->EnableID_OKorID_Cancel(false); } - int retCode = scanner->aquire_bmpdata(*bmpData.get()); if (retCode != 0) { scanner->Set_ErrorCode(0); diff --git a/huagao/huagaods.hpp b/huagao/huagaods.hpp index 90a9a876..7696b307 100644 --- a/huagao/huagaods.hpp +++ b/huagao/huagaods.hpp @@ -91,6 +91,7 @@ private://method Twpp::UInt32 bmpSize() const noexcept; const char* bmpBegin() const noexcept; const char* bmpEnd() const noexcept; + void dogear_callback(int indexpaper); void updataGscanCap(); Twpp::Result capCommon(const Twpp::Identity& origin, Twpp::Msg msg, Twpp::Capability& data); void showmsg(std::string caption, std::string text, int retcode=0); diff --git a/huagao/huagaotwds.rc b/huagao/huagaotwds.rc index 0f4dec46..51e69179 100644 Binary files a/huagao/huagaotwds.rc and b/huagao/huagaotwds.rc differ diff --git a/huagao/resource.h b/huagao/resource.h index 2c385f8b..281b74c1 100644 Binary files a/huagao/resource.h and b/huagao/resource.h differ diff --git a/huagao/stdafx.h b/huagao/stdafx.h index 04a82056..90a6d6c1 100644 Binary files a/huagao/stdafx.h and b/huagao/stdafx.h differ