資源簡介
為了兼容常用品牌的掃描儀設備,使用了國際標準協議Twain Qt5 C++

代碼片段和文件信息
#include?“scaninterface.h“
#include?“./ui/constants/constants.h“
#define?ICAP_EXT_PAPERWIDTH?(CAP_CUSTOMbase?+?2)
#define?ICAP_EXT_PAPERHEIGHT?(CAP_CUSTOMbase?+?3)
//?靜態成員變量需要在類體的外面進行初始化
ScanInterface*?ScanInterface::m_pScanInterface?;//=?new?ScanInterface();
ScanInterface*?ScanInterface::GetInstance()
{
????if(m_pScanInterface?==?NULL)
????{
????????m_pScanInterface?=?new?ScanInterface();
????}
????return?m_pScanInterface;
}
void?ScanInterface::ReleaseTwain()
{
????qDebug()<<“ReleaseTwain:m_state=“<
????if?(m_state?>?3)
????{
????????CloseDS();
????}
????if?(m_state?>?2)
????{
????????CloseDSM();
????}
????//?Unload?the?Source?Manager
????if(m_hTwainDLL){
????????qDebug()<<“free?libray?“;
????????FreeLibrary(m_hTwainDLL);
????????m_hTwainDLL?=?NULL;
????????m_state?=?1;
????}
????if?(m_pScanInterface?!=?NULL)
????{
????????delete?m_pScanInterface;
????????m_pScanInterface?=?NULL;
????}
}
ScanInterface::ScanInterface(Qobject?*parent)?:?Qobject(parent)
{
????m_pngIndex?=?0;
????m_state?=?0;
????DSM_Entry?=?NULL;
????m_hTwainDLL?=?NULL;
????m_bDSMOpen?=?false;
????m_bDSOpen?=?false;
????m_bSourceEnabled?=?false;
????m_bSourceSelected?=?false;
}
ScanInterface::~ScanInterface()
{
}
void?ScanInterface::SetTwain(HWND?winId)
{
????m_winId?=?winId;
????m_twUI.hParent?=?m_winId;
????m_twUI.ShowUI?=?false;
}
int?ScanInterface::InitTwain()
{
????GetIdentity();
????InitTwainDll();
????OpenDSM();
????return?0;
}
TW_UINT16?ScanInterface::SetCapOneValue(DSMENTRYPROC?DSM_Entry?pTW_IDENTITY?pappid?pTW_IDENTITY?pdsid?TW_UINT16?capid?TW_UINT16?type?TW_UINT32?val)
{
????TW_UINT16?twRC?=?TWRC_FAILURE;
????TW_CAPABILITY?cap?=?{0};
????pTW_ONEVALUE?pOneValue?=?NULL;
????memset(&cap?0?sizeof(TW_CAPABILITY));
????cap.Cap?=?capid;
????cap.ConType?=?TWON_ONEVALUE;
????cap.hContainer?=?GlobalAlloc(GHND?sizeof(TW_ONEVALUE));
????if?(cap.hContainer)
????{
????????pOneValue?=?(pTW_ONEVALUE)GlobalLock(cap.hContainer);
????????pOneValue->ItemType?=?type;
????????pOneValue->Item?=?val;
????????GlobalUnlock(cap.hContainer);
????????twRC?=?DSM_Entry(pappid?pdsid?DG_CONTROL?DAT_CAPABILITY?MSG_SET?&cap);
????????GlobalFree(cap.hContainer);
????}
????return?twRC;
}
void?ScanInterface::GetIdentity()
{
????//?Expects?all?the?fields?in?m_AppId?to?be?set?except?for?the?id?field.
????m_AppId.Id?=?0;?//?Initialize?to?0?(Source?Manager
????//?will?assign?real?value)
????m_AppId.Version.MajorNum?=?3;?//Your?app‘s?version?number
????m_AppId.Version.MinorNum?=?5;
????m_AppId.Version.Language?=?TWLG_USA;
????m_AppId.Version.Country?=?TWCY_USA;
????strcpy_s?(m_AppId.Version.Info?“3.5“);
????m_AppId.ProtocolMajor?=?TWON_PROTOCOLMAJOR;
????m_AppId.ProtocolMinor?=?TWON_PROTOCOLMINOR;
????m_AppId.SupportedGroups?=?DG_IMAGE?|?DG_CONTROL;
????strcpy_s?(m_AppId.Manufacturer?“MICSS“);
????strcpy_s?(m_AppId.Product
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????21301??2019-04-25?17:22??Qt5Twain\scaninterface.cpp
?????文件???????3643??2019-04-04?15:31??Qt5Twain\scaninterface.h
?????文件????????944??2019-03-05?19:48??Qt5Twain\stdafx.h
?????文件??????79803??2019-03-05?19:48??Qt5Twain\twain.h
?????目錄??????????0??2019-05-09?15:28??Qt5Twain
-----------?---------??----------?-----??----
???????????????105691????????????????????5
評論
共有 條評論