twain协议,传输文件大小达到200MB时采用文件传输模式

This commit is contained in:
yangjiaxuan 2024-06-17 16:36:46 +08:00
parent 6081a5c6c0
commit 4ca44a6024
1 changed files with 41 additions and 34 deletions

View File

@ -1155,7 +1155,11 @@ HGResult HGTwainDSImpl::ImageNativeXfer(HGUInt type, HGUInt origin, HGImage* ima
return HGTWAIN_ERR_FAIL; return HGTWAIN_ERR_FAIL;
} }
#ifdef _WIN64 HGResult ret = HGBASE_ERR_FAIL;
int fileSize = info.ImageWidth * info.ImageLength * info.BitsPerPixel / 8;
if (fileSize > 200 * 1024 * 1024)
{
HANDLE hMem = NULL; HANDLE hMem = NULL;
if (TWRC_XFERDONE != m_dsmImpl->m_pDSMProc(&m_dsmImpl->m_AppId, &m_iden, DG_IMAGE, DAT_IMAGENATIVEXFER, MSG_GET, &hMem)) if (TWRC_XFERDONE != m_dsmImpl->m_pDSMProc(&m_dsmImpl->m_AppId, &m_iden, DG_IMAGE, DAT_IMAGENATIVEXFER, MSG_GET, &hMem))
{ {
@ -1163,7 +1167,7 @@ HGResult HGTwainDSImpl::ImageNativeXfer(HGUInt type, HGUInt origin, HGImage* ima
} }
HGStream stream = NULL; HGStream stream = NULL;
HGResult ret = HGBase_CreateDIBStream(hMem, &stream); ret = HGBase_CreateDIBStream(hMem, &stream);
GlobalFree(hMem); GlobalFree(hMem);
if (HGBASE_ERR_OK != ret) if (HGBASE_ERR_OK != ret)
{ {
@ -1172,7 +1176,9 @@ HGResult HGTwainDSImpl::ImageNativeXfer(HGUInt type, HGUInt origin, HGImage* ima
ret = HGBase_CreateImageFromStream(stream, NULL, type, origin, image); ret = HGBase_CreateImageFromStream(stream, NULL, type, origin, image);
HGBase_DestroyStream(stream); HGBase_DestroyStream(stream);
#else }
else
{
HGChar tmpFile[260]; HGChar tmpFile[260];
HGBase_GetTmpFileName("bmp", tmpFile, 260); HGBase_GetTmpFileName("bmp", tmpFile, 260);
@ -1189,9 +1195,10 @@ HGResult HGTwainDSImpl::ImageNativeXfer(HGUInt type, HGUInt origin, HGImage* ima
return HGTWAIN_ERR_FAIL; return HGTWAIN_ERR_FAIL;
} }
HGResult ret = HGBase_CreateImageFromFile(tmpFile, NULL, type, origin, image); ret = HGBase_CreateImageFromFile(tmpFile, NULL, type, origin, image);
HGBase_DeleteFile(tmpFile); HGBase_DeleteFile(tmpFile);
#endif }
return ret; return ret;
} }