code_app/sdk/scannerlib/HGScannerLib.h

179 lines
4.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __HGSCANNERLIB_H__
#define __HGSCANNERLIB_H__
#include "HGDef.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_RANDETYPE_INTLIST 1L
#define HGLIB_DEVPARAM_RANDETYPE_STRINGLIST 2L
#define HGLIB_DEVPARAM_RANDETYPE_DOUBLELIST 3L
#define HGLIB_DEVPARAM_RANDETYPE_INTRANGE 4L
#define HGLIB_DEVPARAM_RANDETYPE_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; /* 是否OCRpdf和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 HGLibDeviceGetParamGroup* HGAPI HGLib_GetDeviceParamGroupList(HGLibDevice device, HGUInt *count);
/* 销毁设备参数 */
HGEXPORT HGBool HGAPI HGLib_ReleaseDeviceParamGroupList(HGLibDeviceGetParamGroup* paramGroup, HGUInt count);
/* 重置设备参数 */
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__ */