添加单张扫描

This commit is contained in:
yangjiaxuan 2023-05-17 16:45:41 +08:00
parent 23979437ef
commit d879bb1fe7
3 changed files with 103 additions and 44 deletions

View File

@ -394,7 +394,6 @@ MainWindow::~MainWindow()
if (nullptr != m_devUser)
{
disconnect(m_devUser, SIGNAL(newImage(void*)), this, SLOT(on_newImage(void*)));
disconnect(m_devUser, SIGNAL(finishScan()), this, SLOT(on_finishScan()));
delete m_devUser;
m_devUser = nullptr;
}
@ -663,9 +662,9 @@ void MainWindow::on_AcquireInto2()
}
else
{
m_isScanning = true;
// m_isScanning = true;
m_thumb->setAcceptDrops(false);
updateActionStatus();
// updateActionStatus();
}
}
}
@ -2874,9 +2873,9 @@ void MainWindow::on_act_acquireSingle_triggered()
}
else
{
m_isScanning = true;
// m_isScanning = true;
m_thumb->setAcceptDrops(false);
updateActionStatus();
// updateActionStatus();
}
}
@ -2939,9 +2938,9 @@ void MainWindow::on_act_acquireInto_triggered()
}
else
{
m_isScanning = true;
// m_isScanning = true;
m_thumb->setAcceptDrops(false);
updateActionStatus();
// updateActionStatus();
}
}
}
@ -3000,9 +2999,9 @@ void MainWindow::on_act_insertFromScanner_triggered()
}
else
{
m_isScanning = true;
// m_isScanning = true;
m_thumb->setAcceptDrops(false);
updateActionStatus();
// updateActionStatus();
}
}
}
@ -3769,6 +3768,5 @@ void MainWindow::on_act_selectDevice_triggered()
m_devUser = devUser;
m_wndStatusBar->setDeviceStatusInfo(tr("Device %1 is open").arg(m_devUser->GetName()), false);
connect(m_devUser, SIGNAL(newImage(void*)), this, SLOT(on_newImage(void*)));
connect(m_devUser, SIGNAL(finishScan()), this, SLOT(on_finishScan()));
}
}

View File

@ -416,8 +416,8 @@ HGResult HGTwainDSImpl::GetDeviceCustomInfo(HGTwainDeviceCustomInfo *info)
memset(info, 0, sizeof(HGTwainDeviceCustomInfo));
GetCapInt32(0x8852, &info->vid);
GetCapInt32(0x8853, &info->pid);
GetCapInt(0x8852, &info->vid);
GetCapInt(0x8853, &info->pid);
GetCapStr255(0x8856, info->sn, 32);
GetCapStr255(0x8855, info->type, 32);
GetCapStr255(0x8857, info->fwVer, 32);
@ -430,8 +430,8 @@ HGResult HGTwainDSImpl::GetDeviceCustomInfo(HGTwainDeviceCustomInfo *info)
GetCapStr255(0x884E, info->comTel, 32);
GetCapStr255(0x884F, info->comAddr, 256);
GetCapStr255(0x8850, info->comGps, 256);
GetCapInt32(0x9902, &info->rollerCount);
GetCapInt32(0x8849, &info->totalCount);
GetCapInt(0x9902, &info->rollerCount);
GetCapInt(0x8849, &info->totalCount);
return HGBASE_ERR_OK;
}
@ -502,7 +502,7 @@ HGResult HGTwainDSImpl::Logout()
HGResult HGTwainDSImpl::ClearRollerCount()
{
return ResetCapInt32(0x9902);
return ResetCapInt(0x9902, TWTY_INT32);
}
HGResult HGTwainDSImpl::GetDriverLogPath(HGChar *path, HGUInt maxLen)
@ -570,13 +570,13 @@ HGResult HGTwainDSImpl::EnableWithSingleScan(HGDSCloseReqFunc eventFunc, HGPoint
HGDSImageFunc imageFunc, HGPointer imageParam)
{
HGInt oldXferCount = -1;
HGResult ret = GetCapInt32(CAP_XFERCOUNT, &oldXferCount);
HGResult ret = GetCapInt(CAP_XFERCOUNT, &oldXferCount);
if (HGBASE_ERR_OK != ret)
{
return ret;
}
ret = SetCapInt32(CAP_XFERCOUNT, 1);
ret = SetCapInt(CAP_XFERCOUNT, TWTY_INT16, 1);
if (HGBASE_ERR_OK != ret)
{
return ret;
@ -610,22 +610,32 @@ HGResult HGTwainDSImpl::Disable()
if (m_singleScan)
{
SetCapInt32(CAP_XFERCOUNT, m_oldXferCount);
SetCapInt(CAP_XFERCOUNT, TWTY_INT16, m_oldXferCount);
}
m_singleScan = FALSE;
m_oldXferCount = -1;
m_showUI = HGFALSE;
m_parent = NULL;
m_eventFunc = NULL;
m_eventParam = NULL;
m_imageFunc = NULL;
m_imageParam = NULL;
return HGBASE_ERR_OK;
m_showUI = HGFALSE;
m_parent = NULL;
m_eventFunc = NULL;
m_eventParam = NULL;
m_imageFunc = NULL;
m_imageParam = NULL;
return HGBASE_ERR_OK;
}
#pragma pack(push)
#pragma pack(1)
struct CapInt8Type
{
TW_UINT16 ItemType;
TW_INT8 Value;
};
struct CapInt16Type
{
TW_UINT16 ItemType;
TW_INT16 Value;
};
struct CapInt32Type
{
TW_UINT16 ItemType;
@ -633,21 +643,39 @@ struct CapInt32Type
};
#pragma pack(pop)
HGResult HGTwainDSImpl::SetCapInt32(HGUInt cap, HGInt value)
HGResult HGTwainDSImpl::SetCapInt(HGUInt cap, TW_UINT16 itemType, HGInt value)
{
TW_CAPABILITY twCap;
twCap.Cap = (TW_UINT16)cap;
twCap.ConType = TWON_ONEVALUE;
twCap.hContainer = GlobalAlloc(GHND, sizeof(CapInt32Type));
DWORD size = sizeof(CapInt32Type);
if (itemType == TWTY_INT8)
size = sizeof(CapInt8Type);
else if (itemType == TWTY_INT16)
size = sizeof(CapInt16Type);
twCap.hContainer = GlobalAlloc(GHND, size);
if (NULL == twCap.hContainer)
{
return HGBASE_ERR_FAIL;
}
CapInt32Type* pVal = (CapInt32Type*)GlobalLock(twCap.hContainer);
void* pVal = GlobalLock(twCap.hContainer);
assert(NULL != pVal);
pVal->ItemType = TWTY_INT32;
pVal->Value = value;
if (itemType == TWTY_INT8)
{
((CapInt8Type*)pVal)->ItemType = TWTY_INT8;
((CapInt8Type*)pVal)->Value = (TW_INT8)value;
}
else if (itemType == TWTY_INT16)
{
((CapInt16Type*)pVal)->ItemType = TWTY_INT16;
((CapInt16Type*)pVal)->Value = (TW_INT16)value;
}
else
{
((CapInt32Type*)pVal)->ItemType = TWTY_INT32;
((CapInt32Type*)pVal)->Value = (TW_INT32)value;
}
GlobalUnlock(twCap.hContainer);
USHORT ret = m_dsmImpl->m_pDSMProc(&m_dsmImpl->m_AppId, &m_iden, DG_CONTROL, DAT_CAPABILITY, MSG_SET, &twCap);
@ -655,21 +683,39 @@ HGResult HGTwainDSImpl::SetCapInt32(HGUInt cap, HGInt value)
return (TWRC_SUCCESS == ret) ? HGBASE_ERR_OK : HGTWAIN_ERR_FAIL;
}
HGResult HGTwainDSImpl::ResetCapInt32(HGUInt cap)
HGResult HGTwainDSImpl::ResetCapInt(HGUInt cap, TW_UINT16 itemType)
{
TW_CAPABILITY twCap;
twCap.Cap = (TW_UINT16)cap;
twCap.ConType = TWON_ONEVALUE;
twCap.hContainer = GlobalAlloc(GHND, sizeof(CapInt32Type));
DWORD size = sizeof(CapInt32Type);
if (itemType == TWTY_INT8)
size = sizeof(CapInt8Type);
else if (itemType == TWTY_INT16)
size = sizeof(CapInt16Type);
twCap.hContainer = GlobalAlloc(GHND, size);
if (NULL == twCap.hContainer)
{
return HGBASE_ERR_FAIL;
}
CapInt32Type* pVal = (CapInt32Type*)GlobalLock(twCap.hContainer);
void* pVal = GlobalLock(twCap.hContainer);
assert(NULL != pVal);
pVal->ItemType = TWTY_INT32;
pVal->Value = 0;
if (itemType == TWTY_INT8)
{
((CapInt8Type*)pVal)->ItemType = TWTY_INT8;
((CapInt8Type*)pVal)->Value = 0;
}
else if (itemType == TWTY_INT16)
{
((CapInt16Type*)pVal)->ItemType = TWTY_INT16;
((CapInt16Type*)pVal)->Value = 0;
}
else
{
((CapInt32Type*)pVal)->ItemType = TWTY_INT32;
((CapInt32Type*)pVal)->Value = 0;
}
GlobalUnlock(twCap.hContainer);
USHORT ret = m_dsmImpl->m_pDSMProc(&m_dsmImpl->m_AppId, &m_iden, DG_CONTROL, DAT_CAPABILITY, MSG_RESET, &twCap);
@ -677,7 +723,7 @@ HGResult HGTwainDSImpl::ResetCapInt32(HGUInt cap)
return (TWRC_SUCCESS == ret) ? HGBASE_ERR_OK : HGTWAIN_ERR_FAIL;
}
HGResult HGTwainDSImpl::GetCapInt32(HGUInt cap, HGInt* value)
HGResult HGTwainDSImpl::GetCapInt(HGUInt cap, HGInt* value)
{
if (NULL == value)
{
@ -695,13 +741,28 @@ HGResult HGTwainDSImpl::GetCapInt32(HGUInt cap, HGInt* value)
HGResult ret = HGBASE_ERR_FAIL;
assert(NULL != twCap.hContainer);
CapInt32Type* pVal = (CapInt32Type*)GlobalLock(twCap.hContainer);
if (NULL != pVal && pVal->ItemType == TWTY_INT32)
void* pVal = GlobalLock(twCap.hContainer);
if (NULL != pVal)
{
*value = pVal->Value;
ret = HGBASE_ERR_OK;
TW_UINT16 ItemType = *(TW_UINT16*)pVal;
if (ItemType == TWTY_INT8)
{
*value = ((CapInt8Type*)pVal)->Value;
ret = HGBASE_ERR_OK;
}
else if (ItemType == TWTY_INT16)
{
*value = ((CapInt16Type*)pVal)->Value;
ret = HGBASE_ERR_OK;
}
else if (ItemType == TWTY_INT32)
{
*value = ((CapInt32Type*)pVal)->Value;
ret = HGBASE_ERR_OK;
}
GlobalUnlock(twCap.hContainer);
}
GlobalUnlock(twCap.hContainer);
GlobalFree(twCap.hContainer);
return ret;

View File

@ -70,9 +70,9 @@ public:
HGResult Disable();
private:
HGResult SetCapInt32(HGUInt cap, HGInt value);
HGResult ResetCapInt32(HGUInt cap);
HGResult GetCapInt32(HGUInt cap, HGInt* value);
HGResult SetCapInt(HGUInt cap, TW_UINT16 itemType, HGInt value);
HGResult ResetCapInt(HGUInt cap, TW_UINT16 itemType);
HGResult GetCapInt(HGUInt cap, HGInt* value);
HGResult SetCapStr255(HGUInt cap, const HGChar *value);
HGResult ResetCapStr255(HGUInt cap);
HGResult GetCapStr255(HGUInt cap, HGChar *value, HGUInt maxLen);