diff --git a/doc/scannerlib/新版SDK接口说明.doc b/doc/scannerlib/新版SDK接口说明.doc
index 9efd48d8..6b61360c 100644
Binary files a/doc/scannerlib/新版SDK接口说明.doc and b/doc/scannerlib/新版SDK接口说明.doc differ
diff --git a/doc/scannerlib/新版SDK接口说明.pdf b/doc/scannerlib/新版SDK接口说明.pdf
index 3d13b174..b8705cec 100644
Binary files a/doc/scannerlib/新版SDK接口说明.pdf and b/doc/scannerlib/新版SDK接口说明.pdf differ
diff --git a/test/scannerlib/CMakeLists.txt b/test/scannerlib/hanvon/CMakeLists.txt
similarity index 100%
rename from test/scannerlib/CMakeLists.txt
rename to test/scannerlib/hanvon/CMakeLists.txt
diff --git a/test/scannerlib/c#/WindowsFormsApp1/Form1.Designer.cs b/test/scannerlib/hanvon/c#/WindowsFormsApp1/Form1.Designer.cs
similarity index 100%
rename from test/scannerlib/c#/WindowsFormsApp1/Form1.Designer.cs
rename to test/scannerlib/hanvon/c#/WindowsFormsApp1/Form1.Designer.cs
diff --git a/test/scannerlib/c#/WindowsFormsApp1/Form1.cs b/test/scannerlib/hanvon/c#/WindowsFormsApp1/Form1.cs
similarity index 100%
rename from test/scannerlib/c#/WindowsFormsApp1/Form1.cs
rename to test/scannerlib/hanvon/c#/WindowsFormsApp1/Form1.cs
diff --git a/test/scannerlib/c#/WindowsFormsApp1/Form1.resx b/test/scannerlib/hanvon/c#/WindowsFormsApp1/Form1.resx
similarity index 100%
rename from test/scannerlib/c#/WindowsFormsApp1/Form1.resx
rename to test/scannerlib/hanvon/c#/WindowsFormsApp1/Form1.resx
diff --git a/test/scannerlib/hanvon/c#/WindowsFormsApp1/HGScannerLib.cs b/test/scannerlib/hanvon/c#/WindowsFormsApp1/HGScannerLib.cs
new file mode 100644
index 00000000..8e617f9e
--- /dev/null
+++ b/test/scannerlib/hanvon/c#/WindowsFormsApp1/HGScannerLib.cs
@@ -0,0 +1,158 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace WindowsFormsApp1
+{
+ public class HGScannerLib
+ {
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibSaveImageParam
+ {
+ public UInt32 size;
+ public UInt32 jpegQuality;
+ public UInt32 tiffCompression;
+ public UInt32 tiffJpegQuality;
+ public Int32 ocr;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceIntValueList
+ {
+ public IntPtr value; // Int32指针
+ public UInt32 count;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceEnumValueList
+ {
+ public IntPtr value; // UInt32指针
+ public UInt32 count;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceDoubleValueList
+ {
+ public IntPtr value; // Double指针
+ public UInt32 count;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceIntValueRange
+ {
+ public Int32 minValue;
+ public Int32 maxValue;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceDoubleValueRange
+ {
+ public Double minValue;
+ public Double maxValue;
+ }
+
+ [StructLayout(LayoutKind.Explicit, Pack = 4)]
+ public struct HGLibDeviceParamType
+ {
+ [FieldOffset(0)] public Int32 intValue;
+ [FieldOffset(0)] public UInt32 enumValue;
+ [FieldOffset(0)] public Double doubleValue;
+ [FieldOffset(0)] public Int32 boolValue;
+ }
+
+ [StructLayout(LayoutKind.Explicit, Pack = 4)]
+ public struct HGLibDeviceParamRangeType
+ {
+ [FieldOffset(0)] public HGLibDeviceIntValueList intValueList;
+ [FieldOffset(0)] public HGLibDeviceEnumValueList enumValueList;
+ [FieldOffset(0)] public HGLibDeviceDoubleValueList doubleValueList;
+ [FieldOffset(0)] public HGLibDeviceIntValueRange intValueRange;
+ [FieldOffset(0)] public HGLibDeviceDoubleValueRange doubleValueRange;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceParam
+ {
+ public UInt32 option;
+ public UInt32 type;
+ public HGLibDeviceParamType typeValue;
+ public UInt32 rangeType;
+ public HGLibDeviceParamRangeType rangeTypeValue;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceParamGroup
+ {
+ public UInt32 group;
+ public IntPtr param; // HGLibDeviceParam指针
+ public UInt32 paramCount;
+ }
+
+ public delegate void HGLibDeviceHotPlugEventFunc(UInt32 evt, IntPtr deviceName, IntPtr param);
+ public delegate void HGLibDeviceScanEventFunc(UIntPtr device, UInt32 evt, Int32 err, IntPtr info, IntPtr param);
+ public delegate void HGLibDeviceScanImageFunc(UIntPtr device, UIntPtr image, IntPtr param);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_LoadImage")]
+ public static extern UIntPtr HGLib_LoadImage(IntPtr filePath);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_SaveImage")]
+ public static extern Int32 HGLib_SaveImage(UIntPtr image, IntPtr filePath, ref HGLibSaveImageParam saveParam);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_ReleaseImage")]
+ public static extern Int32 HGLib_ReleaseImage(UIntPtr image);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_InitDevice")]
+ public static extern Int32 HGLib_InitDevice(HGLibDeviceHotPlugEventFunc func, IntPtr param);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_DeinitDevice")]
+ public static extern Int32 HGLib_DeinitDevice();
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_GetDeviceNameList")]
+ public static extern IntPtr HGLib_GetDeviceNameList();
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_ReleaseDeviceNameList")]
+ public static extern Int32 HGLib_ReleaseDeviceNameList(IntPtr deviceNameList);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_OpenDevice")]
+ public static extern UIntPtr HGLib_OpenDevice(IntPtr deviceName);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_CloseDevice")]
+ public static extern Int32 HGLib_CloseDevice(UIntPtr device);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_GetDeviceSN")]
+ public static extern Int32 HGLib_GetDeviceSN(UIntPtr device, IntPtr sn, UInt32 maxLen);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_GetDeviceFWVersion")]
+ public static extern Int32 HGLib_GetDeviceFWVersion(UIntPtr device, IntPtr fwVersion, UInt32 maxLen);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_SetDeviceParam")]
+ public static extern Int32 HGLib_SetDeviceParam(UIntPtr device, UInt32 option, IntPtr data);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_GetDeviceParamGroupList")]
+ public static extern IntPtr HGLib_GetDeviceParamGroupList(UIntPtr device, ref UInt32 count);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_GetDeviceParam")]
+ public static extern IntPtr HGLib_GetDeviceParam(UIntPtr device, UInt32 option);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_ReleaseDeviceParamGroupList")]
+ public static extern Int32 HGLib_ReleaseDeviceParamGroupList(IntPtr devParamGroup, UInt32 count);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_ReleaseDeviceParam")]
+ public static extern Int32 HGLib_ReleaseDeviceParam(IntPtr devParam);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_ResetDeviceParam")]
+ public static extern Int32 HGLib_ResetDeviceParam(UIntPtr device);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_DeviceIsPaperOn")]
+ public static extern Int32 HGLib_DeviceIsPaperOn(UIntPtr device);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_StartDeviceScan")]
+ public static extern Int32 HGLib_StartDeviceScan(UIntPtr device, HGLibDeviceScanEventFunc eventFunc, IntPtr eventParam,
+ HGLibDeviceScanImageFunc imageFunc, IntPtr imageParam);
+
+ [DllImport("HWScannerLib.dll", EntryPoint = "HGLib_StopDeviceScan")]
+ public static extern Int32 HGLib_StopDeviceScan(UIntPtr device);
+ }
+}
diff --git a/test/scannerlib/c#/WindowsFormsApp1/Program.cs b/test/scannerlib/hanvon/c#/WindowsFormsApp1/Program.cs
similarity index 100%
rename from test/scannerlib/c#/WindowsFormsApp1/Program.cs
rename to test/scannerlib/hanvon/c#/WindowsFormsApp1/Program.cs
diff --git a/test/scannerlib/c#/WindowsFormsApp1/Properties/AssemblyInfo.cs b/test/scannerlib/hanvon/c#/WindowsFormsApp1/Properties/AssemblyInfo.cs
similarity index 100%
rename from test/scannerlib/c#/WindowsFormsApp1/Properties/AssemblyInfo.cs
rename to test/scannerlib/hanvon/c#/WindowsFormsApp1/Properties/AssemblyInfo.cs
diff --git a/test/scannerlib/c#/WindowsFormsApp1/Properties/Resources.Designer.cs b/test/scannerlib/hanvon/c#/WindowsFormsApp1/Properties/Resources.Designer.cs
similarity index 100%
rename from test/scannerlib/c#/WindowsFormsApp1/Properties/Resources.Designer.cs
rename to test/scannerlib/hanvon/c#/WindowsFormsApp1/Properties/Resources.Designer.cs
diff --git a/test/scannerlib/c#/WindowsFormsApp1/Properties/Resources.resx b/test/scannerlib/hanvon/c#/WindowsFormsApp1/Properties/Resources.resx
similarity index 100%
rename from test/scannerlib/c#/WindowsFormsApp1/Properties/Resources.resx
rename to test/scannerlib/hanvon/c#/WindowsFormsApp1/Properties/Resources.resx
diff --git a/test/scannerlib/c#/WindowsFormsApp1/Properties/Settings.Designer.cs b/test/scannerlib/hanvon/c#/WindowsFormsApp1/Properties/Settings.Designer.cs
similarity index 100%
rename from test/scannerlib/c#/WindowsFormsApp1/Properties/Settings.Designer.cs
rename to test/scannerlib/hanvon/c#/WindowsFormsApp1/Properties/Settings.Designer.cs
diff --git a/test/scannerlib/c#/WindowsFormsApp1/Properties/Settings.settings b/test/scannerlib/hanvon/c#/WindowsFormsApp1/Properties/Settings.settings
similarity index 100%
rename from test/scannerlib/c#/WindowsFormsApp1/Properties/Settings.settings
rename to test/scannerlib/hanvon/c#/WindowsFormsApp1/Properties/Settings.settings
diff --git a/test/scannerlib/c#/WindowsFormsApp1/WindowsFormsApp1.csproj b/test/scannerlib/hanvon/c#/WindowsFormsApp1/WindowsFormsApp1.csproj
similarity index 100%
rename from test/scannerlib/c#/WindowsFormsApp1/WindowsFormsApp1.csproj
rename to test/scannerlib/hanvon/c#/WindowsFormsApp1/WindowsFormsApp1.csproj
diff --git a/test/scannerlib/c#/WindowsFormsApp1/WindowsFormsApp1.sln b/test/scannerlib/hanvon/c#/WindowsFormsApp1/WindowsFormsApp1.sln
similarity index 100%
rename from test/scannerlib/c#/WindowsFormsApp1/WindowsFormsApp1.sln
rename to test/scannerlib/hanvon/c#/WindowsFormsApp1/WindowsFormsApp1.sln
diff --git a/test/scannerlib/main.cpp b/test/scannerlib/hanvon/main.cpp
similarity index 100%
rename from test/scannerlib/main.cpp
rename to test/scannerlib/hanvon/main.cpp
diff --git a/test/scannerlib/hanvon/test.py b/test/scannerlib/hanvon/test.py
new file mode 100644
index 00000000..73ad00fc
--- /dev/null
+++ b/test/scannerlib/hanvon/test.py
@@ -0,0 +1,234 @@
+import ctypes
+import os
+from os import system
+import time
+import platform
+from ctypes import *
+import random
+
+class HGLibSaveImageParam(Structure):
+ _pack_ = 4
+ _fields_ = [ ("size", c_uint),
+ ("jpegQuality", c_uint),
+ ("tiffCompression", c_uint),
+ ("tiffJpegQuality", c_uint),
+ ("ocr", c_int)]
+
+class HGLibDeviceIntValueList(Structure):
+ _pack_ = 4
+ _fields_ = [ ("value", POINTER(c_int)),
+ ("count", c_uint)]
+
+class HGLibDeviceEnumValueList(Structure):
+ _pack_ = 4
+ _fields_ = [ ("value", POINTER(c_uint)),
+ ("count", c_uint)]
+
+class HGLibDeviceDoubleValueList(Structure):
+ _pack_ = 4
+ _fields_ = [ ("value", POINTER(c_double)),
+ ("count", c_uint)]
+
+class HGLibDeviceIntValueRange(Structure):
+ _pack_ = 4
+ _fields_ = [ ("minValue", c_int),
+ ("maxValue", c_int)]
+
+class HGLibDeviceDoubleValueRange(Structure):
+ _pack_ = 4
+ _fields_ = [ ("minValue", c_double),
+ ("maxValue", c_double)]
+
+class HGLibDeviceParamType(Union):
+ _pack_ = 4
+ _fields_ = [ ("intValue", c_int),
+ ("enumValue", c_uint),
+ ("doubleValue", c_double),
+ ("boolValue", c_int)]
+
+class HGLibDeviceParamRangeType(Union):
+ _pack_ = 4
+ _fields_ = [ ("intValueList", HGLibDeviceIntValueList),
+ ("enumValueList", HGLibDeviceEnumValueList),
+ ("doubleValueList", HGLibDeviceDoubleValueList),
+ ("intValueRange", HGLibDeviceIntValueRange),
+ ("doubleValueRange", HGLibDeviceDoubleValueRange)]
+
+class HGLibDeviceParam(Structure):
+ _pack_ = 4
+ _fields_ = [ ("option", c_uint),
+ ("type", c_uint),
+ ("typeValue", HGLibDeviceParamType),
+ ("rangeType", c_uint),
+ ("rangeTypeValue", HGLibDeviceParamRangeType)]
+
+class HGLibDeviceParamGroup(Structure):
+ _pack_ = 4
+ _fields_ = [ ("group", c_uint),
+ ("param", POINTER(HGLibDeviceParam)),
+ ("paramCount", c_uint)]
+
+print(os.path.abspath('.'))
+
+#加载动态库 所有依赖库必须在同一运行目录下边
+if platform.system() == 'Windows':
+ Objdll = ctypes.WinDLL(os.path.abspath('.') + "/HWScannerLib.dll")
+elif platform.system() == "Linux":
+ Objdll = cdll.LoadLibrary(os.path.abspath('.') + "/libHWScannerLib.so")
+
+#加载图像接口示例
+HGLib_LoadImage = Objdll.HGLib_LoadImage
+HGLib_LoadImage.argtypes = [ctypes.c_char_p]
+HGLib_LoadImage.restype = ctypes.c_void_p
+Image = HGLib_LoadImage(c_char_p(b"1.jpg"))
+
+#保存图像接口示例
+HGLib_SaveImage = Objdll.HGLib_SaveImage
+HGLib_SaveImage.argtypes = [ctypes.c_void_p, ctypes.c_char_p, POINTER(HGLibSaveImageParam)]
+HGLib_SaveImage.restype = ctypes.c_int
+ImageParam = HGLibSaveImageParam()
+ImageParam.size = sizeof(ImageParam)
+ImageParam.jpegQuality = 80
+ImageParam.tiffCompression = 4
+ImageParam.tiffJpegQuality = 80
+ImageParam.ocr = 0
+Ret = HGLib_SaveImage(Image, c_char_p(b"2.jpg"), pointer(ImageParam))
+
+#释放图像资源
+HGLib_ReleaseImage = Objdll.HGLib_ReleaseImage
+HGLib_ReleaseImage.argtypes = [ctypes.c_void_p]
+HGLib_ReleaseImage.restype = ctypes.c_int
+Ret = HGLib_ReleaseImage(Image)
+
+#设备热拔插回调事件
+def HGLibDeviceHotPlugEventFunc(event: c_uint, deviceName: c_char_p, param: c_void_p):
+ print(deviceName)
+ return
+
+#初始化操作
+FuncType = CFUNCTYPE(None, c_uint, c_char_p, c_void_p)
+cb = FuncType(HGLibDeviceHotPlugEventFunc)
+HGLib_InitDevice = Objdll.HGLib_InitDevice
+HGLib_InitDevice.argtypes = [FuncType, c_void_p]
+HGLib_InitDevice.restype = ctypes.c_int
+Ret = HGLib_InitDevice(cb, 0)
+
+time.sleep(1)
+
+#获取设备列表
+HGLib_GetDeviceNameList = Objdll.HGLib_GetDeviceNameList
+HGLib_GetDeviceNameList.argtypes = []
+HGLib_GetDeviceNameList.restype = POINTER(ctypes.c_char_p)
+DeviceNameList = HGLib_GetDeviceNameList()
+
+#打开指定设备
+HGLib_OpenDevice = Objdll.HGLib_OpenDevice
+HGLib_OpenDevice.argtypes = [ctypes.c_char_p]
+HGLib_OpenDevice.restype = ctypes.c_void_p
+Device = HGLib_OpenDevice(DeviceNameList[0])
+
+#获取设备所有参数
+HGLib_GetDeviceParamGroupList = Objdll.HGLib_GetDeviceParamGroupList
+HGLib_GetDeviceParamGroupList.argtypes = [ctypes.c_void_p, POINTER(c_uint)]
+HGLib_GetDeviceParamGroupList.restype = POINTER(HGLibDeviceParamGroup)
+DevParamCount = ctypes.c_uint()
+DevParamGroup = HGLib_GetDeviceParamGroupList(Device, pointer(DevParamCount))
+
+GroupList = ['None', 'BaseSetting', 'Brightness', 'ImageProc', 'PaperFeeding']
+ValueTypeList = ['None', 'Int', 'Enum', 'Double', 'Bool']
+ValueRangeTypeList = ['None', 'IntList', 'EnumList', 'DoubleList', 'IntRange', 'DoubleRange']
+
+i = 0
+while i < int(DevParamCount.value):
+ print("group" + str(i) + ":" + GroupList[DevParamGroup[i].group])
+ print(" paramCount:" + str(DevParamGroup[i].paramCount))
+ j = 0
+ while (j < int(DevParamGroup[i].paramCount)):
+ print(" paramOption:" + str(DevParamGroup[i].param[j].option))
+ print(" paramValueType:" + ValueTypeList[DevParamGroup[i].param[j].type])
+ print(" paramValueRangeType:" + ValueRangeTypeList[DevParamGroup[i].param[j].rangeType])
+ j += 1
+ i += 1
+
+#销毁
+HGLib_ReleaseDeviceParamGroupList = Objdll.HGLib_ReleaseDeviceParamGroupList
+HGLib_ReleaseDeviceParamGroupList.argtypes = [POINTER(HGLibDeviceParamGroup), c_uint]
+HGLib_ReleaseDeviceParamGroupList.restype = ctypes.c_int
+Ret = HGLib_ReleaseDeviceParamGroupList(DevParamGroup, DevParamCount)
+
+#设置扫描参数
+HGLib_SetDeviceParam = Objdll.HGLib_SetDeviceParam
+HGLib_SetDeviceParam.argtypes = [ctypes.c_void_p, ctypes.c_uint, ctypes.c_void_p]
+HGLib_SetDeviceParam.restype = ctypes.c_int
+DevParam = ctypes.c_int(1) #HGLIB_OPTION_ENUMVALUE_DLSCLX_W -> 不进行多流输出类型
+Ret = HGLib_SetDeviceParam(Device, 1, byref(DevParam)) #见HGLib_SetDeviceParam 头文件接口说明 1 -> HGLIB_OPTION_NAME_DLSC 多流输出
+
+
+#扫描事件回调
+def HGLibDeviceScanEventFunc(device: c_void_p, event: c_uint, err: c_int, info: c_char_p, param: c_void_p):
+ s_info=info
+ global bStop
+ print("event code",event," event info:",s_info)
+ if event == 2:#HGLIB_DEVSCAN_EVENT_END 扫描停止
+ bStop=True
+ print("bStop true")
+ elif event == 1:
+ bStop=False
+ print("bStop false")
+ return
+imgindex=0
+#扫描图像事件回调
+def HGLibDeviceScanImageFunc(device: c_void_p, image: c_void_p, param: c_void_p):
+ global imgindex
+ ImageParam = HGLibSaveImageParam()
+ ImageParam.size = sizeof(ImageParam)
+ ImageParam.jpegQuality = 80
+ ImageParam.tiffCompression = 4
+ ImageParam.tiffJpegQuality = 80
+ ImageParam.ocr = 0
+ print("image call back!!")
+ imgindex+=1
+ t_index=imgindex
+ imgname=str(t_index) + '_scanned.jpg'
+ print(imgname)
+ b_imagename=imgname.encode('utf-8')
+ pchar=c_char_p(b_imagename)
+ Ret = HGLib_SaveImage(image, pchar, pointer(ImageParam))
+ return
+
+#注册扫描相关事件并启动扫描
+FuncType1 = CFUNCTYPE(None, c_void_p, c_uint, c_int, c_char_p, c_void_p)
+cb1 = FuncType1(HGLibDeviceScanEventFunc)
+FuncType2 = CFUNCTYPE(None, c_void_p, c_void_p, c_void_p)
+cb2 = FuncType2(HGLibDeviceScanImageFunc)
+HGLib_StartDeviceScan = Objdll.HGLib_StartDeviceScan
+HGLib_StartDeviceScan.argtypes = [c_void_p, FuncType1, c_void_p, FuncType2, c_void_p]
+HGLib_StartDeviceScan.restyped = ctypes.c_int
+print("start scan")
+Ret = HGLib_StartDeviceScan(Device, cb1, 0, cb2, 0)
+
+#模拟扫描持续应等待扫描事件回调返回扫描停止才结束本次扫描流程
+while(not bStop):
+ time.sleep(1)
+ print("scanning...")
+
+
+print("scan done!!!")
+
+#关闭当前打开的设备
+HGLib_CloseDevice=Objdll.HGLib_CloseDevice
+HGLib_CloseDevice.argtypes = [c_void_p]
+HGLib_CloseDevice.restype = ctypes.c_int
+HGLib_CloseDevice(Device)
+print("Close Devices")
+
+#释放设备列表资源
+HGLib_ReleaseDeviceNameList=Objdll.HGLib_ReleaseDeviceNameList
+HGLib_ReleaseDeviceNameList.argtypes=[POINTER(ctypes.c_char_p)]
+HGLib_ReleaseDeviceNameList.restype = ctypes.c_int
+HGLib_ReleaseDeviceNameList(DeviceNameList)
+print("ReleaseDeviceNameList done")
+
+print("exit test")
+
+
diff --git a/test/scannerlib/huagao/CMakeLists.txt b/test/scannerlib/huagao/CMakeLists.txt
new file mode 100644
index 00000000..120cd353
--- /dev/null
+++ b/test/scannerlib/huagao/CMakeLists.txt
@@ -0,0 +1,12 @@
+project(testdemo)
+
+FILE(GLOB SRC "*.cpp" "*.h" "*.c")
+include_directories(${PROJECT_SOURCE_DIR}/)
+
+add_executable(${PROJECT_NAME} ${SRC})
+
+target_link_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/)
+
+target_link_libraries(${PROJECT_NAME} HGBase hgdriver HGImgFmt HGImgProc HGScannerLib mupdf pdf sane-hgsane)
+
+set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/)
\ No newline at end of file
diff --git a/test/scannerlib/huagao/c#/WindowsFormsApp1/Form1.Designer.cs b/test/scannerlib/huagao/c#/WindowsFormsApp1/Form1.Designer.cs
new file mode 100644
index 00000000..76ecc4fb
--- /dev/null
+++ b/test/scannerlib/huagao/c#/WindowsFormsApp1/Form1.Designer.cs
@@ -0,0 +1,62 @@
+
+namespace WindowsFormsApp1
+{
+ partial class Form1
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows 窗体设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ this.button1 = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(301, 157);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(166, 65);
+ this.button1.TabIndex = 0;
+ this.button1.Text = "扫描";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.button1);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button button1;
+ }
+}
+
diff --git a/test/scannerlib/huagao/c#/WindowsFormsApp1/Form1.cs b/test/scannerlib/huagao/c#/WindowsFormsApp1/Form1.cs
new file mode 100644
index 00000000..8b733879
--- /dev/null
+++ b/test/scannerlib/huagao/c#/WindowsFormsApp1/Form1.cs
@@ -0,0 +1,281 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using System.Runtime.InteropServices;
+using System.Globalization;
+using System.Timers;
+using System.Threading;
+
+namespace WindowsFormsApp1
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ UIntPtr image = HGScannerLib.HGLib_LoadImage(StringToUtf8("1.jpg"));
+ if (UIntPtr.Zero != image)
+ {
+ HGScannerLib.HGLibSaveImageParam saveParam;
+ saveParam.size = (UInt32)Marshal.SizeOf(typeof(HGScannerLib.HGLibSaveImageParam));
+ saveParam.jpegQuality = 80;
+ saveParam.tiffCompression = 4;
+ saveParam.tiffJpegQuality = 80;
+ saveParam.ocr = 0;
+ HGScannerLib.HGLib_SaveImage(image, StringToUtf8("2.jpg"), ref saveParam);
+ HGScannerLib.HGLib_ReleaseImage(image);
+ }
+
+ HGScannerLib.HGLibDeviceHotPlugEventFunc fun = new HGScannerLib.HGLibDeviceHotPlugEventFunc(DeviceHotPlugEventFunc);
+ HGScannerLib.HGLib_InitDevice(fun, this.Handle);
+ Thread.Sleep(500);
+
+ IntPtr deviceNameList = HGScannerLib.HGLib_GetDeviceNameList();
+ if (IntPtr.Zero != deviceNameList)
+ {
+ // 获取设备列表
+ int i = 0;
+ IntPtr deviceName = Marshal.ReadIntPtr(deviceNameList, 0);
+ while (IntPtr.Zero != deviceName)
+ {
+ String deviceNameText = Utf8ToString(deviceName);
+ ++i;
+ deviceName = Marshal.ReadIntPtr(deviceNameList, Marshal.SizeOf(typeof(IntPtr)) * i);
+ }
+
+ // 打开第一个设备
+ UIntPtr device = HGScannerLib.HGLib_OpenDevice(Marshal.ReadIntPtr(deviceNameList, 0));
+ if (UIntPtr.Zero != device)
+ {
+ // 获取序列号
+ Byte[] sn = new Byte[60];
+ IntPtr snAddr = Marshal.UnsafeAddrOfPinnedArrayElement(sn, 0);
+ HGScannerLib.HGLib_GetDeviceSN(device, snAddr, 60);
+ String snText = Utf8ToString(snAddr);
+
+ // 获取固件版本号
+ Byte[] fwVer = new Byte[60];
+ IntPtr fwVerAddr = Marshal.UnsafeAddrOfPinnedArrayElement(fwVer, 0);
+ HGScannerLib.HGLib_GetDeviceFWVersion(device, fwVerAddr, 60);
+ String fwVerText = Utf8ToString(fwVerAddr);
+
+ // 设置待纸扫描
+ Int32[] dzsm = new Int32[1];
+ dzsm[0] = 1;
+ Int32 ret1 = HGScannerLib.HGLib_SetDeviceParam(device, 67,
+ Marshal.UnsafeAddrOfPinnedArrayElement(dzsm, 0));
+
+ // 设置旋转90度
+ UInt32[] rotate = new UInt32[1];
+ rotate[0] = 67;
+ Int32 ret2 = HGScannerLib.HGLib_SetDeviceParam(device, 59,
+ Marshal.UnsafeAddrOfPinnedArrayElement(rotate, 0));
+
+ // 设置伽马值
+ Double[] gamma = new Double[1];
+ gamma[0] = 1.0;
+ Int32 ret3 = HGScannerLib.HGLib_SetDeviceParam(device, 35,
+ Marshal.UnsafeAddrOfPinnedArrayElement(gamma, 0));
+
+ // 获取旋转的配置
+ IntPtr rotateParam = HGScannerLib.HGLib_GetDeviceParam(device, 59);
+ if (IntPtr.Zero != rotateParam)
+ {
+ HGScannerLib.HGLibDeviceParam param = (HGScannerLib.HGLibDeviceParam)
+ Marshal.PtrToStructure(rotateParam, typeof(HGScannerLib.HGLibDeviceParam));
+
+ // print param
+ PrintParam(ref param);
+
+ HGScannerLib.HGLib_ReleaseDeviceParam(rotateParam);
+ }
+
+ // 获取所有配置
+ UInt32 groupCount = 0;
+ IntPtr groupParamList = HGScannerLib.HGLib_GetDeviceParamGroupList(device, ref groupCount);
+ if (IntPtr.Zero != groupParamList)
+ {
+ for (int groupIdx = 0; groupIdx < (int)groupCount; ++groupIdx)
+ {
+ HGScannerLib.HGLibDeviceParamGroup group = (HGScannerLib.HGLibDeviceParamGroup)
+ Marshal.PtrToStructure(groupParamList + Marshal.SizeOf(typeof(HGScannerLib.HGLibDeviceParamGroup)) * groupIdx,
+ typeof(HGScannerLib.HGLibDeviceParamGroup));
+
+ // 组名
+ UInt32 groupName = group.group;
+ // 组内配置的数量
+ UInt32 paramCount = group.paramCount;
+
+ for (int paramIdx = 0; paramIdx < group.paramCount; ++paramIdx)
+ {
+ HGScannerLib.HGLibDeviceParam param = (HGScannerLib.HGLibDeviceParam)
+ Marshal.PtrToStructure(group.param + Marshal.SizeOf(typeof(HGScannerLib.HGLibDeviceParam)) * paramIdx,
+ typeof(HGScannerLib.HGLibDeviceParam));
+
+ // print param
+ PrintParam(ref param);
+ }
+ }
+
+ HGScannerLib.HGLib_ReleaseDeviceParamGroupList(groupParamList, groupCount);
+ }
+
+ // 扫描
+ m_break = false;
+ HGScannerLib.HGLibDeviceScanEventFunc eventFunc = new HGScannerLib.HGLibDeviceScanEventFunc(DeviceScanEventFunc);
+ HGScannerLib.HGLibDeviceScanImageFunc imageFunc = new HGScannerLib.HGLibDeviceScanImageFunc(DeviceScanImageFunc);
+ Int32 scanRet = HGScannerLib.HGLib_StartDeviceScan(device, eventFunc, this.Handle, imageFunc, this.Handle);
+ if (0 != scanRet)
+ {
+ while (!m_break)
+ {
+ Thread.Sleep(100);
+ }
+
+ HGScannerLib.HGLib_StopDeviceScan(device);
+ }
+
+ HGScannerLib.HGLib_CloseDevice(device);
+ }
+
+ HGScannerLib.HGLib_ReleaseDeviceNameList(deviceNameList);
+ }
+
+ HGScannerLib.HGLib_DeinitDevice();
+ }
+
+ public void DeviceHotPlugEventFunc(UInt32 evt, IntPtr deviceName, IntPtr param)
+ {
+ String devNameText = Utf8ToString(deviceName);
+ }
+
+ public void DeviceScanEventFunc(UIntPtr device, UInt32 evt, Int32 err, IntPtr info, IntPtr param)
+ {
+ if (evt == 2)
+ {
+ m_break = true;
+ }
+ else if (3 == evt)
+ {
+ String infoText = Utf8ToString(info);
+ }
+ }
+
+ public void DeviceScanImageFunc(UIntPtr device, UIntPtr image, IntPtr param)
+ {
+ String fileName = String.Format("Scan_{0}.jpg", m_scanCount);
+ ++m_scanCount;
+
+ HGScannerLib.HGLibSaveImageParam saveParam;
+ saveParam.size = (UInt32)Marshal.SizeOf(typeof(HGScannerLib.HGLibSaveImageParam));
+ saveParam.jpegQuality = 80;
+ saveParam.tiffCompression = 4;
+ saveParam.tiffJpegQuality = 80;
+ saveParam.ocr = 0;
+ HGScannerLib.HGLib_SaveImage(image, StringToUtf8(fileName), ref saveParam);
+ }
+
+ public String Utf8ToString(IntPtr str)
+ {
+ if (IntPtr.Zero == str)
+ {
+ return "";
+ }
+
+ int len = 0;
+ while (0 != Marshal.ReadByte(str, len))
+ {
+ ++len;
+ }
+
+ if (0 == len)
+ {
+ return "";
+ }
+
+ Byte[] utf8 = new Byte[len];
+ Marshal.Copy(str, utf8, 0, len);
+ return Encoding.UTF8.GetString(utf8);
+ }
+
+ public IntPtr StringToUtf8(String str)
+ {
+ if (str.Length == 0)
+ {
+ return IntPtr.Zero;
+ }
+
+ Byte[] src = Encoding.UTF8.GetBytes(str);
+ Byte[] dst = new Byte[src.Length + 1];
+ for (int i = 0; i < src.Length; ++i)
+ dst[i] = src[i];
+ dst[dst.Length - 1] = 0;
+ return Marshal.UnsafeAddrOfPinnedArrayElement(dst, 0);
+ }
+
+ public void PrintParam(ref HGScannerLib.HGLibDeviceParam param)
+ {
+ // 配置名
+ UInt32 option = param.option;
+
+ if (1 == param.type) // 整型
+ {
+ Int32 value = param.typeValue.intValue;
+ }
+ else if (2 == param.type) // 枚举
+ {
+ UInt32 value = param.typeValue.enumValue;
+ }
+ else if (3 == param.type) // 双精度浮点
+ {
+ Double value = param.typeValue.doubleValue;
+ }
+ else if (4 == param.type) // BOOL
+ {
+ Int32 value = param.typeValue.boolValue;
+ }
+
+ if (param.rangeType == 1) // 整型列表
+ {
+ Int32[] intValueList = new Int32[param.rangeTypeValue.intValueList.count];
+ Marshal.Copy(param.rangeTypeValue.intValueList.value, intValueList, 0, (int)param.rangeTypeValue.intValueList.count);
+ }
+ else if (param.rangeType == 2) // 枚举列表
+ {
+ Int32[] enumValueList = new Int32[param.rangeTypeValue.enumValueList.count];
+ Marshal.Copy(param.rangeTypeValue.enumValueList.value, enumValueList, 0, (int)param.rangeTypeValue.enumValueList.count);
+ }
+ else if (param.rangeType == 3) // 双精度浮点列表
+ {
+ Double[] doubleValueList = new Double[param.rangeTypeValue.doubleValueList.count];
+ Marshal.Copy(param.rangeTypeValue.doubleValueList.value, doubleValueList, 0, (int)param.rangeTypeValue.doubleValueList.count);
+ }
+ else if (param.rangeType == 4) // 整型范围
+ {
+ // 最小值
+ Int32 minVal = param.rangeTypeValue.intValueRange.minValue;
+ // 最大值
+ Int32 maxVal = param.rangeTypeValue.intValueRange.maxValue;
+ }
+ else if (param.rangeType == 5) // 双精度浮点范围
+ {
+ // 最小值
+ Double minVal = param.rangeTypeValue.doubleValueRange.minValue;
+ // 最大值
+ Double maxVal = param.rangeTypeValue.doubleValueRange.maxValue;
+ }
+ }
+
+ public UInt32 m_scanCount = 1;
+ public Boolean m_break = false;
+ }
+}
diff --git a/test/scannerlib/huagao/c#/WindowsFormsApp1/Form1.resx b/test/scannerlib/huagao/c#/WindowsFormsApp1/Form1.resx
new file mode 100644
index 00000000..1af7de15
--- /dev/null
+++ b/test/scannerlib/huagao/c#/WindowsFormsApp1/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/test/scannerlib/c#/WindowsFormsApp1/HGScannerLib.cs b/test/scannerlib/huagao/c#/WindowsFormsApp1/HGScannerLib.cs
similarity index 100%
rename from test/scannerlib/c#/WindowsFormsApp1/HGScannerLib.cs
rename to test/scannerlib/huagao/c#/WindowsFormsApp1/HGScannerLib.cs
diff --git a/test/scannerlib/huagao/c#/WindowsFormsApp1/Program.cs b/test/scannerlib/huagao/c#/WindowsFormsApp1/Program.cs
new file mode 100644
index 00000000..1561dc46
--- /dev/null
+++ b/test/scannerlib/huagao/c#/WindowsFormsApp1/Program.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+
+namespace WindowsFormsApp1
+{
+ static class Program
+ {
+ ///
+ /// 应用程序的主入口点。
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/AssemblyInfo.cs b/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..187bd623
--- /dev/null
+++ b/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("WindowsFormsApp1")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WindowsFormsApp1")]
+[assembly: AssemblyCopyright("Copyright © 2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("e364d770-bb5c-400a-902e-213a3dadcbd5")]
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/Resources.Designer.cs b/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..7a2f3472
--- /dev/null
+++ b/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本: 4.0.30319.42000
+//
+// 对此文件的更改可能导致不正确的行为,如果
+// 重新生成代码,则所做更改将丢失。
+//
+//------------------------------------------------------------------------------
+
+
+namespace WindowsFormsApp1.Properties
+{
+ ///
+ /// 强类型资源类,用于查找本地化字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// 返回此类使用的缓存 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsFormsApp1.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 重写当前线程的 CurrentUICulture 属性,对
+ /// 使用此强类型资源类的所有资源查找执行重写。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/Resources.resx b/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/Resources.resx
new file mode 100644
index 00000000..af7dbebb
--- /dev/null
+++ b/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/Settings.Designer.cs b/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..3cdaf800
--- /dev/null
+++ b/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/Settings.Designer.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace WindowsFormsApp1.Properties
+{
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/Settings.settings b/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/Settings.settings
new file mode 100644
index 00000000..39645652
--- /dev/null
+++ b/test/scannerlib/huagao/c#/WindowsFormsApp1/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/test/scannerlib/huagao/c#/WindowsFormsApp1/WindowsFormsApp1.csproj b/test/scannerlib/huagao/c#/WindowsFormsApp1/WindowsFormsApp1.csproj
new file mode 100644
index 00000000..67d99ae5
--- /dev/null
+++ b/test/scannerlib/huagao/c#/WindowsFormsApp1/WindowsFormsApp1.csproj
@@ -0,0 +1,81 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {E364D770-BB5C-400A-902E-213A3DADCBD5}
+ WinExe
+ WindowsFormsApp1
+ WindowsFormsApp1
+ v4.0
+ 512
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ true
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
\ No newline at end of file
diff --git a/test/scannerlib/huagao/c#/WindowsFormsApp1/WindowsFormsApp1.sln b/test/scannerlib/huagao/c#/WindowsFormsApp1/WindowsFormsApp1.sln
new file mode 100644
index 00000000..d528cfab
--- /dev/null
+++ b/test/scannerlib/huagao/c#/WindowsFormsApp1/WindowsFormsApp1.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.32228.343
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsApp1", "WindowsFormsApp1.csproj", "{E364D770-BB5C-400A-902E-213A3DADCBD5}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E364D770-BB5C-400A-902E-213A3DADCBD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E364D770-BB5C-400A-902E-213A3DADCBD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E364D770-BB5C-400A-902E-213A3DADCBD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E364D770-BB5C-400A-902E-213A3DADCBD5}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {8B1D5CE6-959A-4477-B3BE-E7DEDDE78BB6}
+ EndGlobalSection
+EndGlobal
diff --git a/test/scannerlib/huagao/main.cpp b/test/scannerlib/huagao/main.cpp
new file mode 100644
index 00000000..b28bd391
--- /dev/null
+++ b/test/scannerlib/huagao/main.cpp
@@ -0,0 +1,176 @@
+#include
+#include
+#include
+#include
+#include "HGScannerLib.h"
+
+#define DELEAY_MS(x) std::this_thread::sleep_for(std::chrono::milliseconds((x)))
+using namespace std;
+
+//有图事件回调
+static void HGAPI DeviceScanImageFunc(HGLibDevice device, HGLibImage image, HGPointer param)
+{
+ static int indeximg = 0;
+ string savepath = std::to_string(++indeximg) + ".jpg";
+ cout << "save image : " << savepath << endl;
+ auto ret = HGLib_SaveImage(image, savepath.c_str(), 0);
+ cout << "save image : " << savepath << (ret ? " success" : " failed") << endl;
+}
+
+//设备热拔插事件回调
+static void HGAPI DeviceHotPlugEvent(HGUInt event, const HGChar *deviceName, HGPointer param)
+{
+ cout << "Devices : " << deviceName << " DeviceHotPlugEvent : " << (event == HGLIB_DEVHOTPLUG_EVENT_ARRIVE ? "HGLIB_DEVHOTPLUG_EVENT_ARRIVE " : "HGLIB_DEVHOTPLUG_EVENT_LEFT") << endl;
+}
+
+//扫描状态事件回调
+static void HGAPI DeviceScanEvent(HGLibDevice device, HGUInt event, HGBool err, const HGChar *info, HGPointer param)
+{
+ switch (event)
+ {
+ case HGLIB_DEVSCAN_EVENT_BEGIN:
+ cout << "DeviceScanEvent Start Scan" << endl;
+ break;
+ case HGLIB_DEVSCAN_EVENT_END:
+ cout << "DeviceScanEvent Scan stopped" << endl;
+ break;
+ case HGLIB_DEVSCAN_EVENT_INFO:
+ cout << "DeviceScanEvent info : " << info << endl;
+ break;
+ default:
+ cout << "Unkownun DeviceScanEvent " << event << endl;
+ break;
+ }
+}
+
+int main(unsigned char argc, unsigned char *argv[])
+{
+ std::cout << "*********Enter Scanner SDK Demo *********" << std::endl;
+ HGLib_InitDevice(DeviceHotPlugEvent, 0); //初始化调用模块
+ DELEAY_MS(5000);
+
+ HGChar **devNameList = HGLib_GetDeviceNameList(); //获取已连接的设备列表,已字符数组的形式返回
+ if (devNameList)
+ {
+ HGLibDevice dev = HGLib_OpenDevice(devNameList[0]); //此示例代码中调用设备列表中第一个设备
+ if (dev)
+ {
+
+ HGUInt grpCount = 0;
+ HGLibDeviceParamGroup *groups = HGLib_GetDeviceParamGroupList(dev, &grpCount);
+ if (groups)
+ {
+ //获取sdk支持的功能项及配置项内容
+ for (size_t i = 0; i < grpCount; i++)
+ {
+ cout << "group: " << groups[i].group << endl;
+ for (size_t j = 0; j < groups[i].paramCount; j++)
+ {
+ cout << " option: " << groups[i].param[j].option
+ << " type: " << groups[i].param[j].type << endl;
+ switch (groups[i].param[j].rangeType)
+ {
+ case HGLIB_OPTION_VALUERANGETYPE_INTLIST:
+ for (size_t k = 0; k < groups[i].param[j].intValueList.count; k++)
+ {
+ cout<<"support value["<
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows 窗体设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ this.button1 = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(301, 157);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(166, 65);
+ this.button1.TabIndex = 0;
+ this.button1.Text = "扫描";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.button1);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button button1;
+ }
+}
+
diff --git a/test/scannerlib/lanxum/c#/WindowsFormsApp1/Form1.cs b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Form1.cs
new file mode 100644
index 00000000..8b733879
--- /dev/null
+++ b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Form1.cs
@@ -0,0 +1,281 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using System.Runtime.InteropServices;
+using System.Globalization;
+using System.Timers;
+using System.Threading;
+
+namespace WindowsFormsApp1
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ UIntPtr image = HGScannerLib.HGLib_LoadImage(StringToUtf8("1.jpg"));
+ if (UIntPtr.Zero != image)
+ {
+ HGScannerLib.HGLibSaveImageParam saveParam;
+ saveParam.size = (UInt32)Marshal.SizeOf(typeof(HGScannerLib.HGLibSaveImageParam));
+ saveParam.jpegQuality = 80;
+ saveParam.tiffCompression = 4;
+ saveParam.tiffJpegQuality = 80;
+ saveParam.ocr = 0;
+ HGScannerLib.HGLib_SaveImage(image, StringToUtf8("2.jpg"), ref saveParam);
+ HGScannerLib.HGLib_ReleaseImage(image);
+ }
+
+ HGScannerLib.HGLibDeviceHotPlugEventFunc fun = new HGScannerLib.HGLibDeviceHotPlugEventFunc(DeviceHotPlugEventFunc);
+ HGScannerLib.HGLib_InitDevice(fun, this.Handle);
+ Thread.Sleep(500);
+
+ IntPtr deviceNameList = HGScannerLib.HGLib_GetDeviceNameList();
+ if (IntPtr.Zero != deviceNameList)
+ {
+ // 获取设备列表
+ int i = 0;
+ IntPtr deviceName = Marshal.ReadIntPtr(deviceNameList, 0);
+ while (IntPtr.Zero != deviceName)
+ {
+ String deviceNameText = Utf8ToString(deviceName);
+ ++i;
+ deviceName = Marshal.ReadIntPtr(deviceNameList, Marshal.SizeOf(typeof(IntPtr)) * i);
+ }
+
+ // 打开第一个设备
+ UIntPtr device = HGScannerLib.HGLib_OpenDevice(Marshal.ReadIntPtr(deviceNameList, 0));
+ if (UIntPtr.Zero != device)
+ {
+ // 获取序列号
+ Byte[] sn = new Byte[60];
+ IntPtr snAddr = Marshal.UnsafeAddrOfPinnedArrayElement(sn, 0);
+ HGScannerLib.HGLib_GetDeviceSN(device, snAddr, 60);
+ String snText = Utf8ToString(snAddr);
+
+ // 获取固件版本号
+ Byte[] fwVer = new Byte[60];
+ IntPtr fwVerAddr = Marshal.UnsafeAddrOfPinnedArrayElement(fwVer, 0);
+ HGScannerLib.HGLib_GetDeviceFWVersion(device, fwVerAddr, 60);
+ String fwVerText = Utf8ToString(fwVerAddr);
+
+ // 设置待纸扫描
+ Int32[] dzsm = new Int32[1];
+ dzsm[0] = 1;
+ Int32 ret1 = HGScannerLib.HGLib_SetDeviceParam(device, 67,
+ Marshal.UnsafeAddrOfPinnedArrayElement(dzsm, 0));
+
+ // 设置旋转90度
+ UInt32[] rotate = new UInt32[1];
+ rotate[0] = 67;
+ Int32 ret2 = HGScannerLib.HGLib_SetDeviceParam(device, 59,
+ Marshal.UnsafeAddrOfPinnedArrayElement(rotate, 0));
+
+ // 设置伽马值
+ Double[] gamma = new Double[1];
+ gamma[0] = 1.0;
+ Int32 ret3 = HGScannerLib.HGLib_SetDeviceParam(device, 35,
+ Marshal.UnsafeAddrOfPinnedArrayElement(gamma, 0));
+
+ // 获取旋转的配置
+ IntPtr rotateParam = HGScannerLib.HGLib_GetDeviceParam(device, 59);
+ if (IntPtr.Zero != rotateParam)
+ {
+ HGScannerLib.HGLibDeviceParam param = (HGScannerLib.HGLibDeviceParam)
+ Marshal.PtrToStructure(rotateParam, typeof(HGScannerLib.HGLibDeviceParam));
+
+ // print param
+ PrintParam(ref param);
+
+ HGScannerLib.HGLib_ReleaseDeviceParam(rotateParam);
+ }
+
+ // 获取所有配置
+ UInt32 groupCount = 0;
+ IntPtr groupParamList = HGScannerLib.HGLib_GetDeviceParamGroupList(device, ref groupCount);
+ if (IntPtr.Zero != groupParamList)
+ {
+ for (int groupIdx = 0; groupIdx < (int)groupCount; ++groupIdx)
+ {
+ HGScannerLib.HGLibDeviceParamGroup group = (HGScannerLib.HGLibDeviceParamGroup)
+ Marshal.PtrToStructure(groupParamList + Marshal.SizeOf(typeof(HGScannerLib.HGLibDeviceParamGroup)) * groupIdx,
+ typeof(HGScannerLib.HGLibDeviceParamGroup));
+
+ // 组名
+ UInt32 groupName = group.group;
+ // 组内配置的数量
+ UInt32 paramCount = group.paramCount;
+
+ for (int paramIdx = 0; paramIdx < group.paramCount; ++paramIdx)
+ {
+ HGScannerLib.HGLibDeviceParam param = (HGScannerLib.HGLibDeviceParam)
+ Marshal.PtrToStructure(group.param + Marshal.SizeOf(typeof(HGScannerLib.HGLibDeviceParam)) * paramIdx,
+ typeof(HGScannerLib.HGLibDeviceParam));
+
+ // print param
+ PrintParam(ref param);
+ }
+ }
+
+ HGScannerLib.HGLib_ReleaseDeviceParamGroupList(groupParamList, groupCount);
+ }
+
+ // 扫描
+ m_break = false;
+ HGScannerLib.HGLibDeviceScanEventFunc eventFunc = new HGScannerLib.HGLibDeviceScanEventFunc(DeviceScanEventFunc);
+ HGScannerLib.HGLibDeviceScanImageFunc imageFunc = new HGScannerLib.HGLibDeviceScanImageFunc(DeviceScanImageFunc);
+ Int32 scanRet = HGScannerLib.HGLib_StartDeviceScan(device, eventFunc, this.Handle, imageFunc, this.Handle);
+ if (0 != scanRet)
+ {
+ while (!m_break)
+ {
+ Thread.Sleep(100);
+ }
+
+ HGScannerLib.HGLib_StopDeviceScan(device);
+ }
+
+ HGScannerLib.HGLib_CloseDevice(device);
+ }
+
+ HGScannerLib.HGLib_ReleaseDeviceNameList(deviceNameList);
+ }
+
+ HGScannerLib.HGLib_DeinitDevice();
+ }
+
+ public void DeviceHotPlugEventFunc(UInt32 evt, IntPtr deviceName, IntPtr param)
+ {
+ String devNameText = Utf8ToString(deviceName);
+ }
+
+ public void DeviceScanEventFunc(UIntPtr device, UInt32 evt, Int32 err, IntPtr info, IntPtr param)
+ {
+ if (evt == 2)
+ {
+ m_break = true;
+ }
+ else if (3 == evt)
+ {
+ String infoText = Utf8ToString(info);
+ }
+ }
+
+ public void DeviceScanImageFunc(UIntPtr device, UIntPtr image, IntPtr param)
+ {
+ String fileName = String.Format("Scan_{0}.jpg", m_scanCount);
+ ++m_scanCount;
+
+ HGScannerLib.HGLibSaveImageParam saveParam;
+ saveParam.size = (UInt32)Marshal.SizeOf(typeof(HGScannerLib.HGLibSaveImageParam));
+ saveParam.jpegQuality = 80;
+ saveParam.tiffCompression = 4;
+ saveParam.tiffJpegQuality = 80;
+ saveParam.ocr = 0;
+ HGScannerLib.HGLib_SaveImage(image, StringToUtf8(fileName), ref saveParam);
+ }
+
+ public String Utf8ToString(IntPtr str)
+ {
+ if (IntPtr.Zero == str)
+ {
+ return "";
+ }
+
+ int len = 0;
+ while (0 != Marshal.ReadByte(str, len))
+ {
+ ++len;
+ }
+
+ if (0 == len)
+ {
+ return "";
+ }
+
+ Byte[] utf8 = new Byte[len];
+ Marshal.Copy(str, utf8, 0, len);
+ return Encoding.UTF8.GetString(utf8);
+ }
+
+ public IntPtr StringToUtf8(String str)
+ {
+ if (str.Length == 0)
+ {
+ return IntPtr.Zero;
+ }
+
+ Byte[] src = Encoding.UTF8.GetBytes(str);
+ Byte[] dst = new Byte[src.Length + 1];
+ for (int i = 0; i < src.Length; ++i)
+ dst[i] = src[i];
+ dst[dst.Length - 1] = 0;
+ return Marshal.UnsafeAddrOfPinnedArrayElement(dst, 0);
+ }
+
+ public void PrintParam(ref HGScannerLib.HGLibDeviceParam param)
+ {
+ // 配置名
+ UInt32 option = param.option;
+
+ if (1 == param.type) // 整型
+ {
+ Int32 value = param.typeValue.intValue;
+ }
+ else if (2 == param.type) // 枚举
+ {
+ UInt32 value = param.typeValue.enumValue;
+ }
+ else if (3 == param.type) // 双精度浮点
+ {
+ Double value = param.typeValue.doubleValue;
+ }
+ else if (4 == param.type) // BOOL
+ {
+ Int32 value = param.typeValue.boolValue;
+ }
+
+ if (param.rangeType == 1) // 整型列表
+ {
+ Int32[] intValueList = new Int32[param.rangeTypeValue.intValueList.count];
+ Marshal.Copy(param.rangeTypeValue.intValueList.value, intValueList, 0, (int)param.rangeTypeValue.intValueList.count);
+ }
+ else if (param.rangeType == 2) // 枚举列表
+ {
+ Int32[] enumValueList = new Int32[param.rangeTypeValue.enumValueList.count];
+ Marshal.Copy(param.rangeTypeValue.enumValueList.value, enumValueList, 0, (int)param.rangeTypeValue.enumValueList.count);
+ }
+ else if (param.rangeType == 3) // 双精度浮点列表
+ {
+ Double[] doubleValueList = new Double[param.rangeTypeValue.doubleValueList.count];
+ Marshal.Copy(param.rangeTypeValue.doubleValueList.value, doubleValueList, 0, (int)param.rangeTypeValue.doubleValueList.count);
+ }
+ else if (param.rangeType == 4) // 整型范围
+ {
+ // 最小值
+ Int32 minVal = param.rangeTypeValue.intValueRange.minValue;
+ // 最大值
+ Int32 maxVal = param.rangeTypeValue.intValueRange.maxValue;
+ }
+ else if (param.rangeType == 5) // 双精度浮点范围
+ {
+ // 最小值
+ Double minVal = param.rangeTypeValue.doubleValueRange.minValue;
+ // 最大值
+ Double maxVal = param.rangeTypeValue.doubleValueRange.maxValue;
+ }
+ }
+
+ public UInt32 m_scanCount = 1;
+ public Boolean m_break = false;
+ }
+}
diff --git a/test/scannerlib/lanxum/c#/WindowsFormsApp1/Form1.resx b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Form1.resx
new file mode 100644
index 00000000..1af7de15
--- /dev/null
+++ b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/test/scannerlib/lanxum/c#/WindowsFormsApp1/HGScannerLib.cs b/test/scannerlib/lanxum/c#/WindowsFormsApp1/HGScannerLib.cs
new file mode 100644
index 00000000..dbe9ba4b
--- /dev/null
+++ b/test/scannerlib/lanxum/c#/WindowsFormsApp1/HGScannerLib.cs
@@ -0,0 +1,158 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace WindowsFormsApp1
+{
+ public class HGScannerLib
+ {
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibSaveImageParam
+ {
+ public UInt32 size;
+ public UInt32 jpegQuality;
+ public UInt32 tiffCompression;
+ public UInt32 tiffJpegQuality;
+ public Int32 ocr;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceIntValueList
+ {
+ public IntPtr value; // Int32指针
+ public UInt32 count;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceEnumValueList
+ {
+ public IntPtr value; // UInt32指针
+ public UInt32 count;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceDoubleValueList
+ {
+ public IntPtr value; // Double指针
+ public UInt32 count;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceIntValueRange
+ {
+ public Int32 minValue;
+ public Int32 maxValue;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceDoubleValueRange
+ {
+ public Double minValue;
+ public Double maxValue;
+ }
+
+ [StructLayout(LayoutKind.Explicit, Pack = 4)]
+ public struct HGLibDeviceParamType
+ {
+ [FieldOffset(0)] public Int32 intValue;
+ [FieldOffset(0)] public UInt32 enumValue;
+ [FieldOffset(0)] public Double doubleValue;
+ [FieldOffset(0)] public Int32 boolValue;
+ }
+
+ [StructLayout(LayoutKind.Explicit, Pack = 4)]
+ public struct HGLibDeviceParamRangeType
+ {
+ [FieldOffset(0)] public HGLibDeviceIntValueList intValueList;
+ [FieldOffset(0)] public HGLibDeviceEnumValueList enumValueList;
+ [FieldOffset(0)] public HGLibDeviceDoubleValueList doubleValueList;
+ [FieldOffset(0)] public HGLibDeviceIntValueRange intValueRange;
+ [FieldOffset(0)] public HGLibDeviceDoubleValueRange doubleValueRange;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceParam
+ {
+ public UInt32 option;
+ public UInt32 type;
+ public HGLibDeviceParamType typeValue;
+ public UInt32 rangeType;
+ public HGLibDeviceParamRangeType rangeTypeValue;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct HGLibDeviceParamGroup
+ {
+ public UInt32 group;
+ public IntPtr param; // HGLibDeviceParam指针
+ public UInt32 paramCount;
+ }
+
+ public delegate void HGLibDeviceHotPlugEventFunc(UInt32 evt, IntPtr deviceName, IntPtr param);
+ public delegate void HGLibDeviceScanEventFunc(UIntPtr device, UInt32 evt, Int32 err, IntPtr info, IntPtr param);
+ public delegate void HGLibDeviceScanImageFunc(UIntPtr device, UIntPtr image, IntPtr param);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_LoadImage")]
+ public static extern UIntPtr HGLib_LoadImage(IntPtr filePath);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_SaveImage")]
+ public static extern Int32 HGLib_SaveImage(UIntPtr image, IntPtr filePath, ref HGLibSaveImageParam saveParam);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_ReleaseImage")]
+ public static extern Int32 HGLib_ReleaseImage(UIntPtr image);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_InitDevice")]
+ public static extern Int32 HGLib_InitDevice(HGLibDeviceHotPlugEventFunc func, IntPtr param);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_DeinitDevice")]
+ public static extern Int32 HGLib_DeinitDevice();
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_GetDeviceNameList")]
+ public static extern IntPtr HGLib_GetDeviceNameList();
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_ReleaseDeviceNameList")]
+ public static extern Int32 HGLib_ReleaseDeviceNameList(IntPtr deviceNameList);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_OpenDevice")]
+ public static extern UIntPtr HGLib_OpenDevice(IntPtr deviceName);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_CloseDevice")]
+ public static extern Int32 HGLib_CloseDevice(UIntPtr device);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_GetDeviceSN")]
+ public static extern Int32 HGLib_GetDeviceSN(UIntPtr device, IntPtr sn, UInt32 maxLen);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_GetDeviceFWVersion")]
+ public static extern Int32 HGLib_GetDeviceFWVersion(UIntPtr device, IntPtr fwVersion, UInt32 maxLen);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_SetDeviceParam")]
+ public static extern Int32 HGLib_SetDeviceParam(UIntPtr device, UInt32 option, IntPtr data);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_GetDeviceParamGroupList")]
+ public static extern IntPtr HGLib_GetDeviceParamGroupList(UIntPtr device, ref UInt32 count);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_GetDeviceParam")]
+ public static extern IntPtr HGLib_GetDeviceParam(UIntPtr device, UInt32 option);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_ReleaseDeviceParamGroupList")]
+ public static extern Int32 HGLib_ReleaseDeviceParamGroupList(IntPtr devParamGroup, UInt32 count);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_ReleaseDeviceParam")]
+ public static extern Int32 HGLib_ReleaseDeviceParam(IntPtr devParam);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_ResetDeviceParam")]
+ public static extern Int32 HGLib_ResetDeviceParam(UIntPtr device);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_DeviceIsPaperOn")]
+ public static extern Int32 HGLib_DeviceIsPaperOn(UIntPtr device);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_StartDeviceScan")]
+ public static extern Int32 HGLib_StartDeviceScan(UIntPtr device, HGLibDeviceScanEventFunc eventFunc, IntPtr eventParam,
+ HGLibDeviceScanImageFunc imageFunc, IntPtr imageParam);
+
+ [DllImport("LSCScannerLib.dll", EntryPoint = "HGLib_StopDeviceScan")]
+ public static extern Int32 HGLib_StopDeviceScan(UIntPtr device);
+ }
+}
diff --git a/test/scannerlib/lanxum/c#/WindowsFormsApp1/Program.cs b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Program.cs
new file mode 100644
index 00000000..1561dc46
--- /dev/null
+++ b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Program.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+
+namespace WindowsFormsApp1
+{
+ static class Program
+ {
+ ///
+ /// 应用程序的主入口点。
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/AssemblyInfo.cs b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..187bd623
--- /dev/null
+++ b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("WindowsFormsApp1")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WindowsFormsApp1")]
+[assembly: AssemblyCopyright("Copyright © 2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("e364d770-bb5c-400a-902e-213a3dadcbd5")]
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/Resources.Designer.cs b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..7a2f3472
--- /dev/null
+++ b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本: 4.0.30319.42000
+//
+// 对此文件的更改可能导致不正确的行为,如果
+// 重新生成代码,则所做更改将丢失。
+//
+//------------------------------------------------------------------------------
+
+
+namespace WindowsFormsApp1.Properties
+{
+ ///
+ /// 强类型资源类,用于查找本地化字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// 返回此类使用的缓存 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsFormsApp1.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 重写当前线程的 CurrentUICulture 属性,对
+ /// 使用此强类型资源类的所有资源查找执行重写。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/Resources.resx b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/Resources.resx
new file mode 100644
index 00000000..af7dbebb
--- /dev/null
+++ b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/Settings.Designer.cs b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..3cdaf800
--- /dev/null
+++ b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/Settings.Designer.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace WindowsFormsApp1.Properties
+{
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/Settings.settings b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/Settings.settings
new file mode 100644
index 00000000..39645652
--- /dev/null
+++ b/test/scannerlib/lanxum/c#/WindowsFormsApp1/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/test/scannerlib/lanxum/c#/WindowsFormsApp1/WindowsFormsApp1.csproj b/test/scannerlib/lanxum/c#/WindowsFormsApp1/WindowsFormsApp1.csproj
new file mode 100644
index 00000000..67d99ae5
--- /dev/null
+++ b/test/scannerlib/lanxum/c#/WindowsFormsApp1/WindowsFormsApp1.csproj
@@ -0,0 +1,81 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {E364D770-BB5C-400A-902E-213A3DADCBD5}
+ WinExe
+ WindowsFormsApp1
+ WindowsFormsApp1
+ v4.0
+ 512
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ true
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
\ No newline at end of file
diff --git a/test/scannerlib/lanxum/c#/WindowsFormsApp1/WindowsFormsApp1.sln b/test/scannerlib/lanxum/c#/WindowsFormsApp1/WindowsFormsApp1.sln
new file mode 100644
index 00000000..d528cfab
--- /dev/null
+++ b/test/scannerlib/lanxum/c#/WindowsFormsApp1/WindowsFormsApp1.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.32228.343
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsApp1", "WindowsFormsApp1.csproj", "{E364D770-BB5C-400A-902E-213A3DADCBD5}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E364D770-BB5C-400A-902E-213A3DADCBD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E364D770-BB5C-400A-902E-213A3DADCBD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E364D770-BB5C-400A-902E-213A3DADCBD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E364D770-BB5C-400A-902E-213A3DADCBD5}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {8B1D5CE6-959A-4477-B3BE-E7DEDDE78BB6}
+ EndGlobalSection
+EndGlobal
diff --git a/test/scannerlib/lanxum/main.cpp b/test/scannerlib/lanxum/main.cpp
new file mode 100644
index 00000000..b28bd391
--- /dev/null
+++ b/test/scannerlib/lanxum/main.cpp
@@ -0,0 +1,176 @@
+#include
+#include
+#include
+#include
+#include "HGScannerLib.h"
+
+#define DELEAY_MS(x) std::this_thread::sleep_for(std::chrono::milliseconds((x)))
+using namespace std;
+
+//有图事件回调
+static void HGAPI DeviceScanImageFunc(HGLibDevice device, HGLibImage image, HGPointer param)
+{
+ static int indeximg = 0;
+ string savepath = std::to_string(++indeximg) + ".jpg";
+ cout << "save image : " << savepath << endl;
+ auto ret = HGLib_SaveImage(image, savepath.c_str(), 0);
+ cout << "save image : " << savepath << (ret ? " success" : " failed") << endl;
+}
+
+//设备热拔插事件回调
+static void HGAPI DeviceHotPlugEvent(HGUInt event, const HGChar *deviceName, HGPointer param)
+{
+ cout << "Devices : " << deviceName << " DeviceHotPlugEvent : " << (event == HGLIB_DEVHOTPLUG_EVENT_ARRIVE ? "HGLIB_DEVHOTPLUG_EVENT_ARRIVE " : "HGLIB_DEVHOTPLUG_EVENT_LEFT") << endl;
+}
+
+//扫描状态事件回调
+static void HGAPI DeviceScanEvent(HGLibDevice device, HGUInt event, HGBool err, const HGChar *info, HGPointer param)
+{
+ switch (event)
+ {
+ case HGLIB_DEVSCAN_EVENT_BEGIN:
+ cout << "DeviceScanEvent Start Scan" << endl;
+ break;
+ case HGLIB_DEVSCAN_EVENT_END:
+ cout << "DeviceScanEvent Scan stopped" << endl;
+ break;
+ case HGLIB_DEVSCAN_EVENT_INFO:
+ cout << "DeviceScanEvent info : " << info << endl;
+ break;
+ default:
+ cout << "Unkownun DeviceScanEvent " << event << endl;
+ break;
+ }
+}
+
+int main(unsigned char argc, unsigned char *argv[])
+{
+ std::cout << "*********Enter Scanner SDK Demo *********" << std::endl;
+ HGLib_InitDevice(DeviceHotPlugEvent, 0); //初始化调用模块
+ DELEAY_MS(5000);
+
+ HGChar **devNameList = HGLib_GetDeviceNameList(); //获取已连接的设备列表,已字符数组的形式返回
+ if (devNameList)
+ {
+ HGLibDevice dev = HGLib_OpenDevice(devNameList[0]); //此示例代码中调用设备列表中第一个设备
+ if (dev)
+ {
+
+ HGUInt grpCount = 0;
+ HGLibDeviceParamGroup *groups = HGLib_GetDeviceParamGroupList(dev, &grpCount);
+ if (groups)
+ {
+ //获取sdk支持的功能项及配置项内容
+ for (size_t i = 0; i < grpCount; i++)
+ {
+ cout << "group: " << groups[i].group << endl;
+ for (size_t j = 0; j < groups[i].paramCount; j++)
+ {
+ cout << " option: " << groups[i].param[j].option
+ << " type: " << groups[i].param[j].type << endl;
+ switch (groups[i].param[j].rangeType)
+ {
+ case HGLIB_OPTION_VALUERANGETYPE_INTLIST:
+ for (size_t k = 0; k < groups[i].param[j].intValueList.count; k++)
+ {
+ cout<<"support value["< 不进行多流输出类型
+Ret = HGLib_SetDeviceParam(Device, 1, byref(DevParam)) #见HGLib_SetDeviceParam 头文件接口说明 1 -> HGLIB_OPTION_NAME_DLSC 多流输出
+
+
+#扫描事件回调
+def HGLibDeviceScanEventFunc(device: c_void_p, event: c_uint, err: c_int, info: c_char_p, param: c_void_p):
+ s_info=info
+ global bStop
+ print("event code",event," event info:",s_info)
+ if event == 2:#HGLIB_DEVSCAN_EVENT_END 扫描停止
+ bStop=True
+ print("bStop true")
+ elif event == 1:
+ bStop=False
+ print("bStop false")
+ return
+imgindex=0
+#扫描图像事件回调
+def HGLibDeviceScanImageFunc(device: c_void_p, image: c_void_p, param: c_void_p):
+ global imgindex
+ ImageParam = HGLibSaveImageParam()
+ ImageParam.size = sizeof(ImageParam)
+ ImageParam.jpegQuality = 80
+ ImageParam.tiffCompression = 4
+ ImageParam.tiffJpegQuality = 80
+ ImageParam.ocr = 0
+ print("image call back!!")
+ imgindex+=1
+ t_index=imgindex
+ imgname=str(t_index) + '_scanned.jpg'
+ print(imgname)
+ b_imagename=imgname.encode('utf-8')
+ pchar=c_char_p(b_imagename)
+ Ret = HGLib_SaveImage(image, pchar, pointer(ImageParam))
+ return
+
+#注册扫描相关事件并启动扫描
+FuncType1 = CFUNCTYPE(None, c_void_p, c_uint, c_int, c_char_p, c_void_p)
+cb1 = FuncType1(HGLibDeviceScanEventFunc)
+FuncType2 = CFUNCTYPE(None, c_void_p, c_void_p, c_void_p)
+cb2 = FuncType2(HGLibDeviceScanImageFunc)
+HGLib_StartDeviceScan = Objdll.HGLib_StartDeviceScan
+HGLib_StartDeviceScan.argtypes = [c_void_p, FuncType1, c_void_p, FuncType2, c_void_p]
+HGLib_StartDeviceScan.restyped = ctypes.c_int
+print("start scan")
+Ret = HGLib_StartDeviceScan(Device, cb1, 0, cb2, 0)
+
+#模拟扫描持续应等待扫描事件回调返回扫描停止才结束本次扫描流程
+while(not bStop):
+ time.sleep(1)
+ print("scanning...")
+
+
+print("scan done!!!")
+
+#关闭当前打开的设备
+HGLib_CloseDevice=Objdll.HGLib_CloseDevice
+HGLib_CloseDevice.argtypes = [c_void_p]
+HGLib_CloseDevice.restype = ctypes.c_int
+HGLib_CloseDevice(Device)
+print("Close Devices")
+
+#释放设备列表资源
+HGLib_ReleaseDeviceNameList=Objdll.HGLib_ReleaseDeviceNameList
+HGLib_ReleaseDeviceNameList.argtypes=[POINTER(ctypes.c_char_p)]
+HGLib_ReleaseDeviceNameList.restype = ctypes.c_int
+HGLib_ReleaseDeviceNameList(DeviceNameList)
+print("ReleaseDeviceNameList done")
+
+print("exit test")
+
+