1.修复TWAINUI 点击× 关闭窗体是异常问题;

2.针对长文稿300DPI对折功能,做了功能可用性限制;
3.修复对接科大讯飞软件时,无法调用驱动问题;
This commit is contained in:
lovelyyoung 2020-05-16 09:59:44 +08:00
parent a11f063bf4
commit 562491e08d
16 changed files with 709 additions and 1020 deletions

View File

@ -136,6 +136,7 @@ void CBasicPage::OnBnClickedBtnabout()
void CBasicPage::OnCbnSelchangeCmbcolortype()
{
// TODO: 在此添加控件通知处理程序代码
updateCmbDuplex(TRUE);
m_dataChange();
}
@ -148,7 +149,7 @@ void CBasicPage::OnCbnSelchangeCmbss()
{
sleIndex = 0;
}
updateCmbDuplex(TRUE);
m_dataChange();
}
@ -156,6 +157,7 @@ void CBasicPage::OnCbnSelchangeCmbss()
void CBasicPage::OnCbnSelchangeCmbreslution()
{
// TODO: 在此添加控件通知处理程序代码
updateCmbDuplex(TRUE);
}
@ -168,6 +170,7 @@ void CBasicPage::OnCbnSelchangeCmbduplex()
//DevnMax = index == 2 ? 200 : 300;
m_dataChange();
//}
updateCmbDuplex(TRUE);
}
//跳过空白页设置页面
@ -188,3 +191,22 @@ void CBasicPage::SetScannerInfo(std::string hdVersion, std::string serialNum)
m_hdVersion = hdVersion;
m_serialNum = serialNum;
}
void CBasicPage::updateCmbDuplex(BOOL insert)
{
//m_cmBoxDuplex->GetCurSel();
int tmp_colorindex=m_cmBoxColorMode->GetCurSel();
int tmp_paperindex = m_cmBoxSS->GetCurSel();
int tmp_duplexindex = m_cmBoxDuplex->GetCurSel();
int tmp_resindex = m_cmBoxResultion->GetCurSel();
int totalcount = m_cmBoxDuplex->GetCount();
if (tmp_colorindex == 0 && tmp_paperindex >= 18 && tmp_resindex == 4) {
m_cmBoxDuplex->DeleteString(4);
m_cmBoxDuplex->SetCurSel(1);
}
else {
if (totalcount != 5) {
m_cmBoxDuplex->InsertString(4, TEXT("对折"));
}
}
}

View File

@ -23,7 +23,7 @@ public:
afx_msg void OnCbnSelchangeCmbss();
afx_msg void OnCbnSelchangeCmbreslution();
afx_msg void OnCbnSelchangeCmbduplex();
void updateCmbDuplex(BOOL insert);
public:
int AreaNum;
int DevnMax;

View File

@ -1,288 +0,0 @@
/***************************************************************************
* Copyright ?2007 TWAIN Working Group:
* Adobe Systems Incorporated, AnyDoc Software Inc., Eastman Kodak Company,
* Fujitsu Computer Products of America, JFL Peripheral Solutions Inc.,
* Ricoh Corporation, and Xerox Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the TWAIN Working Group nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TWAIN Working Group ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL TWAIN Working Group BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
***************************************************************************/
/**
* @file CTiffWriter.cpp
* Write an image to disk as a tiff file.
* @author JFL Peripheral Solutions Inc.
* @date October 2007
*/
#include "stdafx.h"
#include "CTiffWriter.h"
#include <sstream>
CTiffWriter::CTiffWriter(const string& _filename,
const long int _width,
const long int _height,
const int _bitsPerPixel,
const unsigned long int _bytesPerRow)
{
m_pImageStream = 0;
m_nOffset = 0;
m_filename = _filename;
m_ImageWidth.TagID = kTIFF_TAG_IMGWIDTH;
m_ImageWidth.DataType = kTIFF_TY_LONG;
m_ImageWidth.DataCount = 1;
m_ImageWidth.DataOffset = _width;
m_ImageLength.TagID = kTIFF_TAG_IMGLENGTH;
m_ImageLength.DataType = kTIFF_TY_LONG;
m_ImageLength.DataCount = 1;
m_ImageLength.DataOffset = _height;
m_BitsPerSample.TagID = kTIFF_TAG_BITSPERSAMPLE;
m_BitsPerSample.DataType = kTIFF_TY_SHORT;
m_BitsPerSample.DataCount = 1;
if(24 == _bitsPerPixel)
{
m_BitsPerSample.DataOffset = 8;
}
else
{
m_BitsPerSample.DataOffset = _bitsPerPixel;
}
m_Compression.TagID = kTIFF_TAG_COMPRESSION;
m_Compression.DataType = kTIFF_TY_SHORT;
m_Compression.DataCount = 1;
m_Compression.DataOffset = 1;
m_PhotometricInterp.TagID = kTIFF_TAG_PHOTOMETRICINT;
m_PhotometricInterp.DataType = kTIFF_TY_SHORT;
m_PhotometricInterp.DataCount = 1;
if(24 == _bitsPerPixel)
{
m_PhotometricInterp.DataOffset = 2;
}
else
{
m_PhotometricInterp.DataOffset = 1;
}
// -there is only one strip that contains all the row data, and it starts right after the header.
// -There are always 12 tags being written for each tiff.
m_StripOffsets.TagID = kTIFF_TAG_STRIPOFFSETS;
m_StripOffsets.DataType = kTIFF_TY_SHORT;
m_StripOffsets.DataCount = 1;
m_StripOffsets.DataOffset = getSizeofHeader();
m_SamplesPerPixel.TagID = kTIFF_TAG_SAMPLESPERPIXEL;
m_SamplesPerPixel.DataType = kTIFF_TY_SHORT;
if(24 == _bitsPerPixel)
{
m_SamplesPerPixel.DataCount = 1;
m_SamplesPerPixel.DataOffset = 3;
}
else
{
m_SamplesPerPixel.DataCount = 1;
m_SamplesPerPixel.DataOffset = 1;
}
m_RowsPerStrip.TagID = kTIFF_TAG_ROWSPERSTRIP;
m_RowsPerStrip.DataType = kTIFF_TY_LONG;
m_RowsPerStrip.DataCount = 1;
m_RowsPerStrip.DataOffset = _height;
m_StripByteCounts.TagID = kTIFF_TAG_STRIPBYTECOUNTS;
m_StripByteCounts.DataType = kTIFF_TY_LONG;
m_StripByteCounts.DataCount = 1;
m_StripByteCounts.DataOffset = _bytesPerRow * _height;
m_XResolution.TagID = kTIFF_TAG_XRESOLUTION;
m_XResolution.DataType = kTIFF_TY_RATIONAL;
m_XResolution.DataCount = 1;
m_XResolution.DataOffset = m_StripOffsets.DataOffset - sizeof(DWORD)*4; // fixed offset from the end of the header
setXResolution(100, 1);
m_YResolution.TagID = kTIFF_TAG_YRESOLUTION;
m_YResolution.DataType = kTIFF_TY_RATIONAL;
m_YResolution.DataCount = 1;
m_YResolution.DataOffset = m_StripOffsets.DataOffset - sizeof(DWORD)*2; // fixed offset from the end of the header
setYResolution(100, 1);
m_ResolutionUnit.TagID = kTIFF_TAG_RESOLUTIONUNIT;
m_ResolutionUnit.DataType = kTIFF_TY_SHORT;
m_ResolutionUnit.DataCount = 1;
m_ResolutionUnit.DataOffset = 2;
}
CTiffWriter::~CTiffWriter()
{
if(0 != m_pImageStream)
{
if(m_pImageStream->is_open())
{
m_pImageStream->close();
}
delete m_pImageStream;
}
}
void CTiffWriter::setImageWidth(const long int _v)
{
m_ImageWidth.DataOffset = _v;
}
void CTiffWriter::setImageHeight(const long int _v)
{
m_ImageLength.DataOffset = _v;
}
void CTiffWriter::setBitsPerSample(const int _v)
{
m_BitsPerSample.DataOffset = _v;
}
void CTiffWriter::setCompression(const int _v)
{
m_Compression.DataOffset = _v;
}
void CTiffWriter::setPhotometricInterp(const int _v)
{
m_PhotometricInterp.DataOffset = _v;
}
void CTiffWriter::setSamplesPerPixel(const int _v)
{
m_SamplesPerPixel.DataOffset = _v;
}
void CTiffWriter::setXResolution(const int _numerator, const int _denominator)
{
m_xres[0] = _numerator;
m_xres[1] = _denominator;
}
void CTiffWriter::setYResolution(const int _numerator, const int _denominator)
{
m_yres[0] = _numerator;
m_yres[1] = _denominator;
}
void CTiffWriter::setBytesPerRow(const int _v)
{
m_StripByteCounts.DataOffset = _v * m_ImageLength.DataOffset;
}
void CTiffWriter::GetImageHeader(stringstream &Header)
{
// write the header
TIFFIFH hdr = {0x4949, 0x002a, sizeof(TIFFIFH)};
Header.write(reinterpret_cast<char*>(&hdr), sizeof(TIFFIFH));
// write the Tags immediately after the header
WORD numTags = 12;
Header.write(reinterpret_cast<char*>(&numTags), sizeof(numTags));
const int nsize = sizeof(TIFFTag);
Header.write(reinterpret_cast<char*>(&m_ImageWidth), nsize);
Header.write(reinterpret_cast<char*>(&m_ImageLength), nsize);
Header.write(reinterpret_cast<char*>(&m_BitsPerSample), nsize);
Header.write(reinterpret_cast<char*>(&m_Compression), nsize);
Header.write(reinterpret_cast<char*>(&m_PhotometricInterp), nsize);
Header.write(reinterpret_cast<char*>(&m_StripOffsets), nsize);
Header.write(reinterpret_cast<char*>(&m_SamplesPerPixel), nsize);
Header.write(reinterpret_cast<char*>(&m_RowsPerStrip), nsize);
Header.write(reinterpret_cast<char*>(&m_StripByteCounts), nsize);
Header.write(reinterpret_cast<char*>(&m_XResolution), nsize);
Header.write(reinterpret_cast<char*>(&m_YResolution), nsize);
Header.write(reinterpret_cast<char*>(&m_ResolutionUnit), nsize);
// end the header by setting the next image offset to null
DWORD end = 0;
Header.write(reinterpret_cast<char*>(&end), sizeof(end));
// write the X and Y resolutions
Header.write(reinterpret_cast<char*>(&m_xres), sizeof(DWORD)*2);
Header.write(reinterpret_cast<char*>(&m_yres), sizeof(DWORD)*2);
}
bool CTiffWriter::writeImageHeader()
{
// create the out stream if not done so already
if(0 == m_pImageStream)
{
m_pImageStream = new ofstream();
}
// open the stream. If already open, reset it
if(m_pImageStream->is_open())
{
m_pImageStream->seekp(0);
}
else
{
m_pImageStream->open(m_filename.c_str(), ios_base::out|ios_base::binary|ios_base::trunc);
}
stringstream Header;
GetImageHeader(Header);
Header.seekp(0, ios_base::end);
m_nOffset =(int) Header.tellp();
Header.seekg(0, ios_base::beg);
char *pData = new char[m_nOffset];
Header.read(pData,m_nOffset);
m_pImageStream->write(pData,m_nOffset);
delete []pData;
return true;
}
bool CTiffWriter::WriteTIFFData(char *_pData, DWORD _nCount)
{
bool bret = false;
if(0 != m_pImageStream &&
m_pImageStream->good())
{
m_pImageStream->seekp(m_nOffset);
m_pImageStream->write(_pData, _nCount);
m_nOffset += _nCount;
bret = true;
}
return bret;
}
unsigned int CTiffWriter::getSizeofHeader()
{
// Header is as follows:
// TIFFIFH + Num. of Tags + each tag + Xres Data (2 dwords) + Yres Data (2 dwords) + Next Image offset (1 dword)
return sizeof(TIFFIFH)+sizeof(WORD)+sizeof(TIFFTag)*12+sizeof(DWORD)*5;
}

View File

@ -1,240 +0,0 @@
/***************************************************************************
* Copyright ?2007 TWAIN Working Group:
* Adobe Systems Incorporated, AnyDoc Software Inc., Eastman Kodak Company,
* Fujitsu Computer Products of America, JFL Peripheral Solutions Inc.,
* Ricoh Corporation, and Xerox Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the TWAIN Working Group nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TWAIN Working Group ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL TWAIN Working Group BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
***************************************************************************/
/**
* @file CTiffWriter.h
* Write an image to disk as a tiff file.
* @author TWAIN Working Group
* @date October 2007
*/
#ifndef __TIFFWRITER_H__
#define __TIFFWRITER_H__
#include <string>
#include <fstream>
using namespace std;
#ifdef _MSC_VER
#include <windows.h>
#else
typedef uint16_t WORD;
typedef uint32_t DWORD;
#endif // _MSC_VER
#define TIFF_UNCOMPRESSED 1 /**< TIFF compression types */
#define TIFF_CCITTGROUP3 3
#define TIFF_CCITTGROUP4 4
// TIFF types
#define kTIFF_TY_BYTE 1 /**< 8-bit unsigned int */
#define kTIFF_TY_ASCII 2 /**< 8-bit byte that contains a 7-bit ASCII code; last byte must be binary 0 (NULL) */
#define kTIFF_TY_SHORT 3 /**< 16-bit (2-byte) unsigned int */
#define kTIFF_TY_LONG 4 /**< 32-bit (4-byte) unsigned int */
#define kTIFF_TY_RATIONAL 5 /**< two LONGs; the first is the numerator of a fraction; the second, the denominator */
// these field types where introduced in TIFF 6.0
#define kTIFF_TY_SBYTE 6 /**< 8-bit signed int */
#define kTIFF_TY_UNDEFINED 7 /**< 8-bit byte that may contain anything, depending on the definition of the field */
#define kTIFF_TY_SSHORT 8 /**< 16-bit (2-byte) signed int */
#define kTIFF_TY_SLONG 9 /**< 32-bit (4-byte) signed int */
#define kTIFF_TY_SRATIONAL 10 /**< two SLONG's; first is numerator of fraction, second is denominator */
#define kTIFF_TY_FLOAT 11 /**< single precision (4-byte) IEEE format */
#define kTIFF_TY_DOUBLE 12 /**< double precision (8-byte) IEEE format */
// TIFF Tags
#define kTIFF_TAG_IMGWIDTH 0x0100 /**< Image width, short or long */
#define kTIFF_TAG_IMGLENGTH 0x0101 /**< Image length, short or long */
#define kTIFF_TAG_BITSPERSAMPLE 0x0102 /**< BitsPerSample, short */
#define kTIFF_TAG_COMPRESSION 0x0103 /**< Compression, short */
#define kTIFF_TAG_PHOTOMETRICINT 0x0106 /**< PhotometricInterpretation, short */
#define kTIFF_TAG_STRIPOFFSETS 0x0111 /**< StripOffsets, short or long */
#define kTIFF_TAG_SAMPLESPERPIXEL 0x0115 /**< Samples per pixel, short */
#define kTIFF_TAG_ROWSPERSTRIP 0x0116 /**< RowsPerStrip, short or long */
#define kTIFF_TAG_STRIPBYTECOUNTS 0x0117 /**< StripByteCounts, short or long */
#define kTIFF_TAG_XRESOLUTION 0x011A /**< X Resolution, rational */
#define kTIFF_TAG_YRESOLUTION 0x011B /**< Y Resolution, rational */
#define kTIFF_TAG_RESOLUTIONUNIT 0x0128 /**< Resolution unit, short */
#define kTIFF_TAG_COLORMAP 0x0140 /**< ColorMap, short, RGB order, black = 0,0,0, TWAIN supports max 256 entry pallette */
/**
* TIFF Image File Header
*/
struct TIFFIFH
{
WORD Identifier;
WORD Version;
DWORD IFDOffset;
};
/**
* A TIFF Tag
* If the actual value of the tag is less then a DWORD, then offset will contain
* it, else offset is truly an offset to the value.
*/
struct TIFFTag
{
WORD TagID;
WORD DataType;
DWORD DataCount;
DWORD DataOffset;
};
/**
* This is a class that will progressively write a TIFF image to a file.
*/
class CTiffWriter
{
public:
/**
* Constructor for CTiffWriter. This is a class that will progressively
* write a TIFF image to a file.
* @param[in] _filename name of file to write to.
* @param[in] _width image width.
* @param[in] _height image height.
* @param[in] _bitsPerPixel number of bits per each pixel.
* @param[in] _bytesPerRow number of bytes per row of data.
*/
CTiffWriter(const string& _filename,
const long int _width,
const long int _height,
const int _bitsPerPixel,
const unsigned long int _bytesPerRow);
/**
* Deconstructor for CTiffWriter.
*/
virtual ~CTiffWriter();
/**
* Set the width of the image.
* @param[in] _v the new image width
*/
void setImageWidth(const long int _v);
/**
* Set the height of the image.
* @param[in] _v the new image height
*/
void setImageHeight(const long int _v);
/**
* Set the bits per sample of the image.
* @param[in] _v the new bits per sample
*/
void setBitsPerSample(const int _v);
/**
* Set the compression method to use.
* @param[in] _v the new compression method
*/
void setCompression(const int _v);
/**
* Set the Photometric Interpretation.
* @param[in] _v the new Photometric Interpretation
*/
void setPhotometricInterp(const int _v);
/**
* Set the number of samples per pixel of the image.
* @param[in] _v the new samples per pixel
*/
void setSamplesPerPixel(const int _v);
/**
* Set the x resolution of the image. Using type kTIFF_TY_RATIONAL (fraction)
* @param[in] _numerator the numerator part of the fraction
* @param[in] _denominator the denominator part of the fraction
*/
void setXResolution(const int _numerator, const int _denominator);
/**
* Set the y resolution of the image. Using type kTIFF_TY_RATIONAL (fraction)
* @param[in] _numerator the numerator part of the fraction
* @param[in] _denominator the denominator part of the fraction
*/
void setYResolution(const int _numerator, const int _denominator);
/**
* Set the Bytes per row of the image.
* @param[in] _v the new bytes per row
*/
void setBytesPerRow(const int _v);
/**
* Write the prepaired image header to the file.
* @return true for succes
*/
bool writeImageHeader();
/**
* Write the data for the image to the file.
* @param[in] _pData pointer to the image data
* @param[in] _nCount number of bytes to write
* @return true for success
*/
bool WriteTIFFData(char *_pData, DWORD _nCount);
/**
* Return the size of the TIFF header for the image file.
* @return the size of the header
*/
unsigned int getSizeofHeader();
void GetImageHeader(stringstream &Header);
protected:
string m_filename; /**< Name and or path of file */
int m_nOffset; /**< Current offset into file */
DWORD m_xres[2]; /**< The X resolution of the image */
DWORD m_yres[2]; /**< The Y resolution of the image */
TIFFTag m_ImageWidth; /**< The image width in pixels */
TIFFTag m_ImageLength; /**< The image height in pixels */
TIFFTag m_BitsPerSample; /**< The number of Bits per sample */
TIFFTag m_Compression; /**< The compression method to use */
TIFFTag m_PhotometricInterp; /**< The Photometric Interpretation to use */
TIFFTag m_StripOffsets; /**< The strip offset, where image data starts */
TIFFTag m_SamplesPerPixel; /**< The number of channels (RGB, G, )*/
TIFFTag m_RowsPerStrip; /**< The number of rows that make up each strip */
TIFFTag m_StripByteCounts; /**< The size of each strip of image data */
TIFFTag m_XResolution; /**< The offset to the X resolution */
TIFFTag m_YResolution; /**< The offset to the Y resolution */
TIFFTag m_ResolutionUnit; /**< The units of the Resolution */
ofstream* m_pImageStream; /**< The output stream to write the file to */
};
#endif // __TIFFWRITER_H__

View File

@ -86,6 +86,7 @@ BEGIN_MESSAGE_MAP(CTwainUI, CDialogEx)
ON_BN_CLICKED(IDC_BTNDELETCONFIG, &CTwainUI::OnBnClickedBtndeletconfig)
ON_BN_CLICKED(IDC_BTNRECOVERYCONFIG, &CTwainUI::OnBnClickedBtnrecoveryconfig)
ON_LBN_SELCHANGE(IDC_LSTCONFIG, &CTwainUI::OnLbnSelchangeLstconfig)
ON_WM_CLOSE()
END_MESSAGE_MAP()
@ -117,14 +118,8 @@ void CTwainUI::OnBnClickedConfirm()
vc.push_back(configItem);
std::string savepath = TCHAR2STRING1(szIniFile);
js.WriteJsonArrayToFile(vc, savepath);
if (str_caption.Compare(_T("扫描")) == 0)//内容为扫描时
{
m_glue.m_scan(*settings);
}
else
{
m_glue.m_cancel();
}
m_glue.m_scan(*settings);
}
@ -207,20 +202,13 @@ void CTwainUI::UpdateUI(CONFIGPARAMS configParams)
m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->EnableWindow(TRUE);
m_pageFeedPaper->m_radioGroupScanMode = 1;
int tempcount = configParams.ScanCount;
//if (configParams.Duplex == 0)
//{
// tempcount = configParams.ScanCount;
//}
//else
//{
// tempcount = configParams.ScanCount / 2;
//}
CString csCount;
csCount.Format(_T("%d"), tempcount);
m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->SetWindowText(csCount);
}
m_pageFeedPaper->UpdateData(FALSE);
m_pageBasic->updateCmbDuplex(TRUE);
}
int CTwainUI::getResolutionIndex(int resolution)
@ -469,8 +457,9 @@ void CTwainUI::UpdateUi()
if (enableback)
{
((CButton*)(m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)))->SetCheck(!enableback);
if (dupindex == 4)
((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->SetCheck(dupindex == 4?TRUE:FALSE);
if (dupindex == 4) {
((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->SetCheck(dupindex == 4 ? TRUE : FALSE);
}
}
((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->EnableWindow(!(dupindex == 4));
m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(!enableback);
@ -600,3 +589,10 @@ void CTwainUI::OnLbnSelchangeLstconfig()
}
}
}
void CTwainUI::OnClose()
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
m_glue.m_cancel();
}

View File

@ -165,4 +165,6 @@ protected:
std::vector<CONFIGINFO> getConfigFiles();
std::unique_ptr<GScanCap> settings;
std::string m_confirmtitle;
public:
afx_msg void OnClose();
};

View File

@ -199,6 +199,31 @@ typedef struct Paper_Status {
}
}PaperStatus;
enum G400_PaperSize {
G400_A3 = 0,
G400_A4,
G400_A4R,
G400_A5,
G400_A5R,
G400_A6,
G400_A6R,
G400_B4,
G400_B5,
G400_B5R,
G400_B6,
G400_B6R,
G400_DOUBLELETTER,
G400_LEGAL,
G400_LETTER,
G400_LETTERR,
G400_LONGLETTER
};
enum G400_DPI {
G400_D300 = 0,
G400_D200,
G400_D600
};
#define CAPTION_LEN 256
#define TWAIN_IMAGE_FILE_LIST_NAME TEXT(".dat")

View File

@ -172,7 +172,7 @@ int UsbScanEx::read_bulk(void* data, int len)
}
break;
default:
int a = 0;
//writelog("Usb read_bulk error code ID: " + std::to_string(error_code));
break;
}
}
@ -212,7 +212,7 @@ int UsbScanEx::write_bulk(void* data, int len)
}
break;
default:
int a = 0;
//writelog("Usb write_bulk error code ID: " + std::to_string(errorcode));
break;
}
}

View File

@ -7,7 +7,7 @@
#include <memory>
#include <list>
#include "IUsb.h"
#include "PublicFunc.h"
#pragma pack(1)
struct tag_usb_pipe

View File

@ -4,6 +4,7 @@
hgConfigClass::hgConfigClass(GScanCap param)
{
m_param = { 0 };
PaperStatus ps = { param.papertype,param.paperAlign };
m_param.paper = ContainspaperTypesKey(ps) ? SupPaperTyps[ps] : 0;
m_param.color = ContainsPixTypeKey(param.hardwarecaps.capturepixtype) ? SupPixelTypes[param.hardwarecaps.capturepixtype] : 2;
@ -47,3 +48,8 @@ bool hgConfigClass::ContainsResolutionKey(float key)
}
return false;
}
unsigned int hgConfigClass::GetData()
{
return m_param.value;
}

View File

@ -13,7 +13,10 @@ class hgConfigClass:public IConfig
{
public:
hgConfigClass(GScanCap param);
// 通过 IConfig 继承
virtual unsigned int GetData() override;
private:
ConfigParam m_param;
enum Config_Scanner
{
cfStaple,

View File

@ -50,11 +50,13 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side)
cv::Mat scale_mat;
cv::Mat thre(src_resize.size(), CV_8UC1);
hg::threshold_Mat(src_resize, thre, m_threshold);
src_resize.release();
if (m_noise > RE)
{
cv::Mat element = getStructuringElement(cv::MORPH_RECT, cv::Size(m_noise / RE, m_noise / RE));
cv::morphologyEx(thre, thre, cv::MORPH_OPEN, element);
element.release();
}
std::vector<cv::Vec4i> hierarchy;
std::vector<std::vector<cv::Point>> contours;
@ -106,8 +108,9 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side)
hierarchy.clear();
contours.clear();
maxContour.clear();
hg::findContours(thre_dst, contours, hierarchy, cv::RETR_EXTERNAL);
thre_dst.release();
maxContour = hg::getMaxContour(contours, hierarchy);
if (m_isConvexHull)
hg::convexHull(maxContour, maxContour);

File diff suppressed because it is too large Load Diff

View File

@ -8,12 +8,12 @@
namespace std {
template<>
struct hash<Twpp::CapType> {
size_t operator()(Twpp::CapType cap) const{
return hash<Twpp::UInt16>()(static_cast<Twpp::UInt16>(cap));
}
};
template<>
struct hash<Twpp::CapType> {
size_t operator()(Twpp::CapType cap) const {
return hash<Twpp::UInt16>()(static_cast<Twpp::UInt16>(cap));
}
};
}
@ -23,7 +23,7 @@ class HuagaoDs : public Twpp::SourceFromThis<HuagaoDs> {
public:
HuagaoDs();
virtual ~HuagaoDs();
virtual ~HuagaoDs();
static const Twpp::Identity& defaultIdentity() noexcept;
// SourceFromThis interface
@ -54,9 +54,16 @@ protected:
virtual Twpp::Result imageLayoutReset(const Twpp::Identity& origin, Twpp::ImageLayout& data) override;
virtual Twpp::Result imageMemXferGet(const Twpp::Identity& origin, Twpp::ImageMemXfer& data) override;
virtual Twpp::Result imageNativeXferGet(const Twpp::Identity& origin, Twpp::ImageNativeXfer& data) override;
virtual Twpp::Result pendingXfersStopFeeder(const Twpp::Identity& origin, Twpp::PendingXfers& data) override;
virtual Twpp::Result call(const Twpp::Identity& origin, Twpp::DataGroup dg, Twpp::Dat dat, Twpp::Msg msg, void* data) override;
virtual Twpp::Result pendingXfersStopFeeder(const Twpp::Identity& origin, Twpp::PendingXfers& data) override;
virtual Twpp::Result imageFileXferGet(const Twpp::Identity& origin) override;
//virtual Twpp::Result pendingXfersStopFeeder(const Twpp::Identity& origin, Twpp::PendingXfers& data) override;
virtual Twpp::Result setupFileXferGet(const Twpp::Identity& origin, Twpp::SetupFileXfer& data) override;
virtual Twpp::Result setupFileXferGetDefault(const Twpp::Identity& origin, Twpp::SetupFileXfer& data) override;
virtual Twpp::Result setupFileXferSet(const Twpp::Identity& origin, Twpp::SetupFileXfer& data) override;
virtual Twpp::Result setupFileXferReset(const Twpp::Identity& origin, Twpp::SetupFileXfer& data) override;
virtual Twpp::Result call(const Twpp::Identity& origin, Twpp::DataGroup dg, Twpp::Dat dat, Twpp::Msg msg, void* data) override;
static void SetResoluton(const char* path, int resolution);
private:
Twpp::Result showTwainUI(Twpp::UserInterface& data, bool bUiOnly = false);
Twpp::Result startScan();
@ -72,6 +79,7 @@ private:
std::unordered_map<Twpp::CapType, std::function<Twpp::Result(Twpp::Msg msg, Twpp::Capability& data)>> m_caps;
std::unordered_map<Twpp::CapType, Twpp::MsgSupport> m_query;
Twpp::SetupFileXfer m_fileXfer;
Twpp::UInt32 m_memXferYOff = 0;
Twpp::UInt16 m_pendingXfers = 0;
@ -79,6 +87,8 @@ private:
Twpp::Fix32 m_brightness = 0.0f;
Twpp::XferMech m_capXferMech = Twpp::XferMech::Native;
Twpp::PixelType m_capPixelType = Twpp::PixelType::Rgb;
unsigned short m_jpegQuality = 80;
bool m_bIndicator = true;
bool m_bFeederEnabled = true;
bool m_bAutoFeed = true;
@ -86,7 +96,7 @@ private:
std::vector<unsigned char> bmpData;
std::unique_ptr<GScanCap> m_scanparam;
HANDLE hMutex;
};

View File

@ -64,6 +64,8 @@ SOURCES += huagaods.cpp \
Device/cJSON.cpp \
Device/CJsonObject.cpp \
Device/JsonConfig.cpp \
Device/GetMemoryUsage.cpp \
Device/G400ScanConfig.cpp \
ImageProcess/ImageApply.cpp \
ImageProcess/ImageApplyAdjustColors.cpp \
ImageProcess/ImageApplyAutoCrop.cpp \
@ -77,6 +79,7 @@ SOURCES += huagaods.cpp \
ImageProcess/ImageApplySharpen.cpp \
ImageProcess/ImageProcess_Public.cpp \
ImageProcess/ImageApplyConcatenation.cpp \
G400ScanConfig.cpp \
Sliders.cpp \
SmartEdit.cpp \
TabCtrlSSL.cpp \
@ -109,12 +112,14 @@ HEADERS += huagaods.hpp \
Device/UsbScanEx.h \
Device/config_new.h \
Device/device_common.h \
Device/GetMemoryUsage.h \
Device/GScan.h \
Device/scn_config.h \
Device/filetools.h \
Device/cJSON.h \
Device/JsonConfig.h \
Device/CJsonObject.hpp \
Device/G400ScanConfig.h \
ImageProcess/ImageApply.h \
ImageProcess/ImageApplyAdjustColors.h \
ImageProcess/ImageApplyAutoCrop.h \

Binary file not shown.