From 6add56a8460fa8f888d261eba53489e8f8072894 Mon Sep 17 00:00:00 2001 From: masayume <1936714878@qq.com> Date: Thu, 17 Dec 2020 17:02:33 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E9=A2=9C=E8=89=B2=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E7=AE=97=E6=B3=95=E3=80=82=202.=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=99=A4=E8=89=B2=E9=80=89=E9=A1=B9=E5=8D=A1=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=8B=BE=E9=80=89=E7=AC=AC=E4=B8=80=E4=B8=AA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- huagao/CBasicPage.cpp | 3 +- huagao/CImageProcPage.cpp | 6 +- huagao/CTwainUI.cpp | 9 +- huagao/Device/GScan.h | 1 - huagao/Device/GScanO200.cpp | 15 +-- huagao/Device/IConfig.h | 2 +- huagao/Device/ImageMatQueue.cpp | 30 ++--- huagao/Device/PublicFunc.h | 4 + huagao/GscanJsonConfig.cpp | 21 ++- .../ImageApplyColorRecognition.cpp | 126 ++++++++++++++++++ .../ImageProcess/ImageApplyColorRecognition.h | 66 +++++++++ huagao/ImageProcess/ImageApplyHeaders.h | 1 + huagao/huagaods.cpp | 71 +++++++++- huagao/huagaotwds.rc | Bin 40700 -> 41286 bytes huagao/resource.h | Bin 13192 -> 13280 bytes huagao/stdafx.h | Bin 10774 -> 10774 bytes 16 files changed, 307 insertions(+), 48 deletions(-) create mode 100644 huagao/ImageProcess/ImageApplyColorRecognition.cpp create mode 100644 huagao/ImageProcess/ImageApplyColorRecognition.h diff --git a/huagao/CBasicPage.cpp b/huagao/CBasicPage.cpp index 1ddcd3ef..493c3bbb 100644 --- a/huagao/CBasicPage.cpp +++ b/huagao/CBasicPage.cpp @@ -14,7 +14,8 @@ static std::vector color_Modes = { _T("24位彩色"), _T("256级灰度"), - _T("黑白") + _T("黑白"), + _T("颜色自动识别") }; diff --git a/huagao/CImageProcPage.cpp b/huagao/CImageProcPage.cpp index 30326d5a..f21905c5 100644 --- a/huagao/CImageProcPage.cpp +++ b/huagao/CImageProcPage.cpp @@ -56,7 +56,6 @@ void CImageProcPage::ImageProcPageUpdate(int val,bool is_Crop) CButton* t_chMultiOutput = (CButton*)(GetDlgItem(IDC_CKMULTIOUTPUT)); CComboBox* m_temp_sharpen = (CComboBox*)(GetDlgItem(IDC_CMBSHARPEN)); is_bw = val == 2 ? true : false; - int ival = (val == 0 ? 0 : (val == 1 ? 1 : 2)); this->is_crop = is_Crop; if (((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck() || is_crop) ((CButton*)GetDlgItem(IDC_ADVANCEDSET))->EnableWindow(true); @@ -64,7 +63,7 @@ void CImageProcPage::ImageProcPageUpdate(int val,bool is_Crop) { ((CButton*)GetDlgItem(IDC_ADVANCEDSET))->EnableWindow(false); } - if (0 == ival)//彩色 + if (0 == val)//彩色 { m_temp->SetCurSel(0); m_temp->EnableWindow(FALSE); @@ -73,12 +72,11 @@ void CImageProcPage::ImageProcPageUpdate(int val,bool is_Crop) } else { - m_temp->SetCurSel(0); m_temp->EnableWindow(TRUE); t_chMultiOutput->SetCheck(FALSE); t_chMultiOutput->EnableWindow(FALSE); } - if (ival == 2) + if (val == 2) { ((CButton*)GetDlgItem(IDC_CHECKDETACHNOISE))->EnableWindow(true); } diff --git a/huagao/CTwainUI.cpp b/huagao/CTwainUI.cpp index d04d1e5f..a28b2da4 100644 --- a/huagao/CTwainUI.cpp +++ b/huagao/CTwainUI.cpp @@ -153,7 +153,7 @@ void CTwainUI::OnBnClickedBtnhelp() void CTwainUI::UpdateUI() { //!< basic page - m_pageBasic->m_cmBoxColorMode->SetCurSel(get_map_key_by_value(colorModes, settings->pixtype));//!< 颜色模式 + m_pageBasic->m_cmBoxColorMode->SetCurSel(settings->automaticcolor ? 3 : get_map_key_by_value(colorModes, settings->pixtype));//!< 颜色模式 m_pageBasic->m_cmBoxResultion->SetCurSel(get_map_key_by_value(resolutions, settings->resolution_dst));//!< 分辨率 m_pageBasic->m_cmBoxDuplex->SetCurSel(getCmbDuplexIndex());//!< 单双面 m_pageBasic->m_cmBoxSS->SetCurSel(getPaparSizeIndex(settings->papertype, settings->paperAlign)); //!< 纸张类型 @@ -232,7 +232,7 @@ void CTwainUI::UpdateUI() void CTwainUI::UpdateFilterCmbx() { - if (settings->pixtype == TWPT_RGB) + if (settings->pixtype == 2) { m_pageImageProc->m_cmBoxFilter.SetCurSel(0); m_pageImageProc->m_cmBoxFilter.EnableWindow(FALSE); @@ -380,7 +380,7 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs) { //!< Page Basic m_pageBasic->UpdateData(); - configItem->Pixtype = m_pageBasic->m_cmBoxColorMode->GetCurSel();//!< 颜色模式 index + configItem->Pixtype = m_pageBasic->m_cmBoxColorMode->GetCurSel() == 3 ? 0 : m_pageBasic->m_cmBoxColorMode->GetCurSel();//!< 颜色模式 index configItem->EnSizeCheck = m_pageBasic->m_enableSizeCheck; configItem->Resolution = m_pageBasic->m_cmBoxResultion->GetCurSel();//!< 分辨率 index configItem->Duplex = m_pageBasic->m_cmBoxDuplex->GetCurSel();//!< 单双面 @@ -435,8 +435,9 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs) if (!updateDs) return; + settings->automaticcolor = m_pageBasic->m_cmBoxColorMode->GetCurSel() == 3 ? 1 : 0; settings->pixtype = colorModes[configItem->Pixtype]; - settings->hardwarecaps.capturepixtype = settings->pixtype; + settings->hardwarecaps.capturepixtype = settings->pixtype == 2 ? 2 : settings->pixtype; PaperStatus paper = paperStatusMap[configItem->PaperSize]; settings->papertype = paper.Paper; diff --git a/huagao/Device/GScan.h b/huagao/Device/GScan.h index eae3c2f8..49d6b485 100644 --- a/huagao/Device/GScan.h +++ b/huagao/Device/GScan.h @@ -62,7 +62,6 @@ typedef enum tagUsbSupported { UPDATE_SCAN_PARAMETER = 72, // PCæ PC_SCAN_BUSY_or_ERROR = 73, - //ߡ DOG_EAR=74, // diff --git a/huagao/Device/GScanO200.cpp b/huagao/Device/GScanO200.cpp index ca0f0f20..06f96071 100644 --- a/huagao/Device/GScanO200.cpp +++ b/huagao/Device/GScanO200.cpp @@ -240,7 +240,7 @@ int GScanO200::aquire_bmpdata(std::vector& bmpdata) while (true) { if (m_pImages->empty()) { - //DoEvents(); + DoEvents(); this_thread::sleep_for(chrono::milliseconds(1)); if (sw.elapsed_s() > 20.00) { @@ -276,7 +276,7 @@ int GScanO200::aquire_bmpdata(std::vector& bmpdata) #endif // LOG return 0; } - //DoEvents(); + DoEvents(); this_thread::sleep_for(chrono::milliseconds(2)); } } @@ -585,16 +585,7 @@ void GScanO200::usbmain() devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP; return; } - - if (gcap.resolution_dst == 200.0f) - { - if (m_pImages->orginimgcount() > 5) - { - this_thread::sleep_for(chrono::milliseconds(10)); - continue; - } - } - else if(gcap.resolution_dst>200.0f) + if(gcap.resolution_dst>200.0f) { if (m_pImages->orginimgcount() > 2) { diff --git a/huagao/Device/IConfig.h b/huagao/Device/IConfig.h index d7564396..69429399 100644 --- a/huagao/Device/IConfig.h +++ b/huagao/Device/IConfig.h @@ -78,7 +78,7 @@ static std::map SupPaperTyps = { static std::map SupPixelTypes = { {0, 0},//bw {1, 0},//gray - {2, 1}//color + {2, 1},//color }; static std::map SupResolutions = { diff --git a/huagao/Device/ImageMatQueue.cpp b/huagao/Device/ImageMatQueue.cpp index 21d68a11..5b47d734 100644 --- a/huagao/Device/ImageMatQueue.cpp +++ b/huagao/Device/ImageMatQueue.cpp @@ -146,15 +146,6 @@ void ImageMatQueue::setparam(const GScanCap& param) scanParam = param; //scanParam.is_duplex = 0; //scanParam.imageRotateDegree = 90.0f; -#ifdef DEBUG - string outinfo = "autodescrew : " + to_string(scanParam.autodescrew) + "\n brightness : " + to_string(scanParam.brightness) + "\n contrast " + to_string(scanParam.contrast) + "\n enhance_color : " + to_string(scanParam.enhance_color) + "\n en_fold: " + to_string(scanParam.en_fold) - + "\n fillbackground : " + to_string(scanParam.fillbackground) + "\n is_fillhole : " + to_string(scanParam.fillhole.is_fillhole) + "\n fillholeratio : " + to_string(scanParam.fillhole.fillholeratio) + "\n filter : " + to_string(scanParam.filter) + "\n gamma : " + to_string(scanParam.gamma) - + "\n imageRotateDegree : " + to_string(scanParam.imageRotateDegree) + "\n is_autocrop : " + to_string(scanParam.is_autocrop) + "\n is_autodiscradblank_normal : " + to_string(scanParam.is_autodiscradblank_normal) + "\n is_autodiscradblank_vince : " + to_string(scanParam.is_autodiscradblank_vince) - + "\n is_autotext : " + to_string(scanParam.is_autotext) + "\n is_backrotate180 : " + to_string(scanParam.is_backrotate180) + "\n is_duplex : " + to_string(scanParam.is_duplex) + "\n is_switchfrontback : " + to_string(scanParam.is_switchfrontback) + "\n multi_output_red : " + to_string(scanParam.multi_output_red) - + "\n paperAlign : " + to_string(scanParam.paperAlign) + "\n papertype : " + to_string(scanParam.papertype) + "\n resolution_dst : " + to_string(scanParam.resolution_dst) + "\n scannum : " + to_string(scanParam.scannum) + "\n sharpen : " + to_string(scanParam.sharpen)+ - "\n Pixtype : "+to_string(scanParam.pixtype); - FileTools::write_log("D:\\2.txt", outinfo); -#endif // DEBUG m_iaList.clear(); if (scanParam.fillhole.is_fillhole) { @@ -173,7 +164,6 @@ void ImageMatQueue::setparam(const GScanCap& param) #endif 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))); } - if (param.is_autodiscradblank_normal || param.is_autodiscradblank_vince) { //m_iaList.push_back(shared_ptr(new CImageApplyDiscardBlank())); CImageApplyDiscardBlank* disBlank = new CImageApplyDiscardBlank(); @@ -249,6 +239,9 @@ void ImageMatQueue::setparam(const GScanCap& param) SharpenBlur sb = (SharpenBlur)param.sharpen; m_iaList.push_back(shared_ptr(new CImageApplySharpen(sb))); } + //Զɫʶ + if (param.automaticcolor) + m_iaList.push_back(shared_ptr(new CImageApplyColorRecognition(param.automaticcolortype==1? CImageApplyColorRecognition::ColorRecognitionMode::Color_Gray:CImageApplyColorRecognition::ColorRecognitionMode::Color_Mono))); //ֵ if (param.pixtype == 0) //threshold m_iaList.push_back(shared_ptr(new CImageApplyBWBinaray(CImageApplyBWBinaray::ThresholdType::THRESH_BINARY))); @@ -410,16 +403,7 @@ void ImageMatQueue::proc() for (int j = 0; j < m_iaList.size(); j++) { m_iaList[j]->apply(mats, scanParam.is_duplex); } - //if (scanParam.imageRotateDegree != 0.0 && scanParam.imageRotateDegree != 180.0) - //{ - // //cv::flip(mats[0], mats[0], -1); - // transpose(mats[0], mats[0]); - // flip(mats[0], mats[0], 1); - // transpose(mats[1], mats[1]); - // flip(mats[1], mats[1], 0); - - //} - + static int index = 0; for (int i = 0; i < mats.size(); i++) { if (!scanParam.is_duplex && i == 1) { mats[i].release(); @@ -430,10 +414,14 @@ void ImageMatQueue::proc() if (scanParam.pixtype == 1 && scanParam.hsvcorrect) if (mats[i].channels() == 3) cvtColor(mats[i], mats[i], cv::COLOR_BGR2GRAY); - idata = scanParam.pixtype == 0 ? (IMat2Bmp)Mat2BmpBw(mats[i], scanParam.resolution_dst) : Mat2Bmp(mats[i], scanParam.resolution_dst); + idata = (scanParam.pixtype == 0 || ((scanParam.automaticcolortype == 0) && (mats[i].channels() == 1))) ? (IMat2Bmp)Mat2BmpBw(mats[i], scanParam.resolution_dst) : Mat2Bmp(mats[i], scanParam.resolution_dst); if (!scanParam.multi_output_red) mats[i].release(); + auto data = idata.getBmpDataBuffer(); + //FILE* fd=fopen("D:\\0.bmp","w+"); + //fwrite(data->data(), data->size(),1 , fd); + //fclose(fd); EnqueueBmpBuffer(data); data.reset(); } diff --git a/huagao/Device/PublicFunc.h b/huagao/Device/PublicFunc.h index 90dd770f..03cf7e48 100644 --- a/huagao/Device/PublicFunc.h +++ b/huagao/Device/PublicFunc.h @@ -21,6 +21,8 @@ using namespace std; // cfgArray, const root.AddEmptySubObject("Config"); /*< basic setting*/ root["Config"].AddEmptySubArray(PIXTYPE); + root["Config"].AddEmptySubArray(AUTOMATICCOLOR); + root["Config"].AddEmptySubArray(AUTOMATICCOLORTYPR); root["Config"].AddEmptySubArray(PAPARSIZE); root["Config"].AddEmptySubArray(PAPERALIGN); root["Config"].AddEmptySubArray(ENSIZECHECK); @@ -191,6 +196,8 @@ void GscanJsonConfig::WriteJsonArrayToFile(std::vector cfgArray, const for (int i = 0; i < cfgArray.size(); i++) { root["Config"][PIXTYPE].Add((int)cfgArray[i].pixtype); + root["Config"][AUTOMATICCOLOR].Add(i,(bool)cfgArray[i].automaticcolor); + root["Config"][AUTOMATICCOLORTYPR].Add((int)cfgArray[i].automaticcolortype); root["Config"][PAPARSIZE].Add((int)cfgArray[i].papertype); root["Config"][PAPERALIGN].Add((int)cfgArray[i].paperAlign); root["Config"][ENSIZECHECK].Add(i, (bool)cfgArray[i].en_sizecheck); @@ -324,6 +331,10 @@ std::vector GscanJsonConfig::parseJsonFromString(const std::string str { neb::CJsonObject itmPixType; root["Config"].Get(PIXTYPE, itmPixType); + neb::CJsonObject itmautomaticcolor; + root["Config"].Get(AUTOMATICCOLOR, itmautomaticcolor); + neb::CJsonObject itmautomaticcolortype; + root["Config"].Get(AUTOMATICCOLORTYPR, itmautomaticcolortype); neb::CJsonObject itmAutoCrop; root["Config"].Get(AUTOCROP, itmAutoCrop); neb::CJsonObject itmPaperAlign; @@ -429,6 +440,10 @@ std::vector GscanJsonConfig::parseJsonFromString(const std::string str itmPixType.Get(i, i_value); cfp.pixtype = i_value; + itmautomaticcolor.Get(i, b_value); + cfp.automaticcolor = b_value; + itmautomaticcolortype.Get(i, i_value); + cfp.automaticcolortype = i_value; itmPaparSize.Get(i, i_value); cfp.papertype = (byte)i_value; itmPaperAlign.Get(i, i_value); @@ -538,6 +553,10 @@ std::vector GscanJsonConfig::parseJsonFromString(const std::string str root["Config"].Get(PIXTYPE, index); cfp.pixtype = index; + root["Config"].Get(AUTOMATICCOLOR, bvalue); + cfp.automaticcolor = bvalue; + root["Config"].Get(AUTOMATICCOLORTYPR, index); + cfp.automaticcolortype = index; root["Config"].Get(PAPARSIZE, index); cfp.papertype = index; root["Config"].Get(PAPERALIGN, index); diff --git a/huagao/ImageProcess/ImageApplyColorRecognition.cpp b/huagao/ImageProcess/ImageApplyColorRecognition.cpp new file mode 100644 index 00000000..caded0ca --- /dev/null +++ b/huagao/ImageProcess/ImageApplyColorRecognition.cpp @@ -0,0 +1,126 @@ +#include "ImageApplyColorRecognition.h" +#include "ImageApplyHeaders.h" + +static CImageApplyBWBinaray m_bw; +static CImageApplyAdjustColors m_ac(0, 50, 1.0f); + +/// +/// ͼǷDzɫǰ߼ԺɫؽжϣںɫΪɫΪDzɫ +/// +/// ͼ +/// trueΪɫfalseΪDzɫ +bool isColor(const cv::Mat& image) +{ + if (image.channels() != 3) return false; + + cv::Mat pDib_resize; + cv::resize(image, pDib_resize, cv::Size(image.cols / 9, image.rows / 9), 0, 0, cv::INTER_AREA); + + cv::Mat hsv; + cv::cvtColor(pDib_resize, hsv, cv::COLOR_BGR2HSV_FULL); + std::vector hsv_channels; + cv::split(hsv, hsv_channels); + + cv::Mat range_h1, range_h2, range_s, range_v; + cv::inRange(hsv_channels[0], 0, 85, range_h1); + cv::inRange(hsv_channels[0], 170, 255, range_h2); + cv::inRange(hsv_channels[1], 60, 255, range_s); + cv::inRange(hsv_channels[2], 100, 255, range_v); + + cv::Mat thre = (range_h1 | range_h2) & range_s & range_v; + return cv::sum(thre)[0] > 4; +} + +bool isGray(const cv::Mat& image) +{ + if (image.channels() == 3) return true; + + cv::Mat image_clone; + cv::resize(image, image_clone, cv::Size(), 0.25, 0.25); + int channels[] = { 0 }; + int histsize[] = { 256 }; + float range[] = { 0, 256 }; + const float* histRanges[] = { range }; + cv::Mat hist; + cv::calcHist(&image_clone, 1, channels, cv::Mat(), hist, 1, histsize, histRanges, true, false); + + float pixel_count0 = hist.at(0, 0); + float pixel_count255 = hist.at(255, 0); + float total = image_clone.total(); + + return ((pixel_count0 + pixel_count255) / total) > 0.95; +} + +CImageApplyColorRecognition::CImageApplyColorRecognition(ColorRecognitionMode mode) + : m_mode(mode) +{ +} + +CImageApplyColorRecognition::~CImageApplyColorRecognition(void) +{ +} + +void CImageApplyColorRecognition::apply(cv::Mat& pDib, int side) +{ + //жǷҪжDzɫ + if (m_mode == AllColor || m_mode == Color_Gray || m_mode == Color_Mono) + { + //Dzɫֱ˳ + if (isColor(pDib)) + { + m_result = Color; + return; + } + } + + if (pDib.channels() == 3) + cv::cvtColor(pDib, pDib, cv::COLOR_BGR2GRAY); + + if (m_mode == Color_Gray) + { + m_result = Gray; + return; + } + + if (m_mode == Color_Mono) + { + m_bw.apply(pDib, side); + m_result = Mono; + return; + } + + if (isGray(pDib)) + m_result = Gray; + else + { + m_bw.apply(pDib, side); + m_result = Mono; + } +} + +void CImageApplyColorRecognition::apply(std::vector& mats, bool isTwoSide) +{ + m_results.clear(); + if (mats.empty()) return; + + if (!mats[0].empty()) + apply(mats[0], 0); + + m_results.push_back(m_result); + + if (isTwoSide && mats.size() > 1) + if (!mats[1].empty()) + apply(mats[1], 1); + + m_results.push_back(m_result); +} + +CImageApplyColorRecognition::ColorType CImageApplyColorRecognition::getResult() +{ + return m_result; +} + +std::vector CImageApplyColorRecognition::getResults() +{ + return m_results; +} diff --git a/huagao/ImageProcess/ImageApplyColorRecognition.h b/huagao/ImageProcess/ImageApplyColorRecognition.h new file mode 100644 index 00000000..f0061221 --- /dev/null +++ b/huagao/ImageProcess/ImageApplyColorRecognition.h @@ -0,0 +1,66 @@ +/* + * ==================================================== + + * ܣɫʶ𣬽ʶᡰҶȡ24λͼתΪ256ɫ8λͼ ʶΪڰסͼתΪֵ8λͼ + * ߣά + * ʱ䣺2020/7/17 + * ޸ʱ䣺2020/12/15 + * 汾ţv1.0 2020/7/17 + * v1.1 2020/12/15 ԣжϺɫأںɫΪɫΪҶȣɾֱתͼ + * v1.2 2020/12/16 ɫģʽֻ֣ӽʽӿ + * ==================================================== + */ + +#ifndef IMAGE_APPLY_COLOR_RECOGNITION_H +#define IMAGE_APPLY_COLOR_RECOGNITION_H + +#include "ImageApply.h" + +class CImageApplyColorRecognition : public CImageApply +{ +public : + + //ɫʶģʽ + enum ColorRecognitionMode + { + AllColor, //ȫɫģʽ ʶܻDzɫҶȡڰ + Color_Gray, //ɫҶģʽ ʶֻDzɫ߻Ҷ + Color_Mono, //ɫڰģʽ ʶֻDzɫߺڰ + Gray_Mono //ҶȺڰģʽ ʶֻǻҶȻߺڰ + }; + + //ɫ + enum ColorType + { + Color, //ɫ + Gray, //Ҷ + Mono //ڰ + }; +public: + CImageApplyColorRecognition(ColorRecognitionMode mode = AllColor); + + virtual ~CImageApplyColorRecognition(void); + + virtual void apply(cv::Mat& pDib, int side); + + virtual void apply(std::vector& mats, bool isTwoSide); + + /// + /// ȡͼƬɫ͡void apply(cv::Mat&, int)ӿʹ + /// + /// ɫ + ColorType getResult(); + + /// + /// ȡͼƬɫ͡void apply(std::vector&, int)ӿʹ + /// + /// ɫ + std::vector getResults(); + +private: + ColorType m_result; + std::vector m_results; + ColorRecognitionMode m_mode; +}; + +#endif // !IMAGE_APPLY_CONCATENATION_H diff --git a/huagao/ImageProcess/ImageApplyHeaders.h b/huagao/ImageProcess/ImageApplyHeaders.h index b581c0e4..6a94ede1 100644 --- a/huagao/ImageProcess/ImageApplyHeaders.h +++ b/huagao/ImageProcess/ImageApplyHeaders.h @@ -16,5 +16,6 @@ #include "ImageApplyConcatenation.h" #include "ImageApplyHSVCorrect.h" #include "ImageApplyDetachNoise.h" +#include "ImageApplyColorRecognition.h" #endif diff --git a/huagao/huagaods.cpp b/huagao/huagaods.cpp index fa38706e..6bde8d08 100644 --- a/huagao/huagaods.cpp +++ b/huagao/huagaods.cpp @@ -722,6 +722,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) { { m_scanparam->filter = (byte)Filter::None; m_scanparam->enhance_color = (byte)Enchace_Color::Enhance_None; + m_scanparam->automaticcolor = FALSE; } else { @@ -739,6 +740,71 @@ Result HuagaoDs::identityOpenDs(const Identity&) { return capBadOperation(); } }; + + m_query[CapType::IAutomaticColorEnabled] = msgSupportGetAllSetReset; + m_caps[CapType::IAutomaticColorEnabled] = [this](Msg msg, Capability& data)->Result { + switch (msg) { + case Msg::Get: + data = Capability::createEnumeration(CapType::IAutomaticColorEnabled, { Bool(),Bool(true) }, Bool(m_scanparam->automaticcolor), FALSE); + return success(); + case Msg::GetCurrent: + data = Capability::createOneValue(CapType::IAutomaticColorEnabled, (Bool)m_scanparam->automaticcolor); + return success(); + case Msg::Reset: + case Msg::GetDefault: + m_scanparam->automaticcolor = FALSE; + data = Capability::createOneValue(CapType::IAutomaticColorEnabled, false); + return success(); + case Msg::Set: { + auto mech = data.currentItem(); + if (mech) + { + m_scanparam->automaticcolor = TRUE; + m_scanparam->pixtype = (int)PixelType::Rgb; + } + else + m_scanparam->automaticcolor = FALSE; + return success(); + } + default: + return capBadOperation(); + } + }; + + m_query[CapType::IAutomaticColorNonColorPixelType] = msgSupportGetAllSetReset; + m_caps[CapType::IAutomaticColorNonColorPixelType] = [this](Msg msg, Capability& data)->Result { + switch (msg) { + case Msg::Get: + data = Capability::createEnumeration(CapType::IAutomaticColorNonColorPixelType, { UInt16(TWPT_BW),UInt16(TWPT_GRAY) }, UInt16(m_scanparam->automaticcolortype), TWPT_GRAY); + return success(); + case Msg::GetCurrent: + data = Capability::createOneValue(CapType::IAutomaticColorNonColorPixelType, (UInt16)m_scanparam->automaticcolortype); + return success(); + + case Msg::Reset: + case Msg::GetDefault: + m_scanparam->automaticcolortype = TWPT_GRAY; + data = Capability::createOneValue(CapType::IAutomaticColorNonColorPixelType, TWPT_GRAY); + return success(); + + case Msg::Set: { + auto mech = data.currentItem(); + if (m_scanparam->automaticcolor == TRUE) + { + if ((UInt16)mech == 0 || (UInt16)mech == 1) + { + m_scanparam->automaticcolortype = (UInt16)mech; + return success(); + } + else + return badValue(); + } + return seqError(); + } + default: + return capBadOperation(); + } + }; //add------------------jpegȼ--------------------- m_query[CapType::IJpegQuality] = msgSupportGetAllSetReset; m_caps[CapType::IJpegQuality] = [this](Msg msg, Capability& data)->Result { @@ -876,10 +942,10 @@ Result HuagaoDs::identityOpenDs(const Identity&) { (UInt16)PaperSize::IsoB5,(UInt16)PaperSize::IsoB6,(UInt16)PaperSize::UsLetter, (UInt16)PaperSize::UsLegal,(UInt16)PaperSize::None #ifndef G300 -#if define G200 +#if defined G200 ,(UInt16)PaperSize::UsLedger,(UInt16)PaperSize::IsoB4, (UInt16)PaperSize::MaxSize,(UInt16)PaperSize::UsStatement -#elif define G400 +#elif defined G400 ,(UInt16)PaperSize::UsLedger,(UInt16)PaperSize::IsoB4 #endif #endif // @@ -927,7 +993,6 @@ Result HuagaoDs::identityOpenDs(const Identity&) { m_autosize = (paper == (byte)PaperSize::None) ? (UInt16)AutoSize::Auto : (UInt16)AutoSize::None; m_autoboarderdetcet = paper == (byte)PaperSize::None; m_scanparam->is_autocrop = paper == (byte)PaperSize::None ? 1 : 0; - } return success(); } diff --git a/huagao/huagaotwds.rc b/huagao/huagaotwds.rc index 28e55a35b1126c955a3c49de0975e9e9bd58cb34..d5ad69ac3881cd9ee78ee109ed92afdcae473441 100644 GIT binary patch delta 154 zcmeyfm+9CcrVVE#nJpR2HlLSVnKb#pR1SV;27d-0AP!;(W^iQ)nLLq4k=uyDjKPpW zhe3hCaPnRr|H%qDWjrnnnGA^xISly>=?s(kqNFB2D0Z2gmCd)gqGp!x(12OJqc^kz@z6z?p^zTZR&m diff --git a/huagao/resource.h b/huagao/resource.h index 64a27eec5b80fdf96456a40ddf01296657af0005..8525995d510da6e50f4aa0acd75126a8a42e80bd 100644 GIT binary patch delta 107 zcmeB3e~`Z61molf0xaAv44w>*3_cA04DOQ|HFYO@8A(kRVC3L+28w`0gBXGtTqhr7 zQJ(mKgV~V5aPmPW&CS;sAFxjr;S032_ delta 68 zcmaEm-jTlH1molh%zT@>m>#fmdN8;$I5T)N7*5_OtvlI(lWnpWR}2sAj~E|RYBRqqJ1+o0BN)d3 delta 83 zcmbOhGA(4oHV#%J1_K6z$&HMXo3C)Ru(1{}q%fpSUMMF!xqwe&vV*MD<~{sVun14y S!|$>Aj~E|RYBRqqJ1+o18W_v~