增加HGScannerLib工程

This commit is contained in:
luoliangyi 2022-07-19 11:51:00 +08:00
parent b9cbf820d3
commit 51590dfd88
7 changed files with 717 additions and 0 deletions

View File

@ -0,0 +1,19 @@
LIBRARY
EXPORTS
HGLib_LoadImage
HGLib_SaveImage
HGLib_ReleaseImage
HGLib_InitDevice
HGLib_DeinitDevice
HGLib_GetDeviceNameList
HGLib_ReleaseDeviceNameList
HGLib_OpenDevice
HGLib_CloseDevice
HGLib_SetDeviceParam
HGLib_GetDeviceParamGroupList
HGLib_ReleaseDeviceParamGroupList
HGLib_ResetDeviceParam
HGLib_StartDeviceScan
HGLib_StopDeviceScan

View File

@ -0,0 +1,179 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\sdk\scannerlib\HGLibDeviceImpl.cpp" />
<ClCompile Include="..\..\..\sdk\scannerlib\HGScannerLib.cpp" />
<ClCompile Include="..\..\..\utility\HGString.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\sdk\scannerlib\HGLibDeviceImpl.hpp" />
<ClInclude Include="..\..\..\sdk\scannerlib\HGScannerLib.h" />
<ClInclude Include="..\..\..\utility\HGString.h" />
</ItemGroup>
<ItemGroup>
<None Include="HGScannerLib.def" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{62cad8e9-4461-49a1-8eb8-4cebe113fe02}</ProjectGuid>
<RootNamespace>HGScannerLib</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;HGSCANNERLIB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>../../../modules/base/;../../../modules/;../../../utility/;../../../../sdk/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>HGScannerLib.def</ModuleDefinitionFile>
<AdditionalDependencies>../Debug/HGBase.lib;../Debug/HGImgFmt.lib;../Debug/HGImgProc.lib;../../../../sdk/lib/win/x86/Release/sane.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;HGSCANNERLIB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>HGScannerLib.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;HGSCANNERLIB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>HGScannerLib.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;HGSCANNERLIB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>HGScannerLib.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -50,6 +50,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HGVersion", "HGVersion\HGVe
{F85F4457-1B42-46E7-BA86-F088D6D5994F} = {F85F4457-1B42-46E7-BA86-F088D6D5994F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HGScannerLib", "HGScannerLib\HGScannerLib.vcxproj", "{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}"
ProjectSection(ProjectDependencies) = postProject
{F85F4457-1B42-46E7-BA86-F088D6D5994F} = {F85F4457-1B42-46E7-BA86-F088D6D5994F}
{5D85F2AC-FACD-436C-A67B-E13056DD0C03} = {5D85F2AC-FACD-436C-A67B-E13056DD0C03}
{4909ACEA-80FF-482E-9FA2-5E8534789A82} = {4909ACEA-80FF-482E-9FA2-5E8534789A82}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@ -130,6 +137,14 @@ Global
{25D00B63-9385-4283-8955-92CAAEDBE68A}.Release|x64.Build.0 = Release|x64
{25D00B63-9385-4283-8955-92CAAEDBE68A}.Release|x86.ActiveCfg = Release|Win32
{25D00B63-9385-4283-8955-92CAAEDBE68A}.Release|x86.Build.0 = Release|Win32
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Debug|x64.ActiveCfg = Debug|x64
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Debug|x64.Build.0 = Debug|x64
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Debug|x86.ActiveCfg = Debug|Win32
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Debug|x86.Build.0 = Debug|Win32
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Release|x64.ActiveCfg = Release|x64
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Release|x64.Build.0 = Release|x64
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Release|x86.ActiveCfg = Release|Win32
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,127 @@
#include "HGLibDeviceImpl.hpp"
#include "base/HGInc.h"
#include "base/HGInfo.h"
#include "HGString.h"
HGLock HGLibDeviceImpl::m_lock = NULL;
HGLibDeviceHotPlugEventFunc HGLibDeviceImpl::m_hotPlugEventFunc = NULL;
HGPointer HGLibDeviceImpl::m_hotPlugEventParam = NULL;
HGBool HGLibDeviceImpl::m_init = HGFALSE;
std::vector<std::string> HGLibDeviceImpl::m_devNameList;
HGLibDeviceImpl::HGLibDeviceImpl()
{
}
HGLibDeviceImpl::~HGLibDeviceImpl()
{
}
HGBool HGLibDeviceImpl::Init(HGLibDeviceHotPlugEventFunc func, HGPointer param)
{
if (m_init)
{
return HGFALSE;
}
assert(NULL == m_lock);
HGBase_CreateLock(&m_lock);
assert(NULL == m_hotPlugEventFunc);
m_hotPlugEventFunc = func;
m_hotPlugEventParam = param;
SANE_Int version_code = 0;
if (SANE_STATUS_GOOD != sane_init_ex(&version_code, sane_ex_callback, NULL))
{
m_hotPlugEventFunc = NULL;
m_hotPlugEventParam = NULL;
HGBase_DestroyLock(m_lock);
m_lock = NULL;
return HGFALSE;
}
m_init = HGTRUE;
return HGTRUE;
}
HGBool HGLibDeviceImpl::Deinit()
{
if (!m_init)
{
return HGFALSE;
}
sane_exit();
m_hotPlugEventFunc = NULL;
m_hotPlugEventParam = NULL;
HGBase_DestroyLock(m_lock);
m_lock = NULL;
m_init = HGFALSE;
return HGTRUE;
}
HGChar** HGLibDeviceImpl::GetNameList()
{
return NULL;
}
HGBool HGLibDeviceImpl::ReleaseNameList(HGChar** deviceName)
{
if (NULL == deviceName)
{
return HGFALSE;
}
while (0 != *deviceName)
{
free(*deviceName);
++deviceName;
}
free(deviceName);
return HGTRUE;
}
int HGLibDeviceImpl::sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param)
{
switch (code)
{
case SANE_EVENT_DEVICE_ARRIVED:
{
SANE_Device* sane_dev = (SANE_Device*)data;
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "SANE_EVENT_DEVICE_ARRIVED, name=%s", Utf8ToStdString(sane_dev->name).c_str());
HGBase_EnterLock(m_lock);
m_devNameList.push_back(sane_dev->name);
HGBase_LeaveLock(m_lock);
if (NULL != m_hotPlugEventFunc)
m_hotPlugEventFunc(HGLIB_DEVHOTPLUG_EVENT_ARRIVE, sane_dev->name, m_hotPlugEventParam);
}
break;
case SANE_EVENT_DEVICE_LEFT:
{
SANE_Device* sane_dev = (SANE_Device*)data;
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "SANE_EVENT_DEVICE_LEFT, name=%s", Utf8ToStdString(sane_dev->name).c_str());
if (NULL != m_hotPlugEventFunc)
m_hotPlugEventFunc(HGLIB_DEVHOTPLUG_EVENT_REMOVE, sane_dev->name, m_hotPlugEventParam);
HGBase_EnterLock(m_lock);
for (int i = 0; i < (int)m_devNameList.size(); ++i)
{
if (0 == strcmp(sane_dev->name, m_devNameList[i].c_str()))
{
m_devNameList.erase(m_devNameList.begin() + i);
break;
}
}
HGBase_LeaveLock(m_lock);
}
break;
}
return 0;
}

View File

@ -0,0 +1,43 @@
#ifndef __HGLIBDEVICEIMPL_HPP__
#define __HGLIBDEVICEIMPL_HPP__
#include "HGScannerLib.h"
#include "base/HGLock.h"
#include "sane/sane_ex.h"
#include "sane/sane_option_definitions.h"
#include <vector>
#include <string>
class HGLibDeviceImpl
{
public:
HGLibDeviceImpl();
~HGLibDeviceImpl();
static HGBool Init(HGLibDeviceHotPlugEventFunc func, HGPointer param);
static HGBool Deinit();
static HGChar** GetNameList();
static HGBool ReleaseNameList(HGChar** deviceName);
HGBool Open(const HGChar* deviceName);
HGBool Close();
HGBool SetParam(const HGLibDeviceSetParam* param, HGUInt count);
HGLibDeviceGetParamGroup* GetParamGroupList(HGUInt* count);
static HGBool ReleaseParamGroupList(HGLibDeviceGetParamGroup* paramGroup, HGUInt count);
HGBool ResetParam();
HGBool StartScan(HGLibDeviceScanEventFunc eventFunc, HGPointer eventParam,
HGLibDeviceScanImageFunc imageFunc, HGPointer imageParam);
HGBool StopScan();
private:
static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param);
private:
static HGLock m_lock;
static HGLibDeviceHotPlugEventFunc m_hotPlugEventFunc;
static HGPointer m_hotPlugEventParam;
static HGBool m_init;
static std::vector<std::string> m_devNameList;
};
#endif /* __HGLIBDEVICEIMPL_HPP__ */

View File

@ -0,0 +1,155 @@
#include "HGScannerLib.h"
#include "base/HGInc.h"
#include "base/HGImage.h"
#include "imgfmt/HGImgFmt.h"
#include "imgproc/HGOcr.h"
#include "HGString.h"
#include "HGLibDeviceImpl.hpp"
typedef struct
{
HGUInt size; /* 结构体大小 */
HGUInt jpegQuality; /* jpeg下有效, 0-100 */
HGUInt tiffCompression; /* tiff下有效, HGLIB_TIFFCOMPRESSION_* */
HGUInt tiffJpegQuality; /* tiff且HGLIB_TIFFCOMPRESSION_JPEG下有效, 0-100 */
HGBool ocr; /* 是否OCRpdf和ofd格式有效 */
}HGLibSaveImageParam_V1;
HGLibImage HGAPI HGLib_LoadImage(const HGChar* filePath)
{
if (NULL == filePath)
{
return NULL;
}
HGImage image = NULL;
HGImgFmt_LoadImage(Utf8ToStdString(filePath).c_str(), 0, NULL, 0, HGBASE_IMGORIGIN_TOP, &image);
return (HGLibImage)image;
}
HGBool HGAPI HGLib_SaveImage(HGLibImage image, const HGChar* savePath, const HGLibSaveImageParam* saveParam)
{
if (NULL == image || NULL == savePath)
{
return HGFALSE;
}
HGUInt fmtType = 0;
HGImgFmt_GetImgFmtTypeFromFileName(Utf8ToStdString(savePath).c_str(), &fmtType);
if (fmtType < HGIMGFMT_TYPE_JPEG || fmtType > HGIMGFMT_TYPE_GIF)
{
return HGFALSE;
}
if (NULL == saveParam)
{
return (HGBASE_ERR_OK == HGImgFmt_SaveImage((HGImage)image, fmtType, NULL, Utf8ToStdString(savePath).c_str()));
}
if (saveParam->size == sizeof(HGLibSaveImageParam_V1))
{
const HGLibSaveImageParam_V1* saveParamV1 = (const HGLibSaveImageParam_V1*)saveParam;
if ((HGIMGFMT_TYPE_PDF == fmtType || HGIMGFMT_TYPE_OFD == fmtType) && saveParamV1->ocr)
{
HGOCRMgr ocrMgr = NULL;
HGImgProc_CreateOCRMgr(&ocrMgr);
if (NULL == ocrMgr)
{
return HGFALSE;
}
HGBool ret = (HGBASE_ERR_OK == HGImgProc_ImageOCRToFile(ocrMgr, (HGImage)image, 0, Utf8ToStdString(savePath).c_str()));
HGImgProc_DestroyOCRMgr(ocrMgr);
return ret;
}
HGImgFmtSaveInfo saveInfo;
saveInfo.jpegQuality = saveParamV1->jpegQuality;
saveInfo.tiffCompression = 0;
if (HGLIB_TIFFCOMPRESSION_NONE == saveParamV1->tiffCompression)
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_NONE;
else if (HGLIB_TIFFCOMPRESSION_CCITTFAX4 == saveParamV1->tiffCompression)
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_CCITTFAX4;
else if (HGLIB_TIFFCOMPRESSION_LZW == saveParamV1->tiffCompression)
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
else if (HGLIB_TIFFCOMPRESSION_JPEG == saveParamV1->tiffCompression)
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
saveInfo.tiffJpegQuality = saveParamV1->tiffJpegQuality;
return (HGBASE_ERR_OK == HGImgFmt_SaveImage((HGImage)image, fmtType, &saveInfo, Utf8ToStdString(savePath).c_str()));
}
return HGFALSE;
}
HGBool HGAPI HGLib_ReleaseImage(HGLibImage image)
{
if (NULL == image)
{
return HGFALSE;
}
HGBase_DestroyImage((HGImage)image);
return HGTRUE;
}
HGBool HGAPI HGLib_InitDevice(HGLibDeviceHotPlugEventFunc func, HGPointer param)
{
return HGLibDeviceImpl::Init(func, param);
}
HGBool HGAPI HGLib_DeinitDevice()
{
return HGLibDeviceImpl::Deinit();
}
HGChar** HGAPI HGLib_GetDeviceNameList()
{
return HGLibDeviceImpl::GetNameList();
}
HGBool HGAPI HGLib_ReleaseDeviceNameList(HGChar** deviceName)
{
return HGLibDeviceImpl::ReleaseNameList(deviceName);
}
HGLibDevice HGAPI HGLib_OpenDevice(const HGChar* deviceName)
{
return NULL;
}
HGBool HGAPI HGLib_CloseDevice(HGLibDevice device)
{
return HGFALSE;
}
HGBool HGAPI HGLib_SetDeviceParam(HGLibDevice device, const HGLibDeviceSetParam* param, HGUInt count)
{
return HGFALSE;
}
HGLibDeviceGetParamGroup* HGAPI HGLib_GetDeviceParamGroupList(HGLibDevice device, HGUInt* count)
{
return NULL;
}
HGBool HGAPI HGLib_ReleaseDeviceParamGroupList(HGLibDeviceGetParamGroup* paramGroup, HGUInt count)
{
return HGFALSE;
}
HGBool HGAPI HGLib_ResetDeviceParam(HGLibDevice device)
{
return HGFALSE;
}
HGBool HGAPI HGLib_StartDeviceScan(HGLibDevice device, HGLibDeviceScanEventFunc eventFunc, HGPointer eventParam,
HGLibDeviceScanImageFunc imageFunc, HGPointer imageParam)
{
return HGFALSE;
}
HGBool HGAPI HGLib_StopDeviceScan(HGLibDevice device)
{
return HGFALSE;
}

View File

@ -0,0 +1,179 @@
#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(HGUInt *count);
/* 销毁扫描仪名称列表 */
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__ */