uv-twain/huagao/Device/PublicFunc.h

283 lines
8.0 KiB
C
Raw Normal View History

#ifndef PUBLICFUNC_H_
#define PUBLICFUNC_H_
#include "stdafx.h"
#include <string>
#include <direct.h>
#include <io.h>
#include <Windows.h>
#include <fstream>
#define BYTES_PERLINE_ALIGN4(width, bpp) (((((int)(width)*(bpp))+31)/32)*4)
#define BYTES_PERLINE(width, bpp) ((((int)(width)*(bpp))+7)/8)
using namespace std;
/************************************
**json格式保存参数名称**
*************************************/
//<!基本选项卡
#define PIXTYPE "iPixType"
#define PAPARSIZE "iPaparSize"
#define ENUVMODEL "bUVmodel"
#define PAPERALIGN "iPaperAlign"
#define RESOLUTION "iResolution"
#define DUPLEX "iDuplex"
#define DISCARBLANK "bDiscardBlank"
#define DISCARBLANKVINCE "bDiscardBlankVince"
#define DB_AREANUM "iAreaNum"
#define DB_DEVNMAX "iDevnMax"
#define FLOD "bFlod"
#define AUTOCROP "bAuotCrop"
#define SWITCHFRONTBACK "bSwitchFrontBack"
//<!亮度对比度选项卡
#define AUTOCONTRAST "bAutoContrast"
#define BRIGHTNESS "iBrightness"
#define CONTRAST "iContrast"
#define GAMMA_ "dGamma"
//<!图像处理选项卡
#define FILTERTYPE "iFilter"
#define ENHANCECOLOR "iEnhance"
#define SHARPENTYPE "iSharpen"
#define FILLBLACK "bFillBlcak"
#define AUTODESCREW "bAutoDescrew"
#define MULTIOUTPUT "iMultiOutPut"
#define OUTHOLE "bOutHole"
#define OUTHOLERATIO "iOutHoleRatio"
#define HSVCORRECT "bHsvCorrect"
//<!送纸选项卡
#define ULTRADETECT "bUltrasonicDetect"
#define BINDINGDETECT "bBindingDetect"
#define SCANCOUNT "ScanCount"
#define DOCORIENTATION "bOrientation"
#define AUTO_TEXT "bAutoText"
#define BACKROTATE180 "iBackRotate180"
#define SCREWDETECT "bScrewDetect"
#define SCREWLEVEL "iScrewLevel"
#define ITEMCAPTION "Caption"
#define SAVEPATH "SavePath"
/******************
****
*******************/
typedef struct tagCONFIGPARAMS
{
/*基本选项卡参数*/
int Pixtype;
int PaperSize;
bool EnAutoCrop;
bool EnUVModel;
int Resolution;
int Duplex;
bool EnDiscardBlank;
bool EnDiscardBlankVince;
int DBlank_AreaNum;
int DBlank_DevnMax;
bool EnFlod;
bool EnSwitchFrontBack;
/*亮度对比度选项卡参数*/
float Brightness;
bool EnAutoContrast;
float Contrast;
float Gamma;
/*图像处理选项卡参数*/
int Filter;
int Sharpen;
bool EnFillBlack;
bool EnAutoDescrew;
bool EnOutHole;
int OutHoleRatio;
bool EnMultiOutPutR;
bool EnHsvCorrect;
/*送纸部分选项卡参数*/
bool EnUltrasonicDetect;
bool EnBindingDetect;
int ScanCount;
int Orentation;
bool EnBackRotate180;
bool EnScrewDetect;
int ScrewDetectLevel;
/*保存信息*/
std::string Caption;
std::string SavePath;
}CONFIGPARAMS, * PCONFIGPARAMS;
typedef struct tagCONFIGINFO
{
std::string Caption;
std::string SavePath;
}CONFIGINFO, * PCONFIGINFO;
typedef struct tagFillHole
{
byte is_fillhole;
int fillholeratio;
}FillHole;
typedef struct tagHARDWAREPARAMS
{
byte capturepixtype;
byte en_doublefeed;
byte en_stapledetect;
byte en_skrewdetect;
byte skrewdetectlevel;
}HardwareCaps;
typedef struct Scan_Rect {
int width;
int height;
int x;
int y;
}ScanRect;
enum PaperAlign :byte {
Rot0 = 0,
Rot270 = 3,
AutoTextOrientation = 5
};
typedef enum Enchace_Color :short {
Enhance_None=0,
Enhance_Red,
Enhance_Green,
Enhance_Blue
}EnchaceColor;
typedef enum SharpenBlur :short {
Sharpen_None,
Sharpen_Normal,
Sharpen_More,
Sharpen_Blur,
Sharpen_Blur_More
}SharpenBlur;
struct GScanCap
{
byte papertype; /**< the current paper source ADF or Flatbed*/
PaperAlign paperAlign;
float imageRotateDegree;
byte is_duplex; /**< True to use duplex false for simplex, ignored if flatbed*/
byte en_fold;
int pixtype; /**< type of pixels to transfer image as */
byte en_uv; /**< uvģʽ*/
float resolution_dst; /**< horizontal resolution */
float resolution_native;
float gamma; /**< Gamma */
float contrast; /**< Contrast */
float brightness; /**< Brightness */
float threshold; /**< Threshold */
byte is_autocontrast; /**< 自动对比度*/
byte is_autocrop; /**< 自动裁切*/
byte is_autodiscradblank_normal; /**< 自动丢弃空白页通用*/
byte is_autodiscradblank_vince;/**自动丢弃空白页发票*/
byte is_switchfrontback; /**交换正反面*/
byte autodescrew; /**< 自动纠偏*/
byte multi_output_red; /*多流输出*/
byte hsvcorrect; /**<答题卡除红*/
byte filter; /**< 除色*/
byte sharpen;
byte enhance_color; /**< 颜色增强*/
byte fillbackground; /**< 填黑框*/
unsigned short scannum; /**< 扫描张数*/
byte is_backrotate180; /**< 背面旋转180*/
HardwareCaps hardwarecaps; /**< 硬件扫描参数*/
FillHole fillhole;
byte is_autotext; /**< 自动文本方向识别*/
std::string Caption;
std::string SavePath;
};
typedef struct Paper_Status {
Paper_Status(unsigned int paper, unsigned int orentate) :Paper(paper), Orentate(orentate) {}
Paper_Status():Paper(0), Orentate(0){}
unsigned int Paper;
unsigned int Orentate;
friend bool operator<(const struct Paper_Status& a, const struct Paper_Status& b) {
if (a.Paper < b.Paper ||
(a.Paper == b.Paper && a.Orentate < b.Orentate)) {
return true;
}
return false;
}
}PaperStatus;
enum G400_PaperSize {
G400_A3 = 0,
G400_A4,
G400_A4R,
G400_A5,
G400_A5R,
G400_A6,
G400_A6R,
G400_B4,
G400_B5,
G400_B5R,
G400_B6,
G400_B6R,
G400_DOUBLELETTER,
G400_LEGAL,
G400_LETTER,
G400_LETTERR,
G400_LONGLETTER
};
enum G400_DPI {
G400_D300 = 0,
G400_D200,
G400_D600
};
#define CAPTION_LEN 256
#ifndef malloc_my
#define malloc_my malloc
#endif
//取得当前模块的文件路径, 参数,模块实列举并, 文件路径, 字符串的长度
TCHAR* GetCurExeFilePath(HINSTANCE hInstance, TCHAR* lpPath, DWORD dwSize);
//取得路径中已经存在的路径,并返回
TCHAR* GetExistFileDir(TCHAR* p_file_path);
//回调函数,取得用户自定义的文件路径
DWORD CALLBACK BrowserCallbackProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ;
BOOL isFolderExist(char* folder);
int32_t createDirectory(char* directoryPath);
std::string UtfToString(std::string strValue);
std::string StringToUtf(std::string strValue);
//检查,创建文件夹, 参数 文件路径, = 真,创建p_file_path不寻在文件路径
BOOL CheckAndCreateFileDir(TCHAR* p_file_path, BOOL flg);
BOOL CheckDiskFreeBitM(HWND hWin, TCHAR *p_disk_name, DWORD dw_min_bit_m);
HBITMAP SetButtonStaticBkBmp(HINSTANCE hInst, HWND hWin, UINT id, UINT iamge_id);
void writelog(std::string msg);
std::string TCHAR2STRING(TCHAR* STR);
float GetContrast(int level);
int GetMappingBrightnessValue(float in);
int GetMappingContrastValue(float in);
int GetContrastLevel(float contrast);
CString GetHidedlgPath();
string getOSInfo();
string getManufactureID();
string getCpuType();
string getMemoryInfo();
void GetDiskInfo(DWORD& dwNum, CString chDriveInfo[]);
static VOID XdPrint(_TCHAR* format, ...) {
va_list args;
va_start(args, format);
_TCHAR buf[256];
_vstprintf(buf, format, args);
OutputDebugString(buf);
va_end(args);
}
#endif