HGSane
This commit is contained in:
parent
308e529d3d
commit
727876c81d
|
@ -372,10 +372,11 @@ void HGAPI DeviceUser::DeviceEventFunc(HGSaneDevice dev, HGUInt event, HGPointer
|
|||
}
|
||||
}
|
||||
|
||||
void HGAPI DeviceUser::DeviceImageFunc(HGSaneDevice dev, HGImage image, HGUInt type, HGPointer param)
|
||||
HGUInt HGAPI DeviceUser::DeviceImageFunc(HGSaneDevice dev, HGImage image, HGUInt type, HGPointer param)
|
||||
{
|
||||
DeviceUser* p = (DeviceUser*)param;
|
||||
emit p->newImage(image);
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -120,7 +120,7 @@ public:
|
|||
|
||||
private:
|
||||
static void HGAPI DeviceEventFunc(HGSaneDevice dev, HGUInt event, HGPointer param);
|
||||
static void HGAPI DeviceImageFunc(HGSaneDevice dev, HGImage image, HGUInt type, HGPointer param);
|
||||
static HGUInt HGAPI DeviceImageFunc(HGSaneDevice dev, HGImage image, HGUInt type, HGPointer param);
|
||||
|
||||
signals:
|
||||
void newImage(void *image);
|
||||
|
|
|
@ -45,7 +45,7 @@ typedef struct
|
|||
/* Sane回调
|
||||
*/
|
||||
typedef void (HGAPI* HGSane_DeviceEventFunc)(HGSaneDevice dev, HGUInt event, HGPointer param);
|
||||
typedef void (HGAPI* HGSane_DeviceImageFunc)(HGSaneDevice dev, HGImage image, HGUInt type, HGPointer param);
|
||||
typedef HGUInt (HGAPI* HGSane_DeviceImageFunc)(HGSaneDevice dev, HGImage image, HGUInt type, HGPointer param);
|
||||
|
||||
HGEXPORT HGResult HGAPI HGSane_CreateManager(HGSaneManager *manager);
|
||||
|
||||
|
|
|
@ -7,4 +7,7 @@
|
|||
/* 设备离线 */
|
||||
#define HGSANE_ERR_DEVICEOFFLINE 0x00004002L
|
||||
|
||||
/* 停止扫描 */
|
||||
#define HGSANE_ERR_STOPSCAN 0x00004003L
|
||||
|
||||
#endif /* __HGSANEERR_H__ */
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "HGSaneImpl.hpp"
|
||||
#include "../base/HGInc.h"
|
||||
#include "../base/HGUtility.h"
|
||||
#include "huagao/hgscanner_error.h"
|
||||
|
||||
HGSaneManagerImpl::HGSaneManagerImpl()
|
||||
{
|
||||
|
@ -1019,7 +1020,7 @@ void HGAPI HGSaneDeviceImpl::ThreadFunc(HGThread thread, HGPointer param)
|
|||
SANE_Parameters params;
|
||||
memset(¶ms, 0, sizeof(SANE_Parameters));
|
||||
SANE_Status stat1 = saneAPI.sane_get_parameters_api(p->m_devHandle, ¶ms);
|
||||
if (SANE_STATUS_GOOD != stat1)
|
||||
if (SANE_STATUS_GOOD != stat1 && SCANNER_ERR_DEVICE_DOUBLE_FEEDING != stat1)
|
||||
{
|
||||
if (NULL != p->m_scanNotify)
|
||||
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(stat1), (int)stat1);
|
||||
|
@ -1094,6 +1095,7 @@ void HGAPI HGSaneDeviceImpl::ThreadFunc(HGThread thread, HGPointer param)
|
|||
if (NULL != p->m_scanNotify)
|
||||
p->m_scanNotify((int)SANE_EVENT_IMAGE_OK, NULL, 0);
|
||||
|
||||
bool stopScan = false;
|
||||
if (nullptr != p->m_imageFunc)
|
||||
{
|
||||
HGUInt imgType = 0;
|
||||
|
@ -1116,7 +1118,11 @@ void HGAPI HGSaneDeviceImpl::ThreadFunc(HGThread thread, HGPointer param)
|
|||
if (NULL != img)
|
||||
{
|
||||
HGBase_SetImageDpi(img, p->m_dpi, p->m_dpi);
|
||||
p->m_imageFunc((HGSaneDevice)p, img, p->m_imageParam);
|
||||
HGUInt type = (SCANNER_ERR_DEVICE_DOUBLE_FEEDING == stat1)
|
||||
? HGSANE_IMAGE_TYPE_DOUBLE : HGSANE_IMAGE_TYPE_NORMAL;
|
||||
HGUInt imgRet = p->m_imageFunc((HGSaneDevice)p, img, type, p->m_imageParam);
|
||||
if (HGSANE_ERR_STOPSCAN == imgRet)
|
||||
stopScan = true;
|
||||
HGBase_DestroyImage(img);
|
||||
}
|
||||
}
|
||||
|
@ -1125,6 +1131,12 @@ void HGAPI HGSaneDeviceImpl::ThreadFunc(HGThread thread, HGPointer param)
|
|||
buffer = NULL;
|
||||
bufferSize = 0;
|
||||
|
||||
if (stopScan)
|
||||
{
|
||||
saneAPI.sane_cancel_api(p->m_devHandle);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!p->m_cancelScan)
|
||||
{
|
||||
SANE_Status stat3 = saneAPI.sane_start_api(p->m_devHandle);
|
||||
|
|
Loading…
Reference in New Issue