Commit graph

1413 commits

Author SHA1 Message Date
AlexGeller1 92854d4a55
Add support for multi-eci encoding for PDF417 (#1506)
* - Added multi-eci encoding for PDF417
- Fixed issue that the PDF417 decoder incorrectly decoded input with a leading ECI and no explicit latch to TEXT encoding
2022-03-05 08:07:37 -06:00
Sean Owen 4bd257e8c5 BitArray perf improvement, possibly addressing https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45189 2022-03-03 10:11:45 -06:00
AlexGeller1 9460f0620a
Adding more PDF417 decoding tests (#1504)
* Added more PDF417 decoding tests
2022-03-02 08:27:40 -06:00
AlexGeller1 427ece8ae7
Fix bug #1502 that PDF417 barcodes without initial latch to Text compaction mode fail to decode (#1503)
* Fixed bug that barcodes without initial latch to text encoding failed to decode
2022-02-27 08:27:24 -06:00
Sean Owen 87f540f5bd Possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44778 2022-02-17 14:38:17 -06:00
Sean Owen 29fbff0802 Minor code changes to previous PR merges 2022-02-17 14:14:37 -06:00
Sean Owen f3f73b47d3 Update to 3.5.0-SNAPSHOT for next release; deps updates 2022-02-17 14:10:00 -06:00
AlexGeller1 13465b3f1c
Added option to force C40 encoding in data matrix (#1495)
* Added option FORCE_C40

* Restored original public API

* Improved javadoc for EncodeHintType.FORCE_C40

* More javadoc fixes
2022-01-26 09:47:18 -06:00
AlexGeller1 39440b3015
Fixed IllegalArgumentException in ErrorCorrection.encodeECC200 cause by the minimal encoder not adding padding (#1496) 2022-01-25 17:20:02 -06:00
AlexGeller1 94fb277607
Minimal encoding for Code-128 (2nd, less intrusive version) (#1484)
* 2nd version of Code128 minimal encoding.
2022-01-20 12:25:45 -06:00
Sean Owen 10d6b08fc6 Probable fix for AIOOBE from https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43765 2022-01-18 14:29:46 -06:00
Sean Owen b30da44d01 Add ReaderException.setStackTrace 2022-01-12 14:18:32 -06:00
AlexGeller1 ab23778d4b
Minimal encoding for Data Matrix with multi ECI and GS1-FNC1 support (2nd) (#1479)
* Added Data Matrix minimal encoding with multi-ECI and GS1-FNC1 support.

* Added support for MACRO-5 and MACRO-6

* Improved comment
2022-01-12 11:58:24 -06:00
Sean Owen 491006ac3b Add isStackTrace support to NotFoundException 2022-01-11 10:48:24 -06:00
AlexGeller1 c4266bf09c
Add support for multiple character-ECIs in data matrix decoder (#1474)
* Added support for multiple character-ECIs

* - Changed from ArrayList<Byte> to ByteArrayOutputStream
- Added blank lines

* Improved performance for the general case (without ECI)
2022-01-05 09:32:36 -06:00
AlexGeller1 9b972bbb07
Simplified code, improved memory usage and performance of the QR-Code minimal encoder. (#1465)
* Simplified code, improved memory usage and performance.

* Simplified code
2021-12-08 09:11:04 -06:00
AlexGeller1 21eb978d67
Fix of error in specification ISO/IEC 16022 Second edition Annex P as suggested by Martin Burke of zint (See 68566fefd2/) (#1459)
Quote of Martin's proposed changes to the spec:
The algorithm can be salvaged to be at least sound by making those changes, e.g. by adding to step e):

 "1) If the next character cannot be encoded as X12, switch to ASCII mode and go to step b)."

(and renumbering the following sub-steps). Similarly step f):

"1) If the next character cannot be encoded as EDIFACT, switch to ASCII mode and go to step b)."
2021-11-15 18:25:31 -06:00
AlexGeller1 c25029d29a
Fix bug624: Illegal Character Exception (#1454)
* - added code to suppress the terminator if the capacity of the version is less than 4 bit
- added test case

* - Removed code in MinimalEncoder that added Mode.TERMINATOR (is taken care of in Encoder.terminateBits)
- Removed the corresponding test case

* Updated test cases

* Improved documentation

* Changed documentation to not use an example with an unsupported character encoding

* Improved wording of comment

* - Simplified code
- Added space after comma in several places

* Added support for more character sets supported by CharacterSetECI

* Syntactic enhancements

* Changed instantiation of generic types to diamond style

* Updated documentation of the QR_COMPACT hint to explain the impact of setting the CHARACTER_SET hint .

* Changed whitespace

* Removed comment

* Fixed typos in comments

* Added text cases for KANJI and Shift_JS encoding

* Improved comments on Japanese language test cases

* Fixed bug

* Compacted code slightly

* Whitespace changes

* Deepend indent
2021-11-11 08:23:33 -06:00
Sean Owen 6c034f9775 Minor code tweaks 2021-10-21 23:38:11 -05:00
AlexGeller1 2e22d09479
Compact QR-Code: Support more character sets (in particular cp1256 (Arabic) and Shift-JIS) (#1453)
* - added code to suppress the terminator if the capacity of the version is less than 4 bit
- added test case

* - Removed code in MinimalEncoder that added Mode.TERMINATOR (is taken care of in Encoder.terminateBits)
- Removed the corresponding test case

* Updated test cases

* Improved documentation

* Changed documentation to not use an example with an unsupported character encoding

* Improved wording of comment

* - Simplified code
- Added space after comma in several places

* Added support for more character sets supported by CharacterSetECI

* Syntactic enhancements

* Changed instantiation of generic types to diamond style

* Updated documentation of the QR_COMPACT hint to explain the impact of setting the CHARACTER_SET hint .

* Changed whitespace

* Removed comment

* Fixed typos in comments

* Added text cases for KANJI and Shift_JS encoding

* Improved comments on Japanese language test cases
2021-10-21 10:10:28 -05:00
AlexGeller1 c729abe393
Compacted QR-code: remove needless adding of Mode.TERMINATOR (is taken care of in Encoder.terminateBits) (#1452)
* - added code to suppress the terminator if the capacity of the version is less than 4 bit
- added test case

* - Removed code in MinimalEncoder that added Mode.TERMINATOR (is taken care of in Encoder.terminateBits)
- Removed the corresponding test case

* Updated test cases

* Improved documentation

* Changed documentation to not use an example with an unsupported character encoding

* Improved wording of comment

* - Simplified code
- Added space after comma in several places
2021-10-19 08:47:58 -05:00
AlexGeller1 128775149b
Add support for EncodeTypeHint.CHARACTER_SET for compacted QR-Codes (#1450)
* Added experimental version of QR-Code compaction which can be activated via EncodeHintType.QR_COMPACT

* - Changed algorithm from recursive divide and conquer to iterative Dijkstra
- Performed the requested modifications.

* Added better debug output and better documententation of the algorithm

* - Added missing error handling in case of a failing assert
- Fixed typo in the documentation

* Fixed bug that the minimal encoder would fail with an internal error if the string to encode contained only characters from ISO-8859-1 and on or more character that is not defined in any of the ISO-8859 characters sets.

* Added unit tests

* - indented class and method comments
- fixed code indententation
- added vertical spacing in statement lists to separate locical blocks
- added comments to document some numeric constants
- commented out debug logging
- made class ResultNode final and all but the methods called by the
class Encoder private.

* - Fixed indentation and line length
- Improved comments

* Fixed line length

* Improved comments

* - Whitespace and comment style changes
- Replaced string concatentation with StringBuilder.append()
- Replaced Vector with ArrayList
- Made members that are ony modified in the constructor final
- Made other minor changes

* - Made more members final
- replaced assert by throwing an IllegalStateException

* Changed internal data representation to be based on java.util.LinkedList

* Removed uneccessary spaces and comments

* Improved the debug output (now produces a compacted graph)

* - Added code to exclude not supported ECIs
- Fixed regression that bits were incorrectly computed

* - Fixed regression that bits were wrongly computed
- Improved compaction
- added a commented proposal for unit test that makes use of the decoder to validate the encoded bits

* Removed useless comparisons

* Removed commented code

* Optimization: added code to cache the value of LinkedList.size().

* Added more test cases

* - Added support for EncodeTypeHint.CHARACTER_SET
- Added support to encode in all ISO-8859 character sets available on the platform
- Removed code that handles failing asserts

* - Replaced string switch case with HashMap lookup
- Reintroduced asserts

* - Replaced <code> with {@code}
- Changed indentation in comment
- Simplified code

* Improved documentation

* Added comment about decoding compatibility with zxing.

* - Made MinimalEncoder responsible of ensuring that the bits fit in the returned version.
- Removed asserts that throw NPE in case of falure.

* Restricted encoder to use only encodings defined in CharacterSetECI

* Improved clarity and readability of the algorithm and of the datastrutures used.
- Minimizing algorithm is based on immutable edges
- ResultList now contains exaclty one ResultNode per mode and possibly several as before

* Changed unit tests (forgotten in previous push)
2021-10-17 08:57:06 -05:00
Sean Owen 831ebac6e7 Minor code style updates to MinimalEncoder and a few other files ; minor dep updates 2021-10-12 21:06:05 -05:00
AlexGeller1 3909ebe294
Fix qr compaction (#1449)
* - Added missing error handling in case of a failing assert
- Fixed typo in the documentation

* Fixed bug that the minimal encoder would fail with an internal error if the string to encode contained only characters from ISO-8859-1 and on or more character that is not defined in any of the ISO-8859 characters sets.
2021-10-12 09:09:19 -05:00
Sean Owen f984496a10 Fix javadoc error 2021-10-11 11:44:10 -05:00
Choi Su Beom f4f3c2971d
fix(core): do not evaluate out of index as white on qrcode mask evaluation (#1446)
* fix(core): do not evaluate out of index as white on qrcode mask evaluation
2021-10-09 13:15:00 -05:00
AlexGeller1 7a760c6384
Added experimental version of QR-Code compaction (#1445)
* Added experimental version of QR-Code compaction which can be activated via EncodeHintType.QR_COMPACT
2021-10-09 10:50:46 -05:00
Sean Owen af7831b5c7 Optimization for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=39707 2021-10-07 21:31:16 -05:00
Sean Owen b51346c072
Enforce line length and indent in checkstyle (#1448) 2021-10-05 15:49:47 -05:00
Anders Hammarquist fc50fca12f
Fix decoding of FNC1 in AztecCode. (#1441)
* Fix decoding of FNC1 in AztecCode. Flush buffer to make sure FNC1 is output in the correct
position in the stream.

* Simplify. Flush buffers outside switch, as it happens for all non-error cases anyway.
2021-09-28 15:28:07 -05:00
Sean Owen be2c5bdd88 Fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38913 2021-09-17 21:46:37 -05:00
Sean Owen c6a4e0fa97 Optimization for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38541 2021-09-11 18:03:19 -05:00
Sean Owen f5ef61ec13 Possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38486 2021-09-11 08:56:09 -05:00
Sean Owen 91a423b050 Possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38309 2021-09-09 12:04:56 -05:00
Sean Owen 0235f355ff Possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38197 ; refactor FieldParser data impl 2021-09-06 20:43:18 -05:00
Sean Owen 895775efa5 Possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38181 ; disallow encodings not supported by the JVM 2021-09-06 07:23:27 -05:00
MakKi (makki_d) f04ab98f97
fix valid y range (#1430) 2021-09-05 11:57:11 -05:00
Sean Owen aeeec7b07f Possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38086 2021-09-04 08:46:11 -05:00
Sean Owen 5b0036446e Fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38010 2021-09-02 09:27:41 -05:00
Sean Owen 6bcae2e5ea Minor hack to fix corner case from https://oss-fuzz.com/testcase-detail/5178194588729344 2021-09-01 22:13:16 -05:00
Sean Owen 50ead4f658 Another possible improvement against https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=37905&q=label%3AProj-zxing 2021-09-01 21:31:36 -05:00
Sean Owen 490769e75f Possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=37905 2021-09-01 12:48:20 -05:00
Sean Owen f6087eea12 Another possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=37858 2021-08-31 12:07:57 -05:00
Sean Owen dc6c8ea422 Possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=37868 2021-08-30 20:06:44 -05:00
Sean Owen 73a3c3a704 Possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=37858 2021-08-30 13:35:02 -05:00
Sean Owen b3941e251b Possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=37853 2021-08-30 13:24:58 -05:00
Sean Owen 2b48aec2c4 Possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=37811 2021-08-30 10:01:28 -05:00
gschwaer d2027d0e0f
Introduce hint to force specific code set for Code-128 encoding (#1411)
* Introduce hint to force specific code set for Code-128 encoding

* Address review comments

* Make character check more readable; address review comments

* Address review comments

Co-authored-by: Gero Schwäricke <gero@schwaericke.email>
2021-07-29 15:28:21 -05:00
Sean Owen 0d08915628 Minor changes from code inspection 2021-07-27 09:20:28 -05:00
Ikko Ashimine 1499c92178
Fix typo in ResultMetadataType.java (#1410)
identifer -> identifier
2021-07-26 18:46:34 -05:00
Sean Owen 32331c0708 Fix possible AIOOBE from fuzz test 2021-07-16 11:47:49 -05:00
MakKi (makki_d) ad061f05e2
Fix symbology identifier tests (#1396)
* rename metadata test files

* implement symbology identifier on ITFReader

* add metadata test

* remove unused code
2021-06-07 07:11:10 -05:00
Sean Owen adbf17d7a7 Minor code and dep changes; return better HTTP status codes from web app 2021-05-23 09:16:45 -05:00
gitlost d4c3d73592
PDF417 Macro: fileId numeric decode; allow Macro only symbol (#1379)
* PDF417 Macro: fileId numeric decode; allow Macro only symbol

* PDF417 Macro: additional FormatException unit tests
2021-04-12 09:44:42 -05:00
dehnhard 99e9b34f5a
Update ResultMetadataType.java (#1376) 2021-04-06 10:19:57 -05:00
gitlost cad70351ef
MaxiCode decoding: add missing NS to Set C (#1375) 2021-04-03 19:40:11 -05:00
Sean Owen f05963d63d Update dependencies and add one new test 2021-04-02 11:59:49 -05:00
Sean Owen 547e58a286 Add support for guessing UTF-16 encoding based on BOM 2021-04-02 11:53:19 -05:00
dehnhard ef498941bf
Symbology Identifier support (#1372)
* decoder support for symbology identifier metadata

Co-authored-by: Daniel Dehnhard <daniel@dehnhard.it>
2021-04-02 07:21:33 -05:00
dehnhard 3bf945e4cf
inverted barcode support (#1371)
* also decodes inverted barcode on hint

Co-authored-by: Daniel Dehnhard <daniel@dehnhard.it>
2021-04-01 17:04:55 -05:00
gitlost 5fb2cf8e96
Aztec Detector::getDimension() fix for layers 27 (131x131) (#1370) 2021-03-17 19:25:26 -05:00
gitlost a7c3516826
Update DMRE versions to ISO/IEC 21471:2020 (#1369) 2021-03-17 18:12:40 -05:00
dehnhard 4426711598
Update dimension ratio change to new location (updates DMRE PR #323) (#1350)
* Update dimension ratio change to new location

* changing threshold to 6

as discussed in #1350
2021-01-19 13:40:59 -06:00
Sean Owen 395dc6b83f Initial support for DMRE 2021-01-15 17:14:02 -06:00
Sean Owen 6dd0776b96 Prevent MaxiCode sampler from sampling off the edge of the image. 2020-12-30 15:44:03 -06:00
Sean Owen fd364d9338 Improve test coverage 2020-12-09 11:29:07 -06:00
Sean Owen e7ed6aee2f Misc dead code cleanup, plugin updates 2020-12-08 11:55:33 -06:00
Dan Lenski 20405981dc
PDF417 detector: try 90 and 270 rotations also (#1333) 2020-11-09 07:29:59 -06:00
Dan Lenski 515688992b
Aztec encode with ECI for non-default character sets (#1330)
* Aztec encoder: add ECI codes according to character set

Added redundant methods to avoid modifying existing tests.

* fix testAztecWriter

- ISO-8859-1 cannot actually encode Euro symbol ('€'); this test case only
  passed before because the Decoder wasn't actually doing the bytes→String
  decode, but simply round-tripping an unknown byte.
- Add extra test cases for implicit ISO-8859-1 (without ECI code), explicit
  ISO-8559-1 (with ECI code), and Shift_JIS

* remove unnecessary conversion between String and byte[] in Aztec EncoderTest and DetectorTest

* Aztec DecoderTest: use constants for charsets

* Aztec Code: remove unnecessary conversion between Charset and Charset.name() strings

* PDF417, QR, DataMatrix: remove unnecessary conversion between Charset and Charset.name() strings

Includes replacing StringUtils.guessEncoding() with .guessCharset(), to return
Charset rather than String.

This change makes the tacit assumption that Shift_JIS charset *will* be
available.  There are existing comments suggesting that it might not always
be available… but the existing *tests* assume it will be.
2020-11-07 16:26:24 -06:00
Dan Lenski 6e349275f7
Aztec Code: decode ECI and FNC1 (#1328)
* decode Aztec FLG(n)

Per https://en.wikipedia.org/wiki/Aztec_Code#Character_set,
FLG(0) → FNC1, FLG(1-6) → ECI identifier

Decode FNC1 as 0x1d (ASCII escape character; same as Code128,
DataMatrix, others)

Not doing anything with ECI yet, but this at least fixes
the mis-synchronization of the bit stream that comes from
ignoring the bits that follow it.

* include ecLevel (percentage) in DecoderResult for Aztec

* Aztec decoder: follow character set indicated by ECI codes

Modeled on PDF417's DecodedBitStreamParser

* add testAztecResultECI and testHighLevelDecode to aztec.decoder.DecoderTest

The latter includes non-ECI, ECI, and mixed test cases.
2020-10-27 20:04:41 -05:00
Sean Owen 32158ee504 [maven-release-plugin] prepare for next development iteration 2020-09-29 19:53:40 -05:00
Sean Owen 272d9561b5 [maven-release-plugin] prepare release zxing-3.4.1 2020-09-29 19:53:33 -05:00
Sean Owen cff1a21291 [maven-release-plugin] rollback the release of zxing-3.4.1 2020-09-29 19:50:02 -05:00
Sean Owen c30aa535e7 [maven-release-plugin] prepare release zxing-3.4.1 2020-09-29 19:48:52 -05:00
Sean Owen 06e3cd4967 [maven-release-plugin] rollback the release of zxing-3.4.1 2020-09-29 11:44:20 -05:00
Sean Owen 09f1a7eea2 [maven-release-plugin] prepare for next development iteration 2020-09-29 11:39:45 -05:00
Sean Owen 3eafc5d447 [maven-release-plugin] prepare release zxing-3.4.1 2020-09-29 11:39:38 -05:00
yerar 6fe3a775a0
Make MultiFinderPatternFinder a public class (#1313)
* Make MultiFinderPatternFinder a public class

* Make MultiFinderPatternFinder constructor public

Co-authored-by: Gerard Finol <gfinol@color-sensing.com>
2020-09-14 10:03:09 -05:00
Sean Owen 40c2e2e9af
Many small updates from code analysis; remove unused files; tune server params (#1311) 2020-09-06 18:21:05 -05:00
Sean Owen da049f21d9
Update proguard to 7. Remove unused slf4j. Minor code tweaks and dep updates. (#1307) 2020-08-26 13:09:20 -05:00
Sean Owen 9aa4db5c1f Misc code simplification and edits 2020-06-05 21:34:13 -05:00
Sean Owen c89470b2b0 Issue #862 : avoid invalid codeword from bad EC number estimate 2020-06-03 11:50:14 -05:00
Sean Owen 3c96923276 Minor dep updates 2020-05-13 14:12:53 -05:00
Sean Owen f8df5f0ca2 Avoid tiny Array.sort; a bottleneck 2020-05-13 14:12:34 -05:00
Sean Owen 2e2b5ba757 Resolve issue #1254: overloaded H: for hidden/p2m 2020-01-27 08:33:27 -06:00
Sean Owen 459c0197a7 Plugin updates; misc code simplifications and optimizations 2019-12-11 15:29:49 -06:00
Sean Owen 4e110ecdbb Minor code inspection: Use Math.min, Arrays.fill. No point in keeping opts from J2ME days 2019-07-29 14:36:16 -05:00
Sean Owen 1cc5cbe961 Don't run Aztec test 1000 times pointlessly 2019-07-29 14:33:58 -05:00
Sean Owen 4d94ac22eb Add addition wifi: QR code test case from mailing list 2019-07-29 14:33:58 -05:00
MakKi (makki_d) ae6d7e55af findFinderPattern()[1] points the outside pixel of the finder pattern (#1179) 2019-06-16 10:10:23 -05:00
anrcode 6075d5b2f6 Minor change to enable manual selection of the QR code mask pattern (#1176)
* Minor change to enable manual selection of the QR code mask pattern via encoding hints. Manual selection of the mask pattern greatly improves performance.

* fixed style
2019-06-13 07:02:10 -05:00
Sean Owen 723b65fe3d Refactor checking of write format in 1D writers 2019-05-31 10:53:24 -05:00
MakKi (makki_d) 2d77cec7c8 check format param in CodaBarWriter::encode (#1173) 2019-05-31 10:32:53 -05:00
Sean Owen 8f1a751ea5 [maven-release-plugin] prepare for next development iteration 2019-05-17 19:36:16 -05:00
Sean Owen 67138cedc8 [maven-release-plugin] prepare release zxing-3.4.0 2019-05-17 19:36:09 -05:00
Sean Owen f1683e1f4f Bump to 3.4.0. Require Java 8. Various code simplifications and plugin / dep updates 2019-05-13 18:44:57 -05:00
MakKi (makki_d) 653ac2a3be Improve FinderPatternFinder.selectBestPatterns (#1158)
* rewrite FinderPatternFinder.selectBestPatterns
2019-04-18 06:42:52 -07:00
Sean Gilligan 0e8c46e262 core JAR Automatic-Module-Name: com.google.zxing (#1155)
Add Automatic-Module-Name entry of com.google.zxing
to the core JAR for Java Platform Module System.

See Issue #1154
2019-04-08 07:43:00 -05:00
MakKi (makki_d) fedfa7a16c Remove duplicate results when it has structured append header. (#1147)
* remove duplicate results in processStructuredAppend

* add whitespace

* remove illegal import
2019-03-22 05:51:06 -05:00
Sean Owen bc645c50bb Small fixes, dep updates, removed warning about Android app, made web app params into annotations 2019-03-09 17:18:31 -06:00