禁用黑白模式上传UV图

This commit is contained in:
masayume 2020-12-01 11:15:32 +08:00
parent 2d7e4ae62c
commit 91c893281c
16 changed files with 96 additions and 51 deletions

View File

@ -50,9 +50,15 @@ BOOL CAboutDlg::OnInitDialog()
SetDlgItemText(IDC_LBDERIVERVERSON, HG_VERSION_INFO); SetDlgItemText(IDC_LBDERIVERVERSON, HG_VERSION_INFO);
SetDlgItemText(IDC_LBCOMPANY, LIMIT_INFO); SetDlgItemText(IDC_LBCOMPANY, LIMIT_INFO);
#ifndef MAKEHUAGAO CStatic* pStatic = (CStatic*)GetDlgItem(IDC_PICABOUTHUAGO);
GetDlgItem(IDC_PICABOUTHUAGO)->ShowWindow(FALSE); #ifdef MAKEHUAGAO
//GetDlgItem(IDC_PICABOUTHUAGO)->ShowWindow(true);
HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BMPABOUTDLG));
#else defined MAKERTW
HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BMPRHW));
#endif #endif
pStatic->ModifyStyle(0xF, SS_BITMAP | SS_CENTERIMAGE);
pStatic->SetBitmap(hBitmap);
SetDlgItemText(IDC_LBDESIGNERVALUE, COMPANY_NAME); SetDlgItemText(IDC_LBDESIGNERVALUE, COMPANY_NAME);
SetDlgItemText(IDC_LBCOMPANYADDRESS, COMPANY_ADDRESS); SetDlgItemText(IDC_LBCOMPANYADDRESS, COMPANY_ADDRESS);
return TRUE; // return TRUE unless you set the focus to a control return TRUE; // return TRUE unless you set the focus to a control

View File

@ -191,6 +191,15 @@ void CBasicPage::updateCmbDuplex(BOOL insert)
int tmp_duplexindex = m_cmBoxDuplex->GetCurSel(); int tmp_duplexindex = m_cmBoxDuplex->GetCurSel();
int tmp_resindex = m_cmBoxResultion->GetCurSel(); int tmp_resindex = m_cmBoxResultion->GetCurSel();
int totalcount = m_cmBoxDuplex->GetCount(); int totalcount = m_cmBoxDuplex->GetCount();
if (tmp_colorindex == 2)
{
((CButton*)(this->GetDlgItem(IDC_CKBENABLEUV)))->SetCheck(false);
((CButton*)(this->GetDlgItem(IDC_CKBENABLEUV)))->EnableWindow(false);
}
else
{
((CButton*)(this->GetDlgItem(IDC_CKBENABLEUV)))->EnableWindow(true);
}
if (tmp_colorindex == 0 && tmp_paperindex >= 18 && tmp_resindex == 4) { if (tmp_colorindex == 0 && tmp_paperindex >= 18 && tmp_resindex == 4) {
m_cmBoxDuplex->DeleteString(4); m_cmBoxDuplex->DeleteString(4);
m_cmBoxDuplex->SetCurSel(1); m_cmBoxDuplex->SetCurSel(1);

View File

@ -105,4 +105,4 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/redistribute)
set(huagaotwain_path "$<$<CONFIG:Debug>:${LIBRARY_OUTPUT_PATH}\\Debug\\huagaotwain.dll>" "$<$<CONFIG:Release>:${LIBRARY_OUTPUT_PATH}\\Release\\huagaotwain.dll>") set(huagaotwain_path "$<$<CONFIG:Debug>:${LIBRARY_OUTPUT_PATH}\\Debug\\huagaotwain.dll>" "$<$<CONFIG:Release>:${LIBRARY_OUTPUT_PATH}\\Release\\huagaotwain.dll>")
string(REPLACE "/" "\\" huagaotwain_path ${huagaotwain_path}) string(REPLACE "/" "\\" huagaotwain_path ${huagaotwain_path})
add_custom_command(TARGET huagaotwain POST_BUILD COMMAND copy ${huagaotwain_path} $ENV{windir}\\twain_32\\huagoscan\\huagaotwain.ds) #add_custom_command(TARGET huagaotwain POST_BUILD COMMAND copy ${huagaotwain_path} $ENV{windir}\\twain_32\\huagoscan\\huagaotwain.ds)

View File

@ -1,3 +1,4 @@
#pragma once
#include "G400ScanConfig.h" #include "G400ScanConfig.h"
G400ScanConfig::G400ScanConfig(GScanCap& gcap) G400ScanConfig::G400ScanConfig(GScanCap& gcap)

View File

@ -164,10 +164,10 @@ void ImageMatQueue::setparam(const GScanCap& param)
m_iaList.push_back(shared_ptr< CImageApply>(apply)); m_iaList.push_back(shared_ptr< CImageApply>(apply));
} }
if (scanParam.en_fold) //if (scanParam.en_fold)
{ //{
m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyConcatenation(CImageApplyConcatenation::horizontal))); // m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyConcatenation(CImageApplyConcatenation::horizontal)));
} //}
if (param.imageRotateDegree != 0.0 || param.is_backrotate180 || param.is_autotext) if (param.imageRotateDegree != 0.0 || param.is_backrotate180 || param.is_autotext)
{ {
@ -186,7 +186,13 @@ void ImageMatQueue::setparam(const GScanCap& param)
TCHAR szIniFile[MAX_PATH] = { 0 }; TCHAR szIniFile[MAX_PATH] = { 0 };
SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_WINDOWS, TRUE); SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_WINDOWS, TRUE);
#ifdef MAKEHUAGAO
_tcscat(szIniFile, _T("\\twain_32\\HuaGoScan\\tessdata")); _tcscat(szIniFile, _T("\\twain_32\\HuaGoScan\\tessdata"));
#else defined MAKERTW
_tcscat(szIniFile, _T("\\twain_32\\RighTWayScan\\tessdata"));
#endif // MAKEHUGO
int iLen = WideCharToMultiByte(CP_ACP, 0, szIniFile, -1, NULL, 0, NULL, NULL); int iLen = WideCharToMultiByte(CP_ACP, 0, szIniFile, -1, NULL, 0, NULL, NULL);
char* chRtn = new char[iLen * sizeof(char)]; char* chRtn = new char[iLen * sizeof(char)];
WideCharToMultiByte(CP_ACP, 0, szIniFile, -1, chRtn, iLen, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, szIniFile, -1, chRtn, iLen, NULL, NULL);
@ -239,6 +245,8 @@ void ImageMatQueue::proc()
for (auto& buf : buffs) for (auto& buf : buffs)
{ {
ImreadModes rm = IMREAD_COLOR;//全部按照彩色解压 ImreadModes rm = IMREAD_COLOR;//全部按照彩色解压
if (scanParam.pixtype == 0)
rm = ImreadModes::IMREAD_GRAYSCALE;
try try
{ {
cv::Mat mat = cv::imdecode(*buf, rm); cv::Mat mat = cv::imdecode(*buf, rm);
@ -265,6 +273,8 @@ void ImageMatQueue::proc()
for (auto& buf : uvbuffers) for (auto& buf : uvbuffers)
{ {
ImreadModes rm = IMREAD_COLOR;//全部按照彩色解压 ImreadModes rm = IMREAD_COLOR;//全部按照彩色解压
if (scanParam.pixtype == 0)
rm = ImreadModes::IMREAD_GRAYSCALE;
try try
{ {
cv::Mat mat = cv::imdecode(*buf, rm); cv::Mat mat = cv::imdecode(*buf, rm);
@ -302,7 +312,6 @@ void ImageMatQueue::proc()
else if (typeid(*ptr) == typeid(CImageApplyRotation)) else if (typeid(*ptr) == typeid(CImageApplyRotation))
angleResults = dynamic_cast<CImageApplyRotation*>(ptr)->angleResults(); angleResults = dynamic_cast<CImageApplyRotation*>(ptr)->angleResults();
} }
if (!m_uvMats.empty()) if (!m_uvMats.empty())
{ {
//拼接原图和UV图 //拼接原图和UV图
@ -313,12 +322,22 @@ void ImageMatQueue::proc()
break; break;
} }
cv::Mat mergeOrgin_UV = ImageApplyUV::Apply(mats[j], m_uvMats[j], rects[j], isDesaskew, angleResults.size() > 0 ? angleResults[j] : 0); cv::Mat mergeOrgin_UV = ImageApplyUV::Apply(mats[j], m_uvMats[j], rects[j], isDesaskew, angleResults.size() > 0 ? angleResults[j] : 0);
//cv::imwrite("D:/pic/mergeOrgin_UV" + std::to_string(j) + ".bmp", mergeOrgin_UV); //cv::imwrite("D:/0.bmp", mergeOrgin_UV);
if (!mergeOrgin_UV.empty()) if (!mergeOrgin_UV.empty())
mats[j] = mergeOrgin_UV; mats[j] = mergeOrgin_UV;
} }
m_uvMats.clear(); m_uvMats.clear();
} }
if (scanParam.en_fold)
{
CImageApplyConcatenation Concatenation;
if(scanParam.en_uv)
Concatenation= CImageApplyConcatenation(CImageApplyConcatenation::vertical);
else
Concatenation = CImageApplyConcatenation(CImageApplyConcatenation::horizontal);
Concatenation.apply(mats, scanParam.is_duplex);
}
for (int i = 0; i < mats.size(); i++) { for (int i = 0; i < mats.size(); i++) {
if (!scanParam.is_duplex && i == 1) { if (!scanParam.is_duplex && i == 1) {
@ -331,6 +350,7 @@ void ImageMatQueue::proc()
IMat2Bmp idata; IMat2Bmp idata;
idata = scanParam.pixtype == 0 ? (IMat2Bmp)Mat2BmpBw(mats[i], scanParam.resolution_dst) : Mat2Bmp(mats[i], scanParam.resolution_dst); idata = scanParam.pixtype == 0 ? (IMat2Bmp)Mat2BmpBw(mats[i], scanParam.resolution_dst) : Mat2Bmp(mats[i], scanParam.resolution_dst);
auto data = idata.getBmpDataBuffer(); auto data = idata.getBmpDataBuffer();
CStdioFile file;
EnqueueBmpBuffer(data); EnqueueBmpBuffer(data);
} }
else else

View File

@ -89,7 +89,7 @@ public:
int pos = col % 8; int pos = col % 8;
int pix = *(imageData + row * mat.step1() + col); int pix = *(imageData + row * mat.step1() + col);
temp = 1 << (7 - pos); temp = 1 << (7 - pos);
if (pix == 255) if (pix ==255)
{ {
*(binary + (height - row - 1) * m_lineByte + col / 8) |= temp ; *(binary + (height - row - 1) * m_lineByte + col / 8) |= temp ;
} }

View File

@ -437,8 +437,8 @@ CString GetHidedlgPath()
SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_WINDOWS, TRUE); SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_WINDOWS, TRUE);
#ifdef MAKEHUAGAO #ifdef MAKEHUAGAO
_tcscat(szIniFile, _T("\\twain_32\\HuaGoScan\\hidedlg.exe")); _tcscat(szIniFile, _T("\\twain_32\\HuaGoScan\\hidedlg.exe"));
#else // MAKEHUAGAO #else defined MAKERTW
_tcscat(szIniFile, _T("\\twain_32\\ZhibenScan\\hidedlg.exe")); _tcscat(szIniFile, _T("\\twain_32\\RighTWayScan\\hidedlg.exe"));
#endif #endif
int iLen = WideCharToMultiByte(CP_ACP, 0, szIniFile, -1, NULL, 0, NULL, NULL); int iLen = WideCharToMultiByte(CP_ACP, 0, szIniFile, -1, NULL, 0, NULL, NULL);
char* chRtn = new char[iLen * sizeof(char)]; char* chRtn = new char[iLen * sizeof(char)];

View File

@ -3,32 +3,33 @@
#include "Device/PublicFunc.h" #include "Device/PublicFunc.h"
#include "Device/PaperSize.h" #include "Device/PaperSize.h"
class G400ScanConfig : #pragma once
public IConfig //class G400ScanConfig :
{ // public IConfig
public: //{
union Configuration //public:
{ // union Configuration
struct // {
{ // struct
unsigned int pageSize : 5; // {
unsigned int isColor : 1; // unsigned int pageSize : 5;
unsigned int dpi : 2; // unsigned int isColor : 1;
unsigned int doubleFeeded : 1; // unsigned int dpi : 2;
unsigned int enableUV : 1; // unsigned int doubleFeeded : 1;
unsigned int enableLed : 1; // unsigned int enableUV : 1;
unsigned int reversed1 : 6; // unsigned int enableLed : 1;
unsigned int isCorrect : 1; // unsigned int reversed1 : 6;
unsigned int dstHeight : 8; // unsigned int isCorrect : 1;
unsigned int reversed2 : 6; // unsigned int dstHeight : 8;
}params; // unsigned int reversed2 : 6;
unsigned int value; // }params;
}; // unsigned int value;
G400ScanConfig(GScanCap& gcap); // };
virtual ~G400ScanConfig(); // G400ScanConfig(GScanCap& gcap);
virtual unsigned int GetData() override; // virtual ~G400ScanConfig();
private: // virtual unsigned int GetData() override;
Configuration cfg; //private:
Device::PaperSize PaperSize; // Configuration cfg;
}; // Device::PaperSize PaperSize;
//};

View File

@ -55,11 +55,9 @@ void ImageApplyUV::Apply(cv::Mat& image, const cv::Mat& uv, int dpi, int thresh)
cv::Mat ImageApplyUV::Apply(const cv::Mat& image, const cv::Mat& uv, const cv::RotatedRect& uvRoi, bool isDesaskew, int angle) cv::Mat ImageApplyUV::Apply(const cv::Mat& image, const cv::Mat& uv, const cv::RotatedRect& uvRoi, bool isDesaskew, int angle)
{ {
if (uvRoi.size.width == 0) return cv::Mat(); if (uvRoi.size.width == 0) return cv::Mat();
cv::RotatedRect uvRoi_clone = uvRoi; cv::RotatedRect uvRoi_clone = uvRoi;
cv::Mat dst = cv::Mat::zeros(image.rows > image.cols ? image.rows : (image.rows * 2), image.cols > image.rows ? image.cols : (image.cols * 2), image.type()); cv::Mat dst = cv::Mat::zeros(image.rows > image.cols ? image.rows : (image.rows * 2), image.cols > image.rows ? image.cols : (image.cols * 2), image.type());
image.copyTo(dst(cv::Rect(0, 0, image.cols, image.rows))); image.copyTo(dst(cv::Rect(0, 0, image.cols, image.rows)));
cv::Mat dst_uv = dst(cv::Rect(image.rows > image.cols ? image.cols : 0, image.rows > image.cols ? 0 : image.rows, image.cols, image.rows)); cv::Mat dst_uv = dst(cv::Rect(image.rows > image.cols ? image.cols : 0, image.rows > image.cols ? 0 : image.rows, image.cols, image.rows));
if (isDesaskew) if (isDesaskew)
{ {
@ -92,7 +90,6 @@ cv::Mat ImageApplyUV::Apply(const cv::Mat& image, const cv::Mat& uv, const cv::R
dstTri[1] = cv::Point2f(0, 0); dstTri[1] = cv::Point2f(0, 0);
dstTri[2] = cv::Point2f(dst_uv.cols - 1, 0); dstTri[2] = cv::Point2f(dst_uv.cols - 1, 0);
} }
cv::Mat warp_mat = cv::getAffineTransform(srcTri, dstTri); cv::Mat warp_mat = cv::getAffineTransform(srcTri, dstTri);
if (uv.channels() == 1 && dst_uv.channels() == 3) if (uv.channels() == 1 && dst_uv.channels() == 3)
{ {
@ -101,7 +98,9 @@ cv::Mat ImageApplyUV::Apply(const cv::Mat& image, const cv::Mat& uv, const cv::R
cv::cvtColor(uv_temp, dst_uv, cv::COLOR_GRAY2BGR); cv::cvtColor(uv_temp, dst_uv, cv::COLOR_GRAY2BGR);
} }
else else
{
cv::warpAffine(uv, dst_uv, warp_mat, dst_uv.size()); cv::warpAffine(uv, dst_uv, warp_mat, dst_uv.size());
}
} }
else else
{ {
@ -112,7 +111,6 @@ cv::Mat ImageApplyUV::Apply(const cv::Mat& image, const cv::Mat& uv, const cv::R
roi_dst_right.width = cv::min(dst_uv.cols, uvBoundingRect.width); roi_dst_right.width = cv::min(dst_uv.cols, uvBoundingRect.width);
roi_dst_right.y = dst_uv.rows > uvBoundingRect.height ? (dst_uv.rows - uvBoundingRect.height) / 2 : 0; roi_dst_right.y = dst_uv.rows > uvBoundingRect.height ? (dst_uv.rows - uvBoundingRect.height) / 2 : 0;
roi_dst_right.height = cv::min(dst_uv.rows, uvBoundingRect.height); roi_dst_right.height = cv::min(dst_uv.rows, uvBoundingRect.height);
cv::Rect roi_uv_BoundingRect((uvBoundingRect.width - roi_dst_right.width) / 2, cv::Rect roi_uv_BoundingRect((uvBoundingRect.width - roi_dst_right.width) / 2,
(uvBoundingRect.height - roi_dst_right.height) / 2, roi_dst_right.width, roi_dst_right.height); (uvBoundingRect.height - roi_dst_right.height) / 2, roi_dst_right.width, roi_dst_right.height);

BIN
huagao/bitmap1.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -66,9 +66,15 @@ TWPP_ENTRY_MFC(HuagaoDs)
static constexpr const Identity srcIdent( static constexpr const Identity srcIdent(
Version(3, 3, Language::English, Country::China, "v3.3.2.4"), Version(3, 3, Language::English, Country::China, "v3.3.2.4"),
DataGroup::Image, DataGroup::Image,
#ifdef MAKEHUAGAO
"HUAGO", "HUAGO",
"G300 Series", "G300 Series",
"HUAGOSCAN G300 UVTWAIN" "HUAGOSCAN G300 UVTWAIN"
#else defined MAKERTW
"RIGHTWAY",
"G300 Series",
"RIGHTWAYSCAN G300 UVTWAIN"
#endif // MAKEHUAGAO
#if defined(_MSC_VER) #if defined(_MSC_VER)
"" ""
#elif defined(__GNUC__) #elif defined(__GNUC__)
@ -378,6 +384,7 @@ Result HuagaoDs::eventProcess(const Identity&, Event& event) {
// // QApplication::processEvents(); - TODO: needs more investigation; results in freeze when attempting to scan using old DSM // // QApplication::processEvents(); - TODO: needs more investigation; results in freeze when attempting to scan using old DSM
// QApplication::sendPostedEvents(); // QApplication::sendPostedEvents();
guiTwain->SendMessage((UINT)(event.message())); guiTwain->SendMessage((UINT)(event.message()));
//guiTwain->PostMessage((UINT)(event.message()));
} }
event.setMessage(Msg::Null); event.setMessage(Msg::Null);
@ -434,7 +441,8 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
bmInfo.biBitCount = m_scanparam->pixtype == 2 ? 24 : (m_scanparam->pixtype == 1 ? 8 : 0); bmInfo.biBitCount = m_scanparam->pixtype == 2 ? 24 : (m_scanparam->pixtype == 1 ? 8 : 0);
m_iBitdepth = m_scanparam->pixtype == 2 ? 24 : (m_scanparam->pixtype == 1 ? 8 : 0); m_iBitdepth = m_scanparam->pixtype == 2 ? 24 : (m_scanparam->pixtype == 1 ? 8 : 0);
scanner->open(0x064B, 0x7823); scanner->open(0x064B, 0x7823);
//scanner->open(0x31c9, 0x8200);
//scanner->open(0x3072, 0x0300);
if (!scanner->IsConnected()) { if (!scanner->IsConnected()) {
ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString("201"), NULL, SW_HIDE); ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString("201"), NULL, SW_HIDE);
return checkDeviceOnline(); return checkDeviceOnline();
@ -1104,6 +1112,8 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
return success(); return success();
case Msg::Set: { case Msg::Set: {
auto mech = data.currentItem<Bool>(); auto mech = data.currentItem<Bool>();
if(m_scanparam->pixtype==0)
return badValue();
m_scanparam->en_uv = mech; m_scanparam->en_uv = mech;
return success(); return success();
} }
@ -2439,7 +2449,7 @@ Twpp::Result HuagaoDs::showTwainUI(Twpp::UserInterface& ui, bool bUiOnly)
void HuagaoDs::DeviceEvent_callback(int eventID, void* usrdata) void HuagaoDs::DeviceEvent_callback(int eventID, void* usrdata)
{ {
HuagaoDs* This = (HuagaoDs*)usrdata; HuagaoDs* This = (HuagaoDs*)usrdata;
This->onDeviceEvent(eventID); //This->onDeviceEvent(eventID);
} }
void HuagaoDs::onDeviceEvent(int eventID) void HuagaoDs::onDeviceEvent(int eventID)
@ -2502,7 +2512,6 @@ Twpp::Result HuagaoDs::startScan()
} }
scanner->ResetScanner(); scanner->ResetScanner();
scanner->clear_hwerror(); scanner->clear_hwerror();
scanner->config_params(*m_scanparam); scanner->config_params(*m_scanparam);
//FileTools::write_log("D:\\2.txt", "is_autodiscradblank_normal = " + to_string(m_scanparam->is_autodiscradblank_normal) + " 222is_autodiscradblank_vince =" + to_string(m_scanparam->is_autodiscradblank_vince)); //FileTools::write_log("D:\\2.txt", "is_autodiscradblank_normal = " + to_string(m_scanparam->is_autodiscradblank_normal) + " 222is_autodiscradblank_vince =" + to_string(m_scanparam->is_autodiscradblank_vince));
@ -2523,6 +2532,7 @@ Twpp::Result HuagaoDs::startScan()
guiIndicator->ShowWindow(SW_SHOWNORMAL); guiIndicator->ShowWindow(SW_SHOWNORMAL);
} }
scanner->Scanner_StartScan(m_scanparam->scannum); scanner->Scanner_StartScan(m_scanparam->scannum);
if (bmpData.size() > 0) if (bmpData.size() > 0)
bmpData.clear(); bmpData.clear();

Binary file not shown.

BIN
huagao/icon_rwlogo.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

BIN
huagao/icon_rwlogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Binary file not shown.