1.添加颜色识别算法。

2.修改除色选项卡默认勾选第一个。
This commit is contained in:
masayume 2020-12-17 17:02:33 +08:00
parent c4a9dc06e7
commit 6add56a846
16 changed files with 307 additions and 48 deletions

View File

@ -14,7 +14,8 @@
static std::vector<CString> color_Modes = {
_T("24位彩色"),
_T("256级灰度"),
_T("黑白")
_T("黑白"),
_T("颜色自动识别")
};

View File

@ -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);
}

View File

@ -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;

View File

@ -62,7 +62,6 @@ typedef enum tagUsbSupported {
UPDATE_SCAN_PARAMETER = 72,
// PC繁忙或出错
PC_SCAN_BUSY_or_ERROR = 73,
//摺角
DOG_EAR=74,
//幅面检测错误

View File

@ -240,7 +240,7 @@ int GScanO200::aquire_bmpdata(std::vector<unsigned char>& 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<unsigned char>& 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)
{

View File

@ -78,7 +78,7 @@ static std::map<PaperStatus, unsigned int> SupPaperTyps = {
static std::map<unsigned short, unsigned int> SupPixelTypes = {
{0, 0},//bw
{1, 0},//gray
{2, 1}//color
{2, 1},//color
};
static std::map<float, unsigned int> SupResolutions = {

View File

@ -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<CImageApply>(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<CImageApply>(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<CImageApply>(new CImageApplySharpen(sb)));
}
//×Ô¶¯ÑÕɫʶ±ð
if (param.automaticcolor)
m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyColorRecognition(param.automaticcolortype==1? CImageApplyColorRecognition::ColorRecognitionMode::Color_Gray:CImageApplyColorRecognition::ColorRecognitionMode::Color_Mono)));
//¶þÖµ»¯
if (param.pixtype == 0) //threshold
m_iaList.push_back(shared_ptr<CImageApply>(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();
}

View File

@ -21,6 +21,8 @@ using namespace std;
//<!»ù±¾Ñ¡Ï
#define PIXTYPE "iPixType"
#define AUTOMATICCOLOR "iautomaticcolor"
#define AUTOMATICCOLORTYPR "iautomaticcolortype"
#define PAPARSIZE "iPaparSize"
#define ENSIZECHECK "iEnSizeCheck"
#define PAPERALIGN "iPaperAlign"
@ -187,6 +189,8 @@ struct GScanCap
byte is_duplex; /**< True to use duplex false for simplex, ignored if flatbed*/
byte en_fold;
int pixtype; /**< type of pixels to transfer image as */
int automaticcolor; /**<顔色自動識別*/
int automaticcolortype; /**<顔色自動識別后非彩色上傳類型*/
//ScanRect scanrect;
float resolution_dst; /**< horizontal resolution */
float resolution_native;

View File

@ -20,10 +20,11 @@ GScanCap GscanJsonConfig::GetDefaultGscancapValue()
/*< basic page setting*/
gcap.pixtype = 2;//ĬÈϲÊÉ«
gcap.automaticcolor = FALSE;
gcap.automaticcolortype = 1;
gcap.paperAlign = PaperAlign::Rot0;
gcap.papertype = 0;//TwSS::NONE
gcap.en_sizecheck = FALSE;
gcap.en_sizecheck = FALSE;
gcap.is_autocrop = TRUE;//ĬÈÏ×Ô¶¯²ÃÇÐ
gcap.is_duplex = TRUE;
gcap.is_autodiscradblank_normal = FALSE;
@ -80,6 +81,8 @@ void GscanJsonConfig::SaveGscanCapConfig(const GScanCap & gcap, const std::strin
outJson.AddEmptySubObject("Config");//header
outJson["Config"].Add(PIXTYPE, (int)gcap.pixtype);
outJson["Config"].Add(AUTOMATICCOLOR, (bool)gcap.automaticcolor,false);
outJson["Config"].Add(AUTOMATICCOLORTYPR, (int)gcap.automaticcolortype);
outJson["Config"].Add(PAPARSIZE, (int)(gcap.papertype));
outJson["Config"].Add(PAPERALIGN, (int)(gcap.paperAlign));
outJson["Config"].Add(ENSIZECHECK, (bool)(gcap.en_sizecheck), false);
@ -137,6 +140,8 @@ void GscanJsonConfig::WriteJsonArrayToFile(std::vector<GScanCap> 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<GScanCap> 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<GScanCap> 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<GScanCap> 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<GScanCap> 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);

View File

@ -0,0 +1,126 @@
#include "ImageApplyColorRecognition.h"
#include "ImageApplyHeaders.h"
static CImageApplyBWBinaray m_bw;
static CImageApplyAdjustColors m_ac(0, 50, 1.0f);
/// <summary>
/// 检测图像是否是彩色。当前逻辑仅针对红色像素进行判断,即存在红色像素则为彩色,否则为非彩色
/// </summary>
/// <param name="image">待测图像</param>
/// <returns>true为彩色false为非彩色</returns>
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<cv::Mat> 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<float>(0, 0);
float pixel_count255 = hist.at<float>(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)
{
//先判断是否需要判断是彩色
if (m_mode == AllColor || m_mode == Color_Gray || m_mode == Color_Mono)
{
//如果是彩色,直接退出
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<cv::Mat>& 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::ColorType> CImageApplyColorRecognition::getResults()
{
return m_results;
}

View File

@ -0,0 +1,66 @@
/*
* ====================================================
* 242568 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, //全色模式 识别结果可能会是彩色、灰度、黑白
Color_Gray, //彩色灰度模式 识别结果只会是彩色或者灰度
Color_Mono, //彩色黑白模式 识别结果只会是彩色或者黑白
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<cv::Mat>& mats, bool isTwoSide);
/// <summary>
/// 获取图片色彩类型。配合void apply(cv::Mat&, int)接口使用
/// </summary>
/// <returns>色彩类型</returns>
ColorType getResult();
/// <summary>
/// 获取图片色彩类型。配合void apply(std::vector<cv::Mat>&, int)接口使用
/// </summary>
/// <returns>色彩类型数组</returns>
std::vector<ColorType> getResults();
private:
ColorType m_result;
std::vector<ColorType> m_results;
ColorRecognitionMode m_mode;
};
#endif // !IMAGE_APPLY_CONCATENATION_H

View File

@ -16,5 +16,6 @@
#include "ImageApplyConcatenation.h"
#include "ImageApplyHSVCorrect.h"
#include "ImageApplyDetachNoise.h"
#include "ImageApplyColorRecognition.h"
#endif

View File

@ -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<Bool>(CapType::IAutomaticColorEnabled, { Bool(),Bool(true) }, Bool(m_scanparam->automaticcolor), FALSE);
return success();
case Msg::GetCurrent:
data = Capability::createOneValue<Bool>(CapType::IAutomaticColorEnabled, (Bool)m_scanparam->automaticcolor);
return success();
case Msg::Reset:
case Msg::GetDefault:
m_scanparam->automaticcolor = FALSE;
data = Capability::createOneValue<Bool>(CapType::IAutomaticColorEnabled, false);
return success();
case Msg::Set: {
auto mech = data.currentItem<CapType::IAutomaticColorEnabled>();
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<UInt16>(CapType::IAutomaticColorNonColorPixelType, { UInt16(TWPT_BW),UInt16(TWPT_GRAY) }, UInt16(m_scanparam->automaticcolortype), TWPT_GRAY);
return success();
case Msg::GetCurrent:
data = Capability::createOneValue<UInt16>(CapType::IAutomaticColorNonColorPixelType, (UInt16)m_scanparam->automaticcolortype);
return success();
case Msg::Reset:
case Msg::GetDefault:
m_scanparam->automaticcolortype = TWPT_GRAY;
data = Capability::createOneValue<UInt16>(CapType::IAutomaticColorNonColorPixelType, TWPT_GRAY);
return success();
case Msg::Set: {
auto mech = data.currentItem<CapType::IAutomaticColorNonColorPixelType>();
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();
}

Binary file not shown.

Binary file not shown.

Binary file not shown.