PageRenderTime 85ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 2ms

/zbar_update_to_617889f8f73.patch

#
Patch | 12235 lines | 12142 code | 93 blank | 0 comment | 0 complexity | bec7532f513f4040726f95b8d12b2056 MD5 | raw file
Possible License(s): LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. diff --git a/COPYING b/COPYING
  2. --- a/COPYING
  3. +++ b/COPYING
  4. @@ -1,4 +1,4 @@
  5. -The ZBar Bar Code Reader is Copyright (C) 2007-2009 Jeff Brown
  6. +The ZBar Bar Code Reader is Copyright (C) 2007-2010 Jeff Brown
  7. <spadix@users.sourceforge.net>
  8. The QR Code reader is Copyright (C) 1999-2009 Timothy B. Terriberry
  9. <tterribe@xiph.org>
  10. diff --git a/Makefile.am b/Makefile.am
  11. --- a/Makefile.am
  12. +++ b/Makefile.am
  13. @@ -1,6 +1,3 @@
  14. -AM_CPPFLAGS = -I$(srcdir)/include
  15. -AM_CFLAGS = -Wall -Wno-parentheses
  16. -AM_CXXFLAGS = $(AM_CFLAGS)
  17. ACLOCAL_AMFLAGS = -I config
  18. bin_PROGRAMS =
  19. check_PROGRAMS =
  20. @@ -9,8 +6,10 @@ lib_LTLIBRARIES =
  21. pyexec_LTLIBRARIES =
  22. CLEANFILES =
  23. DISTCLEANFILES =
  24. +MAINTAINERCLEANFILES =
  25. BUILT_SOURCES =
  26. EXTRA_DIST =
  27. +SUBDIRS = .
  28. pkgconfigdir = $(libdir)/pkgconfig
  29. pkgconfig_DATA = zbar.pc
  30. @@ -39,6 +38,9 @@ if HAVE_QT
  31. include $(srcdir)/qt/Makefile.am.inc
  32. pkgconfig_DATA += zbar-qt.pc
  33. endif
  34. +if HAVE_JAVA
  35. +SUBDIRS += java
  36. +endif
  37. if HAVE_NPAPI
  38. include $(srcdir)/plugin/Makefile.am.inc
  39. endif
  40. @@ -47,11 +49,8 @@ include $(srcdir)/doc/Makefile.am.inc
  41. EXTRA_DIST += zbar.ico zbar.nsi
  42. -EXTRA_DIST += examples/upcrpc.pl examples/upcrpc.py examples/paginate.pl \
  43. - examples/barcode.png examples/processor.pl examples/processor.py \
  44. - examples/read_one.py examples/read_one.pl \
  45. - examples/scan_image.c examples/scan_image.cpp examples/scan_image.pl \
  46. - examples/scan_image.py examples/scan_image.vcproj
  47. +EXTRA_DIST += examples/barcode.png examples/upcrpc.py examples/upcrpc.pl \
  48. + examples/scan_image.c examples/scan_image.cpp examples/scan_image.vcproj
  49. EXTRA_DIST += perl/MANIFEST perl/README perl/Changes perl/COPYING.LIB \
  50. perl/Makefile.PL perl/typemap perl/ZBar.xs perl/ppport.h \
  51. diff --git a/configure.ac b/configure.ac
  52. --- a/configure.ac
  53. +++ b/configure.ac
  54. @@ -46,6 +46,13 @@ AC_DEFINE_UNQUOTED([LIB_VERSION_REVISION
  55. [[`echo "$LIB_VERSION" | sed -e 's/^[^:]*:\([^:]*\):.*$/\1/'`]],
  56. [Library revision])
  57. +AM_CPPFLAGS="-I$srcdir/include"
  58. +AM_CFLAGS="-Wall -Wno-parentheses"
  59. +AM_CXXFLAGS="$AM_CFLAGS"
  60. +AC_SUBST([AM_CPPFLAGS])
  61. +AC_SUBST([AM_CFLAGS])
  62. +AC_SUBST([AM_CXXFLAGS])
  63. +
  64. dnl windows build
  65. AC_CANONICAL_HOST
  66. @@ -73,13 +80,36 @@ documentation generation])
  67. AC_ARG_VAR([XMLTOFLAGS], [additional arguments for xmlto])
  68. AC_CHECK_PROGS([XMLTO], [xmlto], [:])
  69. +have_java="maybe"
  70. +AC_ARG_VAR([JAVA_HOME], [root location of JDK])
  71. +AS_IF([test "x$JAVA_HOME" = "x"],
  72. + [JAVA_PATH="$PATH"],
  73. + [JAVA_PATH="$JAVA_HOME/bin$PATH_SEPARATOR$PATH"])
  74. +
  75. +AC_ARG_VAR([JAVAC], [location of Java language compiler])
  76. +AC_PATH_PROGS([JAVAC], [javac jikes ecj gcj], [:], [$JAVA_PATH])
  77. +AS_IF([test "x$JAVAC" = "x:"], [have_java="no"])
  78. +
  79. +AC_ARG_VAR([JAVAH], [location of Java header generator])
  80. +AC_PATH_PROGS([JAVAH], [javah], [/bin/false], [$JAVA_PATH])
  81. +
  82. +AC_ARG_VAR([JAR], [location of Java archive tool])
  83. +AC_PATH_PROGS([JAR], [jar], [:], [$JAVA_PATH])
  84. +AS_IF([test "x$JAR" = "x:"], [have_java="no"])
  85. +
  86. +AC_ARG_VAR([JAVA], [location of Java application launcher])
  87. +AC_PATH_PROGS([JAVA], [java], [/bin/false], [$JAVA_PATH])
  88. +
  89. +AC_ARG_VAR([CLASSPATH], [Java class path (include JUnit to run java tests)])
  90. +AS_IF([test "x$CLASSPATH" = "x"], [CLASSPATH="."])
  91. +
  92. dnl symbologies
  93. AC_ARG_ENABLE([codes],
  94. [AS_HELP_STRING([--enable-codes=SYMS],
  95. - [select symbologies to compile [default=ean,i25,code39,code128,qrcode]])],
  96. + [select symbologies to compile [default=ean,databar,code128,code93,code39,i25,qrcode]])],
  97. [],
  98. - [enable_codes="ean,code39,code128,i25,qrcode"]) dnl pdf417
  99. + [enable_codes="ean,databar,code128,code93,code39,i25,qrcode"])
  100. AC_DEFUN([ZBAR_CHK_CODE], [
  101. AC_MSG_CHECKING([whether to build $2])
  102. @@ -97,11 +127,13 @@ AC_DEFUN([ZBAR_CHK_CODE], [
  103. ])dnl
  104. ZBAR_CHK_CODE([ean], [EAN symbologies])
  105. +ZBAR_CHK_CODE([databar], [DataBar symbology])
  106. ZBAR_CHK_CODE([code128], [Code 128 symbology])
  107. +ZBAR_CHK_CODE([code93], [Code 93 symbology])
  108. ZBAR_CHK_CODE([code39], [Code 39 symbology])
  109. -ZBAR_CHK_CODE([pdf417], [PDF417 symbology])
  110. ZBAR_CHK_CODE([i25], [Interleaved 2 of 5 symbology])
  111. ZBAR_CHK_CODE([qrcode], [QR Code])
  112. +ZBAR_CHK_CODE([pdf417], [PDF417 symbology])
  113. dnl libraries
  114. @@ -255,7 +287,7 @@ AM_CONDITIONAL([HAVE_JPEG], [test "x$wit
  115. dnl ImageMagick
  116. AC_ARG_WITH([imagemagick],
  117. [AS_HELP_STRING([--without-imagemagick],
  118. - [disable support for scanning images using ImageMagick])],
  119. + [disable support for scanning images with ImageMagick])],
  120. [],
  121. [with_imagemagick="yes"])
  122. @@ -296,7 +328,7 @@ AM_CONDITIONAL([HAVE_MAGICK], [test "x$w
  123. dnl Mozilla NPAPI
  124. AC_ARG_WITH([npapi],
  125. [AS_HELP_STRING([--with-npapi],
  126. - [enable support for Firefox/Mozilla/OpenOffice NPAPI plugin])],
  127. + [enable support for Firefox/Mozilla/OpenOffice plugin])],
  128. [],
  129. [with_npapi="no"])
  130. @@ -383,13 +415,38 @@ AS_IF([test "x$with_qt" != "xno"],
  131. AM_CONDITIONAL([HAVE_QT], [test "x$with_qt" = "xyes"])
  132. +dnl Java
  133. +AC_ARG_WITH([java],
  134. + [AS_HELP_STRING([--without-java],
  135. + [disable support for Java interface])],
  136. + [],
  137. + [with_java="check"])
  138. +
  139. +AC_ARG_VAR([JAVA_CFLAGS], [compiler flags for building JNI extensions])
  140. +AS_IF([test "x$JAVA_CFLAGS" = "x" && test "x$JAVA_HOME" != "x"],
  141. + [JAVA_CFLAGS="-I$JAVA_HOME/include"])
  142. +
  143. +AS_IF([test "x$with_java" != "xno"],
  144. + [CPPFLAGS_save="$CPPFLAGS"
  145. + CPPFLAGS="$CPPFLAGS $JAVA_CFLAGS"
  146. + AC_CHECK_HEADER([jni.h], [], [have_java="no"])
  147. + CPPFLAGS="$CPPFLAGS_save"
  148. + AS_IF([test "x$have_java" != "xno"],
  149. + [with_java="yes"],
  150. + [test "x$with_java" = "xyes"],
  151. + [AC_MSG_FAILURE([unable to find Java JNI! ensure CFLAGS are set
  152. +appropriately or configure --without-java])],
  153. + [with_java="no"])
  154. +])
  155. +AM_CONDITIONAL([HAVE_JAVA], [test "x$with_java" = "xyes"])
  156. +
  157. dnl header files
  158. dnl FIXME switches for shm, mmap
  159. AC_HEADER_ASSERT
  160. -AC_CHECK_HEADERS([fcntl.h features.h inttypes.h stdlib.h string.h unistd.h \
  161. - sys/ioctl.h sys/time.h sys/times.h sys/ipc.h sys/shm.h sys/mman.h])
  162. +AC_CHECK_HEADERS([errno.h fcntl.h features.h inttypes.h stdlib.h string.h \
  163. + unistd.h sys/ioctl.h sys/time.h sys/times.h sys/ipc.h sys/shm.h sys/mman.h])
  164. dnl types
  165. @@ -428,6 +485,7 @@ AC_CONFIG_COMMANDS([doc/reldate.xml],
  166. AC_CONFIG_FILES([
  167. Makefile
  168. +java/Makefile
  169. zbar.pc
  170. zbar-gtk.pc
  171. zbar-qt.pc
  172. @@ -460,6 +518,9 @@ AS_IF([test "x$with_gtk" != "xyes"],
  173. echo "Qt4 --with-qt=$with_qt"
  174. AS_IF([test "x$with_qt" != "xyes"],
  175. [echo " => the Qt4 widget will *NOT* be built"])
  176. +echo "Java --with-java=$with_java"
  177. +AS_IF([test "x$with_java" != "xyes"],
  178. + [echo " => the Java interface will *NOT* be built"])
  179. #echo "NPAPI Plugin --with-npapi=$with_npapi"
  180. #AS_IF([test "x$with_mozilla" != "xyes"],
  181. # [echo " => the Mozilla/Firefox/OpenOffice plugin will *NOT* be built"])
  182. diff --git a/doc/Makefile.am.inc b/doc/Makefile.am.inc
  183. --- a/doc/Makefile.am.inc
  184. +++ b/doc/Makefile.am.inc
  185. @@ -2,6 +2,7 @@
  186. DOCSOURCES = doc/manual.xml doc/version.xml doc/reldate.xml \
  187. doc/ref/zbarimg.xml doc/ref/zbarcam.xml doc/ref/commonoptions.xml
  188. +MAINTAINERCLEANFILES += doc/man/man.stamp doc/version.xml doc/reldate.xml
  189. # man page targets to distribute and install
  190. dist_man_MANS =
  191. diff --git a/doc/api/footer.html b/doc/api/footer.html
  192. --- a/doc/api/footer.html
  193. +++ b/doc/api/footer.html
  194. @@ -9,9 +9,12 @@
  195. <address><a href="mailto:spadix@users.sourceforge.net">spadix@users.sourceforge.net</a></address>
  196. -<p>Copyright 2008-2009 (c) Jeff Brown - All Rights Reserved.</p>
  197. -<p>Verbatim copying and distribution of this entire article are
  198. - permitted worldwide, without royalty, in any medium, provided this
  199. - notice, and the copyright notice, are preserved.</p>
  200. +<p>Copyright 2008-2010 (c) Jeff Brown</p>
  201. +<p>This documentation is part of the ZBar Barcode Reader; you can
  202. +redistribute it and/or modify it under the terms of the
  203. +<a href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">GNU
  204. +Lesser General Public License</a> as published by the Free Software
  205. +Foundation; either version 2.1 of the License, or (at your option) any
  206. +later version.</p>
  207. </body></html>
  208. diff --git a/doc/manual.xml b/doc/manual.xml
  209. --- a/doc/manual.xml
  210. +++ b/doc/manual.xml
  211. @@ -29,10 +29,10 @@
  212. <year>2007</year>
  213. <year>2008</year>
  214. <year>2009</year>
  215. + <year>2010</year>
  216. <holder>Jeff Brown</holder>
  217. </copyright>
  218. <legalnotice><para>All Rights Reserved</para></legalnotice>
  219. - <!-- <legalnotice><para>insert GNU FDL header?</para></legalnotice> -->
  220. </bookinfo>
  221. <chapter id="intro">
  222. @@ -47,7 +47,4 @@
  223. &refzbarimg;
  224. </reference>
  225. -
  226. - <!-- insert GNU FDL? -->
  227. -
  228. </book>
  229. diff --git a/doc/ref/commonoptions.xml b/doc/ref/commonoptions.xml
  230. --- a/doc/ref/commonoptions.xml
  231. +++ b/doc/ref/commonoptions.xml
  232. @@ -47,8 +47,9 @@
  233. <option>ean13</option>, <option>ean8</option>,
  234. <option>upca</option>, <option>upce</option>,
  235. <option>isbn13</option>, <option>isbn10</option>,
  236. - <option>i25</option>, <option>code39</option>,
  237. - <option>code128</option> or the special value <option>*</option>.
  238. + <option>i25</option>, <option>code39</option>, <option>code93</option>,
  239. + <option>code128</option>, <option>qrcode</option>
  240. + or the special value <option>*</option>.
  241. If <replaceable class="parameter">symbology</replaceable> is
  242. omitted or <option>*</option>, the <replaceable
  243. class="parameter">config</replaceable> will be set for all
  244. diff --git a/doc/ref/zbarcam.xml b/doc/ref/zbarcam.xml
  245. --- a/doc/ref/zbarcam.xml
  246. +++ b/doc/ref/zbarcam.xml
  247. @@ -60,9 +60,10 @@
  248. <filename>/dev/video0</filename></para>
  249. <para>The underlying library currently supports EAN-13 (including
  250. - UPC and ISBN subsets), EAN-8, Code 128, Code 39, and Interleaved
  251. - 2 of 5 symbologies. The specific type of each detected symbol is
  252. - printed with the decoded data.</para>
  253. + UPC and ISBN subsets), EAN-8, DataBar, DataBar Expanded, Code 128,
  254. + Code 93, Code 39, Interleaved 2 of 5 and QR Code symbologies. The
  255. + specific type of each detected symbol is printed with the decoded
  256. + data.</para>
  257. </refsection>
  258. @@ -160,6 +161,37 @@
  259. </refsection>
  260. <refsection>
  261. + <title>Exit Status</title>
  262. +
  263. + <para><command>zbarcam</command> returns an exit code to indicate the
  264. + status of the program execution. Current exit codes are:</para>
  265. +
  266. + <variablelist>
  267. + <varlistentry>
  268. + <term>0</term>
  269. + <listitem>
  270. + <para>Successful program completion.</para>
  271. + </listitem>
  272. + </varlistentry>
  273. +
  274. + <varlistentry>
  275. + <term>1</term>
  276. + <listitem>
  277. + <para>An error occurred. This includes bad arguments and I/O
  278. + errors.</para>
  279. + </listitem>
  280. + </varlistentry>
  281. +
  282. + <varlistentry>
  283. + <term>2</term>
  284. + <listitem>
  285. + <para>A fatal error occurred.</para>
  286. + </listitem>
  287. + </varlistentry>
  288. + </variablelist>
  289. + </refsection>
  290. +
  291. + <refsection>
  292. <title>See Also</title>
  293. <para><xref linkend="zbarimg"/></para>
  294. <para><link xlink:href="http://zbar.sf.net/"/></para>
  295. diff --git a/doc/ref/zbarimg.xml b/doc/ref/zbarimg.xml
  296. --- a/doc/ref/zbarimg.xml
  297. +++ b/doc/ref/zbarimg.xml
  298. @@ -59,9 +59,10 @@
  299. displayed to the screen.</para>
  300. <para>The underlying library currently supports EAN-13 (including
  301. - UPC and ISBN subsets), EAN-8, Code 128, Code 39, and Interleaved
  302. - 2 of 5 symbologies. The specific type of each detected symbol is
  303. - printed with the decoded data.</para>
  304. + UPC and ISBN subsets), EAN-8, DataBar, DataBar Expanded, Code 128,
  305. + Code 93, Code 39, Interleaved 2 of 5 and QR Code symbologies. The
  306. + specific type of each detected symbol is printed with the decoded
  307. + data.</para>
  308. <para>Note that "<filename><replaceable>image</replaceable></filename>"
  309. @@ -166,6 +167,56 @@
  310. </refsection>
  311. <refsection>
  312. + <title>Exit Status</title>
  313. +
  314. + <para><command>zbarimg</command> returns an exit code to indicate the
  315. + status of the program execution. Current exit codes are:</para>
  316. +
  317. + <variablelist>
  318. + <varlistentry>
  319. + <term>0</term>
  320. + <listitem>
  321. + <para>Barcodes successfully detected in all images. Warnings may
  322. + have been generated, but no errors.</para>
  323. + </listitem>
  324. + </varlistentry>
  325. +
  326. + <varlistentry>
  327. + <term>1</term>
  328. + <listitem>
  329. + <para>An error occurred while processing some image(s). This
  330. + includes bad arguments, I/O errors and image handling errors from
  331. + ImageMagick.</para>
  332. + </listitem>
  333. + </varlistentry>
  334. +
  335. + <varlistentry>
  336. + <term>2</term>
  337. + <listitem>
  338. + <para>ImageMagick fatal error.</para>
  339. + </listitem>
  340. + </varlistentry>
  341. +
  342. + <varlistentry>
  343. + <term>3</term>
  344. + <listitem>
  345. + <para>The user quit the program before all images were scanned.
  346. + Only applies when running in interactive mode
  347. + (with <option>--display</option>)</para>
  348. + </listitem>
  349. + </varlistentry>
  350. +
  351. + <varlistentry>
  352. + <term>4</term>
  353. + <listitem>
  354. + <para>No barcode was detected in one or more of the images. No
  355. + other errors occurred.</para>
  356. + </listitem>
  357. + </varlistentry>
  358. + </variablelist>
  359. + </refsection>
  360. +
  361. + <refsection>
  362. <title>See Also</title>
  363. <para><xref linkend="zbarcam"/></para>
  364. <para><link xlink:href="http://zbar.sf.net/"/></para>
  365. diff --git a/examples/paginate.pl b/examples/paginate.pl
  366. deleted file mode 100755
  367. --- a/examples/paginate.pl
  368. +++ /dev/null
  369. @@ -1,71 +0,0 @@
  370. -#!/usr/bin/perl
  371. -#------------------------------------------------------------------------
  372. -# Copyright 2009 (c) Jeff Brown <spadix@users.sourceforge.net>
  373. -#
  374. -# This file is part of the ZBar Bar Code Reader.
  375. -#
  376. -# The ZBar Bar Code Reader is free software; you can redistribute it
  377. -# and/or modify it under the terms of the GNU Lesser Public License as
  378. -# published by the Free Software Foundation; either version 2.1 of
  379. -# the License, or (at your option) any later version.
  380. -#
  381. -# The ZBar Bar Code Reader is distributed in the hope that it will be
  382. -# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  383. -# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  384. -# GNU Lesser Public License for more details.
  385. -#
  386. -# You should have received a copy of the GNU Lesser Public License
  387. -# along with the ZBar Bar Code Reader; if not, write to the Free
  388. -# Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  389. -# Boston, MA 02110-1301 USA
  390. -#
  391. -# http://sourceforge.net/projects/zbar
  392. -#------------------------------------------------------------------------
  393. -use warnings;
  394. -use strict;
  395. -
  396. -use Barcode::ZBar;
  397. -use Image::Magick;
  398. -
  399. -warn("no input files specified?\n") if(!@ARGV);
  400. -
  401. -# running output document
  402. -my $out = undef;
  403. -
  404. -# barcode scanner
  405. -my $scanner = Barcode::ZBar::ImageScanner->new();
  406. -
  407. -foreach my $file (@ARGV) {
  408. - print "scanning from \"$file\"\n";
  409. - my $imseq = Image::Magick->new();
  410. - my $err = $imseq->Read($file);
  411. - warn($err) if($err);
  412. -
  413. - foreach my $page (@$imseq) {
  414. - # convert ImageMagick page to ZBar image
  415. - my $zimg = Barcode::ZBar::Image->new();
  416. - $zimg->set_format('Y800');
  417. - $zimg->set_size($page->Get(qw(columns rows)));
  418. - $zimg->set_data($page->Clone()->ImageToBlob(magick => 'GRAY', depth => 8));
  419. -
  420. - # scan for barcodes
  421. - if($scanner->scan_image($zimg)) {
  422. - # write out previous document
  423. - $out->write() if($out);
  424. -
  425. - # use first symbol found to name next image (FIXME sanitize)
  426. - my $data = ($zimg->get_symbols())[0]->get_data();
  427. - my $idx = $page->Get('scene') + 1;
  428. - print "splitting $data from page $idx\n";
  429. -
  430. - # create new output document
  431. - $out = Image::Magick->new(filename => $data);
  432. - }
  433. -
  434. - # append this page to current output
  435. - push(@$out, $page) if($out);
  436. - }
  437. -
  438. - # write out final document
  439. - $out->write() if($out);
  440. -}
  441. diff --git a/examples/processor.c b/examples/processor.c
  442. new file mode 100644
  443. --- /dev/null
  444. +++ b/examples/processor.c
  445. @@ -0,0 +1,47 @@
  446. +#include <stdio.h>
  447. +#include <zbar.h>
  448. +
  449. +static void my_handler (zbar_image_t *image,
  450. + const void *userdata)
  451. +{
  452. + /* extract results */
  453. + const zbar_symbol_t *symbol = zbar_image_first_symbol(image);
  454. + for(; symbol; symbol = zbar_symbol_next(symbol)) {
  455. + /* do something useful with results */
  456. + zbar_symbol_type_t typ = zbar_symbol_get_type(symbol);
  457. + const char *data = zbar_symbol_get_data(symbol);
  458. + printf("decoded %s symbol \"%s\"\n",
  459. + zbar_get_symbol_name(typ), data);
  460. + }
  461. +}
  462. +
  463. +int main (int argc, char **argv)
  464. +{
  465. + const char *device = "/dev/video0";
  466. +
  467. + /* create a Processor */
  468. + zbar_processor_t *proc = zbar_processor_create(1);
  469. +
  470. + /* configure the Processor */
  471. + zbar_processor_set_config(proc, 0, ZBAR_CFG_ENABLE, 1);
  472. +
  473. + /* initialize the Processor */
  474. + if(argc > 1)
  475. + device = argv[1];
  476. + zbar_processor_init(proc, device, 1);
  477. +
  478. + /* setup a callback */
  479. + zbar_processor_set_data_handler(proc, my_handler, NULL);
  480. +
  481. + /* enable the preview window */
  482. + zbar_processor_set_visible(proc, 1);
  483. + zbar_processor_set_active(proc, 1);
  484. +
  485. + /* keep scanning until user provides key/mouse input */
  486. + zbar_processor_user_wait(proc, -1);
  487. +
  488. + /* clean up */
  489. + zbar_processor_destroy(proc);
  490. +
  491. + return(0);
  492. +}
  493. diff --git a/examples/processor.cpp b/examples/processor.cpp
  494. new file mode 100644
  495. --- /dev/null
  496. +++ b/examples/processor.cpp
  497. @@ -0,0 +1,45 @@
  498. +#include <iostream>
  499. +#include <zbar.h>
  500. +
  501. +using namespace std;
  502. +using namespace zbar;
  503. +
  504. +class MyHandler : public Image::Handler
  505. +{
  506. + void image_callback (Image &image)
  507. + {
  508. + for(SymbolIterator symbol = image.symbol_begin();
  509. + symbol != image.symbol_end();
  510. + ++symbol)
  511. + cout << "decoded " << symbol->get_type_name() << " symbol "
  512. + << "\"" << symbol->get_data() << "\"" << endl;
  513. + }
  514. +};
  515. +
  516. +int main (int argc, char **argv)
  517. +{
  518. + // create and initialize a Processor
  519. + const char *device = "/dev/video0";
  520. + if(argc > 1)
  521. + device = argv[1];
  522. + Processor proc(true, device);
  523. +
  524. + // configure the Processor
  525. + proc.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);
  526. +
  527. + // setup a callback
  528. + MyHandler my_handler;
  529. + proc.set_handler(my_handler);
  530. +
  531. + // enable the preview window
  532. + proc.set_visible();
  533. + proc.set_active();
  534. +
  535. + try {
  536. + // keep scanning until user provides key/mouse input
  537. + proc.user_wait();
  538. + }
  539. + catch(ClosedError &e) {
  540. + }
  541. + return(0);
  542. +}
  543. diff --git a/examples/processor.pl b/examples/processor.pl
  544. deleted file mode 100755
  545. --- a/examples/processor.pl
  546. +++ /dev/null
  547. @@ -1,35 +0,0 @@
  548. -#!/usr/bin/env perl
  549. -use warnings;
  550. -use strict;
  551. -require Barcode::ZBar;
  552. -
  553. -# create a Processor
  554. -my $proc = Barcode::ZBar::Processor->new();
  555. -
  556. -# configure the Processor
  557. -$proc->parse_config("enable");
  558. -
  559. -# initialize the Processor
  560. -$proc->init($ARGV[0] || '/dev/video0');
  561. -
  562. -# setup a callback
  563. -sub my_handler {
  564. - my ($proc, $image, $closure) = @_;
  565. -
  566. - # extract results
  567. - foreach my $symbol ($proc->get_results()) {
  568. - # do something useful with results
  569. - print('decoded ' . $symbol->get_type() .
  570. - ' symbol "' . $symbol->get_data() . "\"\n");
  571. - }
  572. -}
  573. -$proc->set_data_handler(\&my_handler);
  574. -
  575. -# enable the preview window
  576. -$proc->set_visible();
  577. -
  578. -# initiate scanning
  579. -$proc->set_active();
  580. -
  581. -# keep scanning until user provides key/mouse input
  582. -$proc->user_wait();
  583. diff --git a/examples/read_one.pl b/examples/read_one.pl
  584. deleted file mode 100755
  585. --- a/examples/read_one.pl
  586. +++ /dev/null
  587. @@ -1,29 +0,0 @@
  588. -#!/usr/bin/env perl
  589. -use warnings;
  590. -use strict;
  591. -require Barcode::ZBar;
  592. -
  593. -# create a Processor
  594. -my $proc = Barcode::ZBar::Processor->new();
  595. -
  596. -# configure the Processor
  597. -$proc->parse_config("enable");
  598. -
  599. -# initialize the Processor
  600. -$proc->init($ARGV[0] || '/dev/video0');
  601. -
  602. -# enable the preview window
  603. -$proc->set_visible();
  604. -
  605. -# read at least one barcode (or until window closed)
  606. -$proc->process_one();
  607. -
  608. -# hide the preview window
  609. -$proc->set_visible(0);
  610. -
  611. -# extract results
  612. -foreach my $symbol ($proc->get_results()) {
  613. - # do something useful with results
  614. - print('decoded ' . $symbol->get_type() .
  615. - ' symbol "' . $symbol->get_data() . "\"\n");
  616. -}
  617. diff --git a/examples/scan_image.c b/examples/scan_image.c
  618. --- a/examples/scan_image.c
  619. +++ b/examples/scan_image.c
  620. @@ -65,7 +65,7 @@ int main (int argc, char **argv)
  621. /* wrap image data */
  622. zbar_image_t *image = zbar_image_create();
  623. - zbar_image_set_format(image, *(int*)"Y800");
  624. + zbar_image_set_format(image, zbar_fourcc('Y','8','0','0'));
  625. zbar_image_set_size(image, width, height);
  626. zbar_image_set_data(image, raw, width * height, zbar_image_free_data);
  627. diff --git a/examples/scan_image.pl b/examples/scan_image.pl
  628. deleted file mode 100755
  629. --- a/examples/scan_image.pl
  630. +++ /dev/null
  631. @@ -1,37 +0,0 @@
  632. -#!/usr/bin/perl
  633. -use warnings;
  634. -use strict;
  635. -require Image::Magick;
  636. -require Barcode::ZBar;
  637. -
  638. -$ARGV[0] || die;
  639. -
  640. -# create a reader
  641. -my $scanner = Barcode::ZBar::ImageScanner->new();
  642. -
  643. -# configure the reader
  644. -$scanner->parse_config("enable");
  645. -
  646. -# obtain image data
  647. -my $magick = Image::Magick->new();
  648. -$magick->Read($ARGV[0]) && die;
  649. -my $raw = $magick->ImageToBlob(magick => 'GRAY', depth => 8);
  650. -
  651. -# wrap image data
  652. -my $image = Barcode::ZBar::Image->new();
  653. -$image->set_format('Y800');
  654. -$image->set_size($magick->Get(qw(columns rows)));
  655. -$image->set_data($raw);
  656. -
  657. -# scan the image for barcodes
  658. -my $n = $scanner->scan_image($image);
  659. -
  660. -# extract results
  661. -foreach my $symbol ($image->get_symbols()) {
  662. - # do something useful with results
  663. - print('decoded ' . $symbol->get_type() .
  664. - ' symbol "' . $symbol->get_data() . "\"\n");
  665. -}
  666. -
  667. -# clean up
  668. -undef($image);
  669. diff --git a/examples/upcrpc.pl b/examples/upcrpc.pl
  670. --- a/examples/upcrpc.pl
  671. +++ b/examples/upcrpc.pl
  672. @@ -3,7 +3,7 @@ use warnings;
  673. use strict;
  674. use Frontier::Client;
  675. use Data::Dumper;
  676. -my $s = Frontier::Client->new('url' => 'http://dev.upcdatabase.com/rpc');
  677. +my $s = Frontier::Client->new('url' => 'http://www.upcdatabase.com/rpc');
  678. $| = 1; # autoflush
  679. diff --git a/examples/upcrpc.py b/examples/upcrpc.py
  680. --- a/examples/upcrpc.py
  681. +++ b/examples/upcrpc.py
  682. @@ -2,7 +2,7 @@
  683. from xmlrpclib import ServerProxy
  684. import sys, re
  685. -server = ServerProxy("http://dev.upcdatabase.com/rpc")
  686. +server = ServerProxy("http://www.upcdatabase.com/rpc")
  687. ean_re = re.compile(r'^(UPC-A:|EAN-13:)?(\d{11,13})$', re.M)
  688. def lookup(decode):
  689. diff --git a/gtk/zbargtk.c b/gtk/zbargtk.c
  690. --- a/gtk/zbargtk.c
  691. +++ b/gtk/zbargtk.c
  692. @@ -1,5 +1,5 @@
  693. /*------------------------------------------------------------------------
  694. - * Copyright 2008-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
  695. + * Copyright 2008-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
  696. *
  697. * This file is part of the ZBar Bar Code Reader.
  698. *
  699. @@ -35,11 +35,6 @@
  700. #define DEFAULT_WIDTH 640
  701. #define DEFAULT_HEIGHT 480
  702. -/* adapted from v4l2 spec */
  703. -#define fourcc(a, b, c, d) \
  704. - ((long)(a) | ((long)(b) << 8) | \
  705. - ((long)(c) << 16) | ((long)(d) << 24))
  706. -
  707. enum {
  708. DECODED,
  709. DECODED_TEXT,
  710. @@ -88,15 +83,15 @@ gboolean zbar_gtk_image_from_pixbuf (zba
  711. /* these are all guesses... */
  712. if(nchannels == 3 && bps == 8)
  713. - type = fourcc('R','G','B','3');
  714. + type = zbar_fourcc('R','G','B','3');
  715. else if(nchannels == 4 && bps == 8)
  716. - type = fourcc('B','G','R','4'); /* FIXME alpha flipped?! */
  717. + type = zbar_fourcc('B','G','R','4'); /* FIXME alpha flipped?! */
  718. else if(nchannels == 1 && bps == 8)
  719. - type = fourcc('Y','8','0','0');
  720. + type = zbar_fourcc('Y','8','0','0');
  721. else if(nchannels == 3 && bps == 5)
  722. - type = fourcc('R','G','B','R');
  723. + type = zbar_fourcc('R','G','B','R');
  724. else if(nchannels == 3 && bps == 4)
  725. - type = fourcc('R','4','4','4'); /* FIXME maybe? */
  726. + type = zbar_fourcc('R','4','4','4'); /* FIXME maybe? */
  727. else {
  728. g_warning("unsupported combination: nchannels=%d bps=%d\n",
  729. nchannels, bps);
  730. @@ -142,10 +137,6 @@ static inline gboolean zbar_gtk_video_op
  731. gdk_threads_enter();
  732. - zbar->req_width = DEFAULT_WIDTH;
  733. - zbar->req_height = DEFAULT_HEIGHT;
  734. - gtk_widget_queue_resize(GTK_WIDGET(self));
  735. -
  736. zbar->video_opened = FALSE;
  737. if(zbar->thread)
  738. g_object_notify(G_OBJECT(self), "video-opened");
  739. @@ -184,6 +175,10 @@ static inline gboolean zbar_gtk_video_op
  740. */
  741. gdk_threads_enter();
  742. + if(zbar->video_width && zbar->video_height)
  743. + zbar_video_request_size(zbar->video,
  744. + zbar->video_width, zbar->video_height);
  745. +
  746. video_opened = !zbar_negotiate_format(zbar->video, zbar->window);
  747. if(video_opened) {
  748. @@ -209,7 +204,7 @@ static inline int zbar_gtk_process_image
  749. if(!image)
  750. return(-1);
  751. - zbar_image_t *tmp = zbar_image_convert(image, fourcc('Y','8','0','0'));
  752. + zbar_image_t *tmp = zbar_image_convert(image, zbar_fourcc('Y','8','0','0'));
  753. if(!tmp)
  754. return(-1);
  755. @@ -560,6 +555,19 @@ gboolean zbar_gtk_get_video_opened (ZBar
  756. return(zbar->video_opened);
  757. }
  758. +void zbar_gtk_request_video_size (ZBarGtk *self,
  759. + int width,
  760. + int height)
  761. +{
  762. + if(!self->_private || width < 0 || height < 0)
  763. + return;
  764. + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
  765. +
  766. + zbar->req_width = zbar->video_width = width;
  767. + zbar->req_height = zbar->video_height = height;
  768. + gtk_widget_queue_resize(GTK_WIDGET(self));
  769. +}
  770. +
  771. static void zbar_gtk_set_property (GObject *object,
  772. guint prop_id,
  773. const GValue *value,
  774. @@ -613,8 +621,8 @@ static void zbar_gtk_init (ZBarGtk *self
  775. zbar->window = zbar_window_create();
  776. g_assert(zbar->window);
  777. - zbar->req_width = DEFAULT_WIDTH;
  778. - zbar->req_height = DEFAULT_HEIGHT;
  779. + zbar->req_width = zbar->video_width = DEFAULT_WIDTH;
  780. + zbar->req_height = zbar->video_width = DEFAULT_HEIGHT;
  781. /* spawn a thread to handle decoding and video */
  782. zbar->queue = g_async_queue_new();
  783. diff --git a/gtk/zbargtkprivate.h b/gtk/zbargtkprivate.h
  784. --- a/gtk/zbargtkprivate.h
  785. +++ b/gtk/zbargtkprivate.h
  786. @@ -71,6 +71,7 @@ typedef struct _ZBarGtkPrivate
  787. * protected by main gui lock
  788. */
  789. unsigned req_width, req_height;
  790. + unsigned video_width, video_height;
  791. gboolean video_opened;
  792. /* window is shared: owned by main gui thread.
  793. diff --git a/include/zbar.h b/include/zbar.h
  794. --- a/include/zbar.h
  795. +++ b/include/zbar.h
  796. @@ -1,5 +1,5 @@
  797. /*------------------------------------------------------------------------
  798. - * Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
  799. + * Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
  800. *
  801. * This file is part of the ZBar Bar Code Reader.
  802. *
  803. @@ -93,9 +93,12 @@ typedef enum zbar_symbol_type_e {
  804. ZBAR_EAN13 = 13, /**< EAN-13 */
  805. ZBAR_ISBN13 = 14, /**< ISBN-13 (from EAN-13). @since 0.4 */
  806. ZBAR_I25 = 25, /**< Interleaved 2 of 5. @since 0.4 */
  807. + ZBAR_DATABAR = 34, /**< GS1 DataBar (RSS). @since 0.11 */
  808. + ZBAR_DATABAR_EXP = 35, /**< GS1 DataBar Expanded. @since 0.11 */
  809. ZBAR_CODE39 = 39, /**< Code 39. @since 0.4 */
  810. ZBAR_PDF417 = 57, /**< PDF417. @since 0.6 */
  811. ZBAR_QRCODE = 64, /**< QR Code. @since 0.10 */
  812. + ZBAR_CODE93 = 93, /**< Code 93. @since 0.11 */
  813. ZBAR_CODE128 = 128, /**< Code 128 */
  814. ZBAR_SYMBOL = 0x00ff, /**< mask for base symbol type */
  815. ZBAR_ADDON2 = 0x0200, /**< 2-digit add-on flag */
  816. @@ -103,6 +106,17 @@ typedef enum zbar_symbol_type_e {
  817. ZBAR_ADDON = 0x0700, /**< add-on flag mask */
  818. } zbar_symbol_type_t;
  819. +/** decoded symbol coarse orientation.
  820. + * @since 0.11
  821. + */
  822. +typedef enum zbar_orientation_e {
  823. + ZBAR_ORIENT_UNKNOWN = -1, /**< unable to determine orientation */
  824. + ZBAR_ORIENT_UP, /**< upright, read left to right */
  825. + ZBAR_ORIENT_RIGHT, /**< sideways, read top to bottom */
  826. + ZBAR_ORIENT_DOWN, /**< upside-down, read right to left */
  827. + ZBAR_ORIENT_LEFT, /**< sideways, read bottom to top */
  828. +} zbar_orientation_t;
  829. +
  830. /** error codes. */
  831. typedef enum zbar_error_e {
  832. ZBAR_OK = 0, /**< no error */
  833. @@ -133,12 +147,33 @@ typedef enum zbar_config_e {
  834. ZBAR_CFG_MIN_LEN = 0x20, /**< minimum data length for valid decode */
  835. ZBAR_CFG_MAX_LEN, /**< maximum data length for valid decode */
  836. + ZBAR_CFG_UNCERTAINTY = 0x40,/**< required video consistency frames */
  837. +
  838. ZBAR_CFG_POSITION = 0x80, /**< enable scanner to collect position data */
  839. ZBAR_CFG_X_DENSITY = 0x100, /**< image scanner vertical scan density */
  840. ZBAR_CFG_Y_DENSITY, /**< image scanner horizontal scan density */
  841. } zbar_config_t;
  842. +/** decoder symbology modifier flags.
  843. + * @since 0.11
  844. + */
  845. +typedef enum zbar_modifier_e {
  846. + /** barcode tagged as GS1 (EAN.UCC) reserved
  847. + * (eg, FNC1 before first data character).
  848. + * data may be parsed as a sequence of GS1 AIs
  849. + */
  850. + ZBAR_MOD_GS1 = 0,
  851. +
  852. + /** barcode tagged as AIM reserved
  853. + * (eg, FNC1 after first character or digit pair)
  854. + */
  855. + ZBAR_MOD_AIM,
  856. +
  857. + /** number of modifiers */
  858. + ZBAR_MOD_NUM,
  859. +} zbar_modifier_t;
  860. +
  861. /** retrieve runtime library version information.
  862. * @param major set to the running major version (unless NULL)
  863. * @param minor set to the running minor version (unless NULL)
  864. @@ -171,6 +206,28 @@ extern const char *zbar_get_symbol_name(
  865. */
  866. extern const char *zbar_get_addon_name(zbar_symbol_type_t sym);
  867. +/** retrieve string name for configuration setting.
  868. + * @param config setting to name
  869. + * @returns static string name for config,
  870. + * or the empty string if value is not a known config
  871. + */
  872. +extern const char *zbar_get_config_name(zbar_config_t config);
  873. +
  874. +/** retrieve string name for modifier.
  875. + * @param modifier flag to name
  876. + * @returns static string name for modifier,
  877. + * or the empty string if the value is not a known flag
  878. + */
  879. +extern const char *zbar_get_modifier_name(zbar_modifier_t modifier);
  880. +
  881. +/** retrieve string name for orientation.
  882. + * @param orientation orientation encoding
  883. + * @returns the static string name for the specified orientation,
  884. + * or "UNKNOWN" if the orientation is not recognized
  885. + * @since 0.11
  886. + */
  887. +extern const char *zbar_get_orientation_name(zbar_orientation_t orientation);
  888. +
  889. /** parse a configuration string of the form "[symbology.]config[=value]".
  890. * the config must match one of the recognized names.
  891. * the symbology, if present, must match one of the recognized names.
  892. @@ -184,6 +241,30 @@ extern int zbar_parse_config(const char
  893. zbar_config_t *config,
  894. int *value);
  895. +/** consistently compute fourcc values across architectures
  896. + * (adapted from v4l2 specification)
  897. + * @since 0.11
  898. + */
  899. +#define zbar_fourcc(a, b, c, d) \
  900. + ((unsigned long)(a) | \
  901. + ((unsigned long)(b) << 8) | \
  902. + ((unsigned long)(c) << 16) | \
  903. + ((unsigned long)(d) << 24))
  904. +
  905. +/** parse a fourcc string into its encoded integer value.
  906. + * @since 0.11
  907. + */
  908. +static inline unsigned long zbar_fourcc_parse (const char *format)
  909. +{
  910. + unsigned long fourcc = 0;
  911. + if(format) {
  912. + int i;
  913. + for(i = 0; i < 4 && format[i]; i++)
  914. + fourcc |= ((unsigned long)format[i]) << (i * 8);
  915. + }
  916. + return(fourcc);
  917. +}
  918. +
  919. /** @internal type unsafe error API (don't use) */
  920. extern int _zbar_error_spew(const void *object,
  921. int verbosity);
  922. @@ -229,6 +310,20 @@ extern void zbar_symbol_ref(const zbar_s
  923. */
  924. extern zbar_symbol_type_t zbar_symbol_get_type(const zbar_symbol_t *symbol);
  925. +/** retrieve symbology boolean config settings.
  926. + * @returns a bitmask indicating which configs were set for the detected
  927. + * symbology during decoding.
  928. + * @since 0.11
  929. + */
  930. +extern unsigned int zbar_symbol_get_configs(const zbar_symbol_t *symbol);
  931. +
  932. +/** retrieve symbology modifier flag settings.
  933. + * @returns a bitmask indicating which characteristics were detected
  934. + * during decoding.
  935. + * @since 0.11
  936. + */
  937. +extern unsigned int zbar_symbol_get_modifiers(const zbar_symbol_t *symbol);
  938. +
  939. /** retrieve data decoded from symbol.
  940. * @returns the data string
  941. */
  942. @@ -284,6 +379,14 @@ extern int zbar_symbol_get_loc_x(const z
  943. extern int zbar_symbol_get_loc_y(const zbar_symbol_t *symbol,
  944. unsigned index);
  945. +/** retrieve general orientation of decoded symbol.
  946. + * @returns a coarse, axis-aligned indication of symbol orientation or
  947. + * ZBAR_ORIENT_UNKNOWN if unknown
  948. + * @since 0.11
  949. + */
  950. +extern zbar_orientation_t
  951. +zbar_symbol_get_orientation(const zbar_symbol_t *symbol);
  952. +
  953. /** iterate the set to which this symbol belongs (there can be only one).
  954. * @returns the next symbol in the set, or
  955. * @returns NULL when no more results are available
  956. @@ -357,6 +460,14 @@ extern int zbar_symbol_set_get_size(cons
  957. extern const zbar_symbol_t*
  958. zbar_symbol_set_first_symbol(const zbar_symbol_set_t *symbols);
  959. +/** raw result iterator.
  960. + * @returns the first decoded symbol result in a set, *before* filtering
  961. + * @returns NULL if the set is empty
  962. + * @since 0.11
  963. + */
  964. +extern const zbar_symbol_t*
  965. +zbar_symbol_set_first_unfiltered(const zbar_symbol_set_t *symbols);
  966. +
  967. /*@}*/
  968. /*------------------------------------------------------------*/
  969. @@ -456,6 +567,25 @@ extern unsigned zbar_image_get_width(con
  970. */
  971. extern unsigned zbar_image_get_height(const zbar_image_t *image);
  972. +/** retrieve both dimensions of the image.
  973. + * fills in the width and height in samples
  974. + */
  975. +extern void zbar_image_get_size(const zbar_image_t *image,
  976. + unsigned *width,
  977. + unsigned *height);
  978. +
  979. +/** retrieve the crop rectangle.
  980. + * fills in the image coordinates of the upper left corner and size
  981. + * of an axis-aligned rectangular area of the image that will be scanned.
  982. + * defaults to the full image
  983. + * @since 0.11
  984. + */
  985. +extern void zbar_image_get_crop(const zbar_image_t *image,
  986. + unsigned *x,
  987. + unsigned *y,
  988. + unsigned *width,
  989. + unsigned *height);
  990. +
  991. /** return the image sample data. the returned data buffer is only
  992. * valid until zbar_image_destroy() is called
  993. */
  994. @@ -505,12 +635,24 @@ extern void zbar_image_set_sequence(zbar
  995. unsigned sequence_num);
  996. /** specify the pixel size of the image.
  997. + * @note this also resets the crop rectangle to the full image
  998. + * (0, 0, width, height)
  999. * @note this does not affect the data!
  1000. */
  1001. extern void zbar_image_set_size(zbar_image_t *image,
  1002. unsigned width,
  1003. unsigned height);
  1004. +/** specify a rectangular region of the image to scan.
  1005. + * the rectangle will be clipped to the image boundaries.
  1006. + * defaults to the full image specified by zbar_image_set_size()
  1007. + */
  1008. +extern void zbar_image_set_crop(zbar_image_t *image,
  1009. + unsigned x,
  1010. + unsigned y,
  1011. + unsigned width,
  1012. + unsigned height);
  1013. +
  1014. /** specify image sample data. when image data is no longer needed by
  1015. * the library the specific data cleanup handler will be called
  1016. * (unless NULL)
  1017. @@ -1148,6 +1290,14 @@ static inline int zbar_decoder_parse_con
  1018. zbar_decoder_set_config(decoder, sym, cfg, val));
  1019. }
  1020. +/** retrieve symbology boolean config settings.
  1021. + * @returns a bitmask indicating which configs are currently set for the
  1022. + * specified symbology.
  1023. + * @since 0.11
  1024. + */
  1025. +extern unsigned int zbar_decoder_get_configs(const zbar_decoder_t *decoder,
  1026. + zbar_symbol_type_t symbology);
  1027. +
  1028. /** clear all decoder state.
  1029. * any partial symbols are flushed
  1030. */
  1031. @@ -1195,6 +1345,20 @@ zbar_decoder_get_data_length(const zbar_
  1032. extern zbar_symbol_type_t
  1033. zbar_decoder_get_type(const zbar_decoder_t *decoder);
  1034. +/** retrieve modifier flags for the last decoded symbol.
  1035. + * @returns a bitmask indicating which characteristics were detected
  1036. + * during decoding.
  1037. + * @since 0.11
  1038. + */
  1039. +extern unsigned int zbar_decoder_get_modifiers(const zbar_decoder_t *decoder);
  1040. +
  1041. +/** retrieve last decode direction.
  1042. + * @returns 1 for forward and -1 for reverse
  1043. + * @returns 0 if the decode direction is unknown or does not apply
  1044. + * @since 0.11
  1045. + */
  1046. +extern int zbar_decoder_get_direction(const zbar_decoder_t *decoder);
  1047. +
  1048. /** setup data handler callback.
  1049. * the registered function will be called by the decoder
  1050. * just before zbar_decode_width() returns a non-zero value.
  1051. diff --git a/include/zbar/Decoder.h b/include/zbar/Decoder.h
  1052. --- a/include/zbar/Decoder.h
  1053. +++ b/include/zbar/Decoder.h
  1054. @@ -1,5 +1,5 @@
  1055. //------------------------------------------------------------------------
  1056. -// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
  1057. +// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
  1058. //
  1059. // This file is part of the ZBar Bar Code Reader.
  1060. //
  1061. @@ -149,6 +149,14 @@ class Decoder {
  1062. return(zbar_decoder_get_data_length(_decoder));
  1063. }
  1064. + /// retrieve last decode direction.
  1065. + /// see zbar_decoder_get_direction()
  1066. + /// @since 0.11
  1067. + int get_direction() const
  1068. + {
  1069. + return(zbar_decoder_get_direction(_decoder));
  1070. + }
  1071. +
  1072. /// setup callback to handle result data.
  1073. void set_handler (Handler &handler)
  1074. {
  1075. diff --git a/include/zbar/Image.h b/include/zbar/Image.h
  1076. --- a/include/zbar/Image.h
  1077. +++ b/include/zbar/Image.h
  1078. @@ -1,5 +1,5 @@
  1079. //------------------------------------------------------------------------
  1080. -// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
  1081. +// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
  1082. //
  1083. // This file is part of the ZBar Bar Code Reader.
  1084. //
  1085. @@ -67,7 +67,12 @@ public:
  1086. {
  1087. if(userdata) {
  1088. Image *image = (Image*)zbar_image_get_userdata(zimg);
  1089. - ((Handler*)userdata)->image_callback(*image);
  1090. + if(image)
  1091. + ((Handler*)userdata)->image_callback(*image);
  1092. + else {
  1093. + Image tmp(zimg, 1);
  1094. + ((Handler*)userdata)->image_callback(tmp);
  1095. + }
  1096. }
  1097. }
  1098. };
  1099. @@ -110,6 +115,8 @@ public:
  1100. ~Image ()
  1101. {
  1102. + set_data(NULL, 0);
  1103. + zbar_image_set_userdata(_img, NULL);
  1104. zbar_image_ref(_img, -1);
  1105. }
  1106. @@ -143,12 +150,7 @@ public:
  1107. /// see zbar_image_set_format()
  1108. void set_format (const std::string& format)
  1109. {
  1110. - if(format.length() != 4)
  1111. - throw FormatError();
  1112. - unsigned long fourcc = ((format[0] & 0xff) |
  1113. - ((format[1] & 0xff) << 8) |
  1114. - ((format[2] & 0xff) << 16) |
  1115. - ((format[3] & 0xff) << 24));
  1116. + unsigned long fourcc = zbar_fourcc_parse(format.c_str());
  1117. zbar_image_set_format(_img, fourcc);
  1118. }
  1119. @@ -183,6 +185,15 @@ public:
  1120. return(zbar_image_get_height(_img));
  1121. }
  1122. + /// retrieve both dimensions of the image.
  1123. + /// see zbar_image_get_size()
  1124. + /// @since 0.11
  1125. + void get_size (unsigned &width,
  1126. + unsigned &height) const
  1127. + {
  1128. + zbar_image_get_size(_img, &width, &height);
  1129. + }
  1130. +
  1131. /// specify the pixel size of the image.
  1132. /// see zbar_image_set_size()
  1133. void set_size (unsigned width,
  1134. @@ -191,6 +202,26 @@ public:
  1135. zbar_image_set_size(_img, width, height);
  1136. }
  1137. + /// retrieve the scan crop rectangle.
  1138. + /// see zbar_image_get_crop()
  1139. + void get_crop (unsigned &x,
  1140. + unsigned &y,
  1141. + unsigned &width,
  1142. + unsigned &height) const
  1143. + {
  1144. + zbar_image_get_crop(_img, &x, &y, &width, &height);
  1145. + }
  1146. +
  1147. + /// set the scan crop rectangle.
  1148. + /// see zbar_image_set_crop()
  1149. + void set_crop (unsigned x,
  1150. + unsigned y,
  1151. + unsigned width,
  1152. + unsigned height)
  1153. + {
  1154. + zbar_image_set_crop(_img, x, y, width, height);
  1155. + }
  1156. +
  1157. /// return the image sample data.
  1158. /// see zbar_image_get_data()
  1159. const void *get_data () const
  1160. diff --git a/include/zbar/Processor.h b/include/zbar/Processor.h
  1161. --- a/include/zbar/Processor.h
  1162. +++ b/include/zbar/Processor.h
  1163. @@ -1,5 +1,5 @@
  1164. //------------------------------------------------------------------------
  1165. -// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
  1166. +// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
  1167. //
  1168. // This file is part of the ZBar Bar Code Reader.
  1169. //
  1170. @@ -183,8 +183,8 @@ class Processor {
  1171. void force_format (std::string& input_format,
  1172. std::string& output_format)
  1173. {
  1174. - unsigned long ifourcc = *(unsigned long*)input_format.c_str();
  1175. - unsigned long ofourcc = *(unsigned long*)output_format.c_str();
  1176. + unsigned long ifourcc = zbar_fourcc_parse(input_format.c_str());
  1177. + unsigned long ofourcc = zbar_fourcc_parse(output_format.c_str());
  1178. if(zbar_processor_force_format(_processor, ifourcc, ofourcc))
  1179. throw_exception(_processor);
  1180. }
  1181. diff --git a/include/zbar/QZBarImage.h b/include/zbar/QZBarImage.h
  1182. --- a/include/zbar/QZBarImage.h
  1183. +++ b/include/zbar/QZBarImage.h
  1184. @@ -1,5 +1,5 @@
  1185. //------------------------------------------------------------------------
  1186. -// Copyright 2008-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
  1187. +// Copyright 2008-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
  1188. //
  1189. // This file is part of the ZBar Bar Code Reader.
  1190. //
  1191. @@ -53,7 +53,7 @@ public:
  1192. unsigned width = bpl / 4;
  1193. unsigned height = qimg.height();
  1194. set_size(width, height);
  1195. - set_format('B' | ('G' << 8) | ('R' << 16) | ('4' << 24));
  1196. + set_format(zbar_fourcc('B','G','R','4'));
  1197. unsigned long datalen = qimg.numBytes();
  1198. set_data(qimg.bits(), datalen);
  1199. diff --git a/include/zbar/Symbol.h b/include/zbar/Symbol.h
  1200. --- a/include/zbar/Symbol.h
  1201. +++ b/include/zbar/Symbol.h
  1202. @@ -1,5 +1,5 @@
  1203. //------------------------------------------------------------------------
  1204. -// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
  1205. +// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
  1206. //
  1207. // This file is part of the ZBar Bar Code Reader.
  1208. //
  1209. @@ -64,6 +64,21 @@ public:
  1210. ref(-1);
  1211. }
  1212. + /// assignment.
  1213. + SymbolSet& operator= (const SymbolSet& syms)
  1214. + {
  1215. + syms.ref();
  1216. + ref(-1);
  1217. + _syms = syms._syms;
  1218. + return(*this);
  1219. + }
  1220. +
  1221. + /// truth testing.
  1222. + bool operator! () const
  1223. + {
  1224. + return(!_syms || !get_size());
  1225. + }
  1226. +
  1227. /// manipulate reference count.
  1228. void ref (int delta = 1) const
  1229. {
  1230. @@ -77,7 +92,7 @@ public:
  1231. return(_syms);
  1232. }
  1233. - int get_size ()
  1234. + int get_size () const
  1235. {
  1236. return((_syms) ? zbar_symbol_set_get_size(_syms) : 0);
  1237. }
  1238. @@ -112,9 +127,16 @@ public:
  1239. /// copy constructor.
  1240. Point (const Point& pt)
  1241. + : x(pt.x),
  1242. + y(pt.y)
  1243. + { }
  1244. +
  1245. + /// assignment.
  1246. + Point& operator= (const Point& pt)
  1247. {
  1248. x = pt.x;
  1249. y = pt.y;
  1250. + return(*this);
  1251. }
  1252. };
  1253. @@ -135,7 +157,7 @@ public:
  1254. _index = -1;
  1255. }
  1256. - /// constructor.
  1257. + /// copy constructor.
  1258. PointIterator (const PointIterator& iter)
  1259. : _sym(iter._sym),
  1260. _index(iter._index)
  1261. @@ -149,6 +171,22 @@ public:
  1262. _sym->ref(-1);
  1263. }
  1264. + /// assignment.
  1265. + PointIterator& operator= (const PointIterator& iter)
  1266. + {
  1267. + iter._sym->ref();
  1268. + _sym->ref(-1);
  1269. + _sym = iter._sym;
  1270. + _index = iter._index;
  1271. + return(*this);
  1272. + }
  1273. +
  1274. + /// truth testing.
  1275. + bool operator! () const
  1276. + {
  1277. + return(!_sym || _index < 0);
  1278. + }
  1279. +
  1280. /// advance iterator to next Point.
  1281. PointIterator& operator++ ()
  1282. {
  1283. @@ -161,7 +199,9 @@ public:
  1284. /// retrieve currently referenced Point.
  1285. const Point operator* () const
  1286. {
  1287. - assert(_index >= 0);
  1288. + assert(!!*this);
  1289. + if(!*this)
  1290. + return(Point());
  1291. return(Point(zbar_symbol_get_loc_x(*_sym, _index),
  1292. zbar_symbol_get_loc_y(*_sym, _index)));
  1293. }
  1294. @@ -213,6 +253,32 @@ public:
  1295. ref(-1);
  1296. }
  1297. + /// assignment.
  1298. + Symbol& operator= (const Symbol& sym)
  1299. + {
  1300. + sym.ref(1);
  1301. + ref(-1);
  1302. + _sym = sym._sym;
  1303. + _type = sym._type;
  1304. + _data = sym._data;
  1305. + return(*this);
  1306. + }
  1307. +
  1308. + Symbol& operator= (const zbar_symbol_t *sym)
  1309. + {
  1310. + if(sym)
  1311. + zbar_symbol_ref(sym, 1);
  1312. + ref(-1);
  1313. + init(sym);
  1314. + return(*this);
  1315. + }
  1316. +
  1317. + /// truth testing.
  1318. + bool operator! () const
  1319. + {
  1320. + return(!_sym);
  1321. + }
  1322. +
  1323. void ref (int delta = 1) const
  1324. {
  1325. if(_sym)
  1326. @@ -311,6 +377,13 @@ public:
  1327. return((_sym) ? zbar_symbol_get_loc_y(_sym, index) : -1);
  1328. }
  1329. + /// see zbar_symbol_get_orientation().
  1330. + /// @since 0.11
  1331. + int get_orientation () const
  1332. + {
  1333. + return(zbar_symbol_get_orientation(_sym));
  1334. + }
  1335. +
  1336. /// see zbar_symbol_xml().
  1337. const std::string xml () const
  1338. {
  1339. @@ -320,9 +393,6 @@ public:
  1340. }
  1341. protected:
  1342. -
  1343. - friend class SymbolIterator;
  1344. -
  1345. /// (re)initialize Symbol from C symbol object.
  1346. void init (const zbar_symbol_t *sym = NULL)
  1347. {
  1348. @@ -361,7 +431,7 @@ public:
  1349. {
  1350. const zbar_symbol_set_t *zsyms = _syms;
  1351. if(zsyms)
  1352. - _sym.init(zbar_symbol_set_first_symbol(zsyms));
  1353. + _sym = zbar_symbol_set_first_symbol(zsyms);
  1354. }
  1355. /// copy constructor.
  1356. @@ -370,25 +440,33 @@ public:
  1357. {
  1358. const zbar_symbol_set_t *zsyms = _syms;
  1359. if(zsyms)
  1360. - _sym.init(zbar_symbol_set_first_symbol(zsyms));
  1361. + _sym = zbar_symbol_set_first_symbol(zsyms);
  1362. }
  1363. ~SymbolIterator ()
  1364. {
  1365. - _sym.init();
  1366. + }
  1367. +
  1368. + /// assignment.
  1369. + SymbolIterator& operator= (const SymbolIterator& iter)
  1370. + {
  1371. + _syms = iter._syms;
  1372. + _sym = iter._sym;
  1373. + return(*this);
  1374. + }
  1375. +
  1376. + bool operator! () const
  1377. + {
  1378. + return(!_syms || !_sym);
  1379. }
  1380. /// advance iterator to next Symbol.
  1381. SymbolIterator& operator++ ()
  1382. {
  1383. - const zbar_symbol_t *zsym = _sym;
  1384. - if(zsym)
  1385. - _sym.init(zbar_symbol_next(zsym));
  1386. - else {
  1387. - const zbar_symbol_set_t *zsyms = _syms;
  1388. - if(zsyms)
  1389. - _sym.init(zbar_symbol_set_first_symbol(zsyms));
  1390. - }
  1391. + if(!!_sym)
  1392. + _sym = zbar_symbol_next(_sym);
  1393. + else if(!!_syms)
  1394. + _sym = zbar_symbol_set_first_symbol(_syms);
  1395. return(*this);
  1396. }
  1397. diff --git a/include/zbar/Video.h b/include/zbar/Video.h
  1398. --- a/include/zbar/Video.h
  1399. +++ b/include/zbar/Video.h
  1400. @@ -1,5 +1,5 @@
  1401. //------------------------------------------------------------------------
  1402. -// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
  1403. +// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
  1404. //
  1405. // This file is part of the ZBar Bar Code Reader.
  1406. //
  1407. @@ -92,7 +92,7 @@ public:
  1408. /// see zbar_video_init()
  1409. void init (std::string& format)
  1410. {
  1411. - unsigned int fourcc = *(unsigned int*)format.c_str();
  1412. + unsigned int fourcc = zbar_fourcc_parse(format.c_str());
  1413. if(zbar_video_init(_video, fourcc))
  1414. throw_exception(_video);
  1415. }
  1416. diff --git a/include/zbar/zbargtk.h b/include/zbar/zbargtk.h
  1417. --- a/include/zbar/zbargtk.h
  1418. +++ b/include/zbar/zbargtk.h
  1419. @@ -136,7 +136,7 @@ struct _ZBarGtkClass {
  1420. GType zbar_gtk_get_type(void) G_GNUC_CONST;
  1421. -/**
  1422. +/**
  1423. * zbar_gtk_new:
  1424. * create a new barcode reader widget instance.
  1425. * initially has no associated video device or image.
  1426. @@ -189,7 +189,17 @@ void zbar_gtk_set_video_enabled(ZBarGtk
  1427. */
  1428. gboolean zbar_gtk_get_video_opened(ZBarGtk *zbar);
  1429. -/**
  1430. +/** set video camera resolution.
  1431. + * @width: width in pixels
  1432. + * @height: height in pixels
  1433. + *
  1434. + * @note this call must be made before video is initialized
  1435. + */
  1436. +void zbar_gtk_request_video_size(ZBarGtk *zbar,
  1437. + int width,
  1438. + int height);
  1439. +
  1440. +/**
  1441. * utility function to populate a zbar_image_t from a GdkPixbuf.
  1442. * @image: the zbar library image destination to populate
  1443. * @pixbuf: the GdkPixbuf source
  1444. diff --git a/iphone/ChangeLog b/iphone/ChangeLog
  1445. new file mode 100644
  1446. --- /dev/null
  1447. +++ b/iphone/ChangeLog
  1448. @@ -0,0 +1,70 @@
  1449. +version 1.0.1:
  1450. + * hotfix broken ZBarHelpController back button
  1451. + * release updates
  1452. + - update docs
  1453. + * fix support for GS1 AIs
  1454. + * fix simulated camera image orientation/scaling
  1455. + * cleanup and expose ZBarHelpController
  1456. + * expose enable for reader capture processing
  1457. + * workaround iOS 4.2 hang
  1458. + - upd…

Large files files are truncated, but you can click here to view the full file