#ifndef PUBLICFUNC_H_ #define PUBLICFUNC_H_ #include "stdafx.h" #include #include #include #include #include #define BYTES_PERLINE_ALIGN4(width, bpp) (((((int)(width)*(bpp))+31)/32)*4) #define BYTES_PERLINE(width, bpp) ((((int)(width)*(bpp))+7)/8) using byte = unsigned char; using std::string; /************************************ **扫描参数,json格式保存参数名称** *************************************/ const std::string CONFIG = "Config"; //*/ int refuseInflow; /**< 防止渗透>*/ int colorCorrection; /**< 色彩校正>*/ int removeMorr; /**< 去除摩尔纹>*/ int errorExtention; /**< 错误扩散>*/ int textureRemove; /**< 除网纹>*/ int splitImage; /**< 图像拆分>*/ CropRect cropRect; /**< 自定义裁切>*/ MultiOutput multiOutput; /**< 多流输出>*/ bool normalCrop; /**< 自动裁切深色样张>*/ uint32_t dogeardistabce; /**< 折角检测理论顶点到实际轮廓最新距离>*/ bool fadeback; /**< 除底色>*/ int fadebackrange; /**< 除底色范围>*/ bool isuploadexceptionimage; /**< 是否上传双张报错后的异常图像>*/ int fillholeratio_up; /**< 穿孔移除上下左右范围>*/ int fillholeratio_down; int fillholeratio_left; int fillholeratio_right; std::uint8_t fold_concatmode; /*拼接模式*/ int HsvFilterType; /**< 答题卡留红除杂色功能类型 暂定0 为关闭;1为留红除杂色>*/ uint32_t reserve[1024]; /**< 预留4096字节做协议扩展*/ }; 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=17, }; enum G400_DPI { G400_D300 = 0, G400_D200, G400_D600 }; #pragma pack(pop) #define CAPTION_LEN 256 #define TWAIN_IMAGE_FILE_LIST_NAME TEXT(".dat") #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); BOOL isFileExist(std::string 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); char* GBKToUTF8(const char* chGBK); 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