forked from I2P_Developers/i2p.i2p
Zxing: Update to 3.4.1 (2020-09-29)
Merge in javadoc fixes
This commit is contained in:
@ -255,7 +255,7 @@ Applications:
|
|||||||
Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
|
Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
|
||||||
Copyright (c) 2008 Alexander von Gernler. All rights reserved.
|
Copyright (c) 2008 Alexander von Gernler. All rights reserved.
|
||||||
See licenses/LICENSE-BSD.txt
|
See licenses/LICENSE-BSD.txt
|
||||||
Zxing 3.3.0:
|
Zxing 3.4.1:
|
||||||
See licenses/LICENSE-Apache2.0.txt
|
See licenses/LICENSE-Apache2.0.txt
|
||||||
|
|
||||||
Jetty 9.3.28.v20191105 (jetty-*.jar, org.mortbay.*.jar):
|
Jetty 9.3.28.v20191105 (jetty-*.jar, org.mortbay.*.jar):
|
||||||
|
@ -23,6 +23,7 @@ Chang Hyun Park
|
|||||||
Christian Brunschen (Google)
|
Christian Brunschen (Google)
|
||||||
Christoph Schulz (creatale GmbH)
|
Christoph Schulz (creatale GmbH)
|
||||||
crowdin.net
|
crowdin.net
|
||||||
|
Daisuke Makiuchi
|
||||||
Daniel Switkin (Google)
|
Daniel Switkin (Google)
|
||||||
Dave MacLachlan (Google)
|
Dave MacLachlan (Google)
|
||||||
David Phillip Oster (Google)
|
David Phillip Oster (Google)
|
||||||
|
@ -363,3 +363,39 @@
|
|||||||
- BS 4.7.6 release with Android API 23 support
|
- BS 4.7.6 release with Android API 23 support
|
||||||
- TIFF support in online decoder
|
- TIFF support in online decoder
|
||||||
- Many small bug fixes, typo fixes and project build improvements
|
- Many small bug fixes, typo fixes and project build improvements
|
||||||
|
|
||||||
|
3.3.1 (26 Oct 2017)
|
||||||
|
|
||||||
|
- Various fixes to Code 128, 39 encoding; DataMatrix decoding
|
||||||
|
- Improvements to speed and robustness of zxing.org decoder
|
||||||
|
- Java 9 support
|
||||||
|
- Various translation updates for Barcode Scanner
|
||||||
|
- Removed Google Glass, ZXing Test apps
|
||||||
|
|
||||||
|
3.3.2 (31 Jan 2018)
|
||||||
|
|
||||||
|
- Add workaround for Gradle + Android build issues
|
||||||
|
- Minor DataMatrix bug fixes
|
||||||
|
- Improve WPA2 wi-fi configuration support in Barcode Scanner
|
||||||
|
- Various translation updates and minor improvements
|
||||||
|
|
||||||
|
3.3.3 (30 May 2018)
|
||||||
|
|
||||||
|
- Minor fixes and improvements
|
||||||
|
- Java 9+ support
|
||||||
|
|
||||||
|
3.4.0 (19 May 2019)
|
||||||
|
|
||||||
|
- Requires Java 8+
|
||||||
|
- core, javase modules declare a Java 9+ module
|
||||||
|
- HtmlAssetTranslator and StringsResourceTranslator legacy utilities are moved to a .client.j2se subpackage
|
||||||
|
- No more releases of the Barcode Scanner app
|
||||||
|
- Minor bug fixes to Code93Writer
|
||||||
|
- Minor improvements to QR code detection
|
||||||
|
|
||||||
|
3.4.1 (30 Sep 2020)
|
||||||
|
|
||||||
|
- Wifi QR codes now recognize PH2:, not H:, for phase 2 method
|
||||||
|
- Minor bug fixes and improvements
|
||||||
|
|
||||||
|
Note that further release notes will be published at https://github.com/zxing/zxing/releases
|
||||||
|
@ -2,4 +2,4 @@ This is a small portion of zxing, including only what's required
|
|||||||
to generate QR codes. There are no modifications.
|
to generate QR codes. There are no modifications.
|
||||||
We've added a build.xml for ant.
|
We've added a build.xml for ant.
|
||||||
|
|
||||||
https://github.com/zxing/zxing/releases Version 3.3.0 Sept. 16, 2016
|
https://github.com/zxing/zxing/releases Version 3.4.1 Sept. 29, 2020
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
<img align="right" src="https://raw.github.com/wiki/zxing/zxing/zxing-logo.png"/>
|
<img align="right" src="https://raw.github.com/wiki/zxing/zxing/zxing-logo.png"/>
|
||||||
|
|
||||||
##Get Started Developing
|
## Project in Maintenance Mode Only
|
||||||
|
|
||||||
|
The project is in maintenance mode, meaning, changes are driven by contributed patches.
|
||||||
|
Only bug fixes and minor enhancements will be considered. The Barcode Scanner app can
|
||||||
|
no longer be published, so it's unlikely any changes will be accepted for it.
|
||||||
|
There is otherwise no active development or roadmap for this project. It is "DIY".
|
||||||
|
|
||||||
|
## Get Started Developing
|
||||||
|
|
||||||
To get started, please visit: https://github.com/zxing/zxing/wiki/Getting-Started-Developing
|
To get started, please visit: https://github.com/zxing/zxing/wiki/Getting-Started-Developing
|
||||||
|
|
||||||
ZXing ("zebra crossing") is an open-source, multi-format 1D/2D barcode image processing
|
ZXing ("zebra crossing") is an open-source, multi-format 1D/2D barcode image processing
|
||||||
@ -8,15 +16,15 @@ library implemented in Java, with ports to other languages.
|
|||||||
|
|
||||||
## Supported Formats
|
## Supported Formats
|
||||||
|
|
||||||
| 1D product | 1D industrial | 2D
|
| 1D product | 1D industrial | 2D |
|
||||||
| ---------- | ------------- | --------------
|
|:----------------------|:--------------|:---------------|
|
||||||
| UPC-A | Code 39 | QR Code
|
| UPC-A | Code 39 | QR Code |
|
||||||
| UPC-E | Code 93 | Data Matrix
|
| UPC-E | Code 93 | Data Matrix |
|
||||||
| EAN-8 | Code 128 | Aztec (beta)
|
| EAN-8 | Code 128 | Aztec |
|
||||||
| EAN-13 | Codabar | PDF 417 (beta)
|
| EAN-13 | Codabar | PDF 417 |
|
||||||
| | ITF |
|
| UPC/EAN Extension 2/5 | ITF | MaxiCode |
|
||||||
| | RSS-14 |
|
| | | RSS-14 |
|
||||||
| | RSS-Expanded |
|
| | | RSS-Expanded |
|
||||||
|
|
||||||
## Components
|
## Components
|
||||||
|
|
||||||
@ -26,11 +34,9 @@ library implemented in Java, with ports to other languages.
|
|||||||
| ------------------- | -----------
|
| ------------------- | -----------
|
||||||
| core | The core image decoding library, and test code
|
| core | The core image decoding library, and test code
|
||||||
| javase | JavaSE-specific client code
|
| javase | JavaSE-specific client code
|
||||||
| android | Android client Barcode Scanner [](https://play.google.com/store/apps/details?id=com.google.zxing.client.android)
|
| android | Android client Barcode Scanner [<img height='62' width='161' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png'/>](https://play.google.com/store/apps/details?id=com.google.zxing.client.android)
|
||||||
| androidtest | Android test app, ZXing Test
|
|
||||||
| android-integration | Supports integration with Barcode Scanner via `Intent`
|
| android-integration | Supports integration with Barcode Scanner via `Intent`
|
||||||
| android-core | Android-related code shared among `android`, `androidtest`, `glass`
|
| android-core | Android-related code shared among `android`, other Android apps
|
||||||
| glass | Simple Google Glass application
|
|
||||||
| zxingorg | The source behind `zxing.org`
|
| zxingorg | The source behind `zxing.org`
|
||||||
| zxing.appspot.com | The source behind web-based barcode generator at `zxing.appspot.com`
|
| zxing.appspot.com | The source behind web-based barcode generator at `zxing.appspot.com`
|
||||||
|
|
||||||
@ -47,13 +53,21 @@ library implemented in Java, with ports to other languages.
|
|||||||
### ZXing-based third-party open source projects
|
### ZXing-based third-party open source projects
|
||||||
|
|
||||||
| Module | Description
|
| Module | Description
|
||||||
| --------------------------------------------------------------- | -----------
|
| ----------------------------------------------------------------------------------------- | -----------
|
||||||
| [QZXing](https://sourceforge.net/projects/qzxing) | port to Qt framework
|
| [QZXing](https://github.com/ftylitak/qzxing) | port to Qt framework
|
||||||
| [zxing-cpp](https://github.com/glassechidna/zxing-cpp) | port to C++ (forked from the [deprecated official C++ port](https://github.com/zxing/zxing/tree/00f634024ceeee591f54e6984ea7dd666fab22ae/cpp))
|
| [glassechidna/zxing-cpp](https://github.com/glassechidna/zxing-cpp) | port to C++ (forked from the [deprecated official C++ port](https://github.com/zxing/zxing/tree/00f634024ceeee591f54e6984ea7dd666fab22ae/cpp))
|
||||||
|
| [nu-book/zxing-cpp](https://github.com/nu-book/zxing-cpp) | recent port to C++
|
||||||
| [zxing_cpp.rb](https://github.com/glassechidna/zxing_cpp.rb) | bindings for Ruby (not just JRuby), powered by [zxing-cpp](https://github.com/glassechidna/zxing-cpp)
|
| [zxing_cpp.rb](https://github.com/glassechidna/zxing_cpp.rb) | bindings for Ruby (not just JRuby), powered by [zxing-cpp](https://github.com/glassechidna/zxing-cpp)
|
||||||
|
| [jsqrcode](https://github.com/LazarSoft/jsqrcode) | port to JavaScript
|
||||||
| [python-zxing](https://github.com/oostendo/python-zxing) | bindings for Python
|
| [python-zxing](https://github.com/oostendo/python-zxing) | bindings for Python
|
||||||
| [ZXing .NET](http://zxingnet.codeplex.com/) | port to .NET and C#, and related Windows platform
|
| [ZXing .NET](https://github.com/micjahn/ZXing.Net) | port to .NET and C#, and related Windows platform
|
||||||
| [php-qrcode-detector-decoder](https://github.com/khanamiryan/php-qrcode-detector-decoder) | port to PHP
|
| [php-qrcode-detector-decoder](https://github.com/khanamiryan/php-qrcode-detector-decoder) | port to PHP
|
||||||
|
| [ZXing Delphi](https://github.com/Spelt/ZXing.Delphi) | Port to native Delphi object pascal, targeted at Firemonkey compatible devices (IOS/Android/Win/OSX) and VCL.
|
||||||
|
| [ZXingObjC](https://github.com/TheLevelUp/ZXingObjC) | Port to Objective-C
|
||||||
|
| [php-zxing](https://github.com/dsiddharth2/php-zxing) | PHP wrapper to Zxing Java library
|
||||||
|
| [zxing-js/library](https://github.com/zxing-js/library) | TypeScript port of ZXing library
|
||||||
|
| [pyzxing](https://github.com/ChenjieXu/pyzxing) | Python wrapper to ZXing library
|
||||||
|
|
||||||
|
|
||||||
### Other related third-party open source projects
|
### Other related third-party open source projects
|
||||||
|
|
||||||
@ -61,7 +75,7 @@ library implemented in Java, with ports to other languages.
|
|||||||
| ---------------------------------------------- | -----------
|
| ---------------------------------------------- | -----------
|
||||||
| [Barcode4J](http://barcode4j.sourceforge.net/) | Generator library in Java
|
| [Barcode4J](http://barcode4j.sourceforge.net/) | Generator library in Java
|
||||||
| [ZBar](http://zbar.sourceforge.net/) | Reader library in C99
|
| [ZBar](http://zbar.sourceforge.net/) | Reader library in C99
|
||||||
| [OkapiBarcode](https://github.com/woo-j/OkapiBarcode) |
|
| [OkapiBarcode](https://github.com/woo-j/OkapiBarcode) | |
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
@ -73,14 +87,15 @@ library implemented in Java, with ports to other languages.
|
|||||||
## Contacting
|
## Contacting
|
||||||
|
|
||||||
Post to the [discussion forum](https://groups.google.com/group/zxing) or tag a question with [`zxing`
|
Post to the [discussion forum](https://groups.google.com/group/zxing) or tag a question with [`zxing`
|
||||||
on StackOverflow](http://stackoverflow.com/questions/tagged/zxing).
|
on StackOverflow](https://stackoverflow.com/questions/tagged/zxing).
|
||||||
|
|
||||||
## Etcetera
|
## Etcetera
|
||||||
|
|
||||||
[](https://travis-ci.org/zxing/zxing)
|
[](https://travis-ci.org/zxing/zxing)
|
||||||
[](https://scan.coverity.com/projects/1924)
|
[](https://scan.coverity.com/projects/1924)
|
||||||
[](https://codecov.io/github/zxing/zxing?branch=master)
|
[](https://codecov.io/github/zxing/zxing?branch=master)
|
||||||
|
[](https://www.codacy.com/app/srowen/zxing?utm_source=github.com&utm_medium=referral&utm_content=zxing/zxing&utm_campaign=Badge_Grade)
|
||||||
|
|
||||||
QR code is trademarked by Denso Wave, inc. Thanks to Haase & Martin OHG for contributing the logo.
|
QR code is trademarked by Denso Wave, inc. Thanks to Haase & Martin OHG for contributing the logo.
|
||||||
|
|
||||||
Optimized with [](http://www.ej-technologies.com/products/jprofiler/overview.html)
|
Optimized with [](https://www.ej-technologies.com/products/jprofiler/overview.html)
|
||||||
|
@ -101,4 +101,18 @@ public enum EncodeHintType {
|
|||||||
* (Type {@link Integer}, or {@link String} representation of the integer value).
|
* (Type {@link Integer}, or {@link String} representation of the integer value).
|
||||||
*/
|
*/
|
||||||
QR_VERSION,
|
QR_VERSION,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the QR code mask pattern to be used. Allowed values are
|
||||||
|
* 0..QRCode.NUM_MASK_PATTERNS-1. By default the code will automatically select
|
||||||
|
* the optimal mask pattern.
|
||||||
|
* * (Type {@link Integer}, or {@link String} representation of the integer value).
|
||||||
|
*/
|
||||||
|
QR_MASK_PATTERN,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies whether the data should be encoded to the GS1 standard (type {@link Boolean}, or "true" or "false"
|
||||||
|
* {@link String } value).
|
||||||
|
*/
|
||||||
|
GS1_FORMAT,
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public final class BitArray implements Cloneable {
|
|||||||
int bitsOffset = from / 32;
|
int bitsOffset = from / 32;
|
||||||
int currentBits = bits[bitsOffset];
|
int currentBits = bits[bitsOffset];
|
||||||
// mask off lesser bits first
|
// mask off lesser bits first
|
||||||
currentBits &= ~((1 << (from & 0x1F)) - 1);
|
currentBits &= -(1 << (from & 0x1F));
|
||||||
while (currentBits == 0) {
|
while (currentBits == 0) {
|
||||||
if (++bitsOffset == bits.length) {
|
if (++bitsOffset == bits.length) {
|
||||||
return size;
|
return size;
|
||||||
@ -107,7 +107,7 @@ public final class BitArray implements Cloneable {
|
|||||||
currentBits = bits[bitsOffset];
|
currentBits = bits[bitsOffset];
|
||||||
}
|
}
|
||||||
int result = (bitsOffset * 32) + Integer.numberOfTrailingZeros(currentBits);
|
int result = (bitsOffset * 32) + Integer.numberOfTrailingZeros(currentBits);
|
||||||
return result > size ? size : result;
|
return Math.min(result, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,7 +122,7 @@ public final class BitArray implements Cloneable {
|
|||||||
int bitsOffset = from / 32;
|
int bitsOffset = from / 32;
|
||||||
int currentBits = ~bits[bitsOffset];
|
int currentBits = ~bits[bitsOffset];
|
||||||
// mask off lesser bits first
|
// mask off lesser bits first
|
||||||
currentBits &= ~((1 << (from & 0x1F)) - 1);
|
currentBits &= -(1 << (from & 0x1F));
|
||||||
while (currentBits == 0) {
|
while (currentBits == 0) {
|
||||||
if (++bitsOffset == bits.length) {
|
if (++bitsOffset == bits.length) {
|
||||||
return size;
|
return size;
|
||||||
@ -130,7 +130,7 @@ public final class BitArray implements Cloneable {
|
|||||||
currentBits = ~bits[bitsOffset];
|
currentBits = ~bits[bitsOffset];
|
||||||
}
|
}
|
||||||
int result = (bitsOffset * 32) + Integer.numberOfTrailingZeros(currentBits);
|
int result = (bitsOffset * 32) + Integer.numberOfTrailingZeros(currentBits);
|
||||||
return result > size ? size : result;
|
return Math.min(result, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -339,7 +339,7 @@ public final class BitArray implements Cloneable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder result = new StringBuilder(size);
|
StringBuilder result = new StringBuilder(size + (size / 8) + 1);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
if ((i & 0x07) == 0) {
|
if ((i & 0x07) == 0) {
|
||||||
result.append(' ');
|
result.append(' ');
|
||||||
|
@ -40,11 +40,21 @@ public final class BitMatrix implements Cloneable {
|
|||||||
private final int rowSize;
|
private final int rowSize;
|
||||||
private final int[] bits;
|
private final int[] bits;
|
||||||
|
|
||||||
// A helper to construct a square matrix.
|
/**
|
||||||
|
* Creates an empty square {@code BitMatrix}.
|
||||||
|
*
|
||||||
|
* @param dimension height and width
|
||||||
|
*/
|
||||||
public BitMatrix(int dimension) {
|
public BitMatrix(int dimension) {
|
||||||
this(dimension, dimension);
|
this(dimension, dimension);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an empty {@code BitMatrix}.
|
||||||
|
*
|
||||||
|
* @param width bit matrix width
|
||||||
|
* @param height bit matrix height
|
||||||
|
*/
|
||||||
public BitMatrix(int width, int height) {
|
public BitMatrix(int width, int height) {
|
||||||
if (width < 1 || height < 1) {
|
if (width < 1 || height < 1) {
|
||||||
throw new IllegalArgumentException("Both dimensions must be greater than 0");
|
throw new IllegalArgumentException("Both dimensions must be greater than 0");
|
||||||
@ -62,6 +72,27 @@ public final class BitMatrix implements Cloneable {
|
|||||||
this.bits = bits;
|
this.bits = bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interprets a 2D array of booleans as a {@code BitMatrix}, where "true" means an "on" bit.
|
||||||
|
*
|
||||||
|
* @param image bits of the image, as a row-major 2D array. Elements are arrays representing rows
|
||||||
|
* @return {@code BitMatrix} representation of image
|
||||||
|
*/
|
||||||
|
public static BitMatrix parse(boolean[][] image) {
|
||||||
|
int height = image.length;
|
||||||
|
int width = image[0].length;
|
||||||
|
BitMatrix bits = new BitMatrix(width, height);
|
||||||
|
for (int i = 0; i < height; i++) {
|
||||||
|
boolean[] imageI = image[i];
|
||||||
|
for (int j = 0; j < width; j++) {
|
||||||
|
if (imageI[j]) {
|
||||||
|
bits.set(j, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bits;
|
||||||
|
}
|
||||||
|
|
||||||
public static BitMatrix parse(String stringRepresentation, String setString, String unsetString) {
|
public static BitMatrix parse(String stringRepresentation, String setString, String unsetString) {
|
||||||
if (stringRepresentation == null) {
|
if (stringRepresentation == null) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
@ -86,11 +117,11 @@ public final class BitMatrix implements Cloneable {
|
|||||||
nRows++;
|
nRows++;
|
||||||
}
|
}
|
||||||
pos++;
|
pos++;
|
||||||
} else if (stringRepresentation.substring(pos, pos + setString.length()).equals(setString)) {
|
} else if (stringRepresentation.startsWith(setString, pos)) {
|
||||||
pos += setString.length();
|
pos += setString.length();
|
||||||
bits[bitsPos] = true;
|
bits[bitsPos] = true;
|
||||||
bitsPos++;
|
bitsPos++;
|
||||||
} else if (stringRepresentation.substring(pos, pos + unsetString.length()).equals(unsetString)) {
|
} else if (stringRepresentation.startsWith(unsetString, pos)) {
|
||||||
pos += unsetString.length();
|
pos += unsetString.length();
|
||||||
bits[bitsPos] = false;
|
bits[bitsPos] = false;
|
||||||
bitsPos++;
|
bitsPos++;
|
||||||
@ -165,11 +196,10 @@ public final class BitMatrix implements Cloneable {
|
|||||||
* @param mask XOR mask
|
* @param mask XOR mask
|
||||||
*/
|
*/
|
||||||
public void xor(BitMatrix mask) {
|
public void xor(BitMatrix mask) {
|
||||||
if (width != mask.getWidth() || height != mask.getHeight()
|
if (width != mask.width || height != mask.height || rowSize != mask.rowSize) {
|
||||||
|| rowSize != mask.getRowSize()) {
|
|
||||||
throw new IllegalArgumentException("input matrix dimensions do not match");
|
throw new IllegalArgumentException("input matrix dimensions do not match");
|
||||||
}
|
}
|
||||||
BitArray rowArray = new BitArray(width / 32 + 1);
|
BitArray rowArray = new BitArray(width);
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
int offset = y * rowSize;
|
int offset = y * rowSize;
|
||||||
int[] row = mask.getRow(y, rowArray).getBitArray();
|
int[] row = mask.getRow(y, rowArray).getBitArray();
|
||||||
@ -250,17 +280,17 @@ public final class BitMatrix implements Cloneable {
|
|||||||
* Modifies this {@code BitMatrix} to represent the same but rotated 180 degrees
|
* Modifies this {@code BitMatrix} to represent the same but rotated 180 degrees
|
||||||
*/
|
*/
|
||||||
public void rotate180() {
|
public void rotate180() {
|
||||||
int width = getWidth();
|
|
||||||
int height = getHeight();
|
|
||||||
BitArray topRow = new BitArray(width);
|
BitArray topRow = new BitArray(width);
|
||||||
BitArray bottomRow = new BitArray(width);
|
BitArray bottomRow = new BitArray(width);
|
||||||
for (int i = 0; i < (height + 1) / 2; i++) {
|
int maxHeight = (height + 1) / 2;
|
||||||
|
for (int i = 0; i < maxHeight; i++) {
|
||||||
topRow = getRow(i, topRow);
|
topRow = getRow(i, topRow);
|
||||||
bottomRow = getRow(height - 1 - i, bottomRow);
|
int bottomRowIndex = height - 1 - i;
|
||||||
|
bottomRow = getRow(bottomRowIndex, bottomRow);
|
||||||
topRow.reverse();
|
topRow.reverse();
|
||||||
bottomRow.reverse();
|
bottomRow.reverse();
|
||||||
setRow(i, bottomRow);
|
setRow(i, bottomRow);
|
||||||
setRow(height - 1 - i, topRow);
|
setRow(bottomRowIndex, topRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,12 +225,19 @@ final class GenericGFPoly {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
if (isZero()) {
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
StringBuilder result = new StringBuilder(8 * getDegree());
|
StringBuilder result = new StringBuilder(8 * getDegree());
|
||||||
for (int degree = getDegree(); degree >= 0; degree--) {
|
for (int degree = getDegree(); degree >= 0; degree--) {
|
||||||
int coefficient = getCoefficient(degree);
|
int coefficient = getCoefficient(degree);
|
||||||
if (coefficient != 0) {
|
if (coefficient != 0) {
|
||||||
if (coefficient < 0) {
|
if (coefficient < 0) {
|
||||||
|
if (degree == getDegree()) {
|
||||||
|
result.append("-");
|
||||||
|
} else {
|
||||||
result.append(" - ");
|
result.append(" - ");
|
||||||
|
}
|
||||||
coefficient = -coefficient;
|
coefficient = -coefficient;
|
||||||
} else {
|
} else {
|
||||||
if (result.length() > 0) {
|
if (result.length() > 0) {
|
||||||
|
@ -20,7 +20,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Implements Reed-Solomon enbcoding, as the name implies.</p>
|
* <p>Implements Reed-Solomon encoding, as the name implies.</p>
|
||||||
*
|
*
|
||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
* @author William Rucklidge
|
* @author William Rucklidge
|
||||||
|
@ -152,12 +152,11 @@ public final class Version {
|
|||||||
for (int x = 0; x < max; x++) {
|
for (int x = 0; x < max; x++) {
|
||||||
int i = alignmentPatternCenters[x] - 2;
|
int i = alignmentPatternCenters[x] - 2;
|
||||||
for (int y = 0; y < max; y++) {
|
for (int y = 0; y < max; y++) {
|
||||||
if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) {
|
if ((x != 0 || (y != 0 && y != max - 1)) && (x != max - 1 || y != 0)) {
|
||||||
// No alignment patterns near the three finder patterns
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5);
|
bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5);
|
||||||
}
|
}
|
||||||
|
// else no o alignment patterns near the three finder patterns
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vertical timing pattern
|
// Vertical timing pattern
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.google.zxing.qrcode.encoder;
|
package com.google.zxing.qrcode.encoder;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned
|
* JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned
|
||||||
* -1, 0, and 1, I'm going to use less memory and go with bytes.
|
* -1, 0, and 1, I'm going to use less memory and go with bytes.
|
||||||
@ -66,10 +68,8 @@ public final class ByteMatrix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clear(byte value) {
|
public void clear(byte value) {
|
||||||
for (int y = 0; y < height; ++y) {
|
for (byte[] aByte : bytes) {
|
||||||
for (int x = 0; x < width; ++x) {
|
Arrays.fill(aByte, value);
|
||||||
bytes[y][x] = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,8 +77,9 @@ public final class ByteMatrix {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder result = new StringBuilder(2 * width * height + 2);
|
StringBuilder result = new StringBuilder(2 * width * height + 2);
|
||||||
for (int y = 0; y < height; ++y) {
|
for (int y = 0; y < height; ++y) {
|
||||||
|
byte[] bytesY = bytes[y];
|
||||||
for (int x = 0; x < width; ++x) {
|
for (int x = 0; x < width; ++x) {
|
||||||
switch (bytes[y][x]) {
|
switch (bytesY[x]) {
|
||||||
case 0:
|
case 0:
|
||||||
result.append(" 0");
|
result.append(" 0");
|
||||||
break;
|
break;
|
||||||
|
@ -78,7 +78,8 @@ public final class Encoder {
|
|||||||
|
|
||||||
// Determine what character encoding has been specified by the caller, if any
|
// Determine what character encoding has been specified by the caller, if any
|
||||||
String encoding = DEFAULT_BYTE_MODE_ENCODING;
|
String encoding = DEFAULT_BYTE_MODE_ENCODING;
|
||||||
if (hints != null && hints.containsKey(EncodeHintType.CHARACTER_SET)) {
|
boolean hasEncodingHint = hints != null && hints.containsKey(EncodeHintType.CHARACTER_SET);
|
||||||
|
if (hasEncodingHint) {
|
||||||
encoding = hints.get(EncodeHintType.CHARACTER_SET).toString();
|
encoding = hints.get(EncodeHintType.CHARACTER_SET).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,13 +92,20 @@ public final class Encoder {
|
|||||||
BitArray headerBits = new BitArray();
|
BitArray headerBits = new BitArray();
|
||||||
|
|
||||||
// Append ECI segment if applicable
|
// Append ECI segment if applicable
|
||||||
if (mode == Mode.BYTE && !DEFAULT_BYTE_MODE_ENCODING.equals(encoding)) {
|
if (mode == Mode.BYTE && hasEncodingHint) {
|
||||||
CharacterSetECI eci = CharacterSetECI.getCharacterSetECIByName(encoding);
|
CharacterSetECI eci = CharacterSetECI.getCharacterSetECIByName(encoding);
|
||||||
if (eci != null) {
|
if (eci != null) {
|
||||||
appendECI(eci, headerBits);
|
appendECI(eci, headerBits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Append the FNC1 mode header for GS1 formatted data if applicable
|
||||||
|
boolean hasGS1FormatHint = hints != null && hints.containsKey(EncodeHintType.GS1_FORMAT);
|
||||||
|
if (hasGS1FormatHint && Boolean.parseBoolean(hints.get(EncodeHintType.GS1_FORMAT).toString())) {
|
||||||
|
// GS1 formatted codes are prefixed with a FNC1 in first position mode header
|
||||||
|
appendModeInfo(Mode.FNC1_FIRST_POSITION, headerBits);
|
||||||
|
}
|
||||||
|
|
||||||
// (With ECI in place,) Write the mode marker
|
// (With ECI in place,) Write the mode marker
|
||||||
appendModeInfo(mode, headerBits);
|
appendModeInfo(mode, headerBits);
|
||||||
|
|
||||||
@ -147,7 +155,17 @@ public final class Encoder {
|
|||||||
// Choose the mask pattern and set to "qrCode".
|
// Choose the mask pattern and set to "qrCode".
|
||||||
int dimension = version.getDimensionForVersion();
|
int dimension = version.getDimensionForVersion();
|
||||||
ByteMatrix matrix = new ByteMatrix(dimension, dimension);
|
ByteMatrix matrix = new ByteMatrix(dimension, dimension);
|
||||||
int maskPattern = chooseMaskPattern(finalBits, ecLevel, version, matrix);
|
|
||||||
|
// Enable manual selection of the pattern to be used via hint
|
||||||
|
int maskPattern = -1;
|
||||||
|
if (hints != null && hints.containsKey(EncodeHintType.QR_MASK_PATTERN)) {
|
||||||
|
int hintMaskPattern = Integer.parseInt(hints.get(EncodeHintType.QR_MASK_PATTERN).toString());
|
||||||
|
maskPattern = QRCode.isValidMaskPattern(hintMaskPattern) ? hintMaskPattern : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maskPattern == -1) {
|
||||||
|
maskPattern = chooseMaskPattern(finalBits, ecLevel, version, matrix);
|
||||||
|
}
|
||||||
qrCode.setMaskPattern(maskPattern);
|
qrCode.setMaskPattern(maskPattern);
|
||||||
|
|
||||||
// Build the matrix and set it to "qrCode".
|
// Build the matrix and set it to "qrCode".
|
||||||
@ -581,8 +599,11 @@ public final class Encoder {
|
|||||||
} catch (UnsupportedEncodingException uee) {
|
} catch (UnsupportedEncodingException uee) {
|
||||||
throw new WriterException(uee);
|
throw new WriterException(uee);
|
||||||
}
|
}
|
||||||
int length = bytes.length;
|
if (bytes.length % 2 != 0) {
|
||||||
for (int i = 0; i < length; i += 2) {
|
throw new WriterException("Kanji byte size not even");
|
||||||
|
}
|
||||||
|
int maxI = bytes.length - 1; // bytes.length must be even
|
||||||
|
for (int i = 0; i < maxI; i += 2) {
|
||||||
int byte1 = bytes[i] & 0xFF;
|
int byte1 = bytes[i] & 0xFF;
|
||||||
int byte2 = bytes[i + 1] & 0xFF;
|
int byte2 = bytes[i + 1] & 0xFF;
|
||||||
int code = (byte1 << 8) | byte2;
|
int code = (byte1 << 8) | byte2;
|
||||||
|
@ -52,9 +52,10 @@ final class MaskUtil {
|
|||||||
int width = matrix.getWidth();
|
int width = matrix.getWidth();
|
||||||
int height = matrix.getHeight();
|
int height = matrix.getHeight();
|
||||||
for (int y = 0; y < height - 1; y++) {
|
for (int y = 0; y < height - 1; y++) {
|
||||||
|
byte[] arrayY = array[y];
|
||||||
for (int x = 0; x < width - 1; x++) {
|
for (int x = 0; x < width - 1; x++) {
|
||||||
int value = array[y][x];
|
int value = arrayY[x];
|
||||||
if (value == array[y][x + 1] && value == array[y + 1][x] && value == array[y + 1][x + 1]) {
|
if (value == arrayY[x + 1] && value == array[y + 1][x] && value == array[y + 1][x + 1]) {
|
||||||
penalty++;
|
penalty++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,6 @@ import com.google.zxing.qrcode.decoder.Version;
|
|||||||
*/
|
*/
|
||||||
final class MatrixUtil {
|
final class MatrixUtil {
|
||||||
|
|
||||||
private MatrixUtil() {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int[][] POSITION_DETECTION_PATTERN = {
|
private static final int[][] POSITION_DETECTION_PATTERN = {
|
||||||
{1, 1, 1, 1, 1, 1, 1},
|
{1, 1, 1, 1, 1, 1, 1},
|
||||||
{1, 0, 0, 0, 0, 0, 1},
|
{1, 0, 0, 0, 0, 0, 1},
|
||||||
@ -119,6 +115,10 @@ final class MatrixUtil {
|
|||||||
private static final int TYPE_INFO_POLY = 0x537;
|
private static final int TYPE_INFO_POLY = 0x537;
|
||||||
private static final int TYPE_INFO_MASK_PATTERN = 0x5412;
|
private static final int TYPE_INFO_MASK_PATTERN = 0x5412;
|
||||||
|
|
||||||
|
private MatrixUtil() {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
// Set all cells to -1. -1 means that the cell is empty (not set yet).
|
// Set all cells to -1. -1 means that the cell is empty (not set yet).
|
||||||
//
|
//
|
||||||
// JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding
|
// JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding
|
||||||
@ -174,21 +174,23 @@ final class MatrixUtil {
|
|||||||
boolean bit = typeInfoBits.get(typeInfoBits.getSize() - 1 - i);
|
boolean bit = typeInfoBits.get(typeInfoBits.getSize() - 1 - i);
|
||||||
|
|
||||||
// Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46).
|
// Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46).
|
||||||
int x1 = TYPE_INFO_COORDINATES[i][0];
|
int[] coordinates = TYPE_INFO_COORDINATES[i];
|
||||||
int y1 = TYPE_INFO_COORDINATES[i][1];
|
int x1 = coordinates[0];
|
||||||
|
int y1 = coordinates[1];
|
||||||
matrix.set(x1, y1, bit);
|
matrix.set(x1, y1, bit);
|
||||||
|
|
||||||
|
int x2;
|
||||||
|
int y2;
|
||||||
if (i < 8) {
|
if (i < 8) {
|
||||||
// Right top corner.
|
// Right top corner.
|
||||||
int x2 = matrix.getWidth() - i - 1;
|
x2 = matrix.getWidth() - i - 1;
|
||||||
int y2 = 8;
|
y2 = 8;
|
||||||
matrix.set(x2, y2, bit);
|
|
||||||
} else {
|
} else {
|
||||||
// Left bottom corner.
|
// Left bottom corner.
|
||||||
int x2 = 8;
|
x2 = 8;
|
||||||
int y2 = matrix.getHeight() - 7 + (i - 8);
|
y2 = matrix.getHeight() - 7 + (i - 8);
|
||||||
matrix.set(x2, y2, bit);
|
|
||||||
}
|
}
|
||||||
|
matrix.set(x2, y2, bit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +300,7 @@ final class MatrixUtil {
|
|||||||
// The return value is 0xc94 (1100 1001 0100)
|
// The return value is 0xc94 (1100 1001 0100)
|
||||||
//
|
//
|
||||||
// Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit
|
// Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit
|
||||||
// operations. We don't care if cofficients are positive or negative.
|
// operations. We don't care if coefficients are positive or negative.
|
||||||
static int calculateBCHCode(int value, int poly) {
|
static int calculateBCHCode(int value, int poly) {
|
||||||
if (poly == 0) {
|
if (poly == 0) {
|
||||||
throw new IllegalArgumentException("0 polynomial");
|
throw new IllegalArgumentException("0 polynomial");
|
||||||
@ -401,21 +403,20 @@ final class MatrixUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that we cannot unify the function with embedPositionDetectionPattern() despite they are
|
|
||||||
// almost identical, since we cannot write a function that takes 2D arrays in different sizes in
|
|
||||||
// C/C++. We should live with the fact.
|
|
||||||
private static void embedPositionAdjustmentPattern(int xStart, int yStart, ByteMatrix matrix) {
|
private static void embedPositionAdjustmentPattern(int xStart, int yStart, ByteMatrix matrix) {
|
||||||
for (int y = 0; y < 5; ++y) {
|
for (int y = 0; y < 5; ++y) {
|
||||||
|
int[] patternY = POSITION_ADJUSTMENT_PATTERN[y];
|
||||||
for (int x = 0; x < 5; ++x) {
|
for (int x = 0; x < 5; ++x) {
|
||||||
matrix.set(xStart + x, yStart + y, POSITION_ADJUSTMENT_PATTERN[y][x]);
|
matrix.set(xStart + x, yStart + y, patternY[x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void embedPositionDetectionPattern(int xStart, int yStart, ByteMatrix matrix) {
|
private static void embedPositionDetectionPattern(int xStart, int yStart, ByteMatrix matrix) {
|
||||||
for (int y = 0; y < 7; ++y) {
|
for (int y = 0; y < 7; ++y) {
|
||||||
|
int[] patternY = POSITION_DETECTION_PATTERN[y];
|
||||||
for (int x = 0; x < 7; ++x) {
|
for (int x = 0; x < 7; ++x) {
|
||||||
matrix.set(xStart + x, yStart + y, POSITION_DETECTION_PATTERN[y][x]);
|
matrix.set(xStart + x, yStart + y, patternY[x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -459,16 +460,11 @@ final class MatrixUtil {
|
|||||||
}
|
}
|
||||||
int index = version.getVersionNumber() - 1;
|
int index = version.getVersionNumber() - 1;
|
||||||
int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
|
int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
|
||||||
int numCoordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index].length;
|
for (int y : coordinates) {
|
||||||
for (int i = 0; i < numCoordinates; ++i) {
|
if (y >= 0) {
|
||||||
for (int j = 0; j < numCoordinates; ++j) {
|
for (int x : coordinates) {
|
||||||
int y = coordinates[i];
|
if (x >= 0 && isEmpty(matrix.get(x, y))) {
|
||||||
int x = coordinates[j];
|
|
||||||
if (x == -1 || y == -1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// If the cell is unset, we embed the position adjustment pattern here.
|
// If the cell is unset, we embed the position adjustment pattern here.
|
||||||
if (isEmpty(matrix.get(x, y))) {
|
|
||||||
// -2 is necessary since the x/y coordinates point to the center of the pattern, not the
|
// -2 is necessary since the x/y coordinates point to the center of the pattern, not the
|
||||||
// left top corner.
|
// left top corner.
|
||||||
embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
|
embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
|
||||||
@ -476,5 +472,6 @@ final class MatrixUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user