184 lines
5.0 KiB
C
184 lines
5.0 KiB
C
#ifndef __HGSCANNERLIB_H__
|
||
#define __HGSCANNERLIB_H__
|
||
|
||
#include "HGDef.h"
|
||
#include "HGScannerLibOption.h"
|
||
|
||
HG_DECLARE_HANDLE(HGLibImage);
|
||
HG_DECLARE_HANDLE(HGLibDevice);
|
||
|
||
/* TIFF压缩方式 */
|
||
#define HGLIB_TIFFCOMPRESSION_NONE 1L
|
||
#define HGLIB_TIFFCOMPRESSION_CCITTFAX4 2L
|
||
#define HGLIB_TIFFCOMPRESSION_LZW 3L
|
||
#define HGLIB_TIFFCOMPRESSION_JPEG 4L
|
||
|
||
/* 设备热拔插事件 */
|
||
#define HGLIB_DEVHOTPLUG_EVENT_ARRIVE 1L
|
||
#define HGLIB_DEVHOTPLUG_EVENT_REMOVE 2L
|
||
|
||
/* 设备扫描事件 */
|
||
#define HGLIB_DEVSCAN_EVENT_BEGIN 1L
|
||
#define HGLIB_DEVSCAN_EVENT_END 2L
|
||
#define HGLIB_DEVSCAN_EVENT_INFO 3L
|
||
|
||
/* 设备参数类型 */
|
||
#define HGLIB_DEVPARAM_TYPE_INT 1L
|
||
#define HGLIB_DEVPARAM_TYPE_STRING 2L
|
||
#define HGLIB_DEVPARAM_TYPE_DOUBLE 3L
|
||
#define HGLIB_DEVPARAM_TYPE_BOOL 4L
|
||
|
||
/* 设备参数取值范围类型 */
|
||
#define HGLIB_DEVPARAM_RANGETYPE_NULL 0L
|
||
#define HGLIB_DEVPARAM_RANGETYPE_INTLIST 1L
|
||
#define HGLIB_DEVPARAM_RANGETYPE_STRINGLIST 2L
|
||
#define HGLIB_DEVPARAM_RANGETYPE_DOUBLELIST 3L
|
||
#define HGLIB_DEVPARAM_RANGETYPE_INTRANGE 4L
|
||
#define HGLIB_DEVPARAM_RANGETYPE_DOUBLERANGE 5L
|
||
|
||
typedef struct
|
||
{
|
||
HGUInt size; /* 结构体大小,必须初始化为sizeof(HGLibSaveImageParam) */
|
||
HGUInt jpegQuality; /* jpeg下有效, 0-100 */
|
||
HGUInt tiffCompression; /* tiff下有效, HGLIB_TIFFCOMPRESSION_* */
|
||
HGUInt tiffJpegQuality; /* tiff且HGLIB_TIFFCOMPRESSION_JPEG下有效, 0-100 */
|
||
HGBool ocr; /* 是否OCR,pdf和ofd格式有效 */
|
||
}HGLibSaveImageParam;
|
||
|
||
typedef struct
|
||
{
|
||
HGChar *title; /* 参数名, UTF8 */
|
||
HGUInt type; /* 参数类型, 参见HGLIB_DEVPARAM_TYPE_* */
|
||
union
|
||
{
|
||
HGInt intValue;
|
||
HGChar *stringValue;
|
||
HGDouble doubleValue;
|
||
HGBool boolValue;
|
||
};
|
||
}HGLibDeviceSetParam;
|
||
|
||
typedef struct
|
||
{
|
||
HGInt* value;
|
||
HGUInt count;
|
||
}HGLibDeviceIntValueList;
|
||
|
||
typedef struct
|
||
{
|
||
HGChar** value;
|
||
HGUInt count;
|
||
}HGLibDeviceStringValueList;
|
||
|
||
typedef struct
|
||
{
|
||
HGDouble* value;
|
||
HGUInt count;
|
||
}HGLibDeviceDoubleValueList;
|
||
|
||
typedef struct
|
||
{
|
||
HGInt minValue;
|
||
HGInt maxValue;
|
||
}HGLibDeviceIntValueRange;
|
||
|
||
typedef struct
|
||
{
|
||
HGDouble minValue;
|
||
HGDouble maxValue;
|
||
}HGLibDeviceDoubleValueRange;
|
||
|
||
typedef struct
|
||
{
|
||
HGLibDeviceSetParam param;
|
||
HGUInt rangeType; /* 取值类型, 参见HGLIB_DEVPARAM_RANGETYPE_* */
|
||
union
|
||
{
|
||
HGLibDeviceIntValueList intValueList;
|
||
HGLibDeviceStringValueList stringValueList;
|
||
HGLibDeviceDoubleValueList doubleValueList;
|
||
HGLibDeviceIntValueRange intValueRange;
|
||
HGLibDeviceDoubleValueRange doubleValueRange;
|
||
};
|
||
}HGLibDeviceGetParam;
|
||
|
||
typedef struct
|
||
{
|
||
HGChar* groupName;
|
||
HGLibDeviceGetParam* param;
|
||
HGUInt paramCount;
|
||
}HGLibDeviceGetParamGroup;
|
||
|
||
/* 设备热拔插回调
|
||
* event: HGLIB_DEVHOTPLUG_EVENT_*
|
||
* deviceName: 设备名
|
||
* param: 回调参数
|
||
*/
|
||
typedef void (*HGLibDeviceHotPlugEventFunc)(HGUInt event, const HGChar *deviceName, HGPointer param);
|
||
|
||
/* 设备扫描事件回调
|
||
* device: 设备句柄
|
||
* event: HGLIB_DEVSCAN_EVENT_*
|
||
* err: 是否是错误信息, HGLIB_DEVSCAN_EVENT_INFO下有效
|
||
* info: 扫描信息, HGLIB_DEVSCAN_EVENT_INFO下有效
|
||
* param: 回调参数
|
||
*/
|
||
typedef void (*HGLibDeviceScanEventFunc)(HGLibDevice device, HGUInt event, HGBool err, const HGChar *info, HGPointer param);
|
||
|
||
/* 设备扫描图像回调
|
||
* device: 设备句柄
|
||
* image: 图像句柄, 不要调用HGLib_ReleaseImage释放, 回调执行后会自动释放
|
||
* param: 回调参数
|
||
*/
|
||
typedef void (*HGLibDeviceScanImageFunc)(HGLibDevice device, HGLibImage image, HGPointer param);
|
||
|
||
/* 加载图像 */
|
||
HGEXPORT HGLibImage HGAPI HGLib_LoadImage(const HGChar *filePath);
|
||
|
||
/* 保存图像 */
|
||
HGEXPORT HGBool HGAPI HGLib_SaveImage(HGLibImage image, const HGChar* savePath, const HGLibSaveImageParam* saveParam);
|
||
|
||
/* 释放图像 */
|
||
HGEXPORT HGBool HGAPI HGLib_ReleaseImage(HGLibImage image);
|
||
|
||
/* 初始化扫描仪 */
|
||
HGEXPORT HGBool HGAPI HGLib_InitDevice(HGLibDeviceHotPlugEventFunc func, HGPointer param);
|
||
|
||
/* 反初始化扫描仪 */
|
||
HGEXPORT HGBool HGAPI HGLib_DeinitDevice();
|
||
|
||
/* 获取扫描仪名称列表 */
|
||
HGEXPORT HGChar** HGAPI HGLib_GetDeviceNameList();
|
||
|
||
/* 销毁扫描仪名称列表 */
|
||
HGEXPORT HGBool HGAPI HGLib_ReleaseDeviceNameList(HGChar** deviceName);
|
||
|
||
/* 打开设备 */
|
||
HGEXPORT HGLibDevice HGAPI HGLib_OpenDevice(const HGChar *deviceName);
|
||
|
||
/* 关闭设备 */
|
||
HGEXPORT HGBool HGAPI HGLib_CloseDevice(HGLibDevice device);
|
||
|
||
/* 设置设备参数 */
|
||
HGEXPORT HGBool HGAPI HGLib_SetDeviceParam(HGLibDevice device, const HGLibDeviceSetParam *param, HGUInt count);
|
||
HGEXPORT HGBool HGAPI HGLib_SetDeviceParamEx(HGLibDevice device, const HGChar *option, const HGVoid *data);
|
||
|
||
/* 获取设备参数 */
|
||
HGEXPORT HGLibDeviceGetParamGroup* HGAPI HGLib_GetDeviceParamGroupList(HGLibDevice device, HGUInt *count);
|
||
HGEXPORT HGLibDeviceGetParam* HGAPI HGLib_GetDeviceParam(HGLibDevice device, const HGChar* option);
|
||
|
||
/* 销毁设备参数 */
|
||
HGEXPORT HGBool HGAPI HGLib_ReleaseDeviceParamGroupList(HGLibDeviceGetParamGroup* paramGroup, HGUInt count);
|
||
HGEXPORT HGBool HGAPI HGLib_ReleaseDeviceParam(HGLibDeviceGetParam* param);
|
||
|
||
/* 重置设备参数 */
|
||
HGEXPORT HGBool HGAPI HGLib_ResetDeviceParam(HGLibDevice device);
|
||
|
||
/* 开始扫描 */
|
||
HGEXPORT HGBool HGAPI HGLib_StartDeviceScan(HGLibDevice device, HGLibDeviceScanEventFunc eventFunc, HGPointer eventParam,
|
||
HGLibDeviceScanImageFunc imageFunc, HGPointer imageParam);
|
||
|
||
/* 停止扫描 */
|
||
HGEXPORT HGBool HGAPI HGLib_StopDeviceScan(HGLibDevice device);
|
||
|
||
#endif /* __HGSCANNERLIB_H__ */ |