modify interface of ui_helper
This commit is contained in:
parent
90057b3fc2
commit
1956370918
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "sane/sane_ex.h"
|
||||||
|
|
||||||
class ref
|
class ref
|
||||||
{
|
{
|
||||||
|
@ -82,16 +83,12 @@ public:
|
||||||
};
|
};
|
||||||
virtual void test_callback(const wchar_t* name/*test name*/, test_event ev, void* data, size_t flag) = 0;
|
virtual void test_callback(const wchar_t* name/*test name*/, test_event ev, void* data, size_t flag) = 0;
|
||||||
|
|
||||||
|
// register/unregister sane callback, the sane_callback in UI module should dispatch the events to these registered callback
|
||||||
|
virtual int register_sane_callback(sane_callback cb, void* param) = 0;
|
||||||
|
virtual int unregister_sane_callback(sane_callback cb) = 0;
|
||||||
|
|
||||||
// All IO operations are blocking
|
// All IO operations are blocking
|
||||||
enum usb_io_type
|
virtual int io_control(unsigned long code, void* data, unsigned* len) = 0;
|
||||||
{
|
|
||||||
USB_IO_BULK_READ = 0,
|
|
||||||
USB_IO_BULK_WRITE,
|
|
||||||
USB_IO_INTERRUPT_READ,
|
|
||||||
USB_IO_INTERRUPT_WRITE,
|
|
||||||
};
|
|
||||||
virtual int io_bulk_int(usb_io_type type, void* buf, size_t* len/*[in]-size of buf, [out]-data bytes in buf*/) = 0;
|
|
||||||
virtual int io_control(int type, int req, int val, int ind, void* buf, size_t* len/*[in]-in data sizef, [out]-transferred bytes*/) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef TEST_DLL
|
#ifdef TEST_DLL
|
||||||
|
|
|
@ -0,0 +1,248 @@
|
||||||
|
/* sane - Scanner Access Now Easy.
|
||||||
|
Copyright (C) 1997-1999 David Mosberger-Tang and Andreas Beck
|
||||||
|
This file is part of the SANE package.
|
||||||
|
|
||||||
|
This file is in the public domain. You may use and modify it as
|
||||||
|
you see fit, as long as this copyright message is included and
|
||||||
|
that there is an indication as to what modifications have been
|
||||||
|
made (if any).
|
||||||
|
|
||||||
|
SANE is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
This file declares SANE application interface. See the SANE
|
||||||
|
standard for a detailed explanation of the interface. */
|
||||||
|
#ifndef sane_h
|
||||||
|
#define sane_h
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SANE types and defines
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SANE_CURRENT_MAJOR 1
|
||||||
|
#define SANE_CURRENT_MINOR 0
|
||||||
|
|
||||||
|
#define SANE_VERSION_CODE(major, minor, build) \
|
||||||
|
( (((SANE_Word) (major) & 0xff) << 24) \
|
||||||
|
| (((SANE_Word) (minor) & 0xff) << 16) \
|
||||||
|
| (((SANE_Word) (build) & 0xffff) << 0))
|
||||||
|
|
||||||
|
#define SANE_VERSION_MAJOR(code) ((((SANE_Word)(code)) >> 24) & 0xff)
|
||||||
|
#define SANE_VERSION_MINOR(code) ((((SANE_Word)(code)) >> 16) & 0xff)
|
||||||
|
#define SANE_VERSION_BUILD(code) ((((SANE_Word)(code)) >> 0) & 0xffff)
|
||||||
|
|
||||||
|
#define SANE_FALSE 0
|
||||||
|
#define SANE_TRUE 1
|
||||||
|
|
||||||
|
typedef unsigned char SANE_Byte;
|
||||||
|
typedef int SANE_Word;
|
||||||
|
typedef SANE_Word SANE_Bool;
|
||||||
|
typedef SANE_Word SANE_Int;
|
||||||
|
typedef char SANE_Char;
|
||||||
|
typedef SANE_Char *SANE_String;
|
||||||
|
typedef const SANE_Char *SANE_String_Const;
|
||||||
|
typedef void *SANE_Handle;
|
||||||
|
typedef SANE_Word SANE_Fixed;
|
||||||
|
|
||||||
|
#define SANE_FIXED_SCALE_SHIFT 16
|
||||||
|
#define SANE_FIX(v) ((SANE_Word) ((v) * (1 << SANE_FIXED_SCALE_SHIFT)))
|
||||||
|
#define SANE_UNFIX(v) ((double)(v) / (1 << SANE_FIXED_SCALE_SHIFT))
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SANE_STATUS_GOOD = 0, /* everything A-OK */
|
||||||
|
SANE_STATUS_UNSUPPORTED, /* operation is not supported */
|
||||||
|
SANE_STATUS_CANCELLED, /* operation was cancelled */
|
||||||
|
SANE_STATUS_DEVICE_BUSY, /* device is busy; try again later */
|
||||||
|
SANE_STATUS_INVAL, /* data is invalid (includes no dev at open) */
|
||||||
|
SANE_STATUS_EOF, /* no more data available (end-of-file) */
|
||||||
|
SANE_STATUS_JAMMED, /* document feeder jammed */
|
||||||
|
SANE_STATUS_NO_DOCS, /* document feeder out of documents */
|
||||||
|
SANE_STATUS_COVER_OPEN, /* scanner cover is open */
|
||||||
|
SANE_STATUS_IO_ERROR, /* error during device I/O */
|
||||||
|
SANE_STATUS_NO_MEM, /* out of memory */
|
||||||
|
SANE_STATUS_ACCESS_DENIED /* access to resource has been denied */
|
||||||
|
}
|
||||||
|
SANE_Status;
|
||||||
|
|
||||||
|
/* following are for later sane version, older frontends wont support */
|
||||||
|
#if 0
|
||||||
|
#define SANE_STATUS_WARMING_UP 12 /* lamp not ready, please retry */
|
||||||
|
#define SANE_STATUS_HW_LOCKED 13 /* scanner mechanism locked for transport */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SANE_TYPE_BOOL = 0,
|
||||||
|
SANE_TYPE_INT,
|
||||||
|
SANE_TYPE_FIXED,
|
||||||
|
SANE_TYPE_STRING,
|
||||||
|
SANE_TYPE_BUTTON,
|
||||||
|
SANE_TYPE_GROUP
|
||||||
|
}
|
||||||
|
SANE_Value_Type;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SANE_UNIT_NONE = 0, /* the value is unit-less (e.g., # of scans) */
|
||||||
|
SANE_UNIT_PIXEL, /* value is number of pixels */
|
||||||
|
SANE_UNIT_BIT, /* value is number of bits */
|
||||||
|
SANE_UNIT_MM, /* value is millimeters */
|
||||||
|
SANE_UNIT_DPI, /* value is resolution in dots/inch */
|
||||||
|
SANE_UNIT_PERCENT, /* value is a percentage */
|
||||||
|
SANE_UNIT_MICROSECOND /* value is micro seconds */
|
||||||
|
}
|
||||||
|
SANE_Unit;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SANE_String_Const name; /* unique device name */
|
||||||
|
SANE_String_Const vendor; /* device vendor string */
|
||||||
|
SANE_String_Const model; /* device model name */
|
||||||
|
SANE_String_Const type; /* device type (e.g., "flatbed scanner") */
|
||||||
|
}
|
||||||
|
SANE_Device;
|
||||||
|
|
||||||
|
#define SANE_CAP_SOFT_SELECT (1 << 0)
|
||||||
|
#define SANE_CAP_HARD_SELECT (1 << 1)
|
||||||
|
#define SANE_CAP_SOFT_DETECT (1 << 2)
|
||||||
|
#define SANE_CAP_EMULATED (1 << 3)
|
||||||
|
#define SANE_CAP_AUTOMATIC (1 << 4)
|
||||||
|
#define SANE_CAP_INACTIVE (1 << 5)
|
||||||
|
#define SANE_CAP_ADVANCED (1 << 6)
|
||||||
|
|
||||||
|
#define SANE_OPTION_IS_ACTIVE(cap) (((cap) & SANE_CAP_INACTIVE) == 0)
|
||||||
|
#define SANE_OPTION_IS_SETTABLE(cap) (((cap) & SANE_CAP_SOFT_SELECT) != 0)
|
||||||
|
|
||||||
|
#define SANE_INFO_INEXACT (1 << 0)
|
||||||
|
#define SANE_INFO_RELOAD_OPTIONS (1 << 1)
|
||||||
|
#define SANE_INFO_RELOAD_PARAMS (1 << 2)
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SANE_CONSTRAINT_NONE = 0,
|
||||||
|
SANE_CONSTRAINT_RANGE,
|
||||||
|
SANE_CONSTRAINT_WORD_LIST,
|
||||||
|
SANE_CONSTRAINT_STRING_LIST
|
||||||
|
}
|
||||||
|
SANE_Constraint_Type;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SANE_Word min; /* minimum (element) value */
|
||||||
|
SANE_Word max; /* maximum (element) value */
|
||||||
|
SANE_Word quant; /* quantization value (0 if none) */
|
||||||
|
}
|
||||||
|
SANE_Range;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SANE_String_Const name; /* name of this option (command-line name) */
|
||||||
|
SANE_String_Const title; /* title of this option (single-line) */
|
||||||
|
SANE_String_Const desc; /* description of this option (multi-line) */
|
||||||
|
SANE_Value_Type type; /* how are values interpreted? */
|
||||||
|
SANE_Unit unit; /* what is the (physical) unit? */
|
||||||
|
SANE_Int size;
|
||||||
|
SANE_Int cap; /* capabilities */
|
||||||
|
|
||||||
|
SANE_Constraint_Type constraint_type;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
const SANE_String_Const *string_list; /* NULL-terminated list */
|
||||||
|
const SANE_Word *word_list; /* first element is list-length */
|
||||||
|
const SANE_Range *range;
|
||||||
|
}
|
||||||
|
constraint;
|
||||||
|
}
|
||||||
|
SANE_Option_Descriptor;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SANE_ACTION_GET_VALUE = 0,
|
||||||
|
SANE_ACTION_SET_VALUE,
|
||||||
|
SANE_ACTION_SET_AUTO
|
||||||
|
}
|
||||||
|
SANE_Action;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SANE_FRAME_GRAY, /* band covering human visual range */
|
||||||
|
SANE_FRAME_RGB, /* pixel-interleaved red/green/blue bands */
|
||||||
|
SANE_FRAME_RED, /* red band only */
|
||||||
|
SANE_FRAME_GREEN, /* green band only */
|
||||||
|
SANE_FRAME_BLUE /* blue band only */
|
||||||
|
}
|
||||||
|
SANE_Frame;
|
||||||
|
|
||||||
|
/* push remaining types down to match existing backends */
|
||||||
|
/* these are to be exposed in a later version of SANE */
|
||||||
|
/* most front-ends will require updates to understand them */
|
||||||
|
#if 0
|
||||||
|
#define SANE_FRAME_TEXT 0x0A /* backend specific textual data */
|
||||||
|
#define SANE_FRAME_JPEG 0x0B /* complete baseline JPEG file */
|
||||||
|
#define SANE_FRAME_G31D 0x0C /* CCITT Group 3 1-D Compressed (MH) */
|
||||||
|
#define SANE_FRAME_G32D 0x0D /* CCITT Group 3 2-D Compressed (MR) */
|
||||||
|
#define SANE_FRAME_G42D 0x0E /* CCITT Group 4 2-D Compressed (MMR) */
|
||||||
|
|
||||||
|
#define SANE_FRAME_IR 0x0F /* bare infrared channel */
|
||||||
|
#define SANE_FRAME_RGBI 0x10 /* red+green+blue+infrared */
|
||||||
|
#define SANE_FRAME_GRAYI 0x11 /* gray+infrared */
|
||||||
|
#define SANE_FRAME_XML 0x12 /* undefined schema */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SANE_Frame format;
|
||||||
|
SANE_Bool last_frame;
|
||||||
|
SANE_Int bytes_per_line;
|
||||||
|
SANE_Int pixels_per_line;
|
||||||
|
SANE_Int lines;
|
||||||
|
SANE_Int depth;
|
||||||
|
}
|
||||||
|
SANE_Parameters;
|
||||||
|
|
||||||
|
struct SANE_Auth_Data;
|
||||||
|
|
||||||
|
#define SANE_MAX_USERNAME_LEN 128
|
||||||
|
#define SANE_MAX_PASSWORD_LEN 128
|
||||||
|
|
||||||
|
typedef void (*SANE_Auth_Callback) (SANE_String_Const resource,
|
||||||
|
SANE_Char *username,
|
||||||
|
SANE_Char *password);
|
||||||
|
|
||||||
|
extern SANE_Status sane_init (SANE_Int * version_code,
|
||||||
|
SANE_Auth_Callback authorize);
|
||||||
|
extern void sane_exit (void);
|
||||||
|
extern SANE_Status sane_get_devices (const SANE_Device *** device_list,
|
||||||
|
SANE_Bool local_only);
|
||||||
|
extern SANE_Status sane_open (SANE_String_Const devicename,
|
||||||
|
SANE_Handle * handle);
|
||||||
|
extern void sane_close (SANE_Handle handle);
|
||||||
|
extern const SANE_Option_Descriptor *
|
||||||
|
sane_get_option_descriptor (SANE_Handle handle, SANE_Int option);
|
||||||
|
extern SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option,
|
||||||
|
SANE_Action action, void *value,
|
||||||
|
SANE_Int * info);
|
||||||
|
extern SANE_Status sane_get_parameters (SANE_Handle handle,
|
||||||
|
SANE_Parameters * params);
|
||||||
|
extern SANE_Status sane_start (SANE_Handle handle);
|
||||||
|
extern SANE_Status sane_read (SANE_Handle handle, SANE_Byte * data,
|
||||||
|
SANE_Int max_length, SANE_Int * length);
|
||||||
|
extern void sane_cancel (SANE_Handle handle);
|
||||||
|
extern SANE_Status sane_set_io_mode (SANE_Handle handle,
|
||||||
|
SANE_Bool non_blocking);
|
||||||
|
extern SANE_Status sane_get_select_fd (SANE_Handle handle,
|
||||||
|
SANE_Int * fd);
|
||||||
|
extern SANE_String_Const sane_strstatus (SANE_Status status);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* sane_h */
|
|
@ -0,0 +1,459 @@
|
||||||
|
/* sane - Scanner Access Now Easy.
|
||||||
|
对sane标准头文件的扩展
|
||||||
|
|
||||||
|
Author: Gongbing
|
||||||
|
|
||||||
|
Date: 2022-01-14
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef sane_ex_h
|
||||||
|
#define sane_ex_h
|
||||||
|
|
||||||
|
#ifndef EXPORT_SANE_API
|
||||||
|
#ifdef OEM_HANWANG
|
||||||
|
#define ENTIRE_API(pre, tail) pre##_hwsane_##tail
|
||||||
|
#elif defined(OEM_LISICHENG)
|
||||||
|
#define ENTIRE_API(pre, tail) pre##_lscsane_##tail
|
||||||
|
#elif defined(OEM_CANGTIAN)
|
||||||
|
#define ENTIRE_API(pre, tail) pre##_ctssane_##tail
|
||||||
|
#else
|
||||||
|
#define ENTIRE_API(pre, tail) pre##_hgsane_##tail
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define sane_init ENTIRE_API(sane, init)
|
||||||
|
#define sane_init_ex ENTIRE_API(sane, init_ex)
|
||||||
|
#define sane_exit ENTIRE_API(sane, exit)
|
||||||
|
#define sane_get_devices ENTIRE_API(sane, get_devices)
|
||||||
|
#define sane_open ENTIRE_API(sane, open)
|
||||||
|
#define sane_close ENTIRE_API(sane, close)
|
||||||
|
#define sane_get_option_descriptor ENTIRE_API(sane, get_option_descriptor)
|
||||||
|
#define sane_control_option ENTIRE_API(sane, control_option)
|
||||||
|
#define sane_get_parameters ENTIRE_API(sane, get_parameters)
|
||||||
|
#define sane_start ENTIRE_API(sane, start)
|
||||||
|
#define sane_read ENTIRE_API(sane, read)
|
||||||
|
#define sane_cancel ENTIRE_API(sane, cancel)
|
||||||
|
#define sane_set_io_mode ENTIRE_API(sane, set_io_mode)
|
||||||
|
#define sane_get_select_fd ENTIRE_API(sane, get_select_fd)
|
||||||
|
#define sane_strstatus ENTIRE_API(sane, strstatus)
|
||||||
|
#define sane_io_control ENTIRE_API(sane, io_control)
|
||||||
|
#define sane_err_desc ENTIRE_API(sane, err_desc)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// sane-standard-option-name defined by third-app
|
||||||
|
//
|
||||||
|
// PART I: 参数类型与华高一致,可直接通过改name字段为标准值实现
|
||||||
|
#define SANE_STD_OPT_NAME_RESTORE "restore" // OPTION_TITLE_HFMRSZ
|
||||||
|
#define SANE_STD_OPT_NAME_HELP "help" // OPTION_TITLE_BZ
|
||||||
|
#define SANE_STD_OPT_NAME_IS_MULTI_OUT "is-multiout" // OPTION_TITLE_DLSC
|
||||||
|
#define SANE_STD_OPT_NAME_MULTI_OUT_TYPE "multiout-type" // OPTION_TITLE_DLSCLX
|
||||||
|
#define SANE_STD_OPT_NAME_COLOR_MODE "mode" // OPTION_TITLE_YSMS
|
||||||
|
#define SANE_STD_OPT_NAME_BINARY_THRESHOLD "binary-threshold" // OPTION_TITLE_HBTXYZ
|
||||||
|
#define SANE_STD_OPT_NAME_REVERSE_01 "reverse-bw" // OPTION_TITLE_HBTXFSSC
|
||||||
|
#define SANE_STD_OPT_NAME_FILTER "filter" // OPTION_TITLE_HDHHBTX_CS
|
||||||
|
#define SANE_STD_OPT_NAME_RID_MULTIOUT_RED "is-rid-multiout-red" // OPTION_TITLE_24WCSTX_DLSCCH
|
||||||
|
#define SANE_STD_OPT_NAME_RID_ANSWER_SHEET_RED "is-rid-answer-sheet-red" // OPTION_TITLE_24WCSTX_DTKCH
|
||||||
|
#define SANE_STD_OPT_NAME_ERASE_BACKGROUND "is-erase-bkg" // OPTION_TITLE_BJYC
|
||||||
|
#define SANE_STD_OPT_NAME_BKG_COLOR_RANGE "bkg-color-range" // OPTION_TITLE_BJSCFDFW
|
||||||
|
#define SANE_STD_OPT_NAME_SHARPEN "sharpen" // OPTION_TITLE_RHYMH
|
||||||
|
#define SANE_STD_OPT_NAME_RID_MORR "is-rid-morr" // OPTION_TITLE_QCMW
|
||||||
|
#define SANE_STD_OPT_NAME_RID_GRID "is-rid-grid" // OPTION_TITLE_CWW
|
||||||
|
#define SANE_STD_OPT_NAME_ERROR_EXTENSION "is-err-extension" // OPTION_TITLE_CWKS
|
||||||
|
#define SANE_STD_OPT_NAME_NOISE_OPTIMIZE "is-noise-optimize" // OPTION_TITLE_HBTXZDYH
|
||||||
|
#define SANE_STD_OPT_NAME_NOISE_SIZE "noise-size" // OPTION_TITLE_ZDYHCC
|
||||||
|
#define SANE_STD_OPT_NAME_PAPER "paper" // OPTION_TITLE_ZZCC
|
||||||
|
#define SANE_STD_OPT_NAME_CUSTOM_AREA "is-custom-area" // OPTION_TITLE_ZDYSMQY
|
||||||
|
#define SANE_STD_OPT_NAME_CUSTOM_AREA_LEFT "tl-x" // OPTION_TITLE_SMQYZCmm
|
||||||
|
#define SANE_STD_OPT_NAME_CUSTOM_AREA_RIGHT "br-x" // OPTION_TITLE_SMQYYCmm
|
||||||
|
#define SANE_STD_OPT_NAME_CUSTOM_AREA_TOP "tl-y" // OPTION_TITLE_SMQYSCmm
|
||||||
|
#define SANE_STD_OPT_NAME_CUSTOM_AREA_BOTTOM "br-y" // OPTION_TITLE_SMQYXCmm
|
||||||
|
#define SANE_STD_OPT_NAME_SIZE_CHECK "is-size-check" // OPTION_TITLE_CCJC
|
||||||
|
#define SANE_STD_OPT_NAME_PAGE "page" // OPTION_TITLE_SMYM
|
||||||
|
#define SANE_STD_OPT_NAME_DISCARD_BLANK_SENS "blank-sensitivity" // OPTION_TITLE_TGKBYLMD
|
||||||
|
#define SANE_STD_OPT_NAME_RESOLUTION "resolution" // OPTION_TITLE_FBL
|
||||||
|
#define SANE_STD_OPT_NAME_TIME_TO_SLEEP "time-to-sleep" // OPTION_TITLE_XMSJ
|
||||||
|
#define SANE_STD_OPT_NAME_IMAGE_QUALITY "image-quality" // OPTION_TITLE_HZ
|
||||||
|
#define SANE_STD_OPT_NAME_EXCHANGE "is-exchange" // OPTION_TITLE_JHZFM
|
||||||
|
#define SANE_STD_OPT_NAME_SPLIT "is-split" // OPTION_TITLE_TXCF
|
||||||
|
#define SANE_STD_OPT_NAME_ANTI_SKEW "is-anti-skew" // OPTION_TITLE_ZDJP
|
||||||
|
#define SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA "is-custom-gamma" // OPTION_TITLE_QYSDQX
|
||||||
|
#define SANE_STD_OPT_NAME_GAMMA "gamma" // OPTION_TITLE_JMZ
|
||||||
|
#define SANE_STD_OPT_NAME_BRIGHTNESS "brightness" // OPTION_TITLE_LDZ
|
||||||
|
#define SANE_STD_OPT_NAME_CONTRAST "contrast" // OPTION_TITLE_DBD
|
||||||
|
#define SANE_STD_OPT_NAME_IS_PHOTO_MODE "is-photo-mode" // OPTION_TITLE_ZPMS
|
||||||
|
#define SANE_STD_OPT_NAME_ERASE_BLACK_FRAME "is-erase-black-frame" // OPTION_TITLE_XCHK
|
||||||
|
#define SANE_STD_OPT_NAME_DARK_SAMPLE "is-dark-sample" // OPTION_TITLE_SSYZ
|
||||||
|
#define SANE_STD_OPT_NAME_THRESHOLD "threshold" // OPTION_TITLE_YZ
|
||||||
|
#define SANE_STD_OPT_NAME_ANTI_NOISE_LEVEL "anti-noise-level" // OPTION_TITLE_BJKZDJ
|
||||||
|
#define SANE_STD_OPT_NAME_MARGIN "margin" // OPTION_TITLE_BYSJ
|
||||||
|
#define SANE_STD_OPT_NAME_FILL_BKG_MODE "bkg-fill-mode" // OPTION_TITLE_BJTCFS
|
||||||
|
#define SANE_STD_OPT_NAME_IS_ANTI_PERMEATE "is-anti-permeate" // OPTION_TITLE_FZST
|
||||||
|
#define SANE_STD_OPT_NAME_ANTI_PERMEATE_LEVEL "permeate-level" // OPTION_TITLE_FZSTDJ
|
||||||
|
#define SANE_STD_OPT_NAME_RID_HOLE "is-rid-hole" // OPTION_TITLE_CKYC
|
||||||
|
#define SANE_STD_OPT_NAME_SEARCH_HOLE_RANGE "search-hole-range" // OPTION_TITLE_CKSSFWZFMBL
|
||||||
|
#define SANE_STD_OPT_NAME_RID_HOLE_L "is-rid-hole-l" // OPTION_TITLE_CKYCZC
|
||||||
|
#define SANE_STD_OPT_NAME_SEARCH_HOLE_RANGE_L "search-hole-range-l" // OPTION_TITLE_ZCCKSSFWZFMBL
|
||||||
|
#define SANE_STD_OPT_NAME_RID_HOLE_R "is-rid-hole-r" // OPTION_TITLE_CKYCYC
|
||||||
|
#define SANE_STD_OPT_NAME_SEARCH_HOLE_RANGE_R "search-hole-range-r" // OPTION_TITLE_YCCKSSFWZFMBL
|
||||||
|
#define SANE_STD_OPT_NAME_RID_HOLE_T "is-rid-hole-t" // OPTION_TITLE_CKYCSC
|
||||||
|
#define SANE_STD_OPT_NAME_SEARCH_HOLE_RANGE_T "search-hole-range-t" // OPTION_TITLE_SCCKSSFWZFMBL
|
||||||
|
#define SANE_STD_OPT_NAME_RID_HOLE_B "is-rid-hole-b" // OPTION_TITLE_CKYCXC
|
||||||
|
#define SANE_STD_OPT_NAME_SEARCH_HOLE_RANGE_B "search-hole-range-b" // OPTION_TITLE_XCCKSSFWZFMBL
|
||||||
|
#define SANE_STD_OPT_NAME_IS_FILL_COLOR "is-fill-color" // OPTION_TITLE_SCTC
|
||||||
|
#define SANE_STD_OPT_NAME_IS_ULTROSONIC_CHECK "is-ultrosonic" // OPTION_TITLE_CSBJC
|
||||||
|
#define SANE_STD_OPT_NAME_DOUBLE_FEED_HANDLE "double-feed" // OPTION_TITLE_SZTPCL
|
||||||
|
#define SANE_STD_OPT_NAME_IS_CHECK_STAPLE "is-staple" // OPTION_TITLE_ZDJC
|
||||||
|
#define SANE_STD_OPT_NAME_SCAN_MODE "scan-mode" // OPTION_TITLE_SMZS
|
||||||
|
#define SANE_STD_OPT_NAME_SCAN_COUNT "scan-count" // OPTION_TITLE_SMSL
|
||||||
|
#define SANE_STD_OPT_NAME_TEXT_DIRECTION "direction" // OPTION_TITLE_WGFX
|
||||||
|
#define SANE_STD_OPT_NAME_IS_ROTATE_BKG_180 "is-rotate-bkg-180" // OPTION_TITLE_BMXZ180
|
||||||
|
#define SANE_STD_OPT_NAME_IS_CHECK_DOG_EAR "is-check-dog-ear" // OPTION_TITLE_ZJJC
|
||||||
|
#define SANE_STD_OPT_NAME_DOG_EAR_SIZE "dog-ear-size" // OPTION_TITLE_ZJDX
|
||||||
|
#define SANE_STD_OPT_NAME_IS_CHECK_ASKEW "is-check-askew" // OPTION_TITLE_WXJC
|
||||||
|
#define SANE_STD_OPT_NAME_ASKEW_RANGE "askew-range" // OPTION_TITLE_WXRRD
|
||||||
|
#define SANE_STD_OPT_NAME_FEED_STRENGTH "feed-strength" // OPTION_TITLE_FZQD
|
||||||
|
#define SANE_STD_OPT_NAME_IS_AUTO_FEED_STRENGTH "is-auto-strength" // OPTION_TITLE_ZDFZQD
|
||||||
|
#define SANE_STD_OPT_NAME_FEED_STRENGTH_VALUE "feed-strength-value" // OPTION_TITLE_JZSBL
|
||||||
|
#define SANE_STD_OPT_NAME_WAIT_TO_SCAN "is-wait-scan" // OPTION_TITLE_DZSM
|
||||||
|
#define SANE_STD_OPT_NAME_FOLD_TYPE "fold-type" // OPTION_TITLE_DZMS
|
||||||
|
|
||||||
|
// PART II: 参数类型与华高不一致,需要通过“hgsane”组件在中间转换
|
||||||
|
#define SANE_STD_OPT_NAME_PAPER_W "page-width" // OPTION_TITLE_ZZCC
|
||||||
|
#define SANE_STD_OPT_NAME_PAPER_H "page-height" // OPTION_TITLE_ZZCC
|
||||||
|
#define SANE_STD_OPT_NAME_DUPLEX "duplex" // OPTION_TITLE_SMYM
|
||||||
|
// END for sane-standard-option-name defined by third-app
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "sane.h"
|
||||||
|
|
||||||
|
#define MAX_STRING_LEN 256
|
||||||
|
#define IS_DOUBLE_EQUAL(a, b) fabs((a) - (b)) < .000001
|
||||||
|
#define IS_PTR_NUMBER(ptr) (((unsigned long long)(ptr)) < 0x10000)
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma pack(push)
|
||||||
|
#pragma pack(1)
|
||||||
|
#define ZERO_STRUCT(struct_ptr) memset(struct_ptr, 0, sizeof(*(struct_ptr)))
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// extension for standard SANE ...
|
||||||
|
typedef struct _sane_stream
|
||||||
|
{
|
||||||
|
SANE_Int bytes;
|
||||||
|
SANE_Byte *data;
|
||||||
|
}SANE_Stream;
|
||||||
|
|
||||||
|
typedef struct _sane_dev_ex
|
||||||
|
{
|
||||||
|
SANE_String_Const name; /* unique device name */
|
||||||
|
SANE_String_Const vendor; /* device vendor string */
|
||||||
|
SANE_String_Const model; /* device model name */
|
||||||
|
SANE_String_Const type; /* device type (e.g., "flatbed scanner") */
|
||||||
|
SANE_Bool openned; // whether openned
|
||||||
|
}SANE_Device_Ex;
|
||||||
|
typedef struct _sane_auth // for SANE_EVENT_NEED_AUTH
|
||||||
|
{
|
||||||
|
SANE_String_Const resource;
|
||||||
|
SANE_Char name[MAX_STRING_LEN];
|
||||||
|
SANE_Char pwd[MAX_STRING_LEN];
|
||||||
|
SANE_Char method[MAX_STRING_LEN];
|
||||||
|
}SANEAUTH;
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SANE_Image_Statu_OK = 0, // 正常图像
|
||||||
|
SANE_Image_Statu_Blank, // 被判定为空白的图像
|
||||||
|
SANE_Image_Statu_Double, // 出现双张进纸的图像
|
||||||
|
SANE_Image_Statu_Jammed, // 卡纸后的图像
|
||||||
|
}SANE_Image_Statu; // added on 2022-07-23
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SANE_Parameters header;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned int statu : 4; // SANE_Image_Statu
|
||||||
|
unsigned int dpi : 12; // resolution, dots per inch
|
||||||
|
unsigned int reserve : 16;
|
||||||
|
}flag;
|
||||||
|
unsigned long bytes;
|
||||||
|
unsigned char *data;
|
||||||
|
}SANE_Image;
|
||||||
|
typedef struct _about_info
|
||||||
|
{
|
||||||
|
SANE_String_Const title; // APP名称
|
||||||
|
SANE_String_Const version; // 版本号
|
||||||
|
SANE_String_Const copyright; // 版权信息
|
||||||
|
unsigned int logo_bytes; // LOGO 数据长度
|
||||||
|
void* logo; // LOGO 数据
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
SANE_String_Const key; // 附加信息名称,该数据为NULL时,appendix数组结束
|
||||||
|
SANE_String_Const content;// 附加信息内容
|
||||||
|
SANE_String_Const url; // 附加信息链接, NULL则忽略
|
||||||
|
}appendix[1];
|
||||||
|
}SANE_About;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SANE_COMPRESSION_FIRST = 0,
|
||||||
|
SANE_COMPRESSION_NONE = 0, // default value
|
||||||
|
//SANE_COMPRESSION_PACBITS,
|
||||||
|
//SANE_COMPRESSION_GROUP31D,
|
||||||
|
//SANE_COMPRESSION_GROUP31DEOL,
|
||||||
|
//SANE_COMPRESSION_GROUP32D,
|
||||||
|
SANE_COMPRESSION_GROUP4 = 5, // support now ! detail is threshold converting color to BlackWhite, e.g. (void*)128
|
||||||
|
//SANE_COMPRESSION_JPEG,
|
||||||
|
//SANE_COMPRESSION_LZW,
|
||||||
|
//SANE_COMPRESSION_JBIG,
|
||||||
|
//SANE_COMPRESSION_PNG,
|
||||||
|
//SANE_COMPRESSION_RLE4,
|
||||||
|
//SANE_COMPRESSION_RLE8,
|
||||||
|
//SANE_COMPRESSION_BITFIELDS,
|
||||||
|
//SANE_COMPRESSION_ZIZ,
|
||||||
|
//SANE_COMPRESSION_JPEG2000,
|
||||||
|
|
||||||
|
SANE_COMPRESSION_LAST,
|
||||||
|
SANE_COMPRESSION_DONTCARE = 0xFFFF,
|
||||||
|
}SANE_CompressionType;
|
||||||
|
typedef struct _img_compression
|
||||||
|
{
|
||||||
|
SANE_CompressionType compression;
|
||||||
|
void* detail; // see SANE_CompressionType (该参数在当前版本不考虑,暂使用压缩类型的默认值)
|
||||||
|
}SANE_Compression;
|
||||||
|
typedef enum // 与Twpp::ImageFileFormat 保持一致
|
||||||
|
{
|
||||||
|
SANE_IMAGE_TYPE_FIRST = 0,
|
||||||
|
SANE_IMAGE_TYPE_TIFF = 0,
|
||||||
|
SANE_IMAGE_TYPE_BMP = 2, // (BITMAPINFOHEADER*)detail
|
||||||
|
SANE_IMAGE_TYPE_PNG = 7,
|
||||||
|
SANE_IMAGE_TYPE_JPG = 13,
|
||||||
|
SANE_IMAGE_TYPE_JFIF = 4,
|
||||||
|
SANE_IMAGE_TYPE_PDF = 10,
|
||||||
|
|
||||||
|
// 以下为Twpp::ImageFileFormat不存在的值
|
||||||
|
SANE_IMAGE_TYPE_GIF = 100,
|
||||||
|
SANE_IMAGE_TYPE_WEBP,
|
||||||
|
SANE_IMAGE_TYPE_SVG,
|
||||||
|
SANE_IMAGE_TYPE_LAST,
|
||||||
|
}SANE_ImageType;
|
||||||
|
typedef struct _img_final_fmt
|
||||||
|
{
|
||||||
|
SANE_ImageType img_format;
|
||||||
|
void* detail; // see SANE_ImageType (该参数在当前版本不考虑,暂使用该图像类型的默认值)
|
||||||
|
SANE_Compression compress;
|
||||||
|
}SANE_FinalImgFormat;
|
||||||
|
typedef struct _img_format_convert
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
SANE_FinalImgFormat fmt; // format of the data
|
||||||
|
SANE_Bool is_file; // data is a 'path-file' if it was true, or else is raw file data
|
||||||
|
SANE_String_Const data; // represents a local file or a memory data. call 'IO_CTRL_CODE_FREE_MEMORY' to free the dst.data memory if 'is_file' was true !!!
|
||||||
|
unsigned int data_len; // bytes of 'data'
|
||||||
|
}src, dst;
|
||||||
|
}SANE_ImageFormatConvert;
|
||||||
|
|
||||||
|
typedef struct _sane_point
|
||||||
|
{
|
||||||
|
SANE_Byte x;
|
||||||
|
SANE_Byte y;
|
||||||
|
}SANE_Gamma_Point;
|
||||||
|
typedef struct _user_gamma // NOTE: exceeds 4KB !!!
|
||||||
|
{
|
||||||
|
SANE_Bool apply_to_back; // SANE_TRUE: 应用到背面; SANE_FALSE: 应用到正面
|
||||||
|
SANE_Byte pt_count; // 关键点keypoint中有效数据个数,最多4个,0为不使用
|
||||||
|
SANE_Byte pt_count_r; // 关键点keypoint_r中有效数据个数,最多4个,0为不使用
|
||||||
|
SANE_Byte pt_count_g; // 关键点keypoint_g中有效数据个数,最多4个,0为不使用
|
||||||
|
SANE_Byte pt_count_b; // 关键点keypoint_b中有效数据个数,最多4个,0为不使用
|
||||||
|
SANE_Gamma_Point keypoint[4]; // gamma曲线方程式RGB/灰度/黑白模式控制点
|
||||||
|
SANE_Gamma_Point keypoint_r[4]; // gamma曲线方程式Red分量控制点
|
||||||
|
SANE_Gamma_Point keypoint_g[4]; // gamma曲线方程式Green分量控制点
|
||||||
|
SANE_Gamma_Point keypoint_b[4]; // gamma曲线方程式Blue分量控制点
|
||||||
|
SANE_Byte table[3 * 256]; // gamma变换阵列,多分量时,顺序为:R[256] + G[256] + B[256]
|
||||||
|
}SANE_Gamma;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SANE_FUNCTION_PARAMETER_TYPE_STRING = 0, // SANE_String_List
|
||||||
|
SANE_FUNCTION_PARAMETER_TYPE_STREAM, // SANE_Stream
|
||||||
|
SANE_FUNCTION_PARAMETER_TYPE_USER_INPUT, // SANE_String
|
||||||
|
}SANE_Function_Parameter_Type;
|
||||||
|
typedef struct _sane_function_parameter
|
||||||
|
{
|
||||||
|
SANE_Function_Parameter_Type type;
|
||||||
|
}SANE_Function_Parameter;
|
||||||
|
typedef struct _sane_function
|
||||||
|
{
|
||||||
|
SANE_Int func_id;
|
||||||
|
SANE_Int parameter_count;
|
||||||
|
SANE_Function_Parameter parameter[1];
|
||||||
|
}SANE_Function;
|
||||||
|
typedef struct _sane_img_kits
|
||||||
|
{
|
||||||
|
SANE_Int kit_id;
|
||||||
|
SANE_String name;
|
||||||
|
SANE_String title;
|
||||||
|
SANE_String desc;
|
||||||
|
SANE_Stream icon;
|
||||||
|
SANE_Int function_count;
|
||||||
|
SANE_Function function[1];
|
||||||
|
}SANE_Image_Kits;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
AUTO_COLOR_BLACKWHITE = 0,
|
||||||
|
AUTO_COLOR_GRAY,
|
||||||
|
}SANE_AutoColorType;
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
LOG_FILE_DEVICE = 0, // 设备端日志文件
|
||||||
|
LOG_FILE_DRIVER, // 驱动层日志文件
|
||||||
|
}SANE_LogFileType;
|
||||||
|
|
||||||
|
typedef enum // IO_CTRL_CODE_SET_POWER_LEVEL
|
||||||
|
{
|
||||||
|
SANE_POWER_FIRST = 0,
|
||||||
|
SANE_POWER_NONE = SANE_POWER_FIRST,
|
||||||
|
SANE_POWER_MINUTES_5,
|
||||||
|
SANE_POWER_MINUTES_10,
|
||||||
|
SANE_POWER_MINUTES_20,
|
||||||
|
SANE_POWER_MINUTES_30,
|
||||||
|
SANE_POWER_MINUTES_60,
|
||||||
|
SANE_POWER_MINUTES_120,
|
||||||
|
SANE_POWER_MINUTES_240,
|
||||||
|
SANE_POWER_LAST,
|
||||||
|
SANE_POWER_SHUTDOWN, // 关闭设备 239 设备重启和关闭设备不会触发热拔插,所以使用此命令时需要手动关闭设备和打开设备
|
||||||
|
SANE_POWER_RESTART, // 重启设备
|
||||||
|
}SANE_Power;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SANE_EVENT_NONE = 0, // 无意义的回调, both data & len are NULL
|
||||||
|
SANE_EVENT_SUPPORT_ASYNC_IO, // 是否支持异步IO,返回“0”支持,其它不支持。data and len unused
|
||||||
|
SANE_EVENT_IS_MEMORY_ENOUGH, // 当前内存是否足够读取图片, data - unused;*len - needed size. return SCANNER_ERR_OK or SCANNER_ERR_INSUFFICIENT_MEM
|
||||||
|
SANE_EVENT_NEED_AUTH, // data - (SANEAUTH*); len - unused; return none-zero to giveup
|
||||||
|
SANE_EVENT_DEVICE_ARRIVED, // data - SANE_Device_Ex*; *len - sizeof(SANE_Device_Ex)
|
||||||
|
SANE_EVENT_DEVICE_LEFT, // data - SANE_Device*; *len - sizeof(SANE_Device)
|
||||||
|
SANE_EVENT_STATUS, // normal status description. data - (utf8*), len - unused, be NULL
|
||||||
|
SANE_EVENT_ERROR, // error happens, should stop operations. data - (utf8*)description, *len - error code
|
||||||
|
SANE_EVENT_WORKING, // 扫描仪正在扫描, data - (char*)description, len - unused
|
||||||
|
SANE_EVENT_USB_DATA_RECEIVED, // 从USB读取到一个图片数据包,当前只用作纸张统计。data - NULL, *len - bytes
|
||||||
|
SANE_EVENT_IMAGE_OK, // new image data is ready for UI. data - (SANE_Image*), *len - index of the image (ZERO base)
|
||||||
|
SANE_EVENT_SCAN_FINISHED, // 扫描仪完成扫描, data - (char*)description, *len - error code
|
||||||
|
SANE_EVENT_ABOUT_INFORMATION, // APP关于信息, data - (SANE_About*), len - unused, be NULL
|
||||||
|
SANE_EVENT_SCANNER_CLOSED, // 扫描仪已经关闭,data & len 同 SANE_EVENT_STATUS
|
||||||
|
// SANE_EVENT_WIN_DEBUG_INFO, // writedown debug info on windows platform ... data - (utf8*), *len - HG_LOG_LEVEL, param - NULL !!!
|
||||||
|
|
||||||
|
// ui event ...
|
||||||
|
SANE_EVENT_UI_CLOSE_CANCEL = 0x1000,
|
||||||
|
SANE_EVENT_UI_CLOSE_NORMAL,
|
||||||
|
SANE_EVENT_UI_SCAN_COMMAND, // setting ui notify button 'scan' clicked
|
||||||
|
SANE_EVENT_UI_CLOSE_SETTING,
|
||||||
|
}SANE_Event;
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
typedef int(*sane_callback)( // 注册回调的对象,需要保证该回调是多线程安全的
|
||||||
|
SANE_Handle hdev // 产生事件的设备句柄
|
||||||
|
, int code // 回调事件代码
|
||||||
|
, void* data // 回调事件数据,根据事件代码有所不同,参照具体事件定义
|
||||||
|
, unsigned int* len // 数据长度(字节),或者event_data的缓冲区长度,详细请看相应的事件代码
|
||||||
|
, void* param // 用户自定义数据,与调用sane_init_ex传入时的保持一致
|
||||||
|
); // 返回值依不同的事件代码而定,通常为“0”
|
||||||
|
extern SANE_Status sane_init_ex(SANE_Int* version_code, sane_callback cb, void* param);
|
||||||
|
|
||||||
|
enum io_code
|
||||||
|
{
|
||||||
|
IO_CTRL_CODE_BASE = 0x00C0DE111,
|
||||||
|
IO_CTRL_CODE_TEST_SINGLE = IO_CTRL_CODE_BASE, // 单张测试扫描 data - NULL, len - NULL
|
||||||
|
IO_CTRL_CODE_ABOUT_INFO, // 获取软件关于信息。data - (SANE_About*), 如果data为空或者由len指示的内存大小不足,
|
||||||
|
// 则会在len中返回所需要的最小内存长度,并返回 SANE_STATUS_NO_MEM 错误
|
||||||
|
IO_CTRL_CODE_RESTORE_SETTINGS, // 恢复默认设置 data - NULL, len - NULL
|
||||||
|
IO_CTRL_CODE_GET_DEFAULT_VALUE, // 获取设置项默认值 data - 同sane_control_option - SANE_ACTION_GET_VALUE时的定义, *len - [in] 设置项序号,同sane_control_option中option的值
|
||||||
|
IO_CTRL_CODE_CLEAR_ROLLER_COUNT, // 清除滚轴计数 data - NULL, len - to receive current roller count, can be NULL
|
||||||
|
IO_CTRL_CODE_GET_FINAL_IMAGE_FORMAT, // 获取图像处理最终输出(final())的图像数据格式 data - (SANE_FinalImgFormat*), len - bytes of data
|
||||||
|
IO_CTRL_CODE_SET_FINAL_IMAGE_FORMAT, // 设置图像处理最终输出(final())的图像数据格式 data - (SANE_FinalImgFormat*), len - bytes of data
|
||||||
|
IO_CTRL_CODE_GET_FINAL_COMPRESSION, // 获取支持的压缩格式,data - (SANE_Int*), to receive supported SANE_CompressionType, data[0]: supported counts, data[1]: default value, data[2]: current value; data[3...]: all supported values
|
||||||
|
// *len - array length of data, or need length if it was too small
|
||||||
|
IO_CTRL_CODE_SET_FINAL_COMPRESSION, // 设置图像数据最终输出的压缩格式,data - (SANE_Compression*), len - bytes of data
|
||||||
|
IO_CTRL_CODE_SET_AUTO_COLOR_TYPE, // 设置自动匹配颜色模式, data - (SANE_AutoColorType*), *len - sizeof(data)
|
||||||
|
IO_CTRL_CODE_GET_SERIAL, // 获取设备序列号, data - (char*), *len - bytes of data
|
||||||
|
IO_CTRL_CODE_GET_HARDWARE_VERSION, // 获取硬件版本号,参数同 IO_CTRL_CODE_GET_SERIAL
|
||||||
|
IO_CTRL_CODE_GET_IP, // 获取设备IP, 参数同 IO_CTRL_CODE_GET_SERIAL
|
||||||
|
IO_CTRL_CODE_GET_DEVICE_CODE, // 获取设备编码, 参数同 IO_CTRL_CODE_GET_SERIAL
|
||||||
|
IO_CTRL_CODE_GET_DOGEAR_DISTANCE, // 获取折角检测最小距离阈值, data - (SANE_Int*), *len - sizeof(SANE_Int)
|
||||||
|
IO_CTRL_CODE_SET_DOGEAR_DISTANCE, // 设置折角检测最小距离阈值, data - (SANE_Int*), *len - sizeof(SANE_Int)
|
||||||
|
IO_CTRL_CODE_GET_PAPER_ON, // 获取进纸盘上是否有纸,data - (SANE_Bool*), *len - sizeof(SANE_Bool)
|
||||||
|
IO_CTRL_CODE_SET_POWER_LEVEL, // 设置功耗模式(休眠),data - (SANE_Power*), *len - sizeof(SANE_Power)
|
||||||
|
IO_CTRL_CODE_GET_POWER_LEVEL, // 设置功耗模式(休眠),data - (SANE_Power*), *len - sizeof(SANE_Power)
|
||||||
|
IO_CTRL_CODE_GET_SCAN_WHEN_PAPER_ON, // 获取是否为检测到进纸盘上有纸即开始扫描,data - (SANE_Bool*), *len - sizeof(SANE_Bool)
|
||||||
|
IO_CTRL_CODE_SET_SCAN_WHEN_PAPER_ON, // 设置是否为检测到进纸盘上有纸即开始扫描,data - (SANE_Bool*), *len - sizeof(SANE_Bool)
|
||||||
|
IO_CTRL_CODE_GET_SCAN_WITH_HOLE, // 获取是否为带孔扫描,data - (SANE_Bool*), *len - sizeof(SANE_Bool)
|
||||||
|
IO_CTRL_CODE_SET_SCAN_WITH_HOLE, // 设置是否为带孔扫描,data - (SANE_Bool*), *len - sizeof(SANE_Bool)
|
||||||
|
IO_CTRL_CODE_GET_CUSTOM_GAMMA, // 用于获取用户自定义gamma数值,data - SANE_Gamma*, *len - to receive current color mode
|
||||||
|
IO_CTRL_CODE_SET_CUSTOM_GAMMA, // 用于设置用户自定义gamma数值,data - SANE_Gamma*, len - unused
|
||||||
|
IO_CTRL_CODE_DISPLAY_APP_HELP, // 显示APP帮助文档 data - NULL, len - NULL
|
||||||
|
IO_CTRL_CODE_GET_PAPER_SIZE, // 获取纸张尺寸(mm)。 data - (utf8*)paper name, *len - MAKELPARAM(w, h)
|
||||||
|
IO_CTRL_CODE_GET_IMAGE_QUEUE_COUNT, // 获取图像队列的长度/数量, data - NULL, len - to receive the count
|
||||||
|
IO_CTRL_CODE_CONVERT_IMAGE_FORMAT, // 图像格式转换(文件方式), data - SANE_ImageFormatConvert*, len - unused, be NULL
|
||||||
|
IO_CTRL_CODE_FREE_MEMORY, // 释放由该模块分配的内存, data - 内存块,*len - 内存块长度
|
||||||
|
|
||||||
|
IO_CTRL_CODE_GET_LOG_FILE, // 获取日志文件,data - char[260],用于接收日志文件路径,返回空则获取失败;*len - 日志文件类型 SANE_LogFileType.
|
||||||
|
// 返回的日志文件,如果不再使用,调用者负责删除。
|
||||||
|
IO_CTRL_CODE_GET_SCAN_ISLOCK, // 获取设备是否支持锁定设备功能,data - (SANE_Bool*), *len - sizeof(SANE_Bool)
|
||||||
|
IO_CTRL_CODE_SET_SCAN_LOCK, // 设置设备锁定, data - (SANE_Bool), len - unused
|
||||||
|
IO_CTRL_CODE_SET_SCAN_LOCK_CHECK_VAL, // 设置校验码 ,data - (char*), *len - bytes of data
|
||||||
|
IO_CTRL_CODE_SET_FIRMWARE_UPGRADE, // 设置固件升级,data - (char*), *len - bytes of data
|
||||||
|
IO_CTRL_CODE_GET_HISTORY_ROLLER_NUM, // 获取历史滚轴张数 data - (SANE_Int*), *len - sizeof(SANE_Int)
|
||||||
|
IO_CTRL_CODE_GET_CLEAN_PAPER_ROAD, // 清除纸道 data - (SANE_Bool*), *len - sizeof(SANE_Bool)
|
||||||
|
IO_CTRL_CODE_GET_SCANN_NUM, // 获取扫描张数 data - (SANE_Int*), *len - sizeof(SANE_Int)
|
||||||
|
// all control code must be less than the following value
|
||||||
|
IO_CTRL_CODE_LAST = 0x10000000,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Function: 直接访问控制
|
||||||
|
//
|
||||||
|
// Parameter: h - hg_open_scanner打开的设备句柄
|
||||||
|
//
|
||||||
|
// code - 控制码
|
||||||
|
//
|
||||||
|
// data - 用户分配的内存,对应于控制码的原始数据
|
||||||
|
//
|
||||||
|
// len - data中数据长度。如果是获取操作时,长度小于所需要的长度,则返回需要的长度且返回 E_INSUFFICIENTMEM 的错误
|
||||||
|
//
|
||||||
|
// Return: 错误码
|
||||||
|
extern SANE_Status sane_io_control(SANE_Handle h, unsigned long code, void* data, unsigned* len);
|
||||||
|
|
||||||
|
// Function: 获取错误描述
|
||||||
|
//
|
||||||
|
// Parameters: err - 其它SANE函数返回的错误代码
|
||||||
|
//
|
||||||
|
// Return: 错误描述信息(UTF-8),调用者应立即使用,无须释放
|
||||||
|
extern const char* sane_err_desc(SANE_Status err);
|
||||||
|
|
||||||
|
// for ui interface
|
||||||
|
typedef struct _sane_api
|
||||||
|
{
|
||||||
|
SANE_Status (*sane_get_devices_api)(const SANE_Device*** device_list, SANE_Bool local_only);
|
||||||
|
SANE_Status (*sane_open_api)(SANE_String_Const devicename, SANE_Handle* handle);
|
||||||
|
void (* sane_close_api)(SANE_Handle handle);
|
||||||
|
const SANE_Option_Descriptor* (*sane_get_option_descriptor_api)(SANE_Handle handle, SANE_Int option);
|
||||||
|
SANE_Status (*sane_control_option_api)(SANE_Handle handle, SANE_Int option, SANE_Action action, void* value, SANE_Int* info);
|
||||||
|
SANE_Status (*sane_get_parameters_api)(SANE_Handle handle, SANE_Parameters* params);
|
||||||
|
SANE_Status (*sane_start_api)(SANE_Handle handle);
|
||||||
|
SANE_Status (*sane_read_api)(SANE_Handle handle, SANE_Byte* data, SANE_Int max_length, SANE_Int* length);
|
||||||
|
void (*sane_cancel_api)(SANE_Handle handle);
|
||||||
|
SANE_Status (*sane_set_io_mode_api)(SANE_Handle handle, SANE_Bool non_blocking);
|
||||||
|
SANE_Status (*sane_get_select_fd_api)(SANE_Handle handle, SANE_Int* fd);
|
||||||
|
SANE_String_Const (*sane_strstatus_api)(SANE_Status status);
|
||||||
|
SANE_Status (*sane_io_control_api)(SANE_Handle h, unsigned long code, void* data, unsigned* len);
|
||||||
|
}SANEAPI, *LPSANEAPI;
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* sane_ex_h */
|
|
@ -0,0 +1,416 @@
|
||||||
|
//
|
||||||
|
// definitions for option titles and values
|
||||||
|
//
|
||||||
|
// all multi-bytes letter are in UTF-8 format
|
||||||
|
//
|
||||||
|
// Date: 2022-09-30 14:23:02
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_HFMRSZ "恢复默认设置"
|
||||||
|
#define OPTION_TITLE_HFMRSZ "\346\201\242\345\244\215\351\273\230\350\256\244\350\256\276\347\275\256"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_BZ "帮助"
|
||||||
|
#define OPTION_TITLE_BZ "\345\270\256\345\212\251"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_DLSC "多流输出"
|
||||||
|
#define OPTION_TITLE_DLSC "\345\244\232\346\265\201\350\276\223\345\207\272"
|
||||||
|
// #define OPTION_TITLE_DLSCLX "多流输出类型"
|
||||||
|
#define OPTION_TITLE_DLSCLX "\345\244\232\346\265\201\350\276\223\345\207\272\347\261\273\345\236\213"
|
||||||
|
// #define OPTION_VALUE_DLSCLX_W "无"
|
||||||
|
#define OPTION_VALUE_DLSCLX_W "\346\227\240"
|
||||||
|
// #define OPTION_VALUE_DLSCLX_CS_HD_HB "彩色+灰度+黑白"
|
||||||
|
#define OPTION_VALUE_DLSCLX_CS_HD_HB "\345\275\251\350\211\262+\347\201\260\345\272\246+\351\273\221\347\231\275"
|
||||||
|
// #define OPTION_VALUE_DLSCLX_CS_HD "彩色+灰度"
|
||||||
|
#define OPTION_VALUE_DLSCLX_CS_HD "\345\275\251\350\211\262+\347\201\260\345\272\246"
|
||||||
|
// #define OPTION_VALUE_DLSCLX_CS_HB "彩色+黑白"
|
||||||
|
#define OPTION_VALUE_DLSCLX_CS_HB "\345\275\251\350\211\262+\351\273\221\347\231\275"
|
||||||
|
// #define OPTION_VALUE_DLSCLX_HD_HB "灰度+黑白"
|
||||||
|
#define OPTION_VALUE_DLSCLX_HD_HB "\347\201\260\345\272\246+\351\273\221\347\231\275"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_YSMS "颜色模式"
|
||||||
|
#define OPTION_TITLE_YSMS "\351\242\234\350\211\262\346\250\241\345\274\217"
|
||||||
|
// #define OPTION_VALUE_YSMS_24WCS "24位彩色"
|
||||||
|
#define OPTION_VALUE_YSMS_24WCS "24\344\275\215\345\275\251\350\211\262"
|
||||||
|
// #define OPTION_VALUE_YSMS_256JHD "256级灰度"
|
||||||
|
#define OPTION_VALUE_YSMS_256JHD "256\347\272\247\347\201\260\345\272\246"
|
||||||
|
// #define OPTION_VALUE_YSMS_HB "黑白"
|
||||||
|
#define OPTION_VALUE_YSMS_HB "\351\273\221\347\231\275"
|
||||||
|
// #define OPTION_VALUE_YSMS_YSZDSB "颜色自动识别"
|
||||||
|
#define OPTION_VALUE_YSMS_YSZDSB "\351\242\234\350\211\262\350\207\252\345\212\250\350\257\206\345\210\253"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_HBTXYZ "黑白图像阈值"
|
||||||
|
#define OPTION_TITLE_HBTXYZ "\351\273\221\347\231\275\345\233\276\345\203\217\351\230\210\345\200\274"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_HBTXFSSC "黑白图像反色输出"
|
||||||
|
#define OPTION_TITLE_HBTXFSSC "\351\273\221\347\231\275\345\233\276\345\203\217\345\217\215\350\211\262\350\276\223\345\207\272"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_HDHHBTX_CSYZQ "灰度或黑白图像 - 除色与增强"
|
||||||
|
#define OPTION_TITLE_HDHHBTX_CSYZQ "\347\201\260\345\272\246\346\210\226\351\273\221\347\231\275\345\233\276\345\203\217 - \351\231\244\350\211\262\344\270\216\345\242\236\345\274\272"
|
||||||
|
// #define OPTION_VALUE_HDHHBTX_CSYZQ_BCS "不除色"
|
||||||
|
#define OPTION_VALUE_HDHHBTX_CSYZQ_BCS "\344\270\215\351\231\244\350\211\262"
|
||||||
|
// #define OPTION_VALUE_HDHHBTX_CSYZQ_CHS "除红色"
|
||||||
|
#define OPTION_VALUE_HDHHBTX_CSYZQ_CHS "\351\231\244\347\272\242\350\211\262"
|
||||||
|
// #define OPTION_VALUE_HDHHBTX_CSYZQ_CLS "除绿色"
|
||||||
|
#define OPTION_VALUE_HDHHBTX_CSYZQ_CLS "\351\231\244\347\273\277\350\211\262"
|
||||||
|
// #define OPTION_VALUE_HDHHBTX_CSYZQ_CHULANSE "除蓝色"
|
||||||
|
#define OPTION_VALUE_HDHHBTX_CSYZQ_CHULANSE "\351\231\244\350\223\235\350\211\262"
|
||||||
|
// #define OPTION_VALUE_HDHHBTX_CSYZQ_HSZQ "红色增强"
|
||||||
|
#define OPTION_VALUE_HDHHBTX_CSYZQ_HSZQ "\347\272\242\350\211\262\345\242\236\345\274\272"
|
||||||
|
// #define OPTION_VALUE_HDHHBTX_CSYZQ_LSZQ "绿色增强"
|
||||||
|
#define OPTION_VALUE_HDHHBTX_CSYZQ_LSZQ "\347\273\277\350\211\262\345\242\236\345\274\272"
|
||||||
|
// #define OPTION_VALUE_HDHHBTX_CSYZQ_LANSEZENGQIANG "蓝色增强"
|
||||||
|
#define OPTION_VALUE_HDHHBTX_CSYZQ_LANSEZENGQIANG "\350\223\235\350\211\262\345\242\236\345\274\272"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_24WCSTX_DLSCCH "24位彩色图像 - 多流输出除红"
|
||||||
|
#define OPTION_TITLE_24WCSTX_DLSCCH "24\344\275\215\345\275\251\350\211\262\345\233\276\345\203\217 - \345\244\232\346\265\201\350\276\223\345\207\272\351\231\244\347\272\242"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_24WCSTX_DTKCH "24位彩色图像 - 答题卡除红"
|
||||||
|
#define OPTION_TITLE_24WCSTX_DTKCH "24\344\275\215\345\275\251\350\211\262\345\233\276\345\203\217 - \347\255\224\351\242\230\345\215\241\351\231\244\347\272\242"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_BJYC "背景移除"
|
||||||
|
#define OPTION_TITLE_BJYC "\350\203\214\346\231\257\347\247\273\351\231\244"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_BJSCFDFW "背景色彩浮动范围"
|
||||||
|
#define OPTION_TITLE_BJSCFDFW "\350\203\214\346\231\257\350\211\262\345\275\251\346\265\256\345\212\250\350\214\203\345\233\264"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_RHYMH "锐化与模糊"
|
||||||
|
#define OPTION_TITLE_RHYMH "\351\224\220\345\214\226\344\270\216\346\250\241\347\263\212"
|
||||||
|
// #define OPTION_VALUE_RHYMH_W "无"
|
||||||
|
#define OPTION_VALUE_RHYMH_W "\346\227\240"
|
||||||
|
// #define OPTION_VALUE_RHYMH_RH "锐化"
|
||||||
|
#define OPTION_VALUE_RHYMH_RH "\351\224\220\345\214\226"
|
||||||
|
// #define OPTION_VALUE_RHYMH_JYBRH "进一步锐化"
|
||||||
|
#define OPTION_VALUE_RHYMH_JYBRH "\350\277\233\344\270\200\346\255\245\351\224\220\345\214\226"
|
||||||
|
// #define OPTION_VALUE_RHYMH_MH "模糊"
|
||||||
|
#define OPTION_VALUE_RHYMH_MH "\346\250\241\347\263\212"
|
||||||
|
// #define OPTION_VALUE_RHYMH_JYBMH "进一步模糊"
|
||||||
|
#define OPTION_VALUE_RHYMH_JYBMH "\350\277\233\344\270\200\346\255\245\346\250\241\347\263\212"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_QCMW "去除摩尔纹"
|
||||||
|
#define OPTION_TITLE_QCMW "\345\216\273\351\231\244\346\221\251\345\260\224\347\272\271"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_CWW "除网纹"
|
||||||
|
#define OPTION_TITLE_CWW "\351\231\244\347\275\221\347\272\271"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_CWKS "错误扩散"
|
||||||
|
#define OPTION_TITLE_CWKS "\351\224\231\350\257\257\346\211\251\346\225\243"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_HBTXZDYH "黑白图像噪点优化"
|
||||||
|
#define OPTION_TITLE_HBTXZDYH "\351\273\221\347\231\275\345\233\276\345\203\217\345\231\252\347\202\271\344\274\230\345\214\226"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_ZDYHCC "噪点优化尺寸"
|
||||||
|
#define OPTION_TITLE_ZDYHCC "\345\231\252\347\202\271\344\274\230\345\214\226\345\260\272\345\257\270"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_ZZCC "纸张尺寸"
|
||||||
|
#define OPTION_TITLE_ZZCC "\347\272\270\345\274\240\345\260\272\345\257\270"
|
||||||
|
// #define OPTION_VALUE_ZZCC_A3 "A3"
|
||||||
|
#define OPTION_VALUE_ZZCC_A3 "A3"
|
||||||
|
// #define OPTION_VALUE_ZZCC_8K "8开"
|
||||||
|
#define OPTION_VALUE_ZZCC_8K "8\345\274\200"
|
||||||
|
// #define OPTION_VALUE_ZZCC_A4 "A4"
|
||||||
|
#define OPTION_VALUE_ZZCC_A4 "A4"
|
||||||
|
// #define OPTION_VALUE_ZZCC_A4HX "A4横向"
|
||||||
|
#define OPTION_VALUE_ZZCC_A4HX "A4\346\250\252\345\220\221"
|
||||||
|
// #define OPTION_VALUE_ZZCC_16K "16开"
|
||||||
|
#define OPTION_VALUE_ZZCC_16K "16\345\274\200"
|
||||||
|
// #define OPTION_VALUE_ZZCC_16KHX "16开横向"
|
||||||
|
#define OPTION_VALUE_ZZCC_16KHX "16\345\274\200\346\250\252\345\220\221"
|
||||||
|
// #define OPTION_VALUE_ZZCC_A5 "A5"
|
||||||
|
#define OPTION_VALUE_ZZCC_A5 "A5"
|
||||||
|
// #define OPTION_VALUE_ZZCC_A5HX "A5横向"
|
||||||
|
#define OPTION_VALUE_ZZCC_A5HX "A5\346\250\252\345\220\221"
|
||||||
|
// #define OPTION_VALUE_ZZCC_A6 "A6"
|
||||||
|
#define OPTION_VALUE_ZZCC_A6 "A6"
|
||||||
|
// #define OPTION_VALUE_ZZCC_A6HX "A6横向"
|
||||||
|
#define OPTION_VALUE_ZZCC_A6HX "A6\346\250\252\345\220\221"
|
||||||
|
// #define OPTION_VALUE_ZZCC_B4 "B4"
|
||||||
|
#define OPTION_VALUE_ZZCC_B4 "B4"
|
||||||
|
// #define OPTION_VALUE_ZZCC_B5 "B5"
|
||||||
|
#define OPTION_VALUE_ZZCC_B5 "B5"
|
||||||
|
// #define OPTION_VALUE_ZZCC_B5HX "B5横向"
|
||||||
|
#define OPTION_VALUE_ZZCC_B5HX "B5\346\250\252\345\220\221"
|
||||||
|
// #define OPTION_VALUE_ZZCC_B6 "B6"
|
||||||
|
#define OPTION_VALUE_ZZCC_B6 "B6"
|
||||||
|
// #define OPTION_VALUE_ZZCC_B6HX "B6横向"
|
||||||
|
#define OPTION_VALUE_ZZCC_B6HX "B6\346\250\252\345\220\221"
|
||||||
|
// #define OPTION_VALUE_ZZCC_Letter "Letter"
|
||||||
|
#define OPTION_VALUE_ZZCC_Letter "Letter"
|
||||||
|
// #define OPTION_VALUE_ZZCC_LetterHX "Letter横向"
|
||||||
|
#define OPTION_VALUE_ZZCC_LetterHX "Letter\346\250\252\345\220\221"
|
||||||
|
// #define OPTION_VALUE_ZZCC_DoubleLetter "Double Letter"
|
||||||
|
#define OPTION_VALUE_ZZCC_DoubleLetter "Double Letter"
|
||||||
|
// #define OPTION_VALUE_ZZCC_LEGAL "LEGAL"
|
||||||
|
#define OPTION_VALUE_ZZCC_LEGAL "LEGAL"
|
||||||
|
// #define OPTION_VALUE_ZZCC_PPYSCC "匹配原始尺寸"
|
||||||
|
#define OPTION_VALUE_ZZCC_PPYSCC "\345\214\271\351\205\215\345\216\237\345\247\213\345\260\272\345\257\270"
|
||||||
|
// #define OPTION_VALUE_ZZCC_ZDSMCCZDCQ "最大扫描尺寸自动裁切"
|
||||||
|
#define OPTION_VALUE_ZZCC_ZDSMCCZDCQ "\346\234\200\345\244\247\346\211\253\346\217\217\345\260\272\345\257\270\350\207\252\345\212\250\350\243\201\345\210\207"
|
||||||
|
// #define OPTION_VALUE_ZZCC_ZDSMCC "最大扫描尺寸"
|
||||||
|
#define OPTION_VALUE_ZZCC_ZDSMCC "\346\234\200\345\244\247\346\211\253\346\217\217\345\260\272\345\257\270"
|
||||||
|
// #define OPTION_VALUE_ZZCC_SLSJ "三联试卷"
|
||||||
|
#define OPTION_VALUE_ZZCC_SLSJ "\344\270\211\350\201\224\350\257\225\345\215\267"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_ZDYSMQY "自定义扫描区域"
|
||||||
|
#define OPTION_TITLE_ZDYSMQY "\350\207\252\345\256\232\344\271\211\346\211\253\346\217\217\345\214\272\345\237\237"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_SMQYZCmm "扫描区域左侧(mm)"
|
||||||
|
#define OPTION_TITLE_SMQYZCmm "\346\211\253\346\217\217\345\214\272\345\237\237\345\267\246\344\276\247\357\274\210mm\357\274\211"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_SMQYYCmm "扫描区域右侧(mm)"
|
||||||
|
#define OPTION_TITLE_SMQYYCmm "\346\211\253\346\217\217\345\214\272\345\237\237\345\217\263\344\276\247\357\274\210mm\357\274\211"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_SMQYSCmm "扫描区域上侧(mm)"
|
||||||
|
#define OPTION_TITLE_SMQYSCmm "\346\211\253\346\217\217\345\214\272\345\237\237\344\270\212\344\276\247\357\274\210mm\357\274\211"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_SMQYXCmm "扫描区域下侧(mm)"
|
||||||
|
#define OPTION_TITLE_SMQYXCmm "\346\211\253\346\217\217\345\214\272\345\237\237\344\270\213\344\276\247\357\274\210mm\357\274\211"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_CCJC "尺寸检测"
|
||||||
|
#define OPTION_TITLE_CCJC "\345\260\272\345\257\270\346\243\200\346\265\213"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_SMYM "扫描页面"
|
||||||
|
#define OPTION_TITLE_SMYM "\346\211\253\346\217\217\351\241\265\351\235\242"
|
||||||
|
// #define OPTION_VALUE_SMYM_DM "单面"
|
||||||
|
#define OPTION_VALUE_SMYM_DM "\345\215\225\351\235\242"
|
||||||
|
// #define OPTION_VALUE_SMYM_SM "双面"
|
||||||
|
#define OPTION_VALUE_SMYM_SM "\345\217\214\351\235\242"
|
||||||
|
// #define OPTION_VALUE_SMYM_TGKBYTY "跳过空白页(通用)"
|
||||||
|
#define OPTION_VALUE_SMYM_TGKBYTY "\350\267\263\350\277\207\347\251\272\347\231\275\351\241\265\357\274\210\351\200\232\347\224\250\357\274\211"
|
||||||
|
// #define OPTION_VALUE_SMYM_TGKBYFPZ "跳过空白页(发票纸)"
|
||||||
|
#define OPTION_VALUE_SMYM_TGKBYFPZ "\350\267\263\350\277\207\347\251\272\347\231\275\351\241\265\357\274\210\345\217\221\347\245\250\347\272\270\357\274\211"
|
||||||
|
// #define OPTION_VALUE_SMYM_DZ "对折"
|
||||||
|
#define OPTION_VALUE_SMYM_DZ "\345\257\271\346\212\230"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_TGKBYLMD "跳过空白页灵敏度"
|
||||||
|
#define OPTION_TITLE_TGKBYLMD "\350\267\263\350\277\207\347\251\272\347\231\275\351\241\265\347\201\265\346\225\217\345\272\246"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_FBL "分辨率"
|
||||||
|
#define OPTION_TITLE_FBL "\345\210\206\350\276\250\347\216\207"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_HZ "画质"
|
||||||
|
#define OPTION_TITLE_HZ "\347\224\273\350\264\250"
|
||||||
|
// #define OPTION_VALUE_HZ_W "无"
|
||||||
|
#define OPTION_VALUE_HZ_W "\346\227\240"
|
||||||
|
// #define OPTION_VALUE_HZ_SDYX "速度优先"
|
||||||
|
#define OPTION_VALUE_HZ_SDYX "\351\200\237\345\272\246\344\274\230\345\205\210"
|
||||||
|
// #define OPTION_VALUE_HZ_HZYX "画质优先"
|
||||||
|
#define OPTION_VALUE_HZ_HZYX "\347\224\273\350\264\250\344\274\230\345\205\210"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_JHZFM "交换正反面"
|
||||||
|
#define OPTION_TITLE_JHZFM "\344\272\244\346\215\242\346\255\243\345\217\215\351\235\242"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_QYSDQX "启用色调曲线"
|
||||||
|
#define OPTION_TITLE_QYSDQX "\345\220\257\347\224\250\350\211\262\350\260\203\346\233\262\347\272\277"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_LDZ "亮度值"
|
||||||
|
#define OPTION_TITLE_LDZ "\344\272\256\345\272\246\345\200\274"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_DBD "对比度"
|
||||||
|
#define OPTION_TITLE_DBD "\345\257\271\346\257\224\345\272\246"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_JMZ "伽马值"
|
||||||
|
#define OPTION_TITLE_JMZ "\344\274\275\351\251\254\345\200\274"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_ZDJP "自动纠偏"
|
||||||
|
#define OPTION_TITLE_ZDJP "\350\207\252\345\212\250\347\272\240\345\201\217"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_TXCF "图像拆分"
|
||||||
|
#define OPTION_TITLE_TXCF "\345\233\276\345\203\217\346\213\206\345\210\206"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_ZPMS "照片模式"
|
||||||
|
#define OPTION_TITLE_ZPMS "\347\205\247\347\211\207\346\250\241\345\274\217"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_XCHK "消除黑框"
|
||||||
|
#define OPTION_TITLE_XCHK "\346\266\210\351\231\244\351\273\221\346\241\206"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_BJTCFS "背景填充方式"
|
||||||
|
#define OPTION_TITLE_BJTCFS "\350\203\214\346\231\257\345\241\253\345\205\205\346\226\271\345\274\217"
|
||||||
|
// #define OPTION_VALUE_BJTCFS_TDBX "凸多边形"
|
||||||
|
#define OPTION_VALUE_BJTCFS_TDBX "\345\207\270\345\244\232\350\276\271\345\275\242"
|
||||||
|
// #define OPTION_VALUE_BJTCFS_ADBX "凹多边形"
|
||||||
|
#define OPTION_VALUE_BJTCFS_ADBX "\345\207\271\345\244\232\350\276\271\345\275\242"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_SCTC "色彩填充"
|
||||||
|
#define OPTION_TITLE_SCTC "\350\211\262\345\275\251\345\241\253\345\205\205"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_YZ "阈值"
|
||||||
|
#define OPTION_TITLE_YZ "\351\230\210\345\200\274"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_BJKZDJ "背景抗噪等级"
|
||||||
|
#define OPTION_TITLE_BJKZDJ "\350\203\214\346\231\257\346\212\227\345\231\252\347\255\211\347\272\247"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_BYSJ "边缘缩进"
|
||||||
|
#define OPTION_TITLE_BYSJ "\350\276\271\347\274\230\347\274\251\350\277\233"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_SSYZ "深色样张"
|
||||||
|
#define OPTION_TITLE_SSYZ "\346\267\261\350\211\262\346\240\267\345\274\240"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_FZST "防止渗透"
|
||||||
|
#define OPTION_TITLE_FZST "\351\230\262\346\255\242\346\270\227\351\200\217"
|
||||||
|
// #define OPTION_TITLE_FZSTDJ "防止渗透等级"
|
||||||
|
#define OPTION_TITLE_FZSTDJ "\351\230\262\346\255\242\346\270\227\351\200\217\347\255\211\347\272\247"
|
||||||
|
// #define OPTION_VALUE_FZSTDJ_R "弱"
|
||||||
|
#define OPTION_VALUE_FZSTDJ_R "\345\274\261"
|
||||||
|
// #define OPTION_VALUE_FZSTDJ_JR "较弱"
|
||||||
|
#define OPTION_VALUE_FZSTDJ_JR "\350\276\203\345\274\261"
|
||||||
|
// #define OPTION_VALUE_FZSTDJ_YB "一般"
|
||||||
|
#define OPTION_VALUE_FZSTDJ_YB "\344\270\200\350\210\254"
|
||||||
|
// #define OPTION_VALUE_FZSTDJ_JQ "较强"
|
||||||
|
#define OPTION_VALUE_FZSTDJ_JQ "\350\276\203\345\274\272"
|
||||||
|
// #define OPTION_VALUE_FZSTDJ_Q "强"
|
||||||
|
#define OPTION_VALUE_FZSTDJ_Q "\345\274\272"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_CKYC "穿孔移除"
|
||||||
|
#define OPTION_TITLE_CKYC "\347\251\277\345\255\224\347\247\273\351\231\244"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_CKSSFWZFMBL "穿孔搜索范围占幅面比例"
|
||||||
|
#define OPTION_TITLE_CKSSFWZFMBL "\347\251\277\345\255\224\346\220\234\347\264\242\350\214\203\345\233\264\345\215\240\345\271\205\351\235\242\346\257\224\344\276\213"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_CKYCZC "穿孔移除—左侧"
|
||||||
|
#define OPTION_TITLE_CKYCZC "\347\251\277\345\255\224\347\247\273\351\231\244\342\200\224\345\267\246\344\276\247"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_ZCCKSSFWZFMBL "左侧穿孔搜索范围占幅面比例"
|
||||||
|
#define OPTION_TITLE_ZCCKSSFWZFMBL "\345\267\246\344\276\247\347\251\277\345\255\224\346\220\234\347\264\242\350\214\203\345\233\264\345\215\240\345\271\205\351\235\242\346\257\224\344\276\213"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_CKYCYC "穿孔移除—右侧"
|
||||||
|
#define OPTION_TITLE_CKYCYC "\347\251\277\345\255\224\347\247\273\351\231\244\342\200\224\345\217\263\344\276\247"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_YCCKSSFWZFMBL "右侧穿孔搜索范围占幅面比例"
|
||||||
|
#define OPTION_TITLE_YCCKSSFWZFMBL "\345\217\263\344\276\247\347\251\277\345\255\224\346\220\234\347\264\242\350\214\203\345\233\264\345\215\240\345\271\205\351\235\242\346\257\224\344\276\213"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_CKYCSC "穿孔移除—上侧"
|
||||||
|
#define OPTION_TITLE_CKYCSC "\347\251\277\345\255\224\347\247\273\351\231\244\342\200\224\344\270\212\344\276\247"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_SCCKSSFWZFMBL "上侧穿孔搜索范围占幅面比例"
|
||||||
|
#define OPTION_TITLE_SCCKSSFWZFMBL "\344\270\212\344\276\247\347\251\277\345\255\224\346\220\234\347\264\242\350\214\203\345\233\264\345\215\240\345\271\205\351\235\242\346\257\224\344\276\213"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_CKYCXC "穿孔移除—下侧"
|
||||||
|
#define OPTION_TITLE_CKYCXC "\347\251\277\345\255\224\347\247\273\351\231\244\342\200\224\344\270\213\344\276\247"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_XCCKSSFWZFMBL "下侧穿孔搜索范围占幅面比例"
|
||||||
|
#define OPTION_TITLE_XCCKSSFWZFMBL "\344\270\213\344\276\247\347\251\277\345\255\224\346\220\234\347\264\242\350\214\203\345\233\264\345\215\240\345\271\205\351\235\242\346\257\224\344\276\213"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_DZSM "待纸扫描"
|
||||||
|
#define OPTION_TITLE_DZSM "\345\276\205\347\272\270\346\211\253\346\217\217"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_SMZS "扫描张数"
|
||||||
|
#define OPTION_TITLE_SMZS "\346\211\253\346\217\217\345\274\240\346\225\260"
|
||||||
|
// #define OPTION_VALUE_SMZS_LXSM "连续扫描"
|
||||||
|
#define OPTION_VALUE_SMZS_LXSM "\350\277\236\347\273\255\346\211\253\346\217\217"
|
||||||
|
// #define OPTION_VALUE_SMZS_SMZDZS "扫描指定张数"
|
||||||
|
#define OPTION_VALUE_SMZS_SMZDZS "\346\211\253\346\217\217\346\214\207\345\256\232\345\274\240\346\225\260"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_SMSL "扫描数量"
|
||||||
|
#define OPTION_TITLE_SMSL "\346\211\253\346\217\217\346\225\260\351\207\217"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_WGFX "文稿方向"
|
||||||
|
#define OPTION_TITLE_WGFX "\346\226\207\347\250\277\346\226\271\345\220\221"
|
||||||
|
// #define OPTION_VALUE_WGFX_0 "0°"
|
||||||
|
#define OPTION_VALUE_WGFX_0 "0\302\260"
|
||||||
|
// #define OPTION_VALUE_WGFX_90 "90°"
|
||||||
|
#define OPTION_VALUE_WGFX_90 "90\302\260"
|
||||||
|
// #define OPTION_VALUE_WGFX_180 "180°"
|
||||||
|
#define OPTION_VALUE_WGFX_180 "180\302\260"
|
||||||
|
// #define OPTION_VALUE_WGFX__90 "-90°"
|
||||||
|
#define OPTION_VALUE_WGFX__90 "-90\302\260"
|
||||||
|
// #define OPTION_VALUE_WGFX_ZDWBFXSB "自动文本方向识别°"
|
||||||
|
#define OPTION_VALUE_WGFX_ZDWBFXSB "\350\207\252\345\212\250\346\226\207\346\234\254\346\226\271\345\220\221\350\257\206\345\210\253\302\260"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_BMXZ180 "背面旋转180°"
|
||||||
|
#define OPTION_TITLE_BMXZ180 "\350\203\214\351\235\242\346\227\213\350\275\254180\302\260"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_CSBJC "超声波检测"
|
||||||
|
#define OPTION_TITLE_CSBJC "\350\266\205\345\243\260\346\263\242\346\243\200\346\265\213"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_SZTPCL "双张图片处理"
|
||||||
|
#define OPTION_TITLE_SZTPCL "\345\217\214\345\274\240\345\233\276\347\211\207\345\244\204\347\220\206"
|
||||||
|
// #define OPTION_VALUE_SZTPCL_DQTXBTZSM "丢弃图像并停止扫描"
|
||||||
|
#define OPTION_VALUE_SZTPCL_DQTXBTZSM "\344\270\242\345\274\203\345\233\276\345\203\217\345\271\266\345\201\234\346\255\242\346\211\253\346\217\217"
|
||||||
|
// #define OPTION_VALUE_SZTPCL_DQTXBJXSM "丢弃图像并继续扫描"
|
||||||
|
#define OPTION_VALUE_SZTPCL_DQTXBJXSM "\344\270\242\345\274\203\345\233\276\345\203\217\345\271\266\347\273\247\347\273\255\346\211\253\346\217\217"
|
||||||
|
// #define OPTION_VALUE_SZTPCL_SCTXBTZSM "上传图像并停止扫描"
|
||||||
|
#define OPTION_VALUE_SZTPCL_SCTXBTZSM "\344\270\212\344\274\240\345\233\276\345\203\217\345\271\266\345\201\234\346\255\242\346\211\253\346\217\217"
|
||||||
|
// #define OPTION_VALUE_SZTPCL_SCTXBJXSM "上传图像并继续扫描"
|
||||||
|
#define OPTION_VALUE_SZTPCL_SCTXBJXSM "\344\270\212\344\274\240\345\233\276\345\203\217\345\271\266\347\273\247\347\273\255\346\211\253\346\217\217"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_ZDJC "装订检测"
|
||||||
|
#define OPTION_TITLE_ZDJC "\350\243\205\350\256\242\346\243\200\346\265\213"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_WXJC "歪斜检测"
|
||||||
|
#define OPTION_TITLE_WXJC "\346\255\252\346\226\234\346\243\200\346\265\213"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_WXRRD "歪斜容忍度"
|
||||||
|
#define OPTION_TITLE_WXRRD "\346\255\252\346\226\234\345\256\271\345\277\215\345\272\246"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_ZJJC "折角检测"
|
||||||
|
#define OPTION_TITLE_ZJJC "\346\212\230\350\247\222\346\243\200\346\265\213"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_ZJDX "折角大小"
|
||||||
|
#define OPTION_TITLE_ZJDX "\346\212\230\350\247\222\345\244\247\345\260\217"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_FZQD "分纸强度"
|
||||||
|
#define OPTION_TITLE_FZQD "\345\210\206\347\272\270\345\274\272\345\272\246"
|
||||||
|
// #define OPTION_VALUE_FZQD_R "弱"
|
||||||
|
#define OPTION_VALUE_FZQD_R "\345\274\261"
|
||||||
|
// #define OPTION_VALUE_FZQD_YB "一般"
|
||||||
|
#define OPTION_VALUE_FZQD_YB "\344\270\200\350\210\254"
|
||||||
|
// #define OPTION_VALUE_FZQD_Q "强"
|
||||||
|
#define OPTION_VALUE_FZQD_Q "\345\274\272"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_XMSJ "休眠时间"
|
||||||
|
#define OPTION_TITLE_XMSJ "\344\274\221\347\234\240\346\227\266\351\227\264"
|
||||||
|
// #define OPTION_VALUE_XMSJ_BXM "不休眠"
|
||||||
|
#define OPTION_VALUE_XMSJ_BXM "\344\270\215\344\274\221\347\234\240"
|
||||||
|
// #define OPTION_VALUE_XMSJ_WFZ "五分钟"
|
||||||
|
#define OPTION_VALUE_XMSJ_WFZ "\344\272\224\345\210\206\351\222\237"
|
||||||
|
// #define OPTION_VALUE_XMSJ_SFZ "十分钟"
|
||||||
|
#define OPTION_VALUE_XMSJ_SFZ "\345\215\201\345\210\206\351\222\237"
|
||||||
|
// #define OPTION_VALUE_XMSJ_BXS "半小时"
|
||||||
|
#define OPTION_VALUE_XMSJ_BXS "\345\215\212\345\260\217\346\227\266"
|
||||||
|
// #define OPTION_VALUE_XMSJ_YXS "一小时"
|
||||||
|
#define OPTION_VALUE_XMSJ_YXS "\344\270\200\345\260\217\346\227\266"
|
||||||
|
// #define OPTION_VALUE_XMSJ_LXS "两小时"
|
||||||
|
#define OPTION_VALUE_XMSJ_LXS "\344\270\244\345\260\217\346\227\266"
|
||||||
|
// #define OPTION_VALUE_XMSJ_SXS "四小时"
|
||||||
|
#define OPTION_VALUE_XMSJ_SXS "\345\233\233\345\260\217\346\227\266"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_ZDFZQD "自动分纸强度"
|
||||||
|
#define OPTION_TITLE_ZDFZQD "\350\207\252\345\212\250\345\210\206\347\272\270\345\274\272\345\272\246"
|
||||||
|
|
||||||
|
// #define OPTION_TITLE_JZSBL "进纸失败率"
|
||||||
|
#define OPTION_TITLE_JZSBL "\350\277\233\347\272\270\345\244\261\350\264\245\347\216\207"
|
||||||
|
|
||||||
|
//#define OPTION_TITLE_DZMS "对折模式"
|
||||||
|
#define OPTION_TITLE_DZMS "\345\257\271\346\212\230\346\250\241\345\274\217"
|
||||||
|
//#define OPTION_VALUE_ZYDZ "左右对折"
|
||||||
|
#define OPTION_VALUE_ZYDZ "\345\267\246\345\217\263\345\257\271\346\212\230"
|
||||||
|
//#define OPTION_VALUE_SXDZ "上下对折"
|
||||||
|
#define OPTION_VALUE_SXDZ "\344\270\212\344\270\213\345\257\271\346\212\230"
|
||||||
|
//#define OPTION_VALUE_SXDZ "自动对折"
|
||||||
|
#define OPTION_VALUE_ZDDZ "\350\207\252\345\212\250\345\257\271\346\212\230"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
// reserved ...
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
#define OPTION_TITLE_GMZ OPTION_TITLE_JMZ
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
// string compare ...
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
#define IMPLEMENT_OPTION_STRING_COMPARE(func_name) \
|
||||||
|
bool func_name(const char* opt_define, const char* value) \
|
||||||
|
{ \
|
||||||
|
while(*value++ == L' '); \
|
||||||
|
value--; \
|
||||||
|
return strcmp(opt_define, value) == 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
/* sane - Scanner Access Now Easy.
|
||||||
|
Copyright (C) 1996 David Mosberger-Tang and Andreas Beck
|
||||||
|
Copyright (C) 2002, 2003 Henning Meier-Geinitz
|
||||||
|
|
||||||
|
This file is part of the SANE package.
|
||||||
|
|
||||||
|
SANE is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SANE is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with sane; see the file COPYING. If not, write to the Free
|
||||||
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
As a special exception, the authors of SANE give permission for
|
||||||
|
additional uses of the libraries contained in this release of SANE.
|
||||||
|
|
||||||
|
The exception is that, if you link a SANE library with other files
|
||||||
|
to produce an executable, this does not by itself cause the
|
||||||
|
resulting executable to be covered by the GNU General Public
|
||||||
|
License. Your use of that executable is in no way restricted on
|
||||||
|
account of linking the SANE library code into it.
|
||||||
|
|
||||||
|
This exception does not, however, invalidate any other reasons why
|
||||||
|
the executable file might be covered by the GNU General Public
|
||||||
|
License.
|
||||||
|
|
||||||
|
If you submit changes to SANE to the maintainers to be included in
|
||||||
|
a subsequent release, you agree by submitting the changes that
|
||||||
|
those changes may be distributed with this exception intact.
|
||||||
|
|
||||||
|
If you write modifications of your own for SANE, it is your choice
|
||||||
|
whether to permit this exception to apply to your modifications.
|
||||||
|
If you do not wish that, delete this exception notice.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file sanei.h
|
||||||
|
* Convenience macros and function declarations for backends
|
||||||
|
* @sa sanei_backend.h sanei_thread.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Doxygen documentation */
|
||||||
|
|
||||||
|
/** @mainpage SANEI (SANE internal routines) documentation
|
||||||
|
*
|
||||||
|
* @image html sane-logo2.jpg
|
||||||
|
* @section intro Introduction
|
||||||
|
*
|
||||||
|
* The header files in the include/sane/ directory named sanei_*.h provide
|
||||||
|
* function declarations and macros that can be used by every SANE backend.
|
||||||
|
* Their implementations can be found in the sanei/ directory. The code aims
|
||||||
|
* to be platform-independent to avoid lots of \#ifdef code in the backends.
|
||||||
|
* Please use the SANEI functions wherever possible.
|
||||||
|
*
|
||||||
|
* This documentation was created by the use of doxygen, the
|
||||||
|
* doc/doxygen-sanei.conf configuration file and documentation in the sanei_*.h
|
||||||
|
* files.
|
||||||
|
*
|
||||||
|
* This documentation is far from complete. Any help is appreciated.
|
||||||
|
*
|
||||||
|
* @section additional Additional documentation
|
||||||
|
* - The SANE standard can be found at <a
|
||||||
|
* href="http://www.sane-project.org/html/">the SANE webserver</a>,
|
||||||
|
* though the PostScript version produced from the source may be more recent.
|
||||||
|
* - Information on how to write a backend: <a
|
||||||
|
* href="../backend-writing.txt">backend-writing.txt</a>.
|
||||||
|
* - General SANE documentation is on <a
|
||||||
|
* href="http://www.sane-project.org/docs.html">the SANE documentation
|
||||||
|
* page</a>.
|
||||||
|
*
|
||||||
|
* @section contact Contact
|
||||||
|
*
|
||||||
|
* The common way to contact the developers of SANE is the sane-devel
|
||||||
|
* mailing list. See the <a
|
||||||
|
* href="http://www.sane-project.org/mailing-lists.html">mailing list webpage</a>
|
||||||
|
* for details. That's the place to ask questions, report bugs, or announce
|
||||||
|
* a new backend.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef sanei_h
|
||||||
|
#define sanei_h
|
||||||
|
|
||||||
|
#include <sane/sane.h>
|
||||||
|
|
||||||
|
/** @name Public macros and functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/** @def STRINGIFY(x)
|
||||||
|
* Turn parameter into string.
|
||||||
|
*/
|
||||||
|
/** @def PASTE(x,y)
|
||||||
|
* Concatenate parameters.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/** @def NELEMS(a)
|
||||||
|
* Return number of elements of an array.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @fn extern SANE_Status sanei_check_value (const SANE_Option_Descriptor * opt, void * value);
|
||||||
|
* Check the constraints of a SANE option.
|
||||||
|
*
|
||||||
|
* @param opt option to check
|
||||||
|
* @param value value of the option
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - SANE_STATUS_GOOD - on success
|
||||||
|
* - SANE_STATUS_INVAL - if the value doesn't fit inside the constraint
|
||||||
|
* or any other error occured
|
||||||
|
* @sa sanei_constrain_value()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @fn extern SANE_Status sanei_constrain_value (const SANE_Option_Descriptor * opt, void * value, SANE_Word * info);
|
||||||
|
* Check the constraints of a SANE option and adjust its value if necessary.
|
||||||
|
*
|
||||||
|
* Depending on the type of the option and constraint, value is modified
|
||||||
|
* to fit inside constraint.
|
||||||
|
*
|
||||||
|
* @param opt option to check
|
||||||
|
* @param value value of the option
|
||||||
|
* @param info info is set to SANE_INFO_INEXACT if value was changed
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - SANE_STATUS_GOOD - on success
|
||||||
|
* - SANE_STATUS_INVAL - if the function wasn't able to fit value into the
|
||||||
|
* constraint or any other error occured
|
||||||
|
* @sa sanei_check_value()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* @} */
|
||||||
|
|
||||||
|
/* A few convenience macros: */
|
||||||
|
/** @hideinitializer */
|
||||||
|
#define NELEMS(a) ((int)(sizeof (a) / sizeof (a[0])))
|
||||||
|
|
||||||
|
/** @hideinitializer */
|
||||||
|
#define STRINGIFY1(x) #x
|
||||||
|
/** @hideinitializer */
|
||||||
|
#define STRINGIFY(x) STRINGIFY1(x)
|
||||||
|
|
||||||
|
/** @hideinitializer */
|
||||||
|
#define PASTE1(x,y) x##y
|
||||||
|
/** @hideinitializer */
|
||||||
|
#define PASTE(x,y) PASTE1(x,y)
|
||||||
|
|
||||||
|
extern SANE_Status sanei_check_value (const SANE_Option_Descriptor * opt,
|
||||||
|
void * value);
|
||||||
|
|
||||||
|
extern SANE_Status sanei_constrain_value (const SANE_Option_Descriptor * opt,
|
||||||
|
void * value, SANE_Word * info);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* sanei_h */
|
|
@ -0,0 +1,188 @@
|
||||||
|
/** @file sanei_backend.h
|
||||||
|
* Compatibility header file for backends
|
||||||
|
*
|
||||||
|
* This file provides some defines for macros missing on some platforms.
|
||||||
|
* It also has the SANE API entry points. sanei_backend.h must be included
|
||||||
|
* by every backend.
|
||||||
|
*
|
||||||
|
* @sa sanei.h sanei_thread.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compiler related options
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Mark unused variables/parameters
|
||||||
|
*
|
||||||
|
* Tells the compiler a variable is unused, so the compiler doesn't spit a warning.
|
||||||
|
*/
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define __sane_unused__ __attribute__((unused))
|
||||||
|
#else
|
||||||
|
#define __sane_unused__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @name Compatibility macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#include "sanei_debug.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_HW_H
|
||||||
|
/* OS/2 i/o-port access compatibility macros: */
|
||||||
|
# define inb(p) _inp8 (p)
|
||||||
|
# define outb(v,p) _outp8 ((p),(v))
|
||||||
|
# define ioperm(b,l,o) _portaccess ((b),(b)+(l)-1)
|
||||||
|
# define HAVE_IOPERM 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_OS2_H
|
||||||
|
#include <fcntl.h>
|
||||||
|
#ifndef O_NONBLOCK
|
||||||
|
# ifdef O_NDELAY
|
||||||
|
# define O_NONBLOCK O_NDELAY
|
||||||
|
# else
|
||||||
|
# ifdef FNDELAY
|
||||||
|
# define O_NONBLOCK FNDELAY /* last resort */
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#endif /* HAVE_OS2_H */
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#ifndef PATH_MAX
|
||||||
|
# define PATH_MAX 1024
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef M_PI
|
||||||
|
#define M_PI 3.14159265358979323846
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MM_PER_INCH
|
||||||
|
#define MM_PER_INCH 25.4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SIGPROCMASK
|
||||||
|
# define SIGACTION sigaction
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Just enough backwards compatibility that we get by in the backends
|
||||||
|
without making handstands. */
|
||||||
|
# ifdef sigset_t
|
||||||
|
# undef sigset_t
|
||||||
|
# endif
|
||||||
|
# ifdef sigemptyset
|
||||||
|
# undef sigemptyset
|
||||||
|
# endif
|
||||||
|
# ifdef sigfillset
|
||||||
|
# undef sigfillset
|
||||||
|
# endif
|
||||||
|
# ifdef sigaddset
|
||||||
|
# undef sigaddset
|
||||||
|
# endif
|
||||||
|
# ifdef sigdelset
|
||||||
|
# undef sigdelset
|
||||||
|
# endif
|
||||||
|
# ifdef sigprocmask
|
||||||
|
# undef sigprocmask
|
||||||
|
# endif
|
||||||
|
# ifdef SIG_BLOCK
|
||||||
|
# undef SIG_BLOCK
|
||||||
|
# endif
|
||||||
|
# ifdef SIG_UNBLOCK
|
||||||
|
# undef SIG_UNBLOCK
|
||||||
|
# endif
|
||||||
|
# ifdef SIG_SETMASK
|
||||||
|
# undef SIG_SETMASK
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define sigset_t int
|
||||||
|
# define sigemptyset(set) do { *(set) = 0; } while (0)
|
||||||
|
# define sigfillset(set) do { *(set) = ~0; } while (0)
|
||||||
|
# define sigaddset(set,signal) do { *(set) |= sigmask (signal); } while (0)
|
||||||
|
# define sigdelset(set,signal) do { *(set) &= ~sigmask (signal); } while (0)
|
||||||
|
# define sigaction(sig,new,old) sigvec (sig,new,old)
|
||||||
|
|
||||||
|
/* Note: it's not safe to just declare our own "struct sigaction" since
|
||||||
|
some systems (e.g., some versions of OpenStep) declare that structure,
|
||||||
|
but do not implement sigprocmask(). Hard to believe, aint it? */
|
||||||
|
# define SIGACTION sigvec
|
||||||
|
# define SIG_BLOCK 1
|
||||||
|
# define SIG_UNBLOCK 2
|
||||||
|
# define SIG_SETMASK 3
|
||||||
|
#endif /* !HAVE_SIGPROCMASK */
|
||||||
|
/* @} */
|
||||||
|
|
||||||
|
|
||||||
|
/** @name Declaration of entry points:
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
extern SANE_Status ENTRY(init) (SANE_Int *, SANE_Auth_Callback);
|
||||||
|
extern SANE_Status ENTRY(get_devices) (const SANE_Device ***, SANE_Bool);
|
||||||
|
extern SANE_Status ENTRY(open) (SANE_String_Const, SANE_Handle *);
|
||||||
|
extern const SANE_Option_Descriptor *
|
||||||
|
ENTRY(get_option_descriptor) (SANE_Handle, SANE_Int);
|
||||||
|
extern SANE_Status ENTRY(control_option) (SANE_Handle, SANE_Int, SANE_Action,
|
||||||
|
void *, SANE_Word *);
|
||||||
|
extern SANE_Status ENTRY(get_parameters) (SANE_Handle, SANE_Parameters *);
|
||||||
|
extern SANE_Status ENTRY(start) (SANE_Handle);
|
||||||
|
extern SANE_Status ENTRY(read) (SANE_Handle, SANE_Byte *, SANE_Int,
|
||||||
|
SANE_Int *);
|
||||||
|
extern SANE_Status ENTRY(set_io_mode) (SANE_Handle, SANE_Bool);
|
||||||
|
extern SANE_Status ENTRY(get_select_fd) (SANE_Handle, SANE_Int *);
|
||||||
|
extern void ENTRY(cancel) (SANE_Handle);
|
||||||
|
extern void ENTRY(close) (SANE_Handle);
|
||||||
|
extern void ENTRY(exit) (void);
|
||||||
|
extern void sanei_debug_msg(int level, int max_level, const char* be, const char* fmt, va_list ap);
|
||||||
|
|
||||||
|
#ifndef STUBS
|
||||||
|
/* Now redirect sane_* calls to backend's functions: */
|
||||||
|
|
||||||
|
#define sane_init(a,b) ENTRY(init) (a,b)
|
||||||
|
#define sane_get_devices(a,b) ENTRY(get_devices) (a,b)
|
||||||
|
#define sane_open(a,b) ENTRY(open) (a,b)
|
||||||
|
#define sane_get_option_descriptor(a,b) ENTRY(get_option_descriptor) (a,b)
|
||||||
|
#define sane_control_option(a,b,c,d,e) ENTRY(control_option) (a,b,c,d,e)
|
||||||
|
#define sane_get_parameters(a,b) ENTRY(get_parameters) (a,b)
|
||||||
|
#define sane_start(a) ENTRY(start) (a)
|
||||||
|
#define sane_read(a,b,c,d) ENTRY(read) (a,b,c,d)
|
||||||
|
#define sane_set_io_mode(a,b) ENTRY(set_io_mode) (a,b)
|
||||||
|
#define sane_get_select_fd(a,b) ENTRY(get_select_fd) (a,b)
|
||||||
|
#define sane_cancel(a) ENTRY(cancel) (a)
|
||||||
|
#define sane_close(a) ENTRY(close) (a)
|
||||||
|
#define sane_exit(a) ENTRY(exit) (a)
|
||||||
|
#define sane_strstatus(a) ENTRY(strstatus)(a)
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// extension for standard SANE ...
|
||||||
|
#define sane_init_ex(a, b, c) ENTRY(init_ex) (a,b,c)
|
||||||
|
#define sane_io_control(a,b,c,d) ENTRY(io_control)(a,b,c,d)
|
||||||
|
#define sane_err_desc(a) ENTRY(err_desc)(a)
|
||||||
|
|
||||||
|
#endif /* STUBS */
|
||||||
|
/* @} */
|
||||||
|
|
||||||
|
/** Internationalization for SANE backends
|
||||||
|
*
|
||||||
|
* Add SANE_I18N() to all texts that can be translated.
|
||||||
|
* E.g. out_txt = SANE_I18N("Hello");
|
||||||
|
*/
|
||||||
|
#ifndef SANE_I18N
|
||||||
|
#define SANE_I18N(text) text
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Option_Value union
|
||||||
|
*
|
||||||
|
* Convenience union to access option values given to the backend
|
||||||
|
*/
|
||||||
|
#ifndef SANE_OPTION
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
SANE_Bool b; /**< bool */
|
||||||
|
SANE_Word w; /**< word */
|
||||||
|
SANE_Word *wa; /**< word array */
|
||||||
|
SANE_String s; /**< string */
|
||||||
|
}
|
||||||
|
Option_Value;
|
||||||
|
#define SANE_OPTION 1
|
||||||
|
#endif
|
|
@ -0,0 +1,153 @@
|
||||||
|
/** @file sanei_debug.h
|
||||||
|
* Support for printing debug messages.
|
||||||
|
*
|
||||||
|
* Use the functions of this header file to print debug or warning messages.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SANEI_DEBUG_H
|
||||||
|
#define _SANEI_DEBUG_H
|
||||||
|
|
||||||
|
#include <sane/sanei.h>
|
||||||
|
|
||||||
|
/** @name Public macros
|
||||||
|
* These macros can be used in backends and other SANE-related
|
||||||
|
* code.
|
||||||
|
*
|
||||||
|
* Before including sanei_debug.h, the following macros must be set:
|
||||||
|
*
|
||||||
|
* - BACKEND_NAME - The name of your backend without double-quotes (must be set in any case)
|
||||||
|
* - STUBS - If this is defined, no macros will be included. Used in
|
||||||
|
* backends consisting of more than one .c file.
|
||||||
|
* - DEBUG_DECLARE_ONLY - Generates prototypes instead of functions. Used in
|
||||||
|
* backends consisting of more than one .c file.
|
||||||
|
* - DEBUG_NOT_STATIC - Doesn't generate static functions. Used in header files if
|
||||||
|
* they are include in more than one .c file.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @def DBG_INIT()
|
||||||
|
* Initialize sanei_debug.
|
||||||
|
*
|
||||||
|
* Call this function before you use any DBG function.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @def DBG(level, fmt, ...)
|
||||||
|
* Print a message at debug level `level' or higher using a printf-like
|
||||||
|
* function. Example: DBG(1, "sane_open: opening fd \%d\\n", fd).
|
||||||
|
*
|
||||||
|
* @param level debug level
|
||||||
|
* @param fmt format (see man 3 printf for details)
|
||||||
|
* @param ... additional arguments
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @def IF_DBG(x)
|
||||||
|
* Compile code only if debugging is enabled.
|
||||||
|
*
|
||||||
|
* Expands to x if debug support is enabled at compile-time. If NDEBUG is
|
||||||
|
* defined at compile-time this macro expands to nothing.
|
||||||
|
*
|
||||||
|
* @param x code to expand when debugging is enabled
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def DBG_LEVEL
|
||||||
|
* Current debug level.
|
||||||
|
*
|
||||||
|
* You can only read this "variable".
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @def ENTRY(name)
|
||||||
|
* Expands to sane_BACKEND_NAME_name.
|
||||||
|
*
|
||||||
|
* Example: ENTRY(init) in mustek.c will expand to sane_mustek_init.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* @} */
|
||||||
|
|
||||||
|
|
||||||
|
/** @hideinitializer*/
|
||||||
|
#define ENTRY(name) PASTE(PASTE(PASTE(sane_,BACKEND_NAME),_),name)
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
|
||||||
|
extern void sanei_debug_ndebug (int level, const char *msg, ...);
|
||||||
|
|
||||||
|
# define DBG_LEVEL (0)
|
||||||
|
# define DBG_INIT()
|
||||||
|
# define DBG sanei_debug_ndebug
|
||||||
|
# define IF_DBG(x)
|
||||||
|
|
||||||
|
#else /* !NDEBUG */
|
||||||
|
|
||||||
|
/** @hideinitializer*/
|
||||||
|
# define DBG_LEVEL PASTE(sanei_debug_,BACKEND_NAME)
|
||||||
|
|
||||||
|
# if defined(BACKEND_NAME) && !defined(STUBS)
|
||||||
|
# ifdef DEBUG_DECLARE_ONLY
|
||||||
|
extern int DBG_LEVEL;
|
||||||
|
# else /* !DEBUG_DECLARE_ONLY */
|
||||||
|
int DBG_LEVEL = 0;
|
||||||
|
# endif /* DEBUG_DECLARE_ONLY */
|
||||||
|
# endif /* BACKEND_NAME && !STUBS */
|
||||||
|
|
||||||
|
/** @hideinitializer*/
|
||||||
|
# define DBG_INIT() \
|
||||||
|
sanei_init_debug (STRINGIFY(BACKEND_NAME), &DBG_LEVEL)
|
||||||
|
|
||||||
|
/** @hideinitializer*/
|
||||||
|
# define DBG_LOCAL PASTE(DBG_LEVEL,_call)
|
||||||
|
|
||||||
|
|
||||||
|
# ifndef STUBS
|
||||||
|
|
||||||
|
# ifdef DEBUG_DECLARE_ONLY
|
||||||
|
|
||||||
|
extern void DBG_LOCAL (int level, const char *msg, ...)
|
||||||
|
#ifdef __GNUC__
|
||||||
|
__attribute__ ((format (printf, 2, 3)))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
|
# else /* !DEBUG_DECLARE_ONLY */
|
||||||
|
|
||||||
|
# include <stdarg.h>
|
||||||
|
|
||||||
|
extern void sanei_debug_msg
|
||||||
|
(int level, int max_level, const char *be, const char *fmt, va_list ap);
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# ifndef DEBUG_NOT_STATIC
|
||||||
|
static
|
||||||
|
# endif /* !DEBUG_NOT_STATIC */
|
||||||
|
void DBG_LOCAL (int level, const char *msg, ...) __attribute__ ((format (printf, 2, 3)));
|
||||||
|
#endif /* __GNUC__ */
|
||||||
|
|
||||||
|
# ifndef DEBUG_NOT_STATIC
|
||||||
|
static
|
||||||
|
# endif /* !DEBUG_NOT_STATIC */
|
||||||
|
void
|
||||||
|
DBG_LOCAL (int level, const char *msg, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start (ap, msg);
|
||||||
|
sanei_debug_msg (level, DBG_LEVEL, STRINGIFY(BACKEND_NAME), msg, ap);
|
||||||
|
va_end (ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
# endif /* DEBUG_DECLARE_ONLY */
|
||||||
|
|
||||||
|
# endif /* !STUBS */
|
||||||
|
|
||||||
|
/** @hideinitializer*/
|
||||||
|
# define DBG DBG_LOCAL
|
||||||
|
|
||||||
|
extern void sanei_init_debug (const char * backend, int * debug_level_var);
|
||||||
|
|
||||||
|
/** @hideinitializer*/
|
||||||
|
# define IF_DBG(x) x
|
||||||
|
|
||||||
|
#endif /* NDEBUG */
|
||||||
|
|
||||||
|
#endif /* _SANEI_DEBUG_H */
|
Loading…
Reference in New Issue