Imagedll.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. #ifndef _IMAGEDLL_H_
  2. #define _IMAGEDLL_H_
  3. //#include <stddef.h>
  4. //#ifdef _WIN32
  5. //#include <windows.h>
  6. //#endif /* _WIN32 */
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif /* __cplusplus */
  10. #ifdef _WIN32
  11. #define EL_CDECL __cdecl
  12. #define EL_STDCALL __stdcall
  13. #define EL_EXPORT __declspec(dllexport)
  14. #else
  15. #define EL_CDECL
  16. #define EL_STDCALL
  17. #define EL_EXPORT
  18. #endif
  19. #ifndef ELAPI
  20. #define ELAPI(rettype) EL_EXPORT rettype EL_CDECL
  21. #endif
  22. #ifdef __cplusplus
  23. #define EL_DEFAULT(val) = val
  24. #else
  25. #define EL_DEFAULT(val)
  26. #endif
  27. typedef void *ELimage;
  28. /* image file */
  29. typedef void *ELfile;
  30. #pragma pack(push, 1)
  31. typedef struct ELsize
  32. {
  33. int width;
  34. int height;
  35. }ELsize;
  36. typedef struct ELpoint
  37. {
  38. int x;
  39. int y;
  40. }ELpoint;
  41. typedef struct ELrect
  42. {
  43. int x;
  44. int y;
  45. int width;
  46. int height;
  47. }ELrect;
  48. typedef struct ELregion
  49. {
  50. ELpoint pt[4];
  51. }ELregion;
  52. #pragma pack(push, 1)
  53. //压缩率选项
  54. enum elCompressMode{
  55. EL_VIDEO_CAP_COMPRESS_HIGH=0,
  56. EL_VIDEO_CAP_COMPRESS_HIGHER,
  57. EL_VIDEO_CAP_COMPRESS_MEDIUM,
  58. EL_VIDEO_CAP_COMPRESS_LOWER,
  59. EL_VIDEO_CAP_COMPRESS_LOW
  60. };
  61. typedef unsigned int ELcolor;
  62. #define EL_INFO_LEVEL_FATAL 0x1
  63. #define EL_INFO_LEVEL_ERROR 0x2
  64. #define EL_INFO_LEVEL_WARNING 0x3
  65. #define EL_INFO_LEVEL_INFO 0x4
  66. /* image format */
  67. #define EL_FORMAT_UNKNOWN -1
  68. #define EL_FORMAT_BMP 0
  69. #define EL_FORMAT_ICO 1
  70. #define EL_FORMAT_JPEG 2
  71. #define EL_FORMAT_PNG 13
  72. #define EL_FORMAT_TIFF 18
  73. #define EL_FORMAT_GIF 25
  74. /* image load and save flag */
  75. #define EL_JPEG_QUALITYSUPERB 0x80 //! save with superb quality (100:1)
  76. #define EL_JPEG_QUALITYGOOD 0x0100 //! save with good quality (75:1)
  77. #define EL_JPEG_QUALITYNORMAL 0x0200 //! save with normal quality (50:1)
  78. #define EL_JPEG_QUALITYAVERAGE 0x0400 //! save with average quality (25:1)
  79. #define EL_JPEG_QUALITYBAD 0x0800 //! save with bad quality (10:1)
  80. //1~100 decimal integer x, save with x:1
  81. /* image create flag */
  82. #define EL_CREATE_TOP_LEFT 0x1
  83. #define EL_CREATE_BOTTOM_LEFT 0x2
  84. /* image channels */
  85. #define EL_CHANNELS_GRAY 0x1
  86. #define EL_CHANNELS_COLOR 0x3
  87. /* image prop */
  88. #define EL_PROP_WIDTH 0x1
  89. #define EL_PROP_HEIGHT 0x2
  90. #define EL_PROP_CHANNELS 0x3
  91. #define EL_PROP_WIDTHSTEP 0x4
  92. #define EL_PROP_XDPI 0x5
  93. #define EL_PROP_YDPI 0x6
  94. /* image cvt */
  95. #define EL_CVT_COLOR2GRAY 0x6
  96. #define EL_CVT_GRAY2COLOR 0x8
  97. /* image rotate */
  98. #define EL_ROTATE_KEEP_SIZE 0x0
  99. #define EL_ROTATE_KEEP_INFO 0x1
  100. /* image flip */
  101. #define EL_FLIP_HORIZONTAL 0
  102. #define EL_FLIP_VERTICAL 1
  103. #define EL_FLIP_BOTH -1
  104. #define EL_DESKEW_CLEAN 0
  105. #define EL_DESKEW_MORE 1
  106. /* image rectify */
  107. #define EL_RECTIFY_NONE 0
  108. #define EL_RECTIFY_IDCARD 1
  109. /* color */
  110. #define EL_RGB(r, g, b) ((ELcolor)(((unsigned char)(r) \
  111. | ((unsigned short)((unsigned char)(g)) << 8)) \
  112. | (((unsigned int)(unsigned char)(b)) << 16)))
  113. ELAPI(int)
  114. elWriteInfo(
  115. int level,
  116. const char *format,
  117. ...
  118. );
  119. ELAPI(int)
  120. elSetLogNameFormat(
  121. const char * prefix,
  122. int flag EL_DEFAULT(0)
  123. );
  124. //加载本地图片
  125. ELAPI(ELimage)
  126. elLoadImage(
  127. const char *fileName,
  128. int flag EL_DEFAULT(0)
  129. );
  130. //保存本地图片
  131. ELAPI(int)
  132. elSaveImage(
  133. ELimage image,
  134. const char *fileName,
  135. int flag EL_DEFAULT(0)
  136. );
  137. ELAPI(int)
  138. elAppendImage(
  139. ELfile file,
  140. ELimage image
  141. );
  142. ELAPI(ELfile)
  143. elCreateFile(
  144. const char *fileName,
  145. int flag EL_DEFAULT(0)
  146. );
  147. ELAPI(int)
  148. elLoadList(
  149. const char *fileName,
  150. ELimage *list,
  151. int *len,
  152. int flag EL_DEFAULT(0)
  153. );
  154. ELAPI(int)
  155. elSaveList(
  156. const char *fileName,
  157. ELimage *list,
  158. int len,
  159. int flag
  160. );
  161. ELAPI(int)
  162. elReleaseImage(
  163. ELimage image
  164. );
  165. ELAPI(int)
  166. elReleaseFile(
  167. ELfile file
  168. );
  169. ELAPI(HBITMAP)
  170. elCreateDIB(
  171. ELimage image
  172. );
  173. ELAPI(int)
  174. elGetImageCount(
  175. ELfile file
  176. );
  177. ELAPI(ELimage)
  178. elGetImage(
  179. ELfile file,
  180. int idx
  181. );
  182. ELAPI(ELfile)
  183. elOpenFile(
  184. const char *fileName,
  185. int flag EL_DEFAULT(0)
  186. );
  187. ELAPI(int)
  188. elAdaptiveThresholdImage(
  189. ELimage image,
  190. int flag EL_DEFAULT(0),
  191. ELimage *dest EL_DEFAULT(NULL)
  192. );
  193. //去底色
  194. ELAPI(int)
  195. elDelImageBkColor(
  196. ELimage image,
  197. ELimage *dest EL_DEFAULT(NULL)
  198. );
  199. //文字印章白底
  200. ELAPI(int)
  201. elDelImageBackgrand(
  202. ELimage image,
  203. ELimage *dest EL_DEFAULT(NULL)
  204. );
  205. //实现单双页展平 参数 bRemoveFinger 是否去除手指;flag 是否去除书籍边缘; bDouble ture表示切分成双页展平,false表示单页展平
  206. ELAPI(int)elZhanPinImage(BOOL bRemoveFinger, ELimage srcImg,
  207. ELimage *outImgLeft, ELimage *outImgRight, int flag,bool bDouble = true
  208. );
  209. #ifdef __cplusplus
  210. }
  211. #endif
  212. #endif