ZBar.pas 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966
  1. unit zbar;
  2. interface
  3. {$MINENUMSIZE 4}
  4. uses
  5. Windows, SysUtils, Classes, Graphics {, dbc, DLL96V1, DLLSP96};
  6. // ------------------------------------------------------------------------
  7. // Copyright 2007-2009 (c) Jeff Brown <[email protected]>
  8. //
  9. // This file is part of the ZBar Bar Code Reader.
  10. //
  11. // The ZBar Bar Code Reader is free software; you can redistribute it
  12. // and/or modify it under the terms of the GNU Lesser Public License as
  13. // published by the Free Software Foundation; either version 2.1 of
  14. // the License, or (at your option) any later version.
  15. //
  16. // The ZBar Bar Code Reader is distributed in the hope that it will be
  17. // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  18. // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. // GNU Lesser Public License for more details.
  20. //
  21. // You should have received a copy of the GNU Lesser Public License
  22. // along with the ZBar Bar Code Reader; if not, write to the Free
  23. // Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  24. // Boston, MA 02110-1301 USA
  25. //
  26. // http://sourceforge.net/projects/zbar
  27. // ------------------------------------------------------------------------*/
  28. // Conversion to Delphi Copyright 2009 (c) Stephen Boyd <[email protected]>
  29. // * @file
  30. // ZBar Barcode Reader C API definition
  31. ///
  32. // * @mainpage
  33. //
  34. // interface to the barcode reader is available at several levels.
  35. // most applications will want to use the high-level interfaces:
  36. //
  37. // @section high-level High-Level Interfaces
  38. //
  39. // these interfaces wrap all library functionality into an easy-to-use
  40. // package for a specific toolkit:
  41. // - the "GTK+ 2.x widget" may be used with GTK GUI applications. a
  42. // Python wrapper is included for PyGtk
  43. // - the @ref zbar::QZBar "Qt4 widget" may be used with Qt GUI
  44. // applications
  45. // - the Processor interface (in @ref c-processor "C" or @ref
  46. // zbar::Processor "C++") adds a scanning window to an application
  47. // with no GUI.
  48. //
  49. // @section mid-level Intermediate Interfaces
  50. //
  51. // building blocks used to construct high-level interfaces:
  52. // - the ImageScanner (in @ref c-imagescanner "C" or @ref
  53. // zbar::ImageScanner "C++") looks for barcodes in a library defined
  54. // image object
  55. // - the Window abstraction (in @ref c-window "C" or @ref
  56. // zbar::Window "C++") sinks library images, displaying them on the
  57. // platform display
  58. // - the Video abstraction (in @ref c-video "C" or @ref zbar::Video
  59. // "C++") sources library images from a video device
  60. //
  61. // @section low-level Low-Level Interfaces
  62. //
  63. // direct interaction with barcode scanning and decoding:
  64. // - the Scanner (in @ref c-scanner "C" or @ref zbar::Scanner "C++")
  65. // looks for barcodes in a linear intensity sample stream
  66. // - the Decoder (in @ref c-decoder "C" or @ref zbar::Decoder "C++")
  67. // extracts barcodes from a stream of bar and space widths
  68. ///
  69. // * @name Global library interfaces */
  70. // @{*/
  71. // * "color" of element: bar or space. */
  72. type
  73. zbar_color_e = (ZBAR_SPACE = 0, // *< light area or space between bars */
  74. ZBAR_BAR = 1 // *< dark area or colored bar segment */
  75. );
  76. zbar_color_t = zbar_color_e;
  77. // * decoded symbol type. */
  78. type
  79. zbar_symbol_type_e = (ZBAR_NONE = 0, // *< no symbol decoded */
  80. ZBAR_PARTIAL = 1, // *< intermediate status */
  81. ZBAR_EAN8 = 8, // *< EAN-8 */
  82. ZBAR_UPCE = 9, // *< UPC-E */
  83. ZBAR_ISBN10 = 10, // *< ISBN-10 (from EAN-13). @since 0.4 */
  84. ZBAR_UPCA = 12, // *< UPC-A */
  85. ZBAR_EAN13 = 13, // *< EAN-13 */
  86. ZBAR_ISBN13 = 14, // *< ISBN-13 (from EAN-13). @since 0.4 */
  87. ZBAR_I25 = 25, // *< Interleaved 2 of 5. @since 0.4 */
  88. ZBAR_CODE39 = 39, // *< Code 39. @since 0.4 */
  89. ZBAR_PDF417 = 57, // *< PDF417. @since 0.6 */
  90. ZBAR_QRCODE = 64, //*< QR Code. @since 0.10 */
  91. ZBAR_CODE128 = 128 // *< Code 128 */
  92. //ZBAR_SYMBOL = $00ff, // *< mask for base symbol type */
  93. //ZBAR_ADDON2 = $0200, // *< 2-digit add-on flag */
  94. //ZBAR_ADDON5 = $0500, // *< 5-digit add-on flag */
  95. //ZBAR_ADDON = $0700 // *< add-on flag mask */
  96. );
  97. zbar_symbol_type_t = zbar_symbol_type_e;
  98. // * error codes. */
  99. type
  100. zbar_error_e = (ZBAR_OK = 0, // *< no error */
  101. ZBAR_ERR_NOMEM, // *< out of memory */
  102. ZBAR_ERR_INTERNAL, // *< internal library error */
  103. ZBAR_ERR_UNSUPPORTED, // *< unsupported request */
  104. ZBAR_ERR_INVALID, // *< invalid request */
  105. ZBAR_ERR_SYSTEM, // *< system error */
  106. ZBAR_ERR_LOCKING, // *< locking error */
  107. ZBAR_ERR_BUSY, // *< all resources busy */
  108. ZBAR_ERR_XDISPLAY, // *< X11 display error */
  109. ZBAR_ERR_XPROTO, // *< X11 protocol error */
  110. ZBAR_ERR_CLOSED, // *< output window is closed */
  111. ZBAR_ERR_NUM // *< number of error codes */
  112. );
  113. zbar_error_t = zbar_error_e;
  114. // * decoder configuration options.
  115. // @since 0.4
  116. ///
  117. type
  118. zbar_config_e = (ZBAR_CFG_ENABLE = 0, // *< enable symbology/feature */
  119. ZBAR_CFG_ADD_CHECK, // *< enable check digit when optional */
  120. ZBAR_CFG_EMIT_CHECK, // *< return check digit when present */
  121. ZBAR_CFG_ASCII, // *< enable full ASCII character set */
  122. ZBAR_CFG_NUM, // *< number of boolean configs */
  123. ZBAR_CFG_MIN_LEN = $20, // *< minimum data length for valid decode */
  124. ZBAR_CFG_MAX_LEN, // *< maximum data length for valid decode */
  125. ZBAR_CFG_X_DENSITY = $100, // *< image scanner vertical scan density */
  126. ZBAR_CFG_Y_DENSITY // *< image scanner horizontal scan density */
  127. );
  128. zbar_config_t = zbar_config_e;
  129. // * retrieve runtime library version information.
  130. // @param major set to the running major version (unless NULL)
  131. // @param minor set to the running minor version (unless NULL)
  132. // @returns 0
  133. ///
  134. function zbar_version(var major: Cardinal; var minor: Cardinal): Integer;
  135. // * set global library debug level.
  136. // @param verbosity desired debug level. higher values create more spew
  137. ///
  138. procedure zbar_set_verbosity(verbosity: Integer);
  139. // * increase global library debug level.
  140. // eg, for -vvvv
  141. ///
  142. procedure zbar_increase_verbosity;
  143. // * retrieve string name for symbol encoding.
  144. // @param sym symbol type encoding
  145. // @returns the static string name for the specified symbol type,
  146. // or "UNKNOWN" if the encoding is not recognized
  147. ///
  148. function zbar_get_symbol_name(sym: zbar_symbol_type_t): PAnsiChar;
  149. // * retrieve string name for addon encoding.
  150. // @param sym symbol type encoding
  151. // @returns static string name for any addon, or the empty string
  152. // if no addons were decoded
  153. ///
  154. function zbar_get_addon_name(sym: zbar_symbol_type_t): PAnsiChar;
  155. // * parse a configuration string of the form "[symbology.]config[=value]".
  156. // the config must match one of the recognized names.
  157. // the symbology, if present, must match one of the recognized names.
  158. // if symbology is unspecified, it will be set to 0.
  159. // if value is unspecified it will be set to 1.
  160. // @returns 0 if the config is parsed successfully, 1 otherwise
  161. // @since 0.4
  162. ///
  163. function zbar_parse_config(const config_string: PAnsiChar; var symbology: zbar_symbol_type_t; var config: zbar_config_t;
  164. var value: Integer): Integer;
  165. // * @internal type unsafe error API (don't use) */
  166. function _zbar_error_spew(objekt: Pointer; verbosity: Integer): Integer;
  167. function _zbar_error_string(objekt: Pointer; verbosity: Integer): PAnsiChar;
  168. function _zbar_get_error_code(objekt: Pointer): zbar_error_t;
  169. // @}*/
  170. // ------------------------------------------------------------*/
  171. // * @name Symbol interface
  172. // decoded barcode symbol result object. stores type, data, and image
  173. // location of decoded symbol. all memory is owned by the library
  174. ///
  175. // @{*/
  176. type
  177. zbar_symbol_s = type Pointer;
  178. // * opaque decoded symbol object. */
  179. zbar_symbol_t = zbar_symbol_s;
  180. // * retrieve type of decoded symbol.
  181. // @returns the symbol type
  182. ///
  183. function zbar_symbol_get_type(symbol: zbar_symbol_t): zbar_symbol_type_t;
  184. // * retrieve ASCII data decoded from symbol.
  185. // @returns the data string
  186. ///
  187. function zbar_symbol_get_data(symbol: zbar_symbol_t): PAnsiChar;
  188. //Function zbar_symbol_get_data_length (symbol: zbar_symbol_t): integer;
  189. // * retrieve current cache count. when the cache is enabled for the
  190. // image_scanner this provides inter-frame reliability and redundancy
  191. // information for video streams.
  192. // @returns < 0 if symbol is still uncertain.
  193. // @returns 0 if symbol is newly verified.
  194. // @returns > 0 for duplicate symbols
  195. ///
  196. function zbar_symbol_get_count(symbol: zbar_symbol_t): Integer;
  197. // * retrieve the number of points in the location polygon. the
  198. // location polygon defines the image area that the symbol was
  199. // extracted from.
  200. // @returns the number of points in the location polygon
  201. // @note this is currently not a polygon, but the scan locations
  202. // where the symbol was decoded
  203. ///
  204. function zbar_symbol_get_loc_size(symbol: zbar_symbol_t): Cardinal;
  205. // * retrieve location polygon x-coordinates.
  206. // points are specified by 0-based index.
  207. // @returns the x-coordinate for a point in the location polygon.
  208. // @returns -1 if index is out of range
  209. ///
  210. function zbar_symbol_get_loc_x(symbol: zbar_symbol_t; index: Cardinal): Integer;
  211. // * retrieve location polygon y-coordinates.
  212. // points are specified by 0-based index.
  213. // @returns the y-coordinate for a point in the location polygon.
  214. // @returns -1 if index is out of range
  215. ///
  216. function zbar_symbol_get_loc_y(symbol: zbar_symbol_t; index: Cardinal): Integer;
  217. // * iterate the result set.
  218. // @returns the next result symbol, or
  219. // @returns NULL when no more results are available
  220. ///
  221. function zbar_symbol_next(symbol: zbar_symbol_t): zbar_symbol_t;
  222. // * print XML symbol element representation to user result buffer.
  223. // @see http://zbar.sourceforge.net/2008/barcode.xsd for the schema.
  224. // @param symbol is the symbol to print
  225. // @param buffer is the inout result pointer, it will be reallocated
  226. // with a larger size if necessary.
  227. // @param buflen is inout length of the result buffer.
  228. // @returns the buffer pointer
  229. // @since 0.6
  230. ///
  231. function zbar_symbol_xml(symbol: zbar_symbol_t; var buffer: PAnsiChar; var buflen: Cardinal): PAnsiChar;
  232. // @}*/
  233. // ------------------------------------------------------------*/
  234. // * @name Image interface
  235. // stores image data samples along with associated format and size
  236. // metadata
  237. ///
  238. // @{*/
  239. type
  240. zbar_image_s = type Pointer;
  241. // * opaque image object. */
  242. zbar_image_t = zbar_image_s;
  243. // * cleanup handler callback function.
  244. // called to free sample data when an image is destroyed.
  245. ///
  246. zbar_image_cleanup_handler_t = procedure(image: zbar_image_t); cdecl;
  247. // * data handler callback function.
  248. // called when decoded symbol results are available for an image
  249. ///
  250. zbar_image_data_handler_t = procedure(image: zbar_image_t; userdata: Pointer); cdecl;
  251. // * new image constructor.
  252. // @returns a new image object with uninitialized data and format.
  253. // this image should be destroyed (using zbar_image_destroy()) as
  254. // soon as the application is finished with it
  255. ///
  256. function zbar_image_create: zbar_image_t;
  257. // * image destructor. all images created by or returned to the
  258. // application should be destroyed using this function. when an image
  259. // is destroyed, the associated data cleanup handler will be invoked
  260. // if available
  261. // @note make no assumptions about the image or the data buffer.
  262. // they may not be destroyed/cleaned immediately if the library
  263. // is still using them. if necessary, use the cleanup handler hook
  264. // to keep track of image data buffers
  265. ///
  266. procedure zbar_image_destroy(image: zbar_image_t);
  267. // * image reference count manipulation.
  268. // increment the reference count when you store a new reference to the
  269. // image. decrement when the reference is no longer used. do not
  270. // refer to the image any longer once the count is decremented.
  271. // zbar_image_ref(image, -1) is the same as zbar_image_destroy(image)
  272. // @since 0.5
  273. ///
  274. procedure zbar_image_ref(image: zbar_image_t; refs: Integer);
  275. // * image format conversion. refer to the documentation for supported
  276. // image formats
  277. // @returns a @em new image with the sample data from the original image
  278. // converted to the requested format. the original image is
  279. // unaffected.
  280. // @note the converted image size may be rounded (up) due to format
  281. // constraints
  282. ///
  283. function zbar_image_convert(image: zbar_image_t; format: PAnsiChar): zbar_image_t;
  284. // * image format conversion with crop/pad.
  285. // if the requested size is larger than the image, the last row/column
  286. // are duplicated to cover the difference. if the requested size is
  287. // smaller than the image, the extra rows/columns are dropped from the
  288. // right/bottom.
  289. // @returns a @em new image with the sample data from the original
  290. // image converted to the requested format and size.
  291. // @note the image is @em not scaled
  292. // @see zbar_image_convert()
  293. // @since 0.4
  294. ///
  295. function zbar_image_convert_resize(image: zbar_image_t; format: PAnsiChar; width: Cardinal; height: Cardinal): zbar_image_t;
  296. // * retrieve the image format.
  297. // @returns the fourcc describing the format of the image sample data
  298. ///
  299. function zbar_image_get_format(image: zbar_image_t): Cardinal;
  300. // * retrieve a "sequence" (page/frame) number associated with this image.
  301. // @since 0.6
  302. ///
  303. function zbar_image_get_sequence(image: zbar_image_t): Cardinal;
  304. // * retrieve the width of the image.
  305. // @returns the width in sample columns
  306. ///
  307. function zbar_image_get_width(image: zbar_image_t): Cardinal;
  308. // * retrieve the height of the image.
  309. // @returns the height in sample rows
  310. ///
  311. function zbar_image_get_height(image: zbar_image_t): Cardinal;
  312. // * return the image sample data. the returned data buffer is only
  313. // valid until zbar_image_destroy() is called
  314. ///
  315. function zbar_image_get_data(image: zbar_image_t): Pointer;
  316. // * return the size of image data.
  317. // @since 0.6
  318. ///
  319. function zbar_image_get_data_length(img: zbar_image_t): Cardinal;
  320. // * image_scanner decode result iterator.
  321. // @returns the first decoded symbol result for an image
  322. // or NULL if no results are available
  323. ///
  324. function zbar_image_first_symbol(image: zbar_image_t): zbar_symbol_t;
  325. // * specify the fourcc image format code for image sample data.
  326. // refer to the documentation for supported formats.
  327. // @note this does not convert the data!
  328. // (see zbar_image_convert() for that)
  329. ///
  330. procedure zbar_image_set_format(image: zbar_image_t; format: PAnsiChar);
  331. // * associate a "sequence" (page/frame) number with this image.
  332. // @since 0.6
  333. ///
  334. procedure zbar_image_set_sequence(image: zbar_image_t; sequence_num: Cardinal);
  335. // * specify the pixel size of the image.
  336. // @note this does not affect the data!
  337. ///
  338. procedure zbar_image_set_size(image: zbar_image_t; width: Cardinal; height: Cardinal);
  339. // * specify image sample data. when image data is no longer needed by
  340. // the library the specific data cleanup handler will be called
  341. // (unless NULL)
  342. // @note application image data will not be modified by the library
  343. ///
  344. procedure zbar_image_set_data(image: zbar_image_t; data: Pointer; data_byte_length: Cardinal;
  345. cleanup_hndlr: zbar_image_cleanup_handler_t);
  346. // * built-in cleanup handler.
  347. // passes the image data buffer to free()
  348. ///
  349. procedure zbar_image_free_data(image: zbar_image_t);
  350. // * associate user specified data value with an image.
  351. // @since 0.5
  352. ///
  353. procedure zbar_image_set_userdata(image: zbar_image_t; userdata: Pointer);
  354. // * return user specified data value associated with the image.
  355. // @since 0.5
  356. ///
  357. function zbar_image_get_userdata(image: zbar_image_t): Pointer;
  358. // * dump raw image data to a file for debug.
  359. // the data will be prefixed with a 16 byte header consisting of:
  360. // - 4 bytes uint = 0x676d697a ("zimg")
  361. // - 4 bytes format fourcc
  362. // - 2 bytes width
  363. // - 2 bytes height
  364. // - 4 bytes size of following image data in bytes
  365. // this header can be dumped w/eg:
  366. // @verbatim
  367. // od -Ax -tx1z -N16 -w4 [file]
  368. // @endverbatim
  369. // for some formats the image can be displayed/converted using
  370. // ImageMagick, eg:
  371. // @verbatim
  372. // display -size 640x480+16 [-depth ?] [-sampling-factor ?x?] \
  373. // {GRAY,RGB,UYVY,YUV}:[file]
  374. // @endverbatim
  375. //
  376. // @param image the image object to dump
  377. // @param filebase base filename, appended with ".XXXX.zimg" where
  378. // XXXX is the format fourcc
  379. // @returns 0 on success or a system error code on failure
  380. ///
  381. function zbar_image_write(image: zbar_image_t; filebase: PAnsiChar): Integer;
  382. // * read back an image in the format written by zbar_image_write()
  383. // @note TBD
  384. ///
  385. function zbar_image_read(filename: PAnsiChar): zbar_image_t;
  386. // @}*/
  387. // *------------------------------------------------------------*/
  388. // * @name Processor interface
  389. // @anchor c-processor
  390. // high-level self-contained image processor.
  391. // processes video and images for barcodes, optionally displaying
  392. // images to a library owned output window
  393. ///
  394. // @{*/
  395. type
  396. zbar_processor_s = type Pointer;
  397. // * opaque standalone processor object. */
  398. zbar_processor_t = zbar_processor_s;
  399. // * constructor.
  400. // if threaded is set and threading is available the processor
  401. // will spawn threads where appropriate to avoid blocking and
  402. // improve responsiveness
  403. ///
  404. function zbar_processor_create(threaded: Integer): zbar_processor_t;
  405. // * destructor. cleans up all resources associated with the processor
  406. ///
  407. procedure zbar_processor_destroy(processor: zbar_processor_t);
  408. // * (re)initialization.
  409. // opens a video input device and/or prepares to display output
  410. ///
  411. function zbar_processor_init(processor: zbar_processor_t; video_device: PAnsiChar; enable_display: Integer): Integer;
  412. // * request a preferred size for the video image from the device.
  413. // the request may be adjusted or completely ignored by the driver.
  414. // @note must be called before zbar_processor_init()
  415. // @since 0.6
  416. ///
  417. function zbar_processor_request_size(processor: zbar_processor_t; width: Cardinal; height: Cardinal): Integer;
  418. // * request a preferred video driver interface version for
  419. // debug/testing.
  420. // @note must be called before zbar_processor_init()
  421. // @since 0.6
  422. ///
  423. function zbar_processor_request_interface(processor: zbar_processor_t; version: Integer): Integer;
  424. // * request a preferred video I/O mode for debug/testing. You will
  425. // get errors if the driver does not support the specified mode.
  426. // @verbatim
  427. // 0 = auto-detect
  428. // 1 = force I/O using read()
  429. // 2 = force memory mapped I/O using mmap()
  430. // 3 = force USERPTR I/O (v4l2 only)
  431. // @endverbatim
  432. // @note must be called before zbar_processor_init()
  433. // @since 0.7
  434. ///
  435. function zbar_processor_request_iomode(video: zbar_processor_t; iomode: Integer): Integer;
  436. // * force specific input and output formats for debug/testing.
  437. // @note must be called before zbar_processor_init()
  438. ///
  439. function zbar_processor_force_format(processor: zbar_processor_t; input_format: Cardinal;
  440. output_format: Cardinal): Integer;
  441. // * setup result handler callback.
  442. // the specified function will be called by the processor whenever
  443. // new results are available from the video stream or a static image.
  444. // pass a NULL value to disable callbacks.
  445. // @param processor the object on which to set the handler.
  446. // @param handler the function to call when new results are available.
  447. // @param userdata is set as with zbar_processor_set_userdata().
  448. // @returns the previously registered handler
  449. ///
  450. function zbar_processor_set_data_handler(processor: zbar_processor_t; handler: zbar_image_data_handler_t;
  451. userdata: PAnsiChar): zbar_image_data_handler_t;
  452. // * associate user specified data value with the processor.
  453. // @since 0.6
  454. ///
  455. procedure zbar_processor_set_userdata(processor: zbar_processor_t; userdata: Pointer);
  456. // * return user specified data value associated with the processor.
  457. // @since 0.6
  458. ///
  459. function zbar_processor_get_userdata(processor: zbar_processor_t): Pointer;
  460. // * set config for indicated symbology (0 for all) to specified value.
  461. // @returns 0 for success, non-0 for failure (config does not apply to
  462. // specified symbology, or value out of range)
  463. // @see zbar_decoder_set_config()
  464. // @since 0.4
  465. ///
  466. function zbar_processor_set_config(processor: zbar_processor_t; symbology: zbar_symbol_type_t; config: zbar_config_t;
  467. value: Integer): Integer;
  468. // * parse configuration string using zbar_parse_config()
  469. // and apply to processor using zbar_processor_set_config().
  470. // @returns 0 for success, non-0 for failure
  471. // @see zbar_parse_config()
  472. // @see zbar_processor_set_config()
  473. // @since 0.4
  474. ///
  475. function zbar_processor_parse_config(processor: zbar_processor_t; config_string: PAnsiChar): Integer;
  476. // * retrieve the current state of the ouput window.
  477. // @returns 1 if the output window is currently displayed, 0 if not.
  478. // @returns -1 if an error occurs
  479. ///
  480. function zbar_processor_is_visible(processor: zbar_processor_t): Integer;
  481. // * show or hide the display window owned by the library.
  482. // the size will be adjusted to the input size
  483. ///
  484. function zbar_processor_set_visible(processor: zbar_processor_t; visible: Integer): Integer;
  485. // * control the processor in free running video mode.
  486. // only works if video input is initialized. if threading is in use,
  487. // scanning will occur in the background, otherwise this is only
  488. // useful wrapping calls to zbar_processor_user_wait(). if the
  489. // library output window is visible, video display will be enabled.
  490. ///
  491. function zbar_processor_set_active(processor: zbar_processor_t; active: Integer): Integer;
  492. // * wait for input to the display window from the user
  493. // (via mouse or keyboard).
  494. // @returns >0 when input is received, 0 if timeout ms expired
  495. // with no input or -1 in case of an error
  496. ///
  497. function zbar_processor_user_wait(processor: zbar_processor_t; timeout: Integer): Integer;
  498. // * process from the video stream until a result is available,
  499. // or the timeout (in milliseconds) expires.
  500. // specify a timeout of -1 to scan indefinitely
  501. // (zbar_processor_set_active() may still be used to abort the scan
  502. // from another thread).
  503. // if the library window is visible, video display will be enabled.
  504. // @note that multiple results may still be returned (despite the
  505. // name).
  506. // @returns >0 if symbols were successfully decoded,
  507. // 0 if no symbols were found (ie, the timeout expired)
  508. // or -1 if an error occurs
  509. ///
  510. function zbar_process_one(processor: zbar_processor_t; timeout: Integer): Integer;
  511. // * process the provided image for barcodes.
  512. // if the library window is visible, the image will be displayed.
  513. // @returns >0 if symbols were successfully decoded,
  514. // 0 if no symbols were found or -1 if an error occurs
  515. ///
  516. function zbar_process_image(processor: zbar_processor_t; image: zbar_image_t): Integer;
  517. // * display detail for last processor error to stderr.
  518. // @returns a non-zero value suitable for passing to exit()
  519. ///
  520. function zbar_processor_error_spew(processor: zbar_processor_t; verbosity: Integer): Integer;
  521. // * retrieve the detail string for the last processor error. */
  522. function zbar_processor_error_string(processor: zbar_processor_t; verbosity: Integer): PAnsiChar;
  523. // * retrieve the type code for the last processor error. */
  524. function zbar_processor_get_error_code(processor: zbar_processor_t): zbar_error_t;
  525. // @}*/
  526. // ------------------------------------------------------------*/
  527. // * @name Video interface
  528. // @anchor c-video
  529. // mid-level video source abstraction.
  530. // captures images from a video device
  531. ///
  532. // @{*/
  533. type
  534. zbar_video_s = type Pointer;
  535. // * opaque video object. */
  536. zbar_video_t = zbar_video_s;
  537. // * constructor. */
  538. function zbar_video_create: zbar_video_t;
  539. // * destructor. */
  540. procedure zbar_video_destroy(video: zbar_video_t);
  541. // * open and probe a video device.
  542. // the device specified by platform specific unique name
  543. // (v4l device node path in *nix eg "/dev/video",
  544. // DirectShow DevicePath property in windows).
  545. // @returns 0 if successful or -1 if an error occurs
  546. ///
  547. function zbar_video_open(video: zbar_video_t; device: PAnsiChar): Integer;
  548. // * retrieve file descriptor associated with open *nix video device
  549. // useful for using select()/poll() to tell when new images are
  550. // available (NB v4l2 only!!).
  551. // @returns the file descriptor or -1 if the video device is not open
  552. // or the driver only supports v4l1
  553. ///
  554. function zbar_video_get_fd(video: zbar_video_t): Integer;
  555. // * request a preferred size for the video image from the device.
  556. // the request may be adjusted or completely ignored by the driver.
  557. // @returns 0 if successful or -1 if the video device is already
  558. // initialized
  559. // @since 0.6
  560. ///
  561. function zbar_video_request_size(video: zbar_video_t; width: Cardinal; height: Cardinal): Integer;
  562. // * request a preferred driver interface version for debug/testing.
  563. // @note must be called before zbar_video_open()
  564. // @since 0.6
  565. ///
  566. function zbar_video_request_interface(video: zbar_video_t; version: Integer): Integer;
  567. // * request a preferred I/O mode for debug/testing. You will get
  568. // errors if the driver does not support the specified mode.
  569. // @verbatim
  570. // 0 = auto-detect
  571. // 1 = force I/O using read()
  572. // 2 = force memory mapped I/O using mmap()
  573. // 3 = force USERPTR I/O (v4l2 only)
  574. // @endverbatim
  575. // @note must be called before zbar_video_open()
  576. // @since 0.7
  577. ///
  578. function zbar_video_request_iomode(video: zbar_video_t; iomode: Integer): Integer;
  579. // * retrieve current output image width.
  580. // @returns the width or 0 if the video device is not open
  581. ///
  582. function zbar_video_get_width(video: zbar_video_t): Integer;
  583. // * retrieve current output image height.
  584. // @returns the height or 0 if the video device is not open
  585. ///
  586. function zbar_video_get_height(video: zbar_video_t): Integer;
  587. // * initialize video using a specific format for debug.
  588. // use zbar_negotiate_format() to automatically select and initialize
  589. // the best available format
  590. ///
  591. function zbar_video_init(video: zbar_video_t; format: Cardinal): Integer;
  592. // * start/stop video capture.
  593. // all buffered images are retired when capture is disabled.
  594. // @returns 0 if successful or -1 if an error occurs
  595. ///
  596. function zbar_video_enable(video: zbar_video_t; enable: Integer): Integer;
  597. // * retrieve next captured image. blocks until an image is available.
  598. // @returns NULL if video is not enabled or an error occurs
  599. ///
  600. function zbar_video_next_image(video: zbar_video_t): zbar_image_t;
  601. // * display detail for last video error to stderr.
  602. // @returns a non-zero value suitable for passing to exit()
  603. ///
  604. function zbar_video_error_spew(video: zbar_video_t; verbosity: Integer): Integer;
  605. // * retrieve the detail string for the last video error. */
  606. function zbar_video_error_string(video: zbar_video_t; verbosity: Integer): PAnsiChar;
  607. // * retrieve the type code for the last video error. */
  608. function zbar_video_get_error_code(video: zbar_video_t): zbar_error_t;
  609. // @}*/
  610. // ------------------------------------------------------------*/
  611. // * @name Window interface
  612. // @anchor c-window
  613. // mid-level output window abstraction.
  614. // displays images to user-specified platform specific output window
  615. ///
  616. // @{*/
  617. type
  618. zbar_window_s = type Pointer;
  619. // * opaque window object. */
  620. zbar_window_t = zbar_window_s;
  621. // * constructor. */
  622. function zbar_window_create: zbar_window_t;
  623. // * destructor. */
  624. procedure zbar_window_destroy(window: zbar_window_t);
  625. // * associate reader with an existing platform window.
  626. // This can be any "Drawable" for X Windows or a "HWND" for windows.
  627. // input images will be scaled into the output window.
  628. // pass NULL to detach from the resource, further input will be
  629. // ignored
  630. ///
  631. function zbar_window_attach(window: zbar_window_t; x11_display_w32_hwnd: Pointer; x11_drawable: Cardinal): Integer;
  632. // * control content level of the reader overlay.
  633. // the overlay displays graphical data for informational or debug
  634. // purposes. higher values increase the level of annotation (possibly
  635. // decreasing performance). @verbatim
  636. // 0 = disable overlay
  637. // 1 = outline decoded symbols (default)
  638. // 2 = also track and display input frame rate
  639. // @endverbatim
  640. ///
  641. procedure zbar_window_set_overlay(window: zbar_window_t; level: Integer);
  642. // * draw a new image into the output window. */
  643. function zbar_window_draw(window: zbar_window_t; image: zbar_image_t): Integer;
  644. // * redraw the last image (exposure handler). */
  645. function zbar_window_redraw(window: zbar_window_t): Integer;
  646. // * resize the image window (reconfigure handler).
  647. // this does @em not update the contents of the window
  648. // @since 0.3, changed in 0.4 to not redraw window
  649. ///
  650. function zbar_window_resize(window: zbar_window_t; width: Cardinal; height: Cardinal): Integer;
  651. // * display detail for last window error to stderr.
  652. // @returns a non-zero value suitable for passing to exit()
  653. ///
  654. function zbar_window_error_spew(window: zbar_window_t; verbosity: Integer): Integer;
  655. // * retrieve the detail string for the last window error. */
  656. function zbar_window_error_string(window: zbar_window_t; verbosity: Integer): PAnsiChar;
  657. // * retrieve the type code for the last window error. */
  658. function zbar_window_get_error_code(window: zbar_window_t): zbar_error_t;
  659. // * select a compatible format between video input and output window.
  660. // the selection algorithm attempts to use a format shared by
  661. // video input and window output which is also most useful for
  662. // barcode scanning. if a format conversion is necessary, it will
  663. // heuristically attempt to minimize the cost of the conversion
  664. ///
  665. function zbar_negotiate_format(video: zbar_video_t; window: zbar_window_t): Integer;
  666. // @}*/
  667. // ------------------------------------------------------------*/
  668. // * @name Image Scanner interface
  669. // @anchor c-imagescanner
  670. // mid-level image scanner interface.
  671. // reads barcodes from 2-D images
  672. ///
  673. // @{*/
  674. type
  675. zbar_image_scanner_s = type Pointer;
  676. // * opaque image scanner object. */
  677. zbar_image_scanner_t = zbar_image_scanner_s;
  678. // * constructor. */
  679. function zbar_image_scanner_create: zbar_image_scanner_t;
  680. // * destructor. */
  681. procedure zbar_image_scanner_destroy(scanner: zbar_image_scanner_t);
  682. // * setup result handler callback.
  683. // the specified function will be called by the scanner whenever
  684. // new results are available from a decoded image.
  685. // pass a NULL value to disable callbacks.
  686. // @returns the previously registered handler
  687. ///
  688. function zbar_image_scanner_set_data_handler(scanner: zbar_image_scanner_t; handler: zbar_image_data_handler_t;
  689. userdata: Pointer): zbar_image_data_handler_t;
  690. // * set config for indicated symbology (0 for all) to specified value.
  691. // @returns 0 for success, non-0 for failure (config does not apply to
  692. // specified symbology, or value out of range)
  693. // @see zbar_decoder_set_config()
  694. // @since 0.4
  695. ///
  696. function zbar_image_scanner_set_config(scanner: zbar_image_scanner_t; symbology: zbar_symbol_type_t;
  697. config: zbar_config_t; value: Integer): Integer;
  698. // * parse configuration string using zbar_parse_config()
  699. // and apply to image scanner using zbar_image_scanner_set_config().
  700. // @returns 0 for success, non-0 for failure
  701. // @see zbar_parse_config()
  702. // @see zbar_image_scanner_set_config()
  703. // @since 0.4
  704. ///
  705. function zbar_image_scanner_parse_config(scanner: zbar_image_scanner_t; config_string: PAnsiChar): Integer;
  706. // * enable or disable the inter-image result cache (default disabled).
  707. // mostly useful for scanning video frames, the cache filters
  708. // duplicate results from consecutive images, while adding some
  709. // consistency checking and hysteresis to the results.
  710. // this interface also clears the cache
  711. ///
  712. procedure zbar_image_scanner_enable_cache(scanner: zbar_image_scanner_t; enable: Integer);
  713. // * scan for symbols in provided image.
  714. // @returns >0 if symbols were successfully decoded from the image,
  715. // 0 if no symbols were found or -1 if an error occurs
  716. ///
  717. function zbar_scan_image(scanner: zbar_image_scanner_t; image: zbar_image_t): Integer;
  718. // @}*/
  719. // ------------------------------------------------------------*/
  720. // * @name Decoder interface
  721. // @anchor c-decoder
  722. // low-level bar width stream decoder interface.
  723. // identifies symbols and extracts encoded data
  724. ///
  725. // @{*/
  726. type
  727. zbar_decoder_s = type Pointer;
  728. // * opaque decoder object. */
  729. zbar_decoder_t = zbar_decoder_s;
  730. // * decoder data handler callback function.
  731. // called by decoder when new data has just been decoded
  732. ///
  733. zbar_decoder_handler_t = procedure(decoder: zbar_decoder_t);
  734. // * constructor. */
  735. function zbar_decoder_create: zbar_decoder_t;
  736. // * destructor. */
  737. procedure zbar_decoder_destroy(decoder: zbar_decoder_t);
  738. // * set config for indicated symbology (0 for all) to specified value.
  739. // @returns 0 for success, non-0 for failure (config does not apply to
  740. // specified symbology, or value out of range)
  741. // @since 0.4
  742. ///
  743. function zbar_decoder_set_config(decoder: zbar_decoder_t; symbology: zbar_symbol_type_t; config: zbar_config_t;
  744. value: Integer): Integer;
  745. // * parse configuration string using zbar_parse_config()
  746. // and apply to decoder using zbar_decoder_set_config().
  747. // @returns 0 for success, non-0 for failure
  748. // @see zbar_parse_config()
  749. // @see zbar_decoder_set_config()
  750. // @since 0.4
  751. ///
  752. function zbar_decoder_parse_config(decoder: zbar_decoder_t; config_string: PAnsiChar): Integer;
  753. // * clear all decoder state.
  754. // any partial symbols are flushed
  755. ///
  756. procedure zbar_decoder_reset(decoder: zbar_decoder_t);
  757. // * mark start of a new scan pass.
  758. // clears any intra-symbol state and resets color to ::ZBAR_SPACE.
  759. // any partially decoded symbol state is retained
  760. ///
  761. procedure zbar_decoder_new_scan(decoder: zbar_decoder_t);
  762. // * process next bar/space width from input stream.
  763. // the width is in arbitrary relative units. first value of a scan
  764. // is ::ZBAR_SPACE width, alternating from there.
  765. // @returns appropriate symbol type if width completes
  766. // decode of a symbol (data is available for retrieval)
  767. // @returns ::ZBAR_PARTIAL as a hint if part of a symbol was decoded
  768. // @returns ::ZBAR_NONE (0) if no new symbol data is available
  769. ///
  770. function zbar_decode_width(decoder: zbar_decoder_t; width: Cardinal): zbar_symbol_type_t;
  771. // * retrieve color of @em next element passed to
  772. // zbar_decode_width(). */
  773. function zbar_decoder_get_color(decoder: zbar_decoder_t): zbar_color_t;
  774. // * retrieve last decoded data in ASCII format.
  775. // @returns the data string or NULL if no new data available.
  776. // the returned data buffer is owned by library, contents are only
  777. // valid between non-0 return from zbar_decode_width and next library
  778. // call
  779. ///
  780. function zbar_decoder_get_data(decoder: zbar_decoder_t): PAnsiChar;
  781. // * retrieve last decoded symbol type.
  782. // @returns the type or ::ZBAR_NONE if no new data available
  783. ///
  784. function zbar_decoder_get_type(decoder: zbar_decoder_t): zbar_symbol_type_t;
  785. // * setup data handler callback.
  786. // the registered function will be called by the decoder
  787. // just before zbar_decode_width() returns a non-zero value.
  788. // pass a NULL value to disable callbacks.
  789. // @returns the previously registered handler
  790. ///
  791. function zbar_decoder_set_handler(decoder: zbar_decoder_t; handler: zbar_decoder_handler_t): zbar_decoder_handler_t;
  792. // * associate user specified data value with the decoder. */
  793. procedure zbar_decoder_set_userdata(decoder: zbar_decoder_t; userdata: Pointer);
  794. // * return user specified data value associated with the decoder. */
  795. function zbar_decoder_get_userdata(decoder: zbar_decoder_t): Pointer;
  796. // @}*/
  797. // ------------------------------------------------------------*/
  798. // * @name Scanner interface
  799. // @anchor c-scanner
  800. // low-level linear intensity sample stream scanner interface.
  801. // identifies "bar" edges and measures width between them.
  802. // optionally passes to bar width decoder
  803. ///
  804. // @{*/
  805. type
  806. zbar_scanner_s = type Pointer;
  807. // * opaque scanner object. */
  808. zbar_scanner_t = zbar_scanner_s;
  809. // * constructor.
  810. // if decoder is non-NULL it will be attached to scanner
  811. // and called automatically at each new edge
  812. // current color is initialized to ::ZBAR_SPACE
  813. // (so an initial BAR->SPACE transition may be discarded)
  814. ///
  815. function zbar_scanner_create(decoder: zbar_decoder_t): zbar_scanner_t;
  816. // * destructor. */
  817. procedure zbar_scanner_destroy(scanner: zbar_scanner_t);
  818. // * clear all scanner state.
  819. // also resets an associated decoder
  820. ///
  821. function zbar_scanner_reset(scanner: zbar_scanner_t): zbar_symbol_type_t;
  822. // * mark start of a new scan pass. resets color to ::ZBAR_SPACE.
  823. // also updates an associated decoder.
  824. // @returns any decode results flushed from the pipeline
  825. // @note when not using callback handlers, the return value should
  826. // be checked the same as zbar_scan_y()
  827. ///
  828. function zbar_scanner_new_scan(scanner: zbar_scanner_t): zbar_symbol_type_t;
  829. // * process next sample intensity value.
  830. // intensity (y) is in arbitrary relative units.
  831. // @returns result of zbar_decode_width() if a decoder is attached,
  832. // otherwise @returns (::ZBAR_PARTIAL) when new edge is detected
  833. // or 0 (::ZBAR_NONE) if no new edge is detected
  834. ///
  835. function zbar_scan_y(scanner: zbar_scanner_t; y: Integer): zbar_symbol_type_t;
  836. // * process next sample from RGB (or BGR) triple. */
  837. function zbar_scan_rgb24(scanner: zbar_scanner_t; rgb: PAnsiChar): zbar_symbol_type_t;
  838. // * retrieve last scanned width. */
  839. function zbar_scanner_get_width(scanner: zbar_scanner_t): Cardinal;
  840. // * retrieve last scanned color. */
  841. function zbar_scanner_get_color(scanner: zbar_scanner_t): zbar_color_t;
  842. // Returns True if the ZBAR dll has been found and loaded
  843. function zbar_loaded: Boolean;
  844. // A table to equate bar code type enum values to descriptive names
  845. type
  846. TZbarBarcodeRecord = record
  847. BCCode: zbar_symbol_type_e;
  848. BCName: AnsiString;
  849. end;
  850. {const
  851. ZBAR_BARCODES: array [0 .. 9] of TZbarBarcodeRecord = ((BCCode: ZBAR_EAN8; BCName: 'EAN-8'), (BCCode: ZBAR_UPCE;
  852. BCName: 'UPCE'), (BCCode: ZBAR_ISBN10; BCName: 'ISBN-10'), (BCCode: ZBAR_UPCA; BCName: 'UPCA'),
  853. (BCCode: ZBAR_EAN13; BCName: 'EAN-13'), (BCCode: ZBAR_ISBN13; BCName: 'ISBN-13'), (BCCode: ZBAR_I25;
  854. BCName: 'Interleaved 2 0f 5'), (BCCode: ZBAR_CODE39; BCName: 'Code39'), (BCCode: ZBAR_PDF417; BCName: 'PDF417'),
  855. (BCCode: ZBAR_CODE128; BCName: 'Code128')); }
  856. const
  857. ZBAR_BARCODES: array[0..10] of TZbarBarcodeRecord = (
  858. (BCCode: ZBAR_EAN8; BCName: 'EAN-8'),
  859. (BCCode: ZBAR_UPCE; BCName: 'UPCE'),
  860. (BCCode: ZBAR_ISBN10; BCName: 'ISBN-10'),
  861. (BCCode: ZBAR_UPCA; BCName: 'UPCA'),
  862. (BCCode: ZBAR_EAN13; BCName: 'EAN-13'),
  863. (BCCode: ZBAR_ISBN13; BCName: 'ISBN-13'),
  864. (BCCode: ZBAR_I25; BCName: 'Interleaved 2 0f 5'),
  865. (BCCode: ZBAR_CODE39; BCName: 'Code39'),
  866. (BCCode: ZBAR_PDF417; BCName: 'PDF417'),
  867. (BCCode: ZBAR_CODE128; BCName: 'Code128'),
  868. (BCCode: ZBAR_QRCODE; BCName: 'QR')
  869. );
  870. implementation
  871. var
  872. DllHandle: THandle;
  873. procedure GetAddressOf(procName: AnsiString; var procPtr: Pointer);
  874. begin
  875. if (DllHandle = 0) then
  876. raise Exception.Create('libzbar-0.dll not found');
  877. procPtr := GetProcAddress(DllHandle, PAnsiChar(procName));
  878. if (not Assigned(procPtr)) then
  879. raise Exception.CreateFmt('Entry point %s not found in libzbar-0.dll', [procName]);
  880. end;
  881. function zbar_loaded: Boolean;
  882. begin
  883. Result := DllHandle <> 0;
  884. end;
  885. function zbar_version(var major: Cardinal; var minor: Cardinal): Integer;
  886. var
  887. proc: function(var major: Cardinal; var minor: Cardinal): Integer; cdecl;
  888. begin
  889. GetAddressOf('zbar_version', @proc);
  890. Result := proc(major, minor);
  891. end;
  892. procedure zbar_set_verbosity(verbosity: Integer);
  893. var
  894. proc: procedure(verbosity: Integer); cdecl;
  895. begin
  896. GetAddressOf('zbar_set_verbosity', @proc);
  897. proc(verbosity);
  898. end;
  899. procedure zbar_increase_verbosity;
  900. var
  901. proc: procedure; cdecl;
  902. begin
  903. GetAddressOf('zbar_increase_verbosity', @proc);
  904. proc;
  905. end;
  906. function zbar_get_symbol_name(sym: zbar_symbol_type_t): PAnsiChar;
  907. var
  908. proc: function(sym: zbar_symbol_type_t): PAnsiChar; cdecl;
  909. begin
  910. GetAddressOf('zbar_get_symbol_name', @proc);
  911. Result := proc(sym);
  912. end;
  913. function zbar_get_addon_name(sym: zbar_symbol_type_t): PAnsiChar;
  914. var
  915. proc: function(sym: zbar_symbol_type_t): PAnsiChar; cdecl;
  916. begin
  917. GetAddressOf('zbar_get_addon_name', @proc);
  918. Result := proc(sym);
  919. end;
  920. function zbar_parse_config(const config_string: PAnsiChar; var symbology: zbar_symbol_type_t; var config: zbar_config_t;
  921. var value: Integer): Integer;
  922. var
  923. proc: function(const config_string: PAnsiChar; var symbology: zbar_symbol_type_t; var config: zbar_config_t;
  924. var value: Integer): Integer; cdecl;
  925. begin
  926. GetAddressOf('zbar_parse_config', @proc);
  927. Result := proc(config_string, symbology, config, value);
  928. end;
  929. function _zbar_error_spew(objekt: Pointer; verbosity: Integer): Integer;
  930. var
  931. proc: function(objekt: Pointer; verbosity: Integer): Integer; cdecl;
  932. begin
  933. GetAddressOf('_zbar_error_spew', @proc);
  934. Result := proc(objekt, verbosity);
  935. end;
  936. function _zbar_error_string(objekt: Pointer; verbosity: Integer): PAnsiChar;
  937. var
  938. proc: function(objekt: Pointer; verbosity: Integer): PAnsiChar; cdecl;
  939. begin
  940. GetAddressOf('_zbar_error_string', @proc);
  941. Result := proc(objekt, verbosity);
  942. end;
  943. function _zbar_get_error_code(objekt: Pointer): zbar_error_t;
  944. var
  945. proc: function(objekt: Pointer): zbar_error_t; cdecl;
  946. begin
  947. GetAddressOf('_zbar_get_error_code', @proc);
  948. Result := proc(objekt);
  949. end;
  950. function zbar_symbol_get_type(symbol: zbar_symbol_t): zbar_symbol_type_t;
  951. var
  952. proc: function(symbol: zbar_symbol_t): zbar_symbol_type_t; cdecl;
  953. begin
  954. GetAddressOf('zbar_symbol_get_type', @proc);
  955. Result := proc(symbol);
  956. end;
  957. {Function zbar_symbol_get_data_length (symbol: zbar_symbol_t): integer;
  958. var
  959. proc: function(symbol: zbar_symbol_t): integer; cdecl;
  960. begin
  961. GetAddressOf('zbar_symbol_get_type', @proc);
  962. Result := proc(symbol.datalen);
  963. end; }
  964. function zbar_symbol_get_data(symbol: zbar_symbol_t): PAnsiChar;
  965. var
  966. proc: function(symbol: zbar_symbol_t): PAnsiChar; cdecl;
  967. begin
  968. GetAddressOf('zbar_symbol_get_data', @proc);
  969. Result := proc(symbol);
  970. end;
  971. function zbar_symbol_get_count(symbol: zbar_symbol_t): Integer;
  972. var
  973. proc: function(symbol: zbar_symbol_t): Integer; cdecl;
  974. begin
  975. GetAddressOf('zbar_symbol_get_count', @proc);
  976. Result := proc(symbol);
  977. end;
  978. function zbar_symbol_get_loc_size(symbol: zbar_symbol_t): Cardinal;
  979. var
  980. proc: function(symbol: zbar_symbol_t): Cardinal; cdecl;
  981. begin
  982. GetAddressOf('zbar_symbol_get_loc_size', @proc);
  983. Result := proc(symbol);
  984. end;
  985. function zbar_symbol_get_loc_x(symbol: zbar_symbol_t; index: Cardinal): Integer;
  986. var
  987. proc: function(symbol: zbar_symbol_t; index: Cardinal): Integer; cdecl;
  988. begin
  989. GetAddressOf('zbar_symbol_get_loc_x', @proc);
  990. Result := proc(symbol, index);
  991. end;
  992. function zbar_symbol_get_loc_y(symbol: zbar_symbol_t; index: Cardinal): Integer;
  993. var
  994. proc: function(symbol: zbar_symbol_t; index: Cardinal): Integer; cdecl;
  995. begin
  996. GetAddressOf('zbar_symbol_get_loc_y', @proc);
  997. Result := proc(symbol, index);
  998. end;
  999. function zbar_symbol_next(symbol: zbar_symbol_t): zbar_symbol_t;
  1000. var
  1001. proc: function(symbol: zbar_symbol_t): zbar_symbol_t; cdecl;
  1002. begin
  1003. GetAddressOf('zbar_symbol_next', @proc);
  1004. Result := proc(symbol);
  1005. end;
  1006. function zbar_symbol_xml(symbol: zbar_symbol_t; var buffer: PAnsiChar; var buflen: Cardinal): PAnsiChar;
  1007. var
  1008. proc: function(symbol: zbar_symbol_t; var buffer: PAnsiChar; var buflen: Cardinal): PAnsiChar; cdecl;
  1009. begin
  1010. GetAddressOf('zbar_symbol_xml', @proc);
  1011. Result := proc(symbol, buffer, buflen);
  1012. end;
  1013. function zbar_image_create: zbar_image_t;
  1014. var
  1015. proc: function: zbar_image_t; cdecl;
  1016. begin
  1017. GetAddressOf('zbar_image_create', @proc);
  1018. Result := proc;
  1019. end;
  1020. procedure zbar_image_destroy(image: zbar_image_t);
  1021. var
  1022. proc: procedure(image: zbar_image_t); cdecl;
  1023. begin
  1024. GetAddressOf('zbar_image_destroy', @proc);
  1025. proc(image);
  1026. end;
  1027. procedure zbar_image_ref(image: zbar_image_t; refs: Integer);
  1028. var
  1029. proc: procedure(image: zbar_image_t; refs: Integer); cdecl;
  1030. begin
  1031. GetAddressOf('zbar_image_ref', @proc);
  1032. proc(image, refs);
  1033. end;
  1034. function zbar_image_convert(image: zbar_image_t; format: PAnsiChar): zbar_image_t;
  1035. var
  1036. proc: function(image: zbar_image_t; format: Cardinal): zbar_image_t; cdecl;
  1037. var
  1038. val: Cardinal;
  1039. begin
  1040. GetAddressOf('zbar_image_convert', @proc);
  1041. val := PCardinal(format)^;
  1042. Result := proc(image, val);
  1043. end;
  1044. function zbar_image_convert_resize(image: zbar_image_t; format: PAnsiChar; width: Cardinal; height: Cardinal): zbar_image_t;
  1045. var
  1046. proc: function(image: zbar_image_t; format: Cardinal; width: Cardinal; height: Cardinal): zbar_image_t; cdecl;
  1047. var
  1048. val: Cardinal;
  1049. begin
  1050. GetAddressOf('zbar_image_convert_resize', @proc);
  1051. val := PCardinal(format)^;
  1052. Result := proc(image, val, width, height);
  1053. end;
  1054. function zbar_image_get_format(image: zbar_image_t): Cardinal;
  1055. var
  1056. proc: function(image: zbar_image_t): Cardinal; cdecl;
  1057. begin
  1058. GetAddressOf('zbar_image_get_format', @proc);
  1059. Result := proc(image);
  1060. end;
  1061. function zbar_image_get_sequence(image: zbar_image_t): Cardinal;
  1062. var
  1063. proc: function(image: zbar_image_t): Cardinal; cdecl;
  1064. begin
  1065. GetAddressOf('zbar_image_get_sequence', @proc);
  1066. Result := proc(image);
  1067. end;
  1068. function zbar_image_get_width(image: zbar_image_t): Cardinal;
  1069. var
  1070. proc: function(image: zbar_image_t): Cardinal; cdecl;
  1071. begin
  1072. GetAddressOf('zbar_image_get_width', @proc);
  1073. Result := proc(image);
  1074. end;
  1075. function zbar_image_get_height(image: zbar_image_t): Cardinal;
  1076. var
  1077. proc: function(image: zbar_image_t): Cardinal; cdecl;
  1078. begin
  1079. GetAddressOf('zbar_image_get_height', @proc);
  1080. Result := proc(image);
  1081. end;
  1082. function zbar_image_get_data(image: zbar_image_t): Pointer;
  1083. var
  1084. proc: function(image: zbar_image_t): Pointer; cdecl;
  1085. begin
  1086. GetAddressOf('zbar_image_get_data', @proc);
  1087. Result := proc(image);
  1088. end;
  1089. function zbar_image_get_data_length(img: zbar_image_t): Cardinal;
  1090. var
  1091. proc: function(img: zbar_image_t): Cardinal; cdecl;
  1092. begin
  1093. GetAddressOf('zbar_image_get_data_length', @proc);
  1094. Result := proc(img);
  1095. end;
  1096. function zbar_image_first_symbol(image: zbar_image_t): zbar_symbol_t;
  1097. var
  1098. proc: function(image: zbar_image_t): zbar_symbol_t; cdecl;
  1099. begin
  1100. GetAddressOf('zbar_image_first_symbol', @proc);
  1101. Result := proc(image);
  1102. end;
  1103. procedure zbar_image_set_format(image: zbar_image_t; format: PAnsiChar);
  1104. var
  1105. proc: procedure(image: zbar_image_t; format: Cardinal); cdecl;
  1106. var
  1107. val: Cardinal;
  1108. begin
  1109. GetAddressOf('zbar_image_set_format', @proc);
  1110. val := PCardinal(format)^;
  1111. proc(image, val);
  1112. end;
  1113. procedure zbar_image_set_sequence(image: zbar_image_t; sequence_num: Cardinal);
  1114. var
  1115. proc: procedure(image: zbar_image_t; sequence_num: Cardinal); cdecl;
  1116. begin
  1117. GetAddressOf('zbar_image_set_sequence', @proc);
  1118. proc(image, sequence_num);
  1119. end;
  1120. procedure zbar_image_set_size(image: zbar_image_t; width: Cardinal; height: Cardinal);
  1121. var
  1122. proc: procedure(image: zbar_image_t; width: Cardinal; height: Cardinal); cdecl;
  1123. begin
  1124. GetAddressOf('zbar_image_set_size', @proc);
  1125. proc(image, width, height);
  1126. end;
  1127. procedure zbar_image_set_data(image: zbar_image_t; data: Pointer; data_byte_length: Cardinal;
  1128. cleanup_hndlr: zbar_image_cleanup_handler_t);
  1129. var
  1130. proc: procedure(image: zbar_image_t; data: Pointer; data_byte_length: Cardinal;
  1131. cleanup_hndlr: zbar_image_cleanup_handler_t); cdecl;
  1132. begin
  1133. GetAddressOf('zbar_image_set_data', @proc);
  1134. proc(image, data, data_byte_length, cleanup_hndlr);
  1135. end;
  1136. procedure zbar_image_free_data(image: zbar_image_t);
  1137. var
  1138. proc: procedure(image: zbar_image_t); cdecl;
  1139. begin
  1140. GetAddressOf('zbar_image_free_data', @proc);
  1141. proc(image);
  1142. end;
  1143. procedure zbar_image_set_userdata(image: zbar_image_t; userdata: Pointer);
  1144. var
  1145. proc: procedure(image: zbar_image_t; userdata: Pointer); cdecl;
  1146. begin
  1147. GetAddressOf('zbar_image_set_userdata', @proc);
  1148. proc(image, userdata);
  1149. end;
  1150. function zbar_image_get_userdata(image: zbar_image_t): Pointer;
  1151. var
  1152. proc: function(image: zbar_image_t): Pointer; cdecl;
  1153. begin
  1154. GetAddressOf('zbar_image_get_userdata', @proc);
  1155. Result := proc(image);
  1156. end;
  1157. function zbar_image_write(image: zbar_image_t; filebase: PAnsiChar): Integer;
  1158. var
  1159. proc: function(image: zbar_image_t; filebase: PAnsiChar): Integer; cdecl;
  1160. begin
  1161. GetAddressOf('zbar_image_write', @proc);
  1162. Result := proc(image, filebase);
  1163. end;
  1164. function zbar_image_read(filename: PAnsiChar): zbar_image_t;
  1165. var
  1166. proc: function(filename: PAnsiChar): zbar_image_t; cdecl;
  1167. begin
  1168. GetAddressOf('zbar_image_read', @proc);
  1169. Result := proc(filename);
  1170. end;
  1171. function zbar_processor_create(threaded: Integer): zbar_processor_t;
  1172. var
  1173. proc: function(threaded: Integer): zbar_processor_t; cdecl;
  1174. begin
  1175. GetAddressOf('zbar_processor_create', @proc);
  1176. Result := proc(threaded);
  1177. end;
  1178. procedure zbar_processor_destroy(processor: zbar_processor_t);
  1179. var
  1180. proc: procedure(processor: zbar_processor_t); cdecl;
  1181. begin
  1182. GetAddressOf('zbar_processor_destroy', @proc);
  1183. proc(processor);
  1184. end;
  1185. function zbar_processor_init(processor: zbar_processor_t; video_device: PAnsiChar; enable_display: Integer): Integer;
  1186. var
  1187. proc: function(processor: zbar_processor_t; video_device: PAnsiChar; enable_display: Integer): Integer; cdecl;
  1188. begin
  1189. GetAddressOf('zbar_processor_init', @proc);
  1190. Result := proc(processor, video_device, enable_display);
  1191. end;
  1192. function zbar_processor_request_size(processor: zbar_processor_t; width: Cardinal; height: Cardinal): Integer;
  1193. var
  1194. proc: function(processor: zbar_processor_t; width: Cardinal; height: Cardinal): Integer; cdecl;
  1195. begin
  1196. GetAddressOf('zbar_processor_request_size', @proc);
  1197. Result := proc(processor, width, height);
  1198. end;
  1199. function zbar_processor_request_interface(processor: zbar_processor_t; version: Integer): Integer;
  1200. var
  1201. proc: function(processor: zbar_processor_t; version: Integer): Integer; cdecl;
  1202. begin
  1203. GetAddressOf('zbar_processor_request_interface', @proc);
  1204. Result := proc(processor, version);
  1205. end;
  1206. function zbar_processor_request_iomode(video: zbar_processor_t; iomode: Integer): Integer;
  1207. var
  1208. proc: function(video: zbar_processor_t; iomode: Integer): Integer; cdecl;
  1209. begin
  1210. GetAddressOf('zbar_processor_request_iomode', @proc);
  1211. Result := proc(video, iomode);
  1212. end;
  1213. function zbar_processor_force_format(processor: zbar_processor_t; input_format: Cardinal;
  1214. output_format: Cardinal): Integer;
  1215. var
  1216. proc: function(processor: zbar_processor_t; input_format: Cardinal; output_format: Cardinal): Integer; cdecl;
  1217. begin
  1218. GetAddressOf('zbar_processor_force_format', @proc);
  1219. Result := proc(processor, input_format, output_format);
  1220. end;
  1221. function zbar_processor_set_data_handler(processor: zbar_processor_t; handler: zbar_image_data_handler_t;
  1222. userdata: PAnsiChar): zbar_image_data_handler_t;
  1223. var
  1224. proc: function(processor: zbar_processor_t; handler: zbar_image_data_handler_t; userdata: PAnsiChar)
  1225. : zbar_image_data_handler_t; cdecl;
  1226. begin
  1227. GetAddressOf('zbar_processor_set_data_handler', @proc);
  1228. Result := proc(processor, handler, userdata);
  1229. end;
  1230. procedure zbar_processor_set_userdata(processor: zbar_processor_t; userdata: Pointer);
  1231. var
  1232. proc: procedure(processor: zbar_processor_t; userdata: Pointer); cdecl;
  1233. begin
  1234. GetAddressOf('zbar_processor_set_userdata', @proc);
  1235. proc(processor, userdata);
  1236. end;
  1237. function zbar_processor_get_userdata(processor: zbar_processor_t): Pointer;
  1238. var
  1239. proc: function(processor: zbar_processor_t): Pointer; cdecl;
  1240. begin
  1241. GetAddressOf('zbar_processor_get_userdata', @proc);
  1242. Result := proc(processor);
  1243. end;
  1244. function zbar_processor_set_config(processor: zbar_processor_t; symbology: zbar_symbol_type_t; config: zbar_config_t;
  1245. value: Integer): Integer;
  1246. var
  1247. proc: function(processor: zbar_processor_t; symbology: zbar_symbol_type_t; config: zbar_config_t; value: Integer)
  1248. : Integer; cdecl;
  1249. begin
  1250. GetAddressOf('zbar_processor_set_config', @proc);
  1251. Result := proc(processor, symbology, config, value);
  1252. end;
  1253. function zbar_processor_parse_config(processor: zbar_processor_t; config_string: PAnsiChar): Integer;
  1254. var
  1255. sym: zbar_symbol_type_t;
  1256. cfg: zbar_config_t;
  1257. val: Integer;
  1258. begin
  1259. Result := zbar_parse_config(config_string, sym, cfg, val) or zbar_processor_set_config(processor, sym, cfg, val);
  1260. end;
  1261. function zbar_processor_is_visible(processor: zbar_processor_t): Integer;
  1262. var
  1263. proc: function(processor: zbar_processor_t): Integer; cdecl;
  1264. begin
  1265. GetAddressOf('zbar_processor_is_visible', @proc);
  1266. Result := proc(processor);
  1267. end;
  1268. function zbar_processor_set_visible(processor: zbar_processor_t; visible: Integer): Integer;
  1269. var
  1270. proc: function(processor: zbar_processor_t; visible: Integer): Integer; cdecl;
  1271. begin
  1272. GetAddressOf('zbar_processor_set_visible', @proc);
  1273. Result := proc(processor, visible);
  1274. end;
  1275. function zbar_processor_set_active(processor: zbar_processor_t; active: Integer): Integer;
  1276. var
  1277. proc: function(processor: zbar_processor_t; active: Integer): Integer; cdecl;
  1278. begin
  1279. GetAddressOf('zbar_processor_set_active', @proc);
  1280. Result := proc(processor, active);
  1281. end;
  1282. function zbar_processor_user_wait(processor: zbar_processor_t; timeout: Integer): Integer;
  1283. var
  1284. proc: function(processor: zbar_processor_t; timeout: Integer): Integer; cdecl;
  1285. begin
  1286. GetAddressOf('zbar_processor_user_wait', @proc);
  1287. Result := proc(processor, timeout);
  1288. end;
  1289. function zbar_process_one(processor: zbar_processor_t; timeout: Integer): Integer;
  1290. var
  1291. proc: function(processor: zbar_processor_t; timeout: Integer): Integer; cdecl;
  1292. begin
  1293. GetAddressOf('zbar_process_one', @proc);
  1294. Result := proc(processor, timeout);
  1295. end;
  1296. function zbar_process_image(processor: zbar_processor_t; image: zbar_image_t): Integer;
  1297. var
  1298. proc: function(processor: zbar_processor_t; image: zbar_image_t): Integer; cdecl;
  1299. begin
  1300. GetAddressOf('zbar_process_image', @proc);
  1301. Result := proc(processor, image);
  1302. end;
  1303. function zbar_processor_error_spew(processor: zbar_processor_t; verbosity: Integer): Integer;
  1304. begin
  1305. Result := _zbar_error_spew(processor, verbosity);
  1306. end;
  1307. function zbar_processor_error_string(processor: zbar_processor_t; verbosity: Integer): PAnsiChar;
  1308. begin
  1309. Result := _zbar_error_string(processor, verbosity);
  1310. end;
  1311. function zbar_processor_get_error_code(processor: zbar_processor_t): zbar_error_t;
  1312. begin
  1313. Result := _zbar_get_error_code(processor);
  1314. end;
  1315. function zbar_video_create: zbar_video_t;
  1316. var
  1317. proc: function: zbar_video_t; cdecl;
  1318. begin
  1319. GetAddressOf('zbar_video_create', @proc);
  1320. Result := proc;
  1321. end;
  1322. procedure zbar_video_destroy(video: zbar_video_t);
  1323. var
  1324. proc: procedure(video: zbar_video_t); cdecl;
  1325. begin
  1326. GetAddressOf('zbar_video_destroy', @proc);
  1327. proc(video);
  1328. end;
  1329. function zbar_video_open(video: zbar_video_t; device: PAnsiChar): Integer;
  1330. var
  1331. proc: function(video: zbar_video_t; device: PAnsiChar): Integer; cdecl;
  1332. begin
  1333. GetAddressOf('zbar_video_open', @proc);
  1334. Result := proc(video, device);
  1335. end;
  1336. function zbar_video_get_fd(video: zbar_video_t): Integer;
  1337. var
  1338. proc: function(video: zbar_video_t): Integer; cdecl;
  1339. begin
  1340. GetAddressOf('zbar_video_get_fd', @proc);
  1341. Result := proc(video);
  1342. end;
  1343. function zbar_video_request_size(video: zbar_video_t; width: Cardinal; height: Cardinal): Integer;
  1344. var
  1345. proc: function(video: zbar_video_t; width: Cardinal; height: Cardinal): Integer; cdecl;
  1346. begin
  1347. GetAddressOf('zbar_video_request_size', @proc);
  1348. Result := proc(video, width, height);
  1349. end;
  1350. function zbar_video_request_interface(video: zbar_video_t; version: Integer): Integer;
  1351. var
  1352. proc: function(video: zbar_video_t; version: Integer): Integer; cdecl;
  1353. begin
  1354. GetAddressOf('zbar_video_request_interface', @proc);
  1355. Result := proc(video, version);
  1356. end;
  1357. function zbar_video_request_iomode(video: zbar_video_t; iomode: Integer): Integer;
  1358. var
  1359. proc: function(video: zbar_video_t; iomode: Integer): Integer; cdecl;
  1360. begin
  1361. GetAddressOf('zbar_video_request_iomode', @proc);
  1362. Result := proc(video, iomode);
  1363. end;
  1364. function zbar_video_get_width(video: zbar_video_t): Integer;
  1365. var
  1366. proc: function(video: zbar_video_t): Integer; cdecl;
  1367. begin
  1368. GetAddressOf('zbar_video_get_width', @proc);
  1369. Result := proc(video);
  1370. end;
  1371. function zbar_video_get_height(video: zbar_video_t): Integer;
  1372. var
  1373. proc: function(video: zbar_video_t): Integer; cdecl;
  1374. begin
  1375. GetAddressOf('zbar_video_get_height', @proc);
  1376. Result := proc(video);
  1377. end;
  1378. function zbar_video_init(video: zbar_video_t; format: Cardinal): Integer;
  1379. var
  1380. proc: function(video: zbar_video_t; format: Cardinal): Integer; cdecl;
  1381. begin
  1382. GetAddressOf('zbar_video_init', @proc);
  1383. Result := proc(video, format);
  1384. end;
  1385. function zbar_video_enable(video: zbar_video_t; enable: Integer): Integer;
  1386. var
  1387. proc: function(video: zbar_video_t; enable: Integer): Integer; cdecl;
  1388. begin
  1389. GetAddressOf('zbar_video_enable', @proc);
  1390. Result := proc(video, enable);
  1391. end;
  1392. function zbar_video_next_image(video: zbar_video_t): zbar_image_t;
  1393. var
  1394. proc: function(video: zbar_video_t): zbar_image_t; cdecl;
  1395. begin
  1396. GetAddressOf('zbar_video_next_image', @proc);
  1397. Result := proc(video);
  1398. end;
  1399. function zbar_video_error_spew(video: zbar_video_t; verbosity: Integer): Integer;
  1400. begin
  1401. Result := _zbar_error_spew(video, verbosity);
  1402. end;
  1403. function zbar_video_error_string(video: zbar_video_t; verbosity: Integer): PAnsiChar;
  1404. begin
  1405. Result := _zbar_error_string(video, verbosity);
  1406. end;
  1407. function zbar_video_get_error_code(video: zbar_video_t): zbar_error_t;
  1408. begin
  1409. Result := _zbar_get_error_code(video);
  1410. end;
  1411. function zbar_window_create: zbar_window_t;
  1412. var
  1413. proc: function: zbar_window_t; cdecl;
  1414. begin
  1415. GetAddressOf('zbar_window_create', @proc);
  1416. Result := proc;
  1417. end;
  1418. procedure zbar_window_destroy(window: zbar_window_t);
  1419. var
  1420. proc: procedure(window: zbar_window_t); cdecl;
  1421. begin
  1422. GetAddressOf('zbar_window_destroy', @proc);
  1423. proc(window);
  1424. end;
  1425. function zbar_window_attach(window: zbar_window_t; x11_display_w32_hwnd: Pointer; x11_drawable: Cardinal): Integer;
  1426. var
  1427. proc: function(window: zbar_window_t; x11_display_w32_hwnd: Pointer; x11_drawable: Cardinal): Integer; cdecl;
  1428. begin
  1429. GetAddressOf('zbar_window_attach', @proc);
  1430. Result := proc(window, x11_display_w32_hwnd, x11_drawable);
  1431. end;
  1432. procedure zbar_window_set_overlay(window: zbar_window_t; level: Integer);
  1433. var
  1434. proc: procedure(window: zbar_window_t; level: Integer); cdecl;
  1435. begin
  1436. GetAddressOf('zbar_window_set_overlay', @proc);
  1437. proc(window, level);
  1438. end;
  1439. function zbar_window_draw(window: zbar_window_t; image: zbar_image_t): Integer;
  1440. var
  1441. proc: function(window: zbar_window_t; image: zbar_image_t): Integer; cdecl;
  1442. begin
  1443. GetAddressOf('zbar_window_draw', @proc);
  1444. Result := proc(window, image);
  1445. end;
  1446. function zbar_window_redraw(window: zbar_window_t): Integer;
  1447. var
  1448. proc: function(window: zbar_window_t): Integer; cdecl;
  1449. begin
  1450. GetAddressOf('zbar_window_redraw', @proc);
  1451. Result := proc(window);
  1452. end;
  1453. function zbar_window_resize(window: zbar_window_t; width: Cardinal; height: Cardinal): Integer;
  1454. var
  1455. proc: function(window: zbar_window_t; width: Cardinal; height: Cardinal): Integer; cdecl;
  1456. begin
  1457. GetAddressOf('zbar_window_resize', @proc);
  1458. Result := proc(window, width, height);
  1459. end;
  1460. function zbar_window_error_spew(window: zbar_window_t; verbosity: Integer): Integer;
  1461. begin
  1462. Result := _zbar_error_spew(window, verbosity);
  1463. end;
  1464. function zbar_window_error_string(window: zbar_window_t; verbosity: Integer): PAnsiChar;
  1465. begin
  1466. Result := _zbar_error_string(window, verbosity);
  1467. end;
  1468. function zbar_window_get_error_code(window: zbar_window_t): zbar_error_t;
  1469. begin
  1470. Result := _zbar_get_error_code(window);
  1471. end;
  1472. function zbar_negotiate_format(video: zbar_video_t; window: zbar_window_t): Integer;
  1473. var
  1474. proc: function(video: zbar_video_t; window: zbar_window_t): Integer; cdecl;
  1475. begin
  1476. GetAddressOf('zbar_negotiate_format', @proc);
  1477. Result := proc(video, window);
  1478. end;
  1479. function zbar_image_scanner_create: zbar_image_scanner_t;
  1480. var
  1481. proc: function: zbar_image_scanner_t; cdecl;
  1482. begin
  1483. GetAddressOf('zbar_image_scanner_create', @proc);
  1484. Result := proc;
  1485. end;
  1486. procedure zbar_image_scanner_destroy(scanner: zbar_image_scanner_t);
  1487. var
  1488. proc: procedure(scanner: zbar_image_scanner_t); cdecl;
  1489. begin
  1490. GetAddressOf('zbar_image_scanner_destroy', @proc);
  1491. proc(scanner);
  1492. end;
  1493. function zbar_image_scanner_set_data_handler(scanner: zbar_image_scanner_t; handler: zbar_image_data_handler_t;
  1494. userdata: Pointer): zbar_image_data_handler_t;
  1495. var
  1496. proc: function(scanner: zbar_image_scanner_t; handler: zbar_image_data_handler_t; userdata: Pointer)
  1497. : zbar_image_data_handler_t; cdecl;
  1498. begin
  1499. GetAddressOf('zbar_image_scanner_set_data_handler', @proc);
  1500. Result := proc(scanner, handler, userdata);
  1501. end;
  1502. function zbar_image_scanner_set_config(scanner: zbar_image_scanner_t; symbology: zbar_symbol_type_t;
  1503. config: zbar_config_t; value: Integer): Integer;
  1504. var
  1505. proc: function(scanner: zbar_image_scanner_t; symbology: zbar_symbol_type_t; config: zbar_config_t; value: Integer)
  1506. : Integer; cdecl;
  1507. begin
  1508. GetAddressOf('zbar_image_scanner_set_config', @proc);
  1509. Result := proc(scanner, symbology, config, value);
  1510. end;
  1511. function zbar_image_scanner_parse_config(scanner: zbar_image_scanner_t; config_string: PAnsiChar): Integer;
  1512. var
  1513. sym: zbar_symbol_type_t;
  1514. cfg: zbar_config_t;
  1515. val: Integer;
  1516. begin
  1517. Result := zbar_parse_config(config_string, &sym, &cfg, &val) or zbar_image_scanner_set_config(scanner, sym, cfg, val);
  1518. end;
  1519. procedure zbar_image_scanner_enable_cache(scanner: zbar_image_scanner_t; enable: Integer);
  1520. var
  1521. proc: procedure(scanner: zbar_image_scanner_t; enable: Integer); cdecl;
  1522. begin
  1523. GetAddressOf('zbar_image_scanner_enable_cache', @proc);
  1524. proc(scanner, enable);
  1525. end;
  1526. function zbar_scan_image(scanner: zbar_image_scanner_t; image: zbar_image_t): Integer;
  1527. var
  1528. proc: function(scanner: zbar_image_scanner_t; image: zbar_image_t): Integer; cdecl;
  1529. begin
  1530. GetAddressOf('zbar_scan_image', @proc);
  1531. Result := proc(scanner, image);
  1532. end;
  1533. function zbar_decoder_create: zbar_decoder_t;
  1534. var
  1535. proc: function: zbar_decoder_t; cdecl;
  1536. begin
  1537. GetAddressOf('zbar_decoder_create', @proc);
  1538. Result := proc;
  1539. end;
  1540. procedure zbar_decoder_destroy(decoder: zbar_decoder_t);
  1541. var
  1542. proc: procedure(decoder: zbar_decoder_t); cdecl;
  1543. begin
  1544. GetAddressOf('zbar_decoder_destroy', @proc);
  1545. proc(decoder);
  1546. end;
  1547. function zbar_decoder_set_config(decoder: zbar_decoder_t; symbology: zbar_symbol_type_t; config: zbar_config_t;
  1548. value: Integer): Integer;
  1549. var
  1550. proc: function(decoder: zbar_decoder_t; symbology: zbar_symbol_type_t; config: zbar_config_t; value: Integer)
  1551. : Integer; cdecl;
  1552. begin
  1553. GetAddressOf('zbar_decoder_set_config', @proc);
  1554. Result := proc(decoder, symbology, config, value);
  1555. end;
  1556. function zbar_decoder_parse_config(decoder: zbar_decoder_t; config_string: PAnsiChar): Integer;
  1557. var
  1558. sym: zbar_symbol_type_t;
  1559. cfg: zbar_config_t;
  1560. val: Integer;
  1561. begin
  1562. Result := zbar_parse_config(config_string, &sym, &cfg, &val) or zbar_decoder_set_config(decoder, sym, cfg, val);
  1563. end;
  1564. procedure zbar_decoder_reset(decoder: zbar_decoder_t);
  1565. var
  1566. proc: procedure(decoder: zbar_decoder_t); cdecl;
  1567. begin
  1568. GetAddressOf('zbar_decoder_reset', @proc);
  1569. proc(decoder);
  1570. end;
  1571. procedure zbar_decoder_new_scan(decoder: zbar_decoder_t);
  1572. var
  1573. proc: procedure(decoder: zbar_decoder_t); cdecl;
  1574. begin
  1575. GetAddressOf('zbar_decoder_new_scan', @proc);
  1576. proc(decoder);
  1577. end;
  1578. function zbar_decode_width(decoder: zbar_decoder_t; width: Cardinal): zbar_symbol_type_t;
  1579. var
  1580. proc: function(decoder: zbar_decoder_t; width: Cardinal): zbar_symbol_type_t; cdecl;
  1581. begin
  1582. GetAddressOf('zbar_decode_width', @proc);
  1583. Result := proc(decoder, width);
  1584. end;
  1585. function zbar_decoder_get_color(decoder: zbar_decoder_t): zbar_color_t;
  1586. var
  1587. proc: function(decoder: zbar_decoder_t): zbar_color_t; cdecl;
  1588. begin
  1589. GetAddressOf('zbar_decoder_get_color', @proc);
  1590. Result := proc(decoder);
  1591. end;
  1592. function zbar_decoder_get_data(decoder: zbar_decoder_t): PAnsiChar;
  1593. var
  1594. proc: function(decoder: zbar_decoder_t): PAnsiChar; cdecl;
  1595. begin
  1596. GetAddressOf('zbar_decoder_get_data', @proc);
  1597. Result := proc(decoder);
  1598. end;
  1599. function zbar_decoder_get_type(decoder: zbar_decoder_t): zbar_symbol_type_t;
  1600. var
  1601. proc: function(decoder: zbar_decoder_t): zbar_symbol_type_t; cdecl;
  1602. begin
  1603. GetAddressOf('zbar_decoder_get_type', @proc);
  1604. Result := proc(decoder);
  1605. end;
  1606. function zbar_decoder_set_handler(decoder: zbar_decoder_t; handler: zbar_decoder_handler_t): zbar_decoder_handler_t;
  1607. var
  1608. proc: function(decoder: zbar_decoder_t; handler: zbar_decoder_handler_t): zbar_decoder_handler_t; cdecl;
  1609. begin
  1610. GetAddressOf('zbar_decoder_set_handler', @proc);
  1611. Result := proc(decoder, handler);
  1612. end;
  1613. procedure zbar_decoder_set_userdata(decoder: zbar_decoder_t; userdata: Pointer);
  1614. var
  1615. proc: procedure(decoder: zbar_decoder_t; userdata: Pointer); cdecl;
  1616. begin
  1617. GetAddressOf('zbar_decoder_set_userdata', @proc);
  1618. proc(decoder, userdata);
  1619. end;
  1620. function zbar_decoder_get_userdata(decoder: zbar_decoder_t): Pointer;
  1621. var
  1622. proc: function(decoder: zbar_decoder_t): Pointer; cdecl;
  1623. begin
  1624. GetAddressOf('zbar_decoder_get_userdata', @proc);
  1625. Result := proc(decoder);
  1626. end;
  1627. function zbar_scanner_create(decoder: zbar_decoder_t): zbar_scanner_t;
  1628. var
  1629. proc: function(decoder: zbar_decoder_t): zbar_scanner_t; cdecl;
  1630. begin
  1631. GetAddressOf('zbar_scanner_create', @proc);
  1632. Result := proc(decoder);
  1633. end;
  1634. procedure zbar_scanner_destroy(scanner: zbar_scanner_t);
  1635. var
  1636. proc: procedure(scanner: zbar_scanner_t); cdecl;
  1637. begin
  1638. GetAddressOf('zbar_scanner_destroy', @proc);
  1639. proc(scanner);
  1640. end;
  1641. function zbar_scanner_reset(scanner: zbar_scanner_t): zbar_symbol_type_t;
  1642. var
  1643. proc: function(scanner: zbar_scanner_t): zbar_symbol_type_t; cdecl;
  1644. begin
  1645. GetAddressOf('zbar_scanner_reset', @proc);
  1646. Result := proc(scanner);
  1647. end;
  1648. function zbar_scanner_new_scan(scanner: zbar_scanner_t): zbar_symbol_type_t;
  1649. var
  1650. proc: function(scanner: zbar_scanner_t): zbar_symbol_type_t; cdecl;
  1651. begin
  1652. GetAddressOf('zbar_scanner_new_scan', @proc);
  1653. Result := proc(scanner);
  1654. end;
  1655. function zbar_scan_y(scanner: zbar_scanner_t; y: Integer): zbar_symbol_type_t;
  1656. var
  1657. proc: function(scanner: zbar_scanner_t; y: Integer): zbar_symbol_type_t; cdecl;
  1658. begin
  1659. GetAddressOf('zbar_scan_y', @proc);
  1660. Result := proc(scanner, y);
  1661. end;
  1662. function zbar_scan_rgb24(scanner: zbar_scanner_t; rgb: PAnsiChar): zbar_symbol_type_t;
  1663. begin
  1664. Result := zbar_scan_y(scanner, Ord(rgb^) + Ord((rgb + 1)^) + Ord((rgb + 2)^));
  1665. end;
  1666. function zbar_scanner_get_width(scanner: zbar_scanner_t): Cardinal;
  1667. var
  1668. proc: function(scanner: zbar_scanner_t): Cardinal; cdecl;
  1669. begin
  1670. GetAddressOf('zbar_scanner_get_width', @proc);
  1671. Result := proc(scanner);
  1672. end;
  1673. function zbar_scanner_get_color(scanner: zbar_scanner_t): zbar_color_t;
  1674. var
  1675. proc: function(scanner: zbar_scanner_t): zbar_color_t; cdecl;
  1676. begin
  1677. GetAddressOf('zbar_scanner_get_color', @proc);
  1678. Result := proc(scanner);
  1679. end;
  1680. initialization
  1681. DllHandle := LoadLibrary('libzbar-0.dll');
  1682. // if DllHandle = 0 then
  1683. //RaiseLastOSError;
  1684. finalization
  1685. if (DllHandle <> 0) then
  1686. FreeLibrary(DllHandle);
  1687. end.