feat(scanner): 初始化扫描仪SDK基础类型和常量定义
- 添加.gitignore文件,排除编译输出和IDE配置文件 - 定义HGDef.h头文件,包含平台相关类型和宏定义 - 创建HGDef.java接口,映射C语言类型到Java JNA类型 - 添加HGScannerConstants.java,定义扫描仪相关常量 - 创建HGScannerLib.h头文件,声明扫描仪库接口和常量
This commit is contained in:
47
.gitignore
vendored
Normal file
47
.gitignore
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
.kotlin
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
|
||||
.claude
|
||||
|
||||
.idea
|
||||
|
||||
settings.xml.example
|
||||
|
||||
DEPLOY.md
|
||||
306
pom.xml
Normal file
306
pom.xml
Normal file
@ -0,0 +1,306 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<!-- 基本信息 -->
|
||||
<groupId>vip.jcfd</groupId>
|
||||
<artifactId>HuaGoScanner-SDK</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<!-- 项目信息 -->
|
||||
<name>HuaGoScanner-SDK</name>
|
||||
<description>HuaGo Scanner SDK for Java</description>
|
||||
<url>https://github.com/yourusername/HuaGoScanner-SDK</url>
|
||||
|
||||
<!-- 开发者信息 -->
|
||||
<developers>
|
||||
<developer>
|
||||
<id>developer-id</id>
|
||||
<name>zkh</name>
|
||||
<email>1650697374@qq.com</email>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
<role>maintainer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<!-- 许可证信息 -->
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
<comments>A business-friendly OSS license</comments>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<!-- SCM信息 -->
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/yourusername/HuaGoScanner-SDK.git</connection>
|
||||
<developerConnection>scm:git:ssh://github.com:yourusername/HuaGoScanner-SDK.git</developerConnection>
|
||||
<url>https://github.com/yourusername/HuaGoScanner-SDK/tree/main</url>
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>5.17.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna-platform</artifactId>
|
||||
<version>5.17.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Maven Assembly Plugin - 用于创建包含所有依赖的jar包 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<!-- 在这里可以设置mainClass,如果您的项目有主类的话 -->
|
||||
<!-- <mainClass>com.yourcompany.MainClass</mainClass> -->
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Maven Compiler Plugin - 确保使用正确的Java版本编译 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Maven Source Plugin - 生成源码jar -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Maven Javadoc Plugin - 生成javadoc jar -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<configuration>
|
||||
<doclint>none</doclint> <!-- 避免javadoc严格检查导致的警告 -->
|
||||
<source>11</source>
|
||||
<encoding>UTF-8</encoding>
|
||||
<charset>UTF-8</charset>
|
||||
<docencoding>UTF-8</docencoding>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Maven GPG Plugin - 用于签名构件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<!-- 使用环境变量中的gpg密钥密码 -->
|
||||
<passphrase>${env.GPG_PASSPHRASE}</passphrase>
|
||||
<!-- 避免在CI/CD中使用交互模式 -->
|
||||
<useAgent>false</useAgent>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Maven Nexus Staging Plugin - 用于部署到Maven Central -->
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.13</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId> <!-- 与settings.xml中的server id对应 -->
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Maven Release Plugin - 用于版本发布 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<configuration>
|
||||
<tagNameFormat>v@{project.version}</tagNameFormat>
|
||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||
<useReleaseProfile>false</useReleaseProfile>
|
||||
<releaseProfiles>release</releaseProfiles>
|
||||
<goals>deploy</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Maven Shade Plugin - 另一个可选的打包插件,可以与Assembly Plugin二选一 -->
|
||||
<!-- 如果您想使用Shade Plugin而不是Assembly Plugin,可以取消下面的注释 -->
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||
<shadedClassifierName>with-dependencies</shadedClassifierName>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>com.yourcompany.MainClass</mainClass>
|
||||
</transformer>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
||||
<resource>META-INF/spring.handlers</resource>
|
||||
</transformer>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
||||
<resource>META-INF/spring.schemas</resource>
|
||||
</transformer>
|
||||
</transformers>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
-->
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<!-- 发布配置 -->
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<!-- 发布配置文件 -->
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- 在发布时激活source和javadoc插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- GPG签名 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
200
src/main/java/vip/jcfd/sdk/HGDef.java
Normal file
200
src/main/java/vip/jcfd/sdk/HGDef.java
Normal file
@ -0,0 +1,200 @@
|
||||
package vip.jcfd.sdk;
|
||||
|
||||
import com.sun.jna.IntegerType;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* JNA接口映射 - 基于HGDef.h头文件
|
||||
*/
|
||||
public interface HGDef extends StdCallLibrary {
|
||||
|
||||
// 基本类型映射
|
||||
class HGVoid {}
|
||||
class HGChar extends IntegerType {
|
||||
public HGChar() { super(1, true); }
|
||||
public HGChar(long value) { super(1, value, true); }
|
||||
}
|
||||
class HGByte extends IntegerType {
|
||||
public HGByte() { super(1, false); }
|
||||
public HGByte(long value) { super(1, value, false); }
|
||||
}
|
||||
class HGShort extends IntegerType {
|
||||
public HGShort() { super(2, true); }
|
||||
public HGShort(long value) { super(2, value, true); }
|
||||
}
|
||||
class HGUShort extends IntegerType {
|
||||
public HGUShort() { super(2, false); }
|
||||
public HGUShort(long value) { super(2, value, false); }
|
||||
}
|
||||
class HGInt extends IntegerType {
|
||||
public HGInt() { super(4, true); }
|
||||
public HGInt(long value) { super(4, value, true); }
|
||||
}
|
||||
class HGUInt extends IntegerType {
|
||||
public HGUInt() { super(4, false); }
|
||||
public HGUInt(long value) { super(4, value, false); }
|
||||
}
|
||||
class HGLonglong extends IntegerType {
|
||||
public HGLonglong() { super(8, true); }
|
||||
public HGLonglong(long value) { super(8, value, true); }
|
||||
}
|
||||
class HGULonglong extends IntegerType {
|
||||
public HGULonglong() { super(8, false); }
|
||||
public HGULonglong(long value) { super(8, value, false); }
|
||||
}
|
||||
class HGBool extends IntegerType {
|
||||
public HGBool() { super(4, true); }
|
||||
public HGBool(long value) { super(4, value, true); }
|
||||
}
|
||||
class HGFloat extends IntegerType {
|
||||
public HGFloat() { super(4, true); }
|
||||
public HGFloat(long value) { super(4, value, true); }
|
||||
}
|
||||
class HGDouble extends IntegerType {
|
||||
public HGDouble() { super(8, true); }
|
||||
public HGDouble(long value) { super(8, value, true); }
|
||||
}
|
||||
|
||||
// 平台相关类型映射
|
||||
boolean IS_64BIT = Native.LONG_SIZE == 8;
|
||||
|
||||
// HGSize 和 HGUSize 根据平台映射
|
||||
class HGSize extends IntegerType {
|
||||
public HGSize() { super(IS_64BIT ? 8 : 4, true); }
|
||||
public HGSize(long value) { super(IS_64BIT ? 8 : 4, value, true); }
|
||||
}
|
||||
|
||||
class HGUSize extends IntegerType {
|
||||
public HGUSize() { super(IS_64BIT ? 8 : 4, false); }
|
||||
public HGUSize(long value) { super(IS_64BIT ? 8 : 4, value, false); }
|
||||
}
|
||||
|
||||
class HGColor extends IntegerType {
|
||||
public HGColor() { super(4, false); }
|
||||
public HGColor(long value) { super(4, value, false); }
|
||||
}
|
||||
|
||||
class HGResult extends IntegerType {
|
||||
public HGResult() { super(4, false); }
|
||||
public HGResult(long value) { super(4, value, false); }
|
||||
}
|
||||
|
||||
// 常量定义
|
||||
int HGTRUE = 1;
|
||||
int HGFALSE = 0;
|
||||
|
||||
// Windows特定类型
|
||||
class HGWindow extends Pointer {
|
||||
public HGWindow() { super(0); }
|
||||
public HGWindow(long peer) { super(peer); }
|
||||
}
|
||||
|
||||
// 结构体定义 - 使用4字节对齐
|
||||
@Structure.FieldOrder({"left", "top", "right", "bottom"})
|
||||
class HGRect extends Structure {
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
|
||||
public HGRect() {}
|
||||
public HGRect(int left, int top, int right, int bottom) {
|
||||
this.left = left;
|
||||
this.top = top;
|
||||
this.right = right;
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("left", "top", "right", "bottom");
|
||||
}
|
||||
}
|
||||
|
||||
@Structure.FieldOrder({"left", "top", "right", "bottom"})
|
||||
class HGRectF extends Structure {
|
||||
public float left;
|
||||
public float top;
|
||||
public float right;
|
||||
public float bottom;
|
||||
|
||||
public HGRectF() {}
|
||||
public HGRectF(float left, float top, float right, float bottom) {
|
||||
this.left = left;
|
||||
this.top = top;
|
||||
this.right = right;
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("left", "top", "right", "bottom");
|
||||
}
|
||||
}
|
||||
|
||||
@Structure.FieldOrder({"x", "y"})
|
||||
class HGPoint extends Structure {
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
public HGPoint() {}
|
||||
public HGPoint(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("x", "y");
|
||||
}
|
||||
}
|
||||
|
||||
@Structure.FieldOrder({"x", "y"})
|
||||
class HGPointF extends Structure {
|
||||
public float x;
|
||||
public float y;
|
||||
|
||||
public HGPointF() {}
|
||||
public HGPointF(float x, float y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("x", "y");
|
||||
}
|
||||
}
|
||||
|
||||
// 颜色处理方法
|
||||
static int HG_MAKECOLOR(int r, int g, int b, int a) {
|
||||
return ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((g & 0xFF) << 8) | (r & 0xFF);
|
||||
}
|
||||
|
||||
static int HG_GETCOLOR_R(int color) {
|
||||
return color & 0xFF;
|
||||
}
|
||||
|
||||
static int HG_GETCOLOR_G(int color) {
|
||||
return (color >> 8) & 0xFF;
|
||||
}
|
||||
|
||||
static int HG_GETCOLOR_B(int color) {
|
||||
return (color >> 16) & 0xFF;
|
||||
}
|
||||
|
||||
static int HG_GETCOLOR_A(int color) {
|
||||
return (color >> 24) & 0xFF;
|
||||
}
|
||||
|
||||
// 路径分隔符
|
||||
char HG_SEP_CHAR = System.getProperty("os.name").toLowerCase().contains("win") ? '\\' : '/';
|
||||
String HG_SEP_STRING = System.getProperty("os.name").toLowerCase().contains("win") ? "\\" : "/";
|
||||
}
|
||||
205
src/main/java/vip/jcfd/sdk/HGScannerConstants.java
Normal file
205
src/main/java/vip/jcfd/sdk/HGScannerConstants.java
Normal file
@ -0,0 +1,205 @@
|
||||
package vip.jcfd.sdk;
|
||||
|
||||
/**
|
||||
* 扫描仪常量定义
|
||||
* 基于HGScannerLib.h中的常量定义
|
||||
*/
|
||||
public class HGScannerConstants {
|
||||
|
||||
// ==================== 设备错误码常量 ====================
|
||||
|
||||
// 1:软件逻辑错误
|
||||
public static final int HGLIB_DEV_OPERATECODE_INVALID_PARAMETER = 0x100;
|
||||
public static final int HGLIB_DEV_OPERATECODE_ERR_USER_CANCELED = 0x101;
|
||||
public static final int HGLIB_DEV_OPERATECODE_INSUFFICIENT_MEMORY = 0x102;
|
||||
public static final int HGLIB_DEV_OPERATECODE_ACCESS_DENIED = 0x103;
|
||||
public static final int HGLIB_DEV_OPERATECODE_IO_PENDING = 0x104;
|
||||
public static final int HGLIB_DEV_OPERATECODE_ERR_NOT_EXACT = 0x105;
|
||||
public static final int HGLIB_DEV_OPERATECODE_ERR_CONFIGURATION_CHANGED = 0x106;
|
||||
public static final int HGLIB_DEV_OPERATECODE_ERR_NOT_OPEN = 0x107;
|
||||
public static final int HGLIB_DEV_OPERATECODE_ERR_NOT_START = 0x108;
|
||||
public static final int HGLIB_DEV_OPERATECODE_ERR_NOT_ANY_MORE = 0x109;
|
||||
public static final int HGLIB_DEV_OPERATECODE_ERR_NO_DATA = 0x10A;
|
||||
public static final int HGLIB_DEV_OPERATECODE_HAS_DATA_YET = 0x10B;
|
||||
public static final int HGLIB_DEV_OPERATECODE_OUT_OF_RANGE = 0x10C;
|
||||
public static final int HGLIB_DEV_OPERATECODE_IO = 0x10D;
|
||||
public static final int HGLIB_DEV_OPERATECODE_TIMEOUT = 0x10E;
|
||||
public static final int HGLIB_DEV_OPERATECODE_OPEN_FILE_FAILED = 0x10F;
|
||||
public static final int HGLIB_DEV_OPERATECODE_CREATE_FILE_FAILED = 0x110;
|
||||
public static final int HGLIB_DEV_OPERATECODE_WRITE_FILE_FAILED = 0x111;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DATA_DAMAGED = 0x112;
|
||||
public static final int HGLIB_DEV_OPERATECODE_OPENED_BY_OTHER_PROCESS = 0x113;
|
||||
public static final int HGLIB_DEV_OPERATECODE_LANG_PAK_LOST = 0x114;
|
||||
public static final int HGLIB_DEV_OPERATECODE_RELOAD_IMAGE_PARAM = 0x115;
|
||||
public static final int HGLIB_DEV_OPERATECODE_RELOAD_OPT_PARAM = 0x116;
|
||||
public static final int HGLIB_DEV_OPERATECODE_IMAGE_PROC_FATAL = 0x117;
|
||||
public static final int HGLIB_DEV_OPERATECODE_SCANNER_ERR_IMAGE_ORDER = 0x11C;
|
||||
|
||||
// 2:USB错误
|
||||
public static final int HGLIB_DEV_OPERATECODE_USB_INIT_FAILED = 0x5B00;
|
||||
public static final int HGLIB_DEV_OPERATECODE_USB_REGISTER_PNP_FAILED = 0x5B01;
|
||||
public static final int HGLIB_DEV_OPERATECODE_USB_CLAIM_INTERFACE_FAILED = 0x5B02;
|
||||
|
||||
// 3:硬件错误
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_NOT_FOUND = 0x0DE00;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_NOT_SUPPORT = 0x0DE01;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_BUSY = 0x0DE02;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_SLEEPING = 0x0DE03;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_COUNT_MODE = 0x0DE04;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_STOPPED = 0x0DE05;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_COVER_OPENNED = 0x0DE06;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_NO_PAPER = 0x0DE07;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_FEEDING_PAPER = 0x0DE08;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_DOUBLE_FEEDING = 0x0DE09;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_PAPER_JAMMED = 0x0DE0A;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_STAPLE_ON = 0x0DE0B;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_PAPER_SKEW = 0x0DE0C;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_SIZE_CHECK = 0x0DE0D;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_DOGEAR = 0x0DE0E;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_NO_IMAGE = 0x0DE0F;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_SCANN_ERROR = 0x0DE10;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_PC_BUSY = 0x0DE11;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_ISLOCK = 0x0DE12;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_UPGRADE_SUCCESSFUL = 0x0DE13;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_UPGRADE_FAIL = 0x0DE14;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_AUTO_FAIL_OVER = 0x0DE15;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_AUTO_FAIL_INFO = 0x0DE16;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_DISTORTION = 0x0DE17;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_MAYBE_IS_HOLE = 0x0DE18;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_DEVS_BOOTING = 0x0DE19;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_UNKNOWN_STATUS = 0x0DE1A;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_LENS_DIRTY = 0x0DE1B;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_OUT_BOUNDARY = 0x0DE1C;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_GET_CT_FAIL = 0x0DE1D;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_JPEG_COMPRESS_FAIL = 0x0DE1E;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_JPEG_FINISH_FAIL = 0x0DE1F;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_THUNK_DATA = 0x0DE20;
|
||||
public static final int HGLIB_DEV_OPERATECODE_DEVICE_WRONG_FIRMWARE_INFO = 0x0DE21;
|
||||
|
||||
// 4:设备状态码
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_UNKNOW = -1;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_NO_PAPER = 0;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_PAPER = 1;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_NOT_FOUND = 2;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_BUSY = 3;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_SLEEPING = 4;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_COUNT_MODE = 5;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_COVER_OPENNED = 6;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_FEEDING_PAPER = 7;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_DOUBLE_FEEDING = 8;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_PAPER_JAMMED = 9;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_STAPLE_ON = 10;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_PAPER_SKEW = 11;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_DOGEAR = 12;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_NO_IMAGE = 13;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_SCANN_ERROR = 14;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_PC_BUSY = 15;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_MAYBE_IS_HOLE = 16;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_DEVS_BOOTING = 17;
|
||||
public static final int HGLIB_DEV_STATUSCODE_DEVICE_LENS_DIRTY = 18;
|
||||
|
||||
// ==================== 组名常量 ====================
|
||||
|
||||
public static final int HGLIB_GROUP_NAME_BASESETTING = 1; // 基本设置
|
||||
public static final int HGLIB_GROUP_NAME_BRIGHTNESS = 2; // 亮度
|
||||
public static final int HGLIB_GROUP_NAME_IMAGEPROCESS = 3; // 图像处理
|
||||
public static final int HGLIB_GROUP_NAME_PAPERFEEDING = 4; // 送纸方式设置
|
||||
|
||||
// ==================== 配置名常量 ====================
|
||||
|
||||
public static final int HGLIB_OPTION_NAME_UNKNOWN = 0; // "未知"
|
||||
public static final int HGLIB_OPTION_NAME_DLSC = 1; // "多流输出"
|
||||
public static final int HGLIB_OPTION_NAME_DLSCLX = 2; // "多流输出类型"
|
||||
public static final int HGLIB_OPTION_NAME_YSMS = 3; // "颜色模式"
|
||||
public static final int HGLIB_OPTION_NAME_HBTXYZ = 4; // "黑白图像阈值"
|
||||
public static final int HGLIB_OPTION_NAME_HDHHBTX_CS = 5; // "灰度或黑白图像 - 除色"
|
||||
public static final int HGLIB_OPTION_NAME_24WCSTX_DLSCCH = 6; // "24位彩色图像 - 多流输出除红"
|
||||
public static final int HGLIB_OPTION_NAME_24WCSTX_DTKCH = 7; // "24位彩色图像 - 答题卡除红"
|
||||
public static final int HGLIB_OPTION_NAME_BJYC = 8; // "背景移除"
|
||||
public static final int HGLIB_OPTION_NAME_BJSCFDFW = 9; // "背景色彩浮动范围"
|
||||
public static final int HGLIB_OPTION_NAME_RHYMH = 10; // "锐化与模糊"
|
||||
public static final int HGLIB_OPTION_NAME_QCMW = 11; // "去除摩尔纹"
|
||||
public static final int HGLIB_OPTION_NAME_CWW = 12; // "除网纹"
|
||||
public static final int HGLIB_OPTION_NAME_CWKS = 13; // "错误扩散"
|
||||
public static final int HGLIB_OPTION_NAME_HBTXZDYH = 14; // "黑白图像噪点优化"
|
||||
public static final int HGLIB_OPTION_NAME_ZDYHCC = 15; // "噪点优化尺寸"
|
||||
public static final int HGLIB_OPTION_NAME_ZZCC = 16; // "纸张尺寸"
|
||||
public static final int HGLIB_OPTION_NAME_ZDYSMQY = 17; // "自定义扫描区域"
|
||||
public static final int HGLIB_OPTION_NAME_SMQYZCmm = 18; // "扫描区域左侧(mm)"
|
||||
public static final int HGLIB_OPTION_NAME_SMQYYCmm = 19; // "扫描区域右侧(mm)"
|
||||
public static final int HGLIB_OPTION_NAME_SMQYSCmm = 20; // "扫描区域上侧(mm)"
|
||||
public static final int HGLIB_OPTION_NAME_SMQYXCmm = 21; // "扫描区域下侧(mm)"
|
||||
public static final int HGLIB_OPTION_NAME_CCJC = 22; // "尺寸检测"
|
||||
public static final int HGLIB_OPTION_NAME_SMYM = 23; // "扫描页面"
|
||||
public static final int HGLIB_OPTION_NAME_TGKBYLMD = 24; // "跳过空白页灵敏度"
|
||||
public static final int HGLIB_OPTION_NAME_FZQD = 25; // "分纸强度"
|
||||
public static final int HGLIB_OPTION_NAME_XMSJ = 26; // "休眠时间"
|
||||
public static final int HGLIB_OPTION_NAME_FBL = 27; // "分辨率"
|
||||
public static final int HGLIB_OPTION_NAME_HZ = 28; // "画质"
|
||||
public static final int HGLIB_OPTION_NAME_JHZFM = 29; // "交换正反面"
|
||||
public static final int HGLIB_OPTION_NAME_TXCF = 30; // "图像拆分"
|
||||
public static final int HGLIB_OPTION_NAME_ZDJP = 31; // "自动纠偏"
|
||||
public static final int HGLIB_OPTION_NAME_QYSDQX = 32; // "启用色调曲线"
|
||||
public static final int HGLIB_OPTION_NAME_LDZ = 33; // "亮度值"
|
||||
public static final int HGLIB_OPTION_NAME_DBD = 34; // "对比度"
|
||||
public static final int HGLIB_OPTION_NAME_GMZ = 35; // "伽马值"
|
||||
public static final int HGLIB_OPTION_NAME_ZPMS = 36; // "照片模式"
|
||||
public static final int HGLIB_OPTION_NAME_XCHK = 37; // "消除黑框"
|
||||
public static final int HGLIB_OPTION_NAME_SSYZ = 38; // "深色样张"
|
||||
public static final int HGLIB_OPTION_NAME_YZ = 39; // "阈值"
|
||||
public static final int HGLIB_OPTION_NAME_BJKZDJ = 40; // "背景抗噪等级"
|
||||
public static final int HGLIB_OPTION_NAME_BYSJ = 41; // "边缘缩进"
|
||||
public static final int HGLIB_OPTION_NAME_BJTCFS = 42; // "背景填充方式"
|
||||
public static final int HGLIB_OPTION_NAME_FZST = 43; // "防止渗透"
|
||||
public static final int HGLIB_OPTION_NAME_FZSTDJ = 44; // "防止渗透等级"
|
||||
public static final int HGLIB_OPTION_NAME_CKYCZC = 45; // "穿孔移除—左侧"
|
||||
public static final int HGLIB_OPTION_NAME_ZCCKSSFWZFMBL = 46; // #"左侧穿孔搜索范围占幅面比例"
|
||||
public static final int HGLIB_OPTION_NAME_CKYCYC = 47; // "穿孔移除—右侧"
|
||||
public static final int HGLIB_OPTION_NAME_YCCKSSFWZFMBL = 48; // #"右侧穿孔搜索范围占幅面比例"
|
||||
public static final int HGLIB_OPTION_NAME_CKYCSC = 49; // "穿孔移除—上侧"
|
||||
public static final int HGLIB_OPTION_NAME_SCCKSSFWZFMBL = 50; // #"上侧穿孔搜索范围占幅面比例"
|
||||
public static final int HGLIB_OPTION_NAME_CKYCXC = 51; // "穿孔移除—下侧"
|
||||
public static final int HGLIB_OPTION_NAME_XCCKSSFWZFMBL = 52; // #"下侧穿孔搜索范围占幅面比例"
|
||||
public static final int HGLIB_OPTION_NAME_SCTC = 53; // "色彩填充"
|
||||
public static final int HGLIB_OPTION_NAME_CSBJC = 54; // "超声波检测"
|
||||
public static final int HGLIB_OPTION_NAME_SZTPCL = 55; // "双张图片处理"
|
||||
public static final int HGLIB_OPTION_NAME_ZDJC = 56; // "装订检测"
|
||||
public static final int HGLIB_OPTION_NAME_SMZS = 57; // "扫描张数"
|
||||
public static final int HGLIB_OPTION_NAME_SMSL = 58; // "扫描数量"
|
||||
public static final int HGLIB_OPTION_NAME_WGFX = 59; // "文稿方向"
|
||||
public static final int HGLIB_OPTION_NAME_BMXZ180 = 60; // "背面旋转180°"
|
||||
public static final int HGLIB_OPTION_NAME_ZJJC = 61; // "折角检测"
|
||||
public static final int HGLIB_OPTION_NAME_ZJDX = 62; // "折角大小"
|
||||
public static final int HGLIB_OPTION_NAME_WXJC = 63; // "歪斜检测"
|
||||
public static final int HGLIB_OPTION_NAME_WXRRD = 64; // "歪斜容忍度"
|
||||
public static final int HGLIB_OPTION_NAME_ZDCZQD = 65; // 自动分纸强度
|
||||
public static final int HGLIB_OPTION_NAME_CZYZ = 66; // 进纸失败率
|
||||
public static final int HGLIB_OPTION_NAME_DZSM = 67; // 待纸扫描
|
||||
public static final int HGLIB_OPTION_NAME_HBTXFSSC = 68; // 黑白图像反色输出(正常颜色为:0 - 黑色;1 - 白色)
|
||||
public static final int HGLIB_OPTION_NAME_DZMS = 69; // 对折模式
|
||||
public static final int HGLIB_OPTION_NAME_SPJZ = 70; // 色偏校正
|
||||
public static final int HGLIB_OPTION_NAME_DZSMTCSJ = 71; // 待纸扫描退出时间
|
||||
public static final int HGLIB_OPTION_NAME_TGKBY = 72; // 跳过空白页
|
||||
public static final int HGLIB_OPTION_NAME_JTZWJC = 73; // 镜头脏污检测
|
||||
public static final int HGLIB_OPTION_NAME_CKYC = 74; // 穿孔移除
|
||||
public static final int HGLIB_OPTION_NAME_CKSSFWZFMBL = 75; // 穿孔搜索范围占幅面比例
|
||||
public static final int HGLIB_OPTION_NAME_BJJC = 76; // 边界检测
|
||||
public static final int HGLIB_OPTION_NAME_SMCGQXHQD = 77; // 扫描传感器信号强度
|
||||
public static final int HGLIB_OPTION_NAME_TGKBYBYKD = 78; // 跳过空白页边缘宽度
|
||||
|
||||
// ==================== 配置值类型 ====================
|
||||
|
||||
public static final int HGLIB_OPTION_VALUETYPE_INT = 1;
|
||||
public static final int HGLIB_OPTION_VALUETYPE_ENUM = 2;
|
||||
public static final int HGLIB_OPTION_VALUETYPE_DOUBLE = 3;
|
||||
public static final int HGLIB_OPTION_VALUETYPE_BOOL = 4;
|
||||
|
||||
// ==================== 配置值范围类型 ====================
|
||||
|
||||
public static final int HGLIB_OPTION_VALUERANGETYPE_NULL = 0;
|
||||
public static final int HGLIB_OPTION_VALUERANGETYPE_INTLIST = 1;
|
||||
public static final int HGLIB_OPTION_VALUERANGETYPE_ENUMLIST = 2;
|
||||
public static final int HGLIB_OPTION_VALUERANGETYPE_DOUBLELIST = 3;
|
||||
public static final int HGLIB_OPTION_VALUERANGETYPE_INTRANGE = 4;
|
||||
public static final int HGLIB_OPTION_VALUERANGETYPE_DOUBLERANGE = 5;
|
||||
}
|
||||
354
src/main/java/vip/jcfd/sdk/HGScannerLib.java
Normal file
354
src/main/java/vip/jcfd/sdk/HGScannerLib.java
Normal file
@ -0,0 +1,354 @@
|
||||
package vip.jcfd.sdk;
|
||||
|
||||
import com.sun.jna.Callback;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* JNA接口映射 - 基于HGScannerLib.h头文件
|
||||
* 扫描仪库的主要功能接口
|
||||
*/
|
||||
public interface HGScannerLib extends HGDef, StdCallLibrary {
|
||||
|
||||
// 库加载路径配置
|
||||
String JNA_LIBRARY_NAME = System.getProperty("os.name").toLowerCase().contains("win")
|
||||
? "HGScannerLib" : "libHGScannerLib";
|
||||
|
||||
// ==================== 常量定义 ====================
|
||||
|
||||
// 图像类型
|
||||
long HGLIB_IMGTYPE_BINARY = 1L;
|
||||
long HGLIB_IMGTYPE_GRAY = 2L;
|
||||
long HGLIB_IMGTYPE_BGR = 3L;
|
||||
long HGLIB_IMGTYPE_RGB = 4L;
|
||||
long HGLIB_IMGTYPE_BGRA = 5L;
|
||||
long HGLIB_IMGTYPE_RGBA = 6L;
|
||||
|
||||
// 图像数据保存方式
|
||||
long HGLIB_IMGORIGIN_TOP = 1L;
|
||||
long HGLIB_IMGORIGIN_BOTTOM = 2L;
|
||||
|
||||
// TIFF压缩方式
|
||||
long HGLIB_TIFFCOMPRESSION_NONE = 1L;
|
||||
long HGLIB_TIFFCOMPRESSION_CCITTFAX4 = 2L;
|
||||
long HGLIB_TIFFCOMPRESSION_LZW = 3L;
|
||||
long HGLIB_TIFFCOMPRESSION_JPEG = 4L;
|
||||
|
||||
// 设备错误码 - 软件逻辑错误
|
||||
long HGLIB_DEV_OPERATECODE_GOOD = 0L;
|
||||
long HGLIB_DEV_OPERATECODE_UNSUPPORTED = 1L;
|
||||
long HGLIB_DEV_OPERATECODE_CANCELLED = 2L;
|
||||
long HGLIB_DEV_OPERATECODE_BUSY = 3L;
|
||||
long HGLIB_DEV_OPERATECODE_INVAL = 4L;
|
||||
long HGLIB_DEV_OPERATECODE_EOF = 5L;
|
||||
long HGLIB_DEV_OPERATECODE_JAMMED = 6L;
|
||||
long HGLIB_DEV_OPERATECODE_NO_DOCS = 7L;
|
||||
long HGLIB_DEV_OPERATECODE_COVER_OPEN = 8L;
|
||||
long HGLIB_DEV_OPERATECODE_IO_ERROR = 9L;
|
||||
long HGLIB_DEV_OPERATECODE_NO_MEM = 10L;
|
||||
long HGLIB_DEV_OPERATECODE_ACCESS_DENIED = 11L;
|
||||
|
||||
// 设备热拔插事件
|
||||
long HGLIB_DEVHOTPLUG_EVENT_ARRIVE = 1L;
|
||||
long HGLIB_DEVHOTPLUG_EVENT_REMOVE = 2L;
|
||||
|
||||
// 设备扫描事件
|
||||
long HGLIB_DEVSCAN_EVENT_BEGIN = 1L;
|
||||
long HGLIB_DEVSCAN_EVENT_END = 2L;
|
||||
long HGLIB_DEVSCAN_EVENT_INFO = 3L;
|
||||
|
||||
// ==================== 句柄类型 ====================
|
||||
|
||||
class HGLibImage extends Pointer {
|
||||
public HGLibImage() {
|
||||
super(0);
|
||||
}
|
||||
|
||||
public HGLibImage(long peer) {
|
||||
super(peer);
|
||||
}
|
||||
}
|
||||
|
||||
class HGLibDevice extends Pointer {
|
||||
public HGLibDevice() {
|
||||
super(0);
|
||||
}
|
||||
|
||||
public HGLibDevice(long peer) {
|
||||
super(peer);
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 结构体定义 ====================
|
||||
|
||||
@Structure.FieldOrder({"size", "jpegQuality", "tiffCompression", "tiffJpegQuality", "ocr", "jp2Ratio"})
|
||||
class HGLibSaveImageParam extends Structure {
|
||||
public int size; // 结构体大小,必须初始化为sizeof(HGLibSaveImageParam)
|
||||
public int jpegQuality; // jpeg下有效, 0-100
|
||||
public int tiffCompression; // tiff下有效, HGLIB_TIFFCOMPRESSION_*
|
||||
public int tiffJpegQuality; // tiff且HGLIB_TIFFCOMPRESSION_JPEG下有效, 0-100
|
||||
public int ocr; // 是否OCR,pdf和ofd格式有效
|
||||
public float jp2Ratio; // jp2压缩比
|
||||
|
||||
public HGLibSaveImageParam() {
|
||||
super();
|
||||
this.size = size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("size", "jpegQuality", "tiffCompression", "tiffJpegQuality", "ocr", "jp2Ratio");
|
||||
}
|
||||
}
|
||||
|
||||
@Structure.FieldOrder({"width", "height", "type", "widthStep", "origin"})
|
||||
class HGLibImageInfo extends Structure {
|
||||
public int width; // 宽(像素),列数
|
||||
public int height; // 高(像素),行数
|
||||
public int type; // 类型,参见HGLIB_IMGTYPE_*
|
||||
public int widthStep; // 每行的字节数
|
||||
public int origin; // 数据排列方式,参见HGLIB_IMGORIGIN_*
|
||||
|
||||
public HGLibImageInfo() {
|
||||
}
|
||||
|
||||
public static class ByReference extends HGLibImageInfo implements Structure.ByReference {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("width", "height", "type", "widthStep", "origin");
|
||||
}
|
||||
}
|
||||
|
||||
@Structure.FieldOrder({"value", "count"})
|
||||
class HGLibDeviceIntValueList extends Structure {
|
||||
public Pointer value; // HGInt*
|
||||
public int count;
|
||||
|
||||
public HGLibDeviceIntValueList() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("value", "count");
|
||||
}
|
||||
}
|
||||
|
||||
@Structure.FieldOrder({"value", "count"})
|
||||
class HGLibDeviceEnumValueList extends Structure {
|
||||
public Pointer value; // HGUInt*
|
||||
public int count;
|
||||
|
||||
public HGLibDeviceEnumValueList() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("value", "count");
|
||||
}
|
||||
}
|
||||
|
||||
@Structure.FieldOrder({"value", "count"})
|
||||
class HGLibDeviceDoubleValueList extends Structure {
|
||||
public Pointer value; // HGDouble*
|
||||
public int count;
|
||||
|
||||
public HGLibDeviceDoubleValueList() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("value", "count");
|
||||
}
|
||||
}
|
||||
|
||||
@Structure.FieldOrder({"minValue", "maxValue"})
|
||||
class HGLibDeviceIntValueRange extends Structure {
|
||||
public int minValue;
|
||||
public int maxValue;
|
||||
|
||||
public HGLibDeviceIntValueRange() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("minValue", "maxValue");
|
||||
}
|
||||
}
|
||||
|
||||
@Structure.FieldOrder({"minValue", "maxValue"})
|
||||
class HGLibDeviceDoubleValueRange extends Structure {
|
||||
public double minValue;
|
||||
public double maxValue;
|
||||
|
||||
public HGLibDeviceDoubleValueRange() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("minValue", "maxValue");
|
||||
}
|
||||
}
|
||||
|
||||
// 使用联合体需要在JNA中特殊处理
|
||||
@Structure.FieldOrder({"option", "type", "intValue", "enumValue", "doubleValue", "boolValue", "rangeType", "unionData"})
|
||||
class HGLibDeviceParam extends Structure {
|
||||
public static class ByValue extends HGLibDeviceParam implements Structure.ByValue {
|
||||
}
|
||||
|
||||
public int option; // 配置名, 参见HGLIB_OPTION_NAME_*
|
||||
public int type; // 值类型, 参见HGLIB_OPTION_VALUETYPE_*
|
||||
public int intValue; // 整数值
|
||||
public int enumValue; // 枚举值
|
||||
public double doubleValue; // 双精度值
|
||||
public int boolValue; // 布尔值
|
||||
public int rangeType; // 值范围类型, 参见HGLIB_OPTION_VALUERANGETYPE_*
|
||||
public Pointer unionData; // 联合数据,需要根据rangeType进行类型转换
|
||||
|
||||
public HGLibDeviceParam() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("option", "type", "intValue", "enumValue", "doubleValue", "boolValue", "rangeType", "unionData");
|
||||
}
|
||||
}
|
||||
|
||||
@Structure.FieldOrder({"group", "param", "paramCount"})
|
||||
class HGLibDeviceParamGroup extends Structure {
|
||||
public int group; // 组名, 参见HGLIB_GROUP_NAME_*
|
||||
public Pointer param; // HGLibDeviceParam*
|
||||
public int paramCount;
|
||||
|
||||
public HGLibDeviceParamGroup() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("group", "param", "paramCount");
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 回调函数定义 ====================
|
||||
|
||||
interface HGLibDeviceHotPlugEventFunc extends Callback {
|
||||
void invoke(int event, String deviceName, Pointer param);
|
||||
}
|
||||
|
||||
interface HGLibDeviceScanEventFunc extends Callback {
|
||||
void invoke(HGLibDevice device, int event, int operateCode, String info, Pointer param);
|
||||
}
|
||||
|
||||
interface HGLibDeviceScanImageFunc extends Callback {
|
||||
void invoke(HGLibDevice device, HGLibImage image, Pointer param);
|
||||
}
|
||||
|
||||
// ==================== 函数接口定义 ====================
|
||||
|
||||
// 内存拷贝
|
||||
boolean HGLib_MemoryCopy(Pointer dest, Pointer src, int size);
|
||||
|
||||
// 图像相关函数
|
||||
HGLibImage HGLib_LoadImage(String filePath);
|
||||
|
||||
HGLibImage HGLib_CloneImage(HGLibImage image, int type, int origin);
|
||||
|
||||
Pointer HGLib_GetImageData(HGLibImage image);
|
||||
|
||||
boolean HGLib_GetImageInfo(HGLibImage image, HGLibImageInfo.ByReference imageInfo);
|
||||
|
||||
boolean HGLib_GetImageDpi(HGLibImage image, IntByReference xDpi, IntByReference yDpi);
|
||||
|
||||
boolean HGLib_SaveImage(HGLibImage image, String savePath, HGLibSaveImageParam saveParam);
|
||||
|
||||
boolean HGLib_ReleaseImage(HGLibImage image);
|
||||
|
||||
String HGLib_GetOcrText(HGLibImage image);
|
||||
|
||||
boolean HGLib_ReleaseOcrText(String ocrText);
|
||||
|
||||
// 设备相关函数
|
||||
boolean HGLib_InitDevice(HGLibDeviceHotPlugEventFunc func, Pointer param);
|
||||
|
||||
boolean HGLib_DeinitDevice();
|
||||
|
||||
Pointer HGLib_GetDeviceNameList();
|
||||
|
||||
boolean HGLib_ReleaseDeviceNameList(Pointer deviceNameList);
|
||||
|
||||
HGLibDevice HGLib_OpenDevice(String deviceName);
|
||||
|
||||
boolean HGLib_CloseDevice(HGLibDevice device);
|
||||
|
||||
boolean HGLib_GetDeviceType(HGLibDevice device, byte[] type, int maxLen);
|
||||
|
||||
boolean HGLib_GetDeviceSN(HGLibDevice device, byte[] sn, int maxLen);
|
||||
|
||||
boolean HGLib_GetDeviceFWVersion(HGLibDevice device, byte[] fwVersion, int maxLen);
|
||||
|
||||
boolean HGLib_GetDevicePD(HGLibDevice device, byte[] pd, int maxLen);
|
||||
|
||||
boolean HGLib_GetDevicePatchId(HGLibDevice device, byte[] patchId, int maxLen);
|
||||
|
||||
int HGLib_GetDeviceRollerCount(HGLibDevice device);
|
||||
|
||||
int HGLib_GetDeviceTotalCount(HGLibDevice device);
|
||||
|
||||
boolean HGLib_ClearDeviceRollerCount(HGLibDevice device);
|
||||
|
||||
boolean HGLib_SetDeviceToken(HGLibDevice device, String code);
|
||||
|
||||
boolean HGLib_SetOriginalImage(HGLibDevice device, int isOriginal);
|
||||
|
||||
// 设备参数相关函数
|
||||
boolean HGLib_SetDeviceParam(HGLibDevice device, int option, Pointer data);
|
||||
|
||||
Pointer HGLib_GetDeviceParamGroupList(HGLibDevice device, IntByReference count);
|
||||
|
||||
Pointer HGLib_GetDeviceParam(HGLibDevice device, int option);
|
||||
|
||||
boolean HGLib_ReleaseDeviceParamGroupList(Pointer paramGroup, int count);
|
||||
|
||||
boolean HGLib_ReleaseDeviceParam(Pointer param);
|
||||
|
||||
boolean HGLib_ResetDeviceParam(HGLibDevice device);
|
||||
|
||||
// 设备状态相关函数
|
||||
boolean HGLib_DeviceIsPaperOn(HGLibDevice device);
|
||||
|
||||
int HGLib_GetDeviceStatus(HGLibDevice device);
|
||||
|
||||
boolean HGLib_GetDeviceIsOnline(HGLibDevice device);
|
||||
|
||||
boolean HGLib_DeviceRestart(HGLibDevice device);
|
||||
|
||||
boolean HGLib_DeviceShutDown(HGLibDevice device);
|
||||
|
||||
// 扫描相关函数
|
||||
boolean HGLib_StartDeviceScan(HGLibDevice device, HGLibDeviceScanEventFunc eventFunc, Pointer eventParam,
|
||||
HGLibDeviceScanImageFunc imageFunc, Pointer imageParam);
|
||||
|
||||
boolean HGLib_StopDeviceScan(HGLibDevice device);
|
||||
|
||||
boolean HGLib_StopDeviceScanAsyn(HGLibDevice device);
|
||||
|
||||
int HGLib_GetDeviceOperateCode(HGLibDevice device);
|
||||
|
||||
int HGLib_GetDevicePageId(HGLibDevice device);
|
||||
|
||||
// ==================== 工厂方法 ====================
|
||||
|
||||
/**
|
||||
* 获取扫描仪库实例
|
||||
*
|
||||
* @return 扫描仪库实例
|
||||
*/
|
||||
HGScannerLib INSTANCE = Native.load(JNA_LIBRARY_NAME, HGScannerLib.class);
|
||||
}
|
||||
387
src/main/java/vip/jcfd/sdk/HGScannerWrapper.java
Normal file
387
src/main/java/vip/jcfd/sdk/HGScannerWrapper.java
Normal file
@ -0,0 +1,387 @@
|
||||
package vip.jcfd.sdk;
|
||||
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 扫描仪JNA封装类
|
||||
* 提供更友好的Java API接口,简化JNA调用
|
||||
*/
|
||||
public class HGScannerWrapper {
|
||||
|
||||
private static final int STRING_BUFFER_SIZE = 256;
|
||||
private static HGScannerLib scannerLib;
|
||||
|
||||
static {
|
||||
scannerLib = HGScannerLib.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化扫描仪
|
||||
*
|
||||
* @param hotPlugCallback 热拔插事件回调,可以为null
|
||||
* @param param 回调参数
|
||||
* @return 是否初始化成功
|
||||
*/
|
||||
public static boolean initialize(HGScannerLib.HGLibDeviceHotPlugEventFunc hotPlugCallback, Pointer param) {
|
||||
return scannerLib.HGLib_InitDevice(hotPlugCallback, param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 反初始化扫描仪
|
||||
*
|
||||
* @return 是否反初始化成功
|
||||
*/
|
||||
public static boolean deinitialize() {
|
||||
return scannerLib.HGLib_DeinitDevice();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备名称列表
|
||||
*
|
||||
* @return 设备名称列表
|
||||
*/
|
||||
public static List<String> getDeviceNameList() {
|
||||
Pointer nameListPtr = scannerLib.HGLib_GetDeviceNameList();
|
||||
if (nameListPtr == null || nameListPtr.equals(Pointer.NULL)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<String> deviceNames = new ArrayList<>();
|
||||
try {
|
||||
// 遍历指针数组,直到遇到null指针
|
||||
int offset = 0;
|
||||
while (true) {
|
||||
Pointer namePtr = nameListPtr.getPointer((long) offset * Native.POINTER_SIZE);
|
||||
if (namePtr == null || namePtr.equals(Pointer.NULL)) {
|
||||
break;
|
||||
}
|
||||
String deviceName = namePtr.getString(0, StandardCharsets.UTF_8.name());
|
||||
deviceNames.add(deviceName);
|
||||
offset++;
|
||||
}
|
||||
} finally {
|
||||
scannerLib.HGLib_ReleaseDeviceNameList(nameListPtr);
|
||||
}
|
||||
|
||||
return deviceNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开设备
|
||||
*
|
||||
* @param deviceName 设备名称
|
||||
* @return 设备句柄
|
||||
*/
|
||||
public static HGScannerLib.HGLibDevice openDevice(String deviceName) {
|
||||
return scannerLib.HGLib_OpenDevice(deviceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭设备
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @return 是否关闭成功
|
||||
*/
|
||||
public static boolean closeDevice(HGScannerLib.HGLibDevice device) {
|
||||
return scannerLib.HGLib_CloseDevice(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备型号
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @return 设备型号
|
||||
*/
|
||||
public static String getDeviceType(HGScannerLib.HGLibDevice device) {
|
||||
byte[] buffer = new byte[STRING_BUFFER_SIZE];
|
||||
boolean result = scannerLib.HGLib_GetDeviceType(device, buffer, buffer.length);
|
||||
if (result) {
|
||||
// 找到第一个0字节的位置
|
||||
int length = 0;
|
||||
while (length < buffer.length && buffer[length] != 0) {
|
||||
length++;
|
||||
}
|
||||
return new String(buffer, 0, length, StandardCharsets.UTF_8);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备序列号
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @return 设备序列号
|
||||
*/
|
||||
public static String getDeviceSerialNumber(HGScannerLib.HGLibDevice device) {
|
||||
byte[] buffer = new byte[STRING_BUFFER_SIZE];
|
||||
boolean result = scannerLib.HGLib_GetDeviceSN(device, buffer, buffer.length);
|
||||
if (result) {
|
||||
// 找到第一个0字节的位置
|
||||
int length = 0;
|
||||
while (length < buffer.length && buffer[length] != 0) {
|
||||
length++;
|
||||
}
|
||||
return new String(buffer, 0, length, StandardCharsets.UTF_8);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备固件版本
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @return 固件版本
|
||||
*/
|
||||
public static String getDeviceFirmwareVersion(HGScannerLib.HGLibDevice device) {
|
||||
byte[] buffer = new byte[STRING_BUFFER_SIZE];
|
||||
boolean result = scannerLib.HGLib_GetDeviceFWVersion(device, buffer, buffer.length);
|
||||
if (result) {
|
||||
// 找到第一个0字节的位置
|
||||
int length = 0;
|
||||
while (length < buffer.length && buffer[length] != 0) {
|
||||
length++;
|
||||
}
|
||||
return new String(buffer, 0, length, StandardCharsets.UTF_8);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载图像
|
||||
*
|
||||
* @param filePath 图像文件路径
|
||||
* @return 图像句柄
|
||||
*/
|
||||
public static HGScannerLib.HGLibImage loadImage(String filePath) {
|
||||
return scannerLib.HGLib_LoadImage(filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图像信息
|
||||
*
|
||||
* @param image 图像句柄
|
||||
* @return 图像信息
|
||||
*/
|
||||
public static HGScannerLib.HGLibImageInfo getImageInfo(HGScannerLib.HGLibImage image) {
|
||||
HGScannerLib.HGLibImageInfo.ByReference imageInfoRef = new HGScannerLib.HGLibImageInfo.ByReference();
|
||||
boolean result = scannerLib.HGLib_GetImageInfo(image, imageInfoRef);
|
||||
return result ? imageInfoRef : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图像数据
|
||||
*
|
||||
* @param image 图像句柄
|
||||
* @return 图像数据
|
||||
*/
|
||||
public static byte[] getImageData(HGScannerLib.HGLibImage image) {
|
||||
HGScannerLib.HGLibImageInfo info = getImageInfo(image);
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Pointer dataPtr = scannerLib.HGLib_GetImageData(image);
|
||||
if (dataPtr == null || dataPtr.equals(Pointer.NULL)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] data = new byte[info.widthStep * info.height];
|
||||
dataPtr.read(0, data, 0, data.length);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存图像
|
||||
*
|
||||
* @param image 图像句柄
|
||||
* @param savePath 保存路径
|
||||
* @param jpegQuality JPEG质量 (0-100),仅对JPEG格式有效
|
||||
* @param ocr 是否启用OCR,仅对PDF和OFD格式有效
|
||||
* @return 是否保存成功
|
||||
*/
|
||||
public static boolean saveImage(HGScannerLib.HGLibImage image, String savePath, int jpegQuality, boolean ocr) {
|
||||
HGScannerLib.HGLibSaveImageParam saveParam = new HGScannerLib.HGLibSaveImageParam();
|
||||
saveParam.jpegQuality = jpegQuality;
|
||||
saveParam.ocr = ocr ? 1 : 0;
|
||||
|
||||
return scannerLib.HGLib_SaveImage(image, savePath, saveParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始扫描
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @param eventCallback 扫描事件回调
|
||||
* @param imageCallback 扫描图像回调
|
||||
* @param param 回调参数
|
||||
* @return 是否开始扫描成功
|
||||
*/
|
||||
public static boolean startScan(HGScannerLib.HGLibDevice device,
|
||||
HGScannerLib.HGLibDeviceScanEventFunc eventCallback,
|
||||
HGScannerLib.HGLibDeviceScanImageFunc imageCallback,
|
||||
Pointer param) {
|
||||
return scannerLib.HGLib_StartDeviceScan(device, eventCallback, param, imageCallback, param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止扫描
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @return 是否停止扫描成功
|
||||
*/
|
||||
public static boolean stopScan(HGScannerLib.HGLibDevice device) {
|
||||
return scannerLib.HGLib_StopDeviceScan(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止扫描(异步)
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @return 是否停止扫描成功
|
||||
*/
|
||||
public static boolean stopScanAsync(HGScannerLib.HGLibDevice device) {
|
||||
return scannerLib.HGLib_StopDeviceScanAsyn(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备错误码
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @return 错误码
|
||||
*/
|
||||
public static int getDeviceOperateCode(HGScannerLib.HGLibDevice device) {
|
||||
return scannerLib.HGLib_GetDeviceOperateCode(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备状态
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @return 状态码
|
||||
*/
|
||||
public static int getDeviceStatus(HGScannerLib.HGLibDevice device) {
|
||||
return scannerLib.HGLib_GetDeviceStatus(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备是否有纸
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @return 是否有纸
|
||||
*/
|
||||
public static boolean isPaperOn(HGScannerLib.HGLibDevice device) {
|
||||
return scannerLib.HGLib_DeviceIsPaperOn(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备是否在线
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @return 是否在线
|
||||
*/
|
||||
public static boolean isOnline(HGScannerLib.HGLibDevice device) {
|
||||
return scannerLib.HGLib_GetDeviceIsOnline(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置设备参数
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @param option 配置名,参考HGLIB_OPTION_NAME_*
|
||||
* @param value 参数值
|
||||
* @return 是否设置成功
|
||||
*/
|
||||
public static boolean setDeviceParam(HGScannerLib.HGLibDevice device, int option, int value) {
|
||||
Memory memory = new Memory(4);
|
||||
memory.setInt(0, value);
|
||||
return scannerLib.HGLib_SetDeviceParam(device, option, memory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置设备参数
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @param option 配置名,参考HGLIB_OPTION_NAME_*
|
||||
* @param value 参数值
|
||||
* @return 是否设置成功
|
||||
*/
|
||||
public static boolean setDeviceParam(HGScannerLib.HGLibDevice device, int option, double value) {
|
||||
Memory memory = new Memory(8);
|
||||
memory.setDouble(0, value);
|
||||
return scannerLib.HGLib_SetDeviceParam(device, option, memory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置设备参数
|
||||
*
|
||||
* @param device 设备句柄
|
||||
* @param option 配置名,参考HGLIB_OPTION_NAME_*
|
||||
* @param value 参数值
|
||||
* @return 是否设置成功
|
||||
*/
|
||||
public static boolean setDeviceParam(HGScannerLib.HGLibDevice device, int option, boolean value) {
|
||||
Memory memory = new Memory(4);
|
||||
memory.setInt(0, value ? 1 : 0);
|
||||
return scannerLib.HGLib_SetDeviceParam(device, option, memory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 克隆图像
|
||||
*
|
||||
* @param image 源图像句柄
|
||||
* @param type 图像类型,参考HGLIB_IMGTYPE_*
|
||||
* @param origin 图像数据排列方式,参考HGLIB_IMGORIGIN_*
|
||||
* @return 克隆后的图像句柄
|
||||
*/
|
||||
public static HGScannerLib.HGLibImage cloneImage(HGScannerLib.HGLibImage image, int type, int origin) {
|
||||
return scannerLib.HGLib_CloneImage(image, type, origin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放图像
|
||||
*
|
||||
* @param image 图像句柄
|
||||
* @return 是否释放成功
|
||||
*/
|
||||
public static boolean releaseImage(HGScannerLib.HGLibImage image) {
|
||||
return scannerLib.HGLib_ReleaseImage(image);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图像OCR文本
|
||||
*
|
||||
* @param image 图像句柄
|
||||
* @return OCR文本
|
||||
*/
|
||||
public static String getOcrText(HGScannerLib.HGLibImage image) {
|
||||
return scannerLib.HGLib_GetOcrText(image);
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放OCR文本
|
||||
*
|
||||
* @param ocrText OCR文本
|
||||
* @return 是否释放成功
|
||||
*/
|
||||
public static boolean releaseOcrText(String ocrText) {
|
||||
return scannerLib.HGLib_ReleaseOcrText(ocrText);
|
||||
}
|
||||
|
||||
/**
|
||||
* 内存拷贝
|
||||
*
|
||||
* @param dest 目标地址
|
||||
* @param src 源地址
|
||||
* @param size 拷贝大小
|
||||
* @return 是否拷贝成功
|
||||
*/
|
||||
public static boolean memoryCopy(Pointer dest, Pointer src, int size) {
|
||||
return scannerLib.HGLib_MemoryCopy(dest, src, size);
|
||||
}
|
||||
}
|
||||
165
src/main/resources/c/HGDef.h
Normal file
165
src/main/resources/c/HGDef.h
Normal file
@ -0,0 +1,165 @@
|
||||
#ifndef __HGDEF_H__
|
||||
#define __HGDEF_H__
|
||||
|
||||
/****************************************************************************
|
||||
* Platform Dependent Definitions and Typedefs *
|
||||
****************************************************************************/
|
||||
|
||||
/* Microsoft C/C++ Compiler */
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) || defined (_WINDOWS)
|
||||
|
||||
#define HG_CMP_MSC
|
||||
#if defined(_WIN64) || defined(WIN64)
|
||||
#define HG_64BIT
|
||||
#elif defined(_WIN32) || defined(WIN32)
|
||||
#define HG_32BIT
|
||||
#endif
|
||||
|
||||
/* Apple Compiler (which is GNU now) */
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
#define HG_CMP_XCODE
|
||||
#define HG_64BIT
|
||||
|
||||
/* GNU C/C++ Compiler */
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
#define HG_CMP_GNU
|
||||
#if defined(__alpha__) || defined(__ia64__) || defined(__ppc64__) || defined(__s390x__) || defined(__x86_64__)
|
||||
#define HG_64BIT
|
||||
#else
|
||||
#define HG_32BIT
|
||||
#endif
|
||||
|
||||
/* Unrecognized */
|
||||
#else
|
||||
|
||||
#error Unrecognized compiler
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* type defines */
|
||||
typedef void HGVoid;
|
||||
typedef char HGChar;
|
||||
typedef unsigned char HGByte;
|
||||
typedef short HGShort;
|
||||
typedef unsigned short HGUShort;
|
||||
typedef int HGInt;
|
||||
typedef unsigned int HGUInt;
|
||||
typedef long long HGLonglong;
|
||||
typedef unsigned long long HGULonglong;
|
||||
typedef void* HGPointer;
|
||||
typedef HGInt HGBool;
|
||||
typedef float HGFloat;
|
||||
typedef double HGDouble;
|
||||
#ifdef HG_64BIT
|
||||
typedef HGLonglong HGSize;
|
||||
typedef HGULonglong HGUSize;
|
||||
#else
|
||||
typedef HGInt HGSize;
|
||||
typedef HGUInt HGUSize;
|
||||
#endif
|
||||
|
||||
typedef HGUInt HGColor;
|
||||
|
||||
#define HG_MAKECOLOR(r, g, b, a) (HGColor)(((HGUInt)a << 24) | ((HGUInt)b << 16) | ((HGUInt)g << 8) | (HGUInt)r)
|
||||
#define HG_GETCOLOR_R(color) (HGUInt)((HGColor)color & 0xFF)
|
||||
#define HG_GETCOLOR_G(color) (HGUInt)(((HGColor)color >> 8) & 0xFF)
|
||||
#define HG_GETCOLOR_B(color) (HGUInt)(((HGColor)color >> 16) & 0xFF)
|
||||
#define HG_GETCOLOR_A(color) (HGUInt)(((HGColor)color >> 24) & 0xFF)
|
||||
|
||||
/* error code */
|
||||
typedef HGUInt HGResult;
|
||||
|
||||
#define HGTRUE 1
|
||||
#define HGFALSE 0
|
||||
|
||||
#ifndef HGMAX
|
||||
#define HGMAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef HGMIN
|
||||
#define HGMIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
#ifdef __cplusplus
|
||||
#define HGEXPORT extern "C"
|
||||
#else
|
||||
#define HGEXPORT
|
||||
#endif /* __cplusplus */
|
||||
#define HGAPI __stdcall
|
||||
#define HGAPIV __cdecl
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
#define HGEXPORT extern "C"
|
||||
#else
|
||||
#define HGEXPORT
|
||||
#endif /* __cplusplus */
|
||||
#define HGAPI
|
||||
#define HGAPIV
|
||||
#endif
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
#include <windows.h>
|
||||
typedef HWND HGWindow;
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
typedef class QWidget* HGWindow;
|
||||
#else
|
||||
typedef void* HGWindow;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
#define HG_SEP_CHAR '\\'
|
||||
#define HG_SEP_STRING "\\"
|
||||
#else
|
||||
#define HG_SEP_CHAR '/'
|
||||
#define HG_SEP_STRING "/"
|
||||
#endif
|
||||
|
||||
#define HG_DECLARE_HANDLE(name) struct name##__{int unused;}; typedef struct name##__ *name
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(4)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HGInt left;
|
||||
HGInt top;
|
||||
HGInt right;
|
||||
HGInt bottom;
|
||||
}HGRect;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HGFloat left;
|
||||
HGFloat top;
|
||||
HGFloat right;
|
||||
HGFloat bottom;
|
||||
}HGRectF;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HGInt x;
|
||||
HGInt y;
|
||||
}HGPoint;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HGFloat x;
|
||||
HGFloat y;
|
||||
}HGPointF;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif /* __HGDEF_H__ */
|
||||
745
src/main/resources/c/HGScannerLib.h
Normal file
745
src/main/resources/c/HGScannerLib.h
Normal file
@ -0,0 +1,745 @@
|
||||
#ifndef __HGSCANNERLIB_H__
|
||||
#define __HGSCANNERLIB_H__
|
||||
|
||||
#include "HGDef.h"
|
||||
|
||||
HG_DECLARE_HANDLE(HGLibImage);
|
||||
HG_DECLARE_HANDLE(HGLibDevice);
|
||||
|
||||
/* 1位黑白图 */
|
||||
#define HGLIB_IMGTYPE_BINARY 1L
|
||||
/* 8位灰度图 */
|
||||
#define HGLIB_IMGTYPE_GRAY 2L
|
||||
/* 24位真彩色,B8G8R8格式 */
|
||||
#define HGLIB_IMGTYPE_BGR 3L
|
||||
/* 24位真彩色,R8G8B8格式 */
|
||||
#define HGLIB_IMGTYPE_RGB 4L
|
||||
/* 32位真彩色,带Alpha通道,B8G8R8A8格式 */
|
||||
#define HGLIB_IMGTYPE_BGRA 5L
|
||||
/* 32位真彩色,带Alpha通道,R8G8B8A8格式 */
|
||||
#define HGLIB_IMGTYPE_RGBA 6L
|
||||
|
||||
/* 图像数据保存方式 */
|
||||
#define HGLIB_IMGORIGIN_TOP 1L
|
||||
#define HGLIB_IMGORIGIN_BOTTOM 2L
|
||||
|
||||
/* TIFF压缩方式 */
|
||||
#define HGLIB_TIFFCOMPRESSION_NONE 1L
|
||||
#define HGLIB_TIFFCOMPRESSION_CCITTFAX4 2L
|
||||
#define HGLIB_TIFFCOMPRESSION_LZW 3L
|
||||
#define HGLIB_TIFFCOMPRESSION_JPEG 4L
|
||||
|
||||
/* 设备错误码 */
|
||||
#define HGLIB_DEV_OPERATECODE_GOOD 0L /* everything A-OK */
|
||||
#define HGLIB_DEV_OPERATECODE_UNSUPPORTED 1L /* operation is not supported */
|
||||
#define HGLIB_DEV_OPERATECODE_CANCELLED 2L /* operation was cancelled */
|
||||
#define HGLIB_DEV_OPERATECODE_BUSY 3L /* device is busy; try again later */
|
||||
#define HGLIB_DEV_OPERATECODE_INVAL 4L /* data is invalid (includes no dev at open) */
|
||||
#define HGLIB_DEV_OPERATECODE_EOF 5L /* no more data available (end-of-file) */
|
||||
#define HGLIB_DEV_OPERATECODE_JAMMED 6L /* document feeder jammed */
|
||||
#define HGLIB_DEV_OPERATECODE_NO_DOCS 7L /* document feeder out of documents */
|
||||
#define HGLIB_DEV_OPERATECODE_COVER_OPEN 8L /* scanner cover is open */
|
||||
#define HGLIB_DEV_OPERATECODE_IO_ERROR 9L /* error during device I/O */
|
||||
#define HGLIB_DEV_OPERATECODE_NO_MEM 10L /* out of memory */
|
||||
#define HGLIB_DEV_OPERATECODE_ACCESS_DENIED 11L /* access to resource has been denied */
|
||||
// 1:软件逻辑错误
|
||||
#define HGLIB_DEV_OPERATECODE_INVALID_PARAMETER 0x100 // 非法的参数调用
|
||||
#define HGLIB_DEV_OPERATECODE_ERR_USER_CANCELED 0x101 // 用户取消了操作
|
||||
#define HGLIB_DEV_OPERATECODE_INSUFFICIENT_MEMORY 0x102 // 分配的内存不足
|
||||
#define HGLIB_DEV_OPERATECODE_ACCESS_DENIED 0x103 // 访问被拒绝
|
||||
#define HGLIB_DEV_OPERATECODE_IO_PENDING 0x104 // 异步访问,数据稍后返回
|
||||
#define HGLIB_DEV_OPERATECODE_ERR_NOT_EXACT 0x105 // 数据不精确,精确的数据已经在同一缓存中返回
|
||||
#define HGLIB_DEV_OPERATECODE_ERR_CONFIGURATION_CHANGED 0x106 // 设备的配置项发生改变,需要重新加载显示
|
||||
#define HGLIB_DEV_OPERATECODE_ERR_NOT_OPEN 0x107 // 设备未打开
|
||||
#define HGLIB_DEV_OPERATECODE_ERR_NOT_START 0x108 // 设备没有启动
|
||||
#define HGLIB_DEV_OPERATECODE_ERR_NOT_ANY_MORE 0x109 // 用于回调返回,在本次扫描中,对相同操作不再回调
|
||||
#define HGLIB_DEV_OPERATECODE_ERR_NO_DATA 0x10A // 没有数据
|
||||
#define HGLIB_DEV_OPERATECODE_HAS_DATA_YET 0x10B // 有数据未被读取(异步操作中)
|
||||
#define HGLIB_DEV_OPERATECODE_OUT_OF_RANGE 0x10C // 相关操作超出范围
|
||||
#define HGLIB_DEV_OPERATECODE_IO 0x10D // IO错误
|
||||
#define HGLIB_DEV_OPERATECODE_TIMEOUT 0x10E // 超时错误
|
||||
#define HGLIB_DEV_OPERATECODE_OPEN_FILE_FAILED 0x10F // 打开本地文件失败
|
||||
#define HGLIB_DEV_OPERATECODE_CREATE_FILE_FAILED 0x110 // 创建本地文件失败
|
||||
#define HGLIB_DEV_OPERATECODE_WRITE_FILE_FAILED 0x111 // 写本地文件失败
|
||||
#define HGLIB_DEV_OPERATECODE_DATA_DAMAGED 0x112 // 数据损坏(内置资源数据损坏)
|
||||
#define HGLIB_DEV_OPERATECODE_OPENED_BY_OTHER_PROCESS 0x113 // 设备已经被其它进程打开占用
|
||||
#define HGLIB_DEV_OPERATECODE_LANG_PAK_LOST 0x114 // 语言包丢失
|
||||
#define HGLIB_DEV_OPERATECODE_RELOAD_IMAGE_PARAM 0x115 // 配置成功,会影响图像参数,应用需要重新加载图像参数 - added on 2023-02-18 for XSANE修改影响图像参数的属性后扫描崩溃的问题
|
||||
#define HGLIB_DEV_OPERATECODE_RELOAD_OPT_PARAM 0x116 // SCANNER_ERR_CONFIGURATION_CHANGED + SCANNER_ERR_RELOAD_IMAGE_PARAM - added on 2023-02-18 for XSANE修改影响图像参数的属性后扫描崩溃的问题
|
||||
#define HGLIB_DEV_OPERATECODE_IMAGE_PROC_FATAL 0x117 // 图像处理失败
|
||||
#define HGLIB_DEV_OPERATECODE_SCANNER_ERR_IMAGE_ORDER 0x11C // 图像顺序错误
|
||||
// 2:USB错误
|
||||
#define HGLIB_DEV_OPERATECODE_USB_INIT_FAILED 0x5B00 // libusb_init 失败
|
||||
#define HGLIB_DEV_OPERATECODE_USB_REGISTER_PNP_FAILED 0x5B01 // 注册USB监听事件失败
|
||||
#define HGLIB_DEV_OPERATECODE_USB_CLAIM_INTERFACE_FAILED 0x5B02 // failed in calling libusb_claim_interface
|
||||
// 3:硬件错误
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_NOT_FOUND 0x0DE00 // 设备未找到
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_NOT_SUPPORT 0x0DE01 // 设备不支持该操作
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_BUSY 0x0DE02 // 设备正忙,不能响应该操作
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_SLEEPING 0x0DE03 // 设备处于睡眠状态
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_COUNT_MODE 0x0DE04 // 设备处于计数扫描状态
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_STOPPED 0x0DE05 // 扫描停止
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_COVER_OPENNED 0x0DE06 // 扫描仪盖板呈打开状态
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_NO_PAPER 0x0DE07 // 没有纸张输入
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_FEEDING_PAPER 0x0DE08 // 搓纸失败
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_DOUBLE_FEEDING 0x0DE09 // 双张检测
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_PAPER_JAMMED 0x0DE0A // 卡纸
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_STAPLE_ON 0x0DE0B // 有钉书钉
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_PAPER_SKEW 0x0DE0C // 纸张倾斜
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_SIZE_CHECK 0x0DE0D // 尺寸检测错误
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_DOGEAR 0x0DE0E // 纸张有折角
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_NO_IMAGE 0x0DE0F // 设备没取到图
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_SCANN_ERROR 0x0DE10 // 设备扫图失败
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_PC_BUSY 0x0DE11 // PC繁忙或出错
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_ISLOCK 0x0DE12 // 设备被锁定
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_UPGRADE_SUCCESSFUL 0x0DE13 // 固件升级成功
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_UPGRADE_FAIL 0x0DE14 // 固件升级失败+
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_AUTO_FAIL_OVER 0x0DE15 // 设备平场自动校正结束
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_AUTO_FAIL_INFO 0x0DE16 // 设备平场自动校正信息传输
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_DISTORTION 0x0DE17 // 畸变修正失败
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_MAYBE_IS_HOLE 0x0DE18 // 纸张有孔洞
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_DEVS_BOOTING 0x0DE19 // 请稍等 - 设备正在准备
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_UNKNOWN_STATUS 0x0DE1A // 设备处于未知状态
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_LENS_DIRTY 0x0DE1B // 镜头脏污
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_OUT_BOUNDARY 0x0DE1C // 纸张超出边界
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_GET_CT_FAIL 0x0DE1D // 获取校正数据失败
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_JPEG_COMPRESS_FAIL 0x0DE1E // JPEG压缩失败
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_JPEG_FINISH_FAIL 0x0DE1F // JPEG失败
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_THUNK_DATA 0x0DE20 //
|
||||
#define HGLIB_DEV_OPERATECODE_DEVICE_WRONG_FIRMWARE_INFO 0x0DE21 // 获取版本信息异常,请重启软件
|
||||
|
||||
// 4:设备状态码
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_UNKNOW -1 // 未知状态
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_NO_PAPER 0 // 没有纸张输入
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_PAPER 1 // 有纸
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_NOT_FOUND 2 // 设备未找到
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_BUSY 3 // 设备正忙,不能响应该操作
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_SLEEPING 4 // 设备处于睡眠状态
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_COUNT_MODE 5 // 设备处于计数扫描状态
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_COVER_OPENNED 6 // 扫描仪盖板呈打开状态
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_FEEDING_PAPER 7 // 搓纸失败
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_DOUBLE_FEEDING 8 // 双张检测
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_PAPER_JAMMED 9 // 卡纸
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_STAPLE_ON 10 // 有钉书钉
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_PAPER_SKEW 11 // 纸张倾斜
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_DOGEAR 12 // 纸张有折角
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_NO_IMAGE 13 // 设备没取到图
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_SCANN_ERROR 14 // 设备扫图失败
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_PC_BUSY 15 // PC繁忙或出错
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_MAYBE_IS_HOLE 16 // 纸张有孔洞
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_DEVS_BOOTING 17 // 请稍等 - 设备正在准备
|
||||
#define HGLIB_DEV_STATUSCODE_DEVICE_LENS_DIRTY 18 // 镜头脏污
|
||||
|
||||
/* 设备热拔插事件 */
|
||||
#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_GROUP_NAME_BASESETTING 1L
|
||||
// 亮度
|
||||
#define HGLIB_GROUP_NAME_BRIGHTNESS 2L
|
||||
// 图像处理
|
||||
#define HGLIB_GROUP_NAME_IMAGEPROCESS 3L
|
||||
// 送纸方式设置
|
||||
#define HGLIB_GROUP_NAME_PAPERFEEDING 4L
|
||||
|
||||
/* 配置名 */
|
||||
#define HGLIB_OPTION_NAME_UNKNOWN 0L
|
||||
// "多流输出"
|
||||
#define HGLIB_OPTION_NAME_DLSC 1L
|
||||
// "多流输出类型"
|
||||
#define HGLIB_OPTION_NAME_DLSCLX 2L
|
||||
// "颜色模式"
|
||||
#define HGLIB_OPTION_NAME_YSMS 3L
|
||||
// "黑白图像阈值"
|
||||
#define HGLIB_OPTION_NAME_HBTXYZ 4L
|
||||
// "灰度或黑白图像 - 除色"
|
||||
#define HGLIB_OPTION_NAME_HDHHBTX_CS 5L
|
||||
// "24位彩色图像 - 多流输出除红"
|
||||
#define HGLIB_OPTION_NAME_24WCSTX_DLSCCH 6L
|
||||
// "24位彩色图像 - 答题卡除红"
|
||||
#define HGLIB_OPTION_NAME_24WCSTX_DTKCH 7L
|
||||
// "背景移除"
|
||||
#define HGLIB_OPTION_NAME_BJYC 8L
|
||||
// "背景色彩浮动范围"
|
||||
#define HGLIB_OPTION_NAME_BJSCFDFW 9L
|
||||
// "锐化与模糊"
|
||||
#define HGLIB_OPTION_NAME_RHYMH 10L
|
||||
// "去除摩尔纹"
|
||||
#define HGLIB_OPTION_NAME_QCMW 11L
|
||||
// "除网纹"
|
||||
#define HGLIB_OPTION_NAME_CWW 12L
|
||||
// "错误扩散"
|
||||
#define HGLIB_OPTION_NAME_CWKS 13L
|
||||
// "黑白图像噪点优化"
|
||||
#define HGLIB_OPTION_NAME_HBTXZDYH 14L
|
||||
// "噪点优化尺寸"
|
||||
#define HGLIB_OPTION_NAME_ZDYHCC 15L
|
||||
// "纸张尺寸"
|
||||
#define HGLIB_OPTION_NAME_ZZCC 16L
|
||||
// "自定义扫描区域"
|
||||
#define HGLIB_OPTION_NAME_ZDYSMQY 17L
|
||||
// "扫描区域左侧(mm)"
|
||||
#define HGLIB_OPTION_NAME_SMQYZCmm 18L
|
||||
// "扫描区域右侧(mm)"
|
||||
#define HGLIB_OPTION_NAME_SMQYYCmm 19L
|
||||
// "扫描区域上侧(mm)"
|
||||
#define HGLIB_OPTION_NAME_SMQYSCmm 20L
|
||||
// "扫描区域下侧(mm)"
|
||||
#define HGLIB_OPTION_NAME_SMQYXCmm 21L
|
||||
// "尺寸检测"
|
||||
#define HGLIB_OPTION_NAME_CCJC 22L
|
||||
// "扫描页面"
|
||||
#define HGLIB_OPTION_NAME_SMYM 23L
|
||||
// "跳过空白页灵敏度"
|
||||
#define HGLIB_OPTION_NAME_TGKBYLMD 24L
|
||||
// "分纸强度"
|
||||
#define HGLIB_OPTION_NAME_FZQD 25L
|
||||
// "休眠时间"
|
||||
#define HGLIB_OPTION_NAME_XMSJ 26L
|
||||
// "分辨率"
|
||||
#define HGLIB_OPTION_NAME_FBL 27L
|
||||
// "画质"
|
||||
#define HGLIB_OPTION_NAME_HZ 28L
|
||||
// "交换正反面"
|
||||
#define HGLIB_OPTION_NAME_JHZFM 29L
|
||||
// "图像拆分"
|
||||
#define HGLIB_OPTION_NAME_TXCF 30L
|
||||
// "自动纠偏"
|
||||
#define HGLIB_OPTION_NAME_ZDJP 31L
|
||||
// "启用色调曲线"
|
||||
#define HGLIB_OPTION_NAME_QYSDQX 32L
|
||||
// "亮度值"
|
||||
#define HGLIB_OPTION_NAME_LDZ 33L
|
||||
// "对比度"
|
||||
#define HGLIB_OPTION_NAME_DBD 34L
|
||||
// "伽马值"
|
||||
#define HGLIB_OPTION_NAME_GMZ 35L
|
||||
// "照片模式"
|
||||
#define HGLIB_OPTION_NAME_ZPMS 36L
|
||||
// "消除黑框"
|
||||
#define HGLIB_OPTION_NAME_XCHK 37L
|
||||
// "深色样张"
|
||||
#define HGLIB_OPTION_NAME_SSYZ 38L
|
||||
// "阈值"
|
||||
#define HGLIB_OPTION_NAME_YZ 39L
|
||||
// "背景抗噪等级"
|
||||
#define HGLIB_OPTION_NAME_BJKZDJ 40L
|
||||
// "边缘缩进"
|
||||
#define HGLIB_OPTION_NAME_BYSJ 41L
|
||||
// "背景填充方式"
|
||||
#define HGLIB_OPTION_NAME_BJTCFS 42L
|
||||
// "防止渗透"
|
||||
#define HGLIB_OPTION_NAME_FZST 43L
|
||||
// "防止渗透等级"
|
||||
#define HGLIB_OPTION_NAME_FZSTDJ 44L
|
||||
// "穿孔移除—左侧"
|
||||
#define HGLIB_OPTION_NAME_CKYCZC 45L
|
||||
// #"左侧穿孔搜索范围占幅面比例"
|
||||
#define HGLIB_OPTION_NAME_ZCCKSSFWZFMBL 46L
|
||||
// "穿孔移除—右侧"
|
||||
#define HGLIB_OPTION_NAME_CKYCYC 47L
|
||||
// #"右侧穿孔搜索范围占幅面比例"
|
||||
#define HGLIB_OPTION_NAME_YCCKSSFWZFMBL 48L
|
||||
// "穿孔移除—上侧"
|
||||
#define HGLIB_OPTION_NAME_CKYCSC 49L
|
||||
// #"上侧穿孔搜索范围占幅面比例"
|
||||
#define HGLIB_OPTION_NAME_SCCKSSFWZFMBL 50L
|
||||
// "穿孔移除—下侧"
|
||||
#define HGLIB_OPTION_NAME_CKYCXC 51L
|
||||
// #"下侧穿孔搜索范围占幅面比例"
|
||||
#define HGLIB_OPTION_NAME_XCCKSSFWZFMBL 52L
|
||||
// "色彩填充"
|
||||
#define HGLIB_OPTION_NAME_SCTC 53L
|
||||
// "超声波检测"
|
||||
#define HGLIB_OPTION_NAME_CSBJC 54L
|
||||
// "双张图片处理"
|
||||
#define HGLIB_OPTION_NAME_SZTPCL 55L
|
||||
// "装订检测"
|
||||
#define HGLIB_OPTION_NAME_ZDJC 56L
|
||||
// "扫描张数"
|
||||
#define HGLIB_OPTION_NAME_SMZS 57L
|
||||
// "扫描数量"
|
||||
#define HGLIB_OPTION_NAME_SMSL 58L
|
||||
// "文稿方向"
|
||||
#define HGLIB_OPTION_NAME_WGFX 59L
|
||||
// "背面旋转180°"
|
||||
#define HGLIB_OPTION_NAME_BMXZ180 60L
|
||||
// "折角检测"
|
||||
#define HGLIB_OPTION_NAME_ZJJC 61L
|
||||
// "折角大小"
|
||||
#define HGLIB_OPTION_NAME_ZJDX 62L
|
||||
// "歪斜检测"
|
||||
#define HGLIB_OPTION_NAME_WXJC 63L
|
||||
// "歪斜容忍度"
|
||||
#define HGLIB_OPTION_NAME_WXRRD 64L
|
||||
// 自动分纸强度
|
||||
#define HGLIB_OPTION_NAME_ZDCZQD 65L
|
||||
// 进纸失败率
|
||||
#define HGLIB_OPTION_NAME_CZYZ 66L
|
||||
// 待纸扫描
|
||||
#define HGLIB_OPTION_NAME_DZSM 67L
|
||||
// 黑白图像反色输出(正常颜色为:0 - 黑色;1 - 白色)
|
||||
#define HGLIB_OPTION_NAME_HBTXFSSC 68L
|
||||
// 对折模式
|
||||
#define HGLIB_OPTION_NAME_DZMS 69L
|
||||
// 色偏校正
|
||||
#define HGLIB_OPTION_NAME_SPJZ 70L
|
||||
// 待纸扫描退出时间
|
||||
#define HGLIB_OPTION_NAME_DZSMTCSJ 71L
|
||||
// 跳过空白页
|
||||
#define HGLIB_OPTION_NAME_TGKBY 72L
|
||||
// 镜头脏污检测
|
||||
#define HGLIB_OPTION_NAME_JTZWJC 73L
|
||||
// 穿孔移除
|
||||
#define HGLIB_OPTION_NAME_CKYC 74L
|
||||
// 穿孔搜索范围占幅面比例
|
||||
#define HGLIB_OPTION_NAME_CKSSFWZFMBL 75L
|
||||
// 边界检测
|
||||
#define HGLIB_OPTION_NAME_BJJC 76L
|
||||
// 扫描传感器信号强度
|
||||
#define HGLIB_OPTION_NAME_SMCGQXHQD 77L
|
||||
// 跳过空白页边缘宽度
|
||||
#define HGLIB_OPTION_NAME_TGKBYBYKD 78L
|
||||
|
||||
/* 配置枚举值 */
|
||||
// "无"
|
||||
#define HGLIB_OPTION_ENUMVALUE_DLSCLX_W 1L
|
||||
// "彩色+灰度+黑白"
|
||||
#define HGLIB_OPTION_ENUMVALUE_DLSCLX_CS_HD_HB 2L
|
||||
// "彩色+灰度"
|
||||
#define HGLIB_OPTION_ENUMVALUE_DLSCLX_CS_HD 3L
|
||||
// "彩色+黑白"
|
||||
#define HGLIB_OPTION_ENUMVALUE_DLSCLX_CS_HB 4L
|
||||
// "灰度+黑白"
|
||||
#define HGLIB_OPTION_ENUMVALUE_DLSCLX_HD_HB 5L
|
||||
// "24位彩色"
|
||||
#define HGLIB_OPTION_ENUMVALUE_YSMS_24WCS 6L
|
||||
// "256级灰度"
|
||||
#define HGLIB_OPTION_ENUMVALUE_YSMS_256JHD 7L
|
||||
// "黑白"
|
||||
#define HGLIB_OPTION_ENUMVALUE_YSMS_HB 8L
|
||||
// "颜色自动识别"
|
||||
#define HGLIB_OPTION_ENUMVALUE_YSMS_YSZDSB 9L
|
||||
// "不除色"
|
||||
#define HGLIB_OPTION_ENUMVALUE_HDHHBTX_CS_BCS 10L
|
||||
// "除红色"
|
||||
#define HGLIB_OPTION_ENUMVALUE_HDHHBTX_CS_CHS 11L
|
||||
// "除绿色"
|
||||
#define HGLIB_OPTION_ENUMVALUE_HDHHBTX_CS_CLS 12L
|
||||
// "除蓝色"
|
||||
#define HGLIB_OPTION_ENUMVALUE_HDHHBTX_CS_CHULANSE 13L
|
||||
// "红色增强"
|
||||
#define HGLIB_OPTION_ENUMVALUE_HDHHBTX_CS_HSZQ 14L
|
||||
// "绿色增强"
|
||||
#define HGLIB_OPTION_ENUMVALUE_HDHHBTX_CS_LSZQ 15L
|
||||
// "蓝色增强"
|
||||
#define HGLIB_OPTION_ENUMVALUE_HDHHBTX_CS_LANSEZENGQIANG 16L
|
||||
// "无"
|
||||
#define HGLIB_OPTION_ENUMVALUE_RHYMH_W 17L
|
||||
// "锐化"
|
||||
#define HGLIB_OPTION_ENUMVALUE_RHYMH_RH 18L
|
||||
// "进一步锐化"
|
||||
#define HGLIB_OPTION_ENUMVALUE_RHYMH_JYBRH 19L
|
||||
// "模糊"
|
||||
#define HGLIB_OPTION_ENUMVALUE_RHYMH_MH 20L
|
||||
// "进一步模糊"
|
||||
#define HGLIB_OPTION_ENUMVALUE_RHYMH_JYBMH 21L
|
||||
// "A3"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_A3 22L
|
||||
// "8开"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_8K 23L
|
||||
// "A4"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_A4 24L
|
||||
// "A4横向"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_A4HX 25L
|
||||
// "16开"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_16K 26L
|
||||
// "16开横向"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_16KHX 27L
|
||||
// "A5"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_A5 28L
|
||||
// "A5横向"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_A5HX 29L
|
||||
// "A6"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_A6 30L
|
||||
// "A6横向"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_A6HX 31L
|
||||
// "B4"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_B4 32L
|
||||
// "B5"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_B5 33L
|
||||
// "B5横向"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_B5HX 34L
|
||||
// "B6"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_B6 35L
|
||||
// "B6横向"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_B6HX 36L
|
||||
// "Letter"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_Letter 37L
|
||||
// "Letter横向"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_LetterHX 38L
|
||||
// "Double Letter"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_DoubleLetter 39L
|
||||
// "LEGAL"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_LEGAL 40L
|
||||
// "匹配原始尺寸"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_PPYSCC 41L
|
||||
// "最大扫描尺寸自动裁切"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_ZDSMCCZDCQ 42L
|
||||
// "最大扫描尺寸"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_ZDSMCC 43L
|
||||
// "三联试卷"
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZZCC_SLSJ 44L
|
||||
// "单面"
|
||||
#define HGLIB_OPTION_ENUMVALUE_SMYM_DM 45L
|
||||
// "双面"
|
||||
#define HGLIB_OPTION_ENUMVALUE_SMYM_SM 46L
|
||||
// "跳过空白页(通用)"
|
||||
#define HGLIB_OPTION_ENUMVALUE_SMYM_TGKBYTY 47L
|
||||
// "跳过空白页(发票纸)"
|
||||
#define HGLIB_OPTION_ENUMVALUE_SMYM_TGKBYFPZ 48L
|
||||
// "对折"
|
||||
#define HGLIB_OPTION_ENUMVALUE_SMYM_DZ 49L
|
||||
// "无"
|
||||
#define HGLIB_OPTION_ENUMVALUE_HZ_W 50L
|
||||
// "速度优先"
|
||||
#define HGLIB_OPTION_ENUMVALUE_HZ_SDYX 51L
|
||||
// "画质优先"
|
||||
#define HGLIB_OPTION_ENUMVALUE_HZ_HZYX 52L
|
||||
// "凸多边形"
|
||||
#define HGLIB_OPTION_ENUMVALUE_BJTCFS_TDBX 53L
|
||||
// "凹多边形"
|
||||
#define HGLIB_OPTION_ENUMVALUE_BJTCFS_ADBX 54L
|
||||
// "弱"
|
||||
#define HGLIB_OPTION_ENUMVALUE_FZSTDJ_R 55L
|
||||
// "较弱"
|
||||
#define HGLIB_OPTION_ENUMVALUE_FZSTDJ_JR 56L
|
||||
// "一般"
|
||||
#define HGLIB_OPTION_ENUMVALUE_FZSTDJ_YB 57L
|
||||
// "较强"
|
||||
#define HGLIB_OPTION_ENUMVALUE_FZSTDJ_JQ 58L
|
||||
// "强"
|
||||
#define HGLIB_OPTION_ENUMVALUE_FZSTDJ_Q 59L
|
||||
// "丢弃图像并停止扫描"
|
||||
#define HGLIB_OPTION_ENUMVALUE_SZTPCL_DQTXBTZSM 60L
|
||||
// "丢弃图像并继续扫描"
|
||||
#define HGLIB_OPTION_ENUMVALUE_SZTPCL_DQTXBJXSM 61L
|
||||
// "上传图像并停止扫描"
|
||||
#define HGLIB_OPTION_ENUMVALUE_SZTPCL_SCTXBTZSM 62L
|
||||
// "上传图像并继续扫描"
|
||||
#define HGLIB_OPTION_ENUMVALUE_SZTPCL_SCTXBJXSM 63L
|
||||
// "连续扫描"
|
||||
#define HGLIB_OPTION_ENUMVALUE_SMZS_LXSM 64L
|
||||
// "扫描指定张数"
|
||||
#define HGLIB_OPTION_ENUMVALUE_SMZS_SMZDZS 65L
|
||||
// "0°"
|
||||
#define HGLIB_OPTION_ENUMVALUE_WGFX_0 66L
|
||||
// "90°"
|
||||
#define HGLIB_OPTION_ENUMVALUE_WGFX_90 67L
|
||||
// "180°"
|
||||
#define HGLIB_OPTION_ENUMVALUE_WGFX_180 68L
|
||||
// "-90°"
|
||||
#define HGLIB_OPTION_ENUMVALUE_WGFX__90 69L
|
||||
// "自动文本方向识别°"
|
||||
#define HGLIB_OPTION_ENUMVALUE_WGFX_ZDWBFXSB 70L
|
||||
// "分纸强度-弱"
|
||||
#define HGLIB_OPTION_ENUMVALUE_FZQD_R 71L
|
||||
// "分纸强度-一般"
|
||||
#define HGLIB_OPTION_ENUMVALUE_FZQD_YB 72L
|
||||
// "分纸强度-强"
|
||||
#define HGLIB_OPTION_ENUMVALUE_FZQD_Q 73L
|
||||
// "不休眠"
|
||||
#define HGLIB_OPTION_ENUMVALUE_XMSJ_BXM 74L
|
||||
// "五分钟"
|
||||
#define HGLIB_OPTION_ENUMVALUE_XMSJ_WFZ 75L
|
||||
// "十分钟"
|
||||
#define HGLIB_OPTION_ENUMVALUE_XMSJ_SFZ 76L
|
||||
// "半小时"
|
||||
#define HGLIB_OPTION_ENUMVALUE_XMSJ_BXS 77L
|
||||
// "一小时"
|
||||
#define HGLIB_OPTION_ENUMVALUE_XMSJ_YXS 78L
|
||||
// "两小时"
|
||||
#define HGLIB_OPTION_ENUMVALUE_XMSJ_LXS 79L
|
||||
// "四小时"
|
||||
#define HGLIB_OPTION_ENUMVALUE_XMSJ_SXS 80L
|
||||
// 左右对折
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZYDZ 81L
|
||||
// 上下对折
|
||||
#define HGLIB_OPTION_ENUMVALUE_SXDZ 82L
|
||||
// 自动对折
|
||||
#define HGLIB_OPTION_ENUMVALUE_ZDDZ 83L
|
||||
// 待纸扫描退出时间15s
|
||||
#define HGLIB_OPTION_ENUMVALUE_DZSMTCSJ_15S 84L
|
||||
// 待纸扫描退出时间30s
|
||||
#define HGLIB_OPTION_ENUMVALUE_DZSMTCSJ_30S 85L
|
||||
// 待纸扫描退出时间60s
|
||||
#define HGLIB_OPTION_ENUMVALUE_DZSMTCSJ_60S 86L
|
||||
// 待纸扫描退出时间2min
|
||||
#define HGLIB_OPTION_ENUMVALUE_DZSMTCSJ_2MIN 87L
|
||||
// 待纸扫描退出时间4min
|
||||
#define HGLIB_OPTION_ENUMVALUE_DZSMTCSJ_4MIN 88L
|
||||
// 待纸扫描退出时间8min
|
||||
#define HGLIB_OPTION_ENUMVALUE_DZSMTCSJ_8MIN 89L
|
||||
// 跳过空白页-基于文件大小
|
||||
#define HGLIB_OPTION_ENUMVALUE_SMYM_TGKBYJYWJDX 90L
|
||||
// 上传图像并校验
|
||||
#define HGLIB_OPTION_ENUMVALUE_SZTPCL_SCTXBJY 91L
|
||||
// "正面"
|
||||
#define HGLIB_OPTION_ENUMVALUE_SMYM_ZM 93L
|
||||
// 背面
|
||||
#define HGLIB_OPTION_ENUMVALUE_SMYM_BM 94L
|
||||
|
||||
/* 配置值类型 */
|
||||
#define HGLIB_OPTION_VALUETYPE_INT 1L
|
||||
#define HGLIB_OPTION_VALUETYPE_ENUM 2L
|
||||
#define HGLIB_OPTION_VALUETYPE_DOUBLE 3L
|
||||
#define HGLIB_OPTION_VALUETYPE_BOOL 4L
|
||||
|
||||
/* 配置值范围类型 */
|
||||
#define HGLIB_OPTION_VALUERANGETYPE_NULL 0L
|
||||
#define HGLIB_OPTION_VALUERANGETYPE_INTLIST 1L
|
||||
#define HGLIB_OPTION_VALUERANGETYPE_ENUMLIST 2L
|
||||
#define HGLIB_OPTION_VALUERANGETYPE_DOUBLELIST 3L
|
||||
#define HGLIB_OPTION_VALUERANGETYPE_INTRANGE 4L
|
||||
#define HGLIB_OPTION_VALUERANGETYPE_DOUBLERANGE 5L
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(4)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HGUInt size; /* 结构体大小,必须初始化为sizeof(HGLibSaveImageParam) */
|
||||
HGUInt jpegQuality; /* jpeg下有效, 0-100 */
|
||||
HGUInt tiffCompression; /* tiff下有效, HGLIB_TIFFCOMPRESSION_* */
|
||||
HGUInt tiffJpegQuality; /* tiff且HGLIB_TIFFCOMPRESSION_JPEG下有效, 0-100 */
|
||||
HGBool ocr; /* 是否OCR,pdf和ofd格式有效 */
|
||||
HGFloat jp2Ratio; /* jp2压缩比 */
|
||||
}HGLibSaveImageParam;
|
||||
|
||||
/* 图像信息 */
|
||||
typedef struct
|
||||
{
|
||||
HGUInt width; /* 宽(像素),列数 */
|
||||
HGUInt height; /* 高(像素),行数 */
|
||||
HGUInt type; /* 类型,参见HGLIB_IMGTYPE_* */
|
||||
HGUInt widthStep; /* 每行的字节数 */
|
||||
HGUInt origin; /* 数据排列方式,参见HGLIB_IMGORIGIN_* */
|
||||
}HGLibImageInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HGInt* value;
|
||||
HGUInt count;
|
||||
}HGLibDeviceIntValueList;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HGUInt* value;
|
||||
HGUInt count;
|
||||
}HGLibDeviceEnumValueList;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HGDouble* value;
|
||||
HGUInt count;
|
||||
}HGLibDeviceDoubleValueList;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HGInt minValue;
|
||||
HGInt maxValue;
|
||||
}HGLibDeviceIntValueRange;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HGDouble minValue;
|
||||
HGDouble maxValue;
|
||||
}HGLibDeviceDoubleValueRange;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HGUInt option; /* 配置名, 参见HGLIB_OPTION_NAME_* */
|
||||
|
||||
HGUInt type; /* 值类型, 参见HGLIB_OPTION_VALUETYPE_* */
|
||||
union
|
||||
{
|
||||
HGInt intValue;
|
||||
HGUInt enumValue;
|
||||
HGDouble doubleValue;
|
||||
HGBool boolValue;
|
||||
};
|
||||
|
||||
HGUInt rangeType; /* 值范围类型, 参见HGLIB_OPTION_VALUERANGETYPE_* */
|
||||
union
|
||||
{
|
||||
HGLibDeviceIntValueList intValueList;
|
||||
HGLibDeviceEnumValueList enumValueList;
|
||||
HGLibDeviceDoubleValueList doubleValueList;
|
||||
HGLibDeviceIntValueRange intValueRange;
|
||||
HGLibDeviceDoubleValueRange doubleValueRange;
|
||||
};
|
||||
}HGLibDeviceParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HGUInt group; /* 组名, 参见HGLIB_GROUP_NAME_* */
|
||||
HGLibDeviceParam* param;
|
||||
HGUInt paramCount;
|
||||
}HGLibDeviceParamGroup;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
/* 设备热拔插回调
|
||||
* event: HGLIB_DEVHOTPLUG_EVENT_*
|
||||
* deviceName: 设备名
|
||||
* param: 回调参数
|
||||
*/
|
||||
typedef void (HGAPI *HGLibDeviceHotPlugEventFunc)(HGUInt event, const HGChar *deviceName, HGPointer param);
|
||||
|
||||
/* 设备扫描事件回调
|
||||
* device: 设备句柄
|
||||
* event: HGLIB_DEVSCAN_EVENT_*
|
||||
* operateCode: 设备错误码, HGLIB_DEVSCAN_EVENT_INFO下有效
|
||||
* info: 扫描信息, HGLIB_DEVSCAN_EVENT_INFO下有效
|
||||
* param: 回调参数
|
||||
*/
|
||||
typedef void (HGAPI *HGLibDeviceScanEventFunc)(HGLibDevice device, HGUInt event, HGInt operateCode, const HGChar *info, HGPointer param);
|
||||
|
||||
/* 设备扫描图像回调
|
||||
* device: 设备句柄
|
||||
* image: 图像句柄, 不要调用HGLib_ReleaseImage释放, 回调执行后会自动释放
|
||||
* param: 回调参数
|
||||
*/
|
||||
typedef void (HGAPI *HGLibDeviceScanImageFunc)(HGLibDevice device, HGLibImage image, HGPointer param);
|
||||
|
||||
/* 内存拷贝 */
|
||||
HGEXPORT HGBool HGAPI HGLib_MemoryCopy(HGVoid *dest, const HGVoid *src, HGUInt size);
|
||||
|
||||
/* 加载图像 */
|
||||
HGEXPORT HGLibImage HGAPI HGLib_LoadImage(const HGChar *filePath);
|
||||
|
||||
/* 克隆图像 */
|
||||
HGEXPORT HGLibImage HGAPI HGLib_CloneImage(HGLibImage image, HGUInt type, HGUInt origin);
|
||||
|
||||
/* 获取图像数据 */
|
||||
HGEXPORT HGByte* HGAPI HGLib_GetImageData(HGLibImage image);
|
||||
|
||||
/* 获取图像信息 */
|
||||
HGEXPORT HGBool HGAPI HGLib_GetImageInfo(HGLibImage image, HGLibImageInfo* imageInfo);
|
||||
|
||||
/* 获取图像DPI */
|
||||
HGEXPORT HGBool HGAPI HGLib_GetImageDpi(HGLibImage image, HGUInt *xDpi, HGUInt *yDpi);
|
||||
|
||||
/* 保存图像 */
|
||||
HGEXPORT HGBool HGAPI HGLib_SaveImage(HGLibImage image, const HGChar* savePath, const HGLibSaveImageParam* saveParam);
|
||||
|
||||
/* 释放图像 */
|
||||
HGEXPORT HGBool HGAPI HGLib_ReleaseImage(HGLibImage image);
|
||||
|
||||
/* 获取OCR文本 */
|
||||
HGEXPORT HGChar* HGAPI HGLib_GetOcrText(HGLibImage image);
|
||||
|
||||
/* 销毁OCR文本 */
|
||||
HGEXPORT HGBool HGAPI HGLib_ReleaseOcrText(HGChar* ocrText);
|
||||
|
||||
/* 初始化扫描仪 */
|
||||
HGEXPORT HGBool HGAPI HGLib_InitDevice(HGLibDeviceHotPlugEventFunc func, HGPointer param);
|
||||
|
||||
/* 反初始化扫描仪 */
|
||||
HGEXPORT HGBool HGAPI HGLib_DeinitDevice();
|
||||
|
||||
/* 获取扫描仪名称列表 */
|
||||
HGEXPORT HGChar** HGAPI HGLib_GetDeviceNameList();
|
||||
|
||||
/* 销毁扫描仪名称列表 */
|
||||
HGEXPORT HGBool HGAPI HGLib_ReleaseDeviceNameList(HGChar** deviceName);
|
||||
|
||||
/* 打开设备 */
|
||||
HGEXPORT HGLibDevice HGAPI HGLib_OpenDevice(const HGChar *deviceName);
|
||||
|
||||
/* 关闭设备 */
|
||||
HGEXPORT HGBool HGAPI HGLib_CloseDevice(HGLibDevice device);
|
||||
|
||||
/* 获取设备型号 */
|
||||
HGEXPORT HGBool HGAPI HGLib_GetDeviceType(HGLibDevice device, HGChar *type, HGUInt maxLen);
|
||||
|
||||
/* 获取设备序列号 */
|
||||
HGEXPORT HGBool HGAPI HGLib_GetDeviceSN(HGLibDevice device, HGChar *sn, HGUInt maxLen);
|
||||
|
||||
/* 获取设备固件版本号*/
|
||||
HGEXPORT HGBool HGAPI HGLib_GetDeviceFWVersion(HGLibDevice device, HGChar* fwVersion, HGUInt maxLen);
|
||||
|
||||
/* 获取设备生产日期 */
|
||||
HGEXPORT HGBool HGAPI HGLib_GetDevicePD(HGLibDevice device, HGChar* pd, HGUInt maxLen);
|
||||
|
||||
/* 获取生产批次号 */
|
||||
HGEXPORT HGBool HGAPI HGLib_GetDevicePatchId(HGLibDevice device, HGChar* patchId, HGUInt maxLen);
|
||||
|
||||
/* 获取设备滚轴计数 */
|
||||
HGEXPORT HGInt HGAPI HGLib_GetDeviceRollerCount(HGLibDevice device);
|
||||
|
||||
/* 获取设备历史扫描张数 */
|
||||
HGEXPORT HGInt HGAPI HGLib_GetDeviceTotalCount(HGLibDevice device);
|
||||
|
||||
/* 清除滚轴计数 */
|
||||
HGEXPORT HGBool HGAPI HGLib_ClearDeviceRollerCount(HGLibDevice device);
|
||||
|
||||
/* 设置设备锁定令牌 */
|
||||
HGEXPORT HGBool HGAPI HGLib_SetDeviceToken(HGLibDevice device, const HGChar *code);
|
||||
|
||||
/* 设置是否获取原图 */
|
||||
HGEXPORT HGBool HGAPI HGLib_SetOriginalImage(HGLibDevice device, HGBool isOriginal);
|
||||
|
||||
/* 设置设备参数 */
|
||||
HGEXPORT HGBool HGAPI HGLib_SetDeviceParam(HGLibDevice device, HGUInt option, const HGVoid *data);
|
||||
|
||||
/* 获取设备参数 */
|
||||
HGEXPORT HGLibDeviceParamGroup* HGAPI HGLib_GetDeviceParamGroupList(HGLibDevice device, HGUInt *count);
|
||||
HGEXPORT HGLibDeviceParam* HGAPI HGLib_GetDeviceParam(HGLibDevice device, HGUInt option);
|
||||
|
||||
/* 销毁设备参数 */
|
||||
HGEXPORT HGBool HGAPI HGLib_ReleaseDeviceParamGroupList(HGLibDeviceParamGroup* paramGroup, HGUInt count);
|
||||
HGEXPORT HGBool HGAPI HGLib_ReleaseDeviceParam(HGLibDeviceParam* param);
|
||||
|
||||
/* 重置设备参数 */
|
||||
HGEXPORT HGBool HGAPI HGLib_ResetDeviceParam(HGLibDevice device);
|
||||
|
||||
/* 设备是否有纸 */
|
||||
HGEXPORT HGBool HGAPI HGLib_DeviceIsPaperOn(HGLibDevice device);
|
||||
|
||||
/* 获取设备状态 */
|
||||
HGEXPORT HGInt HGAPI HGLib_GetDeviceStatus(HGLibDevice device);
|
||||
|
||||
/* 获取设备是否在线 */
|
||||
HGEXPORT HGBool HGAPI HGLib_GetDeviceIsOnline(HGLibDevice device);
|
||||
|
||||
/* 重启设备 */
|
||||
HGEXPORT HGBool HGAPI HGLib_DeviceRestart(HGLibDevice device);
|
||||
|
||||
/* 关闭设备 */
|
||||
HGEXPORT HGBool HGAPI HGLib_DeviceShutDown(HGLibDevice device);
|
||||
|
||||
/* 开始扫描 */
|
||||
HGEXPORT HGBool HGAPI HGLib_StartDeviceScan(HGLibDevice device, HGLibDeviceScanEventFunc eventFunc, HGPointer eventParam,
|
||||
HGLibDeviceScanImageFunc imageFunc, HGPointer imageParam);
|
||||
|
||||
/* 停止扫描 */
|
||||
HGEXPORT HGBool HGAPI HGLib_StopDeviceScan(HGLibDevice device);
|
||||
|
||||
/* 停止扫描-异步 */
|
||||
HGEXPORT HGBool HGAPI HGLib_StopDeviceScanAsyn(HGLibDevice device);
|
||||
|
||||
/* 获取设备错误码(在调用设备操作函数以后) */
|
||||
HGEXPORT HGInt HGAPI HGLib_GetDeviceOperateCode(HGLibDevice device);
|
||||
|
||||
/* 获取当前图像所属的页码序号(必须在HGLibDeviceScanImageFunc回调中调用) */
|
||||
HGEXPORT HGInt HGAPI HGLib_GetDevicePageId(HGLibDevice device);
|
||||
|
||||
#endif /* __HGSCANNERLIB_H__ */
|
||||
Reference in New Issue
Block a user