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