diff --git a/port_src/core/DONE/BarcodeFormat.java b/port_src/core/DONE/BarcodeFormat.java deleted file mode 100644 index 7f6a0ef..0000000 --- a/port_src/core/DONE/BarcodeFormat.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * Enumerates barcode formats known to this package. Please keep alphabetized. - * - * @author Sean Owen - */ -public enum BarcodeFormat { - - /** Aztec 2D barcode format. */ - AZTEC, - - /** CODABAR 1D format. */ - CODABAR, - - /** Code 39 1D format. */ - CODE_39, - - /** Code 93 1D format. */ - CODE_93, - - /** Code 128 1D format. */ - CODE_128, - - /** Data Matrix 2D barcode format. */ - DATA_MATRIX, - - /** EAN-8 1D format. */ - EAN_8, - - /** EAN-13 1D format. */ - EAN_13, - - /** ITF (Interleaved Two of Five) 1D format. */ - ITF, - - /** MaxiCode 2D barcode format. */ - MAXICODE, - - /** PDF417 format. */ - PDF_417, - - /** QR Code 2D barcode format. */ - QR_CODE, - - /** RSS 14 */ - RSS_14, - - /** RSS EXPANDED */ - RSS_EXPANDED, - - /** UPC-A 1D format. */ - UPC_A, - - /** UPC-E 1D format. */ - UPC_E, - - /** UPC/EAN extension format. Not a stand-alone format. */ - UPC_EAN_EXTENSION - -} diff --git a/port_src/core/DONE/Binarizer.java b/port_src/core/DONE/Binarizer.java deleted file mode 100644 index 02af083..0000000 --- a/port_src/core/DONE/Binarizer.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import com.google.zxing.common.BitArray; -import com.google.zxing.common.BitMatrix; - -/** - * This class hierarchy provides a set of methods to convert luminance data to 1 bit data. - * It allows the algorithm to vary polymorphically, for example allowing a very expensive - * thresholding technique for servers and a fast one for mobile. It also permits the implementation - * to vary, e.g. a JNI version for Android and a Java fallback version for other platforms. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public abstract class Binarizer { - - private final LuminanceSource source; - - protected Binarizer(LuminanceSource source) { - this.source = source; - } - - public final LuminanceSource getLuminanceSource() { - return source; - } - - /** - * Converts one row of luminance data to 1 bit data. May actually do the conversion, or return - * cached data. Callers should assume this method is expensive and call it as seldom as possible. - * This method is intended for decoding 1D barcodes and may choose to apply sharpening. - * For callers which only examine one row of pixels at a time, the same BitArray should be reused - * and passed in with each call for performance. However it is legal to keep more than one row - * at a time if needed. - * - * @param y The row to fetch, which must be in [0, bitmap height) - * @param row An optional preallocated array. If null or too small, it will be ignored. - * If used, the Binarizer will call BitArray.clear(). Always use the returned object. - * @return The array of bits for this row (true means black). - * @throws NotFoundException if row can't be binarized - */ - public abstract BitArray getBlackRow(int y, BitArray row) throws NotFoundException; - - /** - * Converts a 2D array of luminance data to 1 bit data. As above, assume this method is expensive - * and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or - * may not apply sharpening. Therefore, a row from this matrix may not be identical to one - * fetched using getBlackRow(), so don't mix and match between them. - * - * @return The 2D array of bits for the image (true means black). - * @throws NotFoundException if image can't be binarized to make a matrix - */ - public abstract BitMatrix getBlackMatrix() throws NotFoundException; - - /** - * Creates a new object with the same type as this Binarizer implementation, but with pristine - * state. This is needed because Binarizer implementations may be stateful, e.g. keeping a cache - * of 1 bit data. See Effective Java for why we can't use Java's clone() method. - * - * @param source The LuminanceSource this Binarizer will operate on. - * @return A new concrete Binarizer implementation object. - */ - public abstract Binarizer createBinarizer(LuminanceSource source); - - public final int getWidth() { - return source.getWidth(); - } - - public final int getHeight() { - return source.getHeight(); - } - -} diff --git a/port_src/core/DONE/BinaryBitmap.java b/port_src/core/DONE/BinaryBitmap.java deleted file mode 100644 index c1ef8a1..0000000 --- a/port_src/core/DONE/BinaryBitmap.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import com.google.zxing.common.BitArray; -import com.google.zxing.common.BitMatrix; - -/** - * This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects - * accept a BinaryBitmap and attempt to decode it. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class BinaryBitmap { - - private final Binarizer binarizer; - private BitMatrix matrix; - - public BinaryBitmap(Binarizer binarizer) { - if (binarizer == null) { - throw new IllegalArgumentException("Binarizer must be non-null."); - } - this.binarizer = binarizer; - } - - /** - * @return The width of the bitmap. - */ - public int getWidth() { - return binarizer.getWidth(); - } - - /** - * @return The height of the bitmap. - */ - public int getHeight() { - return binarizer.getHeight(); - } - - /** - * Converts one row of luminance data to 1 bit data. May actually do the conversion, or return - * cached data. Callers should assume this method is expensive and call it as seldom as possible. - * This method is intended for decoding 1D barcodes and may choose to apply sharpening. - * - * @param y The row to fetch, which must be in [0, bitmap height) - * @param row An optional preallocated array. If null or too small, it will be ignored. - * If used, the Binarizer will call BitArray.clear(). Always use the returned object. - * @return The array of bits for this row (true means black). - * @throws NotFoundException if row can't be binarized - */ - public BitArray getBlackRow(int y, BitArray row) throws NotFoundException { - return binarizer.getBlackRow(y, row); - } - - /** - * Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive - * and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or - * may not apply sharpening. Therefore, a row from this matrix may not be identical to one - * fetched using getBlackRow(), so don't mix and match between them. - * - * @return The 2D array of bits for the image (true means black). - * @throws NotFoundException if image can't be binarized to make a matrix - */ - public BitMatrix getBlackMatrix() throws NotFoundException { - // The matrix is created on demand the first time it is requested, then cached. There are two - // reasons for this: - // 1. This work will never be done if the caller only installs 1D Reader objects, or if a - // 1D Reader finds a barcode before the 2D Readers run. - // 2. This work will only be done once even if the caller installs multiple 2D Readers. - if (matrix == null) { - matrix = binarizer.getBlackMatrix(); - } - return matrix; - } - - /** - * @return Whether this bitmap can be cropped. - */ - public boolean isCropSupported() { - return binarizer.getLuminanceSource().isCropSupported(); - } - - /** - * Returns a new object with cropped image data. Implementations may keep a reference to the - * original data rather than a copy. Only callable if isCropSupported() is true. - * - * @param left The left coordinate, which must be in [0,getWidth()) - * @param top The top coordinate, which must be in [0,getHeight()) - * @param width The width of the rectangle to crop. - * @param height The height of the rectangle to crop. - * @return A cropped version of this object. - */ - public BinaryBitmap crop(int left, int top, int width, int height) { - LuminanceSource newSource = binarizer.getLuminanceSource().crop(left, top, width, height); - return new BinaryBitmap(binarizer.createBinarizer(newSource)); - } - - /** - * @return Whether this bitmap supports counter-clockwise rotation. - */ - public boolean isRotateSupported() { - return binarizer.getLuminanceSource().isRotateSupported(); - } - - /** - * Returns a new object with rotated image data by 90 degrees counterclockwise. - * Only callable if {@link #isRotateSupported()} is true. - * - * @return A rotated version of this object. - */ - public BinaryBitmap rotateCounterClockwise() { - LuminanceSource newSource = binarizer.getLuminanceSource().rotateCounterClockwise(); - return new BinaryBitmap(binarizer.createBinarizer(newSource)); - } - - /** - * Returns a new object with rotated image data by 45 degrees counterclockwise. - * Only callable if {@link #isRotateSupported()} is true. - * - * @return A rotated version of this object. - */ - public BinaryBitmap rotateCounterClockwise45() { - LuminanceSource newSource = binarizer.getLuminanceSource().rotateCounterClockwise45(); - return new BinaryBitmap(binarizer.createBinarizer(newSource)); - } - - @Override - public String toString() { - try { - return getBlackMatrix().toString(); - } catch (NotFoundException e) { - return ""; - } - } - -} diff --git a/port_src/core/DONE/ChecksumException.java b/port_src/core/DONE/ChecksumException.java deleted file mode 100644 index c5acbe3..0000000 --- a/port_src/core/DONE/ChecksumException.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * Thrown when a barcode was successfully detected and decoded, but - * was not returned because its checksum feature failed. - * - * @author Sean Owen - */ -public final class ChecksumException extends ReaderException { - - private static final ChecksumException INSTANCE = new ChecksumException(); - static { - INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless - } - - private ChecksumException() { - // do nothing - } - - private ChecksumException(Throwable cause) { - super(cause); - } - - public static ChecksumException getChecksumInstance() { - return isStackTrace ? new ChecksumException() : INSTANCE; - } - - public static ChecksumException getChecksumInstance(Throwable cause) { - return isStackTrace ? new ChecksumException(cause) : INSTANCE; - } -} \ No newline at end of file diff --git a/port_src/core/DONE/DecodeHintType.java b/port_src/core/DONE/DecodeHintType.java deleted file mode 100644 index a532750..0000000 --- a/port_src/core/DONE/DecodeHintType.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import java.util.List; - -/** - * Encapsulates a type of hint that a caller may pass to a barcode reader to help it - * more quickly or accurately decode it. It is up to implementations to decide what, - * if anything, to do with the information that is supplied. - * - * @author Sean Owen - * @author dswitkin@google.com (Daniel Switkin) - * @see Reader#decode(BinaryBitmap,java.util.Map) - */ -public enum DecodeHintType { - - /** - * Unspecified, application-specific hint. Maps to an unspecified {@link Object}. - */ - OTHER(Object.class), - - /** - * Image is a pure monochrome image of a barcode. Doesn't matter what it maps to; - * use {@link Boolean#TRUE}. - */ - PURE_BARCODE(Void.class), - - /** - * Image is known to be of one of a few possible formats. - * Maps to a {@link List} of {@link BarcodeFormat}s. - */ - POSSIBLE_FORMATS(List.class), - - /** - * Spend more time to try to find a barcode; optimize for accuracy, not speed. - * Doesn't matter what it maps to; use {@link Boolean#TRUE}. - */ - TRY_HARDER(Void.class), - - /** - * Specifies what character encoding to use when decoding, where applicable (type String) - */ - CHARACTER_SET(String.class), - - /** - * Allowed lengths of encoded data -- reject anything else. Maps to an {@code int[]}. - */ - ALLOWED_LENGTHS(int[].class), - - /** - * Assume Code 39 codes employ a check digit. Doesn't matter what it maps to; - * use {@link Boolean#TRUE}. - */ - ASSUME_CODE_39_CHECK_DIGIT(Void.class), - - /** - * Assume the barcode is being processed as a GS1 barcode, and modify behavior as needed. - * For example this affects FNC1 handling for Code 128 (aka GS1-128). Doesn't matter what it maps to; - * use {@link Boolean#TRUE}. - */ - ASSUME_GS1(Void.class), - - /** - * If true, return the start and end digits in a Codabar barcode instead of stripping them. They - * are alpha, whereas the rest are numeric. By default, they are stripped, but this causes them - * to not be. Doesn't matter what it maps to; use {@link Boolean#TRUE}. - */ - RETURN_CODABAR_START_END(Void.class), - - /** - * The caller needs to be notified via callback when a possible {@link ResultPoint} - * is found. Maps to a {@link ResultPointCallback}. - */ - NEED_RESULT_POINT_CALLBACK(ResultPointCallback.class), - - - /** - * Allowed extension lengths for EAN or UPC barcodes. Other formats will ignore this. - * Maps to an {@code int[]} of the allowed extension lengths, for example [2], [5], or [2, 5]. - * If it is optional to have an extension, do not set this hint. If this is set, - * and a UPC or EAN barcode is found but an extension is not, then no result will be returned - * at all. - */ - ALLOWED_EAN_EXTENSIONS(int[].class), - - /** - * If true, also tries to decode as inverted image. All configured decoders are simply called a - * second time with an inverted image. Doesn't matter what it maps to; use {@link Boolean#TRUE}. - */ - ALSO_INVERTED(Void.class), - - // End of enumeration values. - ; - - /** - * Data type the hint is expecting. - * Among the possible values the {@link Void} stands out as being used for - * hints that do not expect a value to be supplied (flag hints). Such hints - * will possibly have their value ignored, or replaced by a - * {@link Boolean#TRUE}. Hint suppliers should probably use - * {@link Boolean#TRUE} as directed by the actual hint documentation. - */ - private final Class valueType; - - DecodeHintType(Class valueType) { - this.valueType = valueType; - } - - public Class getValueType() { - return valueType; - } - -} diff --git a/port_src/core/DONE/Dimension.java b/port_src/core/DONE/Dimension.java deleted file mode 100644 index 242e0f7..0000000 --- a/port_src/core/DONE/Dimension.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * Simply encapsulates a width and height. - */ -public final class Dimension { - - private final int width; - private final int height; - - public Dimension(int width, int height) { - if (width < 0 || height < 0) { - throw new IllegalArgumentException(); - } - this.width = width; - this.height = height; - } - - public int getWidth() { - return width; - } - - public int getHeight() { - return height; - } - - @Override - public boolean equals(Object other) { - if (other instanceof Dimension) { - Dimension d = (Dimension) other; - return width == d.width && height == d.height; - } - return false; - } - - @Override - public int hashCode() { - return width * 32713 + height; - } - - @Override - public String toString() { - return width + "x" + height; - } - -} diff --git a/port_src/core/DONE/EncodeHintType.java b/port_src/core/DONE/EncodeHintType.java deleted file mode 100644 index f94b575..0000000 --- a/port_src/core/DONE/EncodeHintType.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * These are a set of hints that you may pass to Writers to specify their behavior. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public enum EncodeHintType { - - /** - * Specifies what degree of error correction to use, for example in QR Codes. - * Type depends on the encoder. For example for QR codes it's type - * {@link com.google.zxing.qrcode.decoder.ErrorCorrectionLevel ErrorCorrectionLevel}. - * For Aztec it is of type {@link Integer}, representing the minimal percentage of error correction words. - * For PDF417 it is of type {@link Integer}, valid values being 0 to 8. - * In all cases, it can also be a {@link String} representation of the desired value as well. - * Note: an Aztec symbol should have a minimum of 25% EC words. - */ - ERROR_CORRECTION, - - /** - * Specifies what character encoding to use where applicable (type {@link String}) - */ - CHARACTER_SET, - - /** - * Specifies the matrix shape for Data Matrix (type {@link com.google.zxing.datamatrix.encoder.SymbolShapeHint}) - */ - DATA_MATRIX_SHAPE, - - /** - * Specifies whether to use compact mode for Data Matrix (type {@link Boolean}, or "true" or "false" - * {@link String } value). - * The compact encoding mode also supports the encoding of characters that are not in the ISO-8859-1 - * character set via ECIs. - * Please note that in that case, the most compact character encoding is chosen for characters in - * the input that are not in the ISO-8859-1 character set. Based on experience, some scanners do not - * support encodings like cp-1256 (Arabic). In such cases the encoding can be forced to UTF-8 by - * means of the {@link #CHARACTER_SET} encoding hint. - * Compact encoding also provides GS1-FNC1 support when {@link #GS1_FORMAT} is selected. In this case - * group-separator character (ASCII 29 decimal) can be used to encode the positions of FNC1 codewords - * for the purpose of delimiting AIs. - * This option and {@link #FORCE_C40} are mutually exclusive. - */ - DATA_MATRIX_COMPACT, - - /** - * Specifies a minimum barcode size (type {@link Dimension}). Only applicable to Data Matrix now. - * - * @deprecated use width/height params in - * {@link com.google.zxing.datamatrix.DataMatrixWriter#encode(String, BarcodeFormat, int, int)} - */ - @Deprecated - MIN_SIZE, - - /** - * Specifies a maximum barcode size (type {@link Dimension}). Only applicable to Data Matrix now. - * - * @deprecated without replacement - */ - @Deprecated - MAX_SIZE, - - /** - * Specifies margin, in pixels, to use when generating the barcode. The meaning can vary - * by format; for example it controls margin before and after the barcode horizontally for - * most 1D formats. (Type {@link Integer}, or {@link String} representation of the integer value). - */ - MARGIN, - - /** - * Specifies whether to use compact mode for PDF417 (type {@link Boolean}, or "true" or "false" - * {@link String} value). - */ - PDF417_COMPACT, - - /** - * Specifies what compaction mode to use for PDF417 (type - * {@link com.google.zxing.pdf417.encoder.Compaction Compaction} or {@link String} value of one of its - * enum values). - */ - PDF417_COMPACTION, - - /** - * Specifies the minimum and maximum number of rows and columns for PDF417 (type - * {@link com.google.zxing.pdf417.encoder.Dimensions Dimensions}). - */ - PDF417_DIMENSIONS, - - /** - * Specifies whether to automatically insert ECIs when encoding PDF417 (type {@link Boolean}, or "true" or "false" - * {@link String} value). - * Please note that in that case, the most compact character encoding is chosen for characters in - * the input that are not in the ISO-8859-1 character set. Based on experience, some scanners do not - * support encodings like cp-1256 (Arabic). In such cases the encoding can be forced to UTF-8 by - * means of the {@link #CHARACTER_SET} encoding hint. - */ - PDF417_AUTO_ECI, - - /** - * Specifies the required number of layers for an Aztec code. - * A negative number (-1, -2, -3, -4) specifies a compact Aztec code. - * 0 indicates to use the minimum number of layers (the default). - * A positive number (1, 2, .. 32) specifies a normal (non-compact) Aztec code. - * (Type {@link Integer}, or {@link String} representation of the integer value). - */ - AZTEC_LAYERS, - - /** - * Specifies the exact version of QR code to be encoded. - * (Type {@link Integer}, or {@link String} representation of the integer value). - */ - 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 to use compact mode for QR code (type {@link Boolean}, or "true" or "false" - * {@link String } value). - * Please note that when compaction is performed, the most compact character encoding is chosen - * for characters in the input that are not in the ISO-8859-1 character set. Based on experience, - * some scanners do not support encodings like cp-1256 (Arabic). In such cases the encoding can - * be forced to UTF-8 by means of the {@link #CHARACTER_SET} encoding hint. - */ - QR_COMPACT, - - /** - * Specifies whether the data should be encoded to the GS1 standard (type {@link Boolean}, or "true" or "false" - * {@link String } value). - */ - GS1_FORMAT, - - /** - * Forces which encoding will be used. Currently only used for Code-128 code sets (Type {@link String}). - * Valid values are "A", "B", "C". - * This option and {@link #CODE128_COMPACT} are mutually exclusive. - */ - FORCE_CODE_SET, - - /** - * Forces C40 encoding for data-matrix (type {@link Boolean}, or "true" or "false") {@link String } value). This - * option and {@link #DATA_MATRIX_COMPACT} are mutually exclusive. - */ - FORCE_C40, - - /** - * Specifies whether to use compact mode for Code-128 code (type {@link Boolean}, or "true" or "false" - * {@link String } value). - * This can yield slightly smaller bar codes. This option and {@link #FORCE_CODE_SET} are mutually - * exclusive. - */ - CODE128_COMPACT, - -} diff --git a/port_src/core/DONE/FormatException.java b/port_src/core/DONE/FormatException.java deleted file mode 100644 index ebd8008..0000000 --- a/port_src/core/DONE/FormatException.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * Thrown when a barcode was successfully detected, but some aspect of - * the content did not conform to the barcode's format rules. This could have - * been due to a mis-detection. - * - * @author Sean Owen - */ -public final class FormatException extends ReaderException { - - private static final FormatException INSTANCE = new FormatException(); - static { - INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless - } - - private FormatException() { - } - - private FormatException(Throwable cause) { - super(cause); - } - - public static FormatException getFormatInstance() { - return isStackTrace ? new FormatException() : INSTANCE; - } - - public static FormatException getFormatInstance(Throwable cause) { - return isStackTrace ? new FormatException(cause) : INSTANCE; - } -} diff --git a/port_src/core/DONE/InvertedLuminanceSource.java b/port_src/core/DONE/InvertedLuminanceSource.java deleted file mode 100644 index a64e15d..0000000 --- a/port_src/core/DONE/InvertedLuminanceSource.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * A wrapper implementation of {@link LuminanceSource} which inverts the luminances it returns -- black becomes - * white and vice versa, and each value becomes (255-value). - * - * @author Sean Owen - */ -public final class InvertedLuminanceSource extends LuminanceSource { - - private final LuminanceSource delegate; - - public InvertedLuminanceSource(LuminanceSource delegate) { - super(delegate.getWidth(), delegate.getHeight()); - this.delegate = delegate; - } - - @Override - public byte[] getRow(int y, byte[] row) { - row = delegate.getRow(y, row); - int width = getWidth(); - for (int i = 0; i < width; i++) { - row[i] = (byte) (255 - (row[i] & 0xFF)); - } - return row; - } - - @Override - public byte[] getMatrix() { - byte[] matrix = delegate.getMatrix(); - int length = getWidth() * getHeight(); - byte[] invertedMatrix = new byte[length]; - for (int i = 0; i < length; i++) { - invertedMatrix[i] = (byte) (255 - (matrix[i] & 0xFF)); - } - return invertedMatrix; - } - - @Override - public boolean isCropSupported() { - return delegate.isCropSupported(); - } - - @Override - public LuminanceSource crop(int left, int top, int width, int height) { - return new InvertedLuminanceSource(delegate.crop(left, top, width, height)); - } - - @Override - public boolean isRotateSupported() { - return delegate.isRotateSupported(); - } - - /** - * @return original delegate {@link LuminanceSource} since invert undoes itself - */ - @Override - public LuminanceSource invert() { - return delegate; - } - - @Override - public LuminanceSource rotateCounterClockwise() { - return new InvertedLuminanceSource(delegate.rotateCounterClockwise()); - } - - @Override - public LuminanceSource rotateCounterClockwise45() { - return new InvertedLuminanceSource(delegate.rotateCounterClockwise45()); - } - -} diff --git a/port_src/core/DONE/LuminanceSource.java b/port_src/core/DONE/LuminanceSource.java deleted file mode 100644 index 1946d02..0000000 --- a/port_src/core/DONE/LuminanceSource.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * The purpose of this class hierarchy is to abstract different bitmap implementations across - * platforms into a standard interface for requesting greyscale luminance values. The interface - * only provides immutable methods; therefore crop and rotation create copies. This is to ensure - * that one Reader does not modify the original luminance source and leave it in an unknown state - * for other Readers in the chain. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public abstract class LuminanceSource { - - private final int width; - private final int height; - - protected LuminanceSource(int width, int height) { - this.width = width; - this.height = height; - } - - /** - * Fetches one row of luminance data from the underlying platform's bitmap. Values range from - * 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have - * to bitwise and with 0xff for each value. It is preferable for implementations of this method - * to only fetch this row rather than the whole image, since no 2D Readers may be installed and - * getMatrix() may never be called. - * - * @param y The row to fetch, which must be in [0,getHeight()) - * @param row An optional preallocated array. If null or too small, it will be ignored. - * Always use the returned object, and ignore the .length of the array. - * @return An array containing the luminance data. - */ - public abstract byte[] getRow(int y, byte[] row); - - /** - * Fetches luminance data for the underlying bitmap. Values should be fetched using: - * {@code int luminance = array[y * width + x] & 0xff} - * - * @return A row-major 2D array of luminance values. Do not use result.length as it may be - * larger than width * height bytes on some platforms. Do not modify the contents - * of the result. - */ - public abstract byte[] getMatrix(); - - /** - * @return The width of the bitmap. - */ - public final int getWidth() { - return width; - } - - /** - * @return The height of the bitmap. - */ - public final int getHeight() { - return height; - } - - /** - * @return Whether this subclass supports cropping. - */ - public boolean isCropSupported() { - return false; - } - - /** - * Returns a new object with cropped image data. Implementations may keep a reference to the - * original data rather than a copy. Only callable if isCropSupported() is true. - * - * @param left The left coordinate, which must be in [0,getWidth()) - * @param top The top coordinate, which must be in [0,getHeight()) - * @param width The width of the rectangle to crop. - * @param height The height of the rectangle to crop. - * @return A cropped version of this object. - */ - public LuminanceSource crop(int left, int top, int width, int height) { - throw new UnsupportedOperationException("This luminance source does not support cropping."); - } - - /** - * @return Whether this subclass supports counter-clockwise rotation. - */ - public boolean isRotateSupported() { - return false; - } - - /** - * @return a wrapper of this {@code LuminanceSource} which inverts the luminances it returns -- black becomes - * white and vice versa, and each value becomes (255-value). - */ - public LuminanceSource invert() { - return new InvertedLuminanceSource(this); - } - - /** - * Returns a new object with rotated image data by 90 degrees counterclockwise. - * Only callable if {@link #isRotateSupported()} is true. - * - * @return A rotated version of this object. - */ - public LuminanceSource rotateCounterClockwise() { - throw new UnsupportedOperationException("This luminance source does not support rotation by 90 degrees."); - } - - /** - * Returns a new object with rotated image data by 45 degrees counterclockwise. - * Only callable if {@link #isRotateSupported()} is true. - * - * @return A rotated version of this object. - */ - public LuminanceSource rotateCounterClockwise45() { - throw new UnsupportedOperationException("This luminance source does not support rotation by 45 degrees."); - } - - @Override - public final String toString() { - byte[] row = new byte[width]; - StringBuilder result = new StringBuilder(height * (width + 1)); - for (int y = 0; y < height; y++) { - row = getRow(y, row); - for (int x = 0; x < width; x++) { - int luminance = row[x] & 0xFF; - char c; - if (luminance < 0x40) { - c = '#'; - } else if (luminance < 0x80) { - c = '+'; - } else if (luminance < 0xC0) { - c = '.'; - } else { - c = ' '; - } - result.append(c); - } - result.append('\n'); - } - return result.toString(); - } - -} diff --git a/port_src/core/DONE/MultiFormatReader.java b/port_src/core/DONE/MultiFormatReader.java deleted file mode 100644 index 5814729..0000000 --- a/port_src/core/DONE/MultiFormatReader.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import com.google.zxing.aztec.AztecReader; -import com.google.zxing.datamatrix.DataMatrixReader; -import com.google.zxing.maxicode.MaxiCodeReader; -import com.google.zxing.oned.MultiFormatOneDReader; -import com.google.zxing.pdf417.PDF417Reader; -import com.google.zxing.qrcode.QRCodeReader; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -/** - * MultiFormatReader is a convenience class and the main entry point into the library for most uses. - * By default it attempts to decode all barcode formats that the library supports. Optionally, you - * can provide a hints object to request different behavior, for example only decoding QR codes. - * - * @author Sean Owen - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class MultiFormatReader implements Reader { - - private static final Reader[] EMPTY_READER_ARRAY = new Reader[0]; - - private Map hints; - private Reader[] readers; - - /** - * This version of decode honors the intent of Reader.decode(BinaryBitmap) in that it - * passes null as a hint to the decoders. However, that makes it inefficient to call repeatedly. - * Use setHints() followed by decodeWithState() for continuous scan applications. - * - * @param image The pixel data to decode - * @return The contents of the image - * @throws NotFoundException Any errors which occurred - */ - @Override - public Result decode(BinaryBitmap image) throws NotFoundException { - setHints(null); - return decodeInternal(image); - } - - /** - * Decode an image using the hints provided. Does not honor existing state. - * - * @param image The pixel data to decode - * @param hints The hints to use, clearing the previous state. - * @return The contents of the image - * @throws NotFoundException Any errors which occurred - */ - @Override - public Result decode(BinaryBitmap image, Map hints) throws NotFoundException { - setHints(hints); - return decodeInternal(image); - } - - /** - * Decode an image using the state set up by calling setHints() previously. Continuous scan - * clients will get a large speed increase by using this instead of decode(). - * - * @param image The pixel data to decode - * @return The contents of the image - * @throws NotFoundException Any errors which occurred - */ - public Result decodeWithState(BinaryBitmap image) throws NotFoundException { - // Make sure to set up the default state so we don't crash - if (readers == null) { - setHints(null); - } - return decodeInternal(image); - } - - /** - * This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls - * to decodeWithState(image) can reuse the same set of readers without reallocating memory. This - * is important for performance in continuous scan clients. - * - * @param hints The set of hints to use for subsequent calls to decode(image) - */ - public void setHints(Map hints) { - this.hints = hints; - - boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); - @SuppressWarnings("unchecked") - Collection formats = - hints == null ? null : (Collection) hints.get(DecodeHintType.POSSIBLE_FORMATS); - Collection readers = new ArrayList<>(); - if (formats != null) { - boolean addOneDReader = - formats.contains(BarcodeFormat.UPC_A) || - formats.contains(BarcodeFormat.UPC_E) || - formats.contains(BarcodeFormat.EAN_13) || - formats.contains(BarcodeFormat.EAN_8) || - formats.contains(BarcodeFormat.CODABAR) || - formats.contains(BarcodeFormat.CODE_39) || - formats.contains(BarcodeFormat.CODE_93) || - formats.contains(BarcodeFormat.CODE_128) || - formats.contains(BarcodeFormat.ITF) || - formats.contains(BarcodeFormat.RSS_14) || - formats.contains(BarcodeFormat.RSS_EXPANDED); - // Put 1D readers upfront in "normal" mode - if (addOneDReader && !tryHarder) { - readers.add(new MultiFormatOneDReader(hints)); - } - if (formats.contains(BarcodeFormat.QR_CODE)) { - readers.add(new QRCodeReader()); - } - if (formats.contains(BarcodeFormat.DATA_MATRIX)) { - readers.add(new DataMatrixReader()); - } - if (formats.contains(BarcodeFormat.AZTEC)) { - readers.add(new AztecReader()); - } - if (formats.contains(BarcodeFormat.PDF_417)) { - readers.add(new PDF417Reader()); - } - if (formats.contains(BarcodeFormat.MAXICODE)) { - readers.add(new MaxiCodeReader()); - } - // At end in "try harder" mode - if (addOneDReader && tryHarder) { - readers.add(new MultiFormatOneDReader(hints)); - } - } - if (readers.isEmpty()) { - if (!tryHarder) { - readers.add(new MultiFormatOneDReader(hints)); - } - - readers.add(new QRCodeReader()); - readers.add(new DataMatrixReader()); - readers.add(new AztecReader()); - readers.add(new PDF417Reader()); - readers.add(new MaxiCodeReader()); - - if (tryHarder) { - readers.add(new MultiFormatOneDReader(hints)); - } - } - this.readers = readers.toArray(EMPTY_READER_ARRAY); - } - - @Override - public void reset() { - if (readers != null) { - for (Reader reader : readers) { - reader.reset(); - } - } - } - - private Result decodeInternal(BinaryBitmap image) throws NotFoundException { - if (readers != null) { - for (Reader reader : readers) { - if (Thread.currentThread().isInterrupted()) { - throw NotFoundException.getNotFoundInstance(); - } - try { - return reader.decode(image, hints); - } catch (ReaderException re) { - // continue - } - } - if (hints != null && hints.containsKey(DecodeHintType.ALSO_INVERTED)) { - // Calling all readers again with inverted image - image.getBlackMatrix().flip(); - for (Reader reader : readers) { - if (Thread.currentThread().isInterrupted()) { - throw NotFoundException.getNotFoundInstance(); - } - try { - return reader.decode(image, hints); - } catch (ReaderException re) { - // continue - } - } - } - } - throw NotFoundException.getNotFoundInstance(); - } - -} diff --git a/port_src/core/DONE/MultiFormatWriter.java b/port_src/core/DONE/MultiFormatWriter.java deleted file mode 100644 index 19c29a4..0000000 --- a/port_src/core/DONE/MultiFormatWriter.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import com.google.zxing.aztec.AztecWriter; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.datamatrix.DataMatrixWriter; -import com.google.zxing.oned.CodaBarWriter; -import com.google.zxing.oned.Code128Writer; -import com.google.zxing.oned.Code39Writer; -import com.google.zxing.oned.Code93Writer; -import com.google.zxing.oned.EAN13Writer; -import com.google.zxing.oned.EAN8Writer; -import com.google.zxing.oned.ITFWriter; -import com.google.zxing.oned.UPCAWriter; -import com.google.zxing.oned.UPCEWriter; -import com.google.zxing.pdf417.PDF417Writer; -import com.google.zxing.qrcode.QRCodeWriter; - -import java.util.Map; - -/** - * This is a factory class which finds the appropriate Writer subclass for the BarcodeFormat - * requested and encodes the barcode with the supplied contents. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class MultiFormatWriter implements Writer { - - @Override - public BitMatrix encode(String contents, - BarcodeFormat format, - int width, - int height) throws WriterException { - return encode(contents, format, width, height, null); - } - - @Override - public BitMatrix encode(String contents, - BarcodeFormat format, - int width, int height, - Map hints) throws WriterException { - - Writer writer; - switch (format) { - case EAN_8: - writer = new EAN8Writer(); - break; - case UPC_E: - writer = new UPCEWriter(); - break; - case EAN_13: - writer = new EAN13Writer(); - break; - case UPC_A: - writer = new UPCAWriter(); - break; - case QR_CODE: - writer = new QRCodeWriter(); - break; - case CODE_39: - writer = new Code39Writer(); - break; - case CODE_93: - writer = new Code93Writer(); - break; - case CODE_128: - writer = new Code128Writer(); - break; - case ITF: - writer = new ITFWriter(); - break; - case PDF_417: - writer = new PDF417Writer(); - break; - case CODABAR: - writer = new CodaBarWriter(); - break; - case DATA_MATRIX: - writer = new DataMatrixWriter(); - break; - case AZTEC: - writer = new AztecWriter(); - break; - default: - throw new IllegalArgumentException("No encoder available for format " + format); - } - return writer.encode(contents, format, width, height, hints); - } - -} diff --git a/port_src/core/DONE/NotFoundException.java b/port_src/core/DONE/NotFoundException.java deleted file mode 100644 index a00c3fe..0000000 --- a/port_src/core/DONE/NotFoundException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * Thrown when a barcode was not found in the image. It might have been - * partially detected but could not be confirmed. - * - * @author Sean Owen - */ -public final class NotFoundException extends ReaderException { - - private static final NotFoundException INSTANCE = new NotFoundException(); - static { - INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless - } - - private NotFoundException() { - // do nothing - } - - public static NotFoundException getNotFoundInstance() { - return isStackTrace ? new NotFoundException() : INSTANCE; - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/PlanarYUVLuminanceSource.java b/port_src/core/DONE/PlanarYUVLuminanceSource.java deleted file mode 100644 index cecff3e..0000000 --- a/port_src/core/DONE/PlanarYUVLuminanceSource.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * This object extends LuminanceSource around an array of YUV data returned from the camera driver, - * with the option to crop to a rectangle within the full data. This can be used to exclude - * superfluous pixels around the perimeter and speed up decoding. - * - * It works for any pixel format where the Y channel is planar and appears first, including - * YCbCr_420_SP and YCbCr_422_SP. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class PlanarYUVLuminanceSource extends LuminanceSource { - - private static final int THUMBNAIL_SCALE_FACTOR = 2; - - private final byte[] yuvData; - private final int dataWidth; - private final int dataHeight; - private final int left; - private final int top; - - public PlanarYUVLuminanceSource(byte[] yuvData, - int dataWidth, - int dataHeight, - int left, - int top, - int width, - int height, - boolean reverseHorizontal) { - super(width, height); - - if (left + width > dataWidth || top + height > dataHeight) { - throw new IllegalArgumentException("Crop rectangle does not fit within image data."); - } - - this.yuvData = yuvData; - this.dataWidth = dataWidth; - this.dataHeight = dataHeight; - this.left = left; - this.top = top; - if (reverseHorizontal) { - reverseHorizontal(width, height); - } - } - - @Override - public byte[] getRow(int y, byte[] row) { - if (y < 0 || y >= getHeight()) { - throw new IllegalArgumentException("Requested row is outside the image: " + y); - } - int width = getWidth(); - if (row == null || row.length < width) { - row = new byte[width]; - } - int offset = (y + top) * dataWidth + left; - System.arraycopy(yuvData, offset, row, 0, width); - return row; - } - - @Override - public byte[] getMatrix() { - int width = getWidth(); - int height = getHeight(); - - // If the caller asks for the entire underlying image, save the copy and give them the - // original data. The docs specifically warn that result.length must be ignored. - if (width == dataWidth && height == dataHeight) { - return yuvData; - } - - int area = width * height; - byte[] matrix = new byte[area]; - int inputOffset = top * dataWidth + left; - - // If the width matches the full width of the underlying data, perform a single copy. - if (width == dataWidth) { - System.arraycopy(yuvData, inputOffset, matrix, 0, area); - return matrix; - } - - // Otherwise copy one cropped row at a time. - for (int y = 0; y < height; y++) { - int outputOffset = y * width; - System.arraycopy(yuvData, inputOffset, matrix, outputOffset, width); - inputOffset += dataWidth; - } - return matrix; - } - - @Override - public boolean isCropSupported() { - return true; - } - - @Override - public LuminanceSource crop(int left, int top, int width, int height) { - return new PlanarYUVLuminanceSource(yuvData, - dataWidth, - dataHeight, - this.left + left, - this.top + top, - width, - height, - false); - } - - public int[] renderThumbnail() { - int width = getWidth() / THUMBNAIL_SCALE_FACTOR; - int height = getHeight() / THUMBNAIL_SCALE_FACTOR; - int[] pixels = new int[width * height]; - byte[] yuv = yuvData; - int inputOffset = top * dataWidth + left; - - for (int y = 0; y < height; y++) { - int outputOffset = y * width; - for (int x = 0; x < width; x++) { - int grey = yuv[inputOffset + x * THUMBNAIL_SCALE_FACTOR] & 0xff; - pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101); - } - inputOffset += dataWidth * THUMBNAIL_SCALE_FACTOR; - } - return pixels; - } - - /** - * @return width of image from {@link #renderThumbnail()} - */ - public int getThumbnailWidth() { - return getWidth() / THUMBNAIL_SCALE_FACTOR; - } - - /** - * @return height of image from {@link #renderThumbnail()} - */ - public int getThumbnailHeight() { - return getHeight() / THUMBNAIL_SCALE_FACTOR; - } - - private void reverseHorizontal(int width, int height) { - byte[] yuvData = this.yuvData; - for (int y = 0, rowStart = top * dataWidth + left; y < height; y++, rowStart += dataWidth) { - int middle = rowStart + width / 2; - for (int x1 = rowStart, x2 = rowStart + width - 1; x1 < middle; x1++, x2--) { - byte temp = yuvData[x1]; - yuvData[x1] = yuvData[x2]; - yuvData[x2] = temp; - } - } - } - -} diff --git a/port_src/core/DONE/RGBLuminanceSource.java b/port_src/core/DONE/RGBLuminanceSource.java deleted file mode 100644 index 3950ce8..0000000 --- a/port_src/core/DONE/RGBLuminanceSource.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * This class is used to help decode images from files which arrive as RGB data from - * an ARGB pixel array. It does not support rotation. - * - * @author dswitkin@google.com (Daniel Switkin) - * @author Betaminos - */ -public final class RGBLuminanceSource extends LuminanceSource { - - private final byte[] luminances; - private final int dataWidth; - private final int dataHeight; - private final int left; - private final int top; - - public RGBLuminanceSource(int width, int height, int[] pixels) { - super(width, height); - - dataWidth = width; - dataHeight = height; - left = 0; - top = 0; - - // In order to measure pure decoding speed, we convert the entire image to a greyscale array - // up front, which is the same as the Y channel of the YUVLuminanceSource in the real app. - // - // Total number of pixels suffices, can ignore shape - int size = width * height; - luminances = new byte[size]; - for (int offset = 0; offset < size; offset++) { - int pixel = pixels[offset]; - int r = (pixel >> 16) & 0xff; // red - int g2 = (pixel >> 7) & 0x1fe; // 2 * green - int b = pixel & 0xff; // blue - // Calculate green-favouring average cheaply - luminances[offset] = (byte) ((r + g2 + b) / 4); - } - } - - private RGBLuminanceSource(byte[] pixels, - int dataWidth, - int dataHeight, - int left, - int top, - int width, - int height) { - super(width, height); - if (left + width > dataWidth || top + height > dataHeight) { - throw new IllegalArgumentException("Crop rectangle does not fit within image data."); - } - this.luminances = pixels; - this.dataWidth = dataWidth; - this.dataHeight = dataHeight; - this.left = left; - this.top = top; - } - - @Override - public byte[] getRow(int y, byte[] row) { - if (y < 0 || y >= getHeight()) { - throw new IllegalArgumentException("Requested row is outside the image: " + y); - } - int width = getWidth(); - if (row == null || row.length < width) { - row = new byte[width]; - } - int offset = (y + top) * dataWidth + left; - System.arraycopy(luminances, offset, row, 0, width); - return row; - } - - @Override - public byte[] getMatrix() { - int width = getWidth(); - int height = getHeight(); - - // If the caller asks for the entire underlying image, save the copy and give them the - // original data. The docs specifically warn that result.length must be ignored. - if (width == dataWidth && height == dataHeight) { - return luminances; - } - - int area = width * height; - byte[] matrix = new byte[area]; - int inputOffset = top * dataWidth + left; - - // If the width matches the full width of the underlying data, perform a single copy. - if (width == dataWidth) { - System.arraycopy(luminances, inputOffset, matrix, 0, area); - return matrix; - } - - // Otherwise copy one cropped row at a time. - for (int y = 0; y < height; y++) { - int outputOffset = y * width; - System.arraycopy(luminances, inputOffset, matrix, outputOffset, width); - inputOffset += dataWidth; - } - return matrix; - } - - @Override - public boolean isCropSupported() { - return true; - } - - @Override - public LuminanceSource crop(int left, int top, int width, int height) { - return new RGBLuminanceSource(luminances, - dataWidth, - dataHeight, - this.left + left, - this.top + top, - width, - height); - } - -} diff --git a/port_src/core/DONE/Reader.java b/port_src/core/DONE/Reader.java deleted file mode 100644 index 0e6af10..0000000 --- a/port_src/core/DONE/Reader.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import java.util.Map; - -/** - * Implementations of this interface can decode an image of a barcode in some format into - * the String it encodes. For example, {@link com.google.zxing.qrcode.QRCodeReader} can - * decode a QR code. The decoder may optionally receive hints from the caller which may help - * it decode more quickly or accurately. - * - * See {@link MultiFormatReader}, which attempts to determine what barcode - * format is present within the image as well, and then decodes it accordingly. - * - * @author Sean Owen - * @author dswitkin@google.com (Daniel Switkin) - */ -public interface Reader { - - /** - * Locates and decodes a barcode in some format within an image. - * - * @param image image of barcode to decode - * @return String which the barcode encodes - * @throws NotFoundException if no potential barcode is found - * @throws ChecksumException if a potential barcode is found but does not pass its checksum - * @throws FormatException if a potential barcode is found but format is invalid - */ - Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException; - - /** - * Locates and decodes a barcode in some format within an image. This method also accepts - * hints, each possibly associated to some data, which may help the implementation decode. - * - * @param image image of barcode to decode - * @param hints passed as a {@link Map} from {@link DecodeHintType} - * to arbitrary data. The - * meaning of the data depends upon the hint type. The implementation may or may not do - * anything with these hints. - * @return String which the barcode encodes - * @throws NotFoundException if no potential barcode is found - * @throws ChecksumException if a potential barcode is found but does not pass its checksum - * @throws FormatException if a potential barcode is found but format is invalid - */ - Result decode(BinaryBitmap image, Map hints) - throws NotFoundException, ChecksumException, FormatException; - - /** - * Resets any internal state the implementation has after a decode, to prepare it - * for reuse. - */ - void reset(); - -} diff --git a/port_src/core/DONE/ReaderException.java b/port_src/core/DONE/ReaderException.java deleted file mode 100644 index c0690e3..0000000 --- a/port_src/core/DONE/ReaderException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * The general exception class throw when something goes wrong during decoding of a barcode. - * This includes, but is not limited to, failing checksums / error correction algorithms, being - * unable to locate finder timing patterns, and so on. - * - * @author Sean Owen - */ -public abstract class ReaderException extends Exception { - - // disable stack traces when not running inside test units - protected static boolean isStackTrace = - System.getProperty("surefire.test.class.path") != null; - protected static final StackTraceElement[] NO_TRACE = new StackTraceElement[0]; - - ReaderException() { - // do nothing - } - - ReaderException(Throwable cause) { - super(cause); - } - - // Prevent stack traces from being taken - @Override - public final synchronized Throwable fillInStackTrace() { - return null; - } - - /** - * For testing only. Controls whether library exception classes include stack traces or not. - * Defaults to false, unless running in the project's unit testing harness. - * - * @param enabled if true, enables stack traces in library exception classes - * @since 3.5.0 - */ - public static void setStackTrace(boolean enabled) { - isStackTrace = enabled; - } - -} diff --git a/port_src/core/DONE/Result.java b/port_src/core/DONE/Result.java deleted file mode 100644 index 3df435f..0000000 --- a/port_src/core/DONE/Result.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import java.util.EnumMap; -import java.util.Map; - -/** - *

Encapsulates the result of decoding a barcode within an image.

- * - * @author Sean Owen - */ -public final class Result { - - private final String text; - private final byte[] rawBytes; - private final int numBits; - private ResultPoint[] resultPoints; - private final BarcodeFormat format; - private Map resultMetadata; - private final long timestamp; - - public Result(String text, - byte[] rawBytes, - ResultPoint[] resultPoints, - BarcodeFormat format) { - this(text, rawBytes, resultPoints, format, System.currentTimeMillis()); - } - - public Result(String text, - byte[] rawBytes, - ResultPoint[] resultPoints, - BarcodeFormat format, - long timestamp) { - this(text, rawBytes, rawBytes == null ? 0 : 8 * rawBytes.length, - resultPoints, format, timestamp); - } - - public Result(String text, - byte[] rawBytes, - int numBits, - ResultPoint[] resultPoints, - BarcodeFormat format, - long timestamp) { - this.text = text; - this.rawBytes = rawBytes; - this.numBits = numBits; - this.resultPoints = resultPoints; - this.format = format; - this.resultMetadata = null; - this.timestamp = timestamp; - } - - /** - * @return raw text encoded by the barcode - */ - public String getText() { - return text; - } - - /** - * @return raw bytes encoded by the barcode, if applicable, otherwise {@code null} - */ - public byte[] getRawBytes() { - return rawBytes; - } - - /** - * @return how many bits of {@link #getRawBytes()} are valid; typically 8 times its length - * @since 3.3.0 - */ - public int getNumBits() { - return numBits; - } - - /** - * @return points related to the barcode in the image. These are typically points - * identifying finder patterns or the corners of the barcode. The exact meaning is - * specific to the type of barcode that was decoded. - */ - public ResultPoint[] getResultPoints() { - return resultPoints; - } - - /** - * @return {@link BarcodeFormat} representing the format of the barcode that was decoded - */ - public BarcodeFormat getBarcodeFormat() { - return format; - } - - /** - * @return {@link Map} mapping {@link ResultMetadataType} keys to values. May be - * {@code null}. This contains optional metadata about what was detected about the barcode, - * like orientation. - */ - public Map getResultMetadata() { - return resultMetadata; - } - - public void putMetadata(ResultMetadataType type, Object value) { - if (resultMetadata == null) { - resultMetadata = new EnumMap<>(ResultMetadataType.class); - } - resultMetadata.put(type, value); - } - - public void putAllMetadata(Map metadata) { - if (metadata != null) { - if (resultMetadata == null) { - resultMetadata = metadata; - } else { - resultMetadata.putAll(metadata); - } - } - } - - public void addResultPoints(ResultPoint[] newPoints) { - ResultPoint[] oldPoints = resultPoints; - if (oldPoints == null) { - resultPoints = newPoints; - } else if (newPoints != null && newPoints.length > 0) { - ResultPoint[] allPoints = new ResultPoint[oldPoints.length + newPoints.length]; - System.arraycopy(oldPoints, 0, allPoints, 0, oldPoints.length); - System.arraycopy(newPoints, 0, allPoints, oldPoints.length, newPoints.length); - resultPoints = allPoints; - } - } - - public long getTimestamp() { - return timestamp; - } - - @Override - public String toString() { - return text; - } - -} diff --git a/port_src/core/DONE/ResultMetadataType.java b/port_src/core/DONE/ResultMetadataType.java deleted file mode 100644 index 0869170..0000000 --- a/port_src/core/DONE/ResultMetadataType.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * Represents some type of metadata about the result of the decoding that the decoder - * wishes to communicate back to the caller. - * - * @author Sean Owen - */ -public enum ResultMetadataType { - - /** - * Unspecified, application-specific metadata. Maps to an unspecified {@link Object}. - */ - OTHER, - - /** - * Denotes the likely approximate orientation of the barcode in the image. This value - * is given as degrees rotated clockwise from the normal, upright orientation. - * For example a 1D barcode which was found by reading top-to-bottom would be - * said to have orientation "90". This key maps to an {@link Integer} whose - * value is in the range [0,360). - */ - ORIENTATION, - - /** - *

2D barcode formats typically encode text, but allow for a sort of 'byte mode' - * which is sometimes used to encode binary data. While {@link Result} makes available - * the complete raw bytes in the barcode for these formats, it does not offer the bytes - * from the byte segments alone.

- * - *

This maps to a {@link java.util.List} of byte arrays corresponding to the - * raw bytes in the byte segments in the barcode, in order.

- */ - BYTE_SEGMENTS, - - /** - * Error correction level used, if applicable. The value type depends on the - * format, but is typically a String. - */ - ERROR_CORRECTION_LEVEL, - - /** - * For some periodicals, indicates the issue number as an {@link Integer}. - */ - ISSUE_NUMBER, - - /** - * For some products, indicates the suggested retail price in the barcode as a - * formatted {@link String}. - */ - SUGGESTED_PRICE, - - /** - * For some products, the possible country of manufacture as a {@link String} denoting the - * ISO country code. Some map to multiple possible countries, like "US/CA". - */ - POSSIBLE_COUNTRY, - - /** - * For some products, the extension text - */ - UPC_EAN_EXTENSION, - - /** - * PDF417-specific metadata - */ - PDF417_EXTRA_METADATA, - - /** - * If the code format supports structured append and the current scanned code is part of one then the - * sequence number is given with it. - */ - STRUCTURED_APPEND_SEQUENCE, - - /** - * If the code format supports structured append and the current scanned code is part of one then the - * parity is given with it. - */ - STRUCTURED_APPEND_PARITY, - - /** - * Barcode Symbology Identifier. - * Note: According to the GS1 specification the identifier may have to replace a leading FNC1/GS character - * when prepending to the barcode content. - */ - SYMBOLOGY_IDENTIFIER, -} diff --git a/port_src/core/DONE/ResultPoint.java b/port_src/core/DONE/ResultPoint.java deleted file mode 100644 index 9bd8cd2..0000000 --- a/port_src/core/DONE/ResultPoint.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import com.google.zxing.common.detector.MathUtils; - -/** - *

Encapsulates a point of interest in an image containing a barcode. Typically, this - * would be the location of a finder pattern or the corner of the barcode, for example.

- * - * @author Sean Owen - */ -public class ResultPoint { - - private final float x; - private final float y; - - public ResultPoint(float x, float y) { - this.x = x; - this.y = y; - } - - public final float getX() { - return x; - } - - public final float getY() { - return y; - } - - @Override - public final boolean equals(Object other) { - if (other instanceof ResultPoint) { - ResultPoint otherPoint = (ResultPoint) other; - return x == otherPoint.x && y == otherPoint.y; - } - return false; - } - - @Override - public final int hashCode() { - return 31 * Float.floatToIntBits(x) + Float.floatToIntBits(y); - } - - @Override - public final String toString() { - return "(" + x + ',' + y + ')'; - } - - /** - * Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC - * and BC is less than AC, and the angle between BC and BA is less than 180 degrees. - * - * @param patterns array of three {@code ResultPoint} to order - */ - public static void orderBestPatterns(ResultPoint[] patterns) { - - // Find distances between pattern centers - float zeroOneDistance = distance(patterns[0], patterns[1]); - float oneTwoDistance = distance(patterns[1], patterns[2]); - float zeroTwoDistance = distance(patterns[0], patterns[2]); - - ResultPoint pointA; - ResultPoint pointB; - ResultPoint pointC; - // Assume one closest to other two is B; A and C will just be guesses at first - if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) { - pointB = patterns[0]; - pointA = patterns[1]; - pointC = patterns[2]; - } else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) { - pointB = patterns[1]; - pointA = patterns[0]; - pointC = patterns[2]; - } else { - pointB = patterns[2]; - pointA = patterns[0]; - pointC = patterns[1]; - } - - // Use cross product to figure out whether A and C are correct or flipped. - // This asks whether BC x BA has a positive z component, which is the arrangement - // we want for A, B, C. If it's negative, then we've got it flipped around and - // should swap A and C. - if (crossProductZ(pointA, pointB, pointC) < 0.0f) { - ResultPoint temp = pointA; - pointA = pointC; - pointC = temp; - } - - patterns[0] = pointA; - patterns[1] = pointB; - patterns[2] = pointC; - } - - /** - * @param pattern1 first pattern - * @param pattern2 second pattern - * @return distance between two points - */ - public static float distance(ResultPoint pattern1, ResultPoint pattern2) { - return MathUtils.distance(pattern1.x, pattern1.y, pattern2.x, pattern2.y); - } - - /** - * Returns the z component of the cross product between vectors BC and BA. - */ - private static float crossProductZ(ResultPoint pointA, - ResultPoint pointB, - ResultPoint pointC) { - float bX = pointB.x; - float bY = pointB.y; - return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX)); - } - -} diff --git a/port_src/core/DONE/ResultPointCallback.java b/port_src/core/DONE/ResultPointCallback.java deleted file mode 100644 index 0c85410..0000000 --- a/port_src/core/DONE/ResultPointCallback.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * Callback which is invoked when a possible result point (significant - * point in the barcode image such as a corner) is found. - * - * @see DecodeHintType#NEED_RESULT_POINT_CALLBACK - */ -public interface ResultPointCallback { - - void foundPossibleResultPoint(ResultPoint point); - -} diff --git a/port_src/core/DONE/Writer.java b/port_src/core/DONE/Writer.java deleted file mode 100644 index f405fd8..0000000 --- a/port_src/core/DONE/Writer.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import com.google.zxing.common.BitMatrix; - -import java.util.Map; - -/** - * The base class for all objects which encode/generate a barcode image. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public interface Writer { - - /** - * Encode a barcode using the default settings. - * - * @param contents The contents to encode in the barcode - * @param format The barcode format to generate - * @param width The preferred width in pixels - * @param height The preferred height in pixels - * @return {@link BitMatrix} representing encoded barcode image - * @throws WriterException if contents cannot be encoded legally in a format - */ - BitMatrix encode(String contents, BarcodeFormat format, int width, int height) - throws WriterException; - - /** - * @param contents The contents to encode in the barcode - * @param format The barcode format to generate - * @param width The preferred width in pixels - * @param height The preferred height in pixels - * @param hints Additional parameters to supply to the encoder - * @return {@link BitMatrix} representing encoded barcode image - * @throws WriterException if contents cannot be encoded legally in a format - */ - BitMatrix encode(String contents, - BarcodeFormat format, - int width, - int height, - Map hints) - throws WriterException; - -} diff --git a/port_src/core/DONE/WriterException.java b/port_src/core/DONE/WriterException.java deleted file mode 100644 index d2a37bc..0000000 --- a/port_src/core/DONE/WriterException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -/** - * A base class which covers the range of exceptions which may occur when encoding a barcode using - * the Writer framework. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class WriterException extends Exception { - - public WriterException() { - } - - public WriterException(String message) { - super(message); - } - - public WriterException(Throwable cause) { - super(cause); - } - -} diff --git a/port_src/core/DONE/aztec/AztecDetectorResult.java b/port_src/core/DONE/aztec/AztecDetectorResult.java deleted file mode 100644 index 8341578..0000000 --- a/port_src/core/DONE/aztec/AztecDetectorResult.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec; - -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DetectorResult; - -/** - *

Extends {@link DetectorResult} with more information specific to the Aztec format, - * like the number of layers and whether it's compact.

- * - * @author Sean Owen - */ -public final class AztecDetectorResult extends DetectorResult { - - private final boolean compact; - private final int nbDatablocks; - private final int nbLayers; - - public AztecDetectorResult(BitMatrix bits, - ResultPoint[] points, - boolean compact, - int nbDatablocks, - int nbLayers) { - super(bits, points); - this.compact = compact; - this.nbDatablocks = nbDatablocks; - this.nbLayers = nbLayers; - } - - public int getNbLayers() { - return nbLayers; - } - - public int getNbDatablocks() { - return nbDatablocks; - } - - public boolean isCompact() { - return compact; - } - -} diff --git a/port_src/core/DONE/aztec/AztecReader.java b/port_src/core/DONE/aztec/AztecReader.java deleted file mode 100644 index f3a3e21..0000000 --- a/port_src/core/DONE/aztec/AztecReader.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Reader; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.ResultPointCallback; -import com.google.zxing.aztec.decoder.Decoder; -import com.google.zxing.aztec.detector.Detector; -import com.google.zxing.common.DecoderResult; - -import java.util.List; -import java.util.Map; - -/** - * This implementation can detect and decode Aztec codes in an image. - * - * @author David Olivier - */ -public final class AztecReader implements Reader { - - /** - * Locates and decodes a Data Matrix code in an image. - * - * @return a String representing the content encoded by the Data Matrix code - * @throws NotFoundException if a Data Matrix code cannot be found - * @throws FormatException if a Data Matrix code cannot be decoded - */ - @Override - public Result decode(BinaryBitmap image) throws NotFoundException, FormatException { - return decode(image, null); - } - - @Override - public Result decode(BinaryBitmap image, Map hints) - throws NotFoundException, FormatException { - - NotFoundException notFoundException = null; - FormatException formatException = null; - Detector detector = new Detector(image.getBlackMatrix()); - ResultPoint[] points = null; - DecoderResult decoderResult = null; - try { - AztecDetectorResult detectorResult = detector.detect(false); - points = detectorResult.getPoints(); - decoderResult = new Decoder().decode(detectorResult); - } catch (NotFoundException e) { - notFoundException = e; - } catch (FormatException e) { - formatException = e; - } - if (decoderResult == null) { - try { - AztecDetectorResult detectorResult = detector.detect(true); - points = detectorResult.getPoints(); - decoderResult = new Decoder().decode(detectorResult); - } catch (NotFoundException | FormatException e) { - if (notFoundException != null) { - throw notFoundException; - } - if (formatException != null) { - throw formatException; - } - throw e; - } - } - - if (hints != null) { - ResultPointCallback rpcb = (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); - if (rpcb != null) { - for (ResultPoint point : points) { - rpcb.foundPossibleResultPoint(point); - } - } - } - - Result result = new Result(decoderResult.getText(), - decoderResult.getRawBytes(), - decoderResult.getNumBits(), - points, - BarcodeFormat.AZTEC, - System.currentTimeMillis()); - - List byteSegments = decoderResult.getByteSegments(); - if (byteSegments != null) { - result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); - } - String ecLevel = decoderResult.getECLevel(); - if (ecLevel != null) { - result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); - } - result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]z" + decoderResult.getSymbologyModifier()); - - return result; - } - - @Override - public void reset() { - // do nothing - } - -} diff --git a/port_src/core/DONE/aztec/AztecWriter.java b/port_src/core/DONE/aztec/AztecWriter.java deleted file mode 100644 index e5cb7e6..0000000 --- a/port_src/core/DONE/aztec/AztecWriter.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.Writer; -import com.google.zxing.aztec.encoder.AztecCode; -import com.google.zxing.aztec.encoder.Encoder; -import com.google.zxing.common.BitMatrix; - -import java.nio.charset.Charset; -import java.util.Map; - -/** - * Renders an Aztec code as a {@link BitMatrix}. - */ -public final class AztecWriter implements Writer { - - @Override - public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) { - return encode(contents, format, width, height, null); - } - - @Override - public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map hints) { - Charset charset = null; // Do not add any ECI code by default - int eccPercent = Encoder.DEFAULT_EC_PERCENT; - int layers = Encoder.DEFAULT_AZTEC_LAYERS; - if (hints != null) { - if (hints.containsKey(EncodeHintType.CHARACTER_SET)) { - charset = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString()); - } - if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) { - eccPercent = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString()); - } - if (hints.containsKey(EncodeHintType.AZTEC_LAYERS)) { - layers = Integer.parseInt(hints.get(EncodeHintType.AZTEC_LAYERS).toString()); - } - } - return encode(contents, format, width, height, charset, eccPercent, layers); - } - - private static BitMatrix encode(String contents, BarcodeFormat format, - int width, int height, - Charset charset, int eccPercent, int layers) { - if (format != BarcodeFormat.AZTEC) { - throw new IllegalArgumentException("Can only encode AZTEC, but got " + format); - } - AztecCode aztec = Encoder.encode(contents, eccPercent, layers, charset); - return renderResult(aztec, width, height); - } - - private static BitMatrix renderResult(AztecCode code, int width, int height) { - BitMatrix input = code.getMatrix(); - if (input == null) { - throw new IllegalStateException(); - } - int inputWidth = input.getWidth(); - int inputHeight = input.getHeight(); - int outputWidth = Math.max(width, inputWidth); - int outputHeight = Math.max(height, inputHeight); - - int multiple = Math.min(outputWidth / inputWidth, outputHeight / inputHeight); - int leftPadding = (outputWidth - (inputWidth * multiple)) / 2; - int topPadding = (outputHeight - (inputHeight * multiple)) / 2; - - BitMatrix output = new BitMatrix(outputWidth, outputHeight); - - for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) { - // Write the contents of this row of the barcode - for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) { - if (input.get(inputX, inputY)) { - output.setRegion(outputX, outputY, multiple, multiple); - } - } - } - return output; - } -} diff --git a/port_src/core/DONE/aztec/decoder/Decoder.java b/port_src/core/DONE/aztec/decoder/Decoder.java deleted file mode 100644 index 6f6ac42..0000000 --- a/port_src/core/DONE/aztec/decoder/Decoder.java +++ /dev/null @@ -1,443 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.aztec.AztecDetectorResult; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.CharacterSetECI; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.reedsolomon.GenericGF; -import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; -import com.google.zxing.common.reedsolomon.ReedSolomonException; - -import java.io.ByteArrayOutputStream; -import java.io.UnsupportedEncodingException; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; - -/** - *

The main class which implements Aztec Code decoding -- as opposed to locating and extracting - * the Aztec Code from an image.

- * - * @author David Olivier - */ -public final class Decoder { - - private enum Table { - UPPER, - LOWER, - MIXED, - DIGIT, - PUNCT, - BINARY - } - - private static final String[] UPPER_TABLE = { - "CTRL_PS", " ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", - "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "CTRL_LL", "CTRL_ML", "CTRL_DL", "CTRL_BS" - }; - - private static final String[] LOWER_TABLE = { - "CTRL_PS", " ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", - "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "CTRL_US", "CTRL_ML", "CTRL_DL", "CTRL_BS" - }; - - private static final String[] MIXED_TABLE = { - "CTRL_PS", " ", "\1", "\2", "\3", "\4", "\5", "\6", "\7", "\b", "\t", "\n", - "\13", "\f", "\r", "\33", "\34", "\35", "\36", "\37", "@", "\\", "^", "_", - "`", "|", "~", "\177", "CTRL_LL", "CTRL_UL", "CTRL_PL", "CTRL_BS" - }; - - private static final String[] PUNCT_TABLE = { - "FLG(n)", "\r", "\r\n", ". ", ", ", ": ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", - "*", "+", ",", "-", ".", "/", ":", ";", "<", "=", ">", "?", "[", "]", "{", "}", "CTRL_UL" - }; - - private static final String[] DIGIT_TABLE = { - "CTRL_PS", " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ",", ".", "CTRL_UL", "CTRL_US" - }; - - private static final Charset DEFAULT_ENCODING = StandardCharsets.ISO_8859_1; - - private AztecDetectorResult ddata; - - public DecoderResult decode(AztecDetectorResult detectorResult) throws FormatException { - ddata = detectorResult; - BitMatrix matrix = detectorResult.getBits(); - boolean[] rawbits = extractBits(matrix); - CorrectedBitsResult correctedBits = correctBits(rawbits); - byte[] rawBytes = convertBoolArrayToByteArray(correctedBits.correctBits); - String result = getEncodedData(correctedBits.correctBits); - DecoderResult decoderResult = - new DecoderResult(rawBytes, result, null, String.format("%d%%", correctedBits.ecLevel)); - decoderResult.setNumBits(correctedBits.correctBits.length); - return decoderResult; - } - - // This method is used for testing the high-level encoder - public static String highLevelDecode(boolean[] correctedBits) throws FormatException { - return getEncodedData(correctedBits); - } - - /** - * Gets the string encoded in the aztec code bits - * - * @return the decoded string - */ - private static String getEncodedData(boolean[] correctedBits) throws FormatException { - int endIndex = correctedBits.length; - Table latchTable = Table.UPPER; // table most recently latched to - Table shiftTable = Table.UPPER; // table to use for the next read - - // Final decoded string result - // (correctedBits-5) / 4 is an upper bound on the size (all-digit result) - StringBuilder result = new StringBuilder((correctedBits.length - 5) / 4); - - // Intermediary buffer of decoded bytes, which is decoded into a string and flushed - // when character encoding changes (ECI) or input ends. - ByteArrayOutputStream decodedBytes = new ByteArrayOutputStream(); - Charset encoding = DEFAULT_ENCODING; - - int index = 0; - while (index < endIndex) { - if (shiftTable == Table.BINARY) { - if (endIndex - index < 5) { - break; - } - int length = readCode(correctedBits, index, 5); - index += 5; - if (length == 0) { - if (endIndex - index < 11) { - break; - } - length = readCode(correctedBits, index, 11) + 31; - index += 11; - } - for (int charCount = 0; charCount < length; charCount++) { - if (endIndex - index < 8) { - index = endIndex; // Force outer loop to exit - break; - } - int code = readCode(correctedBits, index, 8); - decodedBytes.write((byte) code); - index += 8; - } - // Go back to whatever mode we had been in - shiftTable = latchTable; - } else { - int size = shiftTable == Table.DIGIT ? 4 : 5; - if (endIndex - index < size) { - break; - } - int code = readCode(correctedBits, index, size); - index += size; - String str = getCharacter(shiftTable, code); - if ("FLG(n)".equals(str)) { - if (endIndex - index < 3) { - break; - } - int n = readCode(correctedBits, index, 3); - index += 3; - // flush bytes, FLG changes state - try { - result.append(decodedBytes.toString(encoding.name())); - } catch (UnsupportedEncodingException uee) { - throw new IllegalStateException(uee); - } - decodedBytes.reset(); - switch (n) { - case 0: - result.append((char) 29); // translate FNC1 as ASCII 29 - break; - case 7: - throw FormatException.getFormatInstance(); // FLG(7) is reserved and illegal - default: - // ECI is decimal integer encoded as 1-6 codes in DIGIT mode - int eci = 0; - if (endIndex - index < 4 * n) { - break; - } - while (n-- > 0) { - int nextDigit = readCode(correctedBits, index, 4); - index += 4; - if (nextDigit < 2 || nextDigit > 11) { - throw FormatException.getFormatInstance(); // Not a decimal digit - } - eci = eci * 10 + (nextDigit - 2); - } - CharacterSetECI charsetECI = CharacterSetECI.getCharacterSetECIByValue(eci); - if (charsetECI == null) { - throw FormatException.getFormatInstance(); - } - encoding = charsetECI.getCharset(); - } - // Go back to whatever mode we had been in - shiftTable = latchTable; - } else if (str.startsWith("CTRL_")) { - // Table changes - // ISO/IEC 24778:2008 prescribes ending a shift sequence in the mode from which it was invoked. - // That's including when that mode is a shift. - // Our test case dlusbs.png for issue #642 exercises that. - latchTable = shiftTable; // Latch the current mode, so as to return to Upper after U/S B/S - shiftTable = getTable(str.charAt(5)); - if (str.charAt(6) == 'L') { - latchTable = shiftTable; - } - } else { - // Though stored as a table of strings for convenience, codes actually represent 1 or 2 *bytes*. - byte[] b = str.getBytes(StandardCharsets.US_ASCII); - decodedBytes.write(b, 0, b.length); - // Go back to whatever mode we had been in - shiftTable = latchTable; - } - } - } - try { - result.append(decodedBytes.toString(encoding.name())); - } catch (UnsupportedEncodingException uee) { - // can't happen - throw new IllegalStateException(uee); - } - return result.toString(); - } - - /** - * gets the table corresponding to the char passed - */ - private static Table getTable(char t) { - switch (t) { - case 'L': - return Table.LOWER; - case 'P': - return Table.PUNCT; - case 'M': - return Table.MIXED; - case 'D': - return Table.DIGIT; - case 'B': - return Table.BINARY; - case 'U': - default: - return Table.UPPER; - } - } - - /** - * Gets the character (or string) corresponding to the passed code in the given table - * - * @param table the table used - * @param code the code of the character - */ - private static String getCharacter(Table table, int code) { - switch (table) { - case UPPER: - return UPPER_TABLE[code]; - case LOWER: - return LOWER_TABLE[code]; - case MIXED: - return MIXED_TABLE[code]; - case PUNCT: - return PUNCT_TABLE[code]; - case DIGIT: - return DIGIT_TABLE[code]; - default: - // Should not reach here. - throw new IllegalStateException("Bad table"); - } - } - - static final class CorrectedBitsResult { - private final boolean[] correctBits; - private final int ecLevel; - - CorrectedBitsResult(boolean[] correctBits, int ecLevel) { - this.correctBits = correctBits; - this.ecLevel = ecLevel; - } - } - - /** - *

Performs RS error correction on an array of bits.

- * - * @return the corrected array - * @throws FormatException if the input contains too many errors - */ - private CorrectedBitsResult correctBits(boolean[] rawbits) throws FormatException { - GenericGF gf; - int codewordSize; - - if (ddata.getNbLayers() <= 2) { - codewordSize = 6; - gf = GenericGF.AZTEC_DATA_6; - } else if (ddata.getNbLayers() <= 8) { - codewordSize = 8; - gf = GenericGF.AZTEC_DATA_8; - } else if (ddata.getNbLayers() <= 22) { - codewordSize = 10; - gf = GenericGF.AZTEC_DATA_10; - } else { - codewordSize = 12; - gf = GenericGF.AZTEC_DATA_12; - } - - int numDataCodewords = ddata.getNbDatablocks(); - int numCodewords = rawbits.length / codewordSize; - if (numCodewords < numDataCodewords) { - throw FormatException.getFormatInstance(); - } - int offset = rawbits.length % codewordSize; - - int[] dataWords = new int[numCodewords]; - for (int i = 0; i < numCodewords; i++, offset += codewordSize) { - dataWords[i] = readCode(rawbits, offset, codewordSize); - } - - try { - ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(gf); - rsDecoder.decode(dataWords, numCodewords - numDataCodewords); - } catch (ReedSolomonException ex) { - throw FormatException.getFormatInstance(ex); - } - - // Now perform the unstuffing operation. - // First, count how many bits are going to be thrown out as stuffing - int mask = (1 << codewordSize) - 1; - int stuffedBits = 0; - for (int i = 0; i < numDataCodewords; i++) { - int dataWord = dataWords[i]; - if (dataWord == 0 || dataWord == mask) { - throw FormatException.getFormatInstance(); - } else if (dataWord == 1 || dataWord == mask - 1) { - stuffedBits++; - } - } - // Now, actually unpack the bits and remove the stuffing - boolean[] correctedBits = new boolean[numDataCodewords * codewordSize - stuffedBits]; - int index = 0; - for (int i = 0; i < numDataCodewords; i++) { - int dataWord = dataWords[i]; - if (dataWord == 1 || dataWord == mask - 1) { - // next codewordSize-1 bits are all zeros or all ones - Arrays.fill(correctedBits, index, index + codewordSize - 1, dataWord > 1); - index += codewordSize - 1; - } else { - for (int bit = codewordSize - 1; bit >= 0; --bit) { - correctedBits[index++] = (dataWord & (1 << bit)) != 0; - } - } - } - - return new CorrectedBitsResult(correctedBits, 100 * (numCodewords - numDataCodewords) / numCodewords); - } - - /** - * Gets the array of bits from an Aztec Code matrix - * - * @return the array of bits - */ - private boolean[] extractBits(BitMatrix matrix) { - boolean compact = ddata.isCompact(); - int layers = ddata.getNbLayers(); - int baseMatrixSize = (compact ? 11 : 14) + layers * 4; // not including alignment lines - int[] alignmentMap = new int[baseMatrixSize]; - boolean[] rawbits = new boolean[totalBitsInLayer(layers, compact)]; - - if (compact) { - for (int i = 0; i < alignmentMap.length; i++) { - alignmentMap[i] = i; - } - } else { - int matrixSize = baseMatrixSize + 1 + 2 * ((baseMatrixSize / 2 - 1) / 15); - int origCenter = baseMatrixSize / 2; - int center = matrixSize / 2; - for (int i = 0; i < origCenter; i++) { - int newOffset = i + i / 15; - alignmentMap[origCenter - i - 1] = center - newOffset - 1; - alignmentMap[origCenter + i] = center + newOffset + 1; - } - } - for (int i = 0, rowOffset = 0; i < layers; i++) { - int rowSize = (layers - i) * 4 + (compact ? 9 : 12); - // The top-left most point of this layer is (not including alignment lines) - int low = i * 2; - // The bottom-right most point of this layer is (not including alignment lines) - int high = baseMatrixSize - 1 - low; - // We pull bits from the two 2 x rowSize columns and two rowSize x 2 rows - for (int j = 0; j < rowSize; j++) { - int columnOffset = j * 2; - for (int k = 0; k < 2; k++) { - // left column - rawbits[rowOffset + columnOffset + k] = - matrix.get(alignmentMap[low + k], alignmentMap[low + j]); - // bottom row - rawbits[rowOffset + 2 * rowSize + columnOffset + k] = - matrix.get(alignmentMap[low + j], alignmentMap[high - k]); - // right column - rawbits[rowOffset + 4 * rowSize + columnOffset + k] = - matrix.get(alignmentMap[high - k], alignmentMap[high - j]); - // top row - rawbits[rowOffset + 6 * rowSize + columnOffset + k] = - matrix.get(alignmentMap[high - j], alignmentMap[low + k]); - } - } - rowOffset += rowSize * 8; - } - return rawbits; - } - - /** - * Reads a code of given length and at given index in an array of bits - */ - private static int readCode(boolean[] rawbits, int startIndex, int length) { - int res = 0; - for (int i = startIndex; i < startIndex + length; i++) { - res <<= 1; - if (rawbits[i]) { - res |= 0x01; - } - } - return res; - } - - /** - * Reads a code of length 8 in an array of bits, padding with zeros - */ - private static byte readByte(boolean[] rawbits, int startIndex) { - int n = rawbits.length - startIndex; - if (n >= 8) { - return (byte) readCode(rawbits, startIndex, 8); - } - return (byte) (readCode(rawbits, startIndex, n) << (8 - n)); - } - - /** - * Packs a bit array into bytes, most significant bit first - */ - static byte[] convertBoolArrayToByteArray(boolean[] boolArr) { - byte[] byteArr = new byte[(boolArr.length + 7) / 8]; - for (int i = 0; i < byteArr.length; i++) { - byteArr[i] = readByte(boolArr, 8 * i); - } - return byteArr; - } - - private static int totalBitsInLayer(int layers, boolean compact) { - return ((compact ? 88 : 112) + 16 * layers) * layers; - } -} diff --git a/port_src/core/DONE/aztec/detector/Detector.java b/port_src/core/DONE/aztec/detector/Detector.java deleted file mode 100644 index c078a94..0000000 --- a/port_src/core/DONE/aztec/detector/Detector.java +++ /dev/null @@ -1,603 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec.detector; - -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPoint; -import com.google.zxing.aztec.AztecDetectorResult; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.GridSampler; -import com.google.zxing.common.detector.MathUtils; -import com.google.zxing.common.detector.WhiteRectangleDetector; -import com.google.zxing.common.reedsolomon.GenericGF; -import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; -import com.google.zxing.common.reedsolomon.ReedSolomonException; - -/** - * Encapsulates logic that can detect an Aztec Code in an image, even if the Aztec Code - * is rotated or skewed, or partially obscured. - * - * @author David Olivier - * @author Frank Yellin - */ -public final class Detector { - - private static final int[] EXPECTED_CORNER_BITS = { - 0xee0, // 07340 XXX .XX X.. ... - 0x1dc, // 00734 ... XXX .XX X.. - 0x83b, // 04073 X.. ... XXX .XX - 0x707, // 03407 .XX X.. ... XXX - }; - - private final BitMatrix image; - - private boolean compact; - private int nbLayers; - private int nbDataBlocks; - private int nbCenterLayers; - private int shift; - - public Detector(BitMatrix image) { - this.image = image; - } - - public AztecDetectorResult detect() throws NotFoundException { - return detect(false); - } - - /** - * Detects an Aztec Code in an image. - * - * @param isMirror if true, image is a mirror-image of original - * @return {@link AztecDetectorResult} encapsulating results of detecting an Aztec Code - * @throws NotFoundException if no Aztec Code can be found - */ - public AztecDetectorResult detect(boolean isMirror) throws NotFoundException { - - // 1. Get the center of the aztec matrix - Point pCenter = getMatrixCenter(); - - // 2. Get the center points of the four diagonal points just outside the bull's eye - // [topRight, bottomRight, bottomLeft, topLeft] - ResultPoint[] bullsEyeCorners = getBullsEyeCorners(pCenter); - - if (isMirror) { - ResultPoint temp = bullsEyeCorners[0]; - bullsEyeCorners[0] = bullsEyeCorners[2]; - bullsEyeCorners[2] = temp; - } - - // 3. Get the size of the matrix and other parameters from the bull's eye - extractParameters(bullsEyeCorners); - - // 4. Sample the grid - BitMatrix bits = sampleGrid(image, - bullsEyeCorners[shift % 4], - bullsEyeCorners[(shift + 1) % 4], - bullsEyeCorners[(shift + 2) % 4], - bullsEyeCorners[(shift + 3) % 4]); - - // 5. Get the corners of the matrix. - ResultPoint[] corners = getMatrixCornerPoints(bullsEyeCorners); - - return new AztecDetectorResult(bits, corners, compact, nbDataBlocks, nbLayers); - } - - /** - * Extracts the number of data layers and data blocks from the layer around the bull's eye. - * - * @param bullsEyeCorners the array of bull's eye corners - * @throws NotFoundException in case of too many errors or invalid parameters - */ - private void extractParameters(ResultPoint[] bullsEyeCorners) throws NotFoundException { - if (!isValid(bullsEyeCorners[0]) || !isValid(bullsEyeCorners[1]) || - !isValid(bullsEyeCorners[2]) || !isValid(bullsEyeCorners[3])) { - throw NotFoundException.getNotFoundInstance(); - } - int length = 2 * nbCenterLayers; - // Get the bits around the bull's eye - int[] sides = { - sampleLine(bullsEyeCorners[0], bullsEyeCorners[1], length), // Right side - sampleLine(bullsEyeCorners[1], bullsEyeCorners[2], length), // Bottom - sampleLine(bullsEyeCorners[2], bullsEyeCorners[3], length), // Left side - sampleLine(bullsEyeCorners[3], bullsEyeCorners[0], length) // Top - }; - - // bullsEyeCorners[shift] is the corner of the bulls'eye that has three - // orientation marks. - // sides[shift] is the row/column that goes from the corner with three - // orientation marks to the corner with two. - shift = getRotation(sides, length); - - // Flatten the parameter bits into a single 28- or 40-bit long - long parameterData = 0; - for (int i = 0; i < 4; i++) { - int side = sides[(shift + i) % 4]; - if (compact) { - // Each side of the form ..XXXXXXX. where Xs are parameter data - parameterData <<= 7; - parameterData += (side >> 1) & 0x7F; - } else { - // Each side of the form ..XXXXX.XXXXX. where Xs are parameter data - parameterData <<= 10; - parameterData += ((side >> 2) & (0x1f << 5)) + ((side >> 1) & 0x1F); - } - } - - // Corrects parameter data using RS. Returns just the data portion - // without the error correction. - int correctedData = getCorrectedParameterData(parameterData, compact); - - if (compact) { - // 8 bits: 2 bits layers and 6 bits data blocks - nbLayers = (correctedData >> 6) + 1; - nbDataBlocks = (correctedData & 0x3F) + 1; - } else { - // 16 bits: 5 bits layers and 11 bits data blocks - nbLayers = (correctedData >> 11) + 1; - nbDataBlocks = (correctedData & 0x7FF) + 1; - } - } - - private static int getRotation(int[] sides, int length) throws NotFoundException { - // In a normal pattern, we expect to See - // ** .* D A - // * * - // - // . * - // .. .. C B - // - // Grab the 3 bits from each of the sides the form the locator pattern and concatenate - // into a 12-bit integer. Start with the bit at A - int cornerBits = 0; - for (int side : sides) { - // XX......X where X's are orientation marks - int t = ((side >> (length - 2)) << 1) + (side & 1); - cornerBits = (cornerBits << 3) + t; - } - // Mov the bottom bit to the top, so that the three bits of the locator pattern at A are - // together. cornerBits is now: - // 3 orientation bits at A || 3 orientation bits at B || ... || 3 orientation bits at D - cornerBits = ((cornerBits & 1) << 11) + (cornerBits >> 1); - // The result shift indicates which element of BullsEyeCorners[] goes into the top-left - // corner. Since the four rotation values have a Hamming distance of 8, we - // can easily tolerate two errors. - for (int shift = 0; shift < 4; shift++) { - if (Integer.bitCount(cornerBits ^ EXPECTED_CORNER_BITS[shift]) <= 2) { - return shift; - } - } - throw NotFoundException.getNotFoundInstance(); - } - - /** - * Corrects the parameter bits using Reed-Solomon algorithm. - * - * @param parameterData parameter bits - * @param compact true if this is a compact Aztec code - * @throws NotFoundException if the array contains too many errors - */ - private static int getCorrectedParameterData(long parameterData, boolean compact) throws NotFoundException { - int numCodewords; - int numDataCodewords; - - if (compact) { - numCodewords = 7; - numDataCodewords = 2; - } else { - numCodewords = 10; - numDataCodewords = 4; - } - - int numECCodewords = numCodewords - numDataCodewords; - int[] parameterWords = new int[numCodewords]; - for (int i = numCodewords - 1; i >= 0; --i) { - parameterWords[i] = (int) parameterData & 0xF; - parameterData >>= 4; - } - try { - ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM); - rsDecoder.decode(parameterWords, numECCodewords); - } catch (ReedSolomonException ignored) { - throw NotFoundException.getNotFoundInstance(); - } - // Toss the error correction. Just return the data as an integer - int result = 0; - for (int i = 0; i < numDataCodewords; i++) { - result = (result << 4) + parameterWords[i]; - } - return result; - } - - /** - * Finds the corners of a bull-eye centered on the passed point. - * This returns the centers of the diagonal points just outside the bull's eye - * Returns [topRight, bottomRight, bottomLeft, topLeft] - * - * @param pCenter Center point - * @return The corners of the bull-eye - * @throws NotFoundException If no valid bull-eye can be found - */ - private ResultPoint[] getBullsEyeCorners(Point pCenter) throws NotFoundException { - - Point pina = pCenter; - Point pinb = pCenter; - Point pinc = pCenter; - Point pind = pCenter; - - boolean color = true; - - for (nbCenterLayers = 1; nbCenterLayers < 9; nbCenterLayers++) { - Point pouta = getFirstDifferent(pina, color, 1, -1); - Point poutb = getFirstDifferent(pinb, color, 1, 1); - Point poutc = getFirstDifferent(pinc, color, -1, 1); - Point poutd = getFirstDifferent(pind, color, -1, -1); - - //d a - // - //c b - - if (nbCenterLayers > 2) { - float q = distance(poutd, pouta) * nbCenterLayers / (distance(pind, pina) * (nbCenterLayers + 2)); - if (q < 0.75 || q > 1.25 || !isWhiteOrBlackRectangle(pouta, poutb, poutc, poutd)) { - break; - } - } - - pina = pouta; - pinb = poutb; - pinc = poutc; - pind = poutd; - - color = !color; - } - - if (nbCenterLayers != 5 && nbCenterLayers != 7) { - throw NotFoundException.getNotFoundInstance(); - } - - compact = nbCenterLayers == 5; - - // Expand the square by .5 pixel in each direction so that we're on the border - // between the white square and the black square - ResultPoint pinax = new ResultPoint(pina.getX() + 0.5f, pina.getY() - 0.5f); - ResultPoint pinbx = new ResultPoint(pinb.getX() + 0.5f, pinb.getY() + 0.5f); - ResultPoint pincx = new ResultPoint(pinc.getX() - 0.5f, pinc.getY() + 0.5f); - ResultPoint pindx = new ResultPoint(pind.getX() - 0.5f, pind.getY() - 0.5f); - - // Expand the square so that its corners are the centers of the points - // just outside the bull's eye. - return expandSquare(new ResultPoint[]{pinax, pinbx, pincx, pindx}, - 2 * nbCenterLayers - 3, - 2 * nbCenterLayers); - } - - /** - * Finds a candidate center point of an Aztec code from an image - * - * @return the center point - */ - private Point getMatrixCenter() { - - ResultPoint pointA; - ResultPoint pointB; - ResultPoint pointC; - ResultPoint pointD; - - //Get a white rectangle that can be the border of the matrix in center bull's eye or - try { - - ResultPoint[] cornerPoints = new WhiteRectangleDetector(image).detect(); - pointA = cornerPoints[0]; - pointB = cornerPoints[1]; - pointC = cornerPoints[2]; - pointD = cornerPoints[3]; - - } catch (NotFoundException e) { - - // This exception can be in case the initial rectangle is white - // In that case, surely in the bull's eye, we try to expand the rectangle. - int cx = image.getWidth() / 2; - int cy = image.getHeight() / 2; - pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint(); - pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint(); - pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint(); - pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint(); - - } - - //Compute the center of the rectangle - int cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0f); - int cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0f); - - // Redetermine the white rectangle starting from previously computed center. - // This will ensure that we end up with a white rectangle in center bull's eye - // in order to compute a more accurate center. - try { - ResultPoint[] cornerPoints = new WhiteRectangleDetector(image, 15, cx, cy).detect(); - pointA = cornerPoints[0]; - pointB = cornerPoints[1]; - pointC = cornerPoints[2]; - pointD = cornerPoints[3]; - } catch (NotFoundException e) { - // This exception can be in case the initial rectangle is white - // In that case we try to expand the rectangle. - pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint(); - pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint(); - pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint(); - pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint(); - } - - // Recompute the center of the rectangle - cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0f); - cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0f); - - return new Point(cx, cy); - } - - /** - * Gets the Aztec code corners from the bull's eye corners and the parameters. - * - * @param bullsEyeCorners the array of bull's eye corners - * @return the array of aztec code corners - */ - private ResultPoint[] getMatrixCornerPoints(ResultPoint[] bullsEyeCorners) { - return expandSquare(bullsEyeCorners, 2 * nbCenterLayers, getDimension()); - } - - /** - * Creates a BitMatrix by sampling the provided image. - * topLeft, topRight, bottomRight, and bottomLeft are the centers of the squares on the - * diagonal just outside the bull's eye. - */ - private BitMatrix sampleGrid(BitMatrix image, - ResultPoint topLeft, - ResultPoint topRight, - ResultPoint bottomRight, - ResultPoint bottomLeft) throws NotFoundException { - - GridSampler sampler = GridSampler.getInstance(); - int dimension = getDimension(); - - float low = dimension / 2.0f - nbCenterLayers; - float high = dimension / 2.0f + nbCenterLayers; - - return sampler.sampleGrid(image, - dimension, - dimension, - low, low, // topleft - high, low, // topright - high, high, // bottomright - low, high, // bottomleft - topLeft.getX(), topLeft.getY(), - topRight.getX(), topRight.getY(), - bottomRight.getX(), bottomRight.getY(), - bottomLeft.getX(), bottomLeft.getY()); - } - - /** - * Samples a line. - * - * @param p1 start point (inclusive) - * @param p2 end point (exclusive) - * @param size number of bits - * @return the array of bits as an int (first bit is high-order bit of result) - */ - private int sampleLine(ResultPoint p1, ResultPoint p2, int size) { - int result = 0; - - float d = distance(p1, p2); - float moduleSize = d / size; - float px = p1.getX(); - float py = p1.getY(); - float dx = moduleSize * (p2.getX() - p1.getX()) / d; - float dy = moduleSize * (p2.getY() - p1.getY()) / d; - for (int i = 0; i < size; i++) { - if (image.get(MathUtils.round(px + i * dx), MathUtils.round(py + i * dy))) { - result |= 1 << (size - i - 1); - } - } - return result; - } - - /** - * @return true if the border of the rectangle passed in parameter is compound of white points only - * or black points only - */ - private boolean isWhiteOrBlackRectangle(Point p1, - Point p2, - Point p3, - Point p4) { - - int corr = 3; - - p1 = new Point(Math.max(0, p1.getX() - corr), Math.min(image.getHeight() - 1, p1.getY() + corr)); - p2 = new Point(Math.max(0, p2.getX() - corr), Math.max(0, p2.getY() - corr)); - p3 = new Point(Math.min(image.getWidth() - 1, p3.getX() + corr), - Math.max(0, Math.min(image.getHeight() - 1, p3.getY() - corr))); - p4 = new Point(Math.min(image.getWidth() - 1, p4.getX() + corr), - Math.min(image.getHeight() - 1, p4.getY() + corr)); - - int cInit = getColor(p4, p1); - - if (cInit == 0) { - return false; - } - - int c = getColor(p1, p2); - - if (c != cInit) { - return false; - } - - c = getColor(p2, p3); - - if (c != cInit) { - return false; - } - - c = getColor(p3, p4); - - return c == cInit; - - } - - /** - * Gets the color of a segment - * - * @return 1 if segment more than 90% black, -1 if segment is more than 90% white, 0 else - */ - private int getColor(Point p1, Point p2) { - float d = distance(p1, p2); - if (d == 0.0f) { - return 0; - } - float dx = (p2.getX() - p1.getX()) / d; - float dy = (p2.getY() - p1.getY()) / d; - int error = 0; - - float px = p1.getX(); - float py = p1.getY(); - - boolean colorModel = image.get(p1.getX(), p1.getY()); - - int iMax = (int) Math.floor(d); - for (int i = 0; i < iMax; i++) { - if (image.get(MathUtils.round(px), MathUtils.round(py)) != colorModel) { - error++; - } - px += dx; - py += dy; - } - - float errRatio = error / d; - - if (errRatio > 0.1f && errRatio < 0.9f) { - return 0; - } - - return (errRatio <= 0.1f) == colorModel ? 1 : -1; - } - - /** - * Gets the coordinate of the first point with a different color in the given direction - */ - private Point getFirstDifferent(Point init, boolean color, int dx, int dy) { - int x = init.getX() + dx; - int y = init.getY() + dy; - - while (isValid(x, y) && image.get(x, y) == color) { - x += dx; - y += dy; - } - - x -= dx; - y -= dy; - - while (isValid(x, y) && image.get(x, y) == color) { - x += dx; - } - x -= dx; - - while (isValid(x, y) && image.get(x, y) == color) { - y += dy; - } - y -= dy; - - return new Point(x, y); - } - - /** - * Expand the square represented by the corner points by pushing out equally in all directions - * - * @param cornerPoints the corners of the square, which has the bull's eye at its center - * @param oldSide the original length of the side of the square in the target bit matrix - * @param newSide the new length of the size of the square in the target bit matrix - * @return the corners of the expanded square - */ - private static ResultPoint[] expandSquare(ResultPoint[] cornerPoints, int oldSide, int newSide) { - float ratio = newSide / (2.0f * oldSide); - float dx = cornerPoints[0].getX() - cornerPoints[2].getX(); - float dy = cornerPoints[0].getY() - cornerPoints[2].getY(); - float centerx = (cornerPoints[0].getX() + cornerPoints[2].getX()) / 2.0f; - float centery = (cornerPoints[0].getY() + cornerPoints[2].getY()) / 2.0f; - - ResultPoint result0 = new ResultPoint(centerx + ratio * dx, centery + ratio * dy); - ResultPoint result2 = new ResultPoint(centerx - ratio * dx, centery - ratio * dy); - - dx = cornerPoints[1].getX() - cornerPoints[3].getX(); - dy = cornerPoints[1].getY() - cornerPoints[3].getY(); - centerx = (cornerPoints[1].getX() + cornerPoints[3].getX()) / 2.0f; - centery = (cornerPoints[1].getY() + cornerPoints[3].getY()) / 2.0f; - ResultPoint result1 = new ResultPoint(centerx + ratio * dx, centery + ratio * dy); - ResultPoint result3 = new ResultPoint(centerx - ratio * dx, centery - ratio * dy); - - return new ResultPoint[]{result0, result1, result2, result3}; - } - - private boolean isValid(int x, int y) { - return x >= 0 && x < image.getWidth() && y >= 0 && y < image.getHeight(); - } - - private boolean isValid(ResultPoint point) { - int x = MathUtils.round(point.getX()); - int y = MathUtils.round(point.getY()); - return isValid(x, y); - } - - private static float distance(Point a, Point b) { - return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY()); - } - - private static float distance(ResultPoint a, ResultPoint b) { - return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY()); - } - - private int getDimension() { - if (compact) { - return 4 * nbLayers + 11; - } - return 4 * nbLayers + 2 * ((2 * nbLayers + 6) / 15) + 15; - } - - static final class Point { - private final int x; - private final int y; - - ResultPoint toResultPoint() { - return new ResultPoint(x, y); - } - - Point(int x, int y) { - this.x = x; - this.y = y; - } - - int getX() { - return x; - } - - int getY() { - return y; - } - - @Override - public String toString() { - return "<" + x + ' ' + y + '>'; - } - } -} diff --git a/port_src/core/DONE/aztec/encoder/AztecCode.java b/port_src/core/DONE/aztec/encoder/AztecCode.java deleted file mode 100644 index 6426d4e..0000000 --- a/port_src/core/DONE/aztec/encoder/AztecCode.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec.encoder; - -import com.google.zxing.common.BitMatrix; - -/** - * Aztec 2D code representation - * - * @author Rustam Abdullaev - */ -public final class AztecCode { - - private boolean compact; - private int size; - private int layers; - private int codeWords; - private BitMatrix matrix; - - /** - * @return {@code true} if compact instead of full mode - */ - public boolean isCompact() { - return compact; - } - - public void setCompact(boolean compact) { - this.compact = compact; - } - - /** - * @return size in pixels (width and height) - */ - public int getSize() { - return size; - } - - public void setSize(int size) { - this.size = size; - } - - /** - * @return number of levels - */ - public int getLayers() { - return layers; - } - - public void setLayers(int layers) { - this.layers = layers; - } - - /** - * @return number of data codewords - */ - public int getCodeWords() { - return codeWords; - } - - public void setCodeWords(int codeWords) { - this.codeWords = codeWords; - } - - /** - * @return the symbol image - */ - public BitMatrix getMatrix() { - return matrix; - } - - public void setMatrix(BitMatrix matrix) { - this.matrix = matrix; - } - -} diff --git a/port_src/core/DONE/aztec/encoder/BinaryShiftToken.java b/port_src/core/DONE/aztec/encoder/BinaryShiftToken.java deleted file mode 100644 index 969b4dc..0000000 --- a/port_src/core/DONE/aztec/encoder/BinaryShiftToken.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec.encoder; - -import com.google.zxing.common.BitArray; - -final class BinaryShiftToken extends Token { - - private final int binaryShiftStart; - private final int binaryShiftByteCount; - - BinaryShiftToken(Token previous, - int binaryShiftStart, - int binaryShiftByteCount) { - super(previous); - this.binaryShiftStart = binaryShiftStart; - this.binaryShiftByteCount = binaryShiftByteCount; - } - - @Override - public void appendTo(BitArray bitArray, byte[] text) { - int bsbc = binaryShiftByteCount; - for (int i = 0; i < bsbc; i++) { - if (i == 0 || (i == 31 && bsbc <= 62)) { - // We need a header before the first character, and before - // character 31 when the total byte code is <= 62 - bitArray.appendBits(31, 5); // BINARY_SHIFT - if (bsbc > 62) { - bitArray.appendBits(bsbc - 31, 16); - } else if (i == 0) { - // 1 <= binaryShiftByteCode <= 62 - bitArray.appendBits(Math.min(bsbc, 31), 5); - } else { - // 32 <= binaryShiftCount <= 62 and i == 31 - bitArray.appendBits(bsbc - 31, 5); - } - } - bitArray.appendBits(text[binaryShiftStart + i], 8); - } - } - - @Override - public String toString() { - return "<" + binaryShiftStart + "::" + (binaryShiftStart + binaryShiftByteCount - 1) + '>'; - } - -} diff --git a/port_src/core/DONE/aztec/encoder/Encoder.java b/port_src/core/DONE/aztec/encoder/Encoder.java deleted file mode 100644 index 4acd8f6..0000000 --- a/port_src/core/DONE/aztec/encoder/Encoder.java +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec.encoder; - -import com.google.zxing.common.BitArray; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.reedsolomon.GenericGF; -import com.google.zxing.common.reedsolomon.ReedSolomonEncoder; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; - -/** - * Generates Aztec 2D barcodes. - * - * @author Rustam Abdullaev - */ -public final class Encoder { - - public static final int DEFAULT_EC_PERCENT = 33; // default minimal percentage of error check words - public static final int DEFAULT_AZTEC_LAYERS = 0; - private static final int MAX_NB_BITS = 32; - private static final int MAX_NB_BITS_COMPACT = 4; - - private static final int[] WORD_SIZE = { - 4, 6, 6, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 - }; - - private Encoder() { - } - - /** - * Encodes the given string content as an Aztec symbol (without ECI code) - * - * @param data input data string; must be encodable as ISO/IEC 8859-1 (Latin-1) - * @return Aztec symbol matrix with metadata - */ - public static AztecCode encode(String data) { - return encode(data.getBytes(StandardCharsets.ISO_8859_1)); - } - - /** - * Encodes the given string content as an Aztec symbol (without ECI code) - * - * @param data input data string; must be encodable as ISO/IEC 8859-1 (Latin-1) - * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008, - * a minimum of 23% + 3 words is recommended) - * @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers - * @return Aztec symbol matrix with metadata - */ - public static AztecCode encode(String data, int minECCPercent, int userSpecifiedLayers) { - return encode(data.getBytes(StandardCharsets.ISO_8859_1), minECCPercent, userSpecifiedLayers, null); - } - - /** - * Encodes the given string content as an Aztec symbol - * - * @param data input data string - * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008, - * a minimum of 23% + 3 words is recommended) - * @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers - * @param charset character set in which to encode string using ECI; if null, no ECI code - * will be inserted, and the string must be encodable as ISO/IEC 8859-1 - * (Latin-1), the default encoding of the symbol. - * @return Aztec symbol matrix with metadata - */ - public static AztecCode encode(String data, int minECCPercent, int userSpecifiedLayers, Charset charset) { - byte[] bytes = data.getBytes(null != charset ? charset : StandardCharsets.ISO_8859_1); - return encode(bytes, minECCPercent, userSpecifiedLayers, charset); - } - - /** - * Encodes the given binary content as an Aztec symbol (without ECI code) - * - * @param data input data string - * @return Aztec symbol matrix with metadata - */ - public static AztecCode encode(byte[] data) { - return encode(data, DEFAULT_EC_PERCENT, DEFAULT_AZTEC_LAYERS, null); - } - - /** - * Encodes the given binary content as an Aztec symbol (without ECI code) - * - * @param data input data string - * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008, - * a minimum of 23% + 3 words is recommended) - * @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers - * @return Aztec symbol matrix with metadata - */ - public static AztecCode encode(byte[] data, int minECCPercent, int userSpecifiedLayers) { - return encode(data, minECCPercent, userSpecifiedLayers, null); - } - - /** - * Encodes the given binary content as an Aztec symbol - * - * @param data input data string - * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008, - * a minimum of 23% + 3 words is recommended) - * @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers - * @param charset character set to mark using ECI; if null, no ECI code will be inserted, and the - * default encoding of ISO/IEC 8859-1 will be assuming by readers. - * @return Aztec symbol matrix with metadata - */ - public static AztecCode encode(byte[] data, int minECCPercent, int userSpecifiedLayers, Charset charset) { - // High-level encode - BitArray bits = new HighLevelEncoder(data, charset).encode(); - - // stuff bits and choose symbol size - int eccBits = bits.getSize() * minECCPercent / 100 + 11; - int totalSizeBits = bits.getSize() + eccBits; - boolean compact; - int layers; - int totalBitsInLayer; - int wordSize; - BitArray stuffedBits; - if (userSpecifiedLayers != DEFAULT_AZTEC_LAYERS) { - compact = userSpecifiedLayers < 0; - layers = Math.abs(userSpecifiedLayers); - if (layers > (compact ? MAX_NB_BITS_COMPACT : MAX_NB_BITS)) { - throw new IllegalArgumentException( - String.format("Illegal value %s for layers", userSpecifiedLayers)); - } - totalBitsInLayer = totalBitsInLayer(layers, compact); - wordSize = WORD_SIZE[layers]; - int usableBitsInLayers = totalBitsInLayer - (totalBitsInLayer % wordSize); - stuffedBits = stuffBits(bits, wordSize); - if (stuffedBits.getSize() + eccBits > usableBitsInLayers) { - throw new IllegalArgumentException("Data to large for user specified layer"); - } - if (compact && stuffedBits.getSize() > wordSize * 64) { - // Compact format only allows 64 data words, though C4 can hold more words than that - throw new IllegalArgumentException("Data to large for user specified layer"); - } - } else { - wordSize = 0; - stuffedBits = null; - // We look at the possible table sizes in the order Compact1, Compact2, Compact3, - // Compact4, Normal4,... Normal(i) for i < 4 isn't typically used since Compact(i+1) - // is the same size, but has more data. - for (int i = 0; ; i++) { - if (i > MAX_NB_BITS) { - throw new IllegalArgumentException("Data too large for an Aztec code"); - } - compact = i <= 3; - layers = compact ? i + 1 : i; - totalBitsInLayer = totalBitsInLayer(layers, compact); - if (totalSizeBits > totalBitsInLayer) { - continue; - } - // [Re]stuff the bits if this is the first opportunity, or if the - // wordSize has changed - if (stuffedBits == null || wordSize != WORD_SIZE[layers]) { - wordSize = WORD_SIZE[layers]; - stuffedBits = stuffBits(bits, wordSize); - } - int usableBitsInLayers = totalBitsInLayer - (totalBitsInLayer % wordSize); - if (compact && stuffedBits.getSize() > wordSize * 64) { - // Compact format only allows 64 data words, though C4 can hold more words than that - continue; - } - if (stuffedBits.getSize() + eccBits <= usableBitsInLayers) { - break; - } - } - } - BitArray messageBits = generateCheckWords(stuffedBits, totalBitsInLayer, wordSize); - - // generate mode message - int messageSizeInWords = stuffedBits.getSize() / wordSize; - BitArray modeMessage = generateModeMessage(compact, layers, messageSizeInWords); - - // allocate symbol - int baseMatrixSize = (compact ? 11 : 14) + layers * 4; // not including alignment lines - int[] alignmentMap = new int[baseMatrixSize]; - int matrixSize; - if (compact) { - // no alignment marks in compact mode, alignmentMap is a no-op - matrixSize = baseMatrixSize; - for (int i = 0; i < alignmentMap.length; i++) { - alignmentMap[i] = i; - } - } else { - matrixSize = baseMatrixSize + 1 + 2 * ((baseMatrixSize / 2 - 1) / 15); - int origCenter = baseMatrixSize / 2; - int center = matrixSize / 2; - for (int i = 0; i < origCenter; i++) { - int newOffset = i + i / 15; - alignmentMap[origCenter - i - 1] = center - newOffset - 1; - alignmentMap[origCenter + i] = center + newOffset + 1; - } - } - BitMatrix matrix = new BitMatrix(matrixSize); - - // draw data bits - for (int i = 0, rowOffset = 0; i < layers; i++) { - int rowSize = (layers - i) * 4 + (compact ? 9 : 12); - for (int j = 0; j < rowSize; j++) { - int columnOffset = j * 2; - for (int k = 0; k < 2; k++) { - if (messageBits.get(rowOffset + columnOffset + k)) { - matrix.set(alignmentMap[i * 2 + k], alignmentMap[i * 2 + j]); - } - if (messageBits.get(rowOffset + rowSize * 2 + columnOffset + k)) { - matrix.set(alignmentMap[i * 2 + j], alignmentMap[baseMatrixSize - 1 - i * 2 - k]); - } - if (messageBits.get(rowOffset + rowSize * 4 + columnOffset + k)) { - matrix.set(alignmentMap[baseMatrixSize - 1 - i * 2 - k], alignmentMap[baseMatrixSize - 1 - i * 2 - j]); - } - if (messageBits.get(rowOffset + rowSize * 6 + columnOffset + k)) { - matrix.set(alignmentMap[baseMatrixSize - 1 - i * 2 - j], alignmentMap[i * 2 + k]); - } - } - } - rowOffset += rowSize * 8; - } - - // draw mode message - drawModeMessage(matrix, compact, matrixSize, modeMessage); - - // draw alignment marks - if (compact) { - drawBullsEye(matrix, matrixSize / 2, 5); - } else { - drawBullsEye(matrix, matrixSize / 2, 7); - for (int i = 0, j = 0; i < baseMatrixSize / 2 - 1; i += 15, j += 16) { - for (int k = (matrixSize / 2) & 1; k < matrixSize; k += 2) { - matrix.set(matrixSize / 2 - j, k); - matrix.set(matrixSize / 2 + j, k); - matrix.set(k, matrixSize / 2 - j); - matrix.set(k, matrixSize / 2 + j); - } - } - } - - AztecCode aztec = new AztecCode(); - aztec.setCompact(compact); - aztec.setSize(matrixSize); - aztec.setLayers(layers); - aztec.setCodeWords(messageSizeInWords); - aztec.setMatrix(matrix); - return aztec; - } - - private static void drawBullsEye(BitMatrix matrix, int center, int size) { - for (int i = 0; i < size; i += 2) { - for (int j = center - i; j <= center + i; j++) { - matrix.set(j, center - i); - matrix.set(j, center + i); - matrix.set(center - i, j); - matrix.set(center + i, j); - } - } - matrix.set(center - size, center - size); - matrix.set(center - size + 1, center - size); - matrix.set(center - size, center - size + 1); - matrix.set(center + size, center - size); - matrix.set(center + size, center - size + 1); - matrix.set(center + size, center + size - 1); - } - - static BitArray generateModeMessage(boolean compact, int layers, int messageSizeInWords) { - BitArray modeMessage = new BitArray(); - if (compact) { - modeMessage.appendBits(layers - 1, 2); - modeMessage.appendBits(messageSizeInWords - 1, 6); - modeMessage = generateCheckWords(modeMessage, 28, 4); - } else { - modeMessage.appendBits(layers - 1, 5); - modeMessage.appendBits(messageSizeInWords - 1, 11); - modeMessage = generateCheckWords(modeMessage, 40, 4); - } - return modeMessage; - } - - private static void drawModeMessage(BitMatrix matrix, boolean compact, int matrixSize, BitArray modeMessage) { - int center = matrixSize / 2; - if (compact) { - for (int i = 0; i < 7; i++) { - int offset = center - 3 + i; - if (modeMessage.get(i)) { - matrix.set(offset, center - 5); - } - if (modeMessage.get(i + 7)) { - matrix.set(center + 5, offset); - } - if (modeMessage.get(20 - i)) { - matrix.set(offset, center + 5); - } - if (modeMessage.get(27 - i)) { - matrix.set(center - 5, offset); - } - } - } else { - for (int i = 0; i < 10; i++) { - int offset = center - 5 + i + i / 5; - if (modeMessage.get(i)) { - matrix.set(offset, center - 7); - } - if (modeMessage.get(i + 10)) { - matrix.set(center + 7, offset); - } - if (modeMessage.get(29 - i)) { - matrix.set(offset, center + 7); - } - if (modeMessage.get(39 - i)) { - matrix.set(center - 7, offset); - } - } - } - } - - private static BitArray generateCheckWords(BitArray bitArray, int totalBits, int wordSize) { - // bitArray is guaranteed to be a multiple of the wordSize, so no padding needed - int messageSizeInWords = bitArray.getSize() / wordSize; - ReedSolomonEncoder rs = new ReedSolomonEncoder(getGF(wordSize)); - int totalWords = totalBits / wordSize; - int[] messageWords = bitsToWords(bitArray, wordSize, totalWords); - rs.encode(messageWords, totalWords - messageSizeInWords); - int startPad = totalBits % wordSize; - BitArray messageBits = new BitArray(); - messageBits.appendBits(0, startPad); - for (int messageWord : messageWords) { - messageBits.appendBits(messageWord, wordSize); - } - return messageBits; - } - - private static int[] bitsToWords(BitArray stuffedBits, int wordSize, int totalWords) { - int[] message = new int[totalWords]; - int i; - int n; - for (i = 0, n = stuffedBits.getSize() / wordSize; i < n; i++) { - int value = 0; - for (int j = 0; j < wordSize; j++) { - value |= stuffedBits.get(i * wordSize + j) ? (1 << wordSize - j - 1) : 0; - } - message[i] = value; - } - return message; - } - - private static GenericGF getGF(int wordSize) { - switch (wordSize) { - case 4: - return GenericGF.AZTEC_PARAM; - case 6: - return GenericGF.AZTEC_DATA_6; - case 8: - return GenericGF.AZTEC_DATA_8; - case 10: - return GenericGF.AZTEC_DATA_10; - case 12: - return GenericGF.AZTEC_DATA_12; - default: - throw new IllegalArgumentException("Unsupported word size " + wordSize); - } - } - - static BitArray stuffBits(BitArray bits, int wordSize) { - BitArray out = new BitArray(); - - int n = bits.getSize(); - int mask = (1 << wordSize) - 2; - for (int i = 0; i < n; i += wordSize) { - int word = 0; - for (int j = 0; j < wordSize; j++) { - if (i + j >= n || bits.get(i + j)) { - word |= 1 << (wordSize - 1 - j); - } - } - if ((word & mask) == mask) { - out.appendBits(word & mask, wordSize); - i--; - } else if ((word & mask) == 0) { - out.appendBits(word | 1, wordSize); - i--; - } else { - out.appendBits(word, wordSize); - } - } - return out; - } - - private static int totalBitsInLayer(int layers, boolean compact) { - return ((compact ? 88 : 112) + 16 * layers) * layers; - } -} diff --git a/port_src/core/DONE/aztec/encoder/HighLevelEncoder.java b/port_src/core/DONE/aztec/encoder/HighLevelEncoder.java deleted file mode 100644 index 1d0cd4b..0000000 --- a/port_src/core/DONE/aztec/encoder/HighLevelEncoder.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec.encoder; - -import com.google.zxing.common.BitArray; -import com.google.zxing.common.CharacterSetECI; - -import java.nio.charset.Charset; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Deque; -import java.util.Iterator; -import java.util.LinkedList; - -/** - * This produces nearly optimal encodings of text into the first-level of - * encoding used by Aztec code. - * - * It uses a dynamic algorithm. For each prefix of the string, it determines - * a set of encodings that could lead to this prefix. We repeatedly add a - * character and generate a new set of optimal encodings until we have read - * through the entire input. - * - * @author Frank Yellin - * @author Rustam Abdullaev - */ -public final class HighLevelEncoder { - - static final String[] MODE_NAMES = {"UPPER", "LOWER", "DIGIT", "MIXED", "PUNCT"}; - - static final int MODE_UPPER = 0; // 5 bits - static final int MODE_LOWER = 1; // 5 bits - static final int MODE_DIGIT = 2; // 4 bits - static final int MODE_MIXED = 3; // 5 bits - static final int MODE_PUNCT = 4; // 5 bits - - // The Latch Table shows, for each pair of Modes, the optimal method for - // getting from one mode to another. In the worst possible case, this can - // be up to 14 bits. In the best possible case, we are already there! - // The high half-word of each entry gives the number of bits. - // The low half-word of each entry are the actual bits necessary to change - static final int[][] LATCH_TABLE = { - { - 0, - (5 << 16) + 28, // UPPER -> LOWER - (5 << 16) + 30, // UPPER -> DIGIT - (5 << 16) + 29, // UPPER -> MIXED - (10 << 16) + (29 << 5) + 30, // UPPER -> MIXED -> PUNCT - }, - { - (9 << 16) + (30 << 4) + 14, // LOWER -> DIGIT -> UPPER - 0, - (5 << 16) + 30, // LOWER -> DIGIT - (5 << 16) + 29, // LOWER -> MIXED - (10 << 16) + (29 << 5) + 30, // LOWER -> MIXED -> PUNCT - }, - { - (4 << 16) + 14, // DIGIT -> UPPER - (9 << 16) + (14 << 5) + 28, // DIGIT -> UPPER -> LOWER - 0, - (9 << 16) + (14 << 5) + 29, // DIGIT -> UPPER -> MIXED - (14 << 16) + (14 << 10) + (29 << 5) + 30, - // DIGIT -> UPPER -> MIXED -> PUNCT - }, - { - (5 << 16) + 29, // MIXED -> UPPER - (5 << 16) + 28, // MIXED -> LOWER - (10 << 16) + (29 << 5) + 30, // MIXED -> UPPER -> DIGIT - 0, - (5 << 16) + 30, // MIXED -> PUNCT - }, - { - (5 << 16) + 31, // PUNCT -> UPPER - (10 << 16) + (31 << 5) + 28, // PUNCT -> UPPER -> LOWER - (10 << 16) + (31 << 5) + 30, // PUNCT -> UPPER -> DIGIT - (10 << 16) + (31 << 5) + 29, // PUNCT -> UPPER -> MIXED - 0, - }, - }; - - // A reverse mapping from [mode][char] to the encoding for that character - // in that mode. An entry of 0 indicates no mapping exists. - private static final int[][] CHAR_MAP = new int[5][256]; - static { - CHAR_MAP[MODE_UPPER][' '] = 1; - for (int c = 'A'; c <= 'Z'; c++) { - CHAR_MAP[MODE_UPPER][c] = c - 'A' + 2; - } - CHAR_MAP[MODE_LOWER][' '] = 1; - for (int c = 'a'; c <= 'z'; c++) { - CHAR_MAP[MODE_LOWER][c] = c - 'a' + 2; - } - CHAR_MAP[MODE_DIGIT][' '] = 1; - for (int c = '0'; c <= '9'; c++) { - CHAR_MAP[MODE_DIGIT][c] = c - '0' + 2; - } - CHAR_MAP[MODE_DIGIT][','] = 12; - CHAR_MAP[MODE_DIGIT]['.'] = 13; - int[] mixedTable = { - '\0', ' ', '\1', '\2', '\3', '\4', '\5', '\6', '\7', '\b', '\t', '\n', - '\13', '\f', '\r', '\33', '\34', '\35', '\36', '\37', '@', '\\', '^', - '_', '`', '|', '~', '\177' - }; - for (int i = 0; i < mixedTable.length; i++) { - CHAR_MAP[MODE_MIXED][mixedTable[i]] = i; - } - int[] punctTable = { - '\0', '\r', '\0', '\0', '\0', '\0', '!', '\'', '#', '$', '%', '&', '\'', - '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', - '[', ']', '{', '}' - }; - for (int i = 0; i < punctTable.length; i++) { - if (punctTable[i] > 0) { - CHAR_MAP[MODE_PUNCT][punctTable[i]] = i; - } - } - } - - // A map showing the available shift codes. (The shifts to BINARY are not - // shown - static final int[][] SHIFT_TABLE = new int[6][6]; // mode shift codes, per table - static { - for (int[] table : SHIFT_TABLE) { - Arrays.fill(table, -1); - } - SHIFT_TABLE[MODE_UPPER][MODE_PUNCT] = 0; - - SHIFT_TABLE[MODE_LOWER][MODE_PUNCT] = 0; - SHIFT_TABLE[MODE_LOWER][MODE_UPPER] = 28; - - SHIFT_TABLE[MODE_MIXED][MODE_PUNCT] = 0; - - SHIFT_TABLE[MODE_DIGIT][MODE_PUNCT] = 0; - SHIFT_TABLE[MODE_DIGIT][MODE_UPPER] = 15; - } - - private final byte[] text; - private final Charset charset; - - public HighLevelEncoder(byte[] text) { - this.text = text; - this.charset = null; - } - - public HighLevelEncoder(byte[] text, Charset charset) { - this.text = text; - this.charset = charset; - } - - /** - * @return text represented by this encoder encoded as a {@link BitArray} - */ - public BitArray encode() { - State initialState = State.INITIAL_STATE; - if (charset != null) { - CharacterSetECI eci = CharacterSetECI.getCharacterSetECI(charset); - if (null == eci) { - throw new IllegalArgumentException("No ECI code for character set " + charset); - } - initialState = initialState.appendFLGn(eci.getValue()); - } - Collection states = Collections.singletonList(initialState); - for (int index = 0; index < text.length; index++) { - int pairCode; - int nextChar = index + 1 < text.length ? text[index + 1] : 0; - switch (text[index]) { - case '\r': - pairCode = nextChar == '\n' ? 2 : 0; - break; - case '.' : - pairCode = nextChar == ' ' ? 3 : 0; - break; - case ',' : - pairCode = nextChar == ' ' ? 4 : 0; - break; - case ':' : - pairCode = nextChar == ' ' ? 5 : 0; - break; - default: - pairCode = 0; - } - if (pairCode > 0) { - // We have one of the four special PUNCT pairs. Treat them specially. - // Get a new set of states for the two new characters. - states = updateStateListForPair(states, index, pairCode); - index++; - } else { - // Get a new set of states for the new character. - states = updateStateListForChar(states, index); - } - } - // We are left with a set of states. Find the shortest one. - State minState = Collections.min(states, new Comparator() { - @Override - public int compare(State a, State b) { - return a.getBitCount() - b.getBitCount(); - } - }); - // Convert it to a bit array, and return. - return minState.toBitArray(text); - } - - // We update a set of states for a new character by updating each state - // for the new character, merging the results, and then removing the - // non-optimal states. - private Collection updateStateListForChar(Iterable states, int index) { - Collection result = new LinkedList<>(); - for (State state : states) { - updateStateForChar(state, index, result); - } - return simplifyStates(result); - } - - // Return a set of states that represent the possible ways of updating this - // state for the next character. The resulting set of states are added to - // the "result" list. - private void updateStateForChar(State state, int index, Collection result) { - char ch = (char) (text[index] & 0xFF); - boolean charInCurrentTable = CHAR_MAP[state.getMode()][ch] > 0; - State stateNoBinary = null; - for (int mode = 0; mode <= MODE_PUNCT; mode++) { - int charInMode = CHAR_MAP[mode][ch]; - if (charInMode > 0) { - if (stateNoBinary == null) { - // Only create stateNoBinary the first time it's required. - stateNoBinary = state.endBinaryShift(index); - } - // Try generating the character by latching to its mode - if (!charInCurrentTable || mode == state.getMode() || mode == MODE_DIGIT) { - // If the character is in the current table, we don't want to latch to - // any other mode except possibly digit (which uses only 4 bits). Any - // other latch would be equally successful *after* this character, and - // so wouldn't save any bits. - State latchState = stateNoBinary.latchAndAppend(mode, charInMode); - result.add(latchState); - } - // Try generating the character by switching to its mode. - if (!charInCurrentTable && SHIFT_TABLE[state.getMode()][mode] >= 0) { - // It never makes sense to temporarily shift to another mode if the - // character exists in the current mode. That can never save bits. - State shiftState = stateNoBinary.shiftAndAppend(mode, charInMode); - result.add(shiftState); - } - } - } - if (state.getBinaryShiftByteCount() > 0 || CHAR_MAP[state.getMode()][ch] == 0) { - // It's never worthwhile to go into binary shift mode if you're not already - // in binary shift mode, and the character exists in your current mode. - // That can never save bits over just outputting the char in the current mode. - State binaryState = state.addBinaryShiftChar(index); - result.add(binaryState); - } - } - - private static Collection updateStateListForPair(Iterable states, int index, int pairCode) { - Collection result = new LinkedList<>(); - for (State state : states) { - updateStateForPair(state, index, pairCode, result); - } - return simplifyStates(result); - } - - private static void updateStateForPair(State state, int index, int pairCode, Collection result) { - State stateNoBinary = state.endBinaryShift(index); - // Possibility 1. Latch to MODE_PUNCT, and then append this code - result.add(stateNoBinary.latchAndAppend(MODE_PUNCT, pairCode)); - if (state.getMode() != MODE_PUNCT) { - // Possibility 2. Shift to MODE_PUNCT, and then append this code. - // Every state except MODE_PUNCT (handled above) can shift - result.add(stateNoBinary.shiftAndAppend(MODE_PUNCT, pairCode)); - } - if (pairCode == 3 || pairCode == 4) { - // both characters are in DIGITS. Sometimes better to just add two digits - State digitState = stateNoBinary - .latchAndAppend(MODE_DIGIT, 16 - pairCode) // period or comma in DIGIT - .latchAndAppend(MODE_DIGIT, 1); // space in DIGIT - result.add(digitState); - } - if (state.getBinaryShiftByteCount() > 0) { - // It only makes sense to do the characters as binary if we're already - // in binary mode. - State binaryState = state.addBinaryShiftChar(index).addBinaryShiftChar(index + 1); - result.add(binaryState); - } - } - - private static Collection simplifyStates(Iterable states) { - Deque result = new LinkedList<>(); - for (State newState : states) { - boolean add = true; - for (Iterator iterator = result.iterator(); iterator.hasNext();) { - State oldState = iterator.next(); - if (oldState.isBetterThanOrEqualTo(newState)) { - add = false; - break; - } - if (newState.isBetterThanOrEqualTo(oldState)) { - iterator.remove(); - } - } - if (add) { - result.addFirst(newState); - } - } - return result; - } - -} diff --git a/port_src/core/DONE/aztec/encoder/SimpleToken.java b/port_src/core/DONE/aztec/encoder/SimpleToken.java deleted file mode 100644 index d3b0c45..0000000 --- a/port_src/core/DONE/aztec/encoder/SimpleToken.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec.encoder; - -import com.google.zxing.common.BitArray; - -final class SimpleToken extends Token { - - // For normal words, indicates value and bitCount - private final short value; - private final short bitCount; - - SimpleToken(Token previous, int value, int bitCount) { - super(previous); - this.value = (short) value; - this.bitCount = (short) bitCount; - } - - @Override - void appendTo(BitArray bitArray, byte[] text) { - bitArray.appendBits(value, bitCount); - } - - @Override - public String toString() { - int value = this.value & ((1 << bitCount) - 1); - value |= 1 << bitCount; - return '<' + Integer.toBinaryString(value | (1 << bitCount)).substring(1) + '>'; - } - -} diff --git a/port_src/core/DONE/aztec/encoder/State.java b/port_src/core/DONE/aztec/encoder/State.java deleted file mode 100644 index 9771fba..0000000 --- a/port_src/core/DONE/aztec/encoder/State.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec.encoder; - -import java.nio.charset.StandardCharsets; - -import java.util.ArrayList; -import java.util.List; - -import com.google.zxing.common.BitArray; - -/** - * State represents all information about a sequence necessary to generate the current output. - * Note that a state is immutable. - */ -final class State { - - static final State INITIAL_STATE = new State(Token.EMPTY, HighLevelEncoder.MODE_UPPER, 0, 0); - - // The current mode of the encoding (or the mode to which we'll return if - // we're in Binary Shift mode. - private final int mode; - // The list of tokens that we output. If we are in Binary Shift mode, this - // token list does *not* yet included the token for those bytes - private final Token token; - // If non-zero, the number of most recent bytes that should be output - // in Binary Shift mode. - private final int binaryShiftByteCount; - // The total number of bits generated (including Binary Shift). - private final int bitCount; - private final int binaryShiftCost; - - private State(Token token, int mode, int binaryBytes, int bitCount) { - this.token = token; - this.mode = mode; - this.binaryShiftByteCount = binaryBytes; - this.bitCount = bitCount; - this.binaryShiftCost = calculateBinaryShiftCost(binaryBytes); - } - - int getMode() { - return mode; - } - - Token getToken() { - return token; - } - - int getBinaryShiftByteCount() { - return binaryShiftByteCount; - } - - int getBitCount() { - return bitCount; - } - - State appendFLGn(int eci) { - State result = shiftAndAppend(HighLevelEncoder.MODE_PUNCT, 0); // 0: FLG(n) - Token token = result.token; - int bitsAdded = 3; - if (eci < 0) { - token = token.add(0, 3); // 0: FNC1 - } else if (eci > 999999) { - throw new IllegalArgumentException("ECI code must be between 0 and 999999"); - } else { - byte[] eciDigits = Integer.toString(eci).getBytes(StandardCharsets.ISO_8859_1); - token = token.add(eciDigits.length, 3); // 1-6: number of ECI digits - for (byte eciDigit : eciDigits) { - token = token.add(eciDigit - '0' + 2, 4); - } - bitsAdded += eciDigits.length * 4; - } - return new State(token, mode, 0, bitCount + bitsAdded); - } - - // Create a new state representing this state with a latch to a (not - // necessary different) mode, and then a code. - State latchAndAppend(int mode, int value) { - int bitCount = this.bitCount; - Token token = this.token; - if (mode != this.mode) { - int latch = HighLevelEncoder.LATCH_TABLE[this.mode][mode]; - token = token.add(latch & 0xFFFF, latch >> 16); - bitCount += latch >> 16; - } - int latchModeBitCount = mode == HighLevelEncoder.MODE_DIGIT ? 4 : 5; - token = token.add(value, latchModeBitCount); - return new State(token, mode, 0, bitCount + latchModeBitCount); - } - - // Create a new state representing this state, with a temporary shift - // to a different mode to output a single value. - State shiftAndAppend(int mode, int value) { - Token token = this.token; - int thisModeBitCount = this.mode == HighLevelEncoder.MODE_DIGIT ? 4 : 5; - // Shifts exist only to UPPER and PUNCT, both with tokens size 5. - token = token.add(HighLevelEncoder.SHIFT_TABLE[this.mode][mode], thisModeBitCount); - token = token.add(value, 5); - return new State(token, this.mode, 0, this.bitCount + thisModeBitCount + 5); - } - - // Create a new state representing this state, but an additional character - // output in Binary Shift mode. - State addBinaryShiftChar(int index) { - Token token = this.token; - int mode = this.mode; - int bitCount = this.bitCount; - if (this.mode == HighLevelEncoder.MODE_PUNCT || this.mode == HighLevelEncoder.MODE_DIGIT) { - int latch = HighLevelEncoder.LATCH_TABLE[mode][HighLevelEncoder.MODE_UPPER]; - token = token.add(latch & 0xFFFF, latch >> 16); - bitCount += latch >> 16; - mode = HighLevelEncoder.MODE_UPPER; - } - int deltaBitCount = - (binaryShiftByteCount == 0 || binaryShiftByteCount == 31) ? 18 : - (binaryShiftByteCount == 62) ? 9 : 8; - State result = new State(token, mode, binaryShiftByteCount + 1, bitCount + deltaBitCount); - if (result.binaryShiftByteCount == 2047 + 31) { - // The string is as long as it's allowed to be. We should end it. - result = result.endBinaryShift(index + 1); - } - return result; - } - - // Create the state identical to this one, but we are no longer in - // Binary Shift mode. - State endBinaryShift(int index) { - if (binaryShiftByteCount == 0) { - return this; - } - Token token = this.token; - token = token.addBinaryShift(index - binaryShiftByteCount, binaryShiftByteCount); - return new State(token, mode, 0, this.bitCount); - } - - // Returns true if "this" state is better (or equal) to be in than "that" - // state under all possible circumstances. - boolean isBetterThanOrEqualTo(State other) { - int newModeBitCount = this.bitCount + (HighLevelEncoder.LATCH_TABLE[this.mode][other.mode] >> 16); - if (this.binaryShiftByteCount < other.binaryShiftByteCount) { - // add additional B/S encoding cost of other, if any - newModeBitCount += other.binaryShiftCost - this.binaryShiftCost; - } else if (this.binaryShiftByteCount > other.binaryShiftByteCount && other.binaryShiftByteCount > 0) { - // maximum possible additional cost (we end up exceeding the 31 byte boundary and other state can stay beneath it) - newModeBitCount += 10; - } - return newModeBitCount <= other.bitCount; - } - - BitArray toBitArray(byte[] text) { - List symbols = new ArrayList<>(); - for (Token token = endBinaryShift(text.length).token; token != null; token = token.getPrevious()) { - symbols.add(token); - } - BitArray bitArray = new BitArray(); - // Add each token to the result in forward order - for (int i = symbols.size() - 1; i >= 0; i--) { - symbols.get(i).appendTo(bitArray, text); - } - return bitArray; - } - - @Override - public String toString() { - return String.format("%s bits=%d bytes=%d", HighLevelEncoder.MODE_NAMES[mode], bitCount, binaryShiftByteCount); - } - - private static int calculateBinaryShiftCost(int binaryShiftByteCount) { - if (binaryShiftByteCount > 62) { - return 21; // B/S with extended length - } - if (binaryShiftByteCount > 31) { - return 20; // two B/S - } - if (binaryShiftByteCount > 0) { - return 10; // one B/S - } - return 0; - } - -} diff --git a/port_src/core/DONE/aztec/encoder/Token.java b/port_src/core/DONE/aztec/encoder/Token.java deleted file mode 100644 index 8178f38..0000000 --- a/port_src/core/DONE/aztec/encoder/Token.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec.encoder; - -import com.google.zxing.common.BitArray; - -abstract class Token { - - static final Token EMPTY = new SimpleToken(null, 0, 0); - - private final Token previous; - - Token(Token previous) { - this.previous = previous; - } - - final Token getPrevious() { - return previous; - } - - final Token add(int value, int bitCount) { - return new SimpleToken(this, value, bitCount); - } - - final Token addBinaryShift(int start, int byteCount) { - //int bitCount = (byteCount * 8) + (byteCount <= 31 ? 10 : byteCount <= 62 ? 20 : 21); - return new BinaryShiftToken(this, start, byteCount); - } - - abstract void appendTo(BitArray bitArray, byte[] text); - -} diff --git a/port_src/core/DONE/client/result/AbstractDoCoMoResultParser.java b/port_src/core/DONE/client/result/AbstractDoCoMoResultParser.java deleted file mode 100644 index bf5c190..0000000 --- a/port_src/core/DONE/client/result/AbstractDoCoMoResultParser.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - *

See - * - * DoCoMo's documentation about the result types represented by subclasses of this class.

- * - *

Thanks to Jeff Griffin for proposing rewrite of these classes that relies less - * on exception-based mechanisms during parsing.

- * - * @author Sean Owen - */ -abstract class AbstractDoCoMoResultParser extends ResultParser { - - static String[] matchDoCoMoPrefixedField(String prefix, String rawText) { - return matchPrefixedField(prefix, rawText, ';', true); - } - - static String matchSingleDoCoMoPrefixedField(String prefix, String rawText, boolean trim) { - return matchSinglePrefixedField(prefix, rawText, ';', trim); - } - -} diff --git a/port_src/core/DONE/client/result/AddressBookAUResultParser.java b/port_src/core/DONE/client/result/AddressBookAUResultParser.java deleted file mode 100644 index b601955..0000000 --- a/port_src/core/DONE/client/result/AddressBookAUResultParser.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -import java.util.ArrayList; -import java.util.List; - -/** - * Implements KDDI AU's address book format. See - * - * http://www.au.kddi.com/ezfactory/tec/two_dimensions/index.html. - * (Thanks to Yuzo for translating!) - * - * @author Sean Owen - */ -public final class AddressBookAUResultParser extends ResultParser { - - @Override - public AddressBookParsedResult parse(Result result) { - String rawText = getMassagedText(result); - // MEMORY is mandatory; seems like a decent indicator, as does end-of-record separator CR/LF - if (!rawText.contains("MEMORY") || !rawText.contains("\r\n")) { - return null; - } - - // NAME1 and NAME2 have specific uses, namely written name and pronunciation, respectively. - // Therefore we treat them specially instead of as an array of names. - String name = matchSinglePrefixedField("NAME1:", rawText, '\r', true); - String pronunciation = matchSinglePrefixedField("NAME2:", rawText, '\r', true); - - String[] phoneNumbers = matchMultipleValuePrefix("TEL", rawText); - String[] emails = matchMultipleValuePrefix("MAIL", rawText); - String note = matchSinglePrefixedField("MEMORY:", rawText, '\r', false); - String address = matchSinglePrefixedField("ADD:", rawText, '\r', true); - String[] addresses = address == null ? null : new String[] {address}; - return new AddressBookParsedResult(maybeWrap(name), - null, - pronunciation, - phoneNumbers, - null, - emails, - null, - null, - note, - addresses, - null, - null, - null, - null, - null, - null); - } - - private static String[] matchMultipleValuePrefix(String prefix, String rawText) { - List values = null; - // For now, always 3, and always trim - for (int i = 1; i <= 3; i++) { - String value = matchSinglePrefixedField(prefix + i + ':', rawText, '\r', true); - if (value == null) { - break; - } - if (values == null) { - values = new ArrayList<>(3); // lazy init - } - values.add(value); - } - if (values == null) { - return null; - } - return values.toArray(EMPTY_STR_ARRAY); - } - -} diff --git a/port_src/core/DONE/client/result/AddressBookDoCoMoResultParser.java b/port_src/core/DONE/client/result/AddressBookDoCoMoResultParser.java deleted file mode 100644 index 4e6e11f..0000000 --- a/port_src/core/DONE/client/result/AddressBookDoCoMoResultParser.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -/** - * Implements the "MECARD" address book entry format. - * - * Supported keys: N, SOUND, TEL, EMAIL, NOTE, ADR, BDAY, URL, plus ORG - * Unsupported keys: TEL-AV, NICKNAME - * - * Except for TEL, multiple values for keys are also not supported; - * the first one found takes precedence. - * - * Our understanding of the MECARD format is based on this document: - * - * http://www.mobicode.org.tw/files/OMIA%20Mobile%20Bar%20Code%20Standard%20v3.2.1.doc - * - * @author Sean Owen - */ -public final class AddressBookDoCoMoResultParser extends AbstractDoCoMoResultParser { - - @Override - public AddressBookParsedResult parse(Result result) { - String rawText = getMassagedText(result); - if (!rawText.startsWith("MECARD:")) { - return null; - } - String[] rawName = matchDoCoMoPrefixedField("N:", rawText); - if (rawName == null) { - return null; - } - String name = parseName(rawName[0]); - String pronunciation = matchSingleDoCoMoPrefixedField("SOUND:", rawText, true); - String[] phoneNumbers = matchDoCoMoPrefixedField("TEL:", rawText); - String[] emails = matchDoCoMoPrefixedField("EMAIL:", rawText); - String note = matchSingleDoCoMoPrefixedField("NOTE:", rawText, false); - String[] addresses = matchDoCoMoPrefixedField("ADR:", rawText); - String birthday = matchSingleDoCoMoPrefixedField("BDAY:", rawText, true); - if (!isStringOfDigits(birthday, 8)) { - // No reason to throw out the whole card because the birthday is formatted wrong. - birthday = null; - } - String[] urls = matchDoCoMoPrefixedField("URL:", rawText); - - // Although ORG may not be strictly legal in MECARD, it does exist in VCARD and we might as well - // honor it when found in the wild. - String org = matchSingleDoCoMoPrefixedField("ORG:", rawText, true); - - return new AddressBookParsedResult(maybeWrap(name), - null, - pronunciation, - phoneNumbers, - null, - emails, - null, - null, - note, - addresses, - null, - org, - birthday, - null, - urls, - null); - } - - private static String parseName(String name) { - int comma = name.indexOf(','); - if (comma >= 0) { - // Format may be last,first; switch it around - return name.substring(comma + 1) + ' ' + name.substring(0, comma); - } - return name; - } - -} diff --git a/port_src/core/DONE/client/result/AddressBookParsedResult.java b/port_src/core/DONE/client/result/AddressBookParsedResult.java deleted file mode 100644 index 0738339..0000000 --- a/port_src/core/DONE/client/result/AddressBookParsedResult.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - * Represents a parsed result that encodes contact information, like that in an address book - * entry. - * - * @author Sean Owen - */ -public final class AddressBookParsedResult extends ParsedResult { - - private final String[] names; - private final String[] nicknames; - private final String pronunciation; - private final String[] phoneNumbers; - private final String[] phoneTypes; - private final String[] emails; - private final String[] emailTypes; - private final String instantMessenger; - private final String note; - private final String[] addresses; - private final String[] addressTypes; - private final String org; - private final String birthday; - private final String title; - private final String[] urls; - private final String[] geo; - - public AddressBookParsedResult(String[] names, - String[] phoneNumbers, - String[] phoneTypes, - String[] emails, - String[] emailTypes, - String[] addresses, - String[] addressTypes) { - this(names, - null, - null, - phoneNumbers, - phoneTypes, - emails, - emailTypes, - null, - null, - addresses, - addressTypes, - null, - null, - null, - null, - null); - } - - public AddressBookParsedResult(String[] names, - String[] nicknames, - String pronunciation, - String[] phoneNumbers, - String[] phoneTypes, - String[] emails, - String[] emailTypes, - String instantMessenger, - String note, - String[] addresses, - String[] addressTypes, - String org, - String birthday, - String title, - String[] urls, - String[] geo) { - super(ParsedResultType.ADDRESSBOOK); - if (phoneNumbers != null && phoneTypes != null && phoneNumbers.length != phoneTypes.length) { - throw new IllegalArgumentException("Phone numbers and types lengths differ"); - } - if (emails != null && emailTypes != null && emails.length != emailTypes.length) { - throw new IllegalArgumentException("Emails and types lengths differ"); - } - if (addresses != null && addressTypes != null && addresses.length != addressTypes.length) { - throw new IllegalArgumentException("Addresses and types lengths differ"); - } - this.names = names; - this.nicknames = nicknames; - this.pronunciation = pronunciation; - this.phoneNumbers = phoneNumbers; - this.phoneTypes = phoneTypes; - this.emails = emails; - this.emailTypes = emailTypes; - this.instantMessenger = instantMessenger; - this.note = note; - this.addresses = addresses; - this.addressTypes = addressTypes; - this.org = org; - this.birthday = birthday; - this.title = title; - this.urls = urls; - this.geo = geo; - } - - public String[] getNames() { - return names; - } - - public String[] getNicknames() { - return nicknames; - } - - /** - * In Japanese, the name is written in kanji, which can have multiple readings. Therefore a hint - * is often provided, called furigana, which spells the name phonetically. - * - * @return The pronunciation of the getNames() field, often in hiragana or katakana. - */ - public String getPronunciation() { - return pronunciation; - } - - public String[] getPhoneNumbers() { - return phoneNumbers; - } - - /** - * @return optional descriptions of the type of each phone number. It could be like "HOME", but, - * there is no guaranteed or standard format. - */ - public String[] getPhoneTypes() { - return phoneTypes; - } - - public String[] getEmails() { - return emails; - } - - /** - * @return optional descriptions of the type of each e-mail. It could be like "WORK", but, - * there is no guaranteed or standard format. - */ - public String[] getEmailTypes() { - return emailTypes; - } - - public String getInstantMessenger() { - return instantMessenger; - } - - public String getNote() { - return note; - } - - public String[] getAddresses() { - return addresses; - } - - /** - * @return optional descriptions of the type of each e-mail. It could be like "WORK", but, - * there is no guaranteed or standard format. - */ - public String[] getAddressTypes() { - return addressTypes; - } - - public String getTitle() { - return title; - } - - public String getOrg() { - return org; - } - - public String[] getURLs() { - return urls; - } - - /** - * @return birthday formatted as yyyyMMdd (e.g. 19780917) - */ - public String getBirthday() { - return birthday; - } - - /** - * @return a location as a latitude/longitude pair - */ - public String[] getGeo() { - return geo; - } - - @Override - public String getDisplayResult() { - StringBuilder result = new StringBuilder(100); - maybeAppend(names, result); - maybeAppend(nicknames, result); - maybeAppend(pronunciation, result); - maybeAppend(title, result); - maybeAppend(org, result); - maybeAppend(addresses, result); - maybeAppend(phoneNumbers, result); - maybeAppend(emails, result); - maybeAppend(instantMessenger, result); - maybeAppend(urls, result); - maybeAppend(birthday, result); - maybeAppend(geo, result); - maybeAppend(note, result); - return result.toString(); - } - -} diff --git a/port_src/core/DONE/client/result/BizcardResultParser.java b/port_src/core/DONE/client/result/BizcardResultParser.java deleted file mode 100644 index f12e80b..0000000 --- a/port_src/core/DONE/client/result/BizcardResultParser.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -import java.util.ArrayList; -import java.util.List; - -/** - * Implements the "BIZCARD" address book entry format, though this has been - * largely reverse-engineered from examples observed in the wild -- still - * looking for a definitive reference. - * - * @author Sean Owen - */ -public final class BizcardResultParser extends AbstractDoCoMoResultParser { - - // Yes, we extend AbstractDoCoMoResultParser since the format is very much - // like the DoCoMo MECARD format, but this is not technically one of - // DoCoMo's proposed formats - - @Override - public AddressBookParsedResult parse(Result result) { - String rawText = getMassagedText(result); - if (!rawText.startsWith("BIZCARD:")) { - return null; - } - String firstName = matchSingleDoCoMoPrefixedField("N:", rawText, true); - String lastName = matchSingleDoCoMoPrefixedField("X:", rawText, true); - String fullName = buildName(firstName, lastName); - String title = matchSingleDoCoMoPrefixedField("T:", rawText, true); - String org = matchSingleDoCoMoPrefixedField("C:", rawText, true); - String[] addresses = matchDoCoMoPrefixedField("A:", rawText); - String phoneNumber1 = matchSingleDoCoMoPrefixedField("B:", rawText, true); - String phoneNumber2 = matchSingleDoCoMoPrefixedField("M:", rawText, true); - String phoneNumber3 = matchSingleDoCoMoPrefixedField("F:", rawText, true); - String email = matchSingleDoCoMoPrefixedField("E:", rawText, true); - - return new AddressBookParsedResult(maybeWrap(fullName), - null, - null, - buildPhoneNumbers(phoneNumber1, phoneNumber2, phoneNumber3), - null, - maybeWrap(email), - null, - null, - null, - addresses, - null, - org, - null, - title, - null, - null); - } - - private static String[] buildPhoneNumbers(String number1, - String number2, - String number3) { - List numbers = new ArrayList<>(3); - if (number1 != null) { - numbers.add(number1); - } - if (number2 != null) { - numbers.add(number2); - } - if (number3 != null) { - numbers.add(number3); - } - int size = numbers.size(); - if (size == 0) { - return null; - } - return numbers.toArray(new String[size]); - } - - private static String buildName(String firstName, String lastName) { - if (firstName == null) { - return lastName; - } else { - return lastName == null ? firstName : firstName + ' ' + lastName; - } - } - -} diff --git a/port_src/core/DONE/client/result/BookmarkDoCoMoResultParser.java b/port_src/core/DONE/client/result/BookmarkDoCoMoResultParser.java deleted file mode 100644 index 1f1f485..0000000 --- a/port_src/core/DONE/client/result/BookmarkDoCoMoResultParser.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -/** - * @author Sean Owen - */ -public final class BookmarkDoCoMoResultParser extends AbstractDoCoMoResultParser { - - @Override - public URIParsedResult parse(Result result) { - String rawText = result.getText(); - if (!rawText.startsWith("MEBKM:")) { - return null; - } - String title = matchSingleDoCoMoPrefixedField("TITLE:", rawText, true); - String[] rawUri = matchDoCoMoPrefixedField("URL:", rawText); - if (rawUri == null) { - return null; - } - String uri = rawUri[0]; - return URIResultParser.isBasicallyValidURI(uri) ? new URIParsedResult(uri, title) : null; - } - -} diff --git a/port_src/core/DONE/client/result/CalendarParsedResult.java b/port_src/core/DONE/client/result/CalendarParsedResult.java deleted file mode 100644 index 7b478a3..0000000 --- a/port_src/core/DONE/client/result/CalendarParsedResult.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Locale; -import java.util.TimeZone; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Represents a parsed result that encodes a calendar event at a certain time, optionally - * with attendees and a location. - * - * @author Sean Owen - */ -public final class CalendarParsedResult extends ParsedResult { - - private static final Pattern RFC2445_DURATION = - Pattern.compile("P(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?"); - private static final long[] RFC2445_DURATION_FIELD_UNITS = { - 7 * 24 * 60 * 60 * 1000L, // 1 week - 24 * 60 * 60 * 1000L, // 1 day - 60 * 60 * 1000L, // 1 hour - 60 * 1000L, // 1 minute - 1000L, // 1 second - }; - - private static final Pattern DATE_TIME = Pattern.compile("[0-9]{8}(T[0-9]{6}Z?)?"); - - private final String summary; - private final long start; - private final boolean startAllDay; - private final long end; - private final boolean endAllDay; - private final String location; - private final String organizer; - private final String[] attendees; - private final String description; - private final double latitude; - private final double longitude; - - public CalendarParsedResult(String summary, - String startString, - String endString, - String durationString, - String location, - String organizer, - String[] attendees, - String description, - double latitude, - double longitude) { - super(ParsedResultType.CALENDAR); - this.summary = summary; - - try { - this.start = parseDate(startString); - } catch (ParseException pe) { - throw new IllegalArgumentException(pe.toString()); - } - - if (endString == null) { - long durationMS = parseDurationMS(durationString); - end = durationMS < 0L ? -1L : start + durationMS; - } else { - try { - this.end = parseDate(endString); - } catch (ParseException pe) { - throw new IllegalArgumentException(pe.toString()); - } - } - - this.startAllDay = startString.length() == 8; - this.endAllDay = endString != null && endString.length() == 8; - - this.location = location; - this.organizer = organizer; - this.attendees = attendees; - this.description = description; - this.latitude = latitude; - this.longitude = longitude; - } - - public String getSummary() { - return summary; - } - - /** - * @return start time - * @deprecated use {@link #getStartTimestamp()} - */ - @Deprecated - public Date getStart() { - return new Date(start); - } - - /** - * @return start time - * @see #getEndTimestamp() - */ - public long getStartTimestamp() { - return start; - } - - /** - * @return true if start time was specified as a whole day - */ - public boolean isStartAllDay() { - return startAllDay; - } - - /** - * @return event end {@link Date}, or {@code null} if event has no duration - * @deprecated use {@link #getEndTimestamp()} - */ - @Deprecated - public Date getEnd() { - return end < 0L ? null : new Date(end); - } - - /** - * @return event end {@link Date}, or -1 if event has no duration - * @see #getStartTimestamp() - */ - public long getEndTimestamp() { - return end; - } - - /** - * @return true if end time was specified as a whole day - */ - public boolean isEndAllDay() { - return endAllDay; - } - - public String getLocation() { - return location; - } - - public String getOrganizer() { - return organizer; - } - - public String[] getAttendees() { - return attendees; - } - - public String getDescription() { - return description; - } - - public double getLatitude() { - return latitude; - } - - public double getLongitude() { - return longitude; - } - - @Override - public String getDisplayResult() { - StringBuilder result = new StringBuilder(100); - maybeAppend(summary, result); - maybeAppend(format(startAllDay, start), result); - maybeAppend(format(endAllDay, end), result); - maybeAppend(location, result); - maybeAppend(organizer, result); - maybeAppend(attendees, result); - maybeAppend(description, result); - return result.toString(); - } - - /** - * Parses a string as a date. RFC 2445 allows the start and end fields to be of type DATE (e.g. 20081021) - * or DATE-TIME (e.g. 20081021T123000 for local time, or 20081021T123000Z for UTC). - * - * @param when The string to parse - * @throws ParseException if not able to parse as a date - */ - private static long parseDate(String when) throws ParseException { - if (!DATE_TIME.matcher(when).matches()) { - throw new ParseException(when, 0); - } - if (when.length() == 8) { - // Show only year/month/day - DateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.ENGLISH); - // For dates without a time, for purposes of interacting with Android, the resulting timestamp - // needs to be midnight of that day in GMT. See: - // http://code.google.com/p/android/issues/detail?id=8330 - format.setTimeZone(TimeZone.getTimeZone("GMT")); - return format.parse(when).getTime(); - } - // The when string can be local time, or UTC if it ends with a Z - if (when.length() == 16 && when.charAt(15) == 'Z') { - long milliseconds = parseDateTimeString(when.substring(0, 15)); - Calendar calendar = new GregorianCalendar(); - // Account for time zone difference - milliseconds += calendar.get(Calendar.ZONE_OFFSET); - // Might need to correct for daylight savings time, but use target time since - // now might be in DST but not then, or vice versa - calendar.setTime(new Date(milliseconds)); - return milliseconds + calendar.get(Calendar.DST_OFFSET); - } - return parseDateTimeString(when); - } - - private static String format(boolean allDay, long date) { - if (date < 0L) { - return null; - } - DateFormat format = allDay - ? DateFormat.getDateInstance(DateFormat.MEDIUM) - : DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); - return format.format(date); - } - - private static long parseDurationMS(CharSequence durationString) { - if (durationString == null) { - return -1L; - } - Matcher m = RFC2445_DURATION.matcher(durationString); - if (!m.matches()) { - return -1L; - } - long durationMS = 0L; - for (int i = 0; i < RFC2445_DURATION_FIELD_UNITS.length; i++) { - String fieldValue = m.group(i + 1); - if (fieldValue != null) { - durationMS += RFC2445_DURATION_FIELD_UNITS[i] * Integer.parseInt(fieldValue); - } - } - return durationMS; - } - - private static long parseDateTimeString(String dateTimeString) throws ParseException { - DateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.ENGLISH); - return format.parse(dateTimeString).getTime(); - } - -} diff --git a/port_src/core/DONE/client/result/EmailAddressParsedResult.java b/port_src/core/DONE/client/result/EmailAddressParsedResult.java deleted file mode 100644 index a5bcd44..0000000 --- a/port_src/core/DONE/client/result/EmailAddressParsedResult.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - * Represents a parsed result that encodes an email message including recipients, subject - * and body text. - * - * @author Sean Owen - */ -public final class EmailAddressParsedResult extends ParsedResult { - - private final String[] tos; - private final String[] ccs; - private final String[] bccs; - private final String subject; - private final String body; - - EmailAddressParsedResult(String to) { - this(new String[] {to}, null, null, null, null); - } - - EmailAddressParsedResult(String[] tos, - String[] ccs, - String[] bccs, - String subject, - String body) { - super(ParsedResultType.EMAIL_ADDRESS); - this.tos = tos; - this.ccs = ccs; - this.bccs = bccs; - this.subject = subject; - this.body = body; - } - - /** - * @return first elements of {@link #getTos()} or {@code null} if none - * @deprecated use {@link #getTos()} - */ - @Deprecated - public String getEmailAddress() { - return tos == null || tos.length == 0 ? null : tos[0]; - } - - public String[] getTos() { - return tos; - } - - public String[] getCCs() { - return ccs; - } - - public String[] getBCCs() { - return bccs; - } - - public String getSubject() { - return subject; - } - - public String getBody() { - return body; - } - - /** - * @return "mailto:" - * @deprecated without replacement - */ - @Deprecated - public String getMailtoURI() { - return "mailto:"; - } - - @Override - public String getDisplayResult() { - StringBuilder result = new StringBuilder(30); - maybeAppend(tos, result); - maybeAppend(ccs, result); - maybeAppend(bccs, result); - maybeAppend(subject, result); - maybeAppend(body, result); - return result.toString(); - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/client/result/EmailAddressResultParser.java b/port_src/core/DONE/client/result/EmailAddressResultParser.java deleted file mode 100644 index 18c4f7a..0000000 --- a/port_src/core/DONE/client/result/EmailAddressResultParser.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -import java.util.Map; -import java.util.regex.Pattern; - -/** - * Represents a result that encodes an e-mail address, either as a plain address - * like "joe@example.org" or a mailto: URL like "mailto:joe@example.org". - * - * @author Sean Owen - */ -public final class EmailAddressResultParser extends ResultParser { - - private static final Pattern COMMA = Pattern.compile(","); - - @Override - public EmailAddressParsedResult parse(Result result) { - String rawText = getMassagedText(result); - if (rawText.startsWith("mailto:") || rawText.startsWith("MAILTO:")) { - // If it starts with mailto:, assume it is definitely trying to be an email address - String hostEmail = rawText.substring(7); - int queryStart = hostEmail.indexOf('?'); - if (queryStart >= 0) { - hostEmail = hostEmail.substring(0, queryStart); - } - try { - hostEmail = urlDecode(hostEmail); - } catch (IllegalArgumentException iae) { - return null; - } - String[] tos = null; - if (!hostEmail.isEmpty()) { - tos = COMMA.split(hostEmail); - } - Map nameValues = parseNameValuePairs(rawText); - String[] ccs = null; - String[] bccs = null; - String subject = null; - String body = null; - if (nameValues != null) { - if (tos == null) { - String tosString = nameValues.get("to"); - if (tosString != null) { - tos = COMMA.split(tosString); - } - } - String ccString = nameValues.get("cc"); - if (ccString != null) { - ccs = COMMA.split(ccString); - } - String bccString = nameValues.get("bcc"); - if (bccString != null) { - bccs = COMMA.split(bccString); - } - subject = nameValues.get("subject"); - body = nameValues.get("body"); - } - return new EmailAddressParsedResult(tos, ccs, bccs, subject, body); - } else { - if (!EmailDoCoMoResultParser.isBasicallyValidEmailAddress(rawText)) { - return null; - } - return new EmailAddressParsedResult(rawText); - } - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/client/result/EmailDoCoMoResultParser.java b/port_src/core/DONE/client/result/EmailDoCoMoResultParser.java deleted file mode 100644 index ab301f4..0000000 --- a/port_src/core/DONE/client/result/EmailDoCoMoResultParser.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -import java.util.regex.Pattern; - -/** - * Implements the "MATMSG" email message entry format. - * - * Supported keys: TO, SUB, BODY - * - * @author Sean Owen - */ -public final class EmailDoCoMoResultParser extends AbstractDoCoMoResultParser { - - private static final Pattern ATEXT_ALPHANUMERIC = Pattern.compile("[a-zA-Z0-9@.!#$%&'*+\\-/=?^_`{|}~]+"); - - @Override - public EmailAddressParsedResult parse(Result result) { - String rawText = getMassagedText(result); - if (!rawText.startsWith("MATMSG:")) { - return null; - } - String[] tos = matchDoCoMoPrefixedField("TO:", rawText); - if (tos == null) { - return null; - } - for (String to : tos) { - if (!isBasicallyValidEmailAddress(to)) { - return null; - } - } - String subject = matchSingleDoCoMoPrefixedField("SUB:", rawText, false); - String body = matchSingleDoCoMoPrefixedField("BODY:", rawText, false); - return new EmailAddressParsedResult(tos, null, null, subject, body); - } - - /** - * This implements only the most basic checking for an email address's validity -- that it contains - * an '@' and contains no characters disallowed by RFC 2822. This is an overly lenient definition of - * validity. We want to generally be lenient here since this class is only intended to encapsulate what's - * in a barcode, not "judge" it. - */ - static boolean isBasicallyValidEmailAddress(String email) { - return email != null && ATEXT_ALPHANUMERIC.matcher(email).matches() && email.indexOf('@') >= 0; - } - -} diff --git a/port_src/core/DONE/client/result/ExpandedProductParsedResult.java b/port_src/core/DONE/client/result/ExpandedProductParsedResult.java deleted file mode 100644 index 13b93f8..0000000 --- a/port_src/core/DONE/client/result/ExpandedProductParsedResult.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.client.result; - -import java.util.Map; -import java.util.Objects; - -/** - * Represents a parsed result that encodes extended product information as encoded - * by the RSS format, like weight, price, dates, etc. - * - * @author Antonio Manuel Benjumea Conde, Servinform, S.A. - * @author Agustín Delgado, Servinform, S.A. - */ -public final class ExpandedProductParsedResult extends ParsedResult { - - public static final String KILOGRAM = "KG"; - public static final String POUND = "LB"; - - private final String rawText; - private final String productID; - private final String sscc; - private final String lotNumber; - private final String productionDate; - private final String packagingDate; - private final String bestBeforeDate; - private final String expirationDate; - private final String weight; - private final String weightType; - private final String weightIncrement; - private final String price; - private final String priceIncrement; - private final String priceCurrency; - // For AIS that not exist in this object - private final Map uncommonAIs; - - public ExpandedProductParsedResult(String rawText, - String productID, - String sscc, - String lotNumber, - String productionDate, - String packagingDate, - String bestBeforeDate, - String expirationDate, - String weight, - String weightType, - String weightIncrement, - String price, - String priceIncrement, - String priceCurrency, - Map uncommonAIs) { - super(ParsedResultType.PRODUCT); - this.rawText = rawText; - this.productID = productID; - this.sscc = sscc; - this.lotNumber = lotNumber; - this.productionDate = productionDate; - this.packagingDate = packagingDate; - this.bestBeforeDate = bestBeforeDate; - this.expirationDate = expirationDate; - this.weight = weight; - this.weightType = weightType; - this.weightIncrement = weightIncrement; - this.price = price; - this.priceIncrement = priceIncrement; - this.priceCurrency = priceCurrency; - this.uncommonAIs = uncommonAIs; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof ExpandedProductParsedResult)) { - return false; - } - - ExpandedProductParsedResult other = (ExpandedProductParsedResult) o; - - return Objects.equals(productID, other.productID) - && Objects.equals(sscc, other.sscc) - && Objects.equals(lotNumber, other.lotNumber) - && Objects.equals(productionDate, other.productionDate) - && Objects.equals(bestBeforeDate, other.bestBeforeDate) - && Objects.equals(expirationDate, other.expirationDate) - && Objects.equals(weight, other.weight) - && Objects.equals(weightType, other.weightType) - && Objects.equals(weightIncrement, other.weightIncrement) - && Objects.equals(price, other.price) - && Objects.equals(priceIncrement, other.priceIncrement) - && Objects.equals(priceCurrency, other.priceCurrency) - && Objects.equals(uncommonAIs, other.uncommonAIs); - } - - @Override - public int hashCode() { - int hash = Objects.hashCode(productID); - hash ^= Objects.hashCode(sscc); - hash ^= Objects.hashCode(lotNumber); - hash ^= Objects.hashCode(productionDate); - hash ^= Objects.hashCode(bestBeforeDate); - hash ^= Objects.hashCode(expirationDate); - hash ^= Objects.hashCode(weight); - hash ^= Objects.hashCode(weightType); - hash ^= Objects.hashCode(weightIncrement); - hash ^= Objects.hashCode(price); - hash ^= Objects.hashCode(priceIncrement); - hash ^= Objects.hashCode(priceCurrency); - hash ^= Objects.hashCode(uncommonAIs); - return hash; - } - - public String getRawText() { - return rawText; - } - - public String getProductID() { - return productID; - } - - public String getSscc() { - return sscc; - } - - public String getLotNumber() { - return lotNumber; - } - - public String getProductionDate() { - return productionDate; - } - - public String getPackagingDate() { - return packagingDate; - } - - public String getBestBeforeDate() { - return bestBeforeDate; - } - - public String getExpirationDate() { - return expirationDate; - } - - public String getWeight() { - return weight; - } - - public String getWeightType() { - return weightType; - } - - public String getWeightIncrement() { - return weightIncrement; - } - - public String getPrice() { - return price; - } - - public String getPriceIncrement() { - return priceIncrement; - } - - public String getPriceCurrency() { - return priceCurrency; - } - - public Map getUncommonAIs() { - return uncommonAIs; - } - - @Override - public String getDisplayResult() { - return String.valueOf(rawText); - } -} diff --git a/port_src/core/DONE/client/result/ExpandedProductResultParser.java b/port_src/core/DONE/client/result/ExpandedProductResultParser.java deleted file mode 100644 index c021587..0000000 --- a/port_src/core/DONE/client/result/ExpandedProductResultParser.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.client.result; - -import java.util.HashMap; -import java.util.Map; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; - -/** - * Parses strings of digits that represent a RSS Extended code. - * - * @author Antonio Manuel Benjumea Conde, Servinform, S.A. - * @author Agustín Delgado, Servinform, S.A. - */ -public final class ExpandedProductResultParser extends ResultParser { - - @Override - public ExpandedProductParsedResult parse(Result result) { - BarcodeFormat format = result.getBarcodeFormat(); - if (format != BarcodeFormat.RSS_EXPANDED) { - // ExtendedProductParsedResult NOT created. Not a RSS Expanded barcode - return null; - } - String rawText = getMassagedText(result); - - String productID = null; - String sscc = null; - String lotNumber = null; - String productionDate = null; - String packagingDate = null; - String bestBeforeDate = null; - String expirationDate = null; - String weight = null; - String weightType = null; - String weightIncrement = null; - String price = null; - String priceIncrement = null; - String priceCurrency = null; - Map uncommonAIs = new HashMap<>(); - - int i = 0; - - while (i < rawText.length()) { - String ai = findAIvalue(i, rawText); - if (ai == null) { - // Error. Code doesn't match with RSS expanded pattern - // ExtendedProductParsedResult NOT created. Not match with RSS Expanded pattern - return null; - } - i += ai.length() + 2; - String value = findValue(i, rawText); - i += value.length(); - - switch (ai) { - case "00": - sscc = value; - break; - case "01": - productID = value; - break; - case "10": - lotNumber = value; - break; - case "11": - productionDate = value; - break; - case "13": - packagingDate = value; - break; - case "15": - bestBeforeDate = value; - break; - case "17": - expirationDate = value; - break; - case "3100": - case "3101": - case "3102": - case "3103": - case "3104": - case "3105": - case "3106": - case "3107": - case "3108": - case "3109": - weight = value; - weightType = ExpandedProductParsedResult.KILOGRAM; - weightIncrement = ai.substring(3); - break; - case "3200": - case "3201": - case "3202": - case "3203": - case "3204": - case "3205": - case "3206": - case "3207": - case "3208": - case "3209": - weight = value; - weightType = ExpandedProductParsedResult.POUND; - weightIncrement = ai.substring(3); - break; - case "3920": - case "3921": - case "3922": - case "3923": - price = value; - priceIncrement = ai.substring(3); - break; - case "3930": - case "3931": - case "3932": - case "3933": - if (value.length() < 4) { - // The value must have more of 3 symbols (3 for currency and - // 1 at least for the price) - // ExtendedProductParsedResult NOT created. Not match with RSS Expanded pattern - return null; - } - price = value.substring(3); - priceCurrency = value.substring(0, 3); - priceIncrement = ai.substring(3); - break; - default: - // No match with common AIs - uncommonAIs.put(ai, value); - break; - } - } - - return new ExpandedProductParsedResult(rawText, - productID, - sscc, - lotNumber, - productionDate, - packagingDate, - bestBeforeDate, - expirationDate, - weight, - weightType, - weightIncrement, - price, - priceIncrement, - priceCurrency, - uncommonAIs); - } - - private static String findAIvalue(int i, String rawText) { - char c = rawText.charAt(i); - // First character must be a open parenthesis.If not, ERROR - if (c != '(') { - return null; - } - - CharSequence rawTextAux = rawText.substring(i + 1); - - StringBuilder buf = new StringBuilder(); - for (int index = 0; index < rawTextAux.length(); index++) { - char currentChar = rawTextAux.charAt(index); - if (currentChar == ')') { - return buf.toString(); - } - if (currentChar < '0' || currentChar > '9') { - return null; - } - buf.append(currentChar); - } - return buf.toString(); - } - - private static String findValue(int i, String rawText) { - StringBuilder buf = new StringBuilder(); - String rawTextAux = rawText.substring(i); - - for (int index = 0; index < rawTextAux.length(); index++) { - char c = rawTextAux.charAt(index); - if (c == '(') { - // We look for a new AI. If it doesn't exist (ERROR), we continue - // with the iteration - if (findAIvalue(index, rawTextAux) != null) { - break; - } - buf.append('('); - } else { - buf.append(c); - } - } - return buf.toString(); - } -} diff --git a/port_src/core/DONE/client/result/GeoParsedResult.java b/port_src/core/DONE/client/result/GeoParsedResult.java deleted file mode 100644 index 3a2cae6..0000000 --- a/port_src/core/DONE/client/result/GeoParsedResult.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - * Represents a parsed result that encodes a geographic coordinate, with latitude, - * longitude and altitude. - * - * @author Sean Owen - */ -public final class GeoParsedResult extends ParsedResult { - - private final double latitude; - private final double longitude; - private final double altitude; - private final String query; - - GeoParsedResult(double latitude, double longitude, double altitude, String query) { - super(ParsedResultType.GEO); - this.latitude = latitude; - this.longitude = longitude; - this.altitude = altitude; - this.query = query; - } - - public String getGeoURI() { - StringBuilder result = new StringBuilder(); - result.append("geo:"); - result.append(latitude); - result.append(','); - result.append(longitude); - if (altitude > 0) { - result.append(','); - result.append(altitude); - } - if (query != null) { - result.append('?'); - result.append(query); - } - return result.toString(); - } - - /** - * @return latitude in degrees - */ - public double getLatitude() { - return latitude; - } - - /** - * @return longitude in degrees - */ - public double getLongitude() { - return longitude; - } - - /** - * @return altitude in meters. If not specified, in the geo URI, returns 0.0 - */ - public double getAltitude() { - return altitude; - } - - /** - * @return query string associated with geo URI or null if none exists - */ - public String getQuery() { - return query; - } - - @Override - public String getDisplayResult() { - StringBuilder result = new StringBuilder(20); - result.append(latitude); - result.append(", "); - result.append(longitude); - if (altitude > 0.0) { - result.append(", "); - result.append(altitude); - result.append('m'); - } - if (query != null) { - result.append(" ("); - result.append(query); - result.append(')'); - } - return result.toString(); - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/client/result/GeoResultParser.java b/port_src/core/DONE/client/result/GeoResultParser.java deleted file mode 100644 index fb9cb07..0000000 --- a/port_src/core/DONE/client/result/GeoResultParser.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Parses a "geo:" URI result, which specifies a location on the surface of - * the Earth as well as an optional altitude above the surface. See - * - * http://tools.ietf.org/html/draft-mayrhofer-geo-uri-00. - * - * @author Sean Owen - */ -public final class GeoResultParser extends ResultParser { - - private static final Pattern GEO_URL_PATTERN = - Pattern.compile("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?", Pattern.CASE_INSENSITIVE); - - @Override - public GeoParsedResult parse(Result result) { - CharSequence rawText = getMassagedText(result); - Matcher matcher = GEO_URL_PATTERN.matcher(rawText); - if (!matcher.matches()) { - return null; - } - - String query = matcher.group(4); - - double latitude; - double longitude; - double altitude; - try { - latitude = Double.parseDouble(matcher.group(1)); - if (latitude > 90.0 || latitude < -90.0) { - return null; - } - longitude = Double.parseDouble(matcher.group(2)); - if (longitude > 180.0 || longitude < -180.0) { - return null; - } - if (matcher.group(3) == null) { - altitude = 0.0; - } else { - altitude = Double.parseDouble(matcher.group(3)); - if (altitude < 0.0) { - return null; - } - } - } catch (NumberFormatException ignored) { - return null; - } - return new GeoParsedResult(latitude, longitude, altitude, query); - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/client/result/ISBNParsedResult.java b/port_src/core/DONE/client/result/ISBNParsedResult.java deleted file mode 100644 index ebf11c5..0000000 --- a/port_src/core/DONE/client/result/ISBNParsedResult.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - * Represents a parsed result that encodes a product ISBN number. - * - * @author jbreiden@google.com (Jeff Breidenbach) - */ -public final class ISBNParsedResult extends ParsedResult { - - private final String isbn; - - ISBNParsedResult(String isbn) { - super(ParsedResultType.ISBN); - this.isbn = isbn; - } - - public String getISBN() { - return isbn; - } - - @Override - public String getDisplayResult() { - return isbn; - } - -} diff --git a/port_src/core/DONE/client/result/ISBNResultParser.java b/port_src/core/DONE/client/result/ISBNResultParser.java deleted file mode 100644 index e957dd0..0000000 --- a/port_src/core/DONE/client/result/ISBNResultParser.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; - -/** - * Parses strings of digits that represent a ISBN. - * - * @author jbreiden@google.com (Jeff Breidenbach) - */ -public final class ISBNResultParser extends ResultParser { - - /** - * See ISBN-13 For Dummies - */ - @Override - public ISBNParsedResult parse(Result result) { - BarcodeFormat format = result.getBarcodeFormat(); - if (format != BarcodeFormat.EAN_13) { - return null; - } - String rawText = getMassagedText(result); - int length = rawText.length(); - if (length != 13) { - return null; - } - if (!rawText.startsWith("978") && !rawText.startsWith("979")) { - return null; - } - - return new ISBNParsedResult(rawText); - } - -} diff --git a/port_src/core/DONE/client/result/ParsedResult.java b/port_src/core/DONE/client/result/ParsedResult.java deleted file mode 100644 index 17660e2..0000000 --- a/port_src/core/DONE/client/result/ParsedResult.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - *

Abstract class representing the result of decoding a barcode, as more than - * a String -- as some type of structured data. This might be a subclass which represents - * a URL, or an e-mail address. {@link ResultParser#parseResult(com.google.zxing.Result)} will turn a raw - * decoded string into the most appropriate type of structured representation.

- * - *

Thanks to Jeff Griffin for proposing rewrite of these classes that relies less - * on exception-based mechanisms during parsing.

- * - * @author Sean Owen - */ -public abstract class ParsedResult { - - private final ParsedResultType type; - - protected ParsedResult(ParsedResultType type) { - this.type = type; - } - - public final ParsedResultType getType() { - return type; - } - - public abstract String getDisplayResult(); - - @Override - public final String toString() { - return getDisplayResult(); - } - - public static void maybeAppend(String value, StringBuilder result) { - if (value != null && !value.isEmpty()) { - // Don't add a newline before the first value - if (result.length() > 0) { - result.append('\n'); - } - result.append(value); - } - } - - public static void maybeAppend(String[] values, StringBuilder result) { - if (values != null) { - for (String value : values) { - maybeAppend(value, result); - } - } - } - -} diff --git a/port_src/core/DONE/client/result/ParsedResultType.java b/port_src/core/DONE/client/result/ParsedResultType.java deleted file mode 100644 index c74d545..0000000 --- a/port_src/core/DONE/client/result/ParsedResultType.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - * Represents the type of data encoded by a barcode -- from plain text, to a - * URI, to an e-mail address, etc. - * - * @author Sean Owen - */ -public enum ParsedResultType { - - ADDRESSBOOK, - EMAIL_ADDRESS, - PRODUCT, - URI, - TEXT, - GEO, - TEL, - SMS, - CALENDAR, - WIFI, - ISBN, - VIN, - -} diff --git a/port_src/core/DONE/client/result/ProductParsedResult.java b/port_src/core/DONE/client/result/ProductParsedResult.java deleted file mode 100644 index 66a5c9b..0000000 --- a/port_src/core/DONE/client/result/ProductParsedResult.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - * Represents a parsed result that encodes a product by an identifier of some kind. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class ProductParsedResult extends ParsedResult { - - private final String productID; - private final String normalizedProductID; - - ProductParsedResult(String productID) { - this(productID, productID); - } - - ProductParsedResult(String productID, String normalizedProductID) { - super(ParsedResultType.PRODUCT); - this.productID = productID; - this.normalizedProductID = normalizedProductID; - } - - public String getProductID() { - return productID; - } - - public String getNormalizedProductID() { - return normalizedProductID; - } - - @Override - public String getDisplayResult() { - return productID; - } - -} diff --git a/port_src/core/DONE/client/result/ProductResultParser.java b/port_src/core/DONE/client/result/ProductResultParser.java deleted file mode 100644 index bed1a7d..0000000 --- a/port_src/core/DONE/client/result/ProductResultParser.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import com.google.zxing.oned.UPCEReader; - -/** - * Parses strings of digits that represent a UPC code. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class ProductResultParser extends ResultParser { - - // Treat all UPC and EAN variants as UPCs, in the sense that they are all product barcodes. - @Override - public ProductParsedResult parse(Result result) { - BarcodeFormat format = result.getBarcodeFormat(); - if (!(format == BarcodeFormat.UPC_A || format == BarcodeFormat.UPC_E || - format == BarcodeFormat.EAN_8 || format == BarcodeFormat.EAN_13)) { - return null; - } - String rawText = getMassagedText(result); - if (!isStringOfDigits(rawText, rawText.length())) { - return null; - } - // Not actually checking the checksum again here - - String normalizedProductID; - // Expand UPC-E for purposes of searching - if (format == BarcodeFormat.UPC_E && rawText.length() == 8) { - normalizedProductID = UPCEReader.convertUPCEtoUPCA(rawText); - } else { - normalizedProductID = rawText; - } - - return new ProductParsedResult(rawText, normalizedProductID); - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/client/result/ResultParser.java b/port_src/core/DONE/client/result/ResultParser.java deleted file mode 100644 index ecf3c20..0000000 --- a/port_src/core/DONE/client/result/ResultParser.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; - -/** - *

Abstract class representing the result of decoding a barcode, as more than - * a String -- as some type of structured data. This might be a subclass which represents - * a URL, or an e-mail address. {@link #parseResult(Result)} will turn a raw - * decoded string into the most appropriate type of structured representation.

- * - *

Thanks to Jeff Griffin for proposing rewrite of these classes that relies less - * on exception-based mechanisms during parsing.

- * - * @author Sean Owen - */ -public abstract class ResultParser { - - private static final ResultParser[] PARSERS = { - new BookmarkDoCoMoResultParser(), - new AddressBookDoCoMoResultParser(), - new EmailDoCoMoResultParser(), - new AddressBookAUResultParser(), - new VCardResultParser(), - new BizcardResultParser(), - new VEventResultParser(), - new EmailAddressResultParser(), - new SMTPResultParser(), - new TelResultParser(), - new SMSMMSResultParser(), - new SMSTOMMSTOResultParser(), - new GeoResultParser(), - new WifiResultParser(), - new URLTOResultParser(), - new URIResultParser(), - new ISBNResultParser(), - new ProductResultParser(), - new ExpandedProductResultParser(), - new VINResultParser(), - }; - - private static final Pattern DIGITS = Pattern.compile("\\d+"); - private static final Pattern AMPERSAND = Pattern.compile("&"); - private static final Pattern EQUALS = Pattern.compile("="); - private static final String BYTE_ORDER_MARK = "\ufeff"; - - static final String[] EMPTY_STR_ARRAY = new String[0]; - - /** - * Attempts to parse the raw {@link Result}'s contents as a particular type - * of information (email, URL, etc.) and return a {@link ParsedResult} encapsulating - * the result of parsing. - * - * @param theResult the raw {@link Result} to parse - * @return {@link ParsedResult} encapsulating the parsing result - */ - public abstract ParsedResult parse(Result theResult); - - protected static String getMassagedText(Result result) { - String text = result.getText(); - if (text.startsWith(BYTE_ORDER_MARK)) { - text = text.substring(1); - } - return text; - } - - public static ParsedResult parseResult(Result theResult) { - for (ResultParser parser : PARSERS) { - ParsedResult result = parser.parse(theResult); - if (result != null) { - return result; - } - } - return new TextParsedResult(theResult.getText(), null); - } - - protected static void maybeAppend(String value, StringBuilder result) { - if (value != null) { - result.append('\n'); - result.append(value); - } - } - - protected static void maybeAppend(String[] value, StringBuilder result) { - if (value != null) { - for (String s : value) { - result.append('\n'); - result.append(s); - } - } - } - - protected static String[] maybeWrap(String value) { - return value == null ? null : new String[] { value }; - } - - protected static String unescapeBackslash(String escaped) { - int backslash = escaped.indexOf('\\'); - if (backslash < 0) { - return escaped; - } - int max = escaped.length(); - StringBuilder unescaped = new StringBuilder(max - 1); - unescaped.append(escaped.toCharArray(), 0, backslash); - boolean nextIsEscaped = false; - for (int i = backslash; i < max; i++) { - char c = escaped.charAt(i); - if (nextIsEscaped || c != '\\') { - unescaped.append(c); - nextIsEscaped = false; - } else { - nextIsEscaped = true; - } - } - return unescaped.toString(); - } - - protected static int parseHexDigit(char c) { - if (c >= '0' && c <= '9') { - return c - '0'; - } - if (c >= 'a' && c <= 'f') { - return 10 + (c - 'a'); - } - if (c >= 'A' && c <= 'F') { - return 10 + (c - 'A'); - } - return -1; - } - - protected static boolean isStringOfDigits(CharSequence value, int length) { - return value != null && length > 0 && length == value.length() && DIGITS.matcher(value).matches(); - } - - protected static boolean isSubstringOfDigits(CharSequence value, int offset, int length) { - if (value == null || length <= 0) { - return false; - } - int max = offset + length; - return value.length() >= max && DIGITS.matcher(value.subSequence(offset, max)).matches(); - } - - static Map parseNameValuePairs(String uri) { - int paramStart = uri.indexOf('?'); - if (paramStart < 0) { - return null; - } - Map result = new HashMap<>(3); - for (String keyValue : AMPERSAND.split(uri.substring(paramStart + 1))) { - appendKeyValue(keyValue, result); - } - return result; - } - - private static void appendKeyValue(CharSequence keyValue, Map result) { - String[] keyValueTokens = EQUALS.split(keyValue, 2); - if (keyValueTokens.length == 2) { - String key = keyValueTokens[0]; - String value = keyValueTokens[1]; - try { - value = urlDecode(value); - result.put(key, value); - } catch (IllegalArgumentException iae) { - // continue; invalid data such as an escape like %0t - } - } - } - - static String urlDecode(String encoded) { - try { - return URLDecoder.decode(encoded, "UTF-8"); - } catch (UnsupportedEncodingException uee) { - throw new IllegalStateException(uee); // can't happen - } - } - - static String[] matchPrefixedField(String prefix, String rawText, char endChar, boolean trim) { - List matches = null; - int i = 0; - int max = rawText.length(); - while (i < max) { - i = rawText.indexOf(prefix, i); - if (i < 0) { - break; - } - i += prefix.length(); // Skip past this prefix we found to start - int start = i; // Found the start of a match here - boolean more = true; - while (more) { - i = rawText.indexOf(endChar, i); - if (i < 0) { - // No terminating end character? uh, done. Set i such that loop terminates and break - i = rawText.length(); - more = false; - } else if (countPrecedingBackslashes(rawText, i) % 2 != 0) { - // semicolon was escaped (odd count of preceding backslashes) so continue - i++; - } else { - // found a match - if (matches == null) { - matches = new ArrayList<>(3); // lazy init - } - String element = unescapeBackslash(rawText.substring(start, i)); - if (trim) { - element = element.trim(); - } - if (!element.isEmpty()) { - matches.add(element); - } - i++; - more = false; - } - } - } - if (matches == null || matches.isEmpty()) { - return null; - } - return matches.toArray(EMPTY_STR_ARRAY); - } - - private static int countPrecedingBackslashes(CharSequence s, int pos) { - int count = 0; - for (int i = pos - 1; i >= 0; i--) { - if (s.charAt(i) == '\\') { - count++; - } else { - break; - } - } - return count; - } - - static String matchSinglePrefixedField(String prefix, String rawText, char endChar, boolean trim) { - String[] matches = matchPrefixedField(prefix, rawText, endChar, trim); - return matches == null ? null : matches[0]; - } - -} diff --git a/port_src/core/DONE/client/result/SMSMMSResultParser.java b/port_src/core/DONE/client/result/SMSMMSResultParser.java deleted file mode 100644 index 2d0840b..0000000 --- a/port_src/core/DONE/client/result/SMSMMSResultParser.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - *

Parses an "sms:" URI result, which specifies a number to SMS. - * See RFC 5724 on this.

- * - *

This class supports "via" syntax for numbers, which is not part of the spec. - * For example "+12125551212;via=+12124440101" may appear as a number. - * It also supports a "subject" query parameter, which is not mentioned in the spec. - * These are included since they were mentioned in earlier IETF drafts and might be - * used.

- * - *

This actually also parses URIs starting with "mms:" and treats them all the same way, - * and effectively converts them to an "sms:" URI for purposes of forwarding to the platform.

- * - * @author Sean Owen - */ -public final class SMSMMSResultParser extends ResultParser { - - @Override - public SMSParsedResult parse(Result result) { - String rawText = getMassagedText(result); - if (!(rawText.startsWith("sms:") || rawText.startsWith("SMS:") || - rawText.startsWith("mms:") || rawText.startsWith("MMS:"))) { - return null; - } - - // Check up front if this is a URI syntax string with query arguments - Map nameValuePairs = parseNameValuePairs(rawText); - String subject = null; - String body = null; - boolean querySyntax = false; - if (nameValuePairs != null && !nameValuePairs.isEmpty()) { - subject = nameValuePairs.get("subject"); - body = nameValuePairs.get("body"); - querySyntax = true; - } - - // Drop sms, query portion - int queryStart = rawText.indexOf('?', 4); - String smsURIWithoutQuery; - // If it's not query syntax, the question mark is part of the subject or message - if (queryStart < 0 || !querySyntax) { - smsURIWithoutQuery = rawText.substring(4); - } else { - smsURIWithoutQuery = rawText.substring(4, queryStart); - } - - int lastComma = -1; - int comma; - List numbers = new ArrayList<>(1); - List vias = new ArrayList<>(1); - while ((comma = smsURIWithoutQuery.indexOf(',', lastComma + 1)) > lastComma) { - String numberPart = smsURIWithoutQuery.substring(lastComma + 1, comma); - addNumberVia(numbers, vias, numberPart); - lastComma = comma; - } - addNumberVia(numbers, vias, smsURIWithoutQuery.substring(lastComma + 1)); - - return new SMSParsedResult(numbers.toArray(EMPTY_STR_ARRAY), - vias.toArray(EMPTY_STR_ARRAY), - subject, - body); - } - - private static void addNumberVia(Collection numbers, - Collection vias, - String numberPart) { - int numberEnd = numberPart.indexOf(';'); - if (numberEnd < 0) { - numbers.add(numberPart); - vias.add(null); - } else { - numbers.add(numberPart.substring(0, numberEnd)); - String maybeVia = numberPart.substring(numberEnd + 1); - String via; - if (maybeVia.startsWith("via=")) { - via = maybeVia.substring(4); - } else { - via = null; - } - vias.add(via); - } - } - -} diff --git a/port_src/core/DONE/client/result/SMSParsedResult.java b/port_src/core/DONE/client/result/SMSParsedResult.java deleted file mode 100644 index 176078e..0000000 --- a/port_src/core/DONE/client/result/SMSParsedResult.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - * Represents a parsed result that encodes an SMS message, including recipients, subject - * and body text. - * - * @author Sean Owen - */ -public final class SMSParsedResult extends ParsedResult { - - private final String[] numbers; - private final String[] vias; - private final String subject; - private final String body; - - public SMSParsedResult(String number, - String via, - String subject, - String body) { - super(ParsedResultType.SMS); - this.numbers = new String[] {number}; - this.vias = new String[] {via}; - this.subject = subject; - this.body = body; - } - - public SMSParsedResult(String[] numbers, - String[] vias, - String subject, - String body) { - super(ParsedResultType.SMS); - this.numbers = numbers; - this.vias = vias; - this.subject = subject; - this.body = body; - } - - public String getSMSURI() { - StringBuilder result = new StringBuilder(); - result.append("sms:"); - boolean first = true; - for (int i = 0; i < numbers.length; i++) { - if (first) { - first = false; - } else { - result.append(','); - } - result.append(numbers[i]); - if (vias != null && vias[i] != null) { - result.append(";via="); - result.append(vias[i]); - } - } - boolean hasBody = body != null; - boolean hasSubject = subject != null; - if (hasBody || hasSubject) { - result.append('?'); - if (hasBody) { - result.append("body="); - result.append(body); - } - if (hasSubject) { - if (hasBody) { - result.append('&'); - } - result.append("subject="); - result.append(subject); - } - } - return result.toString(); - } - - public String[] getNumbers() { - return numbers; - } - - public String[] getVias() { - return vias; - } - - public String getSubject() { - return subject; - } - - public String getBody() { - return body; - } - - @Override - public String getDisplayResult() { - StringBuilder result = new StringBuilder(100); - maybeAppend(numbers, result); - maybeAppend(subject, result); - maybeAppend(body, result); - return result.toString(); - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/client/result/SMSTOMMSTOResultParser.java b/port_src/core/DONE/client/result/SMSTOMMSTOResultParser.java deleted file mode 100644 index 0760565..0000000 --- a/port_src/core/DONE/client/result/SMSTOMMSTOResultParser.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -/** - *

Parses an "smsto:" URI result, whose format is not standardized but appears to be like: - * {@code smsto:number(:body)}.

- * - *

This actually also parses URIs starting with "smsto:", "mmsto:", "SMSTO:", and - * "MMSTO:", and treats them all the same way, and effectively converts them to an "sms:" URI - * for purposes of forwarding to the platform.

- * - * @author Sean Owen - */ -public final class SMSTOMMSTOResultParser extends ResultParser { - - @Override - public SMSParsedResult parse(Result result) { - String rawText = getMassagedText(result); - if (!(rawText.startsWith("smsto:") || rawText.startsWith("SMSTO:") || - rawText.startsWith("mmsto:") || rawText.startsWith("MMSTO:"))) { - return null; - } - // Thanks to dominik.wild for suggesting this enhancement to support - // smsto:number:body URIs - String number = rawText.substring(6); - String body = null; - int bodyStart = number.indexOf(':'); - if (bodyStart >= 0) { - body = number.substring(bodyStart + 1); - number = number.substring(0, bodyStart); - } - return new SMSParsedResult(number, null, null, body); - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/client/result/SMTPResultParser.java b/port_src/core/DONE/client/result/SMTPResultParser.java deleted file mode 100644 index 3279ceb..0000000 --- a/port_src/core/DONE/client/result/SMTPResultParser.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -/** - *

Parses an "smtp:" URI result, whose format is not standardized but appears to be like: - * {@code smtp[:subject[:body]]}.

- * - * @author Sean Owen - */ -public final class SMTPResultParser extends ResultParser { - - @Override - public EmailAddressParsedResult parse(Result result) { - String rawText = getMassagedText(result); - if (!(rawText.startsWith("smtp:") || rawText.startsWith("SMTP:"))) { - return null; - } - String emailAddress = rawText.substring(5); - String subject = null; - String body = null; - int colon = emailAddress.indexOf(':'); - if (colon >= 0) { - subject = emailAddress.substring(colon + 1); - emailAddress = emailAddress.substring(0, colon); - colon = subject.indexOf(':'); - if (colon >= 0) { - body = subject.substring(colon + 1); - subject = subject.substring(0, colon); - } - } - return new EmailAddressParsedResult(new String[] {emailAddress}, - null, - null, - subject, - body); - } -} diff --git a/port_src/core/DONE/client/result/TelParsedResult.java b/port_src/core/DONE/client/result/TelParsedResult.java deleted file mode 100644 index fb606f2..0000000 --- a/port_src/core/DONE/client/result/TelParsedResult.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - * Represents a parsed result that encodes a telephone number. - * - * @author Sean Owen - */ -public final class TelParsedResult extends ParsedResult { - - private final String number; - private final String telURI; - private final String title; - - public TelParsedResult(String number, String telURI, String title) { - super(ParsedResultType.TEL); - this.number = number; - this.telURI = telURI; - this.title = title; - } - - public String getNumber() { - return number; - } - - public String getTelURI() { - return telURI; - } - - public String getTitle() { - return title; - } - - @Override - public String getDisplayResult() { - StringBuilder result = new StringBuilder(20); - maybeAppend(number, result); - maybeAppend(title, result); - return result.toString(); - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/client/result/TelResultParser.java b/port_src/core/DONE/client/result/TelResultParser.java deleted file mode 100644 index e4bca1f..0000000 --- a/port_src/core/DONE/client/result/TelResultParser.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -/** - * Parses a "tel:" URI result, which specifies a phone number. - * - * @author Sean Owen - */ -public final class TelResultParser extends ResultParser { - - @Override - public TelParsedResult parse(Result result) { - String rawText = getMassagedText(result); - if (!rawText.startsWith("tel:") && !rawText.startsWith("TEL:")) { - return null; - } - // Normalize "TEL:" to "tel:" - String telURI = rawText.startsWith("TEL:") ? "tel:" + rawText.substring(4) : rawText; - // Drop tel, query portion - int queryStart = rawText.indexOf('?', 4); - String number = queryStart < 0 ? rawText.substring(4) : rawText.substring(4, queryStart); - return new TelParsedResult(number, telURI, null); - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/client/result/TextParsedResult.java b/port_src/core/DONE/client/result/TextParsedResult.java deleted file mode 100644 index 9cc408e..0000000 --- a/port_src/core/DONE/client/result/TextParsedResult.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - * A simple result type encapsulating a string that has no further - * interpretation. - * - * @author Sean Owen - */ -public final class TextParsedResult extends ParsedResult { - - private final String text; - private final String language; - - public TextParsedResult(String text, String language) { - super(ParsedResultType.TEXT); - this.text = text; - this.language = language; - } - - public String getText() { - return text; - } - - public String getLanguage() { - return language; - } - - @Override - public String getDisplayResult() { - return text; - } - -} diff --git a/port_src/core/DONE/client/result/URIParsedResult.java b/port_src/core/DONE/client/result/URIParsedResult.java deleted file mode 100644 index 7601e79..0000000 --- a/port_src/core/DONE/client/result/URIParsedResult.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - * A simple result type encapsulating a URI that has no further interpretation. - * - * @author Sean Owen - */ -public final class URIParsedResult extends ParsedResult { - - private final String uri; - private final String title; - - public URIParsedResult(String uri, String title) { - super(ParsedResultType.URI); - this.uri = massageURI(uri); - this.title = title; - } - - public String getURI() { - return uri; - } - - public String getTitle() { - return title; - } - - /** - * @return true if the URI contains suspicious patterns that may suggest it intends to - * mislead the user about its true nature - * @deprecated see {@link URIResultParser#isPossiblyMaliciousURI(String)} - */ - @Deprecated - public boolean isPossiblyMaliciousURI() { - return URIResultParser.isPossiblyMaliciousURI(uri); - } - - @Override - public String getDisplayResult() { - StringBuilder result = new StringBuilder(30); - maybeAppend(title, result); - maybeAppend(uri, result); - return result.toString(); - } - - /** - * Transforms a string that represents a URI into something more proper, by adding or canonicalizing - * the protocol. - */ - private static String massageURI(String uri) { - uri = uri.trim(); - int protocolEnd = uri.indexOf(':'); - if (protocolEnd < 0 || isColonFollowedByPortNumber(uri, protocolEnd)) { - // No protocol, or found a colon, but it looks like it is after the host, so the protocol is still missing, - // so assume http - uri = "http://" + uri; - } - return uri; - } - - private static boolean isColonFollowedByPortNumber(String uri, int protocolEnd) { - int start = protocolEnd + 1; - int nextSlash = uri.indexOf('/', start); - if (nextSlash < 0) { - nextSlash = uri.length(); - } - return ResultParser.isSubstringOfDigits(uri, start, nextSlash - start); - } - - -} diff --git a/port_src/core/DONE/client/result/URIResultParser.java b/port_src/core/DONE/client/result/URIResultParser.java deleted file mode 100644 index 21adc34..0000000 --- a/port_src/core/DONE/client/result/URIResultParser.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Tries to parse results that are a URI of some kind. - * - * @author Sean Owen - */ -public final class URIResultParser extends ResultParser { - - private static final Pattern ALLOWED_URI_CHARS_PATTERN = - Pattern.compile("[-._~:/?#\\[\\]@!$&'()*+,;=%A-Za-z0-9]+"); - private static final Pattern USER_IN_HOST = Pattern.compile(":/*([^/@]+)@[^/]+"); - // See http://www.ietf.org/rfc/rfc2396.txt - private static final Pattern URL_WITH_PROTOCOL_PATTERN = Pattern.compile("[a-zA-Z][a-zA-Z0-9+-.]+:"); - private static final Pattern URL_WITHOUT_PROTOCOL_PATTERN = Pattern.compile( - "([a-zA-Z0-9\\-]+\\.){1,6}[a-zA-Z]{2,}" + // host name elements; allow up to say 6 domain elements - "(:\\d{1,5})?" + // maybe port - "(/|\\?|$)"); // query, path or nothing - - @Override - public URIParsedResult parse(Result result) { - String rawText = getMassagedText(result); - // We specifically handle the odd "URL" scheme here for simplicity and add "URI" for fun - // Assume anything starting this way really means to be a URI - if (rawText.startsWith("URL:") || rawText.startsWith("URI:")) { - return new URIParsedResult(rawText.substring(4).trim(), null); - } - rawText = rawText.trim(); - if (!isBasicallyValidURI(rawText) || isPossiblyMaliciousURI(rawText)) { - return null; - } - return new URIParsedResult(rawText, null); - } - - /** - * @return true if the URI contains suspicious patterns that may suggest it intends to - * mislead the user about its true nature. At the moment this looks for the presence - * of user/password syntax in the host/authority portion of a URI which may be used - * in attempts to make the URI's host appear to be other than it is. Example: - * http://yourbank.com@phisher.com This URI connects to phisher.com but may appear - * to connect to yourbank.com at first glance. - */ - static boolean isPossiblyMaliciousURI(String uri) { - return !ALLOWED_URI_CHARS_PATTERN.matcher(uri).matches() || USER_IN_HOST.matcher(uri).find(); - } - - static boolean isBasicallyValidURI(String uri) { - if (uri.contains(" ")) { - // Quick hack check for a common case - return false; - } - Matcher m = URL_WITH_PROTOCOL_PATTERN.matcher(uri); - if (m.find() && m.start() == 0) { // match at start only - return true; - } - m = URL_WITHOUT_PROTOCOL_PATTERN.matcher(uri); - return m.find() && m.start() == 0; - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/client/result/URLTOResultParser.java b/port_src/core/DONE/client/result/URLTOResultParser.java deleted file mode 100644 index fd25900..0000000 --- a/port_src/core/DONE/client/result/URLTOResultParser.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -/** - * Parses the "URLTO" result format, which is of the form "URLTO:[title]:[url]". - * This seems to be used sometimes, but I am not able to find documentation - * on its origin or official format? - * - * @author Sean Owen - */ -public final class URLTOResultParser extends ResultParser { - - @Override - public URIParsedResult parse(Result result) { - String rawText = getMassagedText(result); - if (!rawText.startsWith("urlto:") && !rawText.startsWith("URLTO:")) { - return null; - } - int titleEnd = rawText.indexOf(':', 6); - if (titleEnd < 0) { - return null; - } - String title = titleEnd <= 6 ? null : rawText.substring(6, titleEnd); - String uri = rawText.substring(titleEnd + 1); - return new URIParsedResult(uri, title); - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/client/result/VCardResultParser.java b/port_src/core/DONE/client/result/VCardResultParser.java deleted file mode 100644 index 5155c6f..0000000 --- a/port_src/core/DONE/client/result/VCardResultParser.java +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -import java.io.ByteArrayOutputStream; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Parses contact information formatted according to the VCard (2.1) format. This is not a complete - * implementation but should parse information as commonly encoded in 2D barcodes. - * - * @author Sean Owen - */ -public final class VCardResultParser extends ResultParser { - - private static final Pattern BEGIN_VCARD = Pattern.compile("BEGIN:VCARD", Pattern.CASE_INSENSITIVE); - private static final Pattern VCARD_LIKE_DATE = Pattern.compile("\\d{4}-?\\d{2}-?\\d{2}"); - private static final Pattern CR_LF_SPACE_TAB = Pattern.compile("\r\n[ \t]"); - private static final Pattern NEWLINE_ESCAPE = Pattern.compile("\\\\[nN]"); - private static final Pattern VCARD_ESCAPES = Pattern.compile("\\\\([,;\\\\])"); - private static final Pattern EQUALS = Pattern.compile("="); - private static final Pattern SEMICOLON = Pattern.compile(";"); - private static final Pattern UNESCAPED_SEMICOLONS = Pattern.compile("(?> names = matchVCardPrefixedField("FN", rawText, true, false); - if (names == null) { - // If no display names found, look for regular name fields and format them - names = matchVCardPrefixedField("N", rawText, true, false); - formatNames(names); - } - List nicknameString = matchSingleVCardPrefixedField("NICKNAME", rawText, true, false); - String[] nicknames = nicknameString == null ? null : COMMA.split(nicknameString.get(0)); - List> phoneNumbers = matchVCardPrefixedField("TEL", rawText, true, false); - List> emails = matchVCardPrefixedField("EMAIL", rawText, true, false); - List note = matchSingleVCardPrefixedField("NOTE", rawText, false, false); - List> addresses = matchVCardPrefixedField("ADR", rawText, true, true); - List org = matchSingleVCardPrefixedField("ORG", rawText, true, true); - List birthday = matchSingleVCardPrefixedField("BDAY", rawText, true, false); - if (birthday != null && !isLikeVCardDate(birthday.get(0))) { - birthday = null; - } - List title = matchSingleVCardPrefixedField("TITLE", rawText, true, false); - List> urls = matchVCardPrefixedField("URL", rawText, true, false); - List instantMessenger = matchSingleVCardPrefixedField("IMPP", rawText, true, false); - List geoString = matchSingleVCardPrefixedField("GEO", rawText, true, false); - String[] geo = geoString == null ? null : SEMICOLON_OR_COMMA.split(geoString.get(0)); - if (geo != null && geo.length != 2) { - geo = null; - } - return new AddressBookParsedResult(toPrimaryValues(names), - nicknames, - null, - toPrimaryValues(phoneNumbers), - toTypes(phoneNumbers), - toPrimaryValues(emails), - toTypes(emails), - toPrimaryValue(instantMessenger), - toPrimaryValue(note), - toPrimaryValues(addresses), - toTypes(addresses), - toPrimaryValue(org), - toPrimaryValue(birthday), - toPrimaryValue(title), - toPrimaryValues(urls), - geo); - } - - static List> matchVCardPrefixedField(CharSequence prefix, - String rawText, - boolean trim, - boolean parseFieldDivider) { - List> matches = null; - int i = 0; - int max = rawText.length(); - - while (i < max) { - - // At start or after newline, match prefix, followed by optional metadata - // (led by ;) ultimately ending in colon - Matcher matcher = Pattern.compile("(?:^|\n)" + prefix + "(?:;([^:]*))?:", - Pattern.CASE_INSENSITIVE).matcher(rawText); - if (i > 0) { - i--; // Find from i-1 not i since looking at the preceding character - } - if (!matcher.find(i)) { - break; - } - i = matcher.end(0); // group 0 = whole pattern; end(0) is past final colon - - String metadataString = matcher.group(1); // group 1 = metadata substring - List metadata = null; - boolean quotedPrintable = false; - String quotedPrintableCharset = null; - String valueType = null; - if (metadataString != null) { - for (String metadatum : SEMICOLON.split(metadataString)) { - if (metadata == null) { - metadata = new ArrayList<>(1); - } - metadata.add(metadatum); - String[] metadatumTokens = EQUALS.split(metadatum, 2); - if (metadatumTokens.length > 1) { - String key = metadatumTokens[0]; - String value = metadatumTokens[1]; - if ("ENCODING".equalsIgnoreCase(key) && "QUOTED-PRINTABLE".equalsIgnoreCase(value)) { - quotedPrintable = true; - } else if ("CHARSET".equalsIgnoreCase(key)) { - quotedPrintableCharset = value; - } else if ("VALUE".equalsIgnoreCase(key)) { - valueType = value; - } - } - } - } - - int matchStart = i; // Found the start of a match here - - while ((i = rawText.indexOf('\n', i)) >= 0) { // Really, end in \r\n - if (i < rawText.length() - 1 && // But if followed by tab or space, - (rawText.charAt(i + 1) == ' ' || // this is only a continuation - rawText.charAt(i + 1) == '\t')) { - i += 2; // Skip \n and continutation whitespace - } else if (quotedPrintable && // If preceded by = in quoted printable - ((i >= 1 && rawText.charAt(i - 1) == '=') || // this is a continuation - (i >= 2 && rawText.charAt(i - 2) == '='))) { - i++; // Skip \n - } else { - break; - } - } - - if (i < 0) { - // No terminating end character? uh, done. Set i such that loop terminates and break - i = max; - } else if (i > matchStart) { - // found a match - if (matches == null) { - matches = new ArrayList<>(1); // lazy init - } - if (i >= 1 && rawText.charAt(i - 1) == '\r') { - i--; // Back up over \r, which really should be there - } - String element = rawText.substring(matchStart, i); - if (trim) { - element = element.trim(); - } - if (quotedPrintable) { - element = decodeQuotedPrintable(element, quotedPrintableCharset); - if (parseFieldDivider) { - element = UNESCAPED_SEMICOLONS.matcher(element).replaceAll("\n").trim(); - } - } else { - if (parseFieldDivider) { - element = UNESCAPED_SEMICOLONS.matcher(element).replaceAll("\n").trim(); - } - element = CR_LF_SPACE_TAB.matcher(element).replaceAll(""); - element = NEWLINE_ESCAPE.matcher(element).replaceAll("\n"); - element = VCARD_ESCAPES.matcher(element).replaceAll("$1"); - } - // Only handle VALUE=uri specially - if ("uri".equals(valueType)) { - // Don't actually support dereferencing URIs, but use scheme-specific part not URI - // as value, to support tel: and mailto: - try { - element = URI.create(element).getSchemeSpecificPart(); - } catch (IllegalArgumentException iae) { - // ignore - } - } - if (metadata == null) { - List match = new ArrayList<>(1); - match.add(element); - matches.add(match); - } else { - metadata.add(0, element); - matches.add(metadata); - } - i++; - } else { - i++; - } - - } - - return matches; - } - - private static String decodeQuotedPrintable(CharSequence value, String charset) { - int length = value.length(); - StringBuilder result = new StringBuilder(length); - ByteArrayOutputStream fragmentBuffer = new ByteArrayOutputStream(); - for (int i = 0; i < length; i++) { - char c = value.charAt(i); - switch (c) { - case '\r': - case '\n': - break; - case '=': - if (i < length - 2) { - char nextChar = value.charAt(i + 1); - if (nextChar != '\r' && nextChar != '\n') { - char nextNextChar = value.charAt(i + 2); - int firstDigit = parseHexDigit(nextChar); - int secondDigit = parseHexDigit(nextNextChar); - if (firstDigit >= 0 && secondDigit >= 0) { - fragmentBuffer.write((firstDigit << 4) + secondDigit); - } // else ignore it, assume it was incorrectly encoded - i += 2; - } - } - break; - default: - maybeAppendFragment(fragmentBuffer, charset, result); - result.append(c); - } - } - maybeAppendFragment(fragmentBuffer, charset, result); - return result.toString(); - } - - private static void maybeAppendFragment(ByteArrayOutputStream fragmentBuffer, - String charset, - StringBuilder result) { - if (fragmentBuffer.size() > 0) { - byte[] fragmentBytes = fragmentBuffer.toByteArray(); - String fragment; - if (charset == null) { - fragment = new String(fragmentBytes, StandardCharsets.UTF_8); - } else { - try { - fragment = new String(fragmentBytes, charset); - } catch (UnsupportedEncodingException e) { - fragment = new String(fragmentBytes, StandardCharsets.UTF_8); - } - } - fragmentBuffer.reset(); - result.append(fragment); - } - } - - static List matchSingleVCardPrefixedField(CharSequence prefix, - String rawText, - boolean trim, - boolean parseFieldDivider) { - List> values = matchVCardPrefixedField(prefix, rawText, trim, parseFieldDivider); - return values == null || values.isEmpty() ? null : values.get(0); - } - - private static String toPrimaryValue(List list) { - return list == null || list.isEmpty() ? null : list.get(0); - } - - private static String[] toPrimaryValues(Collection> lists) { - if (lists == null || lists.isEmpty()) { - return null; - } - List result = new ArrayList<>(lists.size()); - for (List list : lists) { - String value = list.get(0); - if (value != null && !value.isEmpty()) { - result.add(value); - } - } - return result.toArray(EMPTY_STR_ARRAY); - } - - private static String[] toTypes(Collection> lists) { - if (lists == null || lists.isEmpty()) { - return null; - } - List result = new ArrayList<>(lists.size()); - for (List list : lists) { - String value = list.get(0); - if (value != null && !value.isEmpty()) { - String type = null; - for (int i = 1; i < list.size(); i++) { - String metadatum = list.get(i); - int equals = metadatum.indexOf('='); - if (equals < 0) { - // take the whole thing as a usable label - type = metadatum; - break; - } - if ("TYPE".equalsIgnoreCase(metadatum.substring(0, equals))) { - type = metadatum.substring(equals + 1); - break; - } - } - result.add(type); - } - } - return result.toArray(EMPTY_STR_ARRAY); - } - - private static boolean isLikeVCardDate(CharSequence value) { - return value == null || VCARD_LIKE_DATE.matcher(value).matches(); - } - - /** - * Formats name fields of the form "Public;John;Q.;Reverend;III" into a form like - * "Reverend John Q. Public III". - * - * @param names name values to format, in place - */ - private static void formatNames(Iterable> names) { - if (names != null) { - for (List list : names) { - String name = list.get(0); - String[] components = new String[5]; - int start = 0; - int end; - int componentIndex = 0; - while (componentIndex < components.length - 1 && (end = name.indexOf(';', start)) >= 0) { - components[componentIndex] = name.substring(start, end); - componentIndex++; - start = end + 1; - } - components[componentIndex] = name.substring(start); - StringBuilder newName = new StringBuilder(100); - maybeAppendComponent(components, 3, newName); - maybeAppendComponent(components, 1, newName); - maybeAppendComponent(components, 2, newName); - maybeAppendComponent(components, 0, newName); - maybeAppendComponent(components, 4, newName); - list.set(0, newName.toString().trim()); - } - } - } - - private static void maybeAppendComponent(String[] components, int i, StringBuilder newName) { - if (components[i] != null && !components[i].isEmpty()) { - if (newName.length() > 0) { - newName.append(' '); - } - newName.append(components[i]); - } - } - -} diff --git a/port_src/core/DONE/client/result/VEventResultParser.java b/port_src/core/DONE/client/result/VEventResultParser.java deleted file mode 100644 index 36ef588..0000000 --- a/port_src/core/DONE/client/result/VEventResultParser.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -import java.util.List; - -/** - * Partially implements the iCalendar format's "VEVENT" format for specifying a - * calendar event. See RFC 2445. This supports SUMMARY, LOCATION, GEO, DTSTART and DTEND fields. - * - * @author Sean Owen - */ -public final class VEventResultParser extends ResultParser { - - @Override - public CalendarParsedResult parse(Result result) { - String rawText = getMassagedText(result); - int vEventStart = rawText.indexOf("BEGIN:VEVENT"); - if (vEventStart < 0) { - return null; - } - - String summary = matchSingleVCardPrefixedField("SUMMARY", rawText); - String start = matchSingleVCardPrefixedField("DTSTART", rawText); - if (start == null) { - return null; - } - String end = matchSingleVCardPrefixedField("DTEND", rawText); - String duration = matchSingleVCardPrefixedField("DURATION", rawText); - String location = matchSingleVCardPrefixedField("LOCATION", rawText); - String organizer = stripMailto(matchSingleVCardPrefixedField("ORGANIZER", rawText)); - - String[] attendees = matchVCardPrefixedField("ATTENDEE", rawText); - if (attendees != null) { - for (int i = 0; i < attendees.length; i++) { - attendees[i] = stripMailto(attendees[i]); - } - } - String description = matchSingleVCardPrefixedField("DESCRIPTION", rawText); - - String geoString = matchSingleVCardPrefixedField("GEO", rawText); - double latitude; - double longitude; - if (geoString == null) { - latitude = Double.NaN; - longitude = Double.NaN; - } else { - int semicolon = geoString.indexOf(';'); - if (semicolon < 0) { - return null; - } - try { - latitude = Double.parseDouble(geoString.substring(0, semicolon)); - longitude = Double.parseDouble(geoString.substring(semicolon + 1)); - } catch (NumberFormatException ignored) { - return null; - } - } - - try { - return new CalendarParsedResult(summary, - start, - end, - duration, - location, - organizer, - attendees, - description, - latitude, - longitude); - } catch (IllegalArgumentException ignored) { - return null; - } - } - - private static String matchSingleVCardPrefixedField(CharSequence prefix, - String rawText) { - List values = VCardResultParser.matchSingleVCardPrefixedField(prefix, rawText, true, false); - return values == null || values.isEmpty() ? null : values.get(0); - } - - private static String[] matchVCardPrefixedField(CharSequence prefix, String rawText) { - List> values = VCardResultParser.matchVCardPrefixedField(prefix, rawText, true, false); - if (values == null || values.isEmpty()) { - return null; - } - int size = values.size(); - String[] result = new String[size]; - for (int i = 0; i < size; i++) { - result[i] = values.get(i).get(0); - } - return result; - } - - private static String stripMailto(String s) { - if (s != null && (s.startsWith("mailto:") || s.startsWith("MAILTO:"))) { - s = s.substring(7); - } - return s; - } - -} diff --git a/port_src/core/DONE/client/result/VINParsedResult.java b/port_src/core/DONE/client/result/VINParsedResult.java deleted file mode 100644 index 79f722d..0000000 --- a/port_src/core/DONE/client/result/VINParsedResult.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2014 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package com.google.zxing.client.result; - -/** - * Represents a parsed result that encodes a Vehicle Identification Number (VIN). - */ -public final class VINParsedResult extends ParsedResult { - - private final String vin; - private final String worldManufacturerID; - private final String vehicleDescriptorSection; - private final String vehicleIdentifierSection; - private final String countryCode; - private final String vehicleAttributes; - private final int modelYear; - private final char plantCode; - private final String sequentialNumber; - - public VINParsedResult(String vin, - String worldManufacturerID, - String vehicleDescriptorSection, - String vehicleIdentifierSection, - String countryCode, - String vehicleAttributes, - int modelYear, - char plantCode, - String sequentialNumber) { - super(ParsedResultType.VIN); - this.vin = vin; - this.worldManufacturerID = worldManufacturerID; - this.vehicleDescriptorSection = vehicleDescriptorSection; - this.vehicleIdentifierSection = vehicleIdentifierSection; - this.countryCode = countryCode; - this.vehicleAttributes = vehicleAttributes; - this.modelYear = modelYear; - this.plantCode = plantCode; - this.sequentialNumber = sequentialNumber; - } - - public String getVIN() { - return vin; - } - - public String getWorldManufacturerID() { - return worldManufacturerID; - } - - public String getVehicleDescriptorSection() { - return vehicleDescriptorSection; - } - - public String getVehicleIdentifierSection() { - return vehicleIdentifierSection; - } - - public String getCountryCode() { - return countryCode; - } - - public String getVehicleAttributes() { - return vehicleAttributes; - } - - public int getModelYear() { - return modelYear; - } - - public char getPlantCode() { - return plantCode; - } - - public String getSequentialNumber() { - return sequentialNumber; - } - - @Override - public String getDisplayResult() { - StringBuilder result = new StringBuilder(50); - result.append(worldManufacturerID).append(' '); - result.append(vehicleDescriptorSection).append(' '); - result.append(vehicleIdentifierSection).append('\n'); - if (countryCode != null) { - result.append(countryCode).append(' '); - } - result.append(modelYear).append(' '); - result.append(plantCode).append(' '); - result.append(sequentialNumber).append('\n'); - return result.toString(); - } -} diff --git a/port_src/core/DONE/client/result/VINResultParser.java b/port_src/core/DONE/client/result/VINResultParser.java deleted file mode 100644 index 0d1314c..0000000 --- a/port_src/core/DONE/client/result/VINResultParser.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright 2014 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; - -import java.util.regex.Pattern; - -/** - * Detects a result that is likely a vehicle identification number. - * - * @author Sean Owen - */ -public final class VINResultParser extends ResultParser { - - private static final Pattern IOQ = Pattern.compile("[IOQ]"); - private static final Pattern AZ09 = Pattern.compile("[A-Z0-9]{17}"); - - @Override - public VINParsedResult parse(Result result) { - if (result.getBarcodeFormat() != BarcodeFormat.CODE_39) { - return null; - } - String rawText = result.getText(); - rawText = IOQ.matcher(rawText).replaceAll("").trim(); - if (!AZ09.matcher(rawText).matches()) { - return null; - } - try { - if (!checkChecksum(rawText)) { - return null; - } - String wmi = rawText.substring(0, 3); - return new VINParsedResult(rawText, - wmi, - rawText.substring(3, 9), - rawText.substring(9, 17), - countryCode(wmi), - rawText.substring(3, 8), - modelYear(rawText.charAt(9)), - rawText.charAt(10), - rawText.substring(11)); - } catch (IllegalArgumentException iae) { - return null; - } - } - - private static boolean checkChecksum(CharSequence vin) { - int sum = 0; - for (int i = 0; i < vin.length(); i++) { - sum += vinPositionWeight(i + 1) * vinCharValue(vin.charAt(i)); - } - char checkChar = vin.charAt(8); - char expectedCheckChar = checkChar(sum % 11); - return checkChar == expectedCheckChar; - } - - private static int vinCharValue(char c) { - if (c >= 'A' && c <= 'I') { - return (c - 'A') + 1; - } - if (c >= 'J' && c <= 'R') { - return (c - 'J') + 1; - } - if (c >= 'S' && c <= 'Z') { - return (c - 'S') + 2; - } - if (c >= '0' && c <= '9') { - return c - '0'; - } - throw new IllegalArgumentException(); - } - - private static int vinPositionWeight(int position) { - if (position >= 1 && position <= 7) { - return 9 - position; - } - if (position == 8) { - return 10; - } - if (position == 9) { - return 0; - } - if (position >= 10 && position <= 17) { - return 19 - position; - } - throw new IllegalArgumentException(); - } - - private static char checkChar(int remainder) { - if (remainder < 10) { - return (char) ('0' + remainder); - } - if (remainder == 10) { - return 'X'; - } - throw new IllegalArgumentException(); - } - - private static int modelYear(char c) { - if (c >= 'E' && c <= 'H') { - return (c - 'E') + 1984; - } - if (c >= 'J' && c <= 'N') { - return (c - 'J') + 1988; - } - if (c == 'P') { - return 1993; - } - if (c >= 'R' && c <= 'T') { - return (c - 'R') + 1994; - } - if (c >= 'V' && c <= 'Y') { - return (c - 'V') + 1997; - } - if (c >= '1' && c <= '9') { - return (c - '1') + 2001; - } - if (c >= 'A' && c <= 'D') { - return (c - 'A') + 2010; - } - throw new IllegalArgumentException(); - } - - private static String countryCode(CharSequence wmi) { - char c1 = wmi.charAt(0); - char c2 = wmi.charAt(1); - switch (c1) { - case '1': - case '4': - case '5': - return "US"; - case '2': - return "CA"; - case '3': - if (c2 >= 'A' && c2 <= 'W') { - return "MX"; - } - break; - case '9': - if ((c2 >= 'A' && c2 <= 'E') || (c2 >= '3' && c2 <= '9')) { - return "BR"; - } - break; - case 'J': - if (c2 >= 'A' && c2 <= 'T') { - return "JP"; - } - break; - case 'K': - if (c2 >= 'L' && c2 <= 'R') { - return "KO"; - } - break; - case 'L': - return "CN"; - case 'M': - if (c2 >= 'A' && c2 <= 'E') { - return "IN"; - } - break; - case 'S': - if (c2 >= 'A' && c2 <= 'M') { - return "UK"; - } - if (c2 >= 'N' && c2 <= 'T') { - return "DE"; - } - break; - case 'V': - if (c2 >= 'F' && c2 <= 'R') { - return "FR"; - } - if (c2 >= 'S' && c2 <= 'W') { - return "ES"; - } - break; - case 'W': - return "DE"; - case 'X': - if (c2 == '0' || (c2 >= '3' && c2 <= '9')) { - return "RU"; - } - break; - case 'Z': - if (c2 >= 'A' && c2 <= 'R') { - return "IT"; - } - break; - } - return null; - } - -} diff --git a/port_src/core/DONE/client/result/WifiParsedResult.java b/port_src/core/DONE/client/result/WifiParsedResult.java deleted file mode 100644 index c88b6aa..0000000 --- a/port_src/core/DONE/client/result/WifiParsedResult.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -/** - * Represents a parsed result that encodes wifi network information, like SSID and password. - * - * @author Vikram Aggarwal - */ -public final class WifiParsedResult extends ParsedResult { - - private final String ssid; - private final String networkEncryption; - private final String password; - private final boolean hidden; - private final String identity; - private final String anonymousIdentity; - private final String eapMethod; - private final String phase2Method; - - public WifiParsedResult(String networkEncryption, String ssid, String password) { - this(networkEncryption, ssid, password, false); - } - - public WifiParsedResult(String networkEncryption, String ssid, String password, boolean hidden) { - this(networkEncryption, ssid, password, hidden, null, null, null, null); - } - - public WifiParsedResult(String networkEncryption, - String ssid, - String password, - boolean hidden, - String identity, - String anonymousIdentity, - String eapMethod, - String phase2Method) { - super(ParsedResultType.WIFI); - this.ssid = ssid; - this.networkEncryption = networkEncryption; - this.password = password; - this.hidden = hidden; - this.identity = identity; - this.anonymousIdentity = anonymousIdentity; - this.eapMethod = eapMethod; - this.phase2Method = phase2Method; - } - - public String getSsid() { - return ssid; - } - - public String getNetworkEncryption() { - return networkEncryption; - } - - public String getPassword() { - return password; - } - - public boolean isHidden() { - return hidden; - } - - public String getIdentity() { - return identity; - } - - public String getAnonymousIdentity() { - return anonymousIdentity; - } - - public String getEapMethod() { - return eapMethod; - } - - public String getPhase2Method() { - return phase2Method; - } - - @Override - public String getDisplayResult() { - StringBuilder result = new StringBuilder(80); - maybeAppend(ssid, result); - maybeAppend(networkEncryption, result); - maybeAppend(password, result); - maybeAppend(Boolean.toString(hidden), result); - return result.toString(); - } - -} diff --git a/port_src/core/DONE/client/result/WifiResultParser.java b/port_src/core/DONE/client/result/WifiResultParser.java deleted file mode 100644 index a35f28d..0000000 --- a/port_src/core/DONE/client/result/WifiResultParser.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.Result; - -@SuppressWarnings("checkstyle:lineLength") -/** - *

Parses a WIFI configuration string. Strings will be of the form:

- * - *

{@code WIFI:T:[network type];S:[network SSID];P:[network password];H:[hidden?];;}

- * - *

For WPA2 enterprise (EAP), strings will be of the form:

- * - *

{@code WIFI:T:WPA2-EAP;S:[network SSID];H:[hidden?];E:[EAP method];PH2:[Phase 2 method];A:[anonymous identity];I:[username];P:[password];;}

- * - *

"EAP method" can e.g. be "TTLS" or "PWD" or one of the other fields in WifiEnterpriseConfig.Eap and "Phase 2 method" can e.g. be "MSCHAPV2" or any of the other fields in WifiEnterpriseConfig.Phase2

- * - *

The fields can appear in any order. Only "S:" is required.

- * - * @author Vikram Aggarwal - * @author Sean Owen - * @author Steffen Kieß - */ -public final class WifiResultParser extends ResultParser { - - @Override - public WifiParsedResult parse(Result result) { - String rawText = getMassagedText(result); - if (!rawText.startsWith("WIFI:")) { - return null; - } - rawText = rawText.substring("WIFI:".length()); - String ssid = matchSinglePrefixedField("S:", rawText, ';', false); - if (ssid == null || ssid.isEmpty()) { - return null; - } - String pass = matchSinglePrefixedField("P:", rawText, ';', false); - String type = matchSinglePrefixedField("T:", rawText, ';', false); - if (type == null) { - type = "nopass"; - } - - // Unfortunately, in the past, H: was not just used for boolean 'hidden', but 'phase 2 method'. - // To try to retain backwards compatibility, we set one or the other based on whether the string - // is 'true' or 'false': - boolean hidden = false; - String phase2Method = matchSinglePrefixedField("PH2:", rawText, ';', false); - String hValue = matchSinglePrefixedField("H:", rawText, ';', false); - if (hValue != null) { - // If PH2 was specified separately, or if the value is clearly boolean, interpret it as 'hidden' - if (phase2Method != null || "true".equalsIgnoreCase(hValue) || "false".equalsIgnoreCase(hValue)) { - hidden = Boolean.parseBoolean(hValue); - } else { - phase2Method = hValue; - } - } - - String identity = matchSinglePrefixedField("I:", rawText, ';', false); - String anonymousIdentity = matchSinglePrefixedField("A:", rawText, ';', false); - String eapMethod = matchSinglePrefixedField("E:", rawText, ';', false); - - return new WifiParsedResult(type, ssid, pass, hidden, identity, anonymousIdentity, eapMethod, phase2Method); - } -} diff --git a/port_src/core/DONE/common/BitArray.java b/port_src/core/DONE/common/BitArray.java deleted file mode 100644 index b07785b..0000000 --- a/port_src/core/DONE/common/BitArray.java +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import java.util.Arrays; - -/** - *

A simple, fast array of bits, represented compactly by an array of ints internally.

- * - * @author Sean Owen - */ -public final class BitArray implements Cloneable { - - private static final int[] EMPTY_BITS = {}; - private static final float LOAD_FACTOR = 0.75f; - - private int[] bits; - private int size; - - public BitArray() { - this.size = 0; - this.bits = EMPTY_BITS; - } - - public BitArray(int size) { - this.size = size; - this.bits = makeArray(size); - } - - // For testing only - BitArray(int[] bits, int size) { - this.bits = bits; - this.size = size; - } - - public int getSize() { - return size; - } - - public int getSizeInBytes() { - return (size + 7) / 8; - } - - private void ensureCapacity(int newSize) { - if (newSize > bits.length * 32) { - int[] newBits = makeArray((int) Math.ceil(newSize / LOAD_FACTOR)); - System.arraycopy(bits, 0, newBits, 0, bits.length); - this.bits = newBits; - } - } - - /** - * @param i bit to get - * @return true iff bit i is set - */ - public boolean get(int i) { - return (bits[i / 32] & (1 << (i & 0x1F))) != 0; - } - - /** - * Sets bit i. - * - * @param i bit to set - */ - public void set(int i) { - bits[i / 32] |= 1 << (i & 0x1F); - } - - /** - * Flips bit i. - * - * @param i bit to set - */ - public void flip(int i) { - bits[i / 32] ^= 1 << (i & 0x1F); - } - - /** - * @param from first bit to check - * @return index of first bit that is set, starting from the given index, or size if none are set - * at or beyond this given index - * @see #getNextUnset(int) - */ - public int getNextSet(int from) { - if (from >= size) { - return size; - } - int bitsOffset = from / 32; - int currentBits = bits[bitsOffset]; - // mask off lesser bits first - currentBits &= -(1 << (from & 0x1F)); - while (currentBits == 0) { - if (++bitsOffset == bits.length) { - return size; - } - currentBits = bits[bitsOffset]; - } - int result = (bitsOffset * 32) + Integer.numberOfTrailingZeros(currentBits); - return Math.min(result, size); - } - - /** - * @param from index to start looking for unset bit - * @return index of next unset bit, or {@code size} if none are unset until the end - * @see #getNextSet(int) - */ - public int getNextUnset(int from) { - if (from >= size) { - return size; - } - int bitsOffset = from / 32; - int currentBits = ~bits[bitsOffset]; - // mask off lesser bits first - currentBits &= -(1 << (from & 0x1F)); - while (currentBits == 0) { - if (++bitsOffset == bits.length) { - return size; - } - currentBits = ~bits[bitsOffset]; - } - int result = (bitsOffset * 32) + Integer.numberOfTrailingZeros(currentBits); - return Math.min(result, size); - } - - /** - * Sets a block of 32 bits, starting at bit i. - * - * @param i first bit to set - * @param newBits the new value of the next 32 bits. Note again that the least-significant bit - * corresponds to bit i, the next-least-significant to i+1, and so on. - */ - public void setBulk(int i, int newBits) { - bits[i / 32] = newBits; - } - - /** - * Sets a range of bits. - * - * @param start start of range, inclusive. - * @param end end of range, exclusive - */ - public void setRange(int start, int end) { - if (end < start || start < 0 || end > size) { - throw new IllegalArgumentException(); - } - if (end == start) { - return; - } - end--; // will be easier to treat this as the last actually set bit -- inclusive - int firstInt = start / 32; - int lastInt = end / 32; - for (int i = firstInt; i <= lastInt; i++) { - int firstBit = i > firstInt ? 0 : start & 0x1F; - int lastBit = i < lastInt ? 31 : end & 0x1F; - // Ones from firstBit to lastBit, inclusive - int mask = (2 << lastBit) - (1 << firstBit); - bits[i] |= mask; - } - } - - /** - * Clears all bits (sets to false). - */ - public void clear() { - int max = bits.length; - for (int i = 0; i < max; i++) { - bits[i] = 0; - } - } - - /** - * Efficient method to check if a range of bits is set, or not set. - * - * @param start start of range, inclusive. - * @param end end of range, exclusive - * @param value if true, checks that bits in range are set, otherwise checks that they are not set - * @return true iff all bits are set or not set in range, according to value argument - * @throws IllegalArgumentException if end is less than start or the range is not contained in the array - */ - public boolean isRange(int start, int end, boolean value) { - if (end < start || start < 0 || end > size) { - throw new IllegalArgumentException(); - } - if (end == start) { - return true; // empty range matches - } - end--; // will be easier to treat this as the last actually set bit -- inclusive - int firstInt = start / 32; - int lastInt = end / 32; - for (int i = firstInt; i <= lastInt; i++) { - int firstBit = i > firstInt ? 0 : start & 0x1F; - int lastBit = i < lastInt ? 31 : end & 0x1F; - // Ones from firstBit to lastBit, inclusive - int mask = (2 << lastBit) - (1 << firstBit); - - // Return false if we're looking for 1s and the masked bits[i] isn't all 1s (that is, - // equals the mask, or we're looking for 0s and the masked portion is not all 0s - if ((bits[i] & mask) != (value ? mask : 0)) { - return false; - } - } - return true; - } - - public void appendBit(boolean bit) { - ensureCapacity(size + 1); - if (bit) { - bits[size / 32] |= 1 << (size & 0x1F); - } - size++; - } - - /** - * Appends the least-significant bits, from value, in order from most-significant to - * least-significant. For example, appending 6 bits from 0x000001E will append the bits - * 0, 1, 1, 1, 1, 0 in that order. - * - * @param value {@code int} containing bits to append - * @param numBits bits from value to append - */ - public void appendBits(int value, int numBits) { - if (numBits < 0 || numBits > 32) { - throw new IllegalArgumentException("Num bits must be between 0 and 32"); - } - int nextSize = size; - ensureCapacity(nextSize + numBits); - for (int numBitsLeft = numBits - 1; numBitsLeft >= 0; numBitsLeft--) { - if ((value & (1 << numBitsLeft)) != 0) { - bits[nextSize / 32] |= 1 << (nextSize & 0x1F); - } - nextSize++; - } - size = nextSize; - } - - public void appendBitArray(BitArray other) { - int otherSize = other.size; - ensureCapacity(size + otherSize); - for (int i = 0; i < otherSize; i++) { - appendBit(other.get(i)); - } - } - - public void xor(BitArray other) { - if (size != other.size) { - throw new IllegalArgumentException("Sizes don't match"); - } - for (int i = 0; i < bits.length; i++) { - // The last int could be incomplete (i.e. not have 32 bits in - // it) but there is no problem since 0 XOR 0 == 0. - bits[i] ^= other.bits[i]; - } - } - - /** - * - * @param bitOffset first bit to start writing - * @param array array to write into. Bytes are written most-significant byte first. This is the opposite - * of the internal representation, which is exposed by {@link #getBitArray()} - * @param offset position in array to start writing - * @param numBytes how many bytes to write - */ - public void toBytes(int bitOffset, byte[] array, int offset, int numBytes) { - for (int i = 0; i < numBytes; i++) { - int theByte = 0; - for (int j = 0; j < 8; j++) { - if (get(bitOffset)) { - theByte |= 1 << (7 - j); - } - bitOffset++; - } - array[offset + i] = (byte) theByte; - } - } - - /** - * @return underlying array of ints. The first element holds the first 32 bits, and the least - * significant bit is bit 0. - */ - public int[] getBitArray() { - return bits; - } - - /** - * Reverses all bits in the array. - */ - public void reverse() { - int[] newBits = new int[bits.length]; - // reverse all int's first - int len = (size - 1) / 32; - int oldBitsLen = len + 1; - for (int i = 0; i < oldBitsLen; i++) { - newBits[len - i] = Integer.reverse(bits[i]); - } - // now correct the int's if the bit size isn't a multiple of 32 - if (size != oldBitsLen * 32) { - int leftOffset = oldBitsLen * 32 - size; - int currentInt = newBits[0] >>> leftOffset; - for (int i = 1; i < oldBitsLen; i++) { - int nextInt = newBits[i]; - currentInt |= nextInt << (32 - leftOffset); - newBits[i - 1] = currentInt; - currentInt = nextInt >>> leftOffset; - } - newBits[oldBitsLen - 1] = currentInt; - } - bits = newBits; - } - - private static int[] makeArray(int size) { - return new int[(size + 31) / 32]; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof BitArray)) { - return false; - } - BitArray other = (BitArray) o; - return size == other.size && Arrays.equals(bits, other.bits); - } - - @Override - public int hashCode() { - return 31 * size + Arrays.hashCode(bits); - } - - @Override - public String toString() { - StringBuilder result = new StringBuilder(size + (size / 8) + 1); - for (int i = 0; i < size; i++) { - if ((i & 0x07) == 0) { - result.append(' '); - } - result.append(get(i) ? 'X' : '.'); - } - return result.toString(); - } - - @Override - public BitArray clone() { - return new BitArray(bits.clone(), size); - } - -} diff --git a/port_src/core/DONE/common/BitMatrix.java b/port_src/core/DONE/common/BitMatrix.java deleted file mode 100644 index d3f2175..0000000 --- a/port_src/core/DONE/common/BitMatrix.java +++ /dev/null @@ -1,537 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import java.util.Arrays; - -/** - *

Represents a 2D matrix of bits. In function arguments below, and throughout the common - * module, x is the column position, and y is the row position. The ordering is always x, y. - * The origin is at the top-left.

- * - *

Internally the bits are represented in a 1-D array of 32-bit ints. However, each row begins - * with a new int. This is done intentionally so that we can copy out a row into a BitArray very - * efficiently.

- * - *

The ordering of bits is row-major. Within each int, the least significant bits are used first, - * meaning they represent lower x values. This is compatible with BitArray's implementation.

- * - * @author Sean Owen - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class BitMatrix implements Cloneable { - - private int width; - private int height; - private int rowSize; - private int[] bits; - - /** - * Creates an empty square {@code BitMatrix}. - * - * @param dimension height and width - */ - public BitMatrix(int 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) { - if (width < 1 || height < 1) { - throw new IllegalArgumentException("Both dimensions must be greater than 0"); - } - this.width = width; - this.height = height; - this.rowSize = (width + 31) / 32; - bits = new int[rowSize * height]; - } - - private BitMatrix(int width, int height, int rowSize, int[] bits) { - this.width = width; - this.height = height; - this.rowSize = rowSize; - 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) { - if (stringRepresentation == null) { - throw new IllegalArgumentException(); - } - - boolean[] bits = new boolean[stringRepresentation.length()]; - int bitsPos = 0; - int rowStartPos = 0; - int rowLength = -1; - int nRows = 0; - int pos = 0; - while (pos < stringRepresentation.length()) { - if (stringRepresentation.charAt(pos) == '\n' || - stringRepresentation.charAt(pos) == '\r') { - if (bitsPos > rowStartPos) { - if (rowLength == -1) { - rowLength = bitsPos - rowStartPos; - } else if (bitsPos - rowStartPos != rowLength) { - throw new IllegalArgumentException("row lengths do not match"); - } - rowStartPos = bitsPos; - nRows++; - } - pos++; - } else if (stringRepresentation.startsWith(setString, pos)) { - pos += setString.length(); - bits[bitsPos] = true; - bitsPos++; - } else if (stringRepresentation.startsWith(unsetString, pos)) { - pos += unsetString.length(); - bits[bitsPos] = false; - bitsPos++; - } else { - throw new IllegalArgumentException( - "illegal character encountered: " + stringRepresentation.substring(pos)); - } - } - - // no EOL at end? - if (bitsPos > rowStartPos) { - if (rowLength == -1) { - rowLength = bitsPos - rowStartPos; - } else if (bitsPos - rowStartPos != rowLength) { - throw new IllegalArgumentException("row lengths do not match"); - } - nRows++; - } - - BitMatrix matrix = new BitMatrix(rowLength, nRows); - for (int i = 0; i < bitsPos; i++) { - if (bits[i]) { - matrix.set(i % rowLength, i / rowLength); - } - } - return matrix; - } - - /** - *

Gets the requested bit, where true means black.

- * - * @param x The horizontal component (i.e. which column) - * @param y The vertical component (i.e. which row) - * @return value of given bit in matrix - */ - public boolean get(int x, int y) { - int offset = y * rowSize + (x / 32); - return ((bits[offset] >>> (x & 0x1f)) & 1) != 0; - } - - /** - *

Sets the given bit to true.

- * - * @param x The horizontal component (i.e. which column) - * @param y The vertical component (i.e. which row) - */ - public void set(int x, int y) { - int offset = y * rowSize + (x / 32); - bits[offset] |= 1 << (x & 0x1f); - } - - public void unset(int x, int y) { - int offset = y * rowSize + (x / 32); - bits[offset] &= ~(1 << (x & 0x1f)); - } - - /** - *

Flips the given bit.

- * - * @param x The horizontal component (i.e. which column) - * @param y The vertical component (i.e. which row) - */ - public void flip(int x, int y) { - int offset = y * rowSize + (x / 32); - bits[offset] ^= 1 << (x & 0x1f); - } - - /** - *

Flips every bit in the matrix.

- */ - public void flip() { - int max = bits.length; - for (int i = 0; i < max; i++) { - bits[i] = ~bits[i]; - } - } - - /** - * Exclusive-or (XOR): Flip the bit in this {@code BitMatrix} if the corresponding - * mask bit is set. - * - * @param mask XOR mask - */ - public void xor(BitMatrix mask) { - if (width != mask.width || height != mask.height || rowSize != mask.rowSize) { - throw new IllegalArgumentException("input matrix dimensions do not match"); - } - BitArray rowArray = new BitArray(width); - for (int y = 0; y < height; y++) { - int offset = y * rowSize; - int[] row = mask.getRow(y, rowArray).getBitArray(); - for (int x = 0; x < rowSize; x++) { - bits[offset + x] ^= row[x]; - } - } - } - - /** - * Clears all bits (sets to false). - */ - public void clear() { - int max = bits.length; - for (int i = 0; i < max; i++) { - bits[i] = 0; - } - } - - /** - *

Sets a square region of the bit matrix to true.

- * - * @param left The horizontal position to begin at (inclusive) - * @param top The vertical position to begin at (inclusive) - * @param width The width of the region - * @param height The height of the region - */ - public void setRegion(int left, int top, int width, int height) { - if (top < 0 || left < 0) { - throw new IllegalArgumentException("Left and top must be nonnegative"); - } - if (height < 1 || width < 1) { - throw new IllegalArgumentException("Height and width must be at least 1"); - } - int right = left + width; - int bottom = top + height; - if (bottom > this.height || right > this.width) { - throw new IllegalArgumentException("The region must fit inside the matrix"); - } - for (int y = top; y < bottom; y++) { - int offset = y * rowSize; - for (int x = left; x < right; x++) { - bits[offset + (x / 32)] |= 1 << (x & 0x1f); - } - } - } - - /** - * A fast method to retrieve one row of data from the matrix as a BitArray. - * - * @param y The row to retrieve - * @param row An optional caller-allocated BitArray, will be allocated if null or too small - * @return The resulting BitArray - this reference should always be used even when passing - * your own row - */ - public BitArray getRow(int y, BitArray row) { - if (row == null || row.getSize() < width) { - row = new BitArray(width); - } else { - row.clear(); - } - int offset = y * rowSize; - for (int x = 0; x < rowSize; x++) { - row.setBulk(x * 32, bits[offset + x]); - } - return row; - } - - /** - * @param y row to set - * @param row {@link BitArray} to copy from - */ - public void setRow(int y, BitArray row) { - System.arraycopy(row.getBitArray(), 0, bits, y * rowSize, rowSize); - } - - /** - * Modifies this {@code BitMatrix} to represent the same but rotated the given degrees (0, 90, 180, 270) - * - * @param degrees number of degrees to rotate through counter-clockwise (0, 90, 180, 270) - */ - public void rotate(int degrees) { - switch (degrees % 360) { - case 0: - return; - case 90: - rotate90(); - return; - case 180: - rotate180(); - return; - case 270: - rotate90(); - rotate180(); - return; - } - throw new IllegalArgumentException("degrees must be a multiple of 0, 90, 180, or 270"); - } - - /** - * Modifies this {@code BitMatrix} to represent the same but rotated 180 degrees - */ - public void rotate180() { - BitArray topRow = new BitArray(width); - BitArray bottomRow = new BitArray(width); - int maxHeight = (height + 1) / 2; - for (int i = 0; i < maxHeight; i++) { - topRow = getRow(i, topRow); - int bottomRowIndex = height - 1 - i; - bottomRow = getRow(bottomRowIndex, bottomRow); - topRow.reverse(); - bottomRow.reverse(); - setRow(i, bottomRow); - setRow(bottomRowIndex, topRow); - } - } - - /** - * Modifies this {@code BitMatrix} to represent the same but rotated 90 degrees counterclockwise - */ - public void rotate90() { - int newWidth = height; - int newHeight = width; - int newRowSize = (newWidth + 31) / 32; - int[] newBits = new int[newRowSize * newHeight]; - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - int offset = y * rowSize + (x / 32); - if (((bits[offset] >>> (x & 0x1f)) & 1) != 0) { - int newOffset = (newHeight - 1 - x) * newRowSize + (y / 32); - newBits[newOffset] |= 1 << (y & 0x1f); - } - } - } - width = newWidth; - height = newHeight; - rowSize = newRowSize; - bits = newBits; - } - - /** - * This is useful in detecting the enclosing rectangle of a 'pure' barcode. - * - * @return {@code left,top,width,height} enclosing rectangle of all 1 bits, or null if it is all white - */ - public int[] getEnclosingRectangle() { - int left = width; - int top = height; - int right = -1; - int bottom = -1; - - for (int y = 0; y < height; y++) { - for (int x32 = 0; x32 < rowSize; x32++) { - int theBits = bits[y * rowSize + x32]; - if (theBits != 0) { - if (y < top) { - top = y; - } - if (y > bottom) { - bottom = y; - } - if (x32 * 32 < left) { - int bit = 0; - while ((theBits << (31 - bit)) == 0) { - bit++; - } - if ((x32 * 32 + bit) < left) { - left = x32 * 32 + bit; - } - } - if (x32 * 32 + 31 > right) { - int bit = 31; - while ((theBits >>> bit) == 0) { - bit--; - } - if ((x32 * 32 + bit) > right) { - right = x32 * 32 + bit; - } - } - } - } - } - - if (right < left || bottom < top) { - return null; - } - - return new int[] {left, top, right - left + 1, bottom - top + 1}; - } - - /** - * This is useful in detecting a corner of a 'pure' barcode. - * - * @return {@code x,y} coordinate of top-left-most 1 bit, or null if it is all white - */ - public int[] getTopLeftOnBit() { - int bitsOffset = 0; - while (bitsOffset < bits.length && bits[bitsOffset] == 0) { - bitsOffset++; - } - if (bitsOffset == bits.length) { - return null; - } - int y = bitsOffset / rowSize; - int x = (bitsOffset % rowSize) * 32; - - int theBits = bits[bitsOffset]; - int bit = 0; - while ((theBits << (31 - bit)) == 0) { - bit++; - } - x += bit; - return new int[] {x, y}; - } - - public int[] getBottomRightOnBit() { - int bitsOffset = bits.length - 1; - while (bitsOffset >= 0 && bits[bitsOffset] == 0) { - bitsOffset--; - } - if (bitsOffset < 0) { - return null; - } - - int y = bitsOffset / rowSize; - int x = (bitsOffset % rowSize) * 32; - - int theBits = bits[bitsOffset]; - int bit = 31; - while ((theBits >>> bit) == 0) { - bit--; - } - x += bit; - - return new int[] {x, y}; - } - - /** - * @return The width of the matrix - */ - public int getWidth() { - return width; - } - - /** - * @return The height of the matrix - */ - public int getHeight() { - return height; - } - - /** - * @return The row size of the matrix - */ - public int getRowSize() { - return rowSize; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof BitMatrix)) { - return false; - } - BitMatrix other = (BitMatrix) o; - return width == other.width && height == other.height && rowSize == other.rowSize && - Arrays.equals(bits, other.bits); - } - - @Override - public int hashCode() { - int hash = width; - hash = 31 * hash + width; - hash = 31 * hash + height; - hash = 31 * hash + rowSize; - hash = 31 * hash + Arrays.hashCode(bits); - return hash; - } - - /** - * @return string representation using "X" for set and " " for unset bits - */ - @Override - public String toString() { - return toString("X ", " "); - } - - /** - * @param setString representation of a set bit - * @param unsetString representation of an unset bit - * @return string representation of entire matrix utilizing given strings - */ - public String toString(String setString, String unsetString) { - return buildToString(setString, unsetString, "\n"); - } - - /** - * @param setString representation of a set bit - * @param unsetString representation of an unset bit - * @param lineSeparator newline character in string representation - * @return string representation of entire matrix utilizing given strings and line separator - * @deprecated call {@link #toString(String,String)} only, which uses \n line separator always - */ - @Deprecated - public String toString(String setString, String unsetString, String lineSeparator) { - return buildToString(setString, unsetString, lineSeparator); - } - - private String buildToString(String setString, String unsetString, String lineSeparator) { - StringBuilder result = new StringBuilder(height * (width + 1)); - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - result.append(get(x, y) ? setString : unsetString); - } - result.append(lineSeparator); - } - return result.toString(); - } - - @Override - public BitMatrix clone() { - return new BitMatrix(width, height, rowSize, bits.clone()); - } - -} diff --git a/port_src/core/DONE/common/BitSource.java b/port_src/core/DONE/common/BitSource.java deleted file mode 100644 index b4d0aaf..0000000 --- a/port_src/core/DONE/common/BitSource.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -/** - *

This provides an easy abstraction to read bits at a time from a sequence of bytes, where the - * number of bits read is not often a multiple of 8.

- * - *

This class is thread-safe but not reentrant -- unless the caller modifies the bytes array - * it passed in, in which case all bets are off.

- * - * @author Sean Owen - */ -public final class BitSource { - - private final byte[] bytes; - private int byteOffset; - private int bitOffset; - - /** - * @param bytes bytes from which this will read bits. Bits will be read from the first byte first. - * Bits are read within a byte from most-significant to least-significant bit. - */ - public BitSource(byte[] bytes) { - this.bytes = bytes; - } - - /** - * @return index of next bit in current byte which would be read by the next call to {@link #readBits(int)}. - */ - public int getBitOffset() { - return bitOffset; - } - - /** - * @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}. - */ - public int getByteOffset() { - return byteOffset; - } - - /** - * @param numBits number of bits to read - * @return int representing the bits read. The bits will appear as the least-significant - * bits of the int - * @throws IllegalArgumentException if numBits isn't in [1,32] or more than is available - */ - public int readBits(int numBits) { - if (numBits < 1 || numBits > 32 || numBits > available()) { - throw new IllegalArgumentException(String.valueOf(numBits)); - } - - int result = 0; - - // First, read remainder from current byte - if (bitOffset > 0) { - int bitsLeft = 8 - bitOffset; - int toRead = Math.min(numBits, bitsLeft); - int bitsToNotRead = bitsLeft - toRead; - int mask = (0xFF >> (8 - toRead)) << bitsToNotRead; - result = (bytes[byteOffset] & mask) >> bitsToNotRead; - numBits -= toRead; - bitOffset += toRead; - if (bitOffset == 8) { - bitOffset = 0; - byteOffset++; - } - } - - // Next read whole bytes - if (numBits > 0) { - while (numBits >= 8) { - result = (result << 8) | (bytes[byteOffset] & 0xFF); - byteOffset++; - numBits -= 8; - } - - // Finally read a partial byte - if (numBits > 0) { - int bitsToNotRead = 8 - numBits; - int mask = (0xFF >> bitsToNotRead) << bitsToNotRead; - result = (result << numBits) | ((bytes[byteOffset] & mask) >> bitsToNotRead); - bitOffset += numBits; - } - } - - return result; - } - - /** - * @return number of bits that can be read successfully - */ - public int available() { - return 8 * (bytes.length - byteOffset) - bitOffset; - } - -} diff --git a/port_src/core/DONE/common/CharacterSetECI.java b/port_src/core/DONE/common/CharacterSetECI.java deleted file mode 100644 index 5865445..0000000 --- a/port_src/core/DONE/common/CharacterSetECI.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import com.google.zxing.FormatException; - -import java.nio.charset.Charset; - -import java.util.HashMap; -import java.util.Map; - -/** - * Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1 - * of ISO 18004. - * - * @author Sean Owen - */ -public enum CharacterSetECI { - - // Enum name is a Java encoding valid for java.lang and java.io - Cp437(new int[]{0,2}), - ISO8859_1(new int[]{1,3}, "ISO-8859-1"), - ISO8859_2(4, "ISO-8859-2"), - ISO8859_3(5, "ISO-8859-3"), - ISO8859_4(6, "ISO-8859-4"), - ISO8859_5(7, "ISO-8859-5"), - // ISO8859_6(8, "ISO-8859-6"), - ISO8859_7(9, "ISO-8859-7"), - // ISO8859_8(10, "ISO-8859-8"), - ISO8859_9(11, "ISO-8859-9"), - // ISO8859_10(12, "ISO-8859-10"), - // ISO8859_11(13, "ISO-8859-11"), - ISO8859_13(15, "ISO-8859-13"), - // ISO8859_14(16, "ISO-8859-14"), - ISO8859_15(17, "ISO-8859-15"), - ISO8859_16(18, "ISO-8859-16"), - SJIS(20, "Shift_JIS"), - Cp1250(21, "windows-1250"), - Cp1251(22, "windows-1251"), - Cp1252(23, "windows-1252"), - Cp1256(24, "windows-1256"), - UnicodeBigUnmarked(25, "UTF-16BE", "UnicodeBig"), - UTF8(26, "UTF-8"), - ASCII(new int[] {27, 170}, "US-ASCII"), - Big5(28), - GB18030(29, "GB2312", "EUC_CN", "GBK"), - EUC_KR(30, "EUC-KR"); - - private static final Map VALUE_TO_ECI = new HashMap<>(); - private static final Map NAME_TO_ECI = new HashMap<>(); - static { - for (CharacterSetECI eci : values()) { - for (int value : eci.values) { - VALUE_TO_ECI.put(value, eci); - } - NAME_TO_ECI.put(eci.name(), eci); - for (String name : eci.otherEncodingNames) { - NAME_TO_ECI.put(name, eci); - } - } - } - - private final int[] values; - private final String[] otherEncodingNames; - - CharacterSetECI(int value) { - this(new int[] {value}); - } - - CharacterSetECI(int value, String... otherEncodingNames) { - this.values = new int[] {value}; - this.otherEncodingNames = otherEncodingNames; - } - - CharacterSetECI(int[] values, String... otherEncodingNames) { - this.values = values; - this.otherEncodingNames = otherEncodingNames; - } - - public int getValue() { - return values[0]; - } - - public Charset getCharset() { - return Charset.forName(name()); - } - - /** - * @param charset Java character set object - * @return CharacterSetECI representing ECI for character encoding, or null if it is legal - * but unsupported - */ - public static CharacterSetECI getCharacterSetECI(Charset charset) { - return NAME_TO_ECI.get(charset.name()); - } - - /** - * @param value character set ECI value - * @return {@code CharacterSetECI} representing ECI of given value, or null if it is legal but - * unsupported - * @throws FormatException if ECI value is invalid - */ - public static CharacterSetECI getCharacterSetECIByValue(int value) throws FormatException { - if (value < 0 || value >= 900) { - throw FormatException.getFormatInstance(); - } - return VALUE_TO_ECI.get(value); - } - - /** - * @param name character set ECI encoding name - * @return CharacterSetECI representing ECI for character encoding, or null if it is legal - * but unsupported - */ - public static CharacterSetECI getCharacterSetECIByName(String name) { - return NAME_TO_ECI.get(name); - } - -} diff --git a/port_src/core/DONE/common/DecoderResult.java b/port_src/core/DONE/common/DecoderResult.java deleted file mode 100644 index db2e7e0..0000000 --- a/port_src/core/DONE/common/DecoderResult.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import java.util.List; - -/** - *

Encapsulates the result of decoding a matrix of bits. This typically - * applies to 2D barcode formats. For now it contains the raw bytes obtained, - * as well as a String interpretation of those bytes, if applicable.

- * - * @author Sean Owen - */ -public final class DecoderResult { - - private final byte[] rawBytes; - private int numBits; - private final String text; - private final List byteSegments; - private final String ecLevel; - private Integer errorsCorrected; - private Integer erasures; - private Object other; - private final int structuredAppendParity; - private final int structuredAppendSequenceNumber; - private final int symbologyModifier; - - public DecoderResult(byte[] rawBytes, - String text, - List byteSegments, - String ecLevel) { - this(rawBytes, text, byteSegments, ecLevel, -1, -1, 0); - } - - public DecoderResult(byte[] rawBytes, - String text, - List byteSegments, - String ecLevel, - int symbologyModifier) { - this(rawBytes, text, byteSegments, ecLevel, -1, -1, symbologyModifier); - } - - public DecoderResult(byte[] rawBytes, - String text, - List byteSegments, - String ecLevel, - int saSequence, - int saParity) { - this(rawBytes, text, byteSegments, ecLevel, saSequence, saParity, 0); - } - - public DecoderResult(byte[] rawBytes, - String text, - List byteSegments, - String ecLevel, - int saSequence, - int saParity, - int symbologyModifier) { - this.rawBytes = rawBytes; - this.numBits = rawBytes == null ? 0 : 8 * rawBytes.length; - this.text = text; - this.byteSegments = byteSegments; - this.ecLevel = ecLevel; - this.structuredAppendParity = saParity; - this.structuredAppendSequenceNumber = saSequence; - this.symbologyModifier = symbologyModifier; - } - - /** - * @return raw bytes representing the result, or {@code null} if not applicable - */ - public byte[] getRawBytes() { - return rawBytes; - } - - /** - * @return how many bits of {@link #getRawBytes()} are valid; typically 8 times its length - * @since 3.3.0 - */ - public int getNumBits() { - return numBits; - } - - /** - * @param numBits overrides the number of bits that are valid in {@link #getRawBytes()} - * @since 3.3.0 - */ - public void setNumBits(int numBits) { - this.numBits = numBits; - } - - /** - * @return text representation of the result - */ - public String getText() { - return text; - } - - /** - * @return list of byte segments in the result, or {@code null} if not applicable - */ - public List getByteSegments() { - return byteSegments; - } - - /** - * @return name of error correction level used, or {@code null} if not applicable - */ - public String getECLevel() { - return ecLevel; - } - - /** - * @return number of errors corrected, or {@code null} if not applicable - */ - public Integer getErrorsCorrected() { - return errorsCorrected; - } - - public void setErrorsCorrected(Integer errorsCorrected) { - this.errorsCorrected = errorsCorrected; - } - - /** - * @return number of erasures corrected, or {@code null} if not applicable - */ - public Integer getErasures() { - return erasures; - } - - public void setErasures(Integer erasures) { - this.erasures = erasures; - } - - /** - * @return arbitrary additional metadata - */ - public Object getOther() { - return other; - } - - public void setOther(Object other) { - this.other = other; - } - - public boolean hasStructuredAppend() { - return structuredAppendParity >= 0 && structuredAppendSequenceNumber >= 0; - } - - public int getStructuredAppendParity() { - return structuredAppendParity; - } - - public int getStructuredAppendSequenceNumber() { - return structuredAppendSequenceNumber; - } - - public int getSymbologyModifier() { - return symbologyModifier; - } - -} diff --git a/port_src/core/DONE/common/DefaultGridSampler.java b/port_src/core/DONE/common/DefaultGridSampler.java deleted file mode 100644 index 1248de0..0000000 --- a/port_src/core/DONE/common/DefaultGridSampler.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import com.google.zxing.NotFoundException; - -/** - * @author Sean Owen - */ -public final class DefaultGridSampler extends GridSampler { - - @Override - public BitMatrix sampleGrid(BitMatrix image, - int dimensionX, - int dimensionY, - float p1ToX, float p1ToY, - float p2ToX, float p2ToY, - float p3ToX, float p3ToY, - float p4ToX, float p4ToY, - float p1FromX, float p1FromY, - float p2FromX, float p2FromY, - float p3FromX, float p3FromY, - float p4FromX, float p4FromY) throws NotFoundException { - - PerspectiveTransform transform = PerspectiveTransform.quadrilateralToQuadrilateral( - p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, - p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY); - - return sampleGrid(image, dimensionX, dimensionY, transform); - } - - @Override - public BitMatrix sampleGrid(BitMatrix image, - int dimensionX, - int dimensionY, - PerspectiveTransform transform) throws NotFoundException { - if (dimensionX <= 0 || dimensionY <= 0) { - throw NotFoundException.getNotFoundInstance(); - } - BitMatrix bits = new BitMatrix(dimensionX, dimensionY); - float[] points = new float[2 * dimensionX]; - for (int y = 0; y < dimensionY; y++) { - int max = points.length; - float iValue = y + 0.5f; - for (int x = 0; x < max; x += 2) { - points[x] = (float) (x / 2) + 0.5f; - points[x + 1] = iValue; - } - transform.transformPoints(points); - // Quick check to see if points transformed to something inside the image; - // sufficient to check the endpoints - checkAndNudgePoints(image, points); - try { - for (int x = 0; x < max; x += 2) { - if (image.get((int) points[x], (int) points[x + 1])) { - // Black(-ish) pixel - bits.set(x / 2, y); - } - } - } catch (ArrayIndexOutOfBoundsException aioobe) { - // This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting - // transform gets "twisted" such that it maps a straight line of points to a set of points - // whose endpoints are in bounds, but others are not. There is probably some mathematical - // way to detect this about the transformation that I don't know yet. - // This results in an ugly runtime exception despite our clever checks above -- can't have - // that. We could check each point's coordinates but that feels duplicative. We settle for - // catching and wrapping ArrayIndexOutOfBoundsException. - throw NotFoundException.getNotFoundInstance(); - } - } - return bits; - } - -} diff --git a/port_src/core/DONE/common/DetectorResult.java b/port_src/core/DONE/common/DetectorResult.java deleted file mode 100644 index 0f3cf15..0000000 --- a/port_src/core/DONE/common/DetectorResult.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import com.google.zxing.ResultPoint; - -/** - *

Encapsulates the result of detecting a barcode in an image. This includes the raw - * matrix of black/white pixels corresponding to the barcode, and possibly points of interest - * in the image, like the location of finder patterns or corners of the barcode in the image.

- * - * @author Sean Owen - */ -public class DetectorResult { - - private final BitMatrix bits; - private final ResultPoint[] points; - - public DetectorResult(BitMatrix bits, ResultPoint[] points) { - this.bits = bits; - this.points = points; - } - - public final BitMatrix getBits() { - return bits; - } - - public final ResultPoint[] getPoints() { - return points; - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/common/ECIEncoderSet.java b/port_src/core/DONE/common/ECIEncoderSet.java deleted file mode 100644 index afa889b..0000000 --- a/port_src/core/DONE/common/ECIEncoderSet.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 2021 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import java.nio.charset.Charset; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.StandardCharsets; -import java.nio.charset.UnsupportedCharsetException; -import java.util.ArrayList; -import java.util.List; - -/** - * Set of CharsetEncoders for a given input string - * - * Invariants: - * - The list contains only encoders from CharacterSetECI (list is shorter then the list of encoders available on - * the platform for which ECI values are defined). - * - The list contains encoders at least one encoder for every character in the input. - * - The first encoder in the list is always the ISO-8859-1 encoder even of no character in the input can be encoded - * by it. - * - If the input contains a character that is not in ISO-8859-1 then the last two entries in the list will be the - * UTF-8 encoder and the UTF-16BE encoder. - * - * @author Alex Geller - */ -public final class ECIEncoderSet { - - // List of encoders that potentially encode characters not in ISO-8859-1 in one byte. - private static final List ENCODERS = new ArrayList<>(); - static { - String[] names = { "IBM437", - "ISO-8859-2", - "ISO-8859-3", - "ISO-8859-4", - "ISO-8859-5", - "ISO-8859-6", - "ISO-8859-7", - "ISO-8859-8", - "ISO-8859-9", - "ISO-8859-10", - "ISO-8859-11", - "ISO-8859-13", - "ISO-8859-14", - "ISO-8859-15", - "ISO-8859-16", - "windows-1250", - "windows-1251", - "windows-1252", - "windows-1256", - "Shift_JIS" }; - for (String name : names) { - if (CharacterSetECI.getCharacterSetECIByName(name) != null) { - try { - ENCODERS.add(Charset.forName(name).newEncoder()); - } catch (UnsupportedCharsetException e) { - // continue - } - } - } - } - - private final CharsetEncoder[] encoders; - private final int priorityEncoderIndex; - - /** - * Constructs an encoder set - * - * @param stringToEncode the string that needs to be encoded - * @param priorityCharset The preferred {@link Charset} or null. - * @param fnc1 fnc1 denotes the character in the input that represents the FNC1 character or -1 for a non-GS1 bar - * code. When specified, it is considered an error to pass it as argument to the methods canEncode() or encode(). - */ - public ECIEncoderSet(String stringToEncode, Charset priorityCharset, int fnc1) { - List neededEncoders = new ArrayList<>(); - - //we always need the ISO-8859-1 encoder. It is the default encoding - neededEncoders.add(StandardCharsets.ISO_8859_1.newEncoder()); - boolean needUnicodeEncoder = priorityCharset != null && priorityCharset.name().startsWith("UTF"); - - //Walk over the input string and see if all characters can be encoded with the list of encoders - for (int i = 0; i < stringToEncode.length(); i++) { - boolean canEncode = false; - for (CharsetEncoder encoder : neededEncoders) { - char c = stringToEncode.charAt(i); - if (c == fnc1 || encoder.canEncode(c)) { - canEncode = true; - break; - } - } - - if (!canEncode) { - //for the character at position i we don't yet have an encoder in the list - for (CharsetEncoder encoder : ENCODERS) { - if (encoder.canEncode(stringToEncode.charAt(i))) { - //Good, we found an encoder that can encode the character. We add him to the list and continue scanning - //the input - neededEncoders.add(encoder); - canEncode = true; - break; - } - } - } - - if (!canEncode) { - //The character is not encodeable by any of the single byte encoders so we remember that we will need a - //Unicode encoder. - needUnicodeEncoder = true; - } - } - - if (neededEncoders.size() == 1 && !needUnicodeEncoder) { - //the entire input can be encoded by the ISO-8859-1 encoder - encoders = new CharsetEncoder[] { neededEncoders.get(0) }; - } else { - // we need more than one single byte encoder or we need a Unicode encoder. - // In this case we append a UTF-8 and UTF-16 encoder to the list - encoders = new CharsetEncoder[neededEncoders.size() + 2]; - int index = 0; - for (CharsetEncoder encoder : neededEncoders) { - encoders[index++] = encoder; - } - - encoders[index] = StandardCharsets.UTF_8.newEncoder(); - encoders[index + 1] = StandardCharsets.UTF_16BE.newEncoder(); - } - - //Compute priorityEncoderIndex by looking up priorityCharset in encoders - int priorityEncoderIndexValue = -1; - if (priorityCharset != null) { - for (int i = 0; i < encoders.length; i++) { - if (encoders[i] != null && priorityCharset.name().equals(encoders[i].charset().name())) { - priorityEncoderIndexValue = i; - break; - } - } - } - priorityEncoderIndex = priorityEncoderIndexValue; - //invariants - assert encoders[0].charset().equals(StandardCharsets.ISO_8859_1); - } - - public int length() { - return encoders.length; - } - - public String getCharsetName(int index) { - assert index < length(); - return encoders[index].charset().name(); - } - - public Charset getCharset(int index) { - assert index < length(); - return encoders[index].charset(); - } - - public int getECIValue(int encoderIndex) { - return CharacterSetECI.getCharacterSetECI(encoders[encoderIndex].charset()).getValue(); - } - - /* - * returns -1 if no priority charset was defined - */ - public int getPriorityEncoderIndex() { - return priorityEncoderIndex; - } - - public boolean canEncode(char c, int encoderIndex) { - assert encoderIndex < length(); - CharsetEncoder encoder = encoders[encoderIndex]; - return encoder.canEncode("" + c); - } - - public byte[] encode(char c, int encoderIndex) { - assert encoderIndex < length(); - CharsetEncoder encoder = encoders[encoderIndex]; - assert encoder.canEncode("" + c); - return ("" + c).getBytes(encoder.charset()); - } - - public byte[] encode(String s, int encoderIndex) { - assert encoderIndex < length(); - CharsetEncoder encoder = encoders[encoderIndex]; - return s.getBytes(encoder.charset()); - } -} diff --git a/port_src/core/DONE/common/ECIInput.java b/port_src/core/DONE/common/ECIInput.java deleted file mode 100644 index ad444e1..0000000 --- a/port_src/core/DONE/common/ECIInput.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2021 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -/** - * Interface to navigate a sequence of ECIs and bytes. - * - * @author Alex Geller - */ -public interface ECIInput { - - /** - * Returns the length of this input. The length is the number - * of {@code byte}s in or ECIs in the sequence. - * - * @return the number of {@code char}s in this sequence - */ - int length(); - - /** - * Returns the {@code byte} value at the specified index. An index ranges from zero - * to {@code length() - 1}. The first {@code byte} value of the sequence is at - * index zero, the next at index one, and so on, as for array - * indexing. - * - * @param index the index of the {@code byte} value to be returned - * - * @return the specified {@code byte} value as character or the FNC1 character - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - * @throws IllegalArgumentException - * if the value at the {@code index} argument is an ECI (@see #isECI) - */ - char charAt(int index); - - /** - * Returns a {@code CharSequence} that is a subsequence of this sequence. - * The subsequence starts with the {@code char} value at the specified index and - * ends with the {@code char} value at index {@code end - 1}. The length - * (in {@code char}s) of the - * returned sequence is {@code end - start}, so if {@code start == end} - * then an empty sequence is returned. - * - * @param start the start index, inclusive - * @param end the end index, exclusive - * - * @return the specified subsequence - * - * @throws IndexOutOfBoundsException - * if {@code start} or {@code end} are negative, - * if {@code end} is greater than {@code length()}, - * or if {@code start} is greater than {@code end} - * @throws IllegalArgumentException - * if a value in the range {@code start}-{@code end} is an ECI (@see #isECI) - */ - CharSequence subSequence(int start, int end); - - /** - * Determines if a value is an ECI - * - * @param index the index of the value - * - * @return true if the value at position {@code index} is an ECI - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - */ - boolean isECI(int index); - - /** - * Returns the {@code int} ECI value at the specified index. An index ranges from zero - * to {@code length() - 1}. The first {@code byte} value of the sequence is at - * index zero, the next at index one, and so on, as for array - * indexing. - * - * @param index the index of the {@code int} value to be returned - * - * @return the specified {@code int} ECI value. - * The ECI specified the encoding of all bytes with a higher index until the - * next ECI or until the end of the input if no other ECI follows. - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - * @throws IllegalArgumentException - * if the value at the {@code index} argument is not an ECI (@see #isECI) - */ - int getECIValue(int index); - boolean haveNCharacters(int index, int n); -} diff --git a/port_src/core/DONE/common/ECIStringBuilder.java b/port_src/core/DONE/common/ECIStringBuilder.java deleted file mode 100644 index a4a2968..0000000 --- a/port_src/core/DONE/common/ECIStringBuilder.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2022 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import com.google.zxing.FormatException; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; - -/** - * Class that converts a sequence of ECIs and bytes into a string - * - * @author Alex Geller - */ -public final class ECIStringBuilder { - private StringBuilder currentBytes; - private StringBuilder result; - private Charset currentCharset = StandardCharsets.ISO_8859_1; - - public ECIStringBuilder() { - currentBytes = new StringBuilder(); - } - public ECIStringBuilder(int initialCapacity) { - currentBytes = new StringBuilder(initialCapacity); - } - - /** - * Appends {@code value} as a byte value - * - * @param value character whose lowest byte is to be appended - */ - public void append(char value) { - currentBytes.append((char) (value & 0xff)); - } - - /** - * Appends {@code value} as a byte value - * - * @param value byte to append - */ - public void append(byte value) { - currentBytes.append((char) (value & 0xff)); - } - - /** - * Appends the characters in {@code value} as bytes values - * - * @param value string to append - */ - public void append(String value) { - currentBytes.append(value); - } - - /** - * Append the string repesentation of {@code value} (short for {@code append(String.valueOf(value))}) - * - * @param value int to append as a string - */ - public void append(int value) { - append(String.valueOf(value)); - } - - /** - * Appends ECI value to output. - * - * @param value ECI value to append, as an int - * @throws FormatException on invalid ECI value - */ - public void appendECI(int value) throws FormatException { - encodeCurrentBytesIfAny(); - CharacterSetECI characterSetECI = CharacterSetECI.getCharacterSetECIByValue(value); - if (characterSetECI == null) { - throw FormatException.getFormatInstance(); - } - currentCharset = characterSetECI.getCharset(); - } - - private void encodeCurrentBytesIfAny() { - if (currentCharset.equals(StandardCharsets.ISO_8859_1)) { - if (currentBytes.length() > 0) { - if (result == null) { - result = currentBytes; - currentBytes = new StringBuilder(); - } else { - result.append(currentBytes); - currentBytes = new StringBuilder(); - } - } - } else if (currentBytes.length() > 0) { - byte[] bytes = currentBytes.toString().getBytes(StandardCharsets.ISO_8859_1); - currentBytes = new StringBuilder(); - if (result == null) { - result = new StringBuilder(new String(bytes, currentCharset)); - } else { - result.append(new String(bytes, currentCharset)); - } - } - } - - /** - * Appends the characters from {@code value} (unlike all other append methods of this class who append bytes) - * - * @param value characters to append - */ - public void appendCharacters(StringBuilder value) { - encodeCurrentBytesIfAny(); - result.append(value); - } - - /** - * Short for {@code toString().length()} (if possible, use {@link #isEmpty()} instead) - * - * @return length of string representation in characters - */ - public int length() { - return toString().length(); - } - - /** - * @return true iff nothing has been appended - */ - public boolean isEmpty() { - return currentBytes.length() == 0 && (result == null || result.length() == 0); - } - - @Override - public String toString() { - encodeCurrentBytesIfAny(); - return result == null ? "" : result.toString(); - } -} diff --git a/port_src/core/DONE/common/GlobalHistogramBinarizer.java b/port_src/core/DONE/common/GlobalHistogramBinarizer.java deleted file mode 100644 index 1856744..0000000 --- a/port_src/core/DONE/common/GlobalHistogramBinarizer.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import com.google.zxing.Binarizer; -import com.google.zxing.LuminanceSource; -import com.google.zxing.NotFoundException; - -/** - * This Binarizer implementation uses the old ZXing global histogram approach. It is suitable - * for low-end mobile devices which don't have enough CPU or memory to use a local thresholding - * algorithm. However, because it picks a global black point, it cannot handle difficult shadows - * and gradients. - * - * Faster mobile devices and all desktop applications should probably use HybridBinarizer instead. - * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - */ -public class GlobalHistogramBinarizer extends Binarizer { - - private static final int LUMINANCE_BITS = 5; - private static final int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS; - private static final int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS; - private static final byte[] EMPTY = new byte[0]; - - private byte[] luminances; - private final int[] buckets; - - public GlobalHistogramBinarizer(LuminanceSource source) { - super(source); - luminances = EMPTY; - buckets = new int[LUMINANCE_BUCKETS]; - } - - // Applies simple sharpening to the row data to improve performance of the 1D Readers. - @Override - public BitArray getBlackRow(int y, BitArray row) throws NotFoundException { - LuminanceSource source = getLuminanceSource(); - int width = source.getWidth(); - if (row == null || row.getSize() < width) { - row = new BitArray(width); - } else { - row.clear(); - } - - initArrays(width); - byte[] localLuminances = source.getRow(y, luminances); - int[] localBuckets = buckets; - for (int x = 0; x < width; x++) { - localBuckets[(localLuminances[x] & 0xff) >> LUMINANCE_SHIFT]++; - } - int blackPoint = estimateBlackPoint(localBuckets); - - if (width < 3) { - // Special case for very small images - for (int x = 0; x < width; x++) { - if ((localLuminances[x] & 0xff) < blackPoint) { - row.set(x); - } - } - } else { - int left = localLuminances[0] & 0xff; - int center = localLuminances[1] & 0xff; - for (int x = 1; x < width - 1; x++) { - int right = localLuminances[x + 1] & 0xff; - // A simple -1 4 -1 box filter with a weight of 2. - if (((center * 4) - left - right) / 2 < blackPoint) { - row.set(x); - } - left = center; - center = right; - } - } - return row; - } - - // Does not sharpen the data, as this call is intended to only be used by 2D Readers. - @Override - public BitMatrix getBlackMatrix() throws NotFoundException { - LuminanceSource source = getLuminanceSource(); - int width = source.getWidth(); - int height = source.getHeight(); - BitMatrix matrix = new BitMatrix(width, height); - - // Quickly calculates the histogram by sampling four rows from the image. This proved to be - // more robust on the blackbox tests than sampling a diagonal as we used to do. - initArrays(width); - int[] localBuckets = buckets; - for (int y = 1; y < 5; y++) { - int row = height * y / 5; - byte[] localLuminances = source.getRow(row, luminances); - int right = (width * 4) / 5; - for (int x = width / 5; x < right; x++) { - int pixel = localLuminances[x] & 0xff; - localBuckets[pixel >> LUMINANCE_SHIFT]++; - } - } - int blackPoint = estimateBlackPoint(localBuckets); - - // We delay reading the entire image luminance until the black point estimation succeeds. - // Although we end up reading four rows twice, it is consistent with our motto of - // "fail quickly" which is necessary for continuous scanning. - byte[] localLuminances = source.getMatrix(); - for (int y = 0; y < height; y++) { - int offset = y * width; - for (int x = 0; x < width; x++) { - int pixel = localLuminances[offset + x] & 0xff; - if (pixel < blackPoint) { - matrix.set(x, y); - } - } - } - - return matrix; - } - - @Override - public Binarizer createBinarizer(LuminanceSource source) { - return new GlobalHistogramBinarizer(source); - } - - private void initArrays(int luminanceSize) { - if (luminances.length < luminanceSize) { - luminances = new byte[luminanceSize]; - } - for (int x = 0; x < LUMINANCE_BUCKETS; x++) { - buckets[x] = 0; - } - } - - private static int estimateBlackPoint(int[] buckets) throws NotFoundException { - // Find the tallest peak in the histogram. - int numBuckets = buckets.length; - int maxBucketCount = 0; - int firstPeak = 0; - int firstPeakSize = 0; - for (int x = 0; x < numBuckets; x++) { - if (buckets[x] > firstPeakSize) { - firstPeak = x; - firstPeakSize = buckets[x]; - } - if (buckets[x] > maxBucketCount) { - maxBucketCount = buckets[x]; - } - } - - // Find the second-tallest peak which is somewhat far from the tallest peak. - int secondPeak = 0; - int secondPeakScore = 0; - for (int x = 0; x < numBuckets; x++) { - int distanceToBiggest = x - firstPeak; - // Encourage more distant second peaks by multiplying by square of distance. - int score = buckets[x] * distanceToBiggest * distanceToBiggest; - if (score > secondPeakScore) { - secondPeak = x; - secondPeakScore = score; - } - } - - // Make sure firstPeak corresponds to the black peak. - if (firstPeak > secondPeak) { - int temp = firstPeak; - firstPeak = secondPeak; - secondPeak = temp; - } - - // If there is too little contrast in the image to pick a meaningful black point, throw rather - // than waste time trying to decode the image, and risk false positives. - if (secondPeak - firstPeak <= numBuckets / 16) { - throw NotFoundException.getNotFoundInstance(); - } - - // Find a valley between them that is low and closer to the white peak. - int bestValley = secondPeak - 1; - int bestValleyScore = -1; - for (int x = secondPeak - 1; x > firstPeak; x--) { - int fromFirst = x - firstPeak; - int score = fromFirst * fromFirst * (secondPeak - x) * (maxBucketCount - buckets[x]); - if (score > bestValleyScore) { - bestValley = x; - bestValleyScore = score; - } - } - - return bestValley << LUMINANCE_SHIFT; - } - -} diff --git a/port_src/core/DONE/common/GridSampler.java b/port_src/core/DONE/common/GridSampler.java deleted file mode 100644 index 43c3cf2..0000000 --- a/port_src/core/DONE/common/GridSampler.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import com.google.zxing.NotFoundException; - -/** - * Implementations of this class can, given locations of finder patterns for a QR code in an - * image, sample the right points in the image to reconstruct the QR code, accounting for - * perspective distortion. It is abstracted since it is relatively expensive and should be allowed - * to take advantage of platform-specific optimized implementations, like Sun's Java Advanced - * Imaging library, but which may not be available in other environments such as J2ME, and vice - * versa. - * - * The implementation used can be controlled by calling {@link #setGridSampler(GridSampler)} - * with an instance of a class which implements this interface. - * - * @author Sean Owen - */ -public abstract class GridSampler { - - private static GridSampler gridSampler = new DefaultGridSampler(); - - /** - * Sets the implementation of GridSampler used by the library. One global - * instance is stored, which may sound problematic. But, the implementation provided - * ought to be appropriate for the entire platform, and all uses of this library - * in the whole lifetime of the JVM. For instance, an Android activity can swap in - * an implementation that takes advantage of native platform libraries. - * - * @param newGridSampler The platform-specific object to install. - */ - public static void setGridSampler(GridSampler newGridSampler) { - gridSampler = newGridSampler; - } - - /** - * @return the current implementation of GridSampler - */ - public static GridSampler getInstance() { - return gridSampler; - } - - /** - * Samples an image for a rectangular matrix of bits of the given dimension. The sampling - * transformation is determined by the coordinates of 4 points, in the original and transformed - * image space. - * - * @param image image to sample - * @param dimensionX width of {@link BitMatrix} to sample from image - * @param dimensionY height of {@link BitMatrix} to sample from image - * @param p1ToX point 1 preimage X - * @param p1ToY point 1 preimage Y - * @param p2ToX point 2 preimage X - * @param p2ToY point 2 preimage Y - * @param p3ToX point 3 preimage X - * @param p3ToY point 3 preimage Y - * @param p4ToX point 4 preimage X - * @param p4ToY point 4 preimage Y - * @param p1FromX point 1 image X - * @param p1FromY point 1 image Y - * @param p2FromX point 2 image X - * @param p2FromY point 2 image Y - * @param p3FromX point 3 image X - * @param p3FromY point 3 image Y - * @param p4FromX point 4 image X - * @param p4FromY point 4 image Y - * @return {@link BitMatrix} representing a grid of points sampled from the image within a region - * defined by the "from" parameters - * @throws NotFoundException if image can't be sampled, for example, if the transformation defined - * by the given points is invalid or results in sampling outside the image boundaries - */ - public abstract BitMatrix sampleGrid(BitMatrix image, - int dimensionX, - int dimensionY, - float p1ToX, float p1ToY, - float p2ToX, float p2ToY, - float p3ToX, float p3ToY, - float p4ToX, float p4ToY, - float p1FromX, float p1FromY, - float p2FromX, float p2FromY, - float p3FromX, float p3FromY, - float p4FromX, float p4FromY) throws NotFoundException; - - public abstract BitMatrix sampleGrid(BitMatrix image, - int dimensionX, - int dimensionY, - PerspectiveTransform transform) throws NotFoundException; - - /** - *

Checks a set of points that have been transformed to sample points on an image against - * the image's dimensions to see if the point are even within the image.

- * - *

This method will actually "nudge" the endpoints back onto the image if they are found to be - * barely (less than 1 pixel) off the image. This accounts for imperfect detection of finder - * patterns in an image where the QR Code runs all the way to the image border.

- * - *

For efficiency, the method will check points from either end of the line until one is found - * to be within the image. Because the set of points are assumed to be linear, this is valid.

- * - * @param image image into which the points should map - * @param points actual points in x1,y1,...,xn,yn form - * @throws NotFoundException if an endpoint is lies outside the image boundaries - */ - protected static void checkAndNudgePoints(BitMatrix image, - float[] points) throws NotFoundException { - int width = image.getWidth(); - int height = image.getHeight(); - // Check and nudge points from start until we see some that are OK: - boolean nudged = true; - int maxOffset = points.length - 1; // points.length must be even - for (int offset = 0; offset < maxOffset && nudged; offset += 2) { - int x = (int) points[offset]; - int y = (int) points[offset + 1]; - if (x < -1 || x > width || y < -1 || y > height) { - throw NotFoundException.getNotFoundInstance(); - } - nudged = false; - if (x == -1) { - points[offset] = 0.0f; - nudged = true; - } else if (x == width) { - points[offset] = width - 1; - nudged = true; - } - if (y == -1) { - points[offset + 1] = 0.0f; - nudged = true; - } else if (y == height) { - points[offset + 1] = height - 1; - nudged = true; - } - } - // Check and nudge points from end: - nudged = true; - for (int offset = points.length - 2; offset >= 0 && nudged; offset -= 2) { - int x = (int) points[offset]; - int y = (int) points[offset + 1]; - if (x < -1 || x > width || y < -1 || y > height) { - throw NotFoundException.getNotFoundInstance(); - } - nudged = false; - if (x == -1) { - points[offset] = 0.0f; - nudged = true; - } else if (x == width) { - points[offset] = width - 1; - nudged = true; - } - if (y == -1) { - points[offset + 1] = 0.0f; - nudged = true; - } else if (y == height) { - points[offset + 1] = height - 1; - nudged = true; - } - } - } - -} diff --git a/port_src/core/DONE/common/HybridBinarizer.java b/port_src/core/DONE/common/HybridBinarizer.java deleted file mode 100644 index 0fbae89..0000000 --- a/port_src/core/DONE/common/HybridBinarizer.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import com.google.zxing.Binarizer; -import com.google.zxing.LuminanceSource; -import com.google.zxing.NotFoundException; - -/** - * This class implements a local thresholding algorithm, which while slower than the - * GlobalHistogramBinarizer, is fairly efficient for what it does. It is designed for - * high frequency images of barcodes with black data on white backgrounds. For this application, - * it does a much better job than a global blackpoint with severe shadows and gradients. - * However it tends to produce artifacts on lower frequency images and is therefore not - * a good general purpose binarizer for uses outside ZXing. - * - * This class extends GlobalHistogramBinarizer, using the older histogram approach for 1D readers, - * and the newer local approach for 2D readers. 1D decoding using a per-row histogram is already - * inherently local, and only fails for horizontal gradients. We can revisit that problem later, - * but for now it was not a win to use local blocks for 1D. - * - * This Binarizer is the default for the unit tests and the recommended class for library users. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class HybridBinarizer extends GlobalHistogramBinarizer { - - // This class uses 5x5 blocks to compute local luminance, where each block is 8x8 pixels. - // So this is the smallest dimension in each axis we can accept. - private static final int BLOCK_SIZE_POWER = 3; - private static final int BLOCK_SIZE = 1 << BLOCK_SIZE_POWER; // ...0100...00 - private static final int BLOCK_SIZE_MASK = BLOCK_SIZE - 1; // ...0011...11 - private static final int MINIMUM_DIMENSION = BLOCK_SIZE * 5; - private static final int MIN_DYNAMIC_RANGE = 24; - - private BitMatrix matrix; - - public HybridBinarizer(LuminanceSource source) { - super(source); - } - - /** - * Calculates the final BitMatrix once for all requests. This could be called once from the - * constructor instead, but there are some advantages to doing it lazily, such as making - * profiling easier, and not doing heavy lifting when callers don't expect it. - */ - @Override - public BitMatrix getBlackMatrix() throws NotFoundException { - if (matrix != null) { - return matrix; - } - LuminanceSource source = getLuminanceSource(); - int width = source.getWidth(); - int height = source.getHeight(); - if (width >= MINIMUM_DIMENSION && height >= MINIMUM_DIMENSION) { - byte[] luminances = source.getMatrix(); - int subWidth = width >> BLOCK_SIZE_POWER; - if ((width & BLOCK_SIZE_MASK) != 0) { - subWidth++; - } - int subHeight = height >> BLOCK_SIZE_POWER; - if ((height & BLOCK_SIZE_MASK) != 0) { - subHeight++; - } - int[][] blackPoints = calculateBlackPoints(luminances, subWidth, subHeight, width, height); - - BitMatrix newMatrix = new BitMatrix(width, height); - calculateThresholdForBlock(luminances, subWidth, subHeight, width, height, blackPoints, newMatrix); - matrix = newMatrix; - } else { - // If the image is too small, fall back to the global histogram approach. - matrix = super.getBlackMatrix(); - } - return matrix; - } - - @Override - public Binarizer createBinarizer(LuminanceSource source) { - return new HybridBinarizer(source); - } - - /** - * For each block in the image, calculate the average black point using a 5x5 grid - * of the blocks around it. Also handles the corner cases (fractional blocks are computed based - * on the last pixels in the row/column which are also used in the previous block). - */ - private static void calculateThresholdForBlock(byte[] luminances, - int subWidth, - int subHeight, - int width, - int height, - int[][] blackPoints, - BitMatrix matrix) { - int maxYOffset = height - BLOCK_SIZE; - int maxXOffset = width - BLOCK_SIZE; - for (int y = 0; y < subHeight; y++) { - int yoffset = y << BLOCK_SIZE_POWER; - if (yoffset > maxYOffset) { - yoffset = maxYOffset; - } - int top = cap(y, subHeight - 3); - for (int x = 0; x < subWidth; x++) { - int xoffset = x << BLOCK_SIZE_POWER; - if (xoffset > maxXOffset) { - xoffset = maxXOffset; - } - int left = cap(x, subWidth - 3); - int sum = 0; - for (int z = -2; z <= 2; z++) { - int[] blackRow = blackPoints[top + z]; - sum += blackRow[left - 2] + blackRow[left - 1] + blackRow[left] + blackRow[left + 1] + blackRow[left + 2]; - } - int average = sum / 25; - thresholdBlock(luminances, xoffset, yoffset, average, width, matrix); - } - } - } - - private static int cap(int value, int max) { - return value < 2 ? 2 : Math.min(value, max); - } - - /** - * Applies a single threshold to a block of pixels. - */ - private static void thresholdBlock(byte[] luminances, - int xoffset, - int yoffset, - int threshold, - int stride, - BitMatrix matrix) { - for (int y = 0, offset = yoffset * stride + xoffset; y < BLOCK_SIZE; y++, offset += stride) { - for (int x = 0; x < BLOCK_SIZE; x++) { - // Comparison needs to be <= so that black == 0 pixels are black even if the threshold is 0. - if ((luminances[offset + x] & 0xFF) <= threshold) { - matrix.set(xoffset + x, yoffset + y); - } - } - } - } - - /** - * Calculates a single black point for each block of pixels and saves it away. - * See the following thread for a discussion of this algorithm: - * http://groups.google.com/group/zxing/browse_thread/thread/d06efa2c35a7ddc0 - */ - private static int[][] calculateBlackPoints(byte[] luminances, - int subWidth, - int subHeight, - int width, - int height) { - int maxYOffset = height - BLOCK_SIZE; - int maxXOffset = width - BLOCK_SIZE; - int[][] blackPoints = new int[subHeight][subWidth]; - for (int y = 0; y < subHeight; y++) { - int yoffset = y << BLOCK_SIZE_POWER; - if (yoffset > maxYOffset) { - yoffset = maxYOffset; - } - for (int x = 0; x < subWidth; x++) { - int xoffset = x << BLOCK_SIZE_POWER; - if (xoffset > maxXOffset) { - xoffset = maxXOffset; - } - int sum = 0; - int min = 0xFF; - int max = 0; - for (int yy = 0, offset = yoffset * width + xoffset; yy < BLOCK_SIZE; yy++, offset += width) { - for (int xx = 0; xx < BLOCK_SIZE; xx++) { - int pixel = luminances[offset + xx] & 0xFF; - sum += pixel; - // still looking for good contrast - if (pixel < min) { - min = pixel; - } - if (pixel > max) { - max = pixel; - } - } - // short-circuit min/max tests once dynamic range is met - if (max - min > MIN_DYNAMIC_RANGE) { - // finish the rest of the rows quickly - for (yy++, offset += width; yy < BLOCK_SIZE; yy++, offset += width) { - for (int xx = 0; xx < BLOCK_SIZE; xx++) { - sum += luminances[offset + xx] & 0xFF; - } - } - } - } - - // The default estimate is the average of the values in the block. - int average = sum >> (BLOCK_SIZE_POWER * 2); - if (max - min <= MIN_DYNAMIC_RANGE) { - // If variation within the block is low, assume this is a block with only light or only - // dark pixels. In that case we do not want to use the average, as it would divide this - // low contrast area into black and white pixels, essentially creating data out of noise. - // - // The default assumption is that the block is light/background. Since no estimate for - // the level of dark pixels exists locally, use half the min for the block. - average = min / 2; - - if (y > 0 && x > 0) { - // Correct the "white background" assumption for blocks that have neighbors by comparing - // the pixels in this block to the previously calculated black points. This is based on - // the fact that dark barcode symbology is always surrounded by some amount of light - // background for which reasonable black point estimates were made. The bp estimated at - // the boundaries is used for the interior. - - // The (min < bp) is arbitrary but works better than other heuristics that were tried. - int averageNeighborBlackPoint = - (blackPoints[y - 1][x] + (2 * blackPoints[y][x - 1]) + blackPoints[y - 1][x - 1]) / 4; - if (min < averageNeighborBlackPoint) { - average = averageNeighborBlackPoint; - } - } - } - blackPoints[y][x] = average; - } - } - return blackPoints; - } - -} diff --git a/port_src/core/DONE/common/MinimalECIInput.java b/port_src/core/DONE/common/MinimalECIInput.java deleted file mode 100644 index 5955c0b..0000000 --- a/port_src/core/DONE/common/MinimalECIInput.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright 2021 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; - -/** - * Class that converts a character string into a sequence of ECIs and bytes - * - * The implementation uses the Dijkstra algorithm to produce minimal encodings - * - * @author Alex Geller - */ -public class MinimalECIInput implements ECIInput { - - private static final int COST_PER_ECI = 3; // approximated (latch + 2 codewords) - private final int[] bytes; - private final int fnc1; - - /** - * Constructs a minimal input - * - * @param stringToEncode the character string to encode - * @param priorityCharset The preferred {@link Charset}. When the value of the argument is null, the algorithm - * chooses charsets that leads to a minimal representation. Otherwise the algorithm will use the priority - * charset to encode any character in the input that can be encoded by it if the charset is among the - * supported charsets. - * @param fnc1 denotes the character in the input that represents the FNC1 character or -1 if this is not GS1 - * input. - */ - public MinimalECIInput(String stringToEncode, Charset priorityCharset, int fnc1) { - this.fnc1 = fnc1; - ECIEncoderSet encoderSet = new ECIEncoderSet(stringToEncode, priorityCharset, fnc1); - if (encoderSet.length() == 1) { //optimization for the case when all can be encoded without ECI in ISO-8859-1 - bytes = new int[stringToEncode.length()]; - for (int i = 0; i < bytes.length; i++) { - char c = stringToEncode.charAt(i); - bytes[i] = c == fnc1 ? 1000 : (int) c; - } - } else { - bytes = encodeMinimally(stringToEncode, encoderSet, fnc1); - } - } - - public int getFNC1Character() { - return fnc1; - } - - /** - * Returns the length of this input. The length is the number - * of {@code byte}s, FNC1 characters or ECIs in the sequence. - * - * @return the number of {@code char}s in this sequence - */ - public int length() { - return bytes.length; - } - - public boolean haveNCharacters(int index, int n) { - if (index + n - 1 >= bytes.length) { - return false; - } - for (int i = 0; i < n; i++) { - if (isECI(index + i)) { - return false; - } - } - return true; - } - - /** - * Returns the {@code byte} value at the specified index. An index ranges from zero - * to {@code length() - 1}. The first {@code byte} value of the sequence is at - * index zero, the next at index one, and so on, as for array - * indexing. - * - * @param index the index of the {@code byte} value to be returned - * - * @return the specified {@code byte} value as character or the FNC1 character - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - * @throws IllegalArgumentException - * if the value at the {@code index} argument is an ECI (@see #isECI) - */ - public char charAt(int index) { - if (index < 0 || index >= length()) { - throw new IndexOutOfBoundsException("" + index); - } - if (isECI(index)) { - throw new IllegalArgumentException("value at " + index + " is not a character but an ECI"); - } - return isFNC1(index) ? (char) fnc1 : (char) bytes[index]; - } - - /** - * Returns a {@code CharSequence} that is a subsequence of this sequence. - * The subsequence starts with the {@code char} value at the specified index and - * ends with the {@code char} value at index {@code end - 1}. The length - * (in {@code char}s) of the - * returned sequence is {@code end - start}, so if {@code start == end} - * then an empty sequence is returned. - * - * @param start the start index, inclusive - * @param end the end index, exclusive - * - * @return the specified subsequence - * - * @throws IndexOutOfBoundsException - * if {@code start} or {@code end} are negative, - * if {@code end} is greater than {@code length()}, - * or if {@code start} is greater than {@code end} - * @throws IllegalArgumentException - * if a value in the range {@code start}-{@code end} is an ECI (@see #isECI) - */ - public CharSequence subSequence(int start, int end) { - if (start < 0 || start > end || end > length()) { - throw new IndexOutOfBoundsException("" + start); - } - StringBuilder result = new StringBuilder(); - for (int i = start; i < end; i++) { - if (isECI(i)) { - throw new IllegalArgumentException("value at " + i + " is not a character but an ECI"); - } - result.append(charAt(i)); - } - return result; - } - - /** - * Determines if a value is an ECI - * - * @param index the index of the value - * - * @return true if the value at position {@code index} is an ECI - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - */ - public boolean isECI(int index) { - if (index < 0 || index >= length()) { - throw new IndexOutOfBoundsException("" + index); - } - return bytes[index] > 255 && bytes[index] <= 999; - } - - /** - * Determines if a value is the FNC1 character - * - * @param index the index of the value - * - * @return true if the value at position {@code index} is the FNC1 character - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - */ - public boolean isFNC1(int index) { - if (index < 0 || index >= length()) { - throw new IndexOutOfBoundsException("" + index); - } - return bytes[index] == 1000; - } - - /** - * Returns the {@code int} ECI value at the specified index. An index ranges from zero - * to {@code length() - 1}. The first {@code byte} value of the sequence is at - * index zero, the next at index one, and so on, as for array - * indexing. - * - * @param index the index of the {@code int} value to be returned - * - * @return the specified {@code int} ECI value. - * The ECI specified the encoding of all bytes with a higher index until the - * next ECI or until the end of the input if no other ECI follows. - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - * @throws IllegalArgumentException - * if the value at the {@code index} argument is not an ECI (@see #isECI) - */ - public int getECIValue(int index) { - if (index < 0 || index >= length()) { - throw new IndexOutOfBoundsException("" + index); - } - if (!isECI(index)) { - throw new IllegalArgumentException("value at " + index + " is not an ECI but a character"); - } - return bytes[index] - 256; - } - - @Override - public String toString() { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < length(); i++) { - if (i > 0) { - result.append(", "); - } - if (isECI(i)) { - result.append("ECI("); - result.append(getECIValue(i)); - result.append(')'); - } else if (charAt(i) < 128) { - result.append('\''); - result.append(charAt(i)); - result.append('\''); - } else { - result.append((int) charAt(i)); - } - } - return result.toString(); - } - static void addEdge(InputEdge[][] edges, int to, InputEdge edge) { - if (edges[to][edge.encoderIndex] == null || - edges[to][edge.encoderIndex].cachedTotalSize > edge.cachedTotalSize) { - edges[to][edge.encoderIndex] = edge; - } - } - - static void addEdges(String stringToEncode, - ECIEncoderSet encoderSet, - InputEdge[][] edges, - int from, - InputEdge previous, - int fnc1) { - - char ch = stringToEncode.charAt(from); - - int start = 0; - int end = encoderSet.length(); - if (encoderSet.getPriorityEncoderIndex() >= 0 && (ch == fnc1 || encoderSet.canEncode(ch, - encoderSet.getPriorityEncoderIndex()))) { - start = encoderSet.getPriorityEncoderIndex(); - end = start + 1; - } - - for (int i = start; i < end; i++) { - if (ch == fnc1 || encoderSet.canEncode(ch,i)) { - addEdge(edges, from + 1, new InputEdge(ch, encoderSet, i, previous, fnc1)); - } - } - } - - static int[] encodeMinimally(String stringToEncode, ECIEncoderSet encoderSet, int fnc1) { - int inputLength = stringToEncode.length(); - - // Array that represents vertices. There is a vertex for every character and encoding. - InputEdge[][] edges = new InputEdge[inputLength + 1][encoderSet.length()]; - addEdges(stringToEncode, encoderSet, edges, 0, null, fnc1); - - for (int i = 1; i <= inputLength; i++) { - for (int j = 0; j < encoderSet.length(); j++) { - if (edges[i][j] != null && i < inputLength) { - addEdges(stringToEncode, encoderSet, edges, i, edges[i][j], fnc1); - } - } - //optimize memory by removing edges that have been passed. - for (int j = 0; j < encoderSet.length(); j++) { - edges[i - 1][j] = null; - } - } - int minimalJ = -1; - int minimalSize = Integer.MAX_VALUE; - for (int j = 0; j < encoderSet.length(); j++) { - if (edges[inputLength][j] != null) { - InputEdge edge = edges[inputLength][j]; - if (edge.cachedTotalSize < minimalSize) { - minimalSize = edge.cachedTotalSize; - minimalJ = j; - } - } - } - if (minimalJ < 0) { - throw new RuntimeException("Internal error: failed to encode \"" + stringToEncode + "\""); - } - List intsAL = new ArrayList<>(); - InputEdge current = edges[inputLength][minimalJ]; - while (current != null) { - if (current.isFNC1()) { - intsAL.add(0, 1000); - } else { - byte[] bytes = encoderSet.encode(current.c,current.encoderIndex); - for (int i = bytes.length - 1; i >= 0; i--) { - intsAL.add(0, (bytes[i] & 0xFF)); - } - } - int previousEncoderIndex = current.previous == null ? 0 : current.previous.encoderIndex; - if (previousEncoderIndex != current.encoderIndex) { - intsAL.add(0,256 + encoderSet.getECIValue(current.encoderIndex)); - } - current = current.previous; - } - int[] ints = new int[intsAL.size()]; - for (int i = 0; i < ints.length; i++) { - ints[i] = intsAL.get(i); - } - return ints; - } - - private static final class InputEdge { - private final char c; - private final int encoderIndex; //the encoding of this edge - private final InputEdge previous; - private final int cachedTotalSize; - - private InputEdge(char c, ECIEncoderSet encoderSet, int encoderIndex, InputEdge previous, int fnc1) { - this.c = c == fnc1 ? 1000 : c; - this.encoderIndex = encoderIndex; - this.previous = previous; - - int size = this.c == 1000 ? 1 : encoderSet.encode(c, encoderIndex).length; - int previousEncoderIndex = previous == null ? 0 : previous.encoderIndex; - if (previousEncoderIndex != encoderIndex) { - size += COST_PER_ECI; - } - if (previous != null) { - size += previous.cachedTotalSize; - } - this.cachedTotalSize = size; - } - - boolean isFNC1() { - return c == 1000; - } - - } -} diff --git a/port_src/core/DONE/common/PerspectiveTransform.java b/port_src/core/DONE/common/PerspectiveTransform.java deleted file mode 100644 index 06dba94..0000000 --- a/port_src/core/DONE/common/PerspectiveTransform.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -/** - *

This class implements a perspective transform in two dimensions. Given four source and four - * destination points, it will compute the transformation implied between them. The code is based - * directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.

- * - * @author Sean Owen - */ -public final class PerspectiveTransform { - - private final float a11; - private final float a12; - private final float a13; - private final float a21; - private final float a22; - private final float a23; - private final float a31; - private final float a32; - private final float a33; - - private PerspectiveTransform(float a11, float a21, float a31, - float a12, float a22, float a32, - float a13, float a23, float a33) { - this.a11 = a11; - this.a12 = a12; - this.a13 = a13; - this.a21 = a21; - this.a22 = a22; - this.a23 = a23; - this.a31 = a31; - this.a32 = a32; - this.a33 = a33; - } - - public static PerspectiveTransform quadrilateralToQuadrilateral(float x0, float y0, - float x1, float y1, - float x2, float y2, - float x3, float y3, - float x0p, float y0p, - float x1p, float y1p, - float x2p, float y2p, - float x3p, float y3p) { - - PerspectiveTransform qToS = quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3); - PerspectiveTransform sToQ = squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p); - return sToQ.times(qToS); - } - - public void transformPoints(float[] points) { - float a11 = this.a11; - float a12 = this.a12; - float a13 = this.a13; - float a21 = this.a21; - float a22 = this.a22; - float a23 = this.a23; - float a31 = this.a31; - float a32 = this.a32; - float a33 = this.a33; - int maxI = points.length - 1; // points.length must be even - for (int i = 0; i < maxI; i += 2) { - float x = points[i]; - float y = points[i + 1]; - float denominator = a13 * x + a23 * y + a33; - points[i] = (a11 * x + a21 * y + a31) / denominator; - points[i + 1] = (a12 * x + a22 * y + a32) / denominator; - } - } - - public void transformPoints(float[] xValues, float[] yValues) { - int n = xValues.length; - for (int i = 0; i < n; i++) { - float x = xValues[i]; - float y = yValues[i]; - float denominator = a13 * x + a23 * y + a33; - xValues[i] = (a11 * x + a21 * y + a31) / denominator; - yValues[i] = (a12 * x + a22 * y + a32) / denominator; - } - } - - public static PerspectiveTransform squareToQuadrilateral(float x0, float y0, - float x1, float y1, - float x2, float y2, - float x3, float y3) { - float dx3 = x0 - x1 + x2 - x3; - float dy3 = y0 - y1 + y2 - y3; - if (dx3 == 0.0f && dy3 == 0.0f) { - // Affine - return new PerspectiveTransform(x1 - x0, x2 - x1, x0, - y1 - y0, y2 - y1, y0, - 0.0f, 0.0f, 1.0f); - } else { - float dx1 = x1 - x2; - float dx2 = x3 - x2; - float dy1 = y1 - y2; - float dy2 = y3 - y2; - float denominator = dx1 * dy2 - dx2 * dy1; - float a13 = (dx3 * dy2 - dx2 * dy3) / denominator; - float a23 = (dx1 * dy3 - dx3 * dy1) / denominator; - return new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, - y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, - a13, a23, 1.0f); - } - } - - public static PerspectiveTransform quadrilateralToSquare(float x0, float y0, - float x1, float y1, - float x2, float y2, - float x3, float y3) { - // Here, the adjoint serves as the inverse: - return squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).buildAdjoint(); - } - - PerspectiveTransform buildAdjoint() { - // Adjoint is the transpose of the cofactor matrix: - return new PerspectiveTransform(a22 * a33 - a23 * a32, - a23 * a31 - a21 * a33, - a21 * a32 - a22 * a31, - a13 * a32 - a12 * a33, - a11 * a33 - a13 * a31, - a12 * a31 - a11 * a32, - a12 * a23 - a13 * a22, - a13 * a21 - a11 * a23, - a11 * a22 - a12 * a21); - } - - PerspectiveTransform times(PerspectiveTransform other) { - return new PerspectiveTransform(a11 * other.a11 + a21 * other.a12 + a31 * other.a13, - a11 * other.a21 + a21 * other.a22 + a31 * other.a23, - a11 * other.a31 + a21 * other.a32 + a31 * other.a33, - a12 * other.a11 + a22 * other.a12 + a32 * other.a13, - a12 * other.a21 + a22 * other.a22 + a32 * other.a23, - a12 * other.a31 + a22 * other.a32 + a32 * other.a33, - a13 * other.a11 + a23 * other.a12 + a33 * other.a13, - a13 * other.a21 + a23 * other.a22 + a33 * other.a23, - a13 * other.a31 + a23 * other.a32 + a33 * other.a33); - - } - -} diff --git a/port_src/core/DONE/common/StringUtils.java b/port_src/core/DONE/common/StringUtils.java deleted file mode 100644 index d855e56..0000000 --- a/port_src/core/DONE/common/StringUtils.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.Map; - -import com.google.zxing.DecodeHintType; - -/** - * Common string-related functions. - * - * @author Sean Owen - * @author Alex Dupre - */ -public final class StringUtils { - - private static final Charset PLATFORM_DEFAULT_ENCODING = Charset.defaultCharset(); - public static final Charset SHIFT_JIS_CHARSET = Charset.forName("SJIS"); - public static final Charset GB2312_CHARSET = Charset.forName("GB2312"); - private static final Charset EUC_JP = Charset.forName("EUC_JP"); - private static final boolean ASSUME_SHIFT_JIS = - SHIFT_JIS_CHARSET.equals(PLATFORM_DEFAULT_ENCODING) || - EUC_JP.equals(PLATFORM_DEFAULT_ENCODING); - - // Retained for ABI compatibility with earlier versions - public static final String SHIFT_JIS = "SJIS"; - public static final String GB2312 = "GB2312"; - - private StringUtils() { } - - /** - * @param bytes bytes encoding a string, whose encoding should be guessed - * @param hints decode hints if applicable - * @return name of guessed encoding; at the moment will only guess one of: - * "SJIS", "UTF8", "ISO8859_1", or the platform default encoding if none - * of these can possibly be correct - */ - public static String guessEncoding(byte[] bytes, Map hints) { - Charset c = guessCharset(bytes, hints); - if (c == SHIFT_JIS_CHARSET) { - return "SJIS"; - } else if (c == StandardCharsets.UTF_8) { - return "UTF8"; - } else if (c == StandardCharsets.ISO_8859_1) { - return "ISO8859_1"; - } - return c.name(); - } - - /** - * @param bytes bytes encoding a string, whose encoding should be guessed - * @param hints decode hints if applicable - * @return Charset of guessed encoding; at the moment will only guess one of: - * {@link #SHIFT_JIS_CHARSET}, {@link StandardCharsets#UTF_8}, - * {@link StandardCharsets#ISO_8859_1}, {@link StandardCharsets#UTF_16}, - * or the platform default encoding if - * none of these can possibly be correct - */ - public static Charset guessCharset(byte[] bytes, Map hints) { - if (hints != null && hints.containsKey(DecodeHintType.CHARACTER_SET)) { - return Charset.forName(hints.get(DecodeHintType.CHARACTER_SET).toString()); - } - - // First try UTF-16, assuming anything with its BOM is UTF-16 - if (bytes.length > 2 && - ((bytes[0] == (byte) 0xFE && bytes[1] == (byte) 0xFF) || - (bytes[0] == (byte) 0xFF && bytes[1] == (byte) 0xFE))) { - return StandardCharsets.UTF_16; - } - - // For now, merely tries to distinguish ISO-8859-1, UTF-8 and Shift_JIS, - // which should be by far the most common encodings. - int length = bytes.length; - boolean canBeISO88591 = true; - boolean canBeShiftJIS = true; - boolean canBeUTF8 = true; - int utf8BytesLeft = 0; - int utf2BytesChars = 0; - int utf3BytesChars = 0; - int utf4BytesChars = 0; - int sjisBytesLeft = 0; - int sjisKatakanaChars = 0; - int sjisCurKatakanaWordLength = 0; - int sjisCurDoubleBytesWordLength = 0; - int sjisMaxKatakanaWordLength = 0; - int sjisMaxDoubleBytesWordLength = 0; - int isoHighOther = 0; - - boolean utf8bom = bytes.length > 3 && - bytes[0] == (byte) 0xEF && - bytes[1] == (byte) 0xBB && - bytes[2] == (byte) 0xBF; - - for (int i = 0; - i < length && (canBeISO88591 || canBeShiftJIS || canBeUTF8); - i++) { - - int value = bytes[i] & 0xFF; - - // UTF-8 stuff - if (canBeUTF8) { - if (utf8BytesLeft > 0) { - if ((value & 0x80) == 0) { - canBeUTF8 = false; - } else { - utf8BytesLeft--; - } - } else if ((value & 0x80) != 0) { - if ((value & 0x40) == 0) { - canBeUTF8 = false; - } else { - utf8BytesLeft++; - if ((value & 0x20) == 0) { - utf2BytesChars++; - } else { - utf8BytesLeft++; - if ((value & 0x10) == 0) { - utf3BytesChars++; - } else { - utf8BytesLeft++; - if ((value & 0x08) == 0) { - utf4BytesChars++; - } else { - canBeUTF8 = false; - } - } - } - } - } - } - - // ISO-8859-1 stuff - if (canBeISO88591) { - if (value > 0x7F && value < 0xA0) { - canBeISO88591 = false; - } else if (value > 0x9F && (value < 0xC0 || value == 0xD7 || value == 0xF7)) { - isoHighOther++; - } - } - - // Shift_JIS stuff - if (canBeShiftJIS) { - if (sjisBytesLeft > 0) { - if (value < 0x40 || value == 0x7F || value > 0xFC) { - canBeShiftJIS = false; - } else { - sjisBytesLeft--; - } - } else if (value == 0x80 || value == 0xA0 || value > 0xEF) { - canBeShiftJIS = false; - } else if (value > 0xA0 && value < 0xE0) { - sjisKatakanaChars++; - sjisCurDoubleBytesWordLength = 0; - sjisCurKatakanaWordLength++; - if (sjisCurKatakanaWordLength > sjisMaxKatakanaWordLength) { - sjisMaxKatakanaWordLength = sjisCurKatakanaWordLength; - } - } else if (value > 0x7F) { - sjisBytesLeft++; - //sjisDoubleBytesChars++; - sjisCurKatakanaWordLength = 0; - sjisCurDoubleBytesWordLength++; - if (sjisCurDoubleBytesWordLength > sjisMaxDoubleBytesWordLength) { - sjisMaxDoubleBytesWordLength = sjisCurDoubleBytesWordLength; - } - } else { - //sjisLowChars++; - sjisCurKatakanaWordLength = 0; - sjisCurDoubleBytesWordLength = 0; - } - } - } - - if (canBeUTF8 && utf8BytesLeft > 0) { - canBeUTF8 = false; - } - if (canBeShiftJIS && sjisBytesLeft > 0) { - canBeShiftJIS = false; - } - - // Easy -- if there is BOM or at least 1 valid not-single byte character (and no evidence it can't be UTF-8), done - if (canBeUTF8 && (utf8bom || utf2BytesChars + utf3BytesChars + utf4BytesChars > 0)) { - return StandardCharsets.UTF_8; - } - // Easy -- if assuming Shift_JIS or >= 3 valid consecutive not-ascii characters (and no evidence it can't be), done - if (canBeShiftJIS && (ASSUME_SHIFT_JIS || sjisMaxKatakanaWordLength >= 3 || sjisMaxDoubleBytesWordLength >= 3)) { - return SHIFT_JIS_CHARSET; - } - // Distinguishing Shift_JIS and ISO-8859-1 can be a little tough for short words. The crude heuristic is: - // - If we saw - // - only two consecutive katakana chars in the whole text, or - // - at least 10% of bytes that could be "upper" not-alphanumeric Latin1, - // - then we conclude Shift_JIS, else ISO-8859-1 - if (canBeISO88591 && canBeShiftJIS) { - return (sjisMaxKatakanaWordLength == 2 && sjisKatakanaChars == 2) || isoHighOther * 10 >= length - ? SHIFT_JIS_CHARSET : StandardCharsets.ISO_8859_1; - } - - // Otherwise, try in order ISO-8859-1, Shift JIS, UTF-8 and fall back to default platform encoding - if (canBeISO88591) { - return StandardCharsets.ISO_8859_1; - } - if (canBeShiftJIS) { - return SHIFT_JIS_CHARSET; - } - if (canBeUTF8) { - return StandardCharsets.UTF_8; - } - // Otherwise, we take a wild guess with platform encoding - return PLATFORM_DEFAULT_ENCODING; - } - -} diff --git a/port_src/core/DONE/common/detector/MathUtils.java b/port_src/core/DONE/common/detector/MathUtils.java deleted file mode 100644 index bd5931b..0000000 --- a/port_src/core/DONE/common/detector/MathUtils.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common.detector; - -/** - * General math-related and numeric utility functions. - */ -public final class MathUtils { - - private MathUtils() { - } - - /** - * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its - * argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut - * differ slightly from {@link Math#round(float)} in that half rounds down for negative - * values. -2.5 rounds to -3, not -2. For purposes here it makes no difference. - * - * @param d real value to round - * @return nearest {@code int} - */ - public static int round(float d) { - return (int) (d + (d < 0.0f ? -0.5f : 0.5f)); - } - - /** - * @param aX point A x coordinate - * @param aY point A y coordinate - * @param bX point B x coordinate - * @param bY point B y coordinate - * @return Euclidean distance between points A and B - */ - public static float distance(float aX, float aY, float bX, float bY) { - double xDiff = aX - bX; - double yDiff = aY - bY; - return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff); - } - - /** - * @param aX point A x coordinate - * @param aY point A y coordinate - * @param bX point B x coordinate - * @param bY point B y coordinate - * @return Euclidean distance between points A and B - */ - public static float distance(int aX, int aY, int bX, int bY) { - double xDiff = aX - bX; - double yDiff = aY - bY; - return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff); - } - - /** - * @param array values to sum - * @return sum of values in array - */ - public static int sum(int[] array) { - int count = 0; - for (int a : array) { - count += a; - } - return count; - } - -} diff --git a/port_src/core/DONE/common/detector/MonochromeRectangleDetector.java b/port_src/core/DONE/common/detector/MonochromeRectangleDetector.java deleted file mode 100644 index e87fa55..0000000 --- a/port_src/core/DONE/common/detector/MonochromeRectangleDetector.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common.detector; - -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; - -/** - *

A somewhat generic detector that looks for a barcode-like rectangular region within an image. - * It looks within a mostly white region of an image for a region of black and white, but mostly - * black. It returns the four corners of the region, as best it can determine.

- * - * @author Sean Owen - * @deprecated without replacement since 3.3.0 - */ -@Deprecated -public final class MonochromeRectangleDetector { - - private static final int MAX_MODULES = 32; - - private final BitMatrix image; - - public MonochromeRectangleDetector(BitMatrix image) { - this.image = image; - } - - /** - *

Detects a rectangular region of black and white -- mostly black -- with a region of mostly - * white, in an image.

- * - * @return {@link ResultPoint}[] describing the corners of the rectangular region. The first and - * last points are opposed on the diagonal, as are the second and third. The first point will be - * the topmost point and the last, the bottommost. The second point will be leftmost and the - * third, the rightmost - * @throws NotFoundException if no Data Matrix Code can be found - */ - public ResultPoint[] detect() throws NotFoundException { - int height = image.getHeight(); - int width = image.getWidth(); - int halfHeight = height / 2; - int halfWidth = width / 2; - int deltaY = Math.max(1, height / (MAX_MODULES * 8)); - int deltaX = Math.max(1, width / (MAX_MODULES * 8)); - - int top = 0; - int bottom = height; - int left = 0; - int right = width; - ResultPoint pointA = findCornerFromCenter(halfWidth, 0, left, right, - halfHeight, -deltaY, top, bottom, halfWidth / 2); - top = (int) pointA.getY() - 1; - ResultPoint pointB = findCornerFromCenter(halfWidth, -deltaX, left, right, - halfHeight, 0, top, bottom, halfHeight / 2); - left = (int) pointB.getX() - 1; - ResultPoint pointC = findCornerFromCenter(halfWidth, deltaX, left, right, - halfHeight, 0, top, bottom, halfHeight / 2); - right = (int) pointC.getX() + 1; - ResultPoint pointD = findCornerFromCenter(halfWidth, 0, left, right, - halfHeight, deltaY, top, bottom, halfWidth / 2); - bottom = (int) pointD.getY() + 1; - - // Go try to find point A again with better information -- might have been off at first. - pointA = findCornerFromCenter(halfWidth, 0, left, right, - halfHeight, -deltaY, top, bottom, halfWidth / 4); - - return new ResultPoint[] { pointA, pointB, pointC, pointD }; - } - - /** - * Attempts to locate a corner of the barcode by scanning up, down, left or right from a center - * point which should be within the barcode. - * - * @param centerX center's x component (horizontal) - * @param deltaX same as deltaY but change in x per step instead - * @param left minimum value of x - * @param right maximum value of x - * @param centerY center's y component (vertical) - * @param deltaY change in y per step. If scanning up this is negative; down, positive; - * left or right, 0 - * @param top minimum value of y to search through (meaningless when di == 0) - * @param bottom maximum value of y - * @param maxWhiteRun maximum run of white pixels that can still be considered to be within - * the barcode - * @return a {@link ResultPoint} encapsulating the corner that was found - * @throws NotFoundException if such a point cannot be found - */ - private ResultPoint findCornerFromCenter(int centerX, - int deltaX, - int left, - int right, - int centerY, - int deltaY, - int top, - int bottom, - int maxWhiteRun) throws NotFoundException { - int[] lastRange = null; - for (int y = centerY, x = centerX; - y < bottom && y >= top && x < right && x >= left; - y += deltaY, x += deltaX) { - int[] range; - if (deltaX == 0) { - // horizontal slices, up and down - range = blackWhiteRange(y, maxWhiteRun, left, right, true); - } else { - // vertical slices, left and right - range = blackWhiteRange(x, maxWhiteRun, top, bottom, false); - } - if (range == null) { - if (lastRange == null) { - throw NotFoundException.getNotFoundInstance(); - } - // lastRange was found - if (deltaX == 0) { - int lastY = y - deltaY; - if (lastRange[0] < centerX) { - if (lastRange[1] > centerX) { - // straddle, choose one or the other based on direction - return new ResultPoint(lastRange[deltaY > 0 ? 0 : 1], lastY); - } - return new ResultPoint(lastRange[0], lastY); - } else { - return new ResultPoint(lastRange[1], lastY); - } - } else { - int lastX = x - deltaX; - if (lastRange[0] < centerY) { - if (lastRange[1] > centerY) { - return new ResultPoint(lastX, lastRange[deltaX < 0 ? 0 : 1]); - } - return new ResultPoint(lastX, lastRange[0]); - } else { - return new ResultPoint(lastX, lastRange[1]); - } - } - } - lastRange = range; - } - throw NotFoundException.getNotFoundInstance(); - } - - /** - * Computes the start and end of a region of pixels, either horizontally or vertically, that could - * be part of a Data Matrix barcode. - * - * @param fixedDimension if scanning horizontally, this is the row (the fixed vertical location) - * where we are scanning. If scanning vertically it's the column, the fixed horizontal location - * @param maxWhiteRun largest run of white pixels that can still be considered part of the - * barcode region - * @param minDim minimum pixel location, horizontally or vertically, to consider - * @param maxDim maximum pixel location, horizontally or vertically, to consider - * @param horizontal if true, we're scanning left-right, instead of up-down - * @return int[] with start and end of found range, or null if no such range is found - * (e.g. only white was found) - */ - private int[] blackWhiteRange(int fixedDimension, int maxWhiteRun, int minDim, int maxDim, boolean horizontal) { - - int center = (minDim + maxDim) / 2; - - // Scan left/up first - int start = center; - while (start >= minDim) { - if (horizontal ? image.get(start, fixedDimension) : image.get(fixedDimension, start)) { - start--; - } else { - int whiteRunStart = start; - do { - start--; - } while (start >= minDim && !(horizontal ? image.get(start, fixedDimension) : - image.get(fixedDimension, start))); - int whiteRunSize = whiteRunStart - start; - if (start < minDim || whiteRunSize > maxWhiteRun) { - start = whiteRunStart; - break; - } - } - } - start++; - - // Then try right/down - int end = center; - while (end < maxDim) { - if (horizontal ? image.get(end, fixedDimension) : image.get(fixedDimension, end)) { - end++; - } else { - int whiteRunStart = end; - do { - end++; - } while (end < maxDim && !(horizontal ? image.get(end, fixedDimension) : - image.get(fixedDimension, end))); - int whiteRunSize = end - whiteRunStart; - if (end >= maxDim || whiteRunSize > maxWhiteRun) { - end = whiteRunStart; - break; - } - } - } - end--; - - return end > start ? new int[]{start, end} : null; - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/common/detector/WhiteRectangleDetector.java b/port_src/core/DONE/common/detector/WhiteRectangleDetector.java deleted file mode 100644 index 8d77b0d..0000000 --- a/port_src/core/DONE/common/detector/WhiteRectangleDetector.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common.detector; - -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; - -/** - *

- * Detects a candidate barcode-like rectangular region within an image. It - * starts around the center of the image, increases the size of the candidate - * region until it finds a white rectangular region. By keeping track of the - * last black points it encountered, it determines the corners of the barcode. - *

- * - * @author David Olivier - */ -public final class WhiteRectangleDetector { - - private static final int INIT_SIZE = 10; - private static final int CORR = 1; - - private final BitMatrix image; - private final int height; - private final int width; - private final int leftInit; - private final int rightInit; - private final int downInit; - private final int upInit; - - public WhiteRectangleDetector(BitMatrix image) throws NotFoundException { - this(image, INIT_SIZE, image.getWidth() / 2, image.getHeight() / 2); - } - - /** - * @param image barcode image to find a rectangle in - * @param initSize initial size of search area around center - * @param x x position of search center - * @param y y position of search center - * @throws NotFoundException if image is too small to accommodate {@code initSize} - */ - public WhiteRectangleDetector(BitMatrix image, int initSize, int x, int y) throws NotFoundException { - this.image = image; - height = image.getHeight(); - width = image.getWidth(); - int halfsize = initSize / 2; - leftInit = x - halfsize; - rightInit = x + halfsize; - upInit = y - halfsize; - downInit = y + halfsize; - if (upInit < 0 || leftInit < 0 || downInit >= height || rightInit >= width) { - throw NotFoundException.getNotFoundInstance(); - } - } - - /** - *

- * Detects a candidate barcode-like rectangular region within an image. It - * starts around the center of the image, increases the size of the candidate - * region until it finds a white rectangular region. - *

- * - * @return {@link ResultPoint}[] describing the corners of the rectangular - * region. The first and last points are opposed on the diagonal, as - * are the second and third. The first point will be the topmost - * point and the last, the bottommost. The second point will be - * leftmost and the third, the rightmost - * @throws NotFoundException if no Data Matrix Code can be found - */ - public ResultPoint[] detect() throws NotFoundException { - - int left = leftInit; - int right = rightInit; - int up = upInit; - int down = downInit; - boolean sizeExceeded = false; - boolean aBlackPointFoundOnBorder = true; - - boolean atLeastOneBlackPointFoundOnRight = false; - boolean atLeastOneBlackPointFoundOnBottom = false; - boolean atLeastOneBlackPointFoundOnLeft = false; - boolean atLeastOneBlackPointFoundOnTop = false; - - while (aBlackPointFoundOnBorder) { - - aBlackPointFoundOnBorder = false; - - // ..... - // . | - // ..... - boolean rightBorderNotWhite = true; - while ((rightBorderNotWhite || !atLeastOneBlackPointFoundOnRight) && right < width) { - rightBorderNotWhite = containsBlackPoint(up, down, right, false); - if (rightBorderNotWhite) { - right++; - aBlackPointFoundOnBorder = true; - atLeastOneBlackPointFoundOnRight = true; - } else if (!atLeastOneBlackPointFoundOnRight) { - right++; - } - } - - if (right >= width) { - sizeExceeded = true; - break; - } - - // ..... - // . . - // .___. - boolean bottomBorderNotWhite = true; - while ((bottomBorderNotWhite || !atLeastOneBlackPointFoundOnBottom) && down < height) { - bottomBorderNotWhite = containsBlackPoint(left, right, down, true); - if (bottomBorderNotWhite) { - down++; - aBlackPointFoundOnBorder = true; - atLeastOneBlackPointFoundOnBottom = true; - } else if (!atLeastOneBlackPointFoundOnBottom) { - down++; - } - } - - if (down >= height) { - sizeExceeded = true; - break; - } - - // ..... - // | . - // ..... - boolean leftBorderNotWhite = true; - while ((leftBorderNotWhite || !atLeastOneBlackPointFoundOnLeft) && left >= 0) { - leftBorderNotWhite = containsBlackPoint(up, down, left, false); - if (leftBorderNotWhite) { - left--; - aBlackPointFoundOnBorder = true; - atLeastOneBlackPointFoundOnLeft = true; - } else if (!atLeastOneBlackPointFoundOnLeft) { - left--; - } - } - - if (left < 0) { - sizeExceeded = true; - break; - } - - // .___. - // . . - // ..... - boolean topBorderNotWhite = true; - while ((topBorderNotWhite || !atLeastOneBlackPointFoundOnTop) && up >= 0) { - topBorderNotWhite = containsBlackPoint(left, right, up, true); - if (topBorderNotWhite) { - up--; - aBlackPointFoundOnBorder = true; - atLeastOneBlackPointFoundOnTop = true; - } else if (!atLeastOneBlackPointFoundOnTop) { - up--; - } - } - - if (up < 0) { - sizeExceeded = true; - break; - } - - } - - if (!sizeExceeded) { - - int maxSize = right - left; - - ResultPoint z = null; - for (int i = 1; z == null && i < maxSize; i++) { - z = getBlackPointOnSegment(left, down - i, left + i, down); - } - - if (z == null) { - throw NotFoundException.getNotFoundInstance(); - } - - ResultPoint t = null; - //go down right - for (int i = 1; t == null && i < maxSize; i++) { - t = getBlackPointOnSegment(left, up + i, left + i, up); - } - - if (t == null) { - throw NotFoundException.getNotFoundInstance(); - } - - ResultPoint x = null; - //go down left - for (int i = 1; x == null && i < maxSize; i++) { - x = getBlackPointOnSegment(right, up + i, right - i, up); - } - - if (x == null) { - throw NotFoundException.getNotFoundInstance(); - } - - ResultPoint y = null; - //go up left - for (int i = 1; y == null && i < maxSize; i++) { - y = getBlackPointOnSegment(right, down - i, right - i, down); - } - - if (y == null) { - throw NotFoundException.getNotFoundInstance(); - } - - return centerEdges(y, z, x, t); - - } else { - throw NotFoundException.getNotFoundInstance(); - } - } - - private ResultPoint getBlackPointOnSegment(float aX, float aY, float bX, float bY) { - int dist = MathUtils.round(MathUtils.distance(aX, aY, bX, bY)); - float xStep = (bX - aX) / dist; - float yStep = (bY - aY) / dist; - - for (int i = 0; i < dist; i++) { - int x = MathUtils.round(aX + i * xStep); - int y = MathUtils.round(aY + i * yStep); - if (image.get(x, y)) { - return new ResultPoint(x, y); - } - } - return null; - } - - /** - * recenters the points of a constant distance towards the center - * - * @param y bottom most point - * @param z left most point - * @param x right most point - * @param t top most point - * @return {@link ResultPoint}[] describing the corners of the rectangular - * region. The first and last points are opposed on the diagonal, as - * are the second and third. The first point will be the topmost - * point and the last, the bottommost. The second point will be - * leftmost and the third, the rightmost - */ - private ResultPoint[] centerEdges(ResultPoint y, ResultPoint z, - ResultPoint x, ResultPoint t) { - - // - // t t - // z x - // x OR z - // y y - // - - float yi = y.getX(); - float yj = y.getY(); - float zi = z.getX(); - float zj = z.getY(); - float xi = x.getX(); - float xj = x.getY(); - float ti = t.getX(); - float tj = t.getY(); - - if (yi < width / 2.0f) { - return new ResultPoint[]{ - new ResultPoint(ti - CORR, tj + CORR), - new ResultPoint(zi + CORR, zj + CORR), - new ResultPoint(xi - CORR, xj - CORR), - new ResultPoint(yi + CORR, yj - CORR)}; - } else { - return new ResultPoint[]{ - new ResultPoint(ti + CORR, tj + CORR), - new ResultPoint(zi + CORR, zj - CORR), - new ResultPoint(xi - CORR, xj + CORR), - new ResultPoint(yi - CORR, yj - CORR)}; - } - } - - /** - * Determines whether a segment contains a black point - * - * @param a min value of the scanned coordinate - * @param b max value of the scanned coordinate - * @param fixed value of fixed coordinate - * @param horizontal set to true if scan must be horizontal, false if vertical - * @return true if a black point has been found, else false. - */ - private boolean containsBlackPoint(int a, int b, int fixed, boolean horizontal) { - - if (horizontal) { - for (int x = a; x <= b; x++) { - if (image.get(x, fixed)) { - return true; - } - } - } else { - for (int y = a; y <= b; y++) { - if (image.get(fixed, y)) { - return true; - } - } - } - - return false; - } - -} diff --git a/port_src/core/DONE/common/reedsolomon/GenericGF.java b/port_src/core/DONE/common/reedsolomon/GenericGF.java deleted file mode 100644 index 2b32566..0000000 --- a/port_src/core/DONE/common/reedsolomon/GenericGF.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common.reedsolomon; - -/** - *

This class contains utility methods for performing mathematical operations over - * the Galois Fields. Operations use a given primitive polynomial in calculations.

- * - *

Throughout this package, elements of the GF are represented as an {@code int} - * for convenience and speed (but at the cost of memory). - *

- * - * @author Sean Owen - * @author David Olivier - */ -public final class GenericGF { - - public static final GenericGF AZTEC_DATA_12 = new GenericGF(0x1069, 4096, 1); // x^12 + x^6 + x^5 + x^3 + 1 - public static final GenericGF AZTEC_DATA_10 = new GenericGF(0x409, 1024, 1); // x^10 + x^3 + 1 - public static final GenericGF AZTEC_DATA_6 = new GenericGF(0x43, 64, 1); // x^6 + x + 1 - public static final GenericGF AZTEC_PARAM = new GenericGF(0x13, 16, 1); // x^4 + x + 1 - public static final GenericGF QR_CODE_FIELD_256 = new GenericGF(0x011D, 256, 0); // x^8 + x^4 + x^3 + x^2 + 1 - public static final GenericGF DATA_MATRIX_FIELD_256 = new GenericGF(0x012D, 256, 1); // x^8 + x^5 + x^3 + x^2 + 1 - public static final GenericGF AZTEC_DATA_8 = DATA_MATRIX_FIELD_256; - public static final GenericGF MAXICODE_FIELD_64 = AZTEC_DATA_6; - - private final int[] expTable; - private final int[] logTable; - private final GenericGFPoly zero; - private final GenericGFPoly one; - private final int size; - private final int primitive; - private final int generatorBase; - - /** - * Create a representation of GF(size) using the given primitive polynomial. - * - * @param primitive irreducible polynomial whose coefficients are represented by - * the bits of an int, where the least-significant bit represents the constant - * coefficient - * @param size the size of the field - * @param b the factor b in the generator polynomial can be 0- or 1-based - * (g(x) = (x+a^b)(x+a^(b+1))...(x+a^(b+2t-1))). - * In most cases it should be 1, but for QR code it is 0. - */ - public GenericGF(int primitive, int size, int b) { - this.primitive = primitive; - this.size = size; - this.generatorBase = b; - - expTable = new int[size]; - logTable = new int[size]; - int x = 1; - for (int i = 0; i < size; i++) { - expTable[i] = x; - x *= 2; // we're assuming the generator alpha is 2 - if (x >= size) { - x ^= primitive; - x &= size - 1; - } - } - for (int i = 0; i < size - 1; i++) { - logTable[expTable[i]] = i; - } - // logTable[0] == 0 but this should never be used - zero = new GenericGFPoly(this, new int[]{0}); - one = new GenericGFPoly(this, new int[]{1}); - } - - GenericGFPoly getZero() { - return zero; - } - - GenericGFPoly getOne() { - return one; - } - - /** - * @return the monomial representing coefficient * x^degree - */ - GenericGFPoly buildMonomial(int degree, int coefficient) { - if (degree < 0) { - throw new IllegalArgumentException(); - } - if (coefficient == 0) { - return zero; - } - int[] coefficients = new int[degree + 1]; - coefficients[0] = coefficient; - return new GenericGFPoly(this, coefficients); - } - - /** - * Implements both addition and subtraction -- they are the same in GF(size). - * - * @return sum/difference of a and b - */ - static int addOrSubtract(int a, int b) { - return a ^ b; - } - - /** - * @return 2 to the power of a in GF(size) - */ - int exp(int a) { - return expTable[a]; - } - - /** - * @return base 2 log of a in GF(size) - */ - int log(int a) { - if (a == 0) { - throw new IllegalArgumentException(); - } - return logTable[a]; - } - - /** - * @return multiplicative inverse of a - */ - int inverse(int a) { - if (a == 0) { - throw new ArithmeticException(); - } - return expTable[size - logTable[a] - 1]; - } - - /** - * @return product of a and b in GF(size) - */ - int multiply(int a, int b) { - if (a == 0 || b == 0) { - return 0; - } - return expTable[(logTable[a] + logTable[b]) % (size - 1)]; - } - - public int getSize() { - return size; - } - - public int getGeneratorBase() { - return generatorBase; - } - - @Override - public String toString() { - return "GF(0x" + Integer.toHexString(primitive) + ',' + size + ')'; - } - -} diff --git a/port_src/core/DONE/common/reedsolomon/GenericGFPoly.java b/port_src/core/DONE/common/reedsolomon/GenericGFPoly.java deleted file mode 100644 index 03f6743..0000000 --- a/port_src/core/DONE/common/reedsolomon/GenericGFPoly.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common.reedsolomon; - -/** - *

Represents a polynomial whose coefficients are elements of a GF. - * Instances of this class are immutable.

- * - *

Much credit is due to William Rucklidge since portions of this code are an indirect - * port of his C++ Reed-Solomon implementation.

- * - * @author Sean Owen - */ -final class GenericGFPoly { - - private final GenericGF field; - private final int[] coefficients; - - /** - * @param field the {@link GenericGF} instance representing the field to use - * to perform computations - * @param coefficients coefficients as ints representing elements of GF(size), arranged - * from most significant (highest-power term) coefficient to least significant - * @throws IllegalArgumentException if argument is null or empty, - * or if leading coefficient is 0 and this is not a - * constant polynomial (that is, it is not the monomial "0") - */ - GenericGFPoly(GenericGF field, int[] coefficients) { - if (coefficients.length == 0) { - throw new IllegalArgumentException(); - } - this.field = field; - int coefficientsLength = coefficients.length; - if (coefficientsLength > 1 && coefficients[0] == 0) { - // Leading term must be non-zero for anything except the constant polynomial "0" - int firstNonZero = 1; - while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) { - firstNonZero++; - } - if (firstNonZero == coefficientsLength) { - this.coefficients = new int[]{0}; - } else { - this.coefficients = new int[coefficientsLength - firstNonZero]; - System.arraycopy(coefficients, - firstNonZero, - this.coefficients, - 0, - this.coefficients.length); - } - } else { - this.coefficients = coefficients; - } - } - - int[] getCoefficients() { - return coefficients; - } - - /** - * @return degree of this polynomial - */ - int getDegree() { - return coefficients.length - 1; - } - - /** - * @return true iff this polynomial is the monomial "0" - */ - boolean isZero() { - return coefficients[0] == 0; - } - - /** - * @return coefficient of x^degree term in this polynomial - */ - int getCoefficient(int degree) { - return coefficients[coefficients.length - 1 - degree]; - } - - /** - * @return evaluation of this polynomial at a given point - */ - int evaluateAt(int a) { - if (a == 0) { - // Just return the x^0 coefficient - return getCoefficient(0); - } - if (a == 1) { - // Just the sum of the coefficients - int result = 0; - for (int coefficient : coefficients) { - result = GenericGF.addOrSubtract(result, coefficient); - } - return result; - } - int result = coefficients[0]; - int size = coefficients.length; - for (int i = 1; i < size; i++) { - result = GenericGF.addOrSubtract(field.multiply(a, result), coefficients[i]); - } - return result; - } - - GenericGFPoly addOrSubtract(GenericGFPoly other) { - if (!field.equals(other.field)) { - throw new IllegalArgumentException("GenericGFPolys do not have same GenericGF field"); - } - if (isZero()) { - return other; - } - if (other.isZero()) { - return this; - } - - int[] smallerCoefficients = this.coefficients; - int[] largerCoefficients = other.coefficients; - if (smallerCoefficients.length > largerCoefficients.length) { - int[] temp = smallerCoefficients; - smallerCoefficients = largerCoefficients; - largerCoefficients = temp; - } - int[] sumDiff = new int[largerCoefficients.length]; - int lengthDiff = largerCoefficients.length - smallerCoefficients.length; - // Copy high-order terms only found in higher-degree polynomial's coefficients - System.arraycopy(largerCoefficients, 0, sumDiff, 0, lengthDiff); - - for (int i = lengthDiff; i < largerCoefficients.length; i++) { - sumDiff[i] = GenericGF.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]); - } - - return new GenericGFPoly(field, sumDiff); - } - - GenericGFPoly multiply(GenericGFPoly other) { - if (!field.equals(other.field)) { - throw new IllegalArgumentException("GenericGFPolys do not have same GenericGF field"); - } - if (isZero() || other.isZero()) { - return field.getZero(); - } - int[] aCoefficients = this.coefficients; - int aLength = aCoefficients.length; - int[] bCoefficients = other.coefficients; - int bLength = bCoefficients.length; - int[] product = new int[aLength + bLength - 1]; - for (int i = 0; i < aLength; i++) { - int aCoeff = aCoefficients[i]; - for (int j = 0; j < bLength; j++) { - product[i + j] = GenericGF.addOrSubtract(product[i + j], - field.multiply(aCoeff, bCoefficients[j])); - } - } - return new GenericGFPoly(field, product); - } - - GenericGFPoly multiply(int scalar) { - if (scalar == 0) { - return field.getZero(); - } - if (scalar == 1) { - return this; - } - int size = coefficients.length; - int[] product = new int[size]; - for (int i = 0; i < size; i++) { - product[i] = field.multiply(coefficients[i], scalar); - } - return new GenericGFPoly(field, product); - } - - GenericGFPoly multiplyByMonomial(int degree, int coefficient) { - if (degree < 0) { - throw new IllegalArgumentException(); - } - if (coefficient == 0) { - return field.getZero(); - } - int size = coefficients.length; - int[] product = new int[size + degree]; - for (int i = 0; i < size; i++) { - product[i] = field.multiply(coefficients[i], coefficient); - } - return new GenericGFPoly(field, product); - } - - GenericGFPoly[] divide(GenericGFPoly other) { - if (!field.equals(other.field)) { - throw new IllegalArgumentException("GenericGFPolys do not have same GenericGF field"); - } - if (other.isZero()) { - throw new IllegalArgumentException("Divide by 0"); - } - - GenericGFPoly quotient = field.getZero(); - GenericGFPoly remainder = this; - - int denominatorLeadingTerm = other.getCoefficient(other.getDegree()); - int inverseDenominatorLeadingTerm = field.inverse(denominatorLeadingTerm); - - while (remainder.getDegree() >= other.getDegree() && !remainder.isZero()) { - int degreeDifference = remainder.getDegree() - other.getDegree(); - int scale = field.multiply(remainder.getCoefficient(remainder.getDegree()), inverseDenominatorLeadingTerm); - GenericGFPoly term = other.multiplyByMonomial(degreeDifference, scale); - GenericGFPoly iterationQuotient = field.buildMonomial(degreeDifference, scale); - quotient = quotient.addOrSubtract(iterationQuotient); - remainder = remainder.addOrSubtract(term); - } - - return new GenericGFPoly[] { quotient, remainder }; - } - - @Override - public String toString() { - if (isZero()) { - return "0"; - } - StringBuilder result = new StringBuilder(8 * getDegree()); - for (int degree = getDegree(); degree >= 0; degree--) { - int coefficient = getCoefficient(degree); - if (coefficient != 0) { - if (coefficient < 0) { - if (degree == getDegree()) { - result.append("-"); - } else { - result.append(" - "); - } - coefficient = -coefficient; - } else { - if (result.length() > 0) { - result.append(" + "); - } - } - if (degree == 0 || coefficient != 1) { - int alphaPower = field.log(coefficient); - if (alphaPower == 0) { - result.append('1'); - } else if (alphaPower == 1) { - result.append('a'); - } else { - result.append("a^"); - result.append(alphaPower); - } - } - if (degree != 0) { - if (degree == 1) { - result.append('x'); - } else { - result.append("x^"); - result.append(degree); - } - } - } - } - return result.toString(); - } - -} diff --git a/port_src/core/DONE/common/reedsolomon/ReedSolomonDecoder.java b/port_src/core/DONE/common/reedsolomon/ReedSolomonDecoder.java deleted file mode 100644 index 2593456..0000000 --- a/port_src/core/DONE/common/reedsolomon/ReedSolomonDecoder.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common.reedsolomon; - -/** - *

Implements Reed-Solomon decoding, as the name implies.

- * - *

The algorithm will not be explained here, but the following references were helpful - * in creating this implementation:

- * - * - * - *

Much credit is due to William Rucklidge since portions of this code are an indirect - * port of his C++ Reed-Solomon implementation.

- * - * @author Sean Owen - * @author William Rucklidge - * @author sanfordsquires - */ -public final class ReedSolomonDecoder { - - private final GenericGF field; - - public ReedSolomonDecoder(GenericGF field) { - this.field = field; - } - - /** - *

Decodes given set of received codewords, which include both data and error-correction - * codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place, - * in the input.

- * - * @param received data and error-correction codewords - * @param twoS number of error-correction codewords available - * @throws ReedSolomonException if decoding fails for any reason - */ - public void decode(int[] received, int twoS) throws ReedSolomonException { - GenericGFPoly poly = new GenericGFPoly(field, received); - int[] syndromeCoefficients = new int[twoS]; - boolean noError = true; - for (int i = 0; i < twoS; i++) { - int eval = poly.evaluateAt(field.exp(i + field.getGeneratorBase())); - syndromeCoefficients[syndromeCoefficients.length - 1 - i] = eval; - if (eval != 0) { - noError = false; - } - } - if (noError) { - return; - } - GenericGFPoly syndrome = new GenericGFPoly(field, syndromeCoefficients); - GenericGFPoly[] sigmaOmega = - runEuclideanAlgorithm(field.buildMonomial(twoS, 1), syndrome, twoS); - GenericGFPoly sigma = sigmaOmega[0]; - GenericGFPoly omega = sigmaOmega[1]; - int[] errorLocations = findErrorLocations(sigma); - int[] errorMagnitudes = findErrorMagnitudes(omega, errorLocations); - for (int i = 0; i < errorLocations.length; i++) { - int position = received.length - 1 - field.log(errorLocations[i]); - if (position < 0) { - throw new ReedSolomonException("Bad error location"); - } - received[position] = GenericGF.addOrSubtract(received[position], errorMagnitudes[i]); - } - } - - private GenericGFPoly[] runEuclideanAlgorithm(GenericGFPoly a, GenericGFPoly b, int R) - throws ReedSolomonException { - // Assume a's degree is >= b's - if (a.getDegree() < b.getDegree()) { - GenericGFPoly temp = a; - a = b; - b = temp; - } - - GenericGFPoly rLast = a; - GenericGFPoly r = b; - GenericGFPoly tLast = field.getZero(); - GenericGFPoly t = field.getOne(); - - // Run Euclidean algorithm until r's degree is less than R/2 - while (2 * r.getDegree() >= R) { - GenericGFPoly rLastLast = rLast; - GenericGFPoly tLastLast = tLast; - rLast = r; - tLast = t; - - // Divide rLastLast by rLast, with quotient in q and remainder in r - if (rLast.isZero()) { - // Oops, Euclidean algorithm already terminated? - throw new ReedSolomonException("r_{i-1} was zero"); - } - r = rLastLast; - GenericGFPoly q = field.getZero(); - int denominatorLeadingTerm = rLast.getCoefficient(rLast.getDegree()); - int dltInverse = field.inverse(denominatorLeadingTerm); - while (r.getDegree() >= rLast.getDegree() && !r.isZero()) { - int degreeDiff = r.getDegree() - rLast.getDegree(); - int scale = field.multiply(r.getCoefficient(r.getDegree()), dltInverse); - q = q.addOrSubtract(field.buildMonomial(degreeDiff, scale)); - r = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale)); - } - - t = q.multiply(tLast).addOrSubtract(tLastLast); - - if (r.getDegree() >= rLast.getDegree()) { - throw new IllegalStateException("Division algorithm failed to reduce polynomial? " + - "r: " + r + ", rLast: " + rLast); - } - } - - int sigmaTildeAtZero = t.getCoefficient(0); - if (sigmaTildeAtZero == 0) { - throw new ReedSolomonException("sigmaTilde(0) was zero"); - } - - int inverse = field.inverse(sigmaTildeAtZero); - GenericGFPoly sigma = t.multiply(inverse); - GenericGFPoly omega = r.multiply(inverse); - return new GenericGFPoly[]{sigma, omega}; - } - - private int[] findErrorLocations(GenericGFPoly errorLocator) throws ReedSolomonException { - // This is a direct application of Chien's search - int numErrors = errorLocator.getDegree(); - if (numErrors == 1) { // shortcut - return new int[] { errorLocator.getCoefficient(1) }; - } - int[] result = new int[numErrors]; - int e = 0; - for (int i = 1; i < field.getSize() && e < numErrors; i++) { - if (errorLocator.evaluateAt(i) == 0) { - result[e] = field.inverse(i); - e++; - } - } - if (e != numErrors) { - throw new ReedSolomonException("Error locator degree does not match number of roots"); - } - return result; - } - - private int[] findErrorMagnitudes(GenericGFPoly errorEvaluator, int[] errorLocations) { - // This is directly applying Forney's Formula - int s = errorLocations.length; - int[] result = new int[s]; - for (int i = 0; i < s; i++) { - int xiInverse = field.inverse(errorLocations[i]); - int denominator = 1; - for (int j = 0; j < s; j++) { - if (i != j) { - //denominator = field.multiply(denominator, - // GenericGF.addOrSubtract(1, field.multiply(errorLocations[j], xiInverse))); - // Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug. - // Below is a funny-looking workaround from Steven Parkes - int term = field.multiply(errorLocations[j], xiInverse); - int termPlus1 = (term & 0x1) == 0 ? term | 1 : term & ~1; - denominator = field.multiply(denominator, termPlus1); - } - } - result[i] = field.multiply(errorEvaluator.evaluateAt(xiInverse), - field.inverse(denominator)); - if (field.getGeneratorBase() != 0) { - result[i] = field.multiply(result[i], xiInverse); - } - } - return result; - } - -} diff --git a/port_src/core/DONE/common/reedsolomon/ReedSolomonEncoder.java b/port_src/core/DONE/common/reedsolomon/ReedSolomonEncoder.java deleted file mode 100644 index 2e2b2f0..0000000 --- a/port_src/core/DONE/common/reedsolomon/ReedSolomonEncoder.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common.reedsolomon; - -import java.util.ArrayList; -import java.util.List; - -/** - *

Implements Reed-Solomon encoding, as the name implies.

- * - * @author Sean Owen - * @author William Rucklidge - */ -public final class ReedSolomonEncoder { - - private final GenericGF field; - private final List cachedGenerators; - - public ReedSolomonEncoder(GenericGF field) { - this.field = field; - this.cachedGenerators = new ArrayList<>(); - cachedGenerators.add(new GenericGFPoly(field, new int[]{1})); - } - - private GenericGFPoly buildGenerator(int degree) { - if (degree >= cachedGenerators.size()) { - GenericGFPoly lastGenerator = cachedGenerators.get(cachedGenerators.size() - 1); - for (int d = cachedGenerators.size(); d <= degree; d++) { - GenericGFPoly nextGenerator = lastGenerator.multiply( - new GenericGFPoly(field, new int[] { 1, field.exp(d - 1 + field.getGeneratorBase()) })); - cachedGenerators.add(nextGenerator); - lastGenerator = nextGenerator; - } - } - return cachedGenerators.get(degree); - } - - public void encode(int[] toEncode, int ecBytes) { - if (ecBytes == 0) { - throw new IllegalArgumentException("No error correction bytes"); - } - int dataBytes = toEncode.length - ecBytes; - if (dataBytes <= 0) { - throw new IllegalArgumentException("No data bytes provided"); - } - GenericGFPoly generator = buildGenerator(ecBytes); - int[] infoCoefficients = new int[dataBytes]; - System.arraycopy(toEncode, 0, infoCoefficients, 0, dataBytes); - GenericGFPoly info = new GenericGFPoly(field, infoCoefficients); - info = info.multiplyByMonomial(ecBytes, 1); - GenericGFPoly remainder = info.divide(generator)[1]; - int[] coefficients = remainder.getCoefficients(); - int numZeroCoefficients = ecBytes - coefficients.length; - for (int i = 0; i < numZeroCoefficients; i++) { - toEncode[dataBytes + i] = 0; - } - System.arraycopy(coefficients, 0, toEncode, dataBytes + numZeroCoefficients, coefficients.length); - } - -} diff --git a/port_src/core/DONE/common/reedsolomon/ReedSolomonException.java b/port_src/core/DONE/common/reedsolomon/ReedSolomonException.java deleted file mode 100644 index d5b45a6..0000000 --- a/port_src/core/DONE/common/reedsolomon/ReedSolomonException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common.reedsolomon; - -/** - *

Thrown when an exception occurs during Reed-Solomon decoding, such as when - * there are too many errors to correct.

- * - * @author Sean Owen - */ -public final class ReedSolomonException extends Exception { - - public ReedSolomonException(String message) { - super(message); - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/datamatrix/DataMatrixReader.java b/port_src/core/DONE/datamatrix/DataMatrixReader.java deleted file mode 100644 index f596fd1..0000000 --- a/port_src/core/DONE/datamatrix/DataMatrixReader.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Reader; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.DetectorResult; -import com.google.zxing.datamatrix.decoder.Decoder; -import com.google.zxing.datamatrix.detector.Detector; - -import java.util.List; -import java.util.Map; - -/** - * This implementation can detect and decode Data Matrix codes in an image. - * - * @author bbrown@google.com (Brian Brown) - */ -public final class DataMatrixReader implements Reader { - - private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; - - private final Decoder decoder = new Decoder(); - - /** - * Locates and decodes a Data Matrix code in an image. - * - * @return a String representing the content encoded by the Data Matrix code - * @throws NotFoundException if a Data Matrix code cannot be found - * @throws FormatException if a Data Matrix code cannot be decoded - * @throws ChecksumException if error correction fails - */ - @Override - public Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException { - return decode(image, null); - } - - @Override - public Result decode(BinaryBitmap image, Map hints) - throws NotFoundException, ChecksumException, FormatException { - DecoderResult decoderResult; - ResultPoint[] points; - if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { - BitMatrix bits = extractPureBits(image.getBlackMatrix()); - decoderResult = decoder.decode(bits); - points = NO_POINTS; - } else { - DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(); - decoderResult = decoder.decode(detectorResult.getBits()); - points = detectorResult.getPoints(); - } - Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, - BarcodeFormat.DATA_MATRIX); - List byteSegments = decoderResult.getByteSegments(); - if (byteSegments != null) { - result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); - } - String ecLevel = decoderResult.getECLevel(); - if (ecLevel != null) { - result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); - } - result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]d" + decoderResult.getSymbologyModifier()); - return result; - } - - @Override - public void reset() { - // do nothing - } - - /** - * This method detects a code in a "pure" image -- that is, pure monochrome image - * which contains only an unrotated, unskewed, image of a code, with some white border - * around it. This is a specialized method that works exceptionally fast in this special - * case. - */ - private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException { - - int[] leftTopBlack = image.getTopLeftOnBit(); - int[] rightBottomBlack = image.getBottomRightOnBit(); - if (leftTopBlack == null || rightBottomBlack == null) { - throw NotFoundException.getNotFoundInstance(); - } - - int moduleSize = moduleSize(leftTopBlack, image); - - int top = leftTopBlack[1]; - int bottom = rightBottomBlack[1]; - int left = leftTopBlack[0]; - int right = rightBottomBlack[0]; - - int matrixWidth = (right - left + 1) / moduleSize; - int matrixHeight = (bottom - top + 1) / moduleSize; - if (matrixWidth <= 0 || matrixHeight <= 0) { - throw NotFoundException.getNotFoundInstance(); - } - - // Push in the "border" by half the module width so that we start - // sampling in the middle of the module. Just in case the image is a - // little off, this will help recover. - int nudge = moduleSize / 2; - top += nudge; - left += nudge; - - // Now just read off the bits - BitMatrix bits = new BitMatrix(matrixWidth, matrixHeight); - for (int y = 0; y < matrixHeight; y++) { - int iOffset = top + y * moduleSize; - for (int x = 0; x < matrixWidth; x++) { - if (image.get(left + x * moduleSize, iOffset)) { - bits.set(x, y); - } - } - } - return bits; - } - - private static int moduleSize(int[] leftTopBlack, BitMatrix image) throws NotFoundException { - int width = image.getWidth(); - int x = leftTopBlack[0]; - int y = leftTopBlack[1]; - while (x < width && image.get(x, y)) { - x++; - } - if (x == width) { - throw NotFoundException.getNotFoundInstance(); - } - - int moduleSize = x - leftTopBlack[0]; - if (moduleSize == 0) { - throw NotFoundException.getNotFoundInstance(); - } - return moduleSize; - } - -} diff --git a/port_src/core/DONE/datamatrix/DataMatrixWriter.java b/port_src/core/DONE/datamatrix/DataMatrixWriter.java deleted file mode 100644 index 0bc680c..0000000 --- a/port_src/core/DONE/datamatrix/DataMatrixWriter.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.Writer; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.datamatrix.encoder.DefaultPlacement; -import com.google.zxing.Dimension; -import com.google.zxing.datamatrix.encoder.ErrorCorrection; -import com.google.zxing.datamatrix.encoder.HighLevelEncoder; -import com.google.zxing.datamatrix.encoder.MinimalEncoder; -import com.google.zxing.datamatrix.encoder.SymbolInfo; -import com.google.zxing.datamatrix.encoder.SymbolShapeHint; -import com.google.zxing.qrcode.encoder.ByteMatrix; - -import java.util.Map; -import java.nio.charset.Charset; - -/** - * This object renders a Data Matrix code as a BitMatrix 2D array of greyscale values. - * - * @author dswitkin@google.com (Daniel Switkin) - * @author Guillaume Le Biller Added to zxing lib. - */ -public final class DataMatrixWriter implements Writer { - - @Override - public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) { - return encode(contents, format, width, height, null); - } - - @Override - public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map hints) { - - if (contents.isEmpty()) { - throw new IllegalArgumentException("Found empty contents"); - } - - if (format != BarcodeFormat.DATA_MATRIX) { - throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format); - } - - if (width < 0 || height < 0) { - throw new IllegalArgumentException("Requested dimensions can't be negative: " + width + 'x' + height); - } - - // Try to get force shape & min / max size - SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE; - Dimension minSize = null; - Dimension maxSize = null; - if (hints != null) { - SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE); - if (requestedShape != null) { - shape = requestedShape; - } - @SuppressWarnings("deprecation") - Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE); - if (requestedMinSize != null) { - minSize = requestedMinSize; - } - @SuppressWarnings("deprecation") - Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE); - if (requestedMaxSize != null) { - maxSize = requestedMaxSize; - } - } - - - //1. step: Data encodation - String encoded; - - boolean hasCompactionHint = hints != null && hints.containsKey(EncodeHintType.DATA_MATRIX_COMPACT) && - Boolean.parseBoolean(hints.get(EncodeHintType.DATA_MATRIX_COMPACT).toString()); - if (hasCompactionHint) { - - boolean hasGS1FormatHint = hints.containsKey(EncodeHintType.GS1_FORMAT) && - Boolean.parseBoolean(hints.get(EncodeHintType.GS1_FORMAT).toString()); - - Charset charset = null; - boolean hasEncodingHint = hints.containsKey(EncodeHintType.CHARACTER_SET); - if (hasEncodingHint) { - charset = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString()); - } - encoded = MinimalEncoder.encodeHighLevel(contents, charset, hasGS1FormatHint ? 0x1D : -1, shape); - } else { - boolean hasForceC40Hint = hints != null && hints.containsKey(EncodeHintType.FORCE_C40) && - Boolean.parseBoolean(hints.get(EncodeHintType.FORCE_C40).toString()); - encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize, hasForceC40Hint); - } - - SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true); - - //2. step: ECC generation - String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo); - - //3. step: Module placement in Matrix - DefaultPlacement placement = - new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight()); - placement.place(); - - //4. step: low-level encoding - return encodeLowLevel(placement, symbolInfo, width, height); - } - - /** - * Encode the given symbol info to a bit matrix. - * - * @param placement The DataMatrix placement. - * @param symbolInfo The symbol info to encode. - * @return The bit matrix generated. - */ - private static BitMatrix encodeLowLevel(DefaultPlacement placement, SymbolInfo symbolInfo, int width, int height) { - int symbolWidth = symbolInfo.getSymbolDataWidth(); - int symbolHeight = symbolInfo.getSymbolDataHeight(); - - ByteMatrix matrix = new ByteMatrix(symbolInfo.getSymbolWidth(), symbolInfo.getSymbolHeight()); - - int matrixY = 0; - - for (int y = 0; y < symbolHeight; y++) { - // Fill the top edge with alternate 0 / 1 - int matrixX; - if ((y % symbolInfo.matrixHeight) == 0) { - matrixX = 0; - for (int x = 0; x < symbolInfo.getSymbolWidth(); x++) { - matrix.set(matrixX, matrixY, (x % 2) == 0); - matrixX++; - } - matrixY++; - } - matrixX = 0; - for (int x = 0; x < symbolWidth; x++) { - // Fill the right edge with full 1 - if ((x % symbolInfo.matrixWidth) == 0) { - matrix.set(matrixX, matrixY, true); - matrixX++; - } - matrix.set(matrixX, matrixY, placement.getBit(x, y)); - matrixX++; - // Fill the right edge with alternate 0 / 1 - if ((x % symbolInfo.matrixWidth) == symbolInfo.matrixWidth - 1) { - matrix.set(matrixX, matrixY, (y % 2) == 0); - matrixX++; - } - } - matrixY++; - // Fill the bottom edge with full 1 - if ((y % symbolInfo.matrixHeight) == symbolInfo.matrixHeight - 1) { - matrixX = 0; - for (int x = 0; x < symbolInfo.getSymbolWidth(); x++) { - matrix.set(matrixX, matrixY, true); - matrixX++; - } - matrixY++; - } - } - - return convertByteMatrixToBitMatrix(matrix, width, height); - } - - /** - * Convert the ByteMatrix to BitMatrix. - * - * @param reqHeight The requested height of the image (in pixels) with the Datamatrix code - * @param reqWidth The requested width of the image (in pixels) with the Datamatrix code - * @param matrix The input matrix. - * @return The output matrix. - */ - private static BitMatrix convertByteMatrixToBitMatrix(ByteMatrix matrix, int reqWidth, int reqHeight) { - int matrixWidth = matrix.getWidth(); - int matrixHeight = matrix.getHeight(); - int outputWidth = Math.max(reqWidth, matrixWidth); - int outputHeight = Math.max(reqHeight, matrixHeight); - - int multiple = Math.min(outputWidth / matrixWidth, outputHeight / matrixHeight); - - int leftPadding = (outputWidth - (matrixWidth * multiple)) / 2 ; - int topPadding = (outputHeight - (matrixHeight * multiple)) / 2 ; - - BitMatrix output; - - // remove padding if requested width and height are too small - if (reqHeight < matrixHeight || reqWidth < matrixWidth) { - leftPadding = 0; - topPadding = 0; - output = new BitMatrix(matrixWidth, matrixHeight); - } else { - output = new BitMatrix(reqWidth, reqHeight); - } - - output.clear(); - for (int inputY = 0, outputY = topPadding; inputY < matrixHeight; inputY++, outputY += multiple) { - // Write the contents of this row of the bytematrix - for (int inputX = 0, outputX = leftPadding; inputX < matrixWidth; inputX++, outputX += multiple) { - if (matrix.get(inputX, inputY) == 1) { - output.setRegion(outputX, outputY, multiple, multiple); - } - } - } - - return output; - } - -} diff --git a/port_src/core/DONE/datamatrix/decoder/BitMatrixParser.java b/port_src/core/DONE/datamatrix/decoder/BitMatrixParser.java deleted file mode 100644 index 225df65..0000000 --- a/port_src/core/DONE/datamatrix/decoder/BitMatrixParser.java +++ /dev/null @@ -1,443 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; - -/** - * @author bbrown@google.com (Brian Brown) - */ -final class BitMatrixParser { - - private final BitMatrix mappingBitMatrix; - private final BitMatrix readMappingMatrix; - private final Version version; - - /** - * @param bitMatrix {@link BitMatrix} to parse - * @throws FormatException if dimension is < 8 or > 144 or not 0 mod 2 - */ - BitMatrixParser(BitMatrix bitMatrix) throws FormatException { - int dimension = bitMatrix.getHeight(); - if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0) { - throw FormatException.getFormatInstance(); - } - - version = readVersion(bitMatrix); - this.mappingBitMatrix = extractDataRegion(bitMatrix); - this.readMappingMatrix = new BitMatrix(this.mappingBitMatrix.getWidth(), this.mappingBitMatrix.getHeight()); - } - - Version getVersion() { - return version; - } - - /** - *

Creates the version object based on the dimension of the original bit matrix from - * the datamatrix code.

- * - *

See ISO 16022:2006 Table 7 - ECC 200 symbol attributes

- * - * @param bitMatrix Original {@link BitMatrix} including alignment patterns - * @return {@link Version} encapsulating the Data Matrix Code's "version" - * @throws FormatException if the dimensions of the mapping matrix are not valid - * Data Matrix dimensions. - */ - private static Version readVersion(BitMatrix bitMatrix) throws FormatException { - int numRows = bitMatrix.getHeight(); - int numColumns = bitMatrix.getWidth(); - return Version.getVersionForDimensions(numRows, numColumns); - } - - /** - *

Reads the bits in the {@link BitMatrix} representing the mapping matrix (No alignment patterns) - * in the correct order in order to reconstitute the codewords bytes contained within the - * Data Matrix Code.

- * - * @return bytes encoded within the Data Matrix Code - * @throws FormatException if the exact number of bytes expected is not read - */ - byte[] readCodewords() throws FormatException { - - byte[] result = new byte[version.getTotalCodewords()]; - int resultOffset = 0; - - int row = 4; - int column = 0; - - int numRows = mappingBitMatrix.getHeight(); - int numColumns = mappingBitMatrix.getWidth(); - - boolean corner1Read = false; - boolean corner2Read = false; - boolean corner3Read = false; - boolean corner4Read = false; - - // Read all of the codewords - do { - // Check the four corner cases - if ((row == numRows) && (column == 0) && !corner1Read) { - result[resultOffset++] = (byte) readCorner1(numRows, numColumns); - row -= 2; - column += 2; - corner1Read = true; - } else if ((row == numRows - 2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) { - result[resultOffset++] = (byte) readCorner2(numRows, numColumns); - row -= 2; - column += 2; - corner2Read = true; - } else if ((row == numRows + 4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) { - result[resultOffset++] = (byte) readCorner3(numRows, numColumns); - row -= 2; - column += 2; - corner3Read = true; - } else if ((row == numRows - 2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) { - result[resultOffset++] = (byte) readCorner4(numRows, numColumns); - row -= 2; - column += 2; - corner4Read = true; - } else { - // Sweep upward diagonally to the right - do { - if ((row < numRows) && (column >= 0) && !readMappingMatrix.get(column, row)) { - result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns); - } - row -= 2; - column += 2; - } while ((row >= 0) && (column < numColumns)); - row += 1; - column += 3; - - // Sweep downward diagonally to the left - do { - if ((row >= 0) && (column < numColumns) && !readMappingMatrix.get(column, row)) { - result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns); - } - row += 2; - column -= 2; - } while ((row < numRows) && (column >= 0)); - row += 3; - column += 1; - } - } while ((row < numRows) || (column < numColumns)); - - if (resultOffset != version.getTotalCodewords()) { - throw FormatException.getFormatInstance(); - } - return result; - } - - /** - *

Reads a bit of the mapping matrix accounting for boundary wrapping.

- * - * @param row Row to read in the mapping matrix - * @param column Column to read in the mapping matrix - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return value of the given bit in the mapping matrix - */ - private boolean readModule(int row, int column, int numRows, int numColumns) { - // Adjust the row and column indices based on boundary wrapping - if (row < 0) { - row += numRows; - column += 4 - ((numRows + 4) & 0x07); - } - if (column < 0) { - column += numColumns; - row += 4 - ((numColumns + 4) & 0x07); - } - if (row >= numRows) { - row -= numRows; - } - readMappingMatrix.set(column, row); - return mappingBitMatrix.get(column, row); - } - - /** - *

Reads the 8 bits of the standard Utah-shaped pattern.

- * - *

See ISO 16022:2006, 5.8.1 Figure 6

- * - * @param row Current row in the mapping matrix, anchored at the 8th bit (LSB) of the pattern - * @param column Current column in the mapping matrix, anchored at the 8th bit (LSB) of the pattern - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the utah shape - */ - private int readUtah(int row, int column, int numRows, int numColumns) { - int currentByte = 0; - if (readModule(row - 2, column - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row - 2, column - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row - 1, column - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row - 1, column - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row - 1, column, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row, column - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row, column - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row, column, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; - } - - /** - *

Reads the 8 bits of the special corner condition 1.

- * - *

See ISO 16022:2006, Figure F.3

- * - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the Corner condition 1 - */ - private int readCorner1(int numRows, int numColumns) { - int currentByte = 0; - if (readModule(numRows - 1, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 1, 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 1, 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(2, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(3, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; - } - - /** - *

Reads the 8 bits of the special corner condition 2.

- * - *

See ISO 16022:2006, Figure F.4

- * - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the Corner condition 2 - */ - private int readCorner2(int numRows, int numColumns) { - int currentByte = 0; - if (readModule(numRows - 3, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 2, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 1, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 4, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 3, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; - } - - /** - *

Reads the 8 bits of the special corner condition 3.

- * - *

See ISO 16022:2006, Figure F.5

- * - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the Corner condition 3 - */ - private int readCorner3(int numRows, int numColumns) { - int currentByte = 0; - if (readModule(numRows - 1, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 3, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(1, numColumns - 3, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(1, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; - } - - /** - *

Reads the 8 bits of the special corner condition 4.

- * - *

See ISO 16022:2006, Figure F.6

- * - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the Corner condition 4 - */ - private int readCorner4(int numRows, int numColumns) { - int currentByte = 0; - if (readModule(numRows - 3, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 2, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 1, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(2, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(3, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; - } - - /** - *

Extracts the data region from a {@link BitMatrix} that contains - * alignment patterns.

- * - * @param bitMatrix Original {@link BitMatrix} with alignment patterns - * @return BitMatrix that has the alignment patterns removed - */ - private BitMatrix extractDataRegion(BitMatrix bitMatrix) { - int symbolSizeRows = version.getSymbolSizeRows(); - int symbolSizeColumns = version.getSymbolSizeColumns(); - - if (bitMatrix.getHeight() != symbolSizeRows) { - throw new IllegalArgumentException("Dimension of bitMatrix must match the version size"); - } - - int dataRegionSizeRows = version.getDataRegionSizeRows(); - int dataRegionSizeColumns = version.getDataRegionSizeColumns(); - - int numDataRegionsRow = symbolSizeRows / dataRegionSizeRows; - int numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns; - - int sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows; - int sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns; - - BitMatrix bitMatrixWithoutAlignment = new BitMatrix(sizeDataRegionColumn, sizeDataRegionRow); - for (int dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) { - int dataRegionRowOffset = dataRegionRow * dataRegionSizeRows; - for (int dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn; ++dataRegionColumn) { - int dataRegionColumnOffset = dataRegionColumn * dataRegionSizeColumns; - for (int i = 0; i < dataRegionSizeRows; ++i) { - int readRowOffset = dataRegionRow * (dataRegionSizeRows + 2) + 1 + i; - int writeRowOffset = dataRegionRowOffset + i; - for (int j = 0; j < dataRegionSizeColumns; ++j) { - int readColumnOffset = dataRegionColumn * (dataRegionSizeColumns + 2) + 1 + j; - if (bitMatrix.get(readColumnOffset, readRowOffset)) { - int writeColumnOffset = dataRegionColumnOffset + j; - bitMatrixWithoutAlignment.set(writeColumnOffset, writeRowOffset); - } - } - } - } - } - return bitMatrixWithoutAlignment; - } - -} diff --git a/port_src/core/DONE/datamatrix/decoder/DataBlock.java b/port_src/core/DONE/datamatrix/decoder/DataBlock.java deleted file mode 100644 index fd64b26..0000000 --- a/port_src/core/DONE/datamatrix/decoder/DataBlock.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.decoder; - -/** - *

Encapsulates a block of data within a Data Matrix Code. Data Matrix Codes may split their data into - * multiple blocks, each of which is a unit of data and error-correction codewords. Each - * is represented by an instance of this class.

- * - * @author bbrown@google.com (Brian Brown) - */ -final class DataBlock { - - private final int numDataCodewords; - private final byte[] codewords; - - private DataBlock(int numDataCodewords, byte[] codewords) { - this.numDataCodewords = numDataCodewords; - this.codewords = codewords; - } - - /** - *

When Data Matrix Codes use multiple data blocks, they actually interleave the bytes of each of them. - * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This - * method will separate the data into original blocks.

- * - * @param rawCodewords bytes as read directly from the Data Matrix Code - * @param version version of the Data Matrix Code - * @return DataBlocks containing original bytes, "de-interleaved" from representation in the - * Data Matrix Code - */ - static DataBlock[] getDataBlocks(byte[] rawCodewords, - Version version) { - // Figure out the number and size of data blocks used by this version - Version.ECBlocks ecBlocks = version.getECBlocks(); - - // First count the total number of data blocks - int totalBlocks = 0; - Version.ECB[] ecBlockArray = ecBlocks.getECBlocks(); - for (Version.ECB ecBlock : ecBlockArray) { - totalBlocks += ecBlock.getCount(); - } - - // Now establish DataBlocks of the appropriate size and number of data codewords - DataBlock[] result = new DataBlock[totalBlocks]; - int numResultBlocks = 0; - for (Version.ECB ecBlock : ecBlockArray) { - for (int i = 0; i < ecBlock.getCount(); i++) { - int numDataCodewords = ecBlock.getDataCodewords(); - int numBlockCodewords = ecBlocks.getECCodewords() + numDataCodewords; - result[numResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]); - } - } - - // All blocks have the same amount of data, except that the last n - // (where n may be 0) have 1 less byte. Figure out where these start. - // TODO(bbrown): There is only one case where there is a difference for Data Matrix for size 144 - int longerBlocksTotalCodewords = result[0].codewords.length; - //int shorterBlocksTotalCodewords = longerBlocksTotalCodewords - 1; - - int longerBlocksNumDataCodewords = longerBlocksTotalCodewords - ecBlocks.getECCodewords(); - int shorterBlocksNumDataCodewords = longerBlocksNumDataCodewords - 1; - // The last elements of result may be 1 element shorter for 144 matrix - // first fill out as many elements as all of them have minus 1 - int rawCodewordsOffset = 0; - for (int i = 0; i < shorterBlocksNumDataCodewords; i++) { - for (int j = 0; j < numResultBlocks; j++) { - result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; - } - } - - // Fill out the last data block in the longer ones - boolean specialVersion = version.getVersionNumber() == 24; - int numLongerBlocks = specialVersion ? 8 : numResultBlocks; - for (int j = 0; j < numLongerBlocks; j++) { - result[j].codewords[longerBlocksNumDataCodewords - 1] = rawCodewords[rawCodewordsOffset++]; - } - - // Now add in error correction blocks - int max = result[0].codewords.length; - for (int i = longerBlocksNumDataCodewords; i < max; i++) { - for (int j = 0; j < numResultBlocks; j++) { - int jOffset = specialVersion ? (j + 8) % numResultBlocks : j; - int iOffset = specialVersion && jOffset > 7 ? i - 1 : i; - result[jOffset].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; - } - } - - if (rawCodewordsOffset != rawCodewords.length) { - throw new IllegalArgumentException(); - } - - return result; - } - - int getNumDataCodewords() { - return numDataCodewords; - } - - byte[] getCodewords() { - return codewords; - } - -} diff --git a/port_src/core/DONE/datamatrix/decoder/DecodedBitStreamParser.java b/port_src/core/DONE/datamatrix/decoder/DecodedBitStreamParser.java deleted file mode 100644 index 497b8c3..0000000 --- a/port_src/core/DONE/datamatrix/decoder/DecodedBitStreamParser.java +++ /dev/null @@ -1,590 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.common.BitSource; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.ECIStringBuilder; - -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - *

Data Matrix Codes can encode text as bits in one of several modes, and can use multiple modes - * in one Data Matrix Code. This class decodes the bits back into text.

- * - *

See ISO 16022:2006, 5.2.1 - 5.2.9.2

- * - * @author bbrown@google.com (Brian Brown) - * @author Sean Owen - */ -final class DecodedBitStreamParser { - - private enum Mode { - PAD_ENCODE, // Not really a mode - ASCII_ENCODE, - C40_ENCODE, - TEXT_ENCODE, - ANSIX12_ENCODE, - EDIFACT_ENCODE, - BASE256_ENCODE, - ECI_ENCODE - } - - /** - * See ISO 16022:2006, Annex C Table C.1 - * The C40 Basic Character Set (*'s used for placeholders for the shift values) - */ - private static final char[] C40_BASIC_SET_CHARS = { - '*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' - }; - - private static final char[] C40_SHIFT2_SET_CHARS = { - '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', - '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_' - }; - - /** - * See ISO 16022:2006, Annex C Table C.2 - * The Text Basic Character Set (*'s used for placeholders for the shift values) - */ - private static final char[] TEXT_BASIC_SET_CHARS = { - '*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' - }; - - // Shift 2 for Text is the same encoding as C40 - private static final char[] TEXT_SHIFT2_SET_CHARS = C40_SHIFT2_SET_CHARS; - - private static final char[] TEXT_SHIFT3_SET_CHARS = { - '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', (char) 127 - }; - - private DecodedBitStreamParser() { - } - - static DecoderResult decode(byte[] bytes) throws FormatException { - BitSource bits = new BitSource(bytes); - ECIStringBuilder result = new ECIStringBuilder(100); - StringBuilder resultTrailer = new StringBuilder(0); - List byteSegments = new ArrayList<>(1); - Mode mode = Mode.ASCII_ENCODE; - // Could look directly at 'bytes', if we're sure of not having to account for multi byte values - Set fnc1Positions = new HashSet<>(); - int symbologyModifier; - boolean isECIencoded = false; - do { - if (mode == Mode.ASCII_ENCODE) { - mode = decodeAsciiSegment(bits, result, resultTrailer, fnc1Positions); - } else { - switch (mode) { - case C40_ENCODE: - decodeC40Segment(bits, result, fnc1Positions); - break; - case TEXT_ENCODE: - decodeTextSegment(bits, result, fnc1Positions); - break; - case ANSIX12_ENCODE: - decodeAnsiX12Segment(bits, result); - break; - case EDIFACT_ENCODE: - decodeEdifactSegment(bits, result); - break; - case BASE256_ENCODE: - decodeBase256Segment(bits, result, byteSegments); - break; - case ECI_ENCODE: - decodeECISegment(bits, result); - isECIencoded = true; // ECI detection only, atm continue decoding as ASCII - break; - default: - throw FormatException.getFormatInstance(); - } - mode = Mode.ASCII_ENCODE; - } - } while (mode != Mode.PAD_ENCODE && bits.available() > 0); - if (resultTrailer.length() > 0) { - result.appendCharacters(resultTrailer); - } - if (isECIencoded) { - // Examples for this numbers can be found in this documentation of a hardware barcode scanner: - // https://honeywellaidc.force.com/supportppr/s/article/List-of-barcode-symbology-AIM-Identifiers - if (fnc1Positions.contains(0) || fnc1Positions.contains(4)) { - symbologyModifier = 5; - } else if (fnc1Positions.contains(1) || fnc1Positions.contains(5)) { - symbologyModifier = 6; - } else { - symbologyModifier = 4; - } - } else { - if (fnc1Positions.contains(0) || fnc1Positions.contains(4)) { - symbologyModifier = 2; - } else if (fnc1Positions.contains(1) || fnc1Positions.contains(5)) { - symbologyModifier = 3; - } else { - symbologyModifier = 1; - } - } - - return new DecoderResult(bytes, - result.toString(), - byteSegments.isEmpty() ? null : byteSegments, - null, - symbologyModifier); - } - - /** - * See ISO 16022:2006, 5.2.3 and Annex C, Table C.2 - */ - private static Mode decodeAsciiSegment(BitSource bits, - ECIStringBuilder result, - StringBuilder resultTrailer, - Set fnc1positions) throws FormatException { - boolean upperShift = false; - do { - int oneByte = bits.readBits(8); - if (oneByte == 0) { - throw FormatException.getFormatInstance(); - } else if (oneByte <= 128) { // ASCII data (ASCII value + 1) - if (upperShift) { - oneByte += 128; - //upperShift = false; - } - result.append((char) (oneByte - 1)); - return Mode.ASCII_ENCODE; - } else if (oneByte == 129) { // Pad - return Mode.PAD_ENCODE; - } else if (oneByte <= 229) { // 2-digit data 00-99 (Numeric Value + 130) - int value = oneByte - 130; - if (value < 10) { // pad with '0' for single digit values - result.append('0'); - } - result.append(value); - } else { - switch (oneByte) { - case 230: // Latch to C40 encodation - return Mode.C40_ENCODE; - case 231: // Latch to Base 256 encodation - return Mode.BASE256_ENCODE; - case 232: // FNC1 - fnc1positions.add(result.length()); - result.append((char) 29); // translate as ASCII 29 - break; - case 233: // Structured Append - case 234: // Reader Programming - // Ignore these symbols for now - //throw ReaderException.getInstance(); - break; - case 235: // Upper Shift (shift to Extended ASCII) - upperShift = true; - break; - case 236: // 05 Macro - result.append("[)>\u001E05\u001D"); - resultTrailer.insert(0, "\u001E\u0004"); - break; - case 237: // 06 Macro - result.append("[)>\u001E06\u001D"); - resultTrailer.insert(0, "\u001E\u0004"); - break; - case 238: // Latch to ANSI X12 encodation - return Mode.ANSIX12_ENCODE; - case 239: // Latch to Text encodation - return Mode.TEXT_ENCODE; - case 240: // Latch to EDIFACT encodation - return Mode.EDIFACT_ENCODE; - case 241: // ECI Character - return Mode.ECI_ENCODE; - default: - // Not to be used in ASCII encodation - // but work around encoders that end with 254, latch back to ASCII - if (oneByte != 254 || bits.available() != 0) { - throw FormatException.getFormatInstance(); - } - break; - } - } - } while (bits.available() > 0); - return Mode.ASCII_ENCODE; - } - - /** - * See ISO 16022:2006, 5.2.5 and Annex C, Table C.1 - */ - private static void decodeC40Segment(BitSource bits, ECIStringBuilder result, Set fnc1positions) - throws FormatException { - // Three C40 values are encoded in a 16-bit value as - // (1600 * C1) + (40 * C2) + C3 + 1 - // TODO(bbrown): The Upper Shift with C40 doesn't work in the 4 value scenario all the time - boolean upperShift = false; - - int[] cValues = new int[3]; - int shift = 0; - - do { - // If there is only one byte left then it will be encoded as ASCII - if (bits.available() == 8) { - return; - } - int firstByte = bits.readBits(8); - if (firstByte == 254) { // Unlatch codeword - return; - } - - parseTwoBytes(firstByte, bits.readBits(8), cValues); - - for (int i = 0; i < 3; i++) { - int cValue = cValues[i]; - switch (shift) { - case 0: - if (cValue < 3) { - shift = cValue + 1; - } else if (cValue < C40_BASIC_SET_CHARS.length) { - char c40char = C40_BASIC_SET_CHARS[cValue]; - if (upperShift) { - result.append((char) (c40char + 128)); - upperShift = false; - } else { - result.append(c40char); - } - } else { - throw FormatException.getFormatInstance(); - } - break; - case 1: - if (upperShift) { - result.append((char) (cValue + 128)); - upperShift = false; - } else { - result.append((char) cValue); - } - shift = 0; - break; - case 2: - if (cValue < C40_SHIFT2_SET_CHARS.length) { - char c40char = C40_SHIFT2_SET_CHARS[cValue]; - if (upperShift) { - result.append((char) (c40char + 128)); - upperShift = false; - } else { - result.append(c40char); - } - } else { - switch (cValue) { - case 27: // FNC1 - fnc1positions.add(result.length()); - result.append((char) 29); // translate as ASCII 29 - break; - case 30: // Upper Shift - upperShift = true; - break; - default: - throw FormatException.getFormatInstance(); - } - } - shift = 0; - break; - case 3: - if (upperShift) { - result.append((char) (cValue + 224)); - upperShift = false; - } else { - result.append((char) (cValue + 96)); - } - shift = 0; - break; - default: - throw FormatException.getFormatInstance(); - } - } - } while (bits.available() > 0); - } - - /** - * See ISO 16022:2006, 5.2.6 and Annex C, Table C.2 - */ - private static void decodeTextSegment(BitSource bits, ECIStringBuilder result, Set fnc1positions) - throws FormatException { - // Three Text values are encoded in a 16-bit value as - // (1600 * C1) + (40 * C2) + C3 + 1 - // TODO(bbrown): The Upper Shift with Text doesn't work in the 4 value scenario all the time - boolean upperShift = false; - - int[] cValues = new int[3]; - int shift = 0; - do { - // If there is only one byte left then it will be encoded as ASCII - if (bits.available() == 8) { - return; - } - int firstByte = bits.readBits(8); - if (firstByte == 254) { // Unlatch codeword - return; - } - - parseTwoBytes(firstByte, bits.readBits(8), cValues); - - for (int i = 0; i < 3; i++) { - int cValue = cValues[i]; - switch (shift) { - case 0: - if (cValue < 3) { - shift = cValue + 1; - } else if (cValue < TEXT_BASIC_SET_CHARS.length) { - char textChar = TEXT_BASIC_SET_CHARS[cValue]; - if (upperShift) { - result.append((char) (textChar + 128)); - upperShift = false; - } else { - result.append(textChar); - } - } else { - throw FormatException.getFormatInstance(); - } - break; - case 1: - if (upperShift) { - result.append((char) (cValue + 128)); - upperShift = false; - } else { - result.append((char) cValue); - } - shift = 0; - break; - case 2: - // Shift 2 for Text is the same encoding as C40 - if (cValue < TEXT_SHIFT2_SET_CHARS.length) { - char textChar = TEXT_SHIFT2_SET_CHARS[cValue]; - if (upperShift) { - result.append((char) (textChar + 128)); - upperShift = false; - } else { - result.append(textChar); - } - } else { - switch (cValue) { - case 27: // FNC1 - fnc1positions.add(result.length()); - result.append((char) 29); // translate as ASCII 29 - break; - case 30: // Upper Shift - upperShift = true; - break; - default: - throw FormatException.getFormatInstance(); - } - } - shift = 0; - break; - case 3: - if (cValue < TEXT_SHIFT3_SET_CHARS.length) { - char textChar = TEXT_SHIFT3_SET_CHARS[cValue]; - if (upperShift) { - result.append((char) (textChar + 128)); - upperShift = false; - } else { - result.append(textChar); - } - shift = 0; - } else { - throw FormatException.getFormatInstance(); - } - break; - default: - throw FormatException.getFormatInstance(); - } - } - } while (bits.available() > 0); - } - - /** - * See ISO 16022:2006, 5.2.7 - */ - private static void decodeAnsiX12Segment(BitSource bits, - ECIStringBuilder result) throws FormatException { - // Three ANSI X12 values are encoded in a 16-bit value as - // (1600 * C1) + (40 * C2) + C3 + 1 - - int[] cValues = new int[3]; - do { - // If there is only one byte left then it will be encoded as ASCII - if (bits.available() == 8) { - return; - } - int firstByte = bits.readBits(8); - if (firstByte == 254) { // Unlatch codeword - return; - } - - parseTwoBytes(firstByte, bits.readBits(8), cValues); - - for (int i = 0; i < 3; i++) { - int cValue = cValues[i]; - switch (cValue) { - case 0: // X12 segment terminator - result.append('\r'); - break; - case 1: // X12 segment separator * - result.append('*'); - break; - case 2: // X12 sub-element separator > - result.append('>'); - break; - case 3: // space - result.append(' '); - break; - default: - if (cValue < 14) { // 0 - 9 - result.append((char) (cValue + 44)); - } else if (cValue < 40) { // A - Z - result.append((char) (cValue + 51)); - } else { - throw FormatException.getFormatInstance(); - } - break; - } - } - } while (bits.available() > 0); - } - - private static void parseTwoBytes(int firstByte, int secondByte, int[] result) { - int fullBitValue = (firstByte << 8) + secondByte - 1; - int temp = fullBitValue / 1600; - result[0] = temp; - fullBitValue -= temp * 1600; - temp = fullBitValue / 40; - result[1] = temp; - result[2] = fullBitValue - temp * 40; - } - - /** - * See ISO 16022:2006, 5.2.8 and Annex C Table C.3 - */ - private static void decodeEdifactSegment(BitSource bits, ECIStringBuilder result) { - do { - // If there is only two or less bytes left then it will be encoded as ASCII - if (bits.available() <= 16) { - return; - } - - for (int i = 0; i < 4; i++) { - int edifactValue = bits.readBits(6); - - // Check for the unlatch character - if (edifactValue == 0x1F) { // 011111 - // Read rest of byte, which should be 0, and stop - int bitsLeft = 8 - bits.getBitOffset(); - if (bitsLeft != 8) { - bits.readBits(bitsLeft); - } - return; - } - - if ((edifactValue & 0x20) == 0) { // no 1 in the leading (6th) bit - edifactValue |= 0x40; // Add a leading 01 to the 6 bit binary value - } - result.append((char) edifactValue); - } - } while (bits.available() > 0); - } - - /** - * See ISO 16022:2006, 5.2.9 and Annex B, B.2 - */ - private static void decodeBase256Segment(BitSource bits, - ECIStringBuilder result, - Collection byteSegments) - throws FormatException { - // Figure out how long the Base 256 Segment is. - int codewordPosition = 1 + bits.getByteOffset(); // position is 1-indexed - int d1 = unrandomize255State(bits.readBits(8), codewordPosition++); - int count; - if (d1 == 0) { // Read the remainder of the symbol - count = bits.available() / 8; - } else if (d1 < 250) { - count = d1; - } else { - count = 250 * (d1 - 249) + unrandomize255State(bits.readBits(8), codewordPosition++); - } - - // We're seeing NegativeArraySizeException errors from users. - if (count < 0) { - throw FormatException.getFormatInstance(); - } - - byte[] bytes = new byte[count]; - for (int i = 0; i < count; i++) { - // Have seen this particular error in the wild, such as at - // http://www.bcgen.com/demo/IDAutomationStreamingDataMatrix.aspx?MODE=3&D=Fred&PFMT=3&PT=F&X=0.3&O=0&LM=0.2 - if (bits.available() < 8) { - throw FormatException.getFormatInstance(); - } - bytes[i] = (byte) unrandomize255State(bits.readBits(8), codewordPosition++); - } - byteSegments.add(bytes); - result.append(new String(bytes, StandardCharsets.ISO_8859_1)); - } - - /** - * See ISO 16022:2007, 5.4.1 - */ - private static void decodeECISegment(BitSource bits, - ECIStringBuilder result) - throws FormatException { - if (bits.available() < 8) { - throw FormatException.getFormatInstance(); - } - int c1 = bits.readBits(8); - if (c1 <= 127) { - result.appendECI(c1 - 1); - } - //currently we only support character set ECIs - /*} else { - if (bits.available() < 8) { - throw FormatException.getFormatInstance(); - } - int c2 = bits.readBits(8); - if (c1 >= 128 && c1 <= 191) { - } else { - if (bits.available() < 8) { - throw FormatException.getFormatInstance(); - } - int c3 = bits.readBits(8); - } - }*/ - } - - - /** - * See ISO 16022:2006, Annex B, B.2 - */ - private static int unrandomize255State(int randomizedBase256Codeword, - int base256CodewordPosition) { - int pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1; - int tempVariable = randomizedBase256Codeword - pseudoRandomNumber; - return tempVariable >= 0 ? tempVariable : tempVariable + 256; - } - -} diff --git a/port_src/core/DONE/datamatrix/decoder/Decoder.java b/port_src/core/DONE/datamatrix/decoder/Decoder.java deleted file mode 100644 index 8711e70..0000000 --- a/port_src/core/DONE/datamatrix/decoder/Decoder.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.decoder; - -import com.google.zxing.ChecksumException; -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.reedsolomon.GenericGF; -import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; -import com.google.zxing.common.reedsolomon.ReedSolomonException; - -/** - *

The main class which implements Data Matrix Code decoding -- as opposed to locating and extracting - * the Data Matrix Code from an image.

- * - * @author bbrown@google.com (Brian Brown) - */ -public final class Decoder { - - private final ReedSolomonDecoder rsDecoder; - - public Decoder() { - rsDecoder = new ReedSolomonDecoder(GenericGF.DATA_MATRIX_FIELD_256); - } - - /** - *

Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans. - * "true" is taken to mean a black module.

- * - * @param image booleans representing white/black Data Matrix Code modules - * @return text and bytes encoded within the Data Matrix Code - * @throws FormatException if the Data Matrix Code cannot be decoded - * @throws ChecksumException if error correction fails - */ - public DecoderResult decode(boolean[][] image) throws FormatException, ChecksumException { - return decode(BitMatrix.parse(image)); - } - - /** - *

Decodes a Data Matrix Code represented as a {@link BitMatrix}. A 1 or "true" is taken - * to mean a black module.

- * - * @param bits booleans representing white/black Data Matrix Code modules - * @return text and bytes encoded within the Data Matrix Code - * @throws FormatException if the Data Matrix Code cannot be decoded - * @throws ChecksumException if error correction fails - */ - public DecoderResult decode(BitMatrix bits) throws FormatException, ChecksumException { - - // Construct a parser and read version, error-correction level - BitMatrixParser parser = new BitMatrixParser(bits); - Version version = parser.getVersion(); - - // Read codewords - byte[] codewords = parser.readCodewords(); - // Separate into data blocks - DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version); - - // Count total number of data bytes - int totalBytes = 0; - for (DataBlock db : dataBlocks) { - totalBytes += db.getNumDataCodewords(); - } - byte[] resultBytes = new byte[totalBytes]; - - int dataBlocksCount = dataBlocks.length; - // Error-correct and copy data blocks together into a stream of bytes - for (int j = 0; j < dataBlocksCount; j++) { - DataBlock dataBlock = dataBlocks[j]; - byte[] codewordBytes = dataBlock.getCodewords(); - int numDataCodewords = dataBlock.getNumDataCodewords(); - correctErrors(codewordBytes, numDataCodewords); - for (int i = 0; i < numDataCodewords; i++) { - // De-interlace data blocks. - resultBytes[i * dataBlocksCount + j] = codewordBytes[i]; - } - } - - // Decode the contents of that stream of bytes - return DecodedBitStreamParser.decode(resultBytes); - } - - /** - *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to - * correct the errors in-place using Reed-Solomon error correction.

- * - * @param codewordBytes data and error correction codewords - * @param numDataCodewords number of codewords that are data bytes - * @throws ChecksumException if error correction fails - */ - private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException { - int numCodewords = codewordBytes.length; - // First read into an array of ints - int[] codewordsInts = new int[numCodewords]; - for (int i = 0; i < numCodewords; i++) { - codewordsInts[i] = codewordBytes[i] & 0xFF; - } - try { - rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords); - } catch (ReedSolomonException ignored) { - throw ChecksumException.getChecksumInstance(); - } - // Copy back into array of bytes -- only need to worry about the bytes that were data - // We don't care about errors in the error-correction codewords - for (int i = 0; i < numDataCodewords; i++) { - codewordBytes[i] = (byte) codewordsInts[i]; - } - } - -} diff --git a/port_src/core/DONE/datamatrix/decoder/Version.java b/port_src/core/DONE/datamatrix/decoder/Version.java deleted file mode 100644 index 2a13326..0000000 --- a/port_src/core/DONE/datamatrix/decoder/Version.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.decoder; - -import com.google.zxing.FormatException; - -/** - * The Version object encapsulates attributes about a particular - * size Data Matrix Code. - * - * @author bbrown@google.com (Brian Brown) - */ -public final class Version { - - private static final Version[] VERSIONS = buildVersions(); - - private final int versionNumber; - private final int symbolSizeRows; - private final int symbolSizeColumns; - private final int dataRegionSizeRows; - private final int dataRegionSizeColumns; - private final ECBlocks ecBlocks; - private final int totalCodewords; - - private Version(int versionNumber, - int symbolSizeRows, - int symbolSizeColumns, - int dataRegionSizeRows, - int dataRegionSizeColumns, - ECBlocks ecBlocks) { - this.versionNumber = versionNumber; - this.symbolSizeRows = symbolSizeRows; - this.symbolSizeColumns = symbolSizeColumns; - this.dataRegionSizeRows = dataRegionSizeRows; - this.dataRegionSizeColumns = dataRegionSizeColumns; - this.ecBlocks = ecBlocks; - - // Calculate the total number of codewords - int total = 0; - int ecCodewords = ecBlocks.getECCodewords(); - ECB[] ecbArray = ecBlocks.getECBlocks(); - for (ECB ecBlock : ecbArray) { - total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords); - } - this.totalCodewords = total; - } - - public int getVersionNumber() { - return versionNumber; - } - - public int getSymbolSizeRows() { - return symbolSizeRows; - } - - public int getSymbolSizeColumns() { - return symbolSizeColumns; - } - - public int getDataRegionSizeRows() { - return dataRegionSizeRows; - } - - public int getDataRegionSizeColumns() { - return dataRegionSizeColumns; - } - - public int getTotalCodewords() { - return totalCodewords; - } - - ECBlocks getECBlocks() { - return ecBlocks; - } - - /** - *

Deduces version information from Data Matrix dimensions.

- * - * @param numRows Number of rows in modules - * @param numColumns Number of columns in modules - * @return Version for a Data Matrix Code of those dimensions - * @throws FormatException if dimensions do correspond to a valid Data Matrix size - */ - public static Version getVersionForDimensions(int numRows, int numColumns) throws FormatException { - if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) { - throw FormatException.getFormatInstance(); - } - - for (Version version : VERSIONS) { - if (version.symbolSizeRows == numRows && version.symbolSizeColumns == numColumns) { - return version; - } - } - - throw FormatException.getFormatInstance(); - } - - /** - *

Encapsulates a set of error-correction blocks in one symbol version. Most versions will - * use blocks of differing sizes within one version, so, this encapsulates the parameters for - * each set of blocks. It also holds the number of error-correction codewords per block since it - * will be the same across all blocks within one version.

- */ - static final class ECBlocks { - private final int ecCodewords; - private final ECB[] ecBlocks; - - private ECBlocks(int ecCodewords, ECB ecBlocks) { - this.ecCodewords = ecCodewords; - this.ecBlocks = new ECB[] { ecBlocks }; - } - - private ECBlocks(int ecCodewords, ECB ecBlocks1, ECB ecBlocks2) { - this.ecCodewords = ecCodewords; - this.ecBlocks = new ECB[] { ecBlocks1, ecBlocks2 }; - } - - int getECCodewords() { - return ecCodewords; - } - - ECB[] getECBlocks() { - return ecBlocks; - } - } - - /** - *

Encapsulates the parameters for one error-correction block in one symbol version. - * This includes the number of data codewords, and the number of times a block with these - * parameters is used consecutively in the Data Matrix code version's format.

- */ - static final class ECB { - private final int count; - private final int dataCodewords; - - private ECB(int count, int dataCodewords) { - this.count = count; - this.dataCodewords = dataCodewords; - } - - int getCount() { - return count; - } - - int getDataCodewords() { - return dataCodewords; - } - } - - @Override - public String toString() { - return String.valueOf(versionNumber); - } - - /** - * See ISO 16022:2006 5.5.1 Table 7 - */ - private static Version[] buildVersions() { - return new Version[]{ - new Version(1, 10, 10, 8, 8, - new ECBlocks(5, new ECB(1, 3))), - new Version(2, 12, 12, 10, 10, - new ECBlocks(7, new ECB(1, 5))), - new Version(3, 14, 14, 12, 12, - new ECBlocks(10, new ECB(1, 8))), - new Version(4, 16, 16, 14, 14, - new ECBlocks(12, new ECB(1, 12))), - new Version(5, 18, 18, 16, 16, - new ECBlocks(14, new ECB(1, 18))), - new Version(6, 20, 20, 18, 18, - new ECBlocks(18, new ECB(1, 22))), - new Version(7, 22, 22, 20, 20, - new ECBlocks(20, new ECB(1, 30))), - new Version(8, 24, 24, 22, 22, - new ECBlocks(24, new ECB(1, 36))), - new Version(9, 26, 26, 24, 24, - new ECBlocks(28, new ECB(1, 44))), - new Version(10, 32, 32, 14, 14, - new ECBlocks(36, new ECB(1, 62))), - new Version(11, 36, 36, 16, 16, - new ECBlocks(42, new ECB(1, 86))), - new Version(12, 40, 40, 18, 18, - new ECBlocks(48, new ECB(1, 114))), - new Version(13, 44, 44, 20, 20, - new ECBlocks(56, new ECB(1, 144))), - new Version(14, 48, 48, 22, 22, - new ECBlocks(68, new ECB(1, 174))), - new Version(15, 52, 52, 24, 24, - new ECBlocks(42, new ECB(2, 102))), - new Version(16, 64, 64, 14, 14, - new ECBlocks(56, new ECB(2, 140))), - new Version(17, 72, 72, 16, 16, - new ECBlocks(36, new ECB(4, 92))), - new Version(18, 80, 80, 18, 18, - new ECBlocks(48, new ECB(4, 114))), - new Version(19, 88, 88, 20, 20, - new ECBlocks(56, new ECB(4, 144))), - new Version(20, 96, 96, 22, 22, - new ECBlocks(68, new ECB(4, 174))), - new Version(21, 104, 104, 24, 24, - new ECBlocks(56, new ECB(6, 136))), - new Version(22, 120, 120, 18, 18, - new ECBlocks(68, new ECB(6, 175))), - new Version(23, 132, 132, 20, 20, - new ECBlocks(62, new ECB(8, 163))), - new Version(24, 144, 144, 22, 22, - new ECBlocks(62, new ECB(8, 156), new ECB(2, 155))), - new Version(25, 8, 18, 6, 16, - new ECBlocks(7, new ECB(1, 5))), - new Version(26, 8, 32, 6, 14, - new ECBlocks(11, new ECB(1, 10))), - new Version(27, 12, 26, 10, 24, - new ECBlocks(14, new ECB(1, 16))), - new Version(28, 12, 36, 10, 16, - new ECBlocks(18, new ECB(1, 22))), - new Version(29, 16, 36, 14, 16, - new ECBlocks(24, new ECB(1, 32))), - new Version(30, 16, 48, 14, 22, - new ECBlocks(28, new ECB(1, 49))), - - // extended forms as specified in - // ISO 21471:2020 (DMRE) 5.5.1 Table 7 - new Version(31, 8, 48, 6, 22, - new ECBlocks(15, new ECB(1, 18))), - new Version(32, 8, 64, 6, 14, - new ECBlocks(18, new ECB(1, 24))), - new Version(33, 8, 80, 6, 18, - new ECBlocks(22, new ECB(1, 32))), - new Version(34, 8, 96, 6, 22, - new ECBlocks(28, new ECB(1, 38))), - new Version(35, 8, 120, 6, 18, - new ECBlocks(32, new ECB(1, 49))), - new Version(36, 8, 144, 6, 22, - new ECBlocks(36, new ECB(1, 63))), - new Version(37, 12, 64, 10, 14, - new ECBlocks(27, new ECB(1, 43))), - new Version(38, 12, 88, 10, 20, - new ECBlocks(36, new ECB(1, 64))), - new Version(39, 16, 64, 14, 14, - new ECBlocks(36, new ECB(1, 62))), - new Version(40, 20, 36, 18, 16, - new ECBlocks(28, new ECB(1, 44))), - new Version(41, 20, 44, 18, 20, - new ECBlocks(34, new ECB(1, 56))), - new Version(42, 20, 64, 18, 14, - new ECBlocks(42, new ECB(1, 84))), - new Version(43, 22, 48, 20, 22, - new ECBlocks(38, new ECB(1, 72))), - new Version(44, 24, 48, 22, 22, - new ECBlocks(41, new ECB(1, 80))), - new Version(45, 24, 64, 22, 14, - new ECBlocks(46, new ECB(1, 108))), - new Version(46, 26, 40, 24, 18, - new ECBlocks(38, new ECB(1, 70))), - new Version(47, 26, 48, 24, 22, - new ECBlocks(42, new ECB(1, 90))), - new Version(48, 26, 64, 24, 14, - new ECBlocks(50, new ECB(1, 118))) - }; - } - -} diff --git a/port_src/core/DONE/datamatrix/detector/Detector.java b/port_src/core/DONE/datamatrix/detector/Detector.java deleted file mode 100644 index 283ca7c..0000000 --- a/port_src/core/DONE/datamatrix/detector/Detector.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.detector; - -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DetectorResult; -import com.google.zxing.common.GridSampler; -import com.google.zxing.common.detector.WhiteRectangleDetector; - -/** - *

Encapsulates logic that can detect a Data Matrix Code in an image, even if the Data Matrix Code - * is rotated or skewed, or partially obscured.

- * - * @author Sean Owen - */ -public final class Detector { - - private final BitMatrix image; - private final WhiteRectangleDetector rectangleDetector; - - public Detector(BitMatrix image) throws NotFoundException { - this.image = image; - rectangleDetector = new WhiteRectangleDetector(image); - } - - /** - *

Detects a Data Matrix Code in an image.

- * - * @return {@link DetectorResult} encapsulating results of detecting a Data Matrix Code - * @throws NotFoundException if no Data Matrix Code can be found - */ - public DetectorResult detect() throws NotFoundException { - - ResultPoint[] cornerPoints = rectangleDetector.detect(); - - ResultPoint[] points = detectSolid1(cornerPoints); - points = detectSolid2(points); - points[3] = correctTopRight(points); - if (points[3] == null) { - throw NotFoundException.getNotFoundInstance(); - } - points = shiftToModuleCenter(points); - - ResultPoint topLeft = points[0]; - ResultPoint bottomLeft = points[1]; - ResultPoint bottomRight = points[2]; - ResultPoint topRight = points[3]; - - int dimensionTop = transitionsBetween(topLeft, topRight) + 1; - int dimensionRight = transitionsBetween(bottomRight, topRight) + 1; - if ((dimensionTop & 0x01) == 1) { - dimensionTop += 1; - } - if ((dimensionRight & 0x01) == 1) { - dimensionRight += 1; - } - - if (4 * dimensionTop < 6 * dimensionRight && 4 * dimensionRight < 6 * dimensionTop) { - // The matrix is square - dimensionTop = dimensionRight = Math.max(dimensionTop, dimensionRight); - } - - BitMatrix bits = sampleGrid(image, - topLeft, - bottomLeft, - bottomRight, - topRight, - dimensionTop, - dimensionRight); - - return new DetectorResult(bits, new ResultPoint[]{topLeft, bottomLeft, bottomRight, topRight}); - } - - private static ResultPoint shiftPoint(ResultPoint point, ResultPoint to, int div) { - float x = (to.getX() - point.getX()) / (div + 1); - float y = (to.getY() - point.getY()) / (div + 1); - return new ResultPoint(point.getX() + x, point.getY() + y); - } - - private static ResultPoint moveAway(ResultPoint point, float fromX, float fromY) { - float x = point.getX(); - float y = point.getY(); - - if (x < fromX) { - x -= 1; - } else { - x += 1; - } - - if (y < fromY) { - y -= 1; - } else { - y += 1; - } - - return new ResultPoint(x, y); - } - - /** - * Detect a solid side which has minimum transition. - */ - private ResultPoint[] detectSolid1(ResultPoint[] cornerPoints) { - // 0 2 - // 1 3 - ResultPoint pointA = cornerPoints[0]; - ResultPoint pointB = cornerPoints[1]; - ResultPoint pointC = cornerPoints[3]; - ResultPoint pointD = cornerPoints[2]; - - int trAB = transitionsBetween(pointA, pointB); - int trBC = transitionsBetween(pointB, pointC); - int trCD = transitionsBetween(pointC, pointD); - int trDA = transitionsBetween(pointD, pointA); - - // 0..3 - // : : - // 1--2 - int min = trAB; - ResultPoint[] points = {pointD, pointA, pointB, pointC}; - if (min > trBC) { - min = trBC; - points[0] = pointA; - points[1] = pointB; - points[2] = pointC; - points[3] = pointD; - } - if (min > trCD) { - min = trCD; - points[0] = pointB; - points[1] = pointC; - points[2] = pointD; - points[3] = pointA; - } - if (min > trDA) { - points[0] = pointC; - points[1] = pointD; - points[2] = pointA; - points[3] = pointB; - } - - return points; - } - - /** - * Detect a second solid side next to first solid side. - */ - private ResultPoint[] detectSolid2(ResultPoint[] points) { - // A..D - // : : - // B--C - ResultPoint pointA = points[0]; - ResultPoint pointB = points[1]; - ResultPoint pointC = points[2]; - ResultPoint pointD = points[3]; - - // Transition detection on the edge is not stable. - // To safely detect, shift the points to the module center. - int tr = transitionsBetween(pointA, pointD); - ResultPoint pointBs = shiftPoint(pointB, pointC, (tr + 1) * 4); - ResultPoint pointCs = shiftPoint(pointC, pointB, (tr + 1) * 4); - int trBA = transitionsBetween(pointBs, pointA); - int trCD = transitionsBetween(pointCs, pointD); - - // 0..3 - // | : - // 1--2 - if (trBA < trCD) { - // solid sides: A-B-C - points[0] = pointA; - points[1] = pointB; - points[2] = pointC; - points[3] = pointD; - } else { - // solid sides: B-C-D - points[0] = pointB; - points[1] = pointC; - points[2] = pointD; - points[3] = pointA; - } - - return points; - } - - /** - * Calculates the corner position of the white top right module. - */ - private ResultPoint correctTopRight(ResultPoint[] points) { - // A..D - // | : - // B--C - ResultPoint pointA = points[0]; - ResultPoint pointB = points[1]; - ResultPoint pointC = points[2]; - ResultPoint pointD = points[3]; - - // shift points for safe transition detection. - int trTop = transitionsBetween(pointA, pointD); - int trRight = transitionsBetween(pointB, pointD); - ResultPoint pointAs = shiftPoint(pointA, pointB, (trRight + 1) * 4); - ResultPoint pointCs = shiftPoint(pointC, pointB, (trTop + 1) * 4); - - trTop = transitionsBetween(pointAs, pointD); - trRight = transitionsBetween(pointCs, pointD); - - ResultPoint candidate1 = new ResultPoint( - pointD.getX() + (pointC.getX() - pointB.getX()) / (trTop + 1), - pointD.getY() + (pointC.getY() - pointB.getY()) / (trTop + 1)); - ResultPoint candidate2 = new ResultPoint( - pointD.getX() + (pointA.getX() - pointB.getX()) / (trRight + 1), - pointD.getY() + (pointA.getY() - pointB.getY()) / (trRight + 1)); - - if (!isValid(candidate1)) { - if (isValid(candidate2)) { - return candidate2; - } - return null; - } - if (!isValid(candidate2)) { - return candidate1; - } - - int sumc1 = transitionsBetween(pointAs, candidate1) + transitionsBetween(pointCs, candidate1); - int sumc2 = transitionsBetween(pointAs, candidate2) + transitionsBetween(pointCs, candidate2); - - if (sumc1 > sumc2) { - return candidate1; - } else { - return candidate2; - } - } - - /** - * Shift the edge points to the module center. - */ - private ResultPoint[] shiftToModuleCenter(ResultPoint[] points) { - // A..D - // | : - // B--C - ResultPoint pointA = points[0]; - ResultPoint pointB = points[1]; - ResultPoint pointC = points[2]; - ResultPoint pointD = points[3]; - - // calculate pseudo dimensions - int dimH = transitionsBetween(pointA, pointD) + 1; - int dimV = transitionsBetween(pointC, pointD) + 1; - - // shift points for safe dimension detection - ResultPoint pointAs = shiftPoint(pointA, pointB, dimV * 4); - ResultPoint pointCs = shiftPoint(pointC, pointB, dimH * 4); - - // calculate more precise dimensions - dimH = transitionsBetween(pointAs, pointD) + 1; - dimV = transitionsBetween(pointCs, pointD) + 1; - if ((dimH & 0x01) == 1) { - dimH += 1; - } - if ((dimV & 0x01) == 1) { - dimV += 1; - } - - // WhiteRectangleDetector returns points inside of the rectangle. - // I want points on the edges. - float centerX = (pointA.getX() + pointB.getX() + pointC.getX() + pointD.getX()) / 4; - float centerY = (pointA.getY() + pointB.getY() + pointC.getY() + pointD.getY()) / 4; - pointA = moveAway(pointA, centerX, centerY); - pointB = moveAway(pointB, centerX, centerY); - pointC = moveAway(pointC, centerX, centerY); - pointD = moveAway(pointD, centerX, centerY); - - ResultPoint pointBs; - ResultPoint pointDs; - - // shift points to the center of each modules - pointAs = shiftPoint(pointA, pointB, dimV * 4); - pointAs = shiftPoint(pointAs, pointD, dimH * 4); - pointBs = shiftPoint(pointB, pointA, dimV * 4); - pointBs = shiftPoint(pointBs, pointC, dimH * 4); - pointCs = shiftPoint(pointC, pointD, dimV * 4); - pointCs = shiftPoint(pointCs, pointB, dimH * 4); - pointDs = shiftPoint(pointD, pointC, dimV * 4); - pointDs = shiftPoint(pointDs, pointA, dimH * 4); - - return new ResultPoint[]{pointAs, pointBs, pointCs, pointDs}; - } - - private boolean isValid(ResultPoint p) { - return p.getX() >= 0 && p.getX() <= image.getWidth() - 1 && p.getY() > 0 && p.getY() <= image.getHeight() - 1; - } - - private static BitMatrix sampleGrid(BitMatrix image, - ResultPoint topLeft, - ResultPoint bottomLeft, - ResultPoint bottomRight, - ResultPoint topRight, - int dimensionX, - int dimensionY) throws NotFoundException { - - GridSampler sampler = GridSampler.getInstance(); - - return sampler.sampleGrid(image, - dimensionX, - dimensionY, - 0.5f, - 0.5f, - dimensionX - 0.5f, - 0.5f, - dimensionX - 0.5f, - dimensionY - 0.5f, - 0.5f, - dimensionY - 0.5f, - topLeft.getX(), - topLeft.getY(), - topRight.getX(), - topRight.getY(), - bottomRight.getX(), - bottomRight.getY(), - bottomLeft.getX(), - bottomLeft.getY()); - } - - /** - * Counts the number of black/white transitions between two points, using something like Bresenham's algorithm. - */ - private int transitionsBetween(ResultPoint from, ResultPoint to) { - // See QR Code Detector, sizeOfBlackWhiteBlackRun() - int fromX = (int) from.getX(); - int fromY = (int) from.getY(); - int toX = (int) to.getX(); - int toY = Math.min(image.getHeight() - 1, (int) to.getY()); - - boolean steep = Math.abs(toY - fromY) > Math.abs(toX - fromX); - if (steep) { - int temp = fromX; - fromX = fromY; - fromY = temp; - temp = toX; - toX = toY; - toY = temp; - } - - int dx = Math.abs(toX - fromX); - int dy = Math.abs(toY - fromY); - int error = -dx / 2; - int ystep = fromY < toY ? 1 : -1; - int xstep = fromX < toX ? 1 : -1; - int transitions = 0; - boolean inBlack = image.get(steep ? fromY : fromX, steep ? fromX : fromY); - for (int x = fromX, y = fromY; x != toX; x += xstep) { - boolean isBlack = image.get(steep ? y : x, steep ? x : y); - if (isBlack != inBlack) { - transitions++; - inBlack = isBlack; - } - error += dy; - if (error > 0) { - if (y == toY) { - break; - } - y += ystep; - error -= dx; - } - } - return transitions; - } - -} diff --git a/port_src/core/DONE/datamatrix/encoder/ASCIIEncoder.java b/port_src/core/DONE/datamatrix/encoder/ASCIIEncoder.java deleted file mode 100644 index 866c3fe..0000000 --- a/port_src/core/DONE/datamatrix/encoder/ASCIIEncoder.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -final class ASCIIEncoder implements Encoder { - - @Override - public int getEncodingMode() { - return HighLevelEncoder.ASCII_ENCODATION; - } - - @Override - public void encode(EncoderContext context) { - //step B - int n = HighLevelEncoder.determineConsecutiveDigitCount(context.getMessage(), context.pos); - if (n >= 2) { - context.writeCodeword(encodeASCIIDigits(context.getMessage().charAt(context.pos), - context.getMessage().charAt(context.pos + 1))); - context.pos += 2; - } else { - char c = context.getCurrentChar(); - int newMode = HighLevelEncoder.lookAheadTest(context.getMessage(), context.pos, getEncodingMode()); - if (newMode != getEncodingMode()) { - switch (newMode) { - case HighLevelEncoder.BASE256_ENCODATION: - context.writeCodeword(HighLevelEncoder.LATCH_TO_BASE256); - context.signalEncoderChange(HighLevelEncoder.BASE256_ENCODATION); - return; - case HighLevelEncoder.C40_ENCODATION: - context.writeCodeword(HighLevelEncoder.LATCH_TO_C40); - context.signalEncoderChange(HighLevelEncoder.C40_ENCODATION); - return; - case HighLevelEncoder.X12_ENCODATION: - context.writeCodeword(HighLevelEncoder.LATCH_TO_ANSIX12); - context.signalEncoderChange(HighLevelEncoder.X12_ENCODATION); - break; - case HighLevelEncoder.TEXT_ENCODATION: - context.writeCodeword(HighLevelEncoder.LATCH_TO_TEXT); - context.signalEncoderChange(HighLevelEncoder.TEXT_ENCODATION); - break; - case HighLevelEncoder.EDIFACT_ENCODATION: - context.writeCodeword(HighLevelEncoder.LATCH_TO_EDIFACT); - context.signalEncoderChange(HighLevelEncoder.EDIFACT_ENCODATION); - break; - default: - throw new IllegalStateException("Illegal mode: " + newMode); - } - } else if (HighLevelEncoder.isExtendedASCII(c)) { - context.writeCodeword(HighLevelEncoder.UPPER_SHIFT); - context.writeCodeword((char) (c - 128 + 1)); - context.pos++; - } else { - context.writeCodeword((char) (c + 1)); - context.pos++; - } - - } - } - - private static char encodeASCIIDigits(char digit1, char digit2) { - if (HighLevelEncoder.isDigit(digit1) && HighLevelEncoder.isDigit(digit2)) { - int num = (digit1 - 48) * 10 + (digit2 - 48); - return (char) (num + 130); - } - throw new IllegalArgumentException("not digits: " + digit1 + digit2); - } - -} diff --git a/port_src/core/DONE/datamatrix/encoder/Base256Encoder.java b/port_src/core/DONE/datamatrix/encoder/Base256Encoder.java deleted file mode 100644 index a0f91de..0000000 --- a/port_src/core/DONE/datamatrix/encoder/Base256Encoder.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -final class Base256Encoder implements Encoder { - - @Override - public int getEncodingMode() { - return HighLevelEncoder.BASE256_ENCODATION; - } - - @Override - public void encode(EncoderContext context) { - StringBuilder buffer = new StringBuilder(); - buffer.append('\0'); //Initialize length field - while (context.hasMoreCharacters()) { - char c = context.getCurrentChar(); - buffer.append(c); - - context.pos++; - - int newMode = HighLevelEncoder.lookAheadTest(context.getMessage(), context.pos, getEncodingMode()); - if (newMode != getEncodingMode()) { - // Return to ASCII encodation, which will actually handle latch to new mode - context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION); - break; - } - } - int dataCount = buffer.length() - 1; - int lengthFieldSize = 1; - int currentSize = context.getCodewordCount() + dataCount + lengthFieldSize; - context.updateSymbolInfo(currentSize); - boolean mustPad = (context.getSymbolInfo().getDataCapacity() - currentSize) > 0; - if (context.hasMoreCharacters() || mustPad) { - if (dataCount <= 249) { - buffer.setCharAt(0, (char) dataCount); - } else if (dataCount <= 1555) { - buffer.setCharAt(0, (char) ((dataCount / 250) + 249)); - buffer.insert(1, (char) (dataCount % 250)); - } else { - throw new IllegalStateException( - "Message length not in valid ranges: " + dataCount); - } - } - for (int i = 0, c = buffer.length(); i < c; i++) { - context.writeCodeword(randomize255State( - buffer.charAt(i), context.getCodewordCount() + 1)); - } - } - - private static char randomize255State(char ch, int codewordPosition) { - int pseudoRandom = ((149 * codewordPosition) % 255) + 1; - int tempVariable = ch + pseudoRandom; - if (tempVariable <= 255) { - return (char) tempVariable; - } else { - return (char) (tempVariable - 256); - } - } - -} diff --git a/port_src/core/DONE/datamatrix/encoder/C40Encoder.java b/port_src/core/DONE/datamatrix/encoder/C40Encoder.java deleted file mode 100644 index 1194bdd..0000000 --- a/port_src/core/DONE/datamatrix/encoder/C40Encoder.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -class C40Encoder implements Encoder { - - @Override - public int getEncodingMode() { - return HighLevelEncoder.C40_ENCODATION; - } - - void encodeMaximal(EncoderContext context) { - StringBuilder buffer = new StringBuilder(); - int lastCharSize = 0; - int backtrackStartPosition = context.pos; - int backtrackBufferLength = 0; - while (context.hasMoreCharacters()) { - char c = context.getCurrentChar(); - context.pos++; - lastCharSize = encodeChar(c, buffer); - if (buffer.length() % 3 == 0) { - backtrackStartPosition = context.pos; - backtrackBufferLength = buffer.length(); - } - } - if (backtrackBufferLength != buffer.length()) { - int unwritten = (buffer.length() / 3) * 2; - - int curCodewordCount = context.getCodewordCount() + unwritten + 1; // +1 for the latch to C40 - context.updateSymbolInfo(curCodewordCount); - int available = context.getSymbolInfo().getDataCapacity() - curCodewordCount; - int rest = buffer.length() % 3; - if ((rest == 2 && available != 2) || - (rest == 1 && (lastCharSize > 3 || available != 1))) { - buffer.setLength(backtrackBufferLength); - context.pos = backtrackStartPosition; - } - } - if (buffer.length() > 0) { - context.writeCodeword(HighLevelEncoder.LATCH_TO_C40); - } - - handleEOD(context, buffer); - } - - @Override - public void encode(EncoderContext context) { - //step C - StringBuilder buffer = new StringBuilder(); - while (context.hasMoreCharacters()) { - char c = context.getCurrentChar(); - context.pos++; - - int lastCharSize = encodeChar(c, buffer); - - int unwritten = (buffer.length() / 3) * 2; - - int curCodewordCount = context.getCodewordCount() + unwritten; - context.updateSymbolInfo(curCodewordCount); - int available = context.getSymbolInfo().getDataCapacity() - curCodewordCount; - - if (!context.hasMoreCharacters()) { - //Avoid having a single C40 value in the last triplet - StringBuilder removed = new StringBuilder(); - if ((buffer.length() % 3) == 2 && available != 2) { - lastCharSize = backtrackOneCharacter(context, buffer, removed, lastCharSize); - } - while ((buffer.length() % 3) == 1 && (lastCharSize > 3 || available != 1)) { - lastCharSize = backtrackOneCharacter(context, buffer, removed, lastCharSize); - } - break; - } - - int count = buffer.length(); - if ((count % 3) == 0) { - int newMode = HighLevelEncoder.lookAheadTest(context.getMessage(), context.pos, getEncodingMode()); - if (newMode != getEncodingMode()) { - // Return to ASCII encodation, which will actually handle latch to new mode - context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION); - break; - } - } - } - handleEOD(context, buffer); - } - - private int backtrackOneCharacter(EncoderContext context, - StringBuilder buffer, StringBuilder removed, int lastCharSize) { - int count = buffer.length(); - buffer.delete(count - lastCharSize, count); - context.pos--; - char c = context.getCurrentChar(); - lastCharSize = encodeChar(c, removed); - context.resetSymbolInfo(); //Deal with possible reduction in symbol size - return lastCharSize; - } - - static void writeNextTriplet(EncoderContext context, StringBuilder buffer) { - context.writeCodewords(encodeToCodewords(buffer)); - buffer.delete(0, 3); - } - - /** - * Handle "end of data" situations - * - * @param context the encoder context - * @param buffer the buffer with the remaining encoded characters - */ - void handleEOD(EncoderContext context, StringBuilder buffer) { - int unwritten = (buffer.length() / 3) * 2; - int rest = buffer.length() % 3; - - int curCodewordCount = context.getCodewordCount() + unwritten; - context.updateSymbolInfo(curCodewordCount); - int available = context.getSymbolInfo().getDataCapacity() - curCodewordCount; - - if (rest == 2) { - buffer.append('\0'); //Shift 1 - while (buffer.length() >= 3) { - writeNextTriplet(context, buffer); - } - if (context.hasMoreCharacters()) { - context.writeCodeword(HighLevelEncoder.C40_UNLATCH); - } - } else if (available == 1 && rest == 1) { - while (buffer.length() >= 3) { - writeNextTriplet(context, buffer); - } - if (context.hasMoreCharacters()) { - context.writeCodeword(HighLevelEncoder.C40_UNLATCH); - } - // else no unlatch - context.pos--; - } else if (rest == 0) { - while (buffer.length() >= 3) { - writeNextTriplet(context, buffer); - } - if (available > 0 || context.hasMoreCharacters()) { - context.writeCodeword(HighLevelEncoder.C40_UNLATCH); - } - } else { - throw new IllegalStateException("Unexpected case. Please report!"); - } - context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION); - } - - int encodeChar(char c, StringBuilder sb) { - if (c == ' ') { - sb.append('\3'); - return 1; - } - if (c >= '0' && c <= '9') { - sb.append((char) (c - 48 + 4)); - return 1; - } - if (c >= 'A' && c <= 'Z') { - sb.append((char) (c - 65 + 14)); - return 1; - } - if (c < ' ') { - sb.append('\0'); //Shift 1 Set - sb.append(c); - return 2; - } - if (c <= '/') { - sb.append('\1'); //Shift 2 Set - sb.append((char) (c - 33)); - return 2; - } - if (c <= '@') { - sb.append('\1'); //Shift 2 Set - sb.append((char) (c - 58 + 15)); - return 2; - } - if (c <= '_') { - sb.append('\1'); //Shift 2 Set - sb.append((char) (c - 91 + 22)); - return 2; - } - if (c <= 127) { - sb.append('\2'); //Shift 3 Set - sb.append((char) (c - 96)); - return 2; - } - sb.append("\1\u001e"); //Shift 2, Upper Shift - int len = 2; - len += encodeChar((char) (c - 128), sb); - return len; - } - - private static String encodeToCodewords(CharSequence sb) { - int v = (1600 * sb.charAt(0)) + (40 * sb.charAt(1)) + sb.charAt(2) + 1; - char cw1 = (char) (v / 256); - char cw2 = (char) (v % 256); - return new String(new char[] {cw1, cw2}); - } - -} diff --git a/port_src/core/DONE/datamatrix/encoder/DataMatrixSymbolInfo144.java b/port_src/core/DONE/datamatrix/encoder/DataMatrixSymbolInfo144.java deleted file mode 100644 index 3146353..0000000 --- a/port_src/core/DONE/datamatrix/encoder/DataMatrixSymbolInfo144.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2006 Jeremias Maerki - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -final class DataMatrixSymbolInfo144 extends SymbolInfo { - - DataMatrixSymbolInfo144() { - super(false, 1558, 620, 22, 22, 36, -1, 62); - } - - @Override - public int getInterleavedBlockCount() { - return 10; - } - - @Override - public int getDataLengthForInterleavedBlock(int index) { - return (index <= 8) ? 156 : 155; - } - -} diff --git a/port_src/core/DONE/datamatrix/encoder/DefaultPlacement.java b/port_src/core/DONE/datamatrix/encoder/DefaultPlacement.java deleted file mode 100644 index c80867c..0000000 --- a/port_src/core/DONE/datamatrix/encoder/DefaultPlacement.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright 2006 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -import java.util.Arrays; - -/** - * Symbol Character Placement Program. Adapted from Annex M.1 in ISO/IEC 16022:2000(E). - */ -public class DefaultPlacement { - - private final CharSequence codewords; - private final int numrows; - private final int numcols; - private final byte[] bits; - - /** - * Main constructor - * - * @param codewords the codewords to place - * @param numcols the number of columns - * @param numrows the number of rows - */ - public DefaultPlacement(CharSequence codewords, int numcols, int numrows) { - this.codewords = codewords; - this.numcols = numcols; - this.numrows = numrows; - this.bits = new byte[numcols * numrows]; - Arrays.fill(this.bits, (byte) -1); //Initialize with "not set" value - } - - final int getNumrows() { - return numrows; - } - - final int getNumcols() { - return numcols; - } - - final byte[] getBits() { - return bits; - } - - public final boolean getBit(int col, int row) { - return bits[row * numcols + col] == 1; - } - - private void setBit(int col, int row, boolean bit) { - bits[row * numcols + col] = (byte) (bit ? 1 : 0); - } - - private boolean noBit(int col, int row) { - return bits[row * numcols + col] < 0; - } - - public final void place() { - int pos = 0; - int row = 4; - int col = 0; - - do { - // repeatedly first check for one of the special corner cases, then... - if ((row == numrows) && (col == 0)) { - corner1(pos++); - } - if ((row == numrows - 2) && (col == 0) && ((numcols % 4) != 0)) { - corner2(pos++); - } - if ((row == numrows - 2) && (col == 0) && (numcols % 8 == 4)) { - corner3(pos++); - } - if ((row == numrows + 4) && (col == 2) && ((numcols % 8) == 0)) { - corner4(pos++); - } - // sweep upward diagonally, inserting successive characters... - do { - if ((row < numrows) && (col >= 0) && noBit(col, row)) { - utah(row, col, pos++); - } - row -= 2; - col += 2; - } while (row >= 0 && (col < numcols)); - row++; - col += 3; - - // and then sweep downward diagonally, inserting successive characters, ... - do { - if ((row >= 0) && (col < numcols) && noBit(col, row)) { - utah(row, col, pos++); - } - row += 2; - col -= 2; - } while ((row < numrows) && (col >= 0)); - row += 3; - col++; - - // ...until the entire array is scanned - } while ((row < numrows) || (col < numcols)); - - // Lastly, if the lower right-hand corner is untouched, fill in fixed pattern - if (noBit(numcols - 1, numrows - 1)) { - setBit(numcols - 1, numrows - 1, true); - setBit(numcols - 2, numrows - 2, true); - } - } - - private void module(int row, int col, int pos, int bit) { - if (row < 0) { - row += numrows; - col += 4 - ((numrows + 4) % 8); - } - if (col < 0) { - col += numcols; - row += 4 - ((numcols + 4) % 8); - } - // Note the conversion: - int v = codewords.charAt(pos); - v &= 1 << (8 - bit); - setBit(col, row, v != 0); - } - - /** - * Places the 8 bits of a utah-shaped symbol character in ECC200. - * - * @param row the row - * @param col the column - * @param pos character position - */ - private void utah(int row, int col, int pos) { - module(row - 2, col - 2, pos, 1); - module(row - 2, col - 1, pos, 2); - module(row - 1, col - 2, pos, 3); - module(row - 1, col - 1, pos, 4); - module(row - 1, col, pos, 5); - module(row, col - 2, pos, 6); - module(row, col - 1, pos, 7); - module(row, col, pos, 8); - } - - private void corner1(int pos) { - module(numrows - 1, 0, pos, 1); - module(numrows - 1, 1, pos, 2); - module(numrows - 1, 2, pos, 3); - module(0, numcols - 2, pos, 4); - module(0, numcols - 1, pos, 5); - module(1, numcols - 1, pos, 6); - module(2, numcols - 1, pos, 7); - module(3, numcols - 1, pos, 8); - } - - private void corner2(int pos) { - module(numrows - 3, 0, pos, 1); - module(numrows - 2, 0, pos, 2); - module(numrows - 1, 0, pos, 3); - module(0, numcols - 4, pos, 4); - module(0, numcols - 3, pos, 5); - module(0, numcols - 2, pos, 6); - module(0, numcols - 1, pos, 7); - module(1, numcols - 1, pos, 8); - } - - private void corner3(int pos) { - module(numrows - 3, 0, pos, 1); - module(numrows - 2, 0, pos, 2); - module(numrows - 1, 0, pos, 3); - module(0, numcols - 2, pos, 4); - module(0, numcols - 1, pos, 5); - module(1, numcols - 1, pos, 6); - module(2, numcols - 1, pos, 7); - module(3, numcols - 1, pos, 8); - } - - private void corner4(int pos) { - module(numrows - 1, 0, pos, 1); - module(numrows - 1, numcols - 1, pos, 2); - module(0, numcols - 3, pos, 3); - module(0, numcols - 2, pos, 4); - module(0, numcols - 1, pos, 5); - module(1, numcols - 3, pos, 6); - module(1, numcols - 2, pos, 7); - module(1, numcols - 1, pos, 8); - } - -} diff --git a/port_src/core/DONE/datamatrix/encoder/EdifactEncoder.java b/port_src/core/DONE/datamatrix/encoder/EdifactEncoder.java deleted file mode 100644 index 3eca332..0000000 --- a/port_src/core/DONE/datamatrix/encoder/EdifactEncoder.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -final class EdifactEncoder implements Encoder { - - @Override - public int getEncodingMode() { - return HighLevelEncoder.EDIFACT_ENCODATION; - } - - @Override - public void encode(EncoderContext context) { - //step F - StringBuilder buffer = new StringBuilder(); - while (context.hasMoreCharacters()) { - char c = context.getCurrentChar(); - encodeChar(c, buffer); - context.pos++; - - int count = buffer.length(); - if (count >= 4) { - context.writeCodewords(encodeToCodewords(buffer)); - buffer.delete(0, 4); - - int newMode = HighLevelEncoder.lookAheadTest(context.getMessage(), context.pos, getEncodingMode()); - if (newMode != getEncodingMode()) { - // Return to ASCII encodation, which will actually handle latch to new mode - context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION); - break; - } - } - } - buffer.append((char) 31); //Unlatch - handleEOD(context, buffer); - } - - /** - * Handle "end of data" situations - * - * @param context the encoder context - * @param buffer the buffer with the remaining encoded characters - */ - private static void handleEOD(EncoderContext context, CharSequence buffer) { - try { - int count = buffer.length(); - if (count == 0) { - return; //Already finished - } - if (count == 1) { - //Only an unlatch at the end - context.updateSymbolInfo(); - int available = context.getSymbolInfo().getDataCapacity() - context.getCodewordCount(); - int remaining = context.getRemainingCharacters(); - // The following two lines are a hack inspired by the 'fix' from https://sourceforge.net/p/barcode4j/svn/221/ - if (remaining > available) { - context.updateSymbolInfo(context.getCodewordCount() + 1); - available = context.getSymbolInfo().getDataCapacity() - context.getCodewordCount(); - } - if (remaining <= available && available <= 2) { - return; //No unlatch - } - } - - if (count > 4) { - throw new IllegalStateException("Count must not exceed 4"); - } - int restChars = count - 1; - String encoded = encodeToCodewords(buffer); - boolean endOfSymbolReached = !context.hasMoreCharacters(); - boolean restInAscii = endOfSymbolReached && restChars <= 2; - - if (restChars <= 2) { - context.updateSymbolInfo(context.getCodewordCount() + restChars); - int available = context.getSymbolInfo().getDataCapacity() - context.getCodewordCount(); - if (available >= 3) { - restInAscii = false; - context.updateSymbolInfo(context.getCodewordCount() + encoded.length()); - //available = context.symbolInfo.dataCapacity - context.getCodewordCount(); - } - } - - if (restInAscii) { - context.resetSymbolInfo(); - context.pos -= restChars; - } else { - context.writeCodewords(encoded); - } - } finally { - context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION); - } - } - - private static void encodeChar(char c, StringBuilder sb) { - if (c >= ' ' && c <= '?') { - sb.append(c); - } else if (c >= '@' && c <= '^') { - sb.append((char) (c - 64)); - } else { - HighLevelEncoder.illegalCharacter(c); - } - } - - private static String encodeToCodewords(CharSequence sb) { - int len = sb.length(); - if (len == 0) { - throw new IllegalStateException("StringBuilder must not be empty"); - } - char c1 = sb.charAt(0); - char c2 = len >= 2 ? sb.charAt(1) : 0; - char c3 = len >= 3 ? sb.charAt(2) : 0; - char c4 = len >= 4 ? sb.charAt(3) : 0; - - int v = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4; - char cw1 = (char) ((v >> 16) & 255); - char cw2 = (char) ((v >> 8) & 255); - char cw3 = (char) (v & 255); - StringBuilder res = new StringBuilder(3); - res.append(cw1); - if (len >= 2) { - res.append(cw2); - } - if (len >= 3) { - res.append(cw3); - } - return res.toString(); - } - -} diff --git a/port_src/core/DONE/datamatrix/encoder/Encoder.java b/port_src/core/DONE/datamatrix/encoder/Encoder.java deleted file mode 100644 index 7a91e1e..0000000 --- a/port_src/core/DONE/datamatrix/encoder/Encoder.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -interface Encoder { - - int getEncodingMode(); - - void encode(EncoderContext context); - -} diff --git a/port_src/core/DONE/datamatrix/encoder/EncoderContext.java b/port_src/core/DONE/datamatrix/encoder/EncoderContext.java deleted file mode 100644 index cc0b0cb..0000000 --- a/port_src/core/DONE/datamatrix/encoder/EncoderContext.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -import com.google.zxing.Dimension; - -import java.nio.charset.StandardCharsets; - -final class EncoderContext { - - private final String msg; - private SymbolShapeHint shape; - private Dimension minSize; - private Dimension maxSize; - private final StringBuilder codewords; - int pos; - private int newEncoding; - private SymbolInfo symbolInfo; - private int skipAtEnd; - - EncoderContext(String msg) { - //From this point on Strings are not Unicode anymore! - byte[] msgBinary = msg.getBytes(StandardCharsets.ISO_8859_1); - StringBuilder sb = new StringBuilder(msgBinary.length); - for (int i = 0, c = msgBinary.length; i < c; i++) { - char ch = (char) (msgBinary[i] & 0xff); - if (ch == '?' && msg.charAt(i) != '?') { - throw new IllegalArgumentException("Message contains characters outside ISO-8859-1 encoding."); - } - sb.append(ch); - } - this.msg = sb.toString(); //Not Unicode here! - shape = SymbolShapeHint.FORCE_NONE; - this.codewords = new StringBuilder(msg.length()); - newEncoding = -1; - } - - public void setSymbolShape(SymbolShapeHint shape) { - this.shape = shape; - } - - public void setSizeConstraints(Dimension minSize, Dimension maxSize) { - this.minSize = minSize; - this.maxSize = maxSize; - } - - public String getMessage() { - return this.msg; - } - - public void setSkipAtEnd(int count) { - this.skipAtEnd = count; - } - - public char getCurrentChar() { - return msg.charAt(pos); - } - - public char getCurrent() { - return msg.charAt(pos); - } - - public StringBuilder getCodewords() { - return codewords; - } - - public void writeCodewords(String codewords) { - this.codewords.append(codewords); - } - - public void writeCodeword(char codeword) { - this.codewords.append(codeword); - } - - public int getCodewordCount() { - return this.codewords.length(); - } - - public int getNewEncoding() { - return newEncoding; - } - - public void signalEncoderChange(int encoding) { - this.newEncoding = encoding; - } - - public void resetEncoderSignal() { - this.newEncoding = -1; - } - - public boolean hasMoreCharacters() { - return pos < getTotalMessageCharCount(); - } - - private int getTotalMessageCharCount() { - return msg.length() - skipAtEnd; - } - - public int getRemainingCharacters() { - return getTotalMessageCharCount() - pos; - } - - public SymbolInfo getSymbolInfo() { - return symbolInfo; - } - - public void updateSymbolInfo() { - updateSymbolInfo(getCodewordCount()); - } - - public void updateSymbolInfo(int len) { - if (this.symbolInfo == null || len > this.symbolInfo.getDataCapacity()) { - this.symbolInfo = SymbolInfo.lookup(len, shape, minSize, maxSize, true); - } - } - - public void resetSymbolInfo() { - this.symbolInfo = null; - } -} diff --git a/port_src/core/DONE/datamatrix/encoder/ErrorCorrection.java b/port_src/core/DONE/datamatrix/encoder/ErrorCorrection.java deleted file mode 100644 index cd652f7..0000000 --- a/port_src/core/DONE/datamatrix/encoder/ErrorCorrection.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright 2006 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -/** - * Error Correction Code for ECC200. - */ -public final class ErrorCorrection { - - /** - * Lookup table which factors to use for which number of error correction codewords. - * See FACTORS. - */ - private static final int[] FACTOR_SETS - = {5, 7, 10, 11, 12, 14, 18, 20, 24, 28, 36, 42, 48, 56, 62, 68}; - - /** - * Precomputed polynomial factors for ECC 200. - */ - private static final int[][] FACTORS = { - {228, 48, 15, 111, 62}, - {23, 68, 144, 134, 240, 92, 254}, - {28, 24, 185, 166, 223, 248, 116, 255, 110, 61}, - {175, 138, 205, 12, 194, 168, 39, 245, 60, 97, 120}, - {41, 153, 158, 91, 61, 42, 142, 213, 97, 178, 100, 242}, - {156, 97, 192, 252, 95, 9, 157, 119, 138, 45, 18, 186, 83, 185}, - {83, 195, 100, 39, 188, 75, 66, 61, 241, 213, 109, 129, 94, 254, 225, 48, 90, 188}, - {15, 195, 244, 9, 233, 71, 168, 2, 188, 160, 153, 145, 253, 79, 108, 82, 27, 174, 186, 172}, - {52, 190, 88, 205, 109, 39, 176, 21, 155, 197, 251, 223, 155, 21, 5, 172, - 254, 124, 12, 181, 184, 96, 50, 193}, - {211, 231, 43, 97, 71, 96, 103, 174, 37, 151, 170, 53, 75, 34, 249, 121, - 17, 138, 110, 213, 141, 136, 120, 151, 233, 168, 93, 255}, - {245, 127, 242, 218, 130, 250, 162, 181, 102, 120, 84, 179, 220, 251, 80, 182, - 229, 18, 2, 4, 68, 33, 101, 137, 95, 119, 115, 44, 175, 184, 59, 25, - 225, 98, 81, 112}, - {77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133, 242, 8, - 175, 95, 100, 9, 167, 105, 214, 111, 57, 121, 21, 1, 253, 57, 54, 101, - 248, 202, 69, 50, 150, 177, 226, 5, 9, 5}, - {245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, 205, 188, 237, 87, - 191, 106, 16, 147, 118, 23, 37, 90, 170, 205, 131, 88, 120, 100, 66, 138, - 186, 240, 82, 44, 176, 87, 187, 147, 160, 175, 69, 213, 92, 253, 225, 19}, - {175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192, 215, 235, - 150, 159, 36, 223, 38, 200, 132, 54, 228, 146, 218, 234, 117, 203, 29, 232, - 144, 238, 22, 150, 201, 117, 62, 207, 164, 13, 137, 245, 127, 67, 247, 28, - 155, 43, 203, 107, 233, 53, 143, 46}, - {242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143, 108, 196, 37, - 185, 112, 134, 230, 245, 63, 197, 190, 250, 106, 185, 221, 175, 64, 114, 71, - 161, 44, 147, 6, 27, 218, 51, 63, 87, 10, 40, 130, 188, 17, 163, 31, - 176, 170, 4, 107, 232, 7, 94, 166, 224, 124, 86, 47, 11, 204}, - {220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36, 73, 127, - 213, 136, 248, 180, 234, 197, 158, 177, 68, 122, 93, 213, 15, 160, 227, 236, - 66, 139, 153, 185, 202, 167, 179, 25, 220, 232, 96, 210, 231, 136, 223, 239, - 181, 241, 59, 52, 172, 25, 49, 232, 211, 189, 64, 54, 108, 153, 132, 63, - 96, 103, 82, 186}}; - - private static final int MODULO_VALUE = 0x12D; - - private static final int[] LOG; - private static final int[] ALOG; - - static { - //Create log and antilog table - LOG = new int[256]; - ALOG = new int[255]; - - int p = 1; - for (int i = 0; i < 255; i++) { - ALOG[i] = p; - LOG[p] = i; - p *= 2; - if (p >= 256) { - p ^= MODULO_VALUE; - } - } - } - - private ErrorCorrection() { - } - - /** - * Creates the ECC200 error correction for an encoded message. - * - * @param codewords the codewords - * @param symbolInfo information about the symbol to be encoded - * @return the codewords with interleaved error correction. - */ - public static String encodeECC200(String codewords, SymbolInfo symbolInfo) { - if (codewords.length() != symbolInfo.getDataCapacity()) { - throw new IllegalArgumentException( - "The number of codewords does not match the selected symbol"); - } - StringBuilder sb = new StringBuilder(symbolInfo.getDataCapacity() + symbolInfo.getErrorCodewords()); - sb.append(codewords); - int blockCount = symbolInfo.getInterleavedBlockCount(); - if (blockCount == 1) { - String ecc = createECCBlock(codewords, symbolInfo.getErrorCodewords()); - sb.append(ecc); - } else { - sb.setLength(sb.capacity()); - int[] dataSizes = new int[blockCount]; - int[] errorSizes = new int[blockCount]; - for (int i = 0; i < blockCount; i++) { - dataSizes[i] = symbolInfo.getDataLengthForInterleavedBlock(i + 1); - errorSizes[i] = symbolInfo.getErrorLengthForInterleavedBlock(i + 1); - } - for (int block = 0; block < blockCount; block++) { - StringBuilder temp = new StringBuilder(dataSizes[block]); - for (int d = block; d < symbolInfo.getDataCapacity(); d += blockCount) { - temp.append(codewords.charAt(d)); - } - String ecc = createECCBlock(temp.toString(), errorSizes[block]); - int pos = 0; - for (int e = block; e < errorSizes[block] * blockCount; e += blockCount) { - sb.setCharAt(symbolInfo.getDataCapacity() + e, ecc.charAt(pos++)); - } - } - } - return sb.toString(); - - } - - private static String createECCBlock(CharSequence codewords, int numECWords) { - int table = -1; - for (int i = 0; i < FACTOR_SETS.length; i++) { - if (FACTOR_SETS[i] == numECWords) { - table = i; - break; - } - } - if (table < 0) { - throw new IllegalArgumentException( - "Illegal number of error correction codewords specified: " + numECWords); - } - int[] poly = FACTORS[table]; - char[] ecc = new char[numECWords]; - for (int i = 0; i < numECWords; i++) { - ecc[i] = 0; - } - for (int i = 0; i < codewords.length(); i++) { - int m = ecc[numECWords - 1] ^ codewords.charAt(i); - for (int k = numECWords - 1; k > 0; k--) { - if (m != 0 && poly[k] != 0) { - ecc[k] = (char) (ecc[k - 1] ^ ALOG[(LOG[m] + LOG[poly[k]]) % 255]); - } else { - ecc[k] = ecc[k - 1]; - } - } - if (m != 0 && poly[0] != 0) { - ecc[0] = (char) ALOG[(LOG[m] + LOG[poly[0]]) % 255]; - } else { - ecc[0] = 0; - } - } - char[] eccReversed = new char[numECWords]; - for (int i = 0; i < numECWords; i++) { - eccReversed[i] = ecc[numECWords - i - 1]; - } - return String.valueOf(eccReversed); - } - -} diff --git a/port_src/core/DONE/datamatrix/encoder/HighLevelEncoder.java b/port_src/core/DONE/datamatrix/encoder/HighLevelEncoder.java deleted file mode 100644 index 0016ce7..0000000 --- a/port_src/core/DONE/datamatrix/encoder/HighLevelEncoder.java +++ /dev/null @@ -1,484 +0,0 @@ -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -import com.google.zxing.Dimension; - -import java.util.Arrays; - -/** - * DataMatrix ECC 200 data encoder following the algorithm described in ISO/IEC 16022:200(E) in - * annex S. - */ -public final class HighLevelEncoder { - - /** - * Padding character - */ - private static final char PAD = 129; - /** - * mode latch to C40 encodation mode - */ - static final char LATCH_TO_C40 = 230; - /** - * mode latch to Base 256 encodation mode - */ - static final char LATCH_TO_BASE256 = 231; - /** - * FNC1 Codeword - */ - //private static final char FNC1 = 232; - /** - * Structured Append Codeword - */ - //private static final char STRUCTURED_APPEND = 233; - /** - * Reader Programming - */ - //private static final char READER_PROGRAMMING = 234; - /** - * Upper Shift - */ - static final char UPPER_SHIFT = 235; - /** - * 05 Macro - */ - private static final char MACRO_05 = 236; - /** - * 06 Macro - */ - private static final char MACRO_06 = 237; - /** - * mode latch to ANSI X.12 encodation mode - */ - static final char LATCH_TO_ANSIX12 = 238; - /** - * mode latch to Text encodation mode - */ - static final char LATCH_TO_TEXT = 239; - /** - * mode latch to EDIFACT encodation mode - */ - static final char LATCH_TO_EDIFACT = 240; - /** - * ECI character (Extended Channel Interpretation) - */ - //private static final char ECI = 241; - - /** - * Unlatch from C40 encodation - */ - static final char C40_UNLATCH = 254; - /** - * Unlatch from X12 encodation - */ - static final char X12_UNLATCH = 254; - - /** - * 05 Macro header - */ - static final String MACRO_05_HEADER = "[)>\u001E05\u001D"; - /** - * 06 Macro header - */ - static final String MACRO_06_HEADER = "[)>\u001E06\u001D"; - /** - * Macro trailer - */ - static final String MACRO_TRAILER = "\u001E\u0004"; - - static final int ASCII_ENCODATION = 0; - static final int C40_ENCODATION = 1; - static final int TEXT_ENCODATION = 2; - static final int X12_ENCODATION = 3; - static final int EDIFACT_ENCODATION = 4; - static final int BASE256_ENCODATION = 5; - - private HighLevelEncoder() { - } - - private static char randomize253State(int codewordPosition) { - int pseudoRandom = ((149 * codewordPosition) % 253) + 1; - int tempVariable = PAD + pseudoRandom; - return (char) (tempVariable <= 254 ? tempVariable : tempVariable - 254); - } - - /** - * Performs message encoding of a DataMatrix message using the algorithm described in annex P - * of ISO/IEC 16022:2000(E). - * - * @param msg the message - * @return the encoded message (the char values range from 0 to 255) - */ - public static String encodeHighLevel(String msg) { - return encodeHighLevel(msg, SymbolShapeHint.FORCE_NONE, null, null, false); - } - - /** - * Performs message encoding of a DataMatrix message using the algorithm described in annex P - * of ISO/IEC 16022:2000(E). - * - * @param msg the message - * @param shape requested shape. May be {@code SymbolShapeHint.FORCE_NONE}, - * {@code SymbolShapeHint.FORCE_SQUARE} or {@code SymbolShapeHint.FORCE_RECTANGLE}. - * @param minSize the minimum symbol size constraint or null for no constraint - * @param maxSize the maximum symbol size constraint or null for no constraint - * @return the encoded message (the char values range from 0 to 255) - */ - public static String encodeHighLevel(String msg, - SymbolShapeHint shape, - Dimension minSize, - Dimension maxSize) { - return encodeHighLevel(msg, shape, minSize, maxSize, false); - } - /** - * Performs message encoding of a DataMatrix message using the algorithm described in annex P - * of ISO/IEC 16022:2000(E). - * - * @param msg the message - * @param shape requested shape. May be {@code SymbolShapeHint.FORCE_NONE}, - * {@code SymbolShapeHint.FORCE_SQUARE} or {@code SymbolShapeHint.FORCE_RECTANGLE}. - * @param minSize the minimum symbol size constraint or null for no constraint - * @param maxSize the maximum symbol size constraint or null for no constraint - * @param forceC40 enforce C40 encoding - * @return the encoded message (the char values range from 0 to 255) - */ - public static String encodeHighLevel(String msg, - SymbolShapeHint shape, - Dimension minSize, - Dimension maxSize, - boolean forceC40) { - //the codewords 0..255 are encoded as Unicode characters - C40Encoder c40Encoder = new C40Encoder(); - Encoder[] encoders = { - new ASCIIEncoder(), c40Encoder, new TextEncoder(), - new X12Encoder(), new EdifactEncoder(), new Base256Encoder() - }; - - EncoderContext context = new EncoderContext(msg); - context.setSymbolShape(shape); - context.setSizeConstraints(minSize, maxSize); - - if (msg.startsWith(MACRO_05_HEADER) && msg.endsWith(MACRO_TRAILER)) { - context.writeCodeword(MACRO_05); - context.setSkipAtEnd(2); - context.pos += MACRO_05_HEADER.length(); - } else if (msg.startsWith(MACRO_06_HEADER) && msg.endsWith(MACRO_TRAILER)) { - context.writeCodeword(MACRO_06); - context.setSkipAtEnd(2); - context.pos += MACRO_06_HEADER.length(); - } - - int encodingMode = ASCII_ENCODATION; //Default mode - - if (forceC40) { - c40Encoder.encodeMaximal(context); - encodingMode = context.getNewEncoding(); - context.resetEncoderSignal(); - } - - while (context.hasMoreCharacters()) { - encoders[encodingMode].encode(context); - if (context.getNewEncoding() >= 0) { - encodingMode = context.getNewEncoding(); - context.resetEncoderSignal(); - } - } - int len = context.getCodewordCount(); - context.updateSymbolInfo(); - int capacity = context.getSymbolInfo().getDataCapacity(); - if (len < capacity && - encodingMode != ASCII_ENCODATION && - encodingMode != BASE256_ENCODATION && - encodingMode != EDIFACT_ENCODATION) { - context.writeCodeword('\u00fe'); //Unlatch (254) - } - //Padding - StringBuilder codewords = context.getCodewords(); - if (codewords.length() < capacity) { - codewords.append(PAD); - } - while (codewords.length() < capacity) { - codewords.append(randomize253State(codewords.length() + 1)); - } - - return context.getCodewords().toString(); - } - - static int lookAheadTest(CharSequence msg, int startpos, int currentMode) { - int newMode = lookAheadTestIntern(msg, startpos, currentMode); - if (currentMode == X12_ENCODATION && newMode == X12_ENCODATION) { - int endpos = Math.min(startpos + 3, msg.length()); - for (int i = startpos; i < endpos; i++) { - if (!isNativeX12(msg.charAt(i))) { - return ASCII_ENCODATION; - } - } - } else if (currentMode == EDIFACT_ENCODATION && newMode == EDIFACT_ENCODATION) { - int endpos = Math.min(startpos + 4, msg.length()); - for (int i = startpos; i < endpos; i++) { - if (!isNativeEDIFACT(msg.charAt(i))) { - return ASCII_ENCODATION; - } - } - } - return newMode; - } - - static int lookAheadTestIntern(CharSequence msg, int startpos, int currentMode) { - if (startpos >= msg.length()) { - return currentMode; - } - float[] charCounts; - //step J - if (currentMode == ASCII_ENCODATION) { - charCounts = new float[]{0, 1, 1, 1, 1, 1.25f}; - } else { - charCounts = new float[]{1, 2, 2, 2, 2, 2.25f}; - charCounts[currentMode] = 0; - } - - int charsProcessed = 0; - byte[] mins = new byte[6]; - int[] intCharCounts = new int[6]; - while (true) { - //step K - if ((startpos + charsProcessed) == msg.length()) { - Arrays.fill(mins, (byte) 0); - Arrays.fill(intCharCounts, 0); - int min = findMinimums(charCounts, intCharCounts, Integer.MAX_VALUE, mins); - int minCount = getMinimumCount(mins); - - if (intCharCounts[ASCII_ENCODATION] == min) { - return ASCII_ENCODATION; - } - if (minCount == 1) { - if (mins[BASE256_ENCODATION] > 0) { - return BASE256_ENCODATION; - } - if (mins[EDIFACT_ENCODATION] > 0) { - return EDIFACT_ENCODATION; - } - if (mins[TEXT_ENCODATION] > 0) { - return TEXT_ENCODATION; - } - if (mins[X12_ENCODATION] > 0) { - return X12_ENCODATION; - } - } - return C40_ENCODATION; - } - - char c = msg.charAt(startpos + charsProcessed); - charsProcessed++; - - //step L - if (isDigit(c)) { - charCounts[ASCII_ENCODATION] += 0.5f; - } else if (isExtendedASCII(c)) { - charCounts[ASCII_ENCODATION] = (float) Math.ceil(charCounts[ASCII_ENCODATION]); - charCounts[ASCII_ENCODATION] += 2.0f; - } else { - charCounts[ASCII_ENCODATION] = (float) Math.ceil(charCounts[ASCII_ENCODATION]); - charCounts[ASCII_ENCODATION]++; - } - - //step M - if (isNativeC40(c)) { - charCounts[C40_ENCODATION] += 2.0f / 3.0f; - } else if (isExtendedASCII(c)) { - charCounts[C40_ENCODATION] += 8.0f / 3.0f; - } else { - charCounts[C40_ENCODATION] += 4.0f / 3.0f; - } - - //step N - if (isNativeText(c)) { - charCounts[TEXT_ENCODATION] += 2.0f / 3.0f; - } else if (isExtendedASCII(c)) { - charCounts[TEXT_ENCODATION] += 8.0f / 3.0f; - } else { - charCounts[TEXT_ENCODATION] += 4.0f / 3.0f; - } - - //step O - if (isNativeX12(c)) { - charCounts[X12_ENCODATION] += 2.0f / 3.0f; - } else if (isExtendedASCII(c)) { - charCounts[X12_ENCODATION] += 13.0f / 3.0f; - } else { - charCounts[X12_ENCODATION] += 10.0f / 3.0f; - } - - //step P - if (isNativeEDIFACT(c)) { - charCounts[EDIFACT_ENCODATION] += 3.0f / 4.0f; - } else if (isExtendedASCII(c)) { - charCounts[EDIFACT_ENCODATION] += 17.0f / 4.0f; - } else { - charCounts[EDIFACT_ENCODATION] += 13.0f / 4.0f; - } - - // step Q - if (isSpecialB256(c)) { - charCounts[BASE256_ENCODATION] += 4.0f; - } else { - charCounts[BASE256_ENCODATION]++; - } - - //step R - if (charsProcessed >= 4) { - Arrays.fill(mins, (byte) 0); - Arrays.fill(intCharCounts, 0); - findMinimums(charCounts, intCharCounts, Integer.MAX_VALUE, mins); - - if (intCharCounts[ASCII_ENCODATION] < min(intCharCounts[BASE256_ENCODATION], - intCharCounts[C40_ENCODATION], intCharCounts[TEXT_ENCODATION], intCharCounts[X12_ENCODATION], - intCharCounts[EDIFACT_ENCODATION])) { - return ASCII_ENCODATION; - } - if (intCharCounts[BASE256_ENCODATION] < intCharCounts[ASCII_ENCODATION] || - intCharCounts[BASE256_ENCODATION] + 1 < min(intCharCounts[C40_ENCODATION], - intCharCounts[TEXT_ENCODATION], intCharCounts[X12_ENCODATION], intCharCounts[EDIFACT_ENCODATION])) { - return BASE256_ENCODATION; - } - if (intCharCounts[EDIFACT_ENCODATION] + 1 < min(intCharCounts[BASE256_ENCODATION], - intCharCounts[C40_ENCODATION] , intCharCounts[TEXT_ENCODATION] , intCharCounts[X12_ENCODATION], - intCharCounts[ASCII_ENCODATION])) { - return EDIFACT_ENCODATION; - } - if (intCharCounts[TEXT_ENCODATION] + 1 < min(intCharCounts[BASE256_ENCODATION], - intCharCounts[C40_ENCODATION] , intCharCounts[EDIFACT_ENCODATION] , intCharCounts[X12_ENCODATION], - intCharCounts[ASCII_ENCODATION])) { - return TEXT_ENCODATION; - } - if (intCharCounts[X12_ENCODATION] + 1 < min(intCharCounts[BASE256_ENCODATION], - intCharCounts[C40_ENCODATION] , intCharCounts[EDIFACT_ENCODATION] , intCharCounts[TEXT_ENCODATION], - intCharCounts[ASCII_ENCODATION])) { - return X12_ENCODATION; - } - if (intCharCounts[C40_ENCODATION] + 1 < min(intCharCounts[ASCII_ENCODATION], - intCharCounts[BASE256_ENCODATION] , intCharCounts[EDIFACT_ENCODATION] , intCharCounts[TEXT_ENCODATION])) { - if (intCharCounts[C40_ENCODATION] < intCharCounts[X12_ENCODATION]) { - return C40_ENCODATION; - } - if (intCharCounts[C40_ENCODATION] == intCharCounts[X12_ENCODATION]) { - int p = startpos + charsProcessed + 1; - while (p < msg.length()) { - char tc = msg.charAt(p); - if (isX12TermSep(tc)) { - return X12_ENCODATION; - } - if (!isNativeX12(tc)) { - break; - } - p++; - } - return C40_ENCODATION; - } - } - } - } - } - - private static int min(int f1, int f2, int f3, int f4, int f5) { - return Math.min(min(f1, f2, f3, f4),f5); - } - - private static int min(int f1, int f2, int f3, int f4) { - return Math.min(f1, Math.min(f2, Math.min(f3, f4))); - } - - private static int findMinimums(float[] charCounts, int[] intCharCounts, int min, byte[] mins) { - for (int i = 0; i < 6; i++) { - int current = (intCharCounts[i] = (int) Math.ceil(charCounts[i])); - if (min > current) { - min = current; - Arrays.fill(mins, (byte) 0); - } - if (min == current) { - mins[i]++; - } - } - return min; - } - - private static int getMinimumCount(byte[] mins) { - int minCount = 0; - for (int i = 0; i < 6; i++) { - minCount += mins[i]; - } - return minCount; - } - - static boolean isDigit(char ch) { - return ch >= '0' && ch <= '9'; - } - - static boolean isExtendedASCII(char ch) { - return ch >= 128 && ch <= 255; - } - - static boolean isNativeC40(char ch) { - return (ch == ' ') || (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z'); - } - - static boolean isNativeText(char ch) { - return (ch == ' ') || (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z'); - } - - static boolean isNativeX12(char ch) { - return isX12TermSep(ch) || (ch == ' ') || (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z'); - } - - private static boolean isX12TermSep(char ch) { - return (ch == '\r') //CR - || (ch == '*') - || (ch == '>'); - } - - static boolean isNativeEDIFACT(char ch) { - return ch >= ' ' && ch <= '^'; - } - - private static boolean isSpecialB256(char ch) { - return false; //TODO NOT IMPLEMENTED YET!!! - } - - /** - * Determines the number of consecutive characters that are encodable using numeric compaction. - * - * @param msg the message - * @param startpos the start position within the message - * @return the requested character count - */ - public static int determineConsecutiveDigitCount(CharSequence msg, int startpos) { - int len = msg.length(); - int idx = startpos; - while (idx < len && isDigit(msg.charAt(idx))) { - idx++; - } - return idx - startpos; - } - - static void illegalCharacter(char c) { - String hex = Integer.toHexString(c); - hex = "0000".substring(0, 4 - hex.length()) + hex; - throw new IllegalArgumentException("Illegal character: " + c + " (0x" + hex + ')'); - } - -} diff --git a/port_src/core/DONE/datamatrix/encoder/MinimalEncoder.java b/port_src/core/DONE/datamatrix/encoder/MinimalEncoder.java deleted file mode 100755 index 4d3dd8d..0000000 --- a/port_src/core/DONE/datamatrix/encoder/MinimalEncoder.java +++ /dev/null @@ -1,1044 +0,0 @@ -/* - * Copyright 2021 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; - -import com.google.zxing.common.MinimalECIInput; - -/** - * Encoder that encodes minimally - * - * Algorithm: - * - * Uses Dijkstra to produce mathematically minimal encodings that are in some cases smaller than the results produced - * by the algorithm described in annex S in the specification ISO/IEC 16022:200(E). The biggest improvment of this - * algorithm over that one is the case when the algorithm enters the most inefficient mode, the B256 mode. The - * algorithm from the specification algorithm will exit this mode only if it encounters digits so that arbitrarily - * inefficient results can be produced if the postfix contains no digits. - * - * Multi ECI support and ECI switching: - * - * For multi language content the algorithm selects the most compact representation using ECI modes. Note that unlike - * the compaction algorithm used for QR-Codes, this implementation operates in two stages and therfore is not - * mathematically optimal. In the first stage, the input string is encoded minimally as a stream of ECI character set - * selectors and bytes encoded in the selected encoding. In this stage the algorithm might for example decide to - * encode ocurrences of the characters "\u0150\u015C" (O-double-acute, S-circumflex) in UTF-8 by a single ECI or - * alternatively by multiple ECIs that switch between IS0-8859-2 and ISO-8859-3 (e.g. in the case that the input - * contains many * characters from ISO-8859-2 (Latin 2) and few from ISO-8859-3 (Latin 3)). - * In a second stage this stream of ECIs and bytes is minimally encoded using the various Data Matrix encoding modes. - * While both stages encode mathematically minimally it is not ensured that the result is mathematically minimal since - * the size growth for inserting an ECI in the first stage can only be approximated as the first stage does not know - * in which mode the ECI will occur in the second stage (may, or may not require an extra latch to ASCII depending on - * the current mode). The reason for this shortcoming are difficulties in implementing it in a straightforward and - * readable manner. - * - * GS1 support - * - * FNC1 delimiters can be encoded in the input string by using the FNC1 character specified in the encoding function. - * When a FNC1 character is specified then a leading FNC1 will be encoded and all ocurrences of delimiter characters - * while result in FNC1 codewords in the symbol. - * - * @author Alex Geller - */ -public final class MinimalEncoder { - - enum Mode { - ASCII, - C40, - TEXT, - X12, - EDF, - B256 - } - static final char[] C40_SHIFT2_CHARS = {'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', - ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_' }; - - - private MinimalEncoder() { - } - - static boolean isExtendedASCII(char ch, int fnc1) { - return ch != fnc1 && ch >= 128 && ch <= 255; - } - - private static boolean isInC40Shift1Set(char ch) { - return ch <= 31; - } - - private static boolean isInC40Shift2Set(char ch, int fnc1) { - for (char c40Shift2Char : C40_SHIFT2_CHARS) { - if (c40Shift2Char == ch) { - return true; - } - } - return ch == fnc1; - } - - private static boolean isInTextShift1Set(char ch) { - return isInC40Shift1Set(ch); - } - - private static boolean isInTextShift2Set(char ch, int fnc1) { - return isInC40Shift2Set(ch, fnc1); - } - - /** - * Performs message encoding of a DataMatrix message - * - * @param msg the message - * @return the encoded message (the char values range from 0 to 255) - */ - public static String encodeHighLevel(String msg) { - return encodeHighLevel(msg, null, -1, SymbolShapeHint.FORCE_NONE); - } - - /** - * Performs message encoding of a DataMatrix message - * - * @param msg the message - * @param priorityCharset The preferred {@link Charset}. When the value of the argument is null, the algorithm - * chooses charsets that leads to a minimal representation. Otherwise the algorithm will use the priority - * charset to encode any character in the input that can be encoded by it if the charset is among the - * supported charsets. - * @param fnc1 denotes the character in the input that represents the FNC1 character or -1 if this is not a GS1 - * bar code. If the value is not -1 then a FNC1 is also prepended. - * @param shape requested shape. - * @return the encoded message (the char values range from 0 to 255) - */ - public static String encodeHighLevel(String msg, Charset priorityCharset, int fnc1, SymbolShapeHint shape) { - int macroId = 0; - if (msg.startsWith(HighLevelEncoder.MACRO_05_HEADER) && msg.endsWith(HighLevelEncoder.MACRO_TRAILER)) { - macroId = 5; - msg = msg.substring(HighLevelEncoder.MACRO_05_HEADER.length(), msg.length() - 2); - } else if (msg.startsWith(HighLevelEncoder.MACRO_06_HEADER) && msg.endsWith(HighLevelEncoder.MACRO_TRAILER)) { - macroId = 6; - msg = msg.substring(HighLevelEncoder.MACRO_06_HEADER.length(), msg.length() - 2); - } - return new String(encode(msg, priorityCharset, fnc1, shape, macroId), StandardCharsets.ISO_8859_1); - } - - /** - * Encodes input minimally and returns an array of the codewords - * - * @param input The string to encode - * @param priorityCharset The preferred {@link Charset}. When the value of the argument is null, the algorithm - * chooses charsets that leads to a minimal representation. Otherwise the algorithm will use the priority - * charset to encode any character in the input that can be encoded by it if the charset is among the - * supported charsets. - * @param fnc1 denotes the character in the input that represents the FNC1 character or -1 if this is not a GS1 - * bar code. If the value is not -1 then a FNC1 is also prepended. - * @param shape requested shape. - * @param macroId Prepends the specified macro function in case that a value of 5 or 6 is specified. - * @return An array of bytes representing the codewords of a minimal encoding. - */ - static byte[] encode(String input, Charset priorityCharset, int fnc1, SymbolShapeHint shape, int macroId) { - return encodeMinimally(new Input(input, priorityCharset, fnc1, shape, macroId)).getBytes(); - } - - static void addEdge(Edge[][] edges, Edge edge) { - int vertexIndex = edge.fromPosition + edge.characterLength; - if (edges[vertexIndex][edge.getEndMode().ordinal()] == null || - edges[vertexIndex][edge.getEndMode().ordinal()].cachedTotalSize > edge.cachedTotalSize) { - edges[vertexIndex][edge.getEndMode().ordinal()] = edge; - } - } - - /** @return the number of words in which the string starting at from can be encoded in c40 or text mode. - * The number of characters encoded is returned in characterLength. - * The number of characters encoded is also minimal in the sense that the algorithm stops as soon - * as a character encoding fills a C40 word competely (three C40 values). An exception is at the - * end of the string where two C40 values are allowed (according to the spec the third c40 value - * is filled with 0 (Shift 1) in this case). - */ - static int getNumberOfC40Words(Input input, int from, boolean c40,int[] characterLength) { - int thirdsCount = 0; - for (int i = from; i < input.length(); i++) { - if (input.isECI(i)) { - characterLength[0] = 0; - return 0; - } - char ci = input.charAt(i); - if (c40 && HighLevelEncoder.isNativeC40(ci) || !c40 && HighLevelEncoder.isNativeText(ci)) { - thirdsCount++; //native - } else if (!isExtendedASCII(ci, input.getFNC1Character())) { - thirdsCount += 2; //shift - } else { - int asciiValue = ci & 0xff; - if (asciiValue >= 128 && (c40 && HighLevelEncoder.isNativeC40((char) (asciiValue - 128)) || - !c40 && HighLevelEncoder.isNativeText((char) (asciiValue - 128)))) { - thirdsCount += 3; // shift, Upper shift - } else { - thirdsCount += 4; // shift, Upper shift, shift - } - } - - if (thirdsCount % 3 == 0 || ((thirdsCount - 2) % 3 == 0 && i + 1 == input.length())) { - characterLength[0] = i - from + 1; - return (int) Math.ceil(((double) thirdsCount) / 3.0); - } - } - characterLength[0] = 0; - return 0; - } - - static void addEdges(Input input, Edge[][] edges, int from, Edge previous) { - - if (input.isECI(from)) { - addEdge(edges, new Edge(input, Mode.ASCII, from, 1, previous)); - return; - } - - char ch = input.charAt(from); - if (previous == null || previous.getEndMode() != Mode.EDF) { //not possible to unlatch a full EDF edge to something - //else - if (HighLevelEncoder.isDigit(ch) && input.haveNCharacters(from, 2) && - HighLevelEncoder.isDigit(input.charAt(from + 1))) { - // two digits ASCII encoded - addEdge(edges, new Edge(input, Mode.ASCII, from, 2, previous)); - } else { - // one ASCII encoded character or an extended character via Upper Shift - addEdge(edges, new Edge(input, Mode.ASCII, from, 1, previous)); - } - - Mode[] modes = {Mode.C40, Mode.TEXT}; - for (Mode mode : modes) { - int[] characterLength = new int[1]; - if (getNumberOfC40Words(input, from, mode == Mode.C40, characterLength) > 0) { - addEdge(edges, new Edge(input, mode, from, characterLength[0], previous)); - } - } - - if (input.haveNCharacters(from,3) && - HighLevelEncoder.isNativeX12(input.charAt(from)) && - HighLevelEncoder.isNativeX12(input.charAt(from + 1)) && - HighLevelEncoder.isNativeX12(input.charAt(from + 2))) { - addEdge(edges, new Edge(input, Mode.X12, from, 3, previous)); - } - - addEdge(edges, new Edge(input, Mode.B256, from, 1, previous)); - } - - //We create 4 EDF edges, with 1, 2 3 or 4 characters length. The fourth normally doesn't have a latch to ASCII - //unless it is 2 characters away from the end of the input. - int i; - for (i = 0; i < 3; i++) { - int pos = from + i; - if (input.haveNCharacters(pos,1) && HighLevelEncoder.isNativeEDIFACT(input.charAt(pos))) { - addEdge(edges, new Edge(input, Mode.EDF, from, i + 1, previous)); - } else { - break; - } - } - if (i == 3 && input.haveNCharacters(from, 4) && HighLevelEncoder.isNativeEDIFACT(input.charAt(from + 3))) { - addEdge(edges, new Edge(input, Mode.EDF, from, 4, previous)); - } - } - static Result encodeMinimally(Input input) { - - @SuppressWarnings("checkstyle:lineLength") - /* The minimal encoding is computed by Dijkstra. The acyclic graph is modeled as follows: - * A vertex represents a combination of a position in the input and an encoding mode where position 0 - * denotes the position left of the first character, 1 the position left of the second character and so on. - * Likewise the end vertices are located after the last character at position input.length(). - * For any position there might be up to six vertices, one for each of the encoding types ASCII, C40, TEXT, X12, - * EDF and B256. - * - * As an example consider the input string "ABC123" then at position 0 there is only one vertex with the default - * ASCII encodation. At position 3 there might be vertices for the types ASCII, C40, X12, EDF and B256. - * - * An edge leading to such a vertex encodes one or more of the characters left of the position that the vertex - * represents. It encodes the characters in the encoding mode of the vertex that it ends on. In other words, - * all edges leading to a particular vertex encode the same characters (the length of the suffix can vary) using the same - * encoding mode. - * As an example consider the input string "ABC123" and the vertex (4,EDF). Possible edges leading to this vertex - * are: - * (0,ASCII) --EDF(ABC1)--> (4,EDF) - * (1,ASCII) --EDF(BC1)--> (4,EDF) - * (1,B256) --EDF(BC1)--> (4,EDF) - * (1,EDF) --EDF(BC1)--> (4,EDF) - * (2,ASCII) --EDF(C1)--> (4,EDF) - * (2,B256) --EDF(C1)--> (4,EDF) - * (2,EDF) --EDF(C1)--> (4,EDF) - * (3,ASCII) --EDF(1)--> (4,EDF) - * (3,B256) --EDF(1)--> (4,EDF) - * (3,EDF) --EDF(1)--> (4,EDF) - * (3,C40) --EDF(1)--> (4,EDF) - * (3,X12) --EDF(1)--> (4,EDF) - * - * The edges leading to a vertex are stored in such a way that there is a fast way to enumerate the edges ending - * on a particular vertex. - * - * The algorithm processes the vertices in order of their position thereby performing the following: - * - * For every vertex at position i the algorithm enumerates the edges ending on the vertex and removes all but the - * shortest from that list. - * Then it processes the vertices for the position i+1. If i+1 == input.length() then the algorithm ends - * and chooses the the edge with the smallest size from any of the edges leading to vertices at this position. - * Otherwise the algorithm computes all possible outgoing edges for the vertices at the position i+1 - * - * Examples: - * The process is illustrated by showing the graph (edges) after each iteration from left to right over the input: - * An edge is drawn as follows "(" + fromVertex + ") -- " + encodingMode + "(" + encodedInput + ") (" + - * accumulatedSize + ") --> (" + toVertex + ")" - * - * Example 1 encoding the string "ABCDEFG": - * - * - * Situation after adding edges to the start vertex (0,ASCII) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) - * (0,ASCII) B256(A) (3) --> (1,B256) - * (0,ASCII) EDF(AB) (4) --> (2,EDF) - * (0,ASCII) C40(ABC) (3) --> (3,C40) - * (0,ASCII) TEXT(ABC) (5) --> (3,TEXT) - * (0,ASCII) X12(ABC) (3) --> (3,X12) - * (0,ASCII) EDF(ABC) (4) --> (3,EDF) - * (0,ASCII) EDF(ABCD) (4) --> (4,EDF) - * - * Situation after adding edges to vertices at position 1 - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) - * (0,ASCII) B256(A) (3) --> (1,B256) - * (0,ASCII) EDF(AB) (4) --> (2,EDF) - * (0,ASCII) C40(ABC) (3) --> (3,C40) - * (0,ASCII) TEXT(ABC) (5) --> (3,TEXT) - * (0,ASCII) X12(ABC) (3) --> (3,X12) - * (0,ASCII) EDF(ABC) (4) --> (3,EDF) - * (0,ASCII) EDF(ABCD) (4) --> (4,EDF) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) B256(B) (4) --> (2,B256) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) EDF(BC) (5) --> (3,EDF) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) C40(BCD) (4) --> (4,C40) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) TEXT(BCD) (6) --> (4,TEXT) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) X12(BCD) (4) --> (4,X12) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) EDF(BCD) (5) --> (4,EDF) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) EDF(BCDE) (5) --> (5,EDF) - * (0,ASCII) B256(A) (3) --> (1,B256) ASCII(B) (4) --> (2,ASCII) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) - * (0,ASCII) B256(A) (3) --> (1,B256) EDF(BC) (6) --> (3,EDF) - * (0,ASCII) B256(A) (3) --> (1,B256) C40(BCD) (5) --> (4,C40) - * (0,ASCII) B256(A) (3) --> (1,B256) TEXT(BCD) (7) --> (4,TEXT) - * (0,ASCII) B256(A) (3) --> (1,B256) X12(BCD) (5) --> (4,X12) - * (0,ASCII) B256(A) (3) --> (1,B256) EDF(BCD) (6) --> (4,EDF) - * (0,ASCII) B256(A) (3) --> (1,B256) EDF(BCDE) (6) --> (5,EDF) - * - * Edge "(1,ASCII) ASCII(B) (2) --> (2,ASCII)" is minimal for the vertex (2,ASCII) so that edge "(1,B256) ASCII(B) (4) --> (2,ASCII)" is removed. - * Edge "(1,B256) B256(B) (3) --> (2,B256)" is minimal for the vertext (2,B256) so that the edge "(1,ASCII) B256(B) (4) --> (2,B256)" is removed. - * - * Situation after adding edges to vertices at position 2 - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) - * (0,ASCII) B256(A) (3) --> (1,B256) - * (0,ASCII) EDF(AB) (4) --> (2,EDF) - * (0,ASCII) C40(ABC) (3) --> (3,C40) - * (0,ASCII) TEXT(ABC) (5) --> (3,TEXT) - * (0,ASCII) X12(ABC) (3) --> (3,X12) - * (0,ASCII) EDF(ABC) (4) --> (3,EDF) - * (0,ASCII) EDF(ABCD) (4) --> (4,EDF) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) EDF(BC) (5) --> (3,EDF) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) C40(BCD) (4) --> (4,C40) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) TEXT(BCD) (6) --> (4,TEXT) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) X12(BCD) (4) --> (4,X12) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) EDF(BCD) (5) --> (4,EDF) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) EDF(BCDE) (5) --> (5,EDF) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) - * (0,ASCII) B256(A) (3) --> (1,B256) EDF(BC) (6) --> (3,EDF) - * (0,ASCII) B256(A) (3) --> (1,B256) C40(BCD) (5) --> (4,C40) - * (0,ASCII) B256(A) (3) --> (1,B256) TEXT(BCD) (7) --> (4,TEXT) - * (0,ASCII) B256(A) (3) --> (1,B256) X12(BCD) (5) --> (4,X12) - * (0,ASCII) B256(A) (3) --> (1,B256) EDF(BCD) (6) --> (4,EDF) - * (0,ASCII) B256(A) (3) --> (1,B256) EDF(BCDE) (6) --> (5,EDF) - * (0,ASCII) EDF(AB) (4) --> (2,EDF) ASCII(C) (5) --> (3,ASCII) - * (0,ASCII) EDF(AB) (4) --> (2,EDF) B256(C) (6) --> (3,B256) - * (0,ASCII) EDF(AB) (4) --> (2,EDF) EDF(CD) (7) --> (4,EDF) - * (0,ASCII) EDF(AB) (4) --> (2,EDF) C40(CDE) (6) --> (5,C40) - * (0,ASCII) EDF(AB) (4) --> (2,EDF) TEXT(CDE) (8) --> (5,TEXT) - * (0,ASCII) EDF(AB) (4) --> (2,EDF) X12(CDE) (6) --> (5,X12) - * (0,ASCII) EDF(AB) (4) --> (2,EDF) EDF(CDE) (7) --> (5,EDF) - * (0,ASCII) EDF(AB) (4) --> (2,EDF) EDF(CDEF) (7) --> (6,EDF) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) ASCII(C) (3) --> (3,ASCII) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) B256(C) (5) --> (3,B256) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) EDF(CD) (6) --> (4,EDF) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) C40(CDE) (5) --> (5,C40) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) TEXT(CDE) (7) --> (5,TEXT) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) X12(CDE) (5) --> (5,X12) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) EDF(CDE) (6) --> (5,EDF) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) EDF(CDEF) (6) --> (6,EDF) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) ASCII(C) (4) --> (3,ASCII) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) B256(C) (4) --> (3,B256) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) EDF(CD) (6) --> (4,EDF) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) C40(CDE) (5) --> (5,C40) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) TEXT(CDE) (7) --> (5,TEXT) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) X12(CDE) (5) --> (5,X12) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) EDF(CDE) (6) --> (5,EDF) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) EDF(CDEF) (6) --> (6,EDF) - * - * Edge "(2,ASCII) ASCII(C) (3) --> (3,ASCII)" is minimal for the vertex (3,ASCII) so that edges "(2,EDF) ASCII(C) (5) --> (3,ASCII)" - * and "(2,B256) ASCII(C) (4) --> (3,ASCII)" can be removed. - * Edge "(0,ASCII) EDF(ABC) (4) --> (3,EDF)" is minimal for the vertex (3,EDF) so that edges "(1,ASCII) EDF(BC) (5) --> (3,EDF)" - * and "(1,B256) EDF(BC) (6) --> (3,EDF)" can be removed. - * Edge "(2,B256) B256(C) (4) --> (3,B256)" is minimal for the vertex (3,B256) so that edges "(2,ASCII) B256(C) (5) --> (3,B256)" - * and "(2,EDF) B256(C) (6) --> (3,B256)" can be removed. - * - * This continues for vertices 3 thru 7 - * - * Situation after adding edges to vertices at position 7 - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) - * (0,ASCII) B256(A) (3) --> (1,B256) - * (0,ASCII) EDF(AB) (4) --> (2,EDF) - * (0,ASCII) C40(ABC) (3) --> (3,C40) - * (0,ASCII) TEXT(ABC) (5) --> (3,TEXT) - * (0,ASCII) X12(ABC) (3) --> (3,X12) - * (0,ASCII) EDF(ABC) (4) --> (3,EDF) - * (0,ASCII) EDF(ABCD) (4) --> (4,EDF) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) C40(BCD) (4) --> (4,C40) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) TEXT(BCD) (6) --> (4,TEXT) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) X12(BCD) (4) --> (4,X12) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) EDF(BCDE) (5) --> (5,EDF) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) - * (0,ASCII) C40(ABC) (3) --> (3,C40) C40(DEF) (5) --> (6,C40) - * (0,ASCII) X12(ABC) (3) --> (3,X12) X12(DEF) (5) --> (6,X12) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) ASCII(C) (3) --> (3,ASCII) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) C40(CDE) (5) --> (5,C40) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) TEXT(CDE) (7) --> (5,TEXT) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) X12(CDE) (5) --> (5,X12) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) EDF(CDEF) (6) --> (6,EDF) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) C40(BCD) (4) --> (4,C40) C40(EFG) (6) --> (7,C40) //Solution 1 - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) X12(BCD) (4) --> (4,X12) X12(EFG) (6) --> (7,X12) //Solution 2 - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) B256(C) (4) --> (3,B256) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) ASCII(C) (3) --> (3,ASCII) ASCII(D) (4) --> (4,ASCII) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) ASCII(C) (3) --> (3,ASCII) TEXT(DEF) (8) --> (6,TEXT) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) ASCII(C) (3) --> (3,ASCII) EDF(DEFG) (7) --> (7,EDF) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) B256(C) (4) --> (3,B256) B256(D) (5) --> (4,B256) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) ASCII(C) (3) --> (3,ASCII) ASCII(D) (4) --> (4,ASCII) ASCII(E) (5) --> (5,ASCII) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) ASCII(C) (3) --> (3,ASCII) ASCII(D) (4) --> (4,ASCII) TEXT(EFG) (9) --> (7,TEXT) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) B256(C) (4) --> (3,B256) B256(D) (5) --> (4,B256) B256(E) (6) --> (5,B256) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) ASCII(C) (3) --> (3,ASCII) ASCII(D) (4) --> (4,ASCII) ASCII(E) (5) --> (5,ASCII) ASCII(F) (6) --> (6,ASCII) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) B256(C) (4) --> (3,B256) B256(D) (5) --> (4,B256) B256(E) (6) --> (5,B256) B256(F) (7) --> (6,B256) - * (0,ASCII) ASCII(A) (1) --> (1,ASCII) ASCII(B) (2) --> (2,ASCII) ASCII(C) (3) --> (3,ASCII) ASCII(D) (4) --> (4,ASCII) ASCII(E) (5) --> (5,ASCII) ASCII(F) (6) --> (6,ASCII) ASCII(G) (7) --> (7,ASCII) - * (0,ASCII) B256(A) (3) --> (1,B256) B256(B) (3) --> (2,B256) B256(C) (4) --> (3,B256) B256(D) (5) --> (4,B256) B256(E) (6) --> (5,B256) B256(F) (7) --> (6,B256) B256(G) (8) --> (7,B256) - * - * Hence a minimal encoding of "ABCDEFG" is either ASCII(A),C40(BCDEFG) or ASCII(A), X12(BCDEFG) with a size of 5 bytes. - */ - - int inputLength = input.length(); - - // Array that represents vertices. There is a vertex for every character and mode. - // The last dimension in the array below encodes the 6 modes ASCII, C40, TEXT, X12, EDF and B256 - Edge[][] edges = new Edge[inputLength + 1][6]; - addEdges(input, edges, 0, null); - - for (int i = 1; i <= inputLength; i++) { - for (int j = 0; j < 6; j++) { - if (edges[i][j] != null && i < inputLength) { - addEdges(input, edges, i, edges[i][j]); - } - } - //optimize memory by removing edges that have been passed. - for (int j = 0; j < 6; j++) { - edges[i - 1][j] = null; - } - } - - int minimalJ = -1; - int minimalSize = Integer.MAX_VALUE; - for (int j = 0; j < 6; j++) { - if (edges[inputLength][j] != null) { - Edge edge = edges[inputLength][j]; - int size = j >= 1 && j <= 3 ? edge.cachedTotalSize + 1 : edge.cachedTotalSize; //C40, TEXT and X12 need an - // extra unlatch at the end - if (size < minimalSize) { - minimalSize = size; - minimalJ = j; - } - } - } - - if (minimalJ < 0) { - throw new RuntimeException("Internal error: failed to encode \"" + input + "\""); - } - return new Result(edges[inputLength][minimalJ]); - } - - private static final class Edge { - private static final int[] allCodewordCapacities = {3, 5, 8, 10, 12, 16, 18, 22, 30, 32, 36, 44, 49, 62, 86, 114, - 144, 174, 204, 280, 368, 456, 576, 696, 816, 1050, 1304, 1558}; - private static final int[] squareCodewordCapacities = {3, 5, 8, 12, 18, 22, 30, 36, 44, 62, 86, 114, 144, 174, 204, - 280, 368, 456, 576, 696, 816, 1050, 1304, 1558}; - private static final int[] rectangularCodewordCapacities = {5, 10, 16, 33, 32, 49}; - private final Input input; - private final Mode mode; //the mode at the start of this edge. - private final int fromPosition; - private final int characterLength; - private final Edge previous; - private final int cachedTotalSize; - - private Edge(Input input, Mode mode, int fromPosition, int characterLength, Edge previous) { - this.input = input; - this.mode = mode; - this.fromPosition = fromPosition; - this.characterLength = characterLength; - this.previous = previous; - assert fromPosition + characterLength <= input.length(); - - int size = previous != null ? previous.cachedTotalSize : 0; - - Mode previousMode = getPreviousMode(); - - /* - * Switching modes - * ASCII -> C40: latch 230 - * ASCII -> TEXT: latch 239 - * ASCII -> X12: latch 238 - * ASCII -> EDF: latch 240 - * ASCII -> B256: latch 231 - * C40 -> ASCII: word(c1,c2,c3), 254 - * TEXT -> ASCII: word(c1,c2,c3), 254 - * X12 -> ASCII: word(c1,c2,c3), 254 - * EDIFACT -> ASCII: Unlatch character,0,0,0 or c1,Unlatch character,0,0 or c1,c2,Unlatch character,0 or - * c1,c2,c3,Unlatch character - * B256 -> ASCII: without latch after n bytes - */ - switch (mode) { - case ASCII: - size++; - if (input.isECI(fromPosition) || isExtendedASCII(input.charAt(fromPosition), input.getFNC1Character())) { - size++; - } - if (previousMode == Mode.C40 || - previousMode == Mode.TEXT || - previousMode == Mode.X12) { - size++; // unlatch 254 to ASCII - } - break; - case B256: - size++; - if (previousMode != Mode.B256) { - size++; //byte count - } else if (getB256Size() == 250) { - size++; //extra byte count - } - if (previousMode == Mode.ASCII) { - size++; //latch to B256 - } else if (previousMode == Mode.C40 || - previousMode == Mode.TEXT || - previousMode == Mode.X12) { - size += 2; //unlatch to ASCII, latch to B256 - } - break; - case C40: - case TEXT: - case X12: - if (mode == Mode.X12) { - size += 2; - } else { - int[] charLen = new int[1]; - size += getNumberOfC40Words(input, fromPosition, mode == Mode.C40, charLen) * 2; - } - - if (previousMode == Mode.ASCII || previousMode == Mode.B256) { - size++; //additional byte for latch from ASCII to this mode - } else if (previousMode != mode && (previousMode == Mode.C40 || - previousMode == Mode.TEXT || - previousMode == Mode.X12)) { - size += 2; //unlatch 254 to ASCII followed by latch to this mode - } - break; - case EDF: - size += 3; - if (previousMode == Mode.ASCII || previousMode == Mode.B256) { - size++; //additional byte for latch from ASCII to this mode - } else if (previousMode == Mode.C40 || - previousMode == Mode.TEXT || - previousMode == Mode.X12) { - size += 2; //unlatch 254 to ASCII followed by latch to this mode - } - break; - } - cachedTotalSize = size; - } - - // does not count beyond 250 - int getB256Size() { - int cnt = 0; - Edge current = this; - while (current != null && current.mode == Mode.B256 && cnt <= 250) { - cnt++; - current = current.previous; - } - return cnt; - } - - Mode getPreviousStartMode() { - return previous == null ? Mode.ASCII : previous.mode; - } - - Mode getPreviousMode() { - return previous == null ? Mode.ASCII : previous.getEndMode(); - } - - /** Returns Mode.ASCII in case that: - * - Mode is EDIFACT and characterLength is less than 4 or the remaining characters can be encoded in at most 2 - * ASCII bytes. - * - Mode is C40, TEXT or X12 and the remaining characters can be encoded in at most 1 ASCII byte. - * Returns mode in all other cases. - * */ - Mode getEndMode() { - if (mode == Mode.EDF) { - if (characterLength < 4) { - return Mode.ASCII; - } - int lastASCII = getLastASCII(); // see 5.2.8.2 EDIFACT encodation Rules - if (lastASCII > 0 && getCodewordsRemaining(cachedTotalSize + lastASCII) <= 2 - lastASCII) { - return Mode.ASCII; - } - } - if (mode == Mode.C40 || - mode == Mode.TEXT || - mode == Mode.X12) { - - // see 5.2.5.2 C40 encodation rules and 5.2.7.2 ANSI X12 encodation rules - if (fromPosition + characterLength >= input.length() && getCodewordsRemaining(cachedTotalSize) == 0) { - return Mode.ASCII; - } - int lastASCII = getLastASCII(); - if (lastASCII == 1 && getCodewordsRemaining(cachedTotalSize + 1) == 0) { - return Mode.ASCII; - } - } - return mode; - } - - Mode getMode() { - return mode; - } - - /** Peeks ahead and returns 1 if the postfix consists of exactly two digits, 2 if the postfix consists of exactly - * two consecutive digits and a non extended character or of 4 digits. - * Returns 0 in any other case - **/ - int getLastASCII() { - int length = input.length(); - int from = fromPosition + characterLength; - if (length - from > 4 || from >= length) { - return 0; - } - if (length - from == 1) { - if (isExtendedASCII(input.charAt(from), input.getFNC1Character())) { - return 0; - } - return 1; - } - if (length - from == 2) { - if (isExtendedASCII(input.charAt(from), input.getFNC1Character()) || isExtendedASCII(input.charAt(from + 1), - input.getFNC1Character())) { - return 0; - } - if (HighLevelEncoder.isDigit(input.charAt(from)) && HighLevelEncoder.isDigit(input.charAt(from + 1))) { - return 1; - } - return 2; - } - if (length - from == 3) { - if (HighLevelEncoder.isDigit(input.charAt(from)) && HighLevelEncoder.isDigit(input.charAt(from + 1)) - && !isExtendedASCII(input.charAt(from + 2), input.getFNC1Character())) { - return 2; - } - if (HighLevelEncoder.isDigit(input.charAt(from + 1)) && HighLevelEncoder.isDigit(input.charAt(from + 2)) - && !isExtendedASCII(input.charAt(from), input.getFNC1Character())) { - return 2; - } - return 0; - } - if (HighLevelEncoder.isDigit(input.charAt(from)) && HighLevelEncoder.isDigit(input.charAt(from + 1)) - && HighLevelEncoder.isDigit(input.charAt(from + 2)) && HighLevelEncoder.isDigit(input.charAt(from + 3))) { - return 2; - } - return 0; - } - - /** Returns the capacity in codewords of the smallest symbol that has enough capacity to fit the given minimal - * number of codewords. - **/ - int getMinSymbolSize(int minimum) { - switch (input.getShapeHint()) { - case FORCE_SQUARE: - for (int capacity : squareCodewordCapacities) { - if (capacity >= minimum) { - return capacity; - } - } - break; - case FORCE_RECTANGLE: - for (int capacity : rectangularCodewordCapacities) { - if (capacity >= minimum) { - return capacity; - } - } - break; - } - for (int capacity : allCodewordCapacities) { - if (capacity >= minimum) { - return capacity; - } - } - return allCodewordCapacities[allCodewordCapacities.length - 1]; - } - - /** Returns the remaining capacity in codewords of the smallest symbol that has enough capacity to fit the given - * minimal number of codewords. - **/ - int getCodewordsRemaining(int minimum) { - return getMinSymbolSize(minimum) - minimum; - } - - static byte[] getBytes(int c) { - byte[] result = new byte[1]; - result[0] = (byte) c; - return result; - } - - static byte[] getBytes(int c1,int c2) { - byte[] result = new byte[2]; - result[0] = (byte) c1; - result[1] = (byte) c2; - return result; - } - - static void setC40Word(byte[] bytes, int offset, int c1, int c2, int c3) { - int val16 = (1600 * (c1 & 0xff)) + (40 * (c2 & 0xff)) + (c3 & 0xff) + 1; - bytes[offset] = (byte) (val16 / 256); - bytes[offset + 1] = (byte) (val16 % 256); - } - - private static int getX12Value(char c) { - return c == 13 ? 0 : - c == 42 ? 1 : - c == 62 ? 2 : - c == 32 ? 3 : - c >= 48 && c <= 57 ? c - 44 : - c >= 65 && c <= 90 ? c - 51 : c; - } - - byte[] getX12Words() { - assert characterLength % 3 == 0; - byte[] result = new byte[characterLength / 3 * 2]; - for (int i = 0; i < result.length; i += 2) { - setC40Word(result,i,getX12Value(input.charAt(fromPosition + i / 2 * 3)), - getX12Value(input.charAt(fromPosition + i / 2 * 3 + 1)), - getX12Value(input.charAt(fromPosition + i / 2 * 3 + 2))); - } - return result; - } - - static int getShiftValue(char c, boolean c40, int fnc1) { - return (c40 && isInC40Shift1Set(c) || - !c40 && isInTextShift1Set(c)) ? 0 : - (c40 && isInC40Shift2Set(c, fnc1) || - !c40 && isInTextShift2Set(c, fnc1)) ? 1 : 2; - } - - private static int getC40Value(boolean c40, int setIndex, char c, int fnc1) { - if (c == fnc1) { - assert setIndex == 2; - return 27; - } - if (c40) { - return c <= 31 ? c : - c == 32 ? 3 : - c <= 47 ? c - 33 : - c <= 57 ? c - 44 : - c <= 64 ? c - 43 : - c <= 90 ? c - 51 : - c <= 95 ? c - 69 : - c <= 127 ? c - 96 : c; - } else { - return c == 0 ? 0 : - setIndex == 0 && c <= 3 ? c - 1 : //is this a bug in the spec? - setIndex == 1 && c <= 31 ? c : - c == 32 ? 3 : - c >= 33 && c <= 47 ? c - 33 : - c >= 48 && c <= 57 ? c - 44 : - c >= 58 && c <= 64 ? c - 43 : - c >= 65 && c <= 90 ? c - 64 : - c >= 91 && c <= 95 ? c - 69 : - c == 96 ? 0 : - c >= 97 && c <= 122 ? c - 83 : - c >= 123 && c <= 127 ? c - 96 : c; - } - } - - byte[] getC40Words(boolean c40, int fnc1) { - List c40Values = new ArrayList<>(); - for (int i = 0; i < characterLength; i++) { - char ci = input.charAt(fromPosition + i); - if (c40 && HighLevelEncoder.isNativeC40(ci) || !c40 && HighLevelEncoder.isNativeText(ci)) { - c40Values.add((byte) getC40Value(c40, 0, ci, fnc1)); - } else if (!isExtendedASCII(ci, fnc1)) { - int shiftValue = getShiftValue(ci, c40, fnc1); - c40Values.add((byte) shiftValue); //Shift[123] - c40Values.add((byte) getC40Value(c40, shiftValue, ci, fnc1)); - } else { - char asciiValue = (char) ((ci & 0xff) - 128); - if (c40 && HighLevelEncoder.isNativeC40(asciiValue) || - !c40 && HighLevelEncoder.isNativeText(asciiValue)) { - c40Values.add((byte) 1); //Shift 2 - c40Values.add((byte) 30); //Upper Shift - c40Values.add((byte) getC40Value(c40, 0, asciiValue, fnc1)); - } else { - c40Values.add((byte) 1); //Shift 2 - c40Values.add((byte) 30); //Upper Shift - int shiftValue = getShiftValue(asciiValue, c40, fnc1); - c40Values.add((byte) shiftValue); // Shift[123] - c40Values.add((byte) getC40Value(c40, shiftValue, asciiValue, fnc1)); - } - } - } - - if ((c40Values.size() % 3) != 0) { - assert (c40Values.size() - 2) % 3 == 0 && fromPosition + characterLength == input.length(); - c40Values.add((byte) 0); // pad with 0 (Shift 1) - } - - byte[] result = new byte[c40Values.size() / 3 * 2]; - int byteIndex = 0; - for (int i = 0; i < c40Values.size(); i += 3) { - setC40Word(result,byteIndex, c40Values.get(i) & 0xff, c40Values.get(i + 1) & 0xff, c40Values.get(i + 2) & 0xff); - byteIndex += 2; - } - return result; - } - - byte[] getEDFBytes() { - int numberOfThirds = (int) Math.ceil(characterLength / 4.0); - byte[] result = new byte[numberOfThirds * 3]; - int pos = fromPosition; - int endPos = Math.min(fromPosition + characterLength - 1 , input.length() - 1); - for (int i = 0; i < numberOfThirds; i += 3) { - int[] edfValues = new int[4]; - for (int j = 0; j < 4; j++) { - if (pos <= endPos) { - edfValues[j] = input.charAt(pos++) & 0x3f; - } else { - edfValues[j] = pos == endPos + 1 ? 0x1f : 0; - } - } - int val24 = edfValues[0] << 18; - val24 |= edfValues[1] << 12; - val24 |= edfValues[2] << 6; - val24 |= edfValues[3]; - result[i] = (byte) ((val24 >> 16) & 0xff); - result[i + 1] = (byte) ((val24 >> 8) & 0xff); - result[i + 2] = (byte) (val24 & 0xff); - } - return result; - } - - byte[] getLatchBytes() { - switch (getPreviousMode()) { - case ASCII: - case B256: //after B256 ends (via length) we are back to ASCII - switch (mode) { - case B256: - return getBytes(231); - case C40: - return getBytes(230); - case TEXT: - return getBytes(239); - case X12: - return getBytes(238); - case EDF: - return getBytes(240); - } - break; - case C40: - case TEXT: - case X12: - if (mode != getPreviousMode()) { - switch (mode) { - case ASCII: - return getBytes(254); - case B256: - return getBytes(254, 231); - case C40: - return getBytes(254, 230); - case TEXT: - return getBytes(254, 239); - case X12: - return getBytes(254, 238); - case EDF: - return getBytes(254, 240); - } - } - break; - case EDF: - assert mode == Mode.EDF; //The rightmost EDIFACT edge always contains an unlatch character - break; - } - return new byte[0]; - } - - // Important: The function does not return the length bytes (one or two) in case of B256 encoding - byte[] getDataBytes() { - switch (mode) { - case ASCII: - if (input.isECI(fromPosition)) { - return getBytes(241,input.getECIValue(fromPosition) + 1); - } else if (isExtendedASCII(input.charAt(fromPosition), input.getFNC1Character())) { - return getBytes(235,input.charAt(fromPosition) - 127); - } else if (characterLength == 2) { - return getBytes((input.charAt(fromPosition) - '0') * 10 + input.charAt(fromPosition + 1) - '0' + 130); - } else if (input.isFNC1(fromPosition)) { - return getBytes(232); - } else { - return getBytes(input.charAt(fromPosition) + 1); - } - case B256: - return getBytes(input.charAt(fromPosition)); - case C40: - return getC40Words(true, input.getFNC1Character()); - case TEXT: - return getC40Words(false, input.getFNC1Character()); - case X12: - return getX12Words(); - case EDF: - return getEDFBytes(); - } - assert false; - return new byte[0]; - } - } - - private static final class Result { - - private final byte[] bytes; - - Result(Edge solution) { - Input input = solution.input; - int size = 0; - List bytesAL = new ArrayList<>(); - List randomizePostfixLength = new ArrayList<>(); - List randomizeLengths = new ArrayList<>(); - if ((solution.mode == Mode.C40 || - solution.mode == Mode.TEXT || - solution.mode == Mode.X12) && - solution.getEndMode() != Mode.ASCII) { - size += prepend(MinimalEncoder.Edge.getBytes(254),bytesAL); - } - Edge current = solution; - while (current != null) { - size += prepend(current.getDataBytes(),bytesAL); - - if (current.previous == null || current.getPreviousStartMode() != current.getMode()) { - if (current.getMode() == Mode.B256) { - if (size <= 249) { - bytesAL.add(0, (byte) size); - size++; - } else { - bytesAL.add(0, (byte) (size % 250)); - bytesAL.add(0, (byte) (size / 250 + 249)); - size += 2; - } - randomizePostfixLength.add(bytesAL.size()); - randomizeLengths.add(size); - } - prepend(current.getLatchBytes(), bytesAL); - size = 0; - } - - current = current.previous; - } - if (input.getMacroId() == 5) { - size += prepend(MinimalEncoder.Edge.getBytes(236), bytesAL); - } else if (input.getMacroId() == 6) { - size += prepend(MinimalEncoder.Edge.getBytes(237), bytesAL); - } - - if (input.getFNC1Character() > 0) { - size += prepend(MinimalEncoder.Edge.getBytes(232), bytesAL); - } - for (int i = 0; i < randomizePostfixLength.size(); i++) { - applyRandomPattern(bytesAL,bytesAL.size() - randomizePostfixLength.get(i), randomizeLengths.get(i)); - } - //add padding - int capacity = solution.getMinSymbolSize(bytesAL.size()); - if (bytesAL.size() < capacity) { - bytesAL.add((byte) 129); - } - while (bytesAL.size() < capacity) { - bytesAL.add((byte) randomize253State(bytesAL.size() + 1)); - } - - bytes = new byte[bytesAL.size()]; - for (int i = 0; i < bytes.length; i++) { - bytes[i] = bytesAL.get(i); - } - } - - static int prepend(byte[] bytes, List into) { - for (int i = bytes.length - 1; i >= 0; i--) { - into.add(0, bytes[i]); - } - return bytes.length; - } - - private static int randomize253State(int codewordPosition) { - int pseudoRandom = ((149 * codewordPosition) % 253) + 1; - int tempVariable = 129 + pseudoRandom; - return tempVariable <= 254 ? tempVariable : tempVariable - 254; - } - - static void applyRandomPattern(List bytesAL,int startPosition, int length) { - for (int i = 0; i < length; i++) { - //See "B.1 253-state algorithm - int Pad_codeword_position = startPosition + i; - int Pad_codeword_value = bytesAL.get(Pad_codeword_position) & 0xff; - int pseudo_random_number = ((149 * (Pad_codeword_position + 1)) % 255) + 1; - int temp_variable = Pad_codeword_value + pseudo_random_number; - bytesAL.set(Pad_codeword_position, (byte) (temp_variable <= 255 ? temp_variable : temp_variable - 256)); - } - } - - public byte[] getBytes() { - return bytes; - } - - } - - private static final class Input extends MinimalECIInput { - - private final SymbolShapeHint shape; - private final int macroId; - - private Input(String stringToEncode, Charset priorityCharset, int fnc1, SymbolShapeHint shape, int macroId) { - super(stringToEncode, priorityCharset, fnc1); - this.shape = shape; - this.macroId = macroId; - } - - private int getMacroId() { - return macroId; - } - - private SymbolShapeHint getShapeHint() { - return shape; - } - } -} diff --git a/port_src/core/DONE/datamatrix/encoder/SymbolInfo.java b/port_src/core/DONE/datamatrix/encoder/SymbolInfo.java deleted file mode 100644 index d57ffd0..0000000 --- a/port_src/core/DONE/datamatrix/encoder/SymbolInfo.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright 2006 Jeremias Maerki - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -import com.google.zxing.Dimension; - -/** - * Symbol info table for DataMatrix. - * - * @version $Id$ - */ -public class SymbolInfo { - - static final SymbolInfo[] PROD_SYMBOLS = { - new SymbolInfo(false, 3, 5, 8, 8, 1), - new SymbolInfo(false, 5, 7, 10, 10, 1), - /*rect*/new SymbolInfo(true, 5, 7, 16, 6, 1), - new SymbolInfo(false, 8, 10, 12, 12, 1), - /*rect*/new SymbolInfo(true, 10, 11, 14, 6, 2), - new SymbolInfo(false, 12, 12, 14, 14, 1), - /*rect*/new SymbolInfo(true, 16, 14, 24, 10, 1), - - new SymbolInfo(false, 18, 14, 16, 16, 1), - new SymbolInfo(false, 22, 18, 18, 18, 1), - /*rect*/new SymbolInfo(true, 22, 18, 16, 10, 2), - new SymbolInfo(false, 30, 20, 20, 20, 1), - /*rect*/new SymbolInfo(true, 32, 24, 16, 14, 2), - new SymbolInfo(false, 36, 24, 22, 22, 1), - new SymbolInfo(false, 44, 28, 24, 24, 1), - /*rect*/new SymbolInfo(true, 49, 28, 22, 14, 2), - - new SymbolInfo(false, 62, 36, 14, 14, 4), - new SymbolInfo(false, 86, 42, 16, 16, 4), - new SymbolInfo(false, 114, 48, 18, 18, 4), - new SymbolInfo(false, 144, 56, 20, 20, 4), - new SymbolInfo(false, 174, 68, 22, 22, 4), - - new SymbolInfo(false, 204, 84, 24, 24, 4, 102, 42), - new SymbolInfo(false, 280, 112, 14, 14, 16, 140, 56), - new SymbolInfo(false, 368, 144, 16, 16, 16, 92, 36), - new SymbolInfo(false, 456, 192, 18, 18, 16, 114, 48), - new SymbolInfo(false, 576, 224, 20, 20, 16, 144, 56), - new SymbolInfo(false, 696, 272, 22, 22, 16, 174, 68), - new SymbolInfo(false, 816, 336, 24, 24, 16, 136, 56), - new SymbolInfo(false, 1050, 408, 18, 18, 36, 175, 68), - new SymbolInfo(false, 1304, 496, 20, 20, 36, 163, 62), - new DataMatrixSymbolInfo144(), - }; - - private static SymbolInfo[] symbols = PROD_SYMBOLS; - - private final boolean rectangular; - private final int dataCapacity; - private final int errorCodewords; - public final int matrixWidth; - public final int matrixHeight; - private final int dataRegions; - private final int rsBlockData; - private final int rsBlockError; - - /** - * Overrides the symbol info set used by this class. Used for testing purposes. - * - * @param override the symbol info set to use - */ - public static void overrideSymbolSet(SymbolInfo[] override) { - symbols = override; - } - - public SymbolInfo(boolean rectangular, int dataCapacity, int errorCodewords, - int matrixWidth, int matrixHeight, int dataRegions) { - this(rectangular, dataCapacity, errorCodewords, matrixWidth, matrixHeight, dataRegions, - dataCapacity, errorCodewords); - } - - SymbolInfo(boolean rectangular, int dataCapacity, int errorCodewords, - int matrixWidth, int matrixHeight, int dataRegions, - int rsBlockData, int rsBlockError) { - this.rectangular = rectangular; - this.dataCapacity = dataCapacity; - this.errorCodewords = errorCodewords; - this.matrixWidth = matrixWidth; - this.matrixHeight = matrixHeight; - this.dataRegions = dataRegions; - this.rsBlockData = rsBlockData; - this.rsBlockError = rsBlockError; - } - - public static SymbolInfo lookup(int dataCodewords) { - return lookup(dataCodewords, SymbolShapeHint.FORCE_NONE, true); - } - - public static SymbolInfo lookup(int dataCodewords, SymbolShapeHint shape) { - return lookup(dataCodewords, shape, true); - } - - public static SymbolInfo lookup(int dataCodewords, boolean allowRectangular, boolean fail) { - SymbolShapeHint shape = allowRectangular - ? SymbolShapeHint.FORCE_NONE : SymbolShapeHint.FORCE_SQUARE; - return lookup(dataCodewords, shape, fail); - } - - private static SymbolInfo lookup(int dataCodewords, SymbolShapeHint shape, boolean fail) { - return lookup(dataCodewords, shape, null, null, fail); - } - - public static SymbolInfo lookup(int dataCodewords, - SymbolShapeHint shape, - Dimension minSize, - Dimension maxSize, - boolean fail) { - for (SymbolInfo symbol : symbols) { - if (shape == SymbolShapeHint.FORCE_SQUARE && symbol.rectangular) { - continue; - } - if (shape == SymbolShapeHint.FORCE_RECTANGLE && !symbol.rectangular) { - continue; - } - if (minSize != null - && (symbol.getSymbolWidth() < minSize.getWidth() - || symbol.getSymbolHeight() < minSize.getHeight())) { - continue; - } - if (maxSize != null - && (symbol.getSymbolWidth() > maxSize.getWidth() - || symbol.getSymbolHeight() > maxSize.getHeight())) { - continue; - } - if (dataCodewords <= symbol.dataCapacity) { - return symbol; - } - } - if (fail) { - throw new IllegalArgumentException( - "Can't find a symbol arrangement that matches the message. Data codewords: " - + dataCodewords); - } - return null; - } - - private int getHorizontalDataRegions() { - switch (dataRegions) { - case 1: - return 1; - case 2: - case 4: - return 2; - case 16: - return 4; - case 36: - return 6; - default: - throw new IllegalStateException("Cannot handle this number of data regions"); - } - } - - private int getVerticalDataRegions() { - switch (dataRegions) { - case 1: - case 2: - return 1; - case 4: - return 2; - case 16: - return 4; - case 36: - return 6; - default: - throw new IllegalStateException("Cannot handle this number of data regions"); - } - } - - public final int getSymbolDataWidth() { - return getHorizontalDataRegions() * matrixWidth; - } - - public final int getSymbolDataHeight() { - return getVerticalDataRegions() * matrixHeight; - } - - public final int getSymbolWidth() { - return getSymbolDataWidth() + (getHorizontalDataRegions() * 2); - } - - public final int getSymbolHeight() { - return getSymbolDataHeight() + (getVerticalDataRegions() * 2); - } - - public int getCodewordCount() { - return dataCapacity + errorCodewords; - } - - public int getInterleavedBlockCount() { - return dataCapacity / rsBlockData; - } - - public final int getDataCapacity() { - return dataCapacity; - } - - public final int getErrorCodewords() { - return errorCodewords; - } - - public int getDataLengthForInterleavedBlock(int index) { - return rsBlockData; - } - - public final int getErrorLengthForInterleavedBlock(int index) { - return rsBlockError; - } - - @Override - public final String toString() { - return (rectangular ? "Rectangular Symbol:" : "Square Symbol:") + - " data region " + matrixWidth + 'x' + matrixHeight + - ", symbol size " + getSymbolWidth() + 'x' + getSymbolHeight() + - ", symbol data size " + getSymbolDataWidth() + 'x' + getSymbolDataHeight() + - ", codewords " + dataCapacity + '+' + errorCodewords; - } - -} diff --git a/port_src/core/DONE/datamatrix/encoder/SymbolShapeHint.java b/port_src/core/DONE/datamatrix/encoder/SymbolShapeHint.java deleted file mode 100644 index 898727f..0000000 --- a/port_src/core/DONE/datamatrix/encoder/SymbolShapeHint.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -/** - * Enumeration for DataMatrix symbol shape hint. It can be used to force square or rectangular - * symbols. - */ -public enum SymbolShapeHint { - - FORCE_NONE, - FORCE_SQUARE, - FORCE_RECTANGLE, - -} diff --git a/port_src/core/DONE/datamatrix/encoder/TextEncoder.java b/port_src/core/DONE/datamatrix/encoder/TextEncoder.java deleted file mode 100644 index 24286ac..0000000 --- a/port_src/core/DONE/datamatrix/encoder/TextEncoder.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -final class TextEncoder extends C40Encoder { - - @Override - public int getEncodingMode() { - return HighLevelEncoder.TEXT_ENCODATION; - } - - @Override - int encodeChar(char c, StringBuilder sb) { - if (c == ' ') { - sb.append('\3'); - return 1; - } - if (c >= '0' && c <= '9') { - sb.append((char) (c - 48 + 4)); - return 1; - } - if (c >= 'a' && c <= 'z') { - sb.append((char) (c - 97 + 14)); - return 1; - } - if (c < ' ') { - sb.append('\0'); //Shift 1 Set - sb.append(c); - return 2; - } - if (c <= '/') { - sb.append('\1'); //Shift 2 Set - sb.append((char) (c - 33)); - return 2; - } - if (c <= '@') { - sb.append('\1'); //Shift 2 Set - sb.append((char) (c - 58 + 15)); - return 2; - } - if (c >= '[' && c <= '_') { - sb.append('\1'); //Shift 2 Set - sb.append((char) (c - 91 + 22)); - return 2; - } - if (c == '`') { - sb.append('\2'); //Shift 3 Set - sb.append((char) 0); // '`' - 96 == 0 - return 2; - } - if (c <= 'Z') { - sb.append('\2'); //Shift 3 Set - sb.append((char) (c - 65 + 1)); - return 2; - } - if (c <= 127) { - sb.append('\2'); //Shift 3 Set - sb.append((char) (c - 123 + 27)); - return 2; - } - sb.append("\1\u001e"); //Shift 2, Upper Shift - int len = 2; - len += encodeChar((char) (c - 128), sb); - return len; - } - -} diff --git a/port_src/core/DONE/datamatrix/encoder/X12Encoder.java b/port_src/core/DONE/datamatrix/encoder/X12Encoder.java deleted file mode 100644 index 79daf49..0000000 --- a/port_src/core/DONE/datamatrix/encoder/X12Encoder.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -final class X12Encoder extends C40Encoder { - - @Override - public int getEncodingMode() { - return HighLevelEncoder.X12_ENCODATION; - } - - @Override - public void encode(EncoderContext context) { - //step C - StringBuilder buffer = new StringBuilder(); - while (context.hasMoreCharacters()) { - char c = context.getCurrentChar(); - context.pos++; - - encodeChar(c, buffer); - - int count = buffer.length(); - if ((count % 3) == 0) { - writeNextTriplet(context, buffer); - - int newMode = HighLevelEncoder.lookAheadTest(context.getMessage(), context.pos, getEncodingMode()); - if (newMode != getEncodingMode()) { - // Return to ASCII encodation, which will actually handle latch to new mode - context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION); - break; - } - } - } - handleEOD(context, buffer); - } - - @Override - int encodeChar(char c, StringBuilder sb) { - switch (c) { - case '\r': - sb.append('\0'); - break; - case '*': - sb.append('\1'); - break; - case '>': - sb.append('\2'); - break; - case ' ': - sb.append('\3'); - break; - default: - if (c >= '0' && c <= '9') { - sb.append((char) (c - 48 + 4)); - } else if (c >= 'A' && c <= 'Z') { - sb.append((char) (c - 65 + 14)); - } else { - HighLevelEncoder.illegalCharacter(c); - } - break; - } - return 1; - } - - @Override - void handleEOD(EncoderContext context, StringBuilder buffer) { - context.updateSymbolInfo(); - int available = context.getSymbolInfo().getDataCapacity() - context.getCodewordCount(); - int count = buffer.length(); - context.pos -= count; - if (context.getRemainingCharacters() > 1 || available > 1 || - context.getRemainingCharacters() != available) { - context.writeCodeword(HighLevelEncoder.X12_UNLATCH); - } - if (context.getNewEncoding() < 0) { - context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION); - } - } -} diff --git a/port_src/core/DONE/maxicode/MaxiCodeReader.java b/port_src/core/DONE/maxicode/MaxiCodeReader.java deleted file mode 100644 index 0cb32ff..0000000 --- a/port_src/core/DONE/maxicode/MaxiCodeReader.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.maxicode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Reader; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.maxicode.decoder.Decoder; - -import java.util.Map; - -/** - * This implementation can detect and decode a MaxiCode in an image. - */ -public final class MaxiCodeReader implements Reader { - - private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; - private static final int MATRIX_WIDTH = 30; - private static final int MATRIX_HEIGHT = 33; - - private final Decoder decoder = new Decoder(); - - /** - * Locates and decodes a MaxiCode in an image. - * - * @return a String representing the content encoded by the MaxiCode - * @throws NotFoundException if a MaxiCode cannot be found - * @throws FormatException if a MaxiCode cannot be decoded - * @throws ChecksumException if error correction fails - */ - @Override - public Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException { - return decode(image, null); - } - - @Override - public Result decode(BinaryBitmap image, Map hints) - throws NotFoundException, ChecksumException, FormatException { - // Note that MaxiCode reader effectively always assumes PURE_BARCODE mode - // and can't detect it in an image - BitMatrix bits = extractPureBits(image.getBlackMatrix()); - DecoderResult decoderResult = decoder.decode(bits, hints); - Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), NO_POINTS, BarcodeFormat.MAXICODE); - - String ecLevel = decoderResult.getECLevel(); - if (ecLevel != null) { - result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); - } - return result; - } - - @Override - public void reset() { - // do nothing - } - - /** - * This method detects a code in a "pure" image -- that is, pure monochrome image - * which contains only an unrotated, unskewed, image of a code, with some white border - * around it. This is a specialized method that works exceptionally fast in this special - * case. - */ - private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException { - - int[] enclosingRectangle = image.getEnclosingRectangle(); - if (enclosingRectangle == null) { - throw NotFoundException.getNotFoundInstance(); - } - - int left = enclosingRectangle[0]; - int top = enclosingRectangle[1]; - int width = enclosingRectangle[2]; - int height = enclosingRectangle[3]; - - // Now just read off the bits - BitMatrix bits = new BitMatrix(MATRIX_WIDTH, MATRIX_HEIGHT); - for (int y = 0; y < MATRIX_HEIGHT; y++) { - int iy = Math.min(top + (y * height + height / 2) / MATRIX_HEIGHT, height - 1); - for (int x = 0; x < MATRIX_WIDTH; x++) { - // srowen: I don't quite understand why the formula below is necessary, but it - // can walk off the image if left + width = the right boundary. So cap it. - int ix = left + Math.min( - (x * width + width / 2 + (y & 0x01) * width / 2) / MATRIX_WIDTH, - width - 1); - if (image.get(ix, iy)) { - bits.set(x, y); - } - } - } - return bits; - } - -} diff --git a/port_src/core/DONE/maxicode/decoder/BitMatrixParser.java b/port_src/core/DONE/maxicode/decoder/BitMatrixParser.java deleted file mode 100644 index fe154b3..0000000 --- a/port_src/core/DONE/maxicode/decoder/BitMatrixParser.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.maxicode.decoder; - -import com.google.zxing.common.BitMatrix; - -/** - * @author mike32767 - * @author Manuel Kasten - */ -final class BitMatrixParser { - - @SuppressWarnings("checkstyle:lineLength") - private static final int[][] BITNR = { - {121,120,127,126,133,132,139,138,145,144,151,150,157,156,163,162,169,168,175,174,181,180,187,186,193,192,199,198, -2, -2}, - {123,122,129,128,135,134,141,140,147,146,153,152,159,158,165,164,171,170,177,176,183,182,189,188,195,194,201,200,816, -3}, - {125,124,131,130,137,136,143,142,149,148,155,154,161,160,167,166,173,172,179,178,185,184,191,190,197,196,203,202,818,817}, - {283,282,277,276,271,270,265,264,259,258,253,252,247,246,241,240,235,234,229,228,223,222,217,216,211,210,205,204,819, -3}, - {285,284,279,278,273,272,267,266,261,260,255,254,249,248,243,242,237,236,231,230,225,224,219,218,213,212,207,206,821,820}, - {287,286,281,280,275,274,269,268,263,262,257,256,251,250,245,244,239,238,233,232,227,226,221,220,215,214,209,208,822, -3}, - {289,288,295,294,301,300,307,306,313,312,319,318,325,324,331,330,337,336,343,342,349,348,355,354,361,360,367,366,824,823}, - {291,290,297,296,303,302,309,308,315,314,321,320,327,326,333,332,339,338,345,344,351,350,357,356,363,362,369,368,825, -3}, - {293,292,299,298,305,304,311,310,317,316,323,322,329,328,335,334,341,340,347,346,353,352,359,358,365,364,371,370,827,826}, - {409,408,403,402,397,396,391,390, 79, 78, -2, -2, 13, 12, 37, 36, 2, -1, 44, 43,109,108,385,384,379,378,373,372,828, -3}, - {411,410,405,404,399,398,393,392, 81, 80, 40, -2, 15, 14, 39, 38, 3, -1, -1, 45,111,110,387,386,381,380,375,374,830,829}, - {413,412,407,406,401,400,395,394, 83, 82, 41, -3, -3, -3, -3, -3, 5, 4, 47, 46,113,112,389,388,383,382,377,376,831, -3}, - {415,414,421,420,427,426,103,102, 55, 54, 16, -3, -3, -3, -3, -3, -3, -3, 20, 19, 85, 84,433,432,439,438,445,444,833,832}, - {417,416,423,422,429,428,105,104, 57, 56, -3, -3, -3, -3, -3, -3, -3, -3, 22, 21, 87, 86,435,434,441,440,447,446,834, -3}, - {419,418,425,424,431,430,107,106, 59, 58, -3, -3, -3, -3, -3, -3, -3, -3, -3, 23, 89, 88,437,436,443,442,449,448,836,835}, - {481,480,475,474,469,468, 48, -2, 30, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, 0, 53, 52,463,462,457,456,451,450,837, -3}, - {483,482,477,476,471,470, 49, -1, -2, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -2, -1,465,464,459,458,453,452,839,838}, - {485,484,479,478,473,472, 51, 50, 31, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, 1, -2, 42,467,466,461,460,455,454,840, -3}, - {487,486,493,492,499,498, 97, 96, 61, 60, -3, -3, -3, -3, -3, -3, -3, -3, -3, 26, 91, 90,505,504,511,510,517,516,842,841}, - {489,488,495,494,501,500, 99, 98, 63, 62, -3, -3, -3, -3, -3, -3, -3, -3, 28, 27, 93, 92,507,506,513,512,519,518,843, -3}, - {491,490,497,496,503,502,101,100, 65, 64, 17, -3, -3, -3, -3, -3, -3, -3, 18, 29, 95, 94,509,508,515,514,521,520,845,844}, - {559,558,553,552,547,546,541,540, 73, 72, 32, -3, -3, -3, -3, -3, -3, 10, 67, 66,115,114,535,534,529,528,523,522,846, -3}, - {561,560,555,554,549,548,543,542, 75, 74, -2, -1, 7, 6, 35, 34, 11, -2, 69, 68,117,116,537,536,531,530,525,524,848,847}, - {563,562,557,556,551,550,545,544, 77, 76, -2, 33, 9, 8, 25, 24, -1, -2, 71, 70,119,118,539,538,533,532,527,526,849, -3}, - {565,564,571,570,577,576,583,582,589,588,595,594,601,600,607,606,613,612,619,618,625,624,631,630,637,636,643,642,851,850}, - {567,566,573,572,579,578,585,584,591,590,597,596,603,602,609,608,615,614,621,620,627,626,633,632,639,638,645,644,852, -3}, - {569,568,575,574,581,580,587,586,593,592,599,598,605,604,611,610,617,616,623,622,629,628,635,634,641,640,647,646,854,853}, - {727,726,721,720,715,714,709,708,703,702,697,696,691,690,685,684,679,678,673,672,667,666,661,660,655,654,649,648,855, -3}, - {729,728,723,722,717,716,711,710,705,704,699,698,693,692,687,686,681,680,675,674,669,668,663,662,657,656,651,650,857,856}, - {731,730,725,724,719,718,713,712,707,706,701,700,695,694,689,688,683,682,677,676,671,670,665,664,659,658,653,652,858, -3}, - {733,732,739,738,745,744,751,750,757,756,763,762,769,768,775,774,781,780,787,786,793,792,799,798,805,804,811,810,860,859}, - {735,734,741,740,747,746,753,752,759,758,765,764,771,770,777,776,783,782,789,788,795,794,801,800,807,806,813,812,861, -3}, - {737,736,743,742,749,748,755,754,761,760,767,766,773,772,779,778,785,784,791,790,797,796,803,802,809,808,815,814,863,862} - }; - - private final BitMatrix bitMatrix; - - /** - * @param bitMatrix {@link BitMatrix} to parse - */ - BitMatrixParser(BitMatrix bitMatrix) { - this.bitMatrix = bitMatrix; - } - - byte[] readCodewords() { - byte[] result = new byte[144]; - int height = bitMatrix.getHeight(); - int width = bitMatrix.getWidth(); - for (int y = 0; y < height; y++) { - int[] bitnrRow = BITNR[y]; - for (int x = 0; x < width; x++) { - int bit = bitnrRow[x]; - if (bit >= 0 && bitMatrix.get(x, y)) { - result[bit / 6] |= (byte) (1 << (5 - (bit % 6))); - } - } - } - return result; - } - -} diff --git a/port_src/core/DONE/maxicode/decoder/DecodedBitStreamParser.java b/port_src/core/DONE/maxicode/decoder/DecodedBitStreamParser.java deleted file mode 100644 index 9ebf7e8..0000000 --- a/port_src/core/DONE/maxicode/decoder/DecodedBitStreamParser.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.maxicode.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.common.DecoderResult; -import java.text.DecimalFormat; -import java.text.NumberFormat; - -/** - *

MaxiCodes can encode text or structured information as bits in one of several modes, - * with multiple character sets in one code. This class decodes the bits back into text.

- * - * @author mike32767 - * @author Manuel Kasten - */ -final class DecodedBitStreamParser { - - private static final char SHIFTA = '\uFFF0'; - private static final char SHIFTB = '\uFFF1'; - private static final char SHIFTC = '\uFFF2'; - private static final char SHIFTD = '\uFFF3'; - private static final char SHIFTE = '\uFFF4'; - private static final char TWOSHIFTA = '\uFFF5'; - private static final char THREESHIFTA = '\uFFF6'; - private static final char LATCHA = '\uFFF7'; - private static final char LATCHB = '\uFFF8'; - private static final char LOCK = '\uFFF9'; - private static final char ECI = '\uFFFA'; - private static final char NS = '\uFFFB'; - private static final char PAD = '\uFFFC'; - private static final char FS = '\u001C'; - private static final char GS = '\u001D'; - private static final char RS = '\u001E'; - private static final byte[] COUNTRY_BYTES = { 53, 54, 43, 44, 45, 46, 47, 48, 37, 38 }; - private static final byte[] SERVICE_CLASS_BYTES = { 55, 56, 57, 58, 59, 60, 49, 50, 51, 52 }; - private static final byte[] POSTCODE_2_LENGTH_BYTES = { 39, 40, 41, 42, 31, 32 }; - private static final byte[] POSTCODE_2_BYTES = { 33, 34, 35, 36, 25, 26, 27, 28, 29, 30, 19, - 20, 21, 22, 23, 24, 13, 14, 15, 16, 17, 18, 7, 8, 9, 10, 11, 12, 1, 2 }; - private static final byte[][] POSTCODE_3_BYTES = { - { 39, 40, 41, 42, 31, 32}, - { 33, 34, 35, 36, 25, 26}, - { 27, 28, 29, 30, 19, 20}, - { 21, 22, 23, 24, 13, 14}, - { 15, 16, 17, 18, 7, 8}, - { 9, 10, 11, 12, 1, 2} - }; - - @SuppressWarnings("checkstyle:lineLength") - private static final String[] SETS = { - "\rABCDEFGHIJKLMNOPQRSTUVWXYZ" + ECI + FS + GS + RS + NS + ' ' + PAD + - "\"#$%&'()*+,-./0123456789:" + SHIFTB + SHIFTC + SHIFTD + SHIFTE + LATCHB, - "`abcdefghijklmnopqrstuvwxyz" + ECI + FS + GS + RS + NS + '{' + PAD + - "}~\u007F;<=>?[\\]^_ ,./:@!|" + PAD + TWOSHIFTA + THREESHIFTA + PAD + - SHIFTA + SHIFTC + SHIFTD + SHIFTE + LATCHA, - "\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA" + - ECI + FS + GS + RS + NS + - "\u00DB\u00DC\u00DD\u00DE\u00DF\u00AA\u00AC\u00B1\u00B2\u00B3\u00B5\u00B9\u00BA\u00BC\u00BD\u00BE\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089" + - LATCHA + ' ' + LOCK + SHIFTD + SHIFTE + LATCHB, - "\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA" + - ECI + FS + GS + RS + NS + - "\u00FB\u00FC\u00FD\u00FE\u00FF\u00A1\u00A8\u00AB\u00AF\u00B0\u00B4\u00B7\u00B8\u00BB\u00BF\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094" + - LATCHA + ' ' + SHIFTC + LOCK + SHIFTE + LATCHB, - "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\n\u000B\u000C\r\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A" + - ECI + PAD + PAD + '\u001B' + NS + FS + GS + RS + - "\u001F\u009F\u00A0\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A9\u00AD\u00AE\u00B6\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E" + - LATCHA + ' ' + SHIFTC + SHIFTD + LOCK + LATCHB, - }; - - private DecodedBitStreamParser() { - } - - static DecoderResult decode(byte[] bytes, int mode) throws FormatException { - StringBuilder result = new StringBuilder(144); - switch (mode) { - case 2: - case 3: - String postcode; - if (mode == 2) { - int pc = getPostCode2(bytes); - int ps2Length = getPostCode2Length(bytes); - if (ps2Length > 10) { - throw FormatException.getFormatInstance(); - } - NumberFormat df = new DecimalFormat("0000000000".substring(0, ps2Length)); - postcode = df.format(pc); - } else { - postcode = getPostCode3(bytes); - } - NumberFormat threeDigits = new DecimalFormat("000"); - String country = threeDigits.format(getCountry(bytes)); - String service = threeDigits.format(getServiceClass(bytes)); - result.append(getMessage(bytes, 10, 84)); - if (result.toString().startsWith("[)>" + RS + "01" + GS)) { - result.insert(9, postcode + GS + country + GS + service + GS); - } else { - result.insert(0, postcode + GS + country + GS + service + GS); - } - break; - case 4: - result.append(getMessage(bytes, 1, 93)); - break; - case 5: - result.append(getMessage(bytes, 1, 77)); - break; - } - return new DecoderResult(bytes, result.toString(), null, String.valueOf(mode)); - } - - private static int getBit(int bit, byte[] bytes) { - bit--; - return (bytes[bit / 6] & (1 << (5 - (bit % 6)))) == 0 ? 0 : 1; - } - - private static int getInt(byte[] bytes, byte[] x) { - int val = 0; - for (int i = 0; i < x.length; i++) { - val += getBit(x[i], bytes) << (x.length - i - 1); - } - return val; - } - - private static int getCountry(byte[] bytes) { - return getInt(bytes, COUNTRY_BYTES); - } - - private static int getServiceClass(byte[] bytes) { - return getInt(bytes, SERVICE_CLASS_BYTES); - } - - private static int getPostCode2Length(byte[] bytes) { - return getInt(bytes, POSTCODE_2_LENGTH_BYTES); - } - - private static int getPostCode2(byte[] bytes) { - return getInt(bytes, POSTCODE_2_BYTES); - } - - private static String getPostCode3(byte[] bytes) { - StringBuilder sb = new StringBuilder(POSTCODE_3_BYTES.length); - for (byte[] p3bytes : POSTCODE_3_BYTES) { - sb.append(SETS[0].charAt(getInt(bytes, p3bytes))); - } - return sb.toString(); - } - - private static String getMessage(byte[] bytes, int start, int len) { - StringBuilder sb = new StringBuilder(); - int shift = -1; - int set = 0; - int lastset = 0; - for (int i = start; i < start + len; i++) { - char c = SETS[set].charAt(bytes[i]); - switch (c) { - case LATCHA: - set = 0; - shift = -1; - break; - case LATCHB: - set = 1; - shift = -1; - break; - case SHIFTA: - case SHIFTB: - case SHIFTC: - case SHIFTD: - case SHIFTE: - lastset = set; - set = c - SHIFTA; - shift = 1; - break; - case TWOSHIFTA: - lastset = set; - set = 0; - shift = 2; - break; - case THREESHIFTA: - lastset = set; - set = 0; - shift = 3; - break; - case NS: - int nsval = (bytes[++i] << 24) + (bytes[++i] << 18) + (bytes[++i] << 12) + (bytes[++i] << 6) + bytes[++i]; - sb.append(new DecimalFormat("000000000").format(nsval)); - break; - case LOCK: - shift = -1; - break; - default: - sb.append(c); - } - if (shift-- == 0) { - set = lastset; - } - } - while (sb.length() > 0 && sb.charAt(sb.length() - 1) == PAD) { - sb.setLength(sb.length() - 1); - } - return sb.toString(); - } - -} diff --git a/port_src/core/DONE/maxicode/decoder/Decoder.java b/port_src/core/DONE/maxicode/decoder/Decoder.java deleted file mode 100644 index f7836f4..0000000 --- a/port_src/core/DONE/maxicode/decoder/Decoder.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.maxicode.decoder; - -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.reedsolomon.GenericGF; -import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; -import com.google.zxing.common.reedsolomon.ReedSolomonException; - -import java.util.Map; - -/** - *

The main class which implements MaxiCode decoding -- as opposed to locating and extracting - * the MaxiCode from an image.

- * - * @author Manuel Kasten - */ -public final class Decoder { - - private static final int ALL = 0; - private static final int EVEN = 1; - private static final int ODD = 2; - - private final ReedSolomonDecoder rsDecoder; - - public Decoder() { - rsDecoder = new ReedSolomonDecoder(GenericGF.MAXICODE_FIELD_64); - } - - public DecoderResult decode(BitMatrix bits) throws ChecksumException, FormatException { - return decode(bits, null); - } - - public DecoderResult decode(BitMatrix bits, - Map hints) throws FormatException, ChecksumException { - BitMatrixParser parser = new BitMatrixParser(bits); - byte[] codewords = parser.readCodewords(); - - correctErrors(codewords, 0, 10, 10, ALL); - int mode = codewords[0] & 0x0F; - byte[] datawords; - switch (mode) { - case 2: - case 3: - case 4: - correctErrors(codewords, 20, 84, 40, EVEN); - correctErrors(codewords, 20, 84, 40, ODD); - datawords = new byte[94]; - break; - case 5: - correctErrors(codewords, 20, 68, 56, EVEN); - correctErrors(codewords, 20, 68, 56, ODD); - datawords = new byte[78]; - break; - default: - throw FormatException.getFormatInstance(); - } - - System.arraycopy(codewords, 0, datawords, 0, 10); - System.arraycopy(codewords, 20, datawords, 10, datawords.length - 10); - - return DecodedBitStreamParser.decode(datawords, mode); - } - - private void correctErrors(byte[] codewordBytes, - int start, - int dataCodewords, - int ecCodewords, - int mode) throws ChecksumException { - int codewords = dataCodewords + ecCodewords; - - // in EVEN or ODD mode only half the codewords - int divisor = mode == ALL ? 1 : 2; - - // First read into an array of ints - int[] codewordsInts = new int[codewords / divisor]; - for (int i = 0; i < codewords; i++) { - if ((mode == ALL) || (i % 2 == (mode - 1))) { - codewordsInts[i / divisor] = codewordBytes[i + start] & 0xFF; - } - } - try { - rsDecoder.decode(codewordsInts, ecCodewords / divisor); - } catch (ReedSolomonException ignored) { - throw ChecksumException.getChecksumInstance(); - } - // Copy back into array of bytes -- only need to worry about the bytes that were data - // We don't care about errors in the error-correction codewords - for (int i = 0; i < dataCodewords; i++) { - if ((mode == ALL) || (i % 2 == (mode - 1))) { - codewordBytes[i + start] = (byte) codewordsInts[i / divisor]; - } - } - } - -} diff --git a/port_src/core/DONE/multi/ByQuadrantReader.java b/port_src/core/DONE/multi/ByQuadrantReader.java deleted file mode 100644 index 6674c8f..0000000 --- a/port_src/core/DONE/multi/ByQuadrantReader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.multi; - -import com.google.zxing.BinaryBitmap; -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Reader; -import com.google.zxing.Result; -import com.google.zxing.ResultPoint; - -import java.util.Map; - -/** - * This class attempts to decode a barcode from an image, not by scanning the whole image, - * but by scanning subsets of the image. This is important when there may be multiple barcodes in - * an image, and detecting a barcode may find parts of multiple barcode and fail to decode - * (e.g. QR Codes). Instead this scans the four quadrants of the image -- and also the center - * 'quadrant' to cover the case where a barcode is found in the center. - * - * @see GenericMultipleBarcodeReader - */ -public final class ByQuadrantReader implements Reader { - - private final Reader delegate; - - public ByQuadrantReader(Reader delegate) { - this.delegate = delegate; - } - - @Override - public Result decode(BinaryBitmap image) - throws NotFoundException, ChecksumException, FormatException { - return decode(image, null); - } - - @Override - public Result decode(BinaryBitmap image, Map hints) - throws NotFoundException, ChecksumException, FormatException { - - int width = image.getWidth(); - int height = image.getHeight(); - int halfWidth = width / 2; - int halfHeight = height / 2; - - try { - // No need to call makeAbsolute as results will be relative to original top left here - return delegate.decode(image.crop(0, 0, halfWidth, halfHeight), hints); - } catch (NotFoundException re) { - // continue - } - - try { - Result result = delegate.decode(image.crop(halfWidth, 0, halfWidth, halfHeight), hints); - makeAbsolute(result.getResultPoints(), halfWidth, 0); - return result; - } catch (NotFoundException re) { - // continue - } - - try { - Result result = delegate.decode(image.crop(0, halfHeight, halfWidth, halfHeight), hints); - makeAbsolute(result.getResultPoints(), 0, halfHeight); - return result; - } catch (NotFoundException re) { - // continue - } - - try { - Result result = delegate.decode(image.crop(halfWidth, halfHeight, halfWidth, halfHeight), hints); - makeAbsolute(result.getResultPoints(), halfWidth, halfHeight); - return result; - } catch (NotFoundException re) { - // continue - } - - int quarterWidth = halfWidth / 2; - int quarterHeight = halfHeight / 2; - BinaryBitmap center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight); - Result result = delegate.decode(center, hints); - makeAbsolute(result.getResultPoints(), quarterWidth, quarterHeight); - return result; - } - - @Override - public void reset() { - delegate.reset(); - } - - private static void makeAbsolute(ResultPoint[] points, int leftOffset, int topOffset) { - if (points != null) { - for (int i = 0; i < points.length; i++) { - ResultPoint relative = points[i]; - if (relative != null) { - points[i] = new ResultPoint(relative.getX() + leftOffset, relative.getY() + topOffset); - } - } - } - } - -} diff --git a/port_src/core/DONE/multi/GenericMultipleBarcodeReader.java b/port_src/core/DONE/multi/GenericMultipleBarcodeReader.java deleted file mode 100644 index 5e53419..0000000 --- a/port_src/core/DONE/multi/GenericMultipleBarcodeReader.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.multi; - -import com.google.zxing.BinaryBitmap; -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.Reader; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.ResultPoint; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - *

Attempts to locate multiple barcodes in an image by repeatedly decoding portion of the image. - * After one barcode is found, the areas left, above, right and below the barcode's - * {@link ResultPoint}s are scanned, recursively.

- * - *

A caller may want to also employ {@link ByQuadrantReader} when attempting to find multiple - * 2D barcodes, like QR Codes, in an image, where the presence of multiple barcodes might prevent - * detecting any one of them.

- * - *

That is, instead of passing a {@link Reader} a caller might pass - * {@code new ByQuadrantReader(reader)}.

- * - * @author Sean Owen - */ -public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader { - - private static final int MIN_DIMENSION_TO_RECUR = 100; - private static final int MAX_DEPTH = 4; - - static final Result[] EMPTY_RESULT_ARRAY = new Result[0]; - - private final Reader delegate; - - public GenericMultipleBarcodeReader(Reader delegate) { - this.delegate = delegate; - } - - @Override - public Result[] decodeMultiple(BinaryBitmap image) throws NotFoundException { - return decodeMultiple(image, null); - } - - @Override - public Result[] decodeMultiple(BinaryBitmap image, Map hints) - throws NotFoundException { - List results = new ArrayList<>(); - doDecodeMultiple(image, hints, results, 0, 0, 0); - if (results.isEmpty()) { - throw NotFoundException.getNotFoundInstance(); - } - return results.toArray(EMPTY_RESULT_ARRAY); - } - - private void doDecodeMultiple(BinaryBitmap image, - Map hints, - List results, - int xOffset, - int yOffset, - int currentDepth) { - if (currentDepth > MAX_DEPTH) { - return; - } - - Result result; - try { - result = delegate.decode(image, hints); - } catch (ReaderException ignored) { - return; - } - boolean alreadyFound = false; - for (Result existingResult : results) { - if (existingResult.getText().equals(result.getText())) { - alreadyFound = true; - break; - } - } - if (!alreadyFound) { - results.add(translateResultPoints(result, xOffset, yOffset)); - } - ResultPoint[] resultPoints = result.getResultPoints(); - if (resultPoints == null || resultPoints.length == 0) { - return; - } - int width = image.getWidth(); - int height = image.getHeight(); - float minX = width; - float minY = height; - float maxX = 0.0f; - float maxY = 0.0f; - for (ResultPoint point : resultPoints) { - if (point == null) { - continue; - } - float x = point.getX(); - float y = point.getY(); - if (x < minX) { - minX = x; - } - if (y < minY) { - minY = y; - } - if (x > maxX) { - maxX = x; - } - if (y > maxY) { - maxY = y; - } - } - - // Decode left of barcode - if (minX > MIN_DIMENSION_TO_RECUR) { - doDecodeMultiple(image.crop(0, 0, (int) minX, height), - hints, results, - xOffset, yOffset, - currentDepth + 1); - } - // Decode above barcode - if (minY > MIN_DIMENSION_TO_RECUR) { - doDecodeMultiple(image.crop(0, 0, width, (int) minY), - hints, results, - xOffset, yOffset, - currentDepth + 1); - } - // Decode right of barcode - if (maxX < width - MIN_DIMENSION_TO_RECUR) { - doDecodeMultiple(image.crop((int) maxX, 0, width - (int) maxX, height), - hints, results, - xOffset + (int) maxX, yOffset, - currentDepth + 1); - } - // Decode below barcode - if (maxY < height - MIN_DIMENSION_TO_RECUR) { - doDecodeMultiple(image.crop(0, (int) maxY, width, height - (int) maxY), - hints, results, - xOffset, yOffset + (int) maxY, - currentDepth + 1); - } - } - - private static Result translateResultPoints(Result result, int xOffset, int yOffset) { - ResultPoint[] oldResultPoints = result.getResultPoints(); - if (oldResultPoints == null) { - return result; - } - ResultPoint[] newResultPoints = new ResultPoint[oldResultPoints.length]; - for (int i = 0; i < oldResultPoints.length; i++) { - ResultPoint oldPoint = oldResultPoints[i]; - if (oldPoint != null) { - newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset); - } - } - Result newResult = new Result(result.getText(), - result.getRawBytes(), - result.getNumBits(), - newResultPoints, - result.getBarcodeFormat(), - result.getTimestamp()); - newResult.putAllMetadata(result.getResultMetadata()); - return newResult; - } - -} diff --git a/port_src/core/DONE/multi/MultipleBarcodeReader.java b/port_src/core/DONE/multi/MultipleBarcodeReader.java deleted file mode 100644 index a358727..0000000 --- a/port_src/core/DONE/multi/MultipleBarcodeReader.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.multi; - -import com.google.zxing.BinaryBitmap; -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; - -import java.util.Map; - -/** - * Implementation of this interface attempt to read several barcodes from one image. - * - * @see com.google.zxing.Reader - * @author Sean Owen - */ -public interface MultipleBarcodeReader { - - Result[] decodeMultiple(BinaryBitmap image) throws NotFoundException; - - Result[] decodeMultiple(BinaryBitmap image, - Map hints) throws NotFoundException; - -} diff --git a/port_src/core/DONE/multi/qrcode/QRCodeMultiReader.java b/port_src/core/DONE/multi/qrcode/QRCodeMultiReader.java deleted file mode 100644 index c366349..0000000 --- a/port_src/core/DONE/multi/qrcode/QRCodeMultiReader.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.multi.qrcode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.DetectorResult; -import com.google.zxing.multi.MultipleBarcodeReader; -import com.google.zxing.multi.qrcode.detector.MultiDetector; -import com.google.zxing.qrcode.QRCodeReader; -import com.google.zxing.qrcode.decoder.QRCodeDecoderMetaData; - -import java.io.ByteArrayOutputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Collections; -import java.util.Comparator; - -/** - * This implementation can detect and decode multiple QR Codes in an image. - * - * @author Sean Owen - * @author Hannes Erven - */ -public final class QRCodeMultiReader extends QRCodeReader implements MultipleBarcodeReader { - - private static final Result[] EMPTY_RESULT_ARRAY = new Result[0]; - private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; - - @Override - public Result[] decodeMultiple(BinaryBitmap image) throws NotFoundException { - return decodeMultiple(image, null); - } - - @Override - public Result[] decodeMultiple(BinaryBitmap image, Map hints) throws NotFoundException { - List results = new ArrayList<>(); - DetectorResult[] detectorResults = new MultiDetector(image.getBlackMatrix()).detectMulti(hints); - for (DetectorResult detectorResult : detectorResults) { - try { - DecoderResult decoderResult = getDecoder().decode(detectorResult.getBits(), hints); - ResultPoint[] points = detectorResult.getPoints(); - // If the code was mirrored: swap the bottom-left and the top-right points. - if (decoderResult.getOther() instanceof QRCodeDecoderMetaData) { - ((QRCodeDecoderMetaData) decoderResult.getOther()).applyMirroredCorrection(points); - } - Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, - BarcodeFormat.QR_CODE); - List byteSegments = decoderResult.getByteSegments(); - if (byteSegments != null) { - result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); - } - String ecLevel = decoderResult.getECLevel(); - if (ecLevel != null) { - result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); - } - if (decoderResult.hasStructuredAppend()) { - result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, - decoderResult.getStructuredAppendSequenceNumber()); - result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_PARITY, - decoderResult.getStructuredAppendParity()); - } - results.add(result); - } catch (ReaderException re) { - // ignore and continue - } - } - if (results.isEmpty()) { - return EMPTY_RESULT_ARRAY; - } else { - results = processStructuredAppend(results); - return results.toArray(EMPTY_RESULT_ARRAY); - } - } - - static List processStructuredAppend(List results) { - List newResults = new ArrayList<>(); - List saResults = new ArrayList<>(); - for (Result result : results) { - if (result.getResultMetadata().containsKey(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE)) { - saResults.add(result); - } else { - newResults.add(result); - } - } - if (saResults.isEmpty()) { - return results; - } - - // sort and concatenate the SA list items - Collections.sort(saResults, new SAComparator()); - StringBuilder newText = new StringBuilder(); - ByteArrayOutputStream newRawBytes = new ByteArrayOutputStream(); - ByteArrayOutputStream newByteSegment = new ByteArrayOutputStream(); - for (Result saResult : saResults) { - newText.append(saResult.getText()); - byte[] saBytes = saResult.getRawBytes(); - newRawBytes.write(saBytes, 0, saBytes.length); - @SuppressWarnings("unchecked") - Iterable byteSegments = - (Iterable) saResult.getResultMetadata().get(ResultMetadataType.BYTE_SEGMENTS); - if (byteSegments != null) { - for (byte[] segment : byteSegments) { - newByteSegment.write(segment, 0, segment.length); - } - } - } - - Result newResult = new Result(newText.toString(), newRawBytes.toByteArray(), NO_POINTS, BarcodeFormat.QR_CODE); - if (newByteSegment.size() > 0) { - newResult.putMetadata(ResultMetadataType.BYTE_SEGMENTS, Collections.singletonList(newByteSegment.toByteArray())); - } - newResults.add(newResult); - return newResults; - } - - private static final class SAComparator implements Comparator, Serializable { - @Override - public int compare(Result a, Result b) { - int aNumber = (int) a.getResultMetadata().get(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE); - int bNumber = (int) b.getResultMetadata().get(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE); - return Integer.compare(aNumber, bNumber); - } - } - -} diff --git a/port_src/core/DONE/multi/qrcode/detector/MultiDetector.java b/port_src/core/DONE/multi/qrcode/detector/MultiDetector.java deleted file mode 100644 index 512b452..0000000 --- a/port_src/core/DONE/multi/qrcode/detector/MultiDetector.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.multi.qrcode.detector; - -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.ReaderException; -import com.google.zxing.ResultPointCallback; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DetectorResult; -import com.google.zxing.qrcode.detector.Detector; -import com.google.zxing.qrcode.detector.FinderPatternInfo; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - *

Encapsulates logic that can detect one or more QR Codes in an image, even if the QR Code - * is rotated or skewed, or partially obscured.

- * - * @author Sean Owen - * @author Hannes Erven - */ -public final class MultiDetector extends Detector { - - private static final DetectorResult[] EMPTY_DETECTOR_RESULTS = new DetectorResult[0]; - - public MultiDetector(BitMatrix image) { - super(image); - } - - public DetectorResult[] detectMulti(Map hints) throws NotFoundException { - BitMatrix image = getImage(); - ResultPointCallback resultPointCallback = - hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); - MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback); - FinderPatternInfo[] infos = finder.findMulti(hints); - - if (infos.length == 0) { - throw NotFoundException.getNotFoundInstance(); - } - - List result = new ArrayList<>(); - for (FinderPatternInfo info : infos) { - try { - result.add(processFinderPatternInfo(info)); - } catch (ReaderException e) { - // ignore - } - } - if (result.isEmpty()) { - return EMPTY_DETECTOR_RESULTS; - } else { - return result.toArray(EMPTY_DETECTOR_RESULTS); - } - } - -} diff --git a/port_src/core/DONE/multi/qrcode/detector/MultiFinderPatternFinder.java b/port_src/core/DONE/multi/qrcode/detector/MultiFinderPatternFinder.java deleted file mode 100644 index b4e96a6..0000000 --- a/port_src/core/DONE/multi/qrcode/detector/MultiFinderPatternFinder.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.multi.qrcode.detector; - -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPoint; -import com.google.zxing.ResultPointCallback; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.qrcode.detector.FinderPattern; -import com.google.zxing.qrcode.detector.FinderPatternFinder; -import com.google.zxing.qrcode.detector.FinderPatternInfo; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -/** - *

This class attempts to find finder patterns in a QR Code. Finder patterns are the square - * markers at three corners of a QR Code.

- * - *

This class is thread-safe but not reentrant. Each thread must allocate its own object. - * - *

In contrast to {@link FinderPatternFinder}, this class will return an array of all possible - * QR code locations in the image.

- * - *

Use the TRY_HARDER hint to ask for a more thorough detection.

- * - * @author Sean Owen - * @author Hannes Erven - */ -public final class MultiFinderPatternFinder extends FinderPatternFinder { - - private static final FinderPatternInfo[] EMPTY_RESULT_ARRAY = new FinderPatternInfo[0]; - private static final FinderPattern[] EMPTY_FP_ARRAY = new FinderPattern[0]; - private static final FinderPattern[][] EMPTY_FP_2D_ARRAY = new FinderPattern[0][]; - - // TODO MIN_MODULE_COUNT and MAX_MODULE_COUNT would be great hints to ask the user for - // since it limits the number of regions to decode - - // max. legal count of modules per QR code edge (177) - private static final float MAX_MODULE_COUNT_PER_EDGE = 180; - // min. legal count per modules per QR code edge (11) - private static final float MIN_MODULE_COUNT_PER_EDGE = 9; - - /** - * More or less arbitrary cutoff point for determining if two finder patterns might belong - * to the same code if they differ less than DIFF_MODSIZE_CUTOFF_PERCENT percent in their - * estimated modules sizes. - */ - private static final float DIFF_MODSIZE_CUTOFF_PERCENT = 0.05f; - - /** - * More or less arbitrary cutoff point for determining if two finder patterns might belong - * to the same code if they differ less than DIFF_MODSIZE_CUTOFF pixels/module in their - * estimated modules sizes. - */ - private static final float DIFF_MODSIZE_CUTOFF = 0.5f; - - - /** - * A comparator that orders FinderPatterns by their estimated module size. - */ - private static final class ModuleSizeComparator implements Comparator, Serializable { - @Override - public int compare(FinderPattern center1, FinderPattern center2) { - float value = center2.getEstimatedModuleSize() - center1.getEstimatedModuleSize(); - return value < 0.0 ? -1 : value > 0.0 ? 1 : 0; - } - } - - public MultiFinderPatternFinder(BitMatrix image, ResultPointCallback resultPointCallback) { - super(image, resultPointCallback); - } - - /** - * @return the 3 best {@link FinderPattern}s from our list of candidates. The "best" are - * those that have been detected at least 2 times, and whose module - * size differs from the average among those patterns the least - * @throws NotFoundException if 3 such finder patterns do not exist - */ - private FinderPattern[][] selectMultipleBestPatterns() throws NotFoundException { - List possibleCenters = new ArrayList<>(); - for (FinderPattern fp : getPossibleCenters()) { - if (fp.getCount() >= 2) { - possibleCenters.add(fp); - } - } - int size = possibleCenters.size(); - - if (size < 3) { - // Couldn't find enough finder patterns - throw NotFoundException.getNotFoundInstance(); - } - - /* - * Begin HE modifications to safely detect multiple codes of equal size - */ - if (size == 3) { - return new FinderPattern[][] { possibleCenters.toArray(EMPTY_FP_ARRAY) }; - } - - // Sort by estimated module size to speed up the upcoming checks - Collections.sort(possibleCenters, new ModuleSizeComparator()); - - /* - * Now lets start: build a list of tuples of three finder locations that - * - feature similar module sizes - * - are placed in a distance so the estimated module count is within the QR specification - * - have similar distance between upper left/right and left top/bottom finder patterns - * - form a triangle with 90° angle (checked by comparing top right/bottom left distance - * with pythagoras) - * - * Note: we allow each point to be used for more than one code region: this might seem - * counterintuitive at first, but the performance penalty is not that big. At this point, - * we cannot make a good quality decision whether the three finders actually represent - * a QR code, or are just by chance laid out so it looks like there might be a QR code there. - * So, if the layout seems right, lets have the decoder try to decode. - */ - - List results = new ArrayList<>(); // holder for the results - - for (int i1 = 0; i1 < (size - 2); i1++) { - FinderPattern p1 = possibleCenters.get(i1); - if (p1 == null) { - continue; - } - - for (int i2 = i1 + 1; i2 < (size - 1); i2++) { - FinderPattern p2 = possibleCenters.get(i2); - if (p2 == null) { - continue; - } - - // Compare the expected module sizes; if they are really off, skip - float vModSize12 = (p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize()) / - Math.min(p1.getEstimatedModuleSize(), p2.getEstimatedModuleSize()); - float vModSize12A = Math.abs(p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize()); - if (vModSize12A > DIFF_MODSIZE_CUTOFF && vModSize12 >= DIFF_MODSIZE_CUTOFF_PERCENT) { - // break, since elements are ordered by the module size deviation there cannot be - // any more interesting elements for the given p1. - break; - } - - for (int i3 = i2 + 1; i3 < size; i3++) { - FinderPattern p3 = possibleCenters.get(i3); - if (p3 == null) { - continue; - } - - // Compare the expected module sizes; if they are really off, skip - float vModSize23 = (p2.getEstimatedModuleSize() - p3.getEstimatedModuleSize()) / - Math.min(p2.getEstimatedModuleSize(), p3.getEstimatedModuleSize()); - float vModSize23A = Math.abs(p2.getEstimatedModuleSize() - p3.getEstimatedModuleSize()); - if (vModSize23A > DIFF_MODSIZE_CUTOFF && vModSize23 >= DIFF_MODSIZE_CUTOFF_PERCENT) { - // break, since elements are ordered by the module size deviation there cannot be - // any more interesting elements for the given p1. - break; - } - - FinderPattern[] test = {p1, p2, p3}; - ResultPoint.orderBestPatterns(test); - - // Calculate the distances: a = topleft-bottomleft, b=topleft-topright, c = diagonal - FinderPatternInfo info = new FinderPatternInfo(test); - float dA = ResultPoint.distance(info.getTopLeft(), info.getBottomLeft()); - float dC = ResultPoint.distance(info.getTopRight(), info.getBottomLeft()); - float dB = ResultPoint.distance(info.getTopLeft(), info.getTopRight()); - - // Check the sizes - float estimatedModuleCount = (dA + dB) / (p1.getEstimatedModuleSize() * 2.0f); - if (estimatedModuleCount > MAX_MODULE_COUNT_PER_EDGE || - estimatedModuleCount < MIN_MODULE_COUNT_PER_EDGE) { - continue; - } - - // Calculate the difference of the edge lengths in percent - float vABBC = Math.abs((dA - dB) / Math.min(dA, dB)); - if (vABBC >= 0.1f) { - continue; - } - - // Calculate the diagonal length by assuming a 90° angle at topleft - float dCpy = (float) Math.sqrt((double) dA * dA + (double) dB * dB); - // Compare to the real distance in % - float vPyC = Math.abs((dC - dCpy) / Math.min(dC, dCpy)); - - if (vPyC >= 0.1f) { - continue; - } - - // All tests passed! - results.add(test); - } - } - } - - if (!results.isEmpty()) { - return results.toArray(EMPTY_FP_2D_ARRAY); - } - - // Nothing found! - throw NotFoundException.getNotFoundInstance(); - } - - public FinderPatternInfo[] findMulti(Map hints) throws NotFoundException { - boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); - BitMatrix image = getImage(); - int maxI = image.getHeight(); - int maxJ = image.getWidth(); - // We are looking for black/white/black/white/black modules in - // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far - - // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the - // image, and then account for the center being 3 modules in size. This gives the smallest - // number of pixels the center could be, so skip this often. When trying harder, look for all - // QR versions regardless of how dense they are. - int iSkip = (3 * maxI) / (4 * MAX_MODULES); - if (iSkip < MIN_SKIP || tryHarder) { - iSkip = MIN_SKIP; - } - - int[] stateCount = new int[5]; - for (int i = iSkip - 1; i < maxI; i += iSkip) { - // Get a row of black/white values - doClearCounts(stateCount); - int currentState = 0; - for (int j = 0; j < maxJ; j++) { - if (image.get(j, i)) { - // Black pixel - if ((currentState & 1) == 1) { // Counting white pixels - currentState++; - } - stateCount[currentState]++; - } else { // White pixel - if ((currentState & 1) == 0) { // Counting black pixels - if (currentState == 4) { // A winner? - if (foundPatternCross(stateCount) && handlePossibleCenter(stateCount, i, j)) { // Yes - // Clear state to start looking again - currentState = 0; - doClearCounts(stateCount); - } else { // No, shift counts back by two - doShiftCounts2(stateCount); - currentState = 3; - } - } else { - stateCount[++currentState]++; - } - } else { // Counting white pixels - stateCount[currentState]++; - } - } - } // for j=... - - if (foundPatternCross(stateCount)) { - handlePossibleCenter(stateCount, i, maxJ); - } - } // for i=iSkip-1 ... - FinderPattern[][] patternInfo = selectMultipleBestPatterns(); - List result = new ArrayList<>(); - for (FinderPattern[] pattern : patternInfo) { - ResultPoint.orderBestPatterns(pattern); - result.add(new FinderPatternInfo(pattern)); - } - - if (result.isEmpty()) { - return EMPTY_RESULT_ARRAY; - } else { - return result.toArray(EMPTY_RESULT_ARRAY); - } - } - -} diff --git a/port_src/core/DONE/oned/CodaBarReader.java b/port_src/core/DONE/oned/CodaBarReader.java deleted file mode 100644 index a5e230d..0000000 --- a/port_src/core/DONE/oned/CodaBarReader.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitArray; - -import java.util.Arrays; -import java.util.Map; - -/** - *

Decodes Codabar barcodes.

- * - * @author Bas Vijfwinkel - * @author David Walker - */ -public final class CodaBarReader extends OneDReader { - - // These values are critical for determining how permissive the decoding - // will be. All stripe sizes must be within the window these define, as - // compared to the average stripe size. - private static final float MAX_ACCEPTABLE = 2.0f; - private static final float PADDING = 1.5f; - - private static final String ALPHABET_STRING = "0123456789-$:/.+ABCD"; - static final char[] ALPHABET = ALPHABET_STRING.toCharArray(); - - /** - * These represent the encodings of characters, as patterns of wide and narrow bars. The 7 least-significant bits of - * each int correspond to the pattern of wide and narrow, with 1s representing "wide" and 0s representing narrow. - */ - static final int[] CHARACTER_ENCODINGS = { - 0x003, 0x006, 0x009, 0x060, 0x012, 0x042, 0x021, 0x024, 0x030, 0x048, // 0-9 - 0x00c, 0x018, 0x045, 0x051, 0x054, 0x015, 0x01A, 0x029, 0x00B, 0x00E, // -$:/.+ABCD - }; - - // minimal number of characters that should be present (including start and stop characters) - // under normal circumstances this should be set to 3, but can be set higher - // as a last-ditch attempt to reduce false positives. - private static final int MIN_CHARACTER_LENGTH = 3; - - // official start and end patterns - private static final char[] STARTEND_ENCODING = {'A', 'B', 'C', 'D'}; - // some Codabar generator allow the Codabar string to be closed by every - // character. This will cause lots of false positives! - - // some industries use a checksum standard but this is not part of the original Codabar standard - // for more information see : http://www.mecsw.com/specs/codabar.html - - // Keep some instance variables to avoid reallocations - private final StringBuilder decodeRowResult; - private int[] counters; - private int counterLength; - - public CodaBarReader() { - decodeRowResult = new StringBuilder(20); - counters = new int[80]; - counterLength = 0; - } - - @Override - public Result decodeRow(int rowNumber, BitArray row, Map hints) throws NotFoundException { - - Arrays.fill(counters, 0); - setCounters(row); - int startOffset = findStartPattern(); - int nextStart = startOffset; - - decodeRowResult.setLength(0); - do { - int charOffset = toNarrowWidePattern(nextStart); - if (charOffset == -1) { - throw NotFoundException.getNotFoundInstance(); - } - // Hack: We store the position in the alphabet table into a - // StringBuilder, so that we can access the decoded patterns in - // validatePattern. We'll translate to the actual characters later. - decodeRowResult.append((char) charOffset); - nextStart += 8; - // Stop as soon as we see the end character. - if (decodeRowResult.length() > 1 && - arrayContains(STARTEND_ENCODING, ALPHABET[charOffset])) { - break; - } - } while (nextStart < counterLength); // no fixed end pattern so keep on reading while data is available - - // Look for whitespace after pattern: - int trailingWhitespace = counters[nextStart - 1]; - int lastPatternSize = 0; - for (int i = -8; i < -1; i++) { - lastPatternSize += counters[nextStart + i]; - } - - // We need to see whitespace equal to 50% of the last pattern size, - // otherwise this is probably a false positive. The exception is if we are - // at the end of the row. (I.e. the barcode barely fits.) - if (nextStart < counterLength && trailingWhitespace < lastPatternSize / 2) { - throw NotFoundException.getNotFoundInstance(); - } - - validatePattern(startOffset); - - // Translate character table offsets to actual characters. - for (int i = 0; i < decodeRowResult.length(); i++) { - decodeRowResult.setCharAt(i, ALPHABET[decodeRowResult.charAt(i)]); - } - // Ensure a valid start and end character - char startchar = decodeRowResult.charAt(0); - if (!arrayContains(STARTEND_ENCODING, startchar)) { - throw NotFoundException.getNotFoundInstance(); - } - char endchar = decodeRowResult.charAt(decodeRowResult.length() - 1); - if (!arrayContains(STARTEND_ENCODING, endchar)) { - throw NotFoundException.getNotFoundInstance(); - } - - // remove stop/start characters character and check if a long enough string is contained - if (decodeRowResult.length() <= MIN_CHARACTER_LENGTH) { - // Almost surely a false positive ( start + stop + at least 1 character) - throw NotFoundException.getNotFoundInstance(); - } - - if (hints == null || !hints.containsKey(DecodeHintType.RETURN_CODABAR_START_END)) { - decodeRowResult.deleteCharAt(decodeRowResult.length() - 1); - decodeRowResult.deleteCharAt(0); - } - - int runningCount = 0; - for (int i = 0; i < startOffset; i++) { - runningCount += counters[i]; - } - float left = runningCount; - for (int i = startOffset; i < nextStart - 1; i++) { - runningCount += counters[i]; - } - float right = runningCount; - - Result result = new Result( - decodeRowResult.toString(), - null, - new ResultPoint[]{ - new ResultPoint(left, rowNumber), - new ResultPoint(right, rowNumber)}, - BarcodeFormat.CODABAR); - result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]F0"); - return result; - } - - private void validatePattern(int start) throws NotFoundException { - // First, sum up the total size of our four categories of stripe sizes; - int[] sizes = {0, 0, 0, 0}; - int[] counts = {0, 0, 0, 0}; - int end = decodeRowResult.length() - 1; - - // We break out of this loop in the middle, in order to handle - // inter-character spaces properly. - int pos = start; - for (int i = 0; i <= end; i++) { - int pattern = CHARACTER_ENCODINGS[decodeRowResult.charAt(i)]; - for (int j = 6; j >= 0; j--) { - // Even j = bars, while odd j = spaces. Categories 2 and 3 are for - // long stripes, while 0 and 1 are for short stripes. - int category = (j & 1) + (pattern & 1) * 2; - sizes[category] += counters[pos + j]; - counts[category]++; - pattern >>= 1; - } - // We ignore the inter-character space - it could be of any size. - pos += 8; - } - - // Calculate our allowable size thresholds using fixed-point math. - float[] maxes = new float[4]; - float[] mins = new float[4]; - // Define the threshold of acceptability to be the midpoint between the - // average small stripe and the average large stripe. No stripe lengths - // should be on the "wrong" side of that line. - for (int i = 0; i < 2; i++) { - mins[i] = 0.0f; // Accept arbitrarily small "short" stripes. - mins[i + 2] = ((float) sizes[i] / counts[i] + (float) sizes[i + 2] / counts[i + 2]) / 2.0f; - maxes[i] = mins[i + 2]; - maxes[i + 2] = (sizes[i + 2] * MAX_ACCEPTABLE + PADDING) / counts[i + 2]; - } - - // Now verify that all of the stripes are within the thresholds. - pos = start; - for (int i = 0; i <= end; i++) { - int pattern = CHARACTER_ENCODINGS[decodeRowResult.charAt(i)]; - for (int j = 6; j >= 0; j--) { - // Even j = bars, while odd j = spaces. Categories 2 and 3 are for - // long stripes, while 0 and 1 are for short stripes. - int category = (j & 1) + (pattern & 1) * 2; - int size = counters[pos + j]; - if (size < mins[category] || size > maxes[category]) { - throw NotFoundException.getNotFoundInstance(); - } - pattern >>= 1; - } - pos += 8; - } - } - - /** - * Records the size of all runs of white and black pixels, starting with white. - * This is just like recordPattern, except it records all the counters, and - * uses our builtin "counters" member for storage. - * @param row row to count from - */ - private void setCounters(BitArray row) throws NotFoundException { - counterLength = 0; - // Start from the first white bit. - int i = row.getNextUnset(0); - int end = row.getSize(); - if (i >= end) { - throw NotFoundException.getNotFoundInstance(); - } - boolean isWhite = true; - int count = 0; - while (i < end) { - if (row.get(i) != isWhite) { - count++; - } else { - counterAppend(count); - count = 1; - isWhite = !isWhite; - } - i++; - } - counterAppend(count); - } - - private void counterAppend(int e) { - counters[counterLength] = e; - counterLength++; - if (counterLength >= counters.length) { - int[] temp = new int[counterLength * 2]; - System.arraycopy(counters, 0, temp, 0, counterLength); - counters = temp; - } - } - - private int findStartPattern() throws NotFoundException { - for (int i = 1; i < counterLength; i += 2) { - int charOffset = toNarrowWidePattern(i); - if (charOffset != -1 && arrayContains(STARTEND_ENCODING, ALPHABET[charOffset])) { - // Look for whitespace before start pattern, >= 50% of width of start pattern - // We make an exception if the whitespace is the first element. - int patternSize = 0; - for (int j = i; j < i + 7; j++) { - patternSize += counters[j]; - } - if (i == 1 || counters[i - 1] >= patternSize / 2) { - return i; - } - } - } - throw NotFoundException.getNotFoundInstance(); - } - - static boolean arrayContains(char[] array, char key) { - if (array != null) { - for (char c : array) { - if (c == key) { - return true; - } - } - } - return false; - } - - // Assumes that counters[position] is a bar. - private int toNarrowWidePattern(int position) { - int end = position + 7; - if (end >= counterLength) { - return -1; - } - - int[] theCounters = counters; - - int maxBar = 0; - int minBar = Integer.MAX_VALUE; - for (int j = position; j < end; j += 2) { - int currentCounter = theCounters[j]; - if (currentCounter < minBar) { - minBar = currentCounter; - } - if (currentCounter > maxBar) { - maxBar = currentCounter; - } - } - int thresholdBar = (minBar + maxBar) / 2; - - int maxSpace = 0; - int minSpace = Integer.MAX_VALUE; - for (int j = position + 1; j < end; j += 2) { - int currentCounter = theCounters[j]; - if (currentCounter < minSpace) { - minSpace = currentCounter; - } - if (currentCounter > maxSpace) { - maxSpace = currentCounter; - } - } - int thresholdSpace = (minSpace + maxSpace) / 2; - - int bitmask = 1 << 7; - int pattern = 0; - for (int i = 0; i < 7; i++) { - int threshold = (i & 1) == 0 ? thresholdBar : thresholdSpace; - bitmask >>= 1; - if (theCounters[position + i] > threshold) { - pattern |= bitmask; - } - } - - for (int i = 0; i < CHARACTER_ENCODINGS.length; i++) { - if (CHARACTER_ENCODINGS[i] == pattern) { - return i; - } - } - return -1; - } - -} diff --git a/port_src/core/DONE/oned/CodaBarWriter.java b/port_src/core/DONE/oned/CodaBarWriter.java deleted file mode 100644 index 523338f..0000000 --- a/port_src/core/DONE/oned/CodaBarWriter.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; - -import java.util.Collection; -import java.util.Collections; - -/** - * This class renders CodaBar as {@code boolean[]}. - * - * @author dsbnatut@gmail.com (Kazuki Nishiura) - */ -public final class CodaBarWriter extends OneDimensionalCodeWriter { - - private static final char[] START_END_CHARS = {'A', 'B', 'C', 'D'}; - private static final char[] ALT_START_END_CHARS = {'T', 'N', '*', 'E'}; - private static final char[] CHARS_WHICH_ARE_TEN_LENGTH_EACH_AFTER_DECODED = {'/', ':', '+', '.'}; - private static final char DEFAULT_GUARD = START_END_CHARS[0]; - - @Override - protected Collection getSupportedWriteFormats() { - return Collections.singleton(BarcodeFormat.CODABAR); - } - - @Override - public boolean[] encode(String contents) { - - if (contents.length() < 2) { - // Can't have a start/end guard, so tentatively add default guards - contents = DEFAULT_GUARD + contents + DEFAULT_GUARD; - } else { - // Verify input and calculate decoded length. - char firstChar = Character.toUpperCase(contents.charAt(0)); - char lastChar = Character.toUpperCase(contents.charAt(contents.length() - 1)); - boolean startsNormal = CodaBarReader.arrayContains(START_END_CHARS, firstChar); - boolean endsNormal = CodaBarReader.arrayContains(START_END_CHARS, lastChar); - boolean startsAlt = CodaBarReader.arrayContains(ALT_START_END_CHARS, firstChar); - boolean endsAlt = CodaBarReader.arrayContains(ALT_START_END_CHARS, lastChar); - if (startsNormal) { - if (!endsNormal) { - throw new IllegalArgumentException("Invalid start/end guards: " + contents); - } - // else already has valid start/end - } else if (startsAlt) { - if (!endsAlt) { - throw new IllegalArgumentException("Invalid start/end guards: " + contents); - } - // else already has valid start/end - } else { - // Doesn't start with a guard - if (endsNormal || endsAlt) { - throw new IllegalArgumentException("Invalid start/end guards: " + contents); - } - // else doesn't end with guard either, so add a default - contents = DEFAULT_GUARD + contents + DEFAULT_GUARD; - } - } - - // The start character and the end character are decoded to 10 length each. - int resultLength = 20; - for (int i = 1; i < contents.length() - 1; i++) { - if (Character.isDigit(contents.charAt(i)) || contents.charAt(i) == '-' || contents.charAt(i) == '$') { - resultLength += 9; - } else if (CodaBarReader.arrayContains(CHARS_WHICH_ARE_TEN_LENGTH_EACH_AFTER_DECODED, contents.charAt(i))) { - resultLength += 10; - } else { - throw new IllegalArgumentException("Cannot encode : '" + contents.charAt(i) + '\''); - } - } - // A blank is placed between each character. - resultLength += contents.length() - 1; - - boolean[] result = new boolean[resultLength]; - int position = 0; - for (int index = 0; index < contents.length(); index++) { - char c = Character.toUpperCase(contents.charAt(index)); - if (index == 0 || index == contents.length() - 1) { - // The start/end chars are not in the CodaBarReader.ALPHABET. - switch (c) { - case 'T': - c = 'A'; - break; - case 'N': - c = 'B'; - break; - case '*': - c = 'C'; - break; - case 'E': - c = 'D'; - break; - } - } - int code = 0; - for (int i = 0; i < CodaBarReader.ALPHABET.length; i++) { - // Found any, because I checked above. - if (c == CodaBarReader.ALPHABET[i]) { - code = CodaBarReader.CHARACTER_ENCODINGS[i]; - break; - } - } - boolean color = true; - int counter = 0; - int bit = 0; - while (bit < 7) { // A character consists of 7 digit. - result[position] = color; - position++; - if (((code >> (6 - bit)) & 1) == 0 || counter == 1) { - color = !color; // Flip the color. - bit++; - counter = 0; - } else { - counter++; - } - } - if (index < contents.length() - 1) { - result[position] = false; - position++; - } - } - return result; - } -} - diff --git a/port_src/core/DONE/oned/Code128Reader.java b/port_src/core/DONE/oned/Code128Reader.java deleted file mode 100644 index a6322a3..0000000 --- a/port_src/core/DONE/oned/Code128Reader.java +++ /dev/null @@ -1,562 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitArray; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - *

Decodes Code 128 barcodes.

- * - * @author Sean Owen - */ -public final class Code128Reader extends OneDReader { - - static final int[][] CODE_PATTERNS = { - {2, 1, 2, 2, 2, 2}, // 0 - {2, 2, 2, 1, 2, 2}, - {2, 2, 2, 2, 2, 1}, - {1, 2, 1, 2, 2, 3}, - {1, 2, 1, 3, 2, 2}, - {1, 3, 1, 2, 2, 2}, // 5 - {1, 2, 2, 2, 1, 3}, - {1, 2, 2, 3, 1, 2}, - {1, 3, 2, 2, 1, 2}, - {2, 2, 1, 2, 1, 3}, - {2, 2, 1, 3, 1, 2}, // 10 - {2, 3, 1, 2, 1, 2}, - {1, 1, 2, 2, 3, 2}, - {1, 2, 2, 1, 3, 2}, - {1, 2, 2, 2, 3, 1}, - {1, 1, 3, 2, 2, 2}, // 15 - {1, 2, 3, 1, 2, 2}, - {1, 2, 3, 2, 2, 1}, - {2, 2, 3, 2, 1, 1}, - {2, 2, 1, 1, 3, 2}, - {2, 2, 1, 2, 3, 1}, // 20 - {2, 1, 3, 2, 1, 2}, - {2, 2, 3, 1, 1, 2}, - {3, 1, 2, 1, 3, 1}, - {3, 1, 1, 2, 2, 2}, - {3, 2, 1, 1, 2, 2}, // 25 - {3, 2, 1, 2, 2, 1}, - {3, 1, 2, 2, 1, 2}, - {3, 2, 2, 1, 1, 2}, - {3, 2, 2, 2, 1, 1}, - {2, 1, 2, 1, 2, 3}, // 30 - {2, 1, 2, 3, 2, 1}, - {2, 3, 2, 1, 2, 1}, - {1, 1, 1, 3, 2, 3}, - {1, 3, 1, 1, 2, 3}, - {1, 3, 1, 3, 2, 1}, // 35 - {1, 1, 2, 3, 1, 3}, - {1, 3, 2, 1, 1, 3}, - {1, 3, 2, 3, 1, 1}, - {2, 1, 1, 3, 1, 3}, - {2, 3, 1, 1, 1, 3}, // 40 - {2, 3, 1, 3, 1, 1}, - {1, 1, 2, 1, 3, 3}, - {1, 1, 2, 3, 3, 1}, - {1, 3, 2, 1, 3, 1}, - {1, 1, 3, 1, 2, 3}, // 45 - {1, 1, 3, 3, 2, 1}, - {1, 3, 3, 1, 2, 1}, - {3, 1, 3, 1, 2, 1}, - {2, 1, 1, 3, 3, 1}, - {2, 3, 1, 1, 3, 1}, // 50 - {2, 1, 3, 1, 1, 3}, - {2, 1, 3, 3, 1, 1}, - {2, 1, 3, 1, 3, 1}, - {3, 1, 1, 1, 2, 3}, - {3, 1, 1, 3, 2, 1}, // 55 - {3, 3, 1, 1, 2, 1}, - {3, 1, 2, 1, 1, 3}, - {3, 1, 2, 3, 1, 1}, - {3, 3, 2, 1, 1, 1}, - {3, 1, 4, 1, 1, 1}, // 60 - {2, 2, 1, 4, 1, 1}, - {4, 3, 1, 1, 1, 1}, - {1, 1, 1, 2, 2, 4}, - {1, 1, 1, 4, 2, 2}, - {1, 2, 1, 1, 2, 4}, // 65 - {1, 2, 1, 4, 2, 1}, - {1, 4, 1, 1, 2, 2}, - {1, 4, 1, 2, 2, 1}, - {1, 1, 2, 2, 1, 4}, - {1, 1, 2, 4, 1, 2}, // 70 - {1, 2, 2, 1, 1, 4}, - {1, 2, 2, 4, 1, 1}, - {1, 4, 2, 1, 1, 2}, - {1, 4, 2, 2, 1, 1}, - {2, 4, 1, 2, 1, 1}, // 75 - {2, 2, 1, 1, 1, 4}, - {4, 1, 3, 1, 1, 1}, - {2, 4, 1, 1, 1, 2}, - {1, 3, 4, 1, 1, 1}, - {1, 1, 1, 2, 4, 2}, // 80 - {1, 2, 1, 1, 4, 2}, - {1, 2, 1, 2, 4, 1}, - {1, 1, 4, 2, 1, 2}, - {1, 2, 4, 1, 1, 2}, - {1, 2, 4, 2, 1, 1}, // 85 - {4, 1, 1, 2, 1, 2}, - {4, 2, 1, 1, 1, 2}, - {4, 2, 1, 2, 1, 1}, - {2, 1, 2, 1, 4, 1}, - {2, 1, 4, 1, 2, 1}, // 90 - {4, 1, 2, 1, 2, 1}, - {1, 1, 1, 1, 4, 3}, - {1, 1, 1, 3, 4, 1}, - {1, 3, 1, 1, 4, 1}, - {1, 1, 4, 1, 1, 3}, // 95 - {1, 1, 4, 3, 1, 1}, - {4, 1, 1, 1, 1, 3}, - {4, 1, 1, 3, 1, 1}, - {1, 1, 3, 1, 4, 1}, - {1, 1, 4, 1, 3, 1}, // 100 - {3, 1, 1, 1, 4, 1}, - {4, 1, 1, 1, 3, 1}, - {2, 1, 1, 4, 1, 2}, - {2, 1, 1, 2, 1, 4}, - {2, 1, 1, 2, 3, 2}, // 105 - {2, 3, 3, 1, 1, 1, 2} - }; - - private static final float MAX_AVG_VARIANCE = 0.25f; - private static final float MAX_INDIVIDUAL_VARIANCE = 0.7f; - - private static final int CODE_SHIFT = 98; - - private static final int CODE_CODE_C = 99; - private static final int CODE_CODE_B = 100; - private static final int CODE_CODE_A = 101; - - private static final int CODE_FNC_1 = 102; - private static final int CODE_FNC_2 = 97; - private static final int CODE_FNC_3 = 96; - private static final int CODE_FNC_4_A = 101; - private static final int CODE_FNC_4_B = 100; - - private static final int CODE_START_A = 103; - private static final int CODE_START_B = 104; - private static final int CODE_START_C = 105; - private static final int CODE_STOP = 106; - - private static int[] findStartPattern(BitArray row) throws NotFoundException { - int width = row.getSize(); - int rowOffset = row.getNextSet(0); - - int counterPosition = 0; - int[] counters = new int[6]; - int patternStart = rowOffset; - boolean isWhite = false; - int patternLength = counters.length; - - for (int i = rowOffset; i < width; i++) { - if (row.get(i) != isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == patternLength - 1) { - float bestVariance = MAX_AVG_VARIANCE; - int bestMatch = -1; - for (int startCode = CODE_START_A; startCode <= CODE_START_C; startCode++) { - float variance = patternMatchVariance(counters, CODE_PATTERNS[startCode], - MAX_INDIVIDUAL_VARIANCE); - if (variance < bestVariance) { - bestVariance = variance; - bestMatch = startCode; - } - } - // Look for whitespace before start pattern, >= 50% of width of start pattern - if (bestMatch >= 0 && - row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart, false)) { - return new int[]{patternStart, i, bestMatch}; - } - patternStart += counters[0] + counters[1]; - System.arraycopy(counters, 2, counters, 0, counterPosition - 1); - counters[counterPosition - 1] = 0; - counters[counterPosition] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - throw NotFoundException.getNotFoundInstance(); - } - - private static int decodeCode(BitArray row, int[] counters, int rowOffset) - throws NotFoundException { - recordPattern(row, rowOffset, counters); - float bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept - int bestMatch = -1; - for (int d = 0; d < CODE_PATTERNS.length; d++) { - int[] pattern = CODE_PATTERNS[d]; - float variance = patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE); - if (variance < bestVariance) { - bestVariance = variance; - bestMatch = d; - } - } - // TODO We're overlooking the fact that the STOP pattern has 7 values, not 6. - if (bestMatch >= 0) { - return bestMatch; - } else { - throw NotFoundException.getNotFoundInstance(); - } - } - - @Override - public Result decodeRow(int rowNumber, BitArray row, Map hints) - throws NotFoundException, FormatException, ChecksumException { - - boolean convertFNC1 = hints != null && hints.containsKey(DecodeHintType.ASSUME_GS1); - - int symbologyModifier = 0; - - int[] startPatternInfo = findStartPattern(row); - int startCode = startPatternInfo[2]; - - List rawCodes = new ArrayList<>(20); - rawCodes.add((byte) startCode); - - int codeSet; - switch (startCode) { - case CODE_START_A: - codeSet = CODE_CODE_A; - break; - case CODE_START_B: - codeSet = CODE_CODE_B; - break; - case CODE_START_C: - codeSet = CODE_CODE_C; - break; - default: - throw FormatException.getFormatInstance(); - } - - boolean done = false; - boolean isNextShifted = false; - - StringBuilder result = new StringBuilder(20); - - int lastStart = startPatternInfo[0]; - int nextStart = startPatternInfo[1]; - int[] counters = new int[6]; - - int lastCode = 0; - int code = 0; - int checksumTotal = startCode; - int multiplier = 0; - boolean lastCharacterWasPrintable = true; - boolean upperMode = false; - boolean shiftUpperMode = false; - - while (!done) { - - boolean unshift = isNextShifted; - isNextShifted = false; - - // Save off last code - lastCode = code; - - // Decode another code from image - code = decodeCode(row, counters, nextStart); - - rawCodes.add((byte) code); - - // Remember whether the last code was printable or not (excluding CODE_STOP) - if (code != CODE_STOP) { - lastCharacterWasPrintable = true; - } - - // Add to checksum computation (if not CODE_STOP of course) - if (code != CODE_STOP) { - multiplier++; - checksumTotal += multiplier * code; - } - - // Advance to where the next code will to start - lastStart = nextStart; - for (int counter : counters) { - nextStart += counter; - } - - // Take care of illegal start codes - switch (code) { - case CODE_START_A: - case CODE_START_B: - case CODE_START_C: - throw FormatException.getFormatInstance(); - } - - switch (codeSet) { - - case CODE_CODE_A: - if (code < 64) { - if (shiftUpperMode == upperMode) { - result.append((char) (' ' + code)); - } else { - result.append((char) (' ' + code + 128)); - } - shiftUpperMode = false; - } else if (code < 96) { - if (shiftUpperMode == upperMode) { - result.append((char) (code - 64)); - } else { - result.append((char) (code + 64)); - } - shiftUpperMode = false; - } else { - // Don't let CODE_STOP, which always appears, affect whether whether we think the last - // code was printable or not. - if (code != CODE_STOP) { - lastCharacterWasPrintable = false; - } - switch (code) { - case CODE_FNC_1: - if (result.length() == 0) { // FNC1 at first or second character determines the symbology - symbologyModifier = 1; - } else if (result.length() == 1) { - symbologyModifier = 2; - } - if (convertFNC1) { - if (result.length() == 0) { - // GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code - // is FNC1 then this is GS1-128. We add the symbology identifier. - result.append("]C1"); - } else { - // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) - result.append((char) 29); - } - } - break; - case CODE_FNC_2: - symbologyModifier = 4; - break; - case CODE_FNC_3: - // do nothing? - break; - case CODE_FNC_4_A: - if (!upperMode && shiftUpperMode) { - upperMode = true; - shiftUpperMode = false; - } else if (upperMode && shiftUpperMode) { - upperMode = false; - shiftUpperMode = false; - } else { - shiftUpperMode = true; - } - break; - case CODE_SHIFT: - isNextShifted = true; - codeSet = CODE_CODE_B; - break; - case CODE_CODE_B: - codeSet = CODE_CODE_B; - break; - case CODE_CODE_C: - codeSet = CODE_CODE_C; - break; - case CODE_STOP: - done = true; - break; - } - } - break; - case CODE_CODE_B: - if (code < 96) { - if (shiftUpperMode == upperMode) { - result.append((char) (' ' + code)); - } else { - result.append((char) (' ' + code + 128)); - } - shiftUpperMode = false; - } else { - if (code != CODE_STOP) { - lastCharacterWasPrintable = false; - } - switch (code) { - case CODE_FNC_1: - if (result.length() == 0) { // FNC1 at first or second character determines the symbology - symbologyModifier = 1; - } else if (result.length() == 1) { - symbologyModifier = 2; - } - if (convertFNC1) { - if (result.length() == 0) { - // GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code - // is FNC1 then this is GS1-128. We add the symbology identifier. - result.append("]C1"); - } else { - // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) - result.append((char) 29); - } - } - break; - case CODE_FNC_2: - symbologyModifier = 4; - break; - case CODE_FNC_3: - // do nothing? - break; - case CODE_FNC_4_B: - if (!upperMode && shiftUpperMode) { - upperMode = true; - shiftUpperMode = false; - } else if (upperMode && shiftUpperMode) { - upperMode = false; - shiftUpperMode = false; - } else { - shiftUpperMode = true; - } - break; - case CODE_SHIFT: - isNextShifted = true; - codeSet = CODE_CODE_A; - break; - case CODE_CODE_A: - codeSet = CODE_CODE_A; - break; - case CODE_CODE_C: - codeSet = CODE_CODE_C; - break; - case CODE_STOP: - done = true; - break; - } - } - break; - case CODE_CODE_C: - if (code < 100) { - if (code < 10) { - result.append('0'); - } - result.append(code); - } else { - if (code != CODE_STOP) { - lastCharacterWasPrintable = false; - } - switch (code) { - case CODE_FNC_1: - if (result.length() == 0) { // FNC1 at first or second character determines the symbology - symbologyModifier = 1; - } else if (result.length() == 1) { - symbologyModifier = 2; - } - if (convertFNC1) { - if (result.length() == 0) { - // GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code - // is FNC1 then this is GS1-128. We add the symbology identifier. - result.append("]C1"); - } else { - // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) - result.append((char) 29); - } - } - break; - case CODE_CODE_A: - codeSet = CODE_CODE_A; - break; - case CODE_CODE_B: - codeSet = CODE_CODE_B; - break; - case CODE_STOP: - done = true; - break; - } - } - break; - } - - // Unshift back to another code set if we were shifted - if (unshift) { - codeSet = codeSet == CODE_CODE_A ? CODE_CODE_B : CODE_CODE_A; - } - - } - - int lastPatternSize = nextStart - lastStart; - - // Check for ample whitespace following pattern, but, to do this we first need to remember that - // we fudged decoding CODE_STOP since it actually has 7 bars, not 6. There is a black bar left - // to read off. Would be slightly better to properly read. Here we just skip it: - nextStart = row.getNextUnset(nextStart); - if (!row.isRange(nextStart, - Math.min(row.getSize(), nextStart + (nextStart - lastStart) / 2), - false)) { - throw NotFoundException.getNotFoundInstance(); - } - - // Pull out from sum the value of the penultimate check code - checksumTotal -= multiplier * lastCode; - // lastCode is the checksum then: - if (checksumTotal % 103 != lastCode) { - throw ChecksumException.getChecksumInstance(); - } - - // Need to pull out the check digits from string - int resultLength = result.length(); - if (resultLength == 0) { - // false positive - throw NotFoundException.getNotFoundInstance(); - } - - // Only bother if the result had at least one character, and if the checksum digit happened to - // be a printable character. If it was just interpreted as a control code, nothing to remove. - if (resultLength > 0 && lastCharacterWasPrintable) { - if (codeSet == CODE_CODE_C) { - result.delete(resultLength - 2, resultLength); - } else { - result.delete(resultLength - 1, resultLength); - } - } - - float left = (startPatternInfo[1] + startPatternInfo[0]) / 2.0f; - float right = lastStart + lastPatternSize / 2.0f; - - int rawCodesSize = rawCodes.size(); - byte[] rawBytes = new byte[rawCodesSize]; - for (int i = 0; i < rawCodesSize; i++) { - rawBytes[i] = rawCodes.get(i); - } - Result resultObject = new Result( - result.toString(), - rawBytes, - new ResultPoint[]{ - new ResultPoint(left, rowNumber), - new ResultPoint(right, rowNumber)}, - BarcodeFormat.CODE_128); - resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]C" + symbologyModifier); - return resultObject; - - } - -} diff --git a/port_src/core/DONE/oned/Code128Writer.java b/port_src/core/DONE/oned/Code128Writer.java deleted file mode 100644 index 27628ed..0000000 --- a/port_src/core/DONE/oned/Code128Writer.java +++ /dev/null @@ -1,567 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.common.BitMatrix; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -/** - * This object renders a CODE128 code as a {@link BitMatrix}. - * - * @author erik.barbara@gmail.com (Erik Barbara) - */ -public final class Code128Writer extends OneDimensionalCodeWriter { - - private static final int CODE_START_A = 103; - private static final int CODE_START_B = 104; - private static final int CODE_START_C = 105; - private static final int CODE_CODE_A = 101; - private static final int CODE_CODE_B = 100; - private static final int CODE_CODE_C = 99; - private static final int CODE_STOP = 106; - - // Dummy characters used to specify control characters in input - private static final char ESCAPE_FNC_1 = '\u00f1'; - private static final char ESCAPE_FNC_2 = '\u00f2'; - private static final char ESCAPE_FNC_3 = '\u00f3'; - private static final char ESCAPE_FNC_4 = '\u00f4'; - - private static final int CODE_FNC_1 = 102; // Code A, Code B, Code C - private static final int CODE_FNC_2 = 97; // Code A, Code B - private static final int CODE_FNC_3 = 96; // Code A, Code B - private static final int CODE_FNC_4_A = 101; // Code A - private static final int CODE_FNC_4_B = 100; // Code B - - // Results of minimal lookahead for code C - private enum CType { - UNCODABLE, - ONE_DIGIT, - TWO_DIGITS, - FNC_1 - } - - @Override - protected Collection getSupportedWriteFormats() { - return Collections.singleton(BarcodeFormat.CODE_128); - } - - @Override - public boolean[] encode(String contents) { - return encode(contents, null); - } - - @Override - protected boolean[] encode(String contents, Map hints) { - - int forcedCodeSet = check(contents, hints); - - boolean hasCompactionHint = hints != null && hints.containsKey(EncodeHintType.CODE128_COMPACT) && - Boolean.parseBoolean(hints.get(EncodeHintType.CODE128_COMPACT).toString()); - - return hasCompactionHint ? new MinimalEncoder().encode(contents) : encodeFast(contents, forcedCodeSet); - } - - private static int check(String contents, Map hints) { - int length = contents.length(); - // Check length - if (length < 1 || length > 80) { - throw new IllegalArgumentException( - "Contents length should be between 1 and 80 characters, but got " + length); - } - - // Check for forced code set hint. - int forcedCodeSet = -1; - if (hints != null && hints.containsKey(EncodeHintType.FORCE_CODE_SET)) { - String codeSetHint = hints.get(EncodeHintType.FORCE_CODE_SET).toString(); - switch (codeSetHint) { - case "A": - forcedCodeSet = CODE_CODE_A; - break; - case "B": - forcedCodeSet = CODE_CODE_B; - break; - case "C": - forcedCodeSet = CODE_CODE_C; - break; - default: - throw new IllegalArgumentException("Unsupported code set hint: " + codeSetHint); - } - } - - // Check content - for (int i = 0; i < length; i++) { - char c = contents.charAt(i); - // check for non ascii characters that are not special GS1 characters - switch (c) { - // special function characters - case ESCAPE_FNC_1: - case ESCAPE_FNC_2: - case ESCAPE_FNC_3: - case ESCAPE_FNC_4: - break; - // non ascii characters - default: - if (c > 127) { - // no full Latin-1 character set available at the moment - // shift and manual code change are not supported - throw new IllegalArgumentException("Bad character in input: ASCII value=" + (int) c); - } - } - // check characters for compatibility with forced code set - switch (forcedCodeSet) { - case CODE_CODE_A: - // allows no ascii above 95 (no lower caps, no special symbols) - if (c > 95 && c <= 127) { - throw new IllegalArgumentException("Bad character in input for forced code set A: ASCII value=" + (int) c); - } - break; - case CODE_CODE_B: - // allows no ascii below 32 (terminal symbols) - if (c <= 32) { - throw new IllegalArgumentException("Bad character in input for forced code set B: ASCII value=" + (int) c); - } - break; - case CODE_CODE_C: - // allows only numbers and no FNC 2/3/4 - if (c < 48 || (c > 57 && c <= 127) || c == ESCAPE_FNC_2 || c == ESCAPE_FNC_3 || c == ESCAPE_FNC_4) { - throw new IllegalArgumentException("Bad character in input for forced code set C: ASCII value=" + (int) c); - } - break; - } - } - return forcedCodeSet; - } - - private static boolean[] encodeFast(String contents, int forcedCodeSet) { - int length = contents.length(); - - Collection patterns = new ArrayList<>(); // temporary storage for patterns - int checkSum = 0; - int checkWeight = 1; - int codeSet = 0; // selected code (CODE_CODE_B or CODE_CODE_C) - int position = 0; // position in contents - - while (position < length) { - //Select code to use - int newCodeSet; - if (forcedCodeSet == -1) { - newCodeSet = chooseCode(contents, position, codeSet); - } else { - newCodeSet = forcedCodeSet; - } - - //Get the pattern index - int patternIndex; - if (newCodeSet == codeSet) { - // Encode the current character - // First handle escapes - switch (contents.charAt(position)) { - case ESCAPE_FNC_1: - patternIndex = CODE_FNC_1; - break; - case ESCAPE_FNC_2: - patternIndex = CODE_FNC_2; - break; - case ESCAPE_FNC_3: - patternIndex = CODE_FNC_3; - break; - case ESCAPE_FNC_4: - if (codeSet == CODE_CODE_A) { - patternIndex = CODE_FNC_4_A; - } else { - patternIndex = CODE_FNC_4_B; - } - break; - default: - // Then handle normal characters otherwise - switch (codeSet) { - case CODE_CODE_A: - patternIndex = contents.charAt(position) - ' '; - if (patternIndex < 0) { - // everything below a space character comes behind the underscore in the code patterns table - patternIndex += '`'; - } - break; - case CODE_CODE_B: - patternIndex = contents.charAt(position) - ' '; - break; - default: - // CODE_CODE_C - if (position + 1 == length) { - // this is the last character, but the encoding is C, which always encodes two characers - throw new IllegalArgumentException("Bad number of characters for digit only encoding."); - } - patternIndex = Integer.parseInt(contents.substring(position, position + 2)); - position++; // Also incremented below - break; - } - } - position++; - } else { - // Should we change the current code? - // Do we have a code set? - if (codeSet == 0) { - // No, we don't have a code set - switch (newCodeSet) { - case CODE_CODE_A: - patternIndex = CODE_START_A; - break; - case CODE_CODE_B: - patternIndex = CODE_START_B; - break; - default: - patternIndex = CODE_START_C; - break; - } - } else { - // Yes, we have a code set - patternIndex = newCodeSet; - } - codeSet = newCodeSet; - } - - // Get the pattern - patterns.add(Code128Reader.CODE_PATTERNS[patternIndex]); - - // Compute checksum - checkSum += patternIndex * checkWeight; - if (position != 0) { - checkWeight++; - } - } - return produceResult(patterns, checkSum); - } - - static boolean[] produceResult(Collection patterns, int checkSum) { - // Compute and append checksum - checkSum %= 103; - patterns.add(Code128Reader.CODE_PATTERNS[checkSum]); - - // Append stop code - patterns.add(Code128Reader.CODE_PATTERNS[CODE_STOP]); - - // Compute code width - int codeWidth = 0; - for (int[] pattern : patterns) { - for (int width : pattern) { - codeWidth += width; - } - } - - // Compute result - boolean[] result = new boolean[codeWidth]; - int pos = 0; - for (int[] pattern : patterns) { - pos += appendPattern(result, pos, pattern, true); - } - - return result; - } - - private static CType findCType(CharSequence value, int start) { - int last = value.length(); - if (start >= last) { - return CType.UNCODABLE; - } - char c = value.charAt(start); - if (c == ESCAPE_FNC_1) { - return CType.FNC_1; - } - if (c < '0' || c > '9') { - return CType.UNCODABLE; - } - if (start + 1 >= last) { - return CType.ONE_DIGIT; - } - c = value.charAt(start + 1); - if (c < '0' || c > '9') { - return CType.ONE_DIGIT; - } - return CType.TWO_DIGITS; - } - - private static int chooseCode(CharSequence value, int start, int oldCode) { - CType lookahead = findCType(value, start); - if (lookahead == CType.ONE_DIGIT) { - if (oldCode == CODE_CODE_A) { - return CODE_CODE_A; - } - return CODE_CODE_B; - } - if (lookahead == CType.UNCODABLE) { - if (start < value.length()) { - char c = value.charAt(start); - if (c < ' ' || (oldCode == CODE_CODE_A && (c < '`' || (c >= ESCAPE_FNC_1 && c <= ESCAPE_FNC_4)))) { - // can continue in code A, encodes ASCII 0 to 95 or FNC1 to FNC4 - return CODE_CODE_A; - } - } - return CODE_CODE_B; // no choice - } - if (oldCode == CODE_CODE_A && lookahead == CType.FNC_1) { - return CODE_CODE_A; - } - if (oldCode == CODE_CODE_C) { // can continue in code C - return CODE_CODE_C; - } - if (oldCode == CODE_CODE_B) { - if (lookahead == CType.FNC_1) { - return CODE_CODE_B; // can continue in code B - } - // Seen two consecutive digits, see what follows - lookahead = findCType(value, start + 2); - if (lookahead == CType.UNCODABLE || lookahead == CType.ONE_DIGIT) { - return CODE_CODE_B; // not worth switching now - } - if (lookahead == CType.FNC_1) { // two digits, then FNC_1... - lookahead = findCType(value, start + 3); - if (lookahead == CType.TWO_DIGITS) { // then two more digits, switch - return CODE_CODE_C; - } else { - return CODE_CODE_B; // otherwise not worth switching - } - } - // At this point, there are at least 4 consecutive digits. - // Look ahead to choose whether to switch now or on the next round. - int index = start + 4; - while ((lookahead = findCType(value, index)) == CType.TWO_DIGITS) { - index += 2; - } - if (lookahead == CType.ONE_DIGIT) { // odd number of digits, switch later - return CODE_CODE_B; - } - return CODE_CODE_C; // even number of digits, switch now - } - // Here oldCode == 0, which means we are choosing the initial code - if (lookahead == CType.FNC_1) { // ignore FNC_1 - lookahead = findCType(value, start + 1); - } - if (lookahead == CType.TWO_DIGITS) { // at least two digits, start in code C - return CODE_CODE_C; - } - return CODE_CODE_B; - } - - /** - * Encodes minimally using Divide-And-Conquer with Memoization - **/ - private static final class MinimalEncoder { - - private enum Charset { A, B, C, NONE } - private enum Latch { A, B, C, SHIFT, NONE } - - static final String A = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\u0000\u0001\u0002" + - "\u0003\u0004\u0005\u0006\u0007\u0008\u0009\n\u000B\u000C\r\u000E\u000F\u0010\u0011" + - "\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + - "\u00FF"; - static final String B = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqr" + - "stuvwxyz{|}~\u007F\u00FF"; - - private static final int CODE_SHIFT = 98; - - private int[][] memoizedCost; - private Latch[][] minPath; - - private boolean[] encode(String contents) { - memoizedCost = new int[4][contents.length()]; - minPath = new Latch[4][contents.length()]; - - encode(contents, Charset.NONE, 0); - - Collection patterns = new ArrayList<>(); - int[] checkSum = new int[] {0}; - int[] checkWeight = new int[] {1}; - int length = contents.length(); - Charset charset = Charset.NONE; - for (int i = 0; i < length; i++) { - Latch latch = minPath[charset.ordinal()][i]; - switch (latch) { - case A: - charset = Charset.A; - addPattern(patterns, i == 0 ? CODE_START_A : CODE_CODE_A, checkSum, checkWeight, i); - break; - case B: - charset = Charset.B; - addPattern(patterns, i == 0 ? CODE_START_B : CODE_CODE_B, checkSum, checkWeight, i); - break; - case C: - charset = Charset.C; - addPattern(patterns, i == 0 ? CODE_START_C : CODE_CODE_C, checkSum, checkWeight, i); - break; - case SHIFT: - addPattern(patterns, CODE_SHIFT, checkSum, checkWeight, i); - break; - } - if (charset == Charset.C) { - if (contents.charAt(i) == ESCAPE_FNC_1) { - addPattern(patterns, CODE_FNC_1, checkSum, checkWeight, i); - } else { - addPattern(patterns, Integer.parseInt(contents.substring(i, i + 2)), checkSum, checkWeight, i); - assert i + 1 < length; //the algorithm never leads to a single trailing digit in character set C - if (i + 1 < length) { - i++; - } - } - } else { // charset A or B - int patternIndex; - switch (contents.charAt(i)) { - case ESCAPE_FNC_1: - patternIndex = CODE_FNC_1; - break; - case ESCAPE_FNC_2: - patternIndex = CODE_FNC_2; - break; - case ESCAPE_FNC_3: - patternIndex = CODE_FNC_3; - break; - case ESCAPE_FNC_4: - if ((charset == Charset.A && latch != Latch.SHIFT) || - (charset == Charset.B && latch == Latch.SHIFT)) { - patternIndex = CODE_FNC_4_A; - } else { - patternIndex = CODE_FNC_4_B; - } - break; - default: - patternIndex = contents.charAt(i) - ' '; - } - if ((charset == Charset.A && latch != Latch.SHIFT) || - (charset == Charset.B && latch == Latch.SHIFT)) { - if (patternIndex < 0) { - patternIndex += '`'; - } - } - addPattern(patterns, patternIndex, checkSum, checkWeight, i); - } - } - memoizedCost = null; - minPath = null; - return produceResult(patterns, checkSum[0]); - } - - private static void addPattern(Collection patterns, - int patternIndex, - int[] checkSum, - int[] checkWeight, - int position) { - patterns.add(Code128Reader.CODE_PATTERNS[patternIndex]); - if (position != 0) { - checkWeight[0]++; - } - checkSum[0] += patternIndex * checkWeight[0]; - } - - private static boolean isDigit(char c) { - return c >= '0' && c <= '9'; - } - - private boolean canEncode(CharSequence contents, Charset charset,int position) { - char c = contents.charAt(position); - switch (charset) { - case A: return c == ESCAPE_FNC_1 || - c == ESCAPE_FNC_2 || - c == ESCAPE_FNC_3 || - c == ESCAPE_FNC_4 || - A.indexOf(c) >= 0; - case B: return c == ESCAPE_FNC_1 || - c == ESCAPE_FNC_2 || - c == ESCAPE_FNC_3 || - c == ESCAPE_FNC_4 || - B.indexOf(c) >= 0; - case C: return c == ESCAPE_FNC_1 || - (position + 1 < contents.length() && - isDigit(c) && - isDigit(contents.charAt(position + 1))); - default: return false; - } - } - - /** - * Encode the string starting at position position starting with the character set charset - **/ - private int encode(CharSequence contents, Charset charset, int position) { - assert position < contents.length(); - int mCost = memoizedCost[charset.ordinal()][position]; - if (mCost > 0) { - return mCost; - } - - int minCost = Integer.MAX_VALUE; - Latch minLatch = Latch.NONE; - boolean atEnd = position + 1 >= contents.length(); - - Charset[] sets = new Charset[] { Charset.A, Charset.B }; - for (int i = 0; i <= 1; i++) { - if (canEncode(contents, sets[i], position)) { - int cost = 1; - Latch latch = Latch.NONE; - if (charset != sets[i]) { - cost++; - latch = Latch.valueOf(sets[i].toString()); - } - if (!atEnd) { - cost += encode(contents, sets[i], position + 1); - } - if (cost < minCost) { - minCost = cost; - minLatch = latch; - } - cost = 1; - if (charset == sets[(i + 1) % 2]) { - cost++; - latch = Latch.SHIFT; - if (!atEnd) { - cost += encode(contents, charset, position + 1); - } - if (cost < minCost) { - minCost = cost; - minLatch = latch; - } - } - } - } - if (canEncode(contents, Charset.C, position)) { - int cost = 1; - Latch latch = Latch.NONE; - if (charset != Charset.C) { - cost++; - latch = Latch.C; - } - int advance = contents.charAt(position) == ESCAPE_FNC_1 ? 1 : 2; - if (position + advance < contents.length()) { - cost += encode(contents, Charset.C, position + advance); - } - if (cost < minCost) { - minCost = cost; - minLatch = latch; - } - } - if (minCost == Integer.MAX_VALUE) { - throw new IllegalArgumentException("Bad character in input: ASCII value=" + (int) contents.charAt(position)); - } - memoizedCost[charset.ordinal()][position] = minCost; - minPath[charset.ordinal()][position] = minLatch; - return minCost; - } - } -} diff --git a/port_src/core/DONE/oned/Code39Reader.java b/port_src/core/DONE/oned/Code39Reader.java deleted file mode 100644 index 35dfb7a..0000000 --- a/port_src/core/DONE/oned/Code39Reader.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitArray; - -import java.util.Arrays; -import java.util.Map; - -/** - *

Decodes Code 39 barcodes. Supports "Full ASCII Code 39" if USE_CODE_39_EXTENDED_MODE is set.

- * - * @author Sean Owen - * @see Code93Reader - */ -public final class Code39Reader extends OneDReader { - - static final String ALPHABET_STRING = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; - - /** - * These represent the encodings of characters, as patterns of wide and narrow bars. - * The 9 least-significant bits of each int correspond to the pattern of wide and narrow, - * with 1s representing "wide" and 0s representing narrow. - */ - static final int[] CHARACTER_ENCODINGS = { - 0x034, 0x121, 0x061, 0x160, 0x031, 0x130, 0x070, 0x025, 0x124, 0x064, // 0-9 - 0x109, 0x049, 0x148, 0x019, 0x118, 0x058, 0x00D, 0x10C, 0x04C, 0x01C, // A-J - 0x103, 0x043, 0x142, 0x013, 0x112, 0x052, 0x007, 0x106, 0x046, 0x016, // K-T - 0x181, 0x0C1, 0x1C0, 0x091, 0x190, 0x0D0, 0x085, 0x184, 0x0C4, 0x0A8, // U-$ - 0x0A2, 0x08A, 0x02A // /-% - }; - - static final int ASTERISK_ENCODING = 0x094; - - private final boolean usingCheckDigit; - private final boolean extendedMode; - private final StringBuilder decodeRowResult; - private final int[] counters; - - /** - * Creates a reader that assumes all encoded data is data, and does not treat the final - * character as a check digit. It will not decoded "extended Code 39" sequences. - */ - public Code39Reader() { - this(false); - } - - /** - * Creates a reader that can be configured to check the last character as a check digit. - * It will not decoded "extended Code 39" sequences. - * - * @param usingCheckDigit if true, treat the last data character as a check digit, not - * data, and verify that the checksum passes. - */ - public Code39Reader(boolean usingCheckDigit) { - this(usingCheckDigit, false); - } - - /** - * Creates a reader that can be configured to check the last character as a check digit, - * or optionally attempt to decode "extended Code 39" sequences that are used to encode - * the full ASCII character set. - * - * @param usingCheckDigit if true, treat the last data character as a check digit, not - * data, and verify that the checksum passes. - * @param extendedMode if true, will attempt to decode extended Code 39 sequences in the - * text. - */ - public Code39Reader(boolean usingCheckDigit, boolean extendedMode) { - this.usingCheckDigit = usingCheckDigit; - this.extendedMode = extendedMode; - decodeRowResult = new StringBuilder(20); - counters = new int[9]; - } - - @Override - public Result decodeRow(int rowNumber, BitArray row, Map hints) - throws NotFoundException, ChecksumException, FormatException { - - int[] theCounters = counters; - Arrays.fill(theCounters, 0); - StringBuilder result = decodeRowResult; - result.setLength(0); - - int[] start = findAsteriskPattern(row, theCounters); - // Read off white space - int nextStart = row.getNextSet(start[1]); - int end = row.getSize(); - - char decodedChar; - int lastStart; - do { - recordPattern(row, nextStart, theCounters); - int pattern = toNarrowWidePattern(theCounters); - if (pattern < 0) { - throw NotFoundException.getNotFoundInstance(); - } - decodedChar = patternToChar(pattern); - result.append(decodedChar); - lastStart = nextStart; - for (int counter : theCounters) { - nextStart += counter; - } - // Read off white space - nextStart = row.getNextSet(nextStart); - } while (decodedChar != '*'); - result.setLength(result.length() - 1); // remove asterisk - - // Look for whitespace after pattern: - int lastPatternSize = 0; - for (int counter : theCounters) { - lastPatternSize += counter; - } - int whiteSpaceAfterEnd = nextStart - lastStart - lastPatternSize; - // If 50% of last pattern size, following last pattern, is not whitespace, fail - // (but if it's whitespace to the very end of the image, that's OK) - if (nextStart != end && (whiteSpaceAfterEnd * 2) < lastPatternSize) { - throw NotFoundException.getNotFoundInstance(); - } - - if (usingCheckDigit) { - int max = result.length() - 1; - int total = 0; - for (int i = 0; i < max; i++) { - total += ALPHABET_STRING.indexOf(decodeRowResult.charAt(i)); - } - if (result.charAt(max) != ALPHABET_STRING.charAt(total % 43)) { - throw ChecksumException.getChecksumInstance(); - } - result.setLength(max); - } - - if (result.length() == 0) { - // false positive - throw NotFoundException.getNotFoundInstance(); - } - - String resultString; - if (extendedMode) { - resultString = decodeExtended(result); - } else { - resultString = result.toString(); - } - - float left = (start[1] + start[0]) / 2.0f; - float right = lastStart + lastPatternSize / 2.0f; - - Result resultObject = new Result( - resultString, - null, - new ResultPoint[]{ - new ResultPoint(left, rowNumber), - new ResultPoint(right, rowNumber)}, - BarcodeFormat.CODE_39); - resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]A0"); - return resultObject; - } - - private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException { - int width = row.getSize(); - int rowOffset = row.getNextSet(0); - - int counterPosition = 0; - int patternStart = rowOffset; - boolean isWhite = false; - int patternLength = counters.length; - - for (int i = rowOffset; i < width; i++) { - if (row.get(i) != isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == patternLength - 1) { - // Look for whitespace before start pattern, >= 50% of width of start pattern - if (toNarrowWidePattern(counters) == ASTERISK_ENCODING && - row.isRange(Math.max(0, patternStart - ((i - patternStart) / 2)), patternStart, false)) { - return new int[]{patternStart, i}; - } - patternStart += counters[0] + counters[1]; - System.arraycopy(counters, 2, counters, 0, counterPosition - 1); - counters[counterPosition - 1] = 0; - counters[counterPosition] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - throw NotFoundException.getNotFoundInstance(); - } - - // For efficiency, returns -1 on failure. Not throwing here saved as many as 700 exceptions - // per image when using some of our blackbox images. - private static int toNarrowWidePattern(int[] counters) { - int numCounters = counters.length; - int maxNarrowCounter = 0; - int wideCounters; - do { - int minCounter = Integer.MAX_VALUE; - for (int counter : counters) { - if (counter < minCounter && counter > maxNarrowCounter) { - minCounter = counter; - } - } - maxNarrowCounter = minCounter; - wideCounters = 0; - int totalWideCountersWidth = 0; - int pattern = 0; - for (int i = 0; i < numCounters; i++) { - int counter = counters[i]; - if (counter > maxNarrowCounter) { - pattern |= 1 << (numCounters - 1 - i); - wideCounters++; - totalWideCountersWidth += counter; - } - } - if (wideCounters == 3) { - // Found 3 wide counters, but are they close enough in width? - // We can perform a cheap, conservative check to see if any individual - // counter is more than 1.5 times the average: - for (int i = 0; i < numCounters && wideCounters > 0; i++) { - int counter = counters[i]; - if (counter > maxNarrowCounter) { - wideCounters--; - // totalWideCountersWidth = 3 * average, so this checks if counter >= 3/2 * average - if ((counter * 2) >= totalWideCountersWidth) { - return -1; - } - } - } - return pattern; - } - } while (wideCounters > 3); - return -1; - } - - private static char patternToChar(int pattern) throws NotFoundException { - for (int i = 0; i < CHARACTER_ENCODINGS.length; i++) { - if (CHARACTER_ENCODINGS[i] == pattern) { - return ALPHABET_STRING.charAt(i); - } - } - if (pattern == ASTERISK_ENCODING) { - return '*'; - } - throw NotFoundException.getNotFoundInstance(); - } - - private static String decodeExtended(CharSequence encoded) throws FormatException { - int length = encoded.length(); - StringBuilder decoded = new StringBuilder(length); - for (int i = 0; i < length; i++) { - char c = encoded.charAt(i); - if (c == '+' || c == '$' || c == '%' || c == '/') { - char next = encoded.charAt(i + 1); - char decodedChar = '\0'; - switch (c) { - case '+': - // +A to +Z map to a to z - if (next >= 'A' && next <= 'Z') { - decodedChar = (char) (next + 32); - } else { - throw FormatException.getFormatInstance(); - } - break; - case '$': - // $A to $Z map to control codes SH to SB - if (next >= 'A' && next <= 'Z') { - decodedChar = (char) (next - 64); - } else { - throw FormatException.getFormatInstance(); - } - break; - case '%': - // %A to %E map to control codes ESC to US - if (next >= 'A' && next <= 'E') { - decodedChar = (char) (next - 38); - } else if (next >= 'F' && next <= 'J') { - decodedChar = (char) (next - 11); - } else if (next >= 'K' && next <= 'O') { - decodedChar = (char) (next + 16); - } else if (next >= 'P' && next <= 'T') { - decodedChar = (char) (next + 43); - } else if (next == 'U') { - decodedChar = (char) 0; - } else if (next == 'V') { - decodedChar = '@'; - } else if (next == 'W') { - decodedChar = '`'; - } else if (next == 'X' || next == 'Y' || next == 'Z') { - decodedChar = (char) 127; - } else { - throw FormatException.getFormatInstance(); - } - break; - case '/': - // /A to /O map to ! to , and /Z maps to : - if (next >= 'A' && next <= 'O') { - decodedChar = (char) (next - 32); - } else if (next == 'Z') { - decodedChar = ':'; - } else { - throw FormatException.getFormatInstance(); - } - break; - } - decoded.append(decodedChar); - // bump up i again since we read two characters - i++; - } else { - decoded.append(c); - } - } - return decoded.toString(); - } - -} diff --git a/port_src/core/DONE/oned/Code39Writer.java b/port_src/core/DONE/oned/Code39Writer.java deleted file mode 100644 index e46fc7c..0000000 --- a/port_src/core/DONE/oned/Code39Writer.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.BitMatrix; - -import java.util.Collection; -import java.util.Collections; - -/** - * This object renders a CODE39 code as a {@link BitMatrix}. - * - * @author erik.barbara@gmail.com (Erik Barbara) - */ -public final class Code39Writer extends OneDimensionalCodeWriter { - - @Override - protected Collection getSupportedWriteFormats() { - return Collections.singleton(BarcodeFormat.CODE_39); - } - - @Override - public boolean[] encode(String contents) { - int length = contents.length(); - if (length > 80) { - throw new IllegalArgumentException( - "Requested contents should be less than 80 digits long, but got " + length); - } - - for (int i = 0; i < length; i++) { - int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i)); - if (indexInString < 0) { - contents = tryToConvertToExtendedMode(contents); - length = contents.length(); - if (length > 80) { - throw new IllegalArgumentException("Requested contents should be less than 80 digits long, but got " + - length + " (extended full ASCII mode)"); - } - break; - } - } - - int[] widths = new int[9]; - int codeWidth = 24 + 1 + (13 * length); - boolean[] result = new boolean[codeWidth]; - toIntArray(Code39Reader.ASTERISK_ENCODING, widths); - int pos = appendPattern(result, 0, widths, true); - int[] narrowWhite = {1}; - pos += appendPattern(result, pos, narrowWhite, false); - //append next character to byte matrix - for (int i = 0; i < length; i++) { - int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i)); - toIntArray(Code39Reader.CHARACTER_ENCODINGS[indexInString], widths); - pos += appendPattern(result, pos, widths, true); - pos += appendPattern(result, pos, narrowWhite, false); - } - toIntArray(Code39Reader.ASTERISK_ENCODING, widths); - appendPattern(result, pos, widths, true); - return result; - } - - private static void toIntArray(int a, int[] toReturn) { - for (int i = 0; i < 9; i++) { - int temp = a & (1 << (8 - i)); - toReturn[i] = temp == 0 ? 1 : 2; - } - } - - private static String tryToConvertToExtendedMode(String contents) { - int length = contents.length(); - StringBuilder extendedContent = new StringBuilder(); - for (int i = 0; i < length; i++) { - char character = contents.charAt(i); - switch (character) { - case '\u0000': - extendedContent.append("%U"); - break; - case ' ': - case '-': - case '.': - extendedContent.append(character); - break; - case '@': - extendedContent.append("%V"); - break; - case '`': - extendedContent.append("%W"); - break; - default: - if (character <= 26) { - extendedContent.append('$'); - extendedContent.append((char) ('A' + (character - 1))); - } else if (character < ' ') { - extendedContent.append('%'); - extendedContent.append((char) ('A' + (character - 27))); - } else if (character <= ',' || character == '/' || character == ':') { - extendedContent.append('/'); - extendedContent.append((char) ('A' + (character - 33))); - } else if (character <= '9') { - extendedContent.append((char) ('0' + (character - 48))); - } else if (character <= '?') { - extendedContent.append('%'); - extendedContent.append((char) ('F' + (character - 59))); - } else if (character <= 'Z') { - extendedContent.append((char) ('A' + (character - 65))); - } else if (character <= '_') { - extendedContent.append('%'); - extendedContent.append((char) ('K' + (character - 91))); - } else if (character <= 'z') { - extendedContent.append('+'); - extendedContent.append((char) ('A' + (character - 97))); - } else if (character <= 127) { - extendedContent.append('%'); - extendedContent.append((char) ('P' + (character - 123))); - } else { - throw new IllegalArgumentException( - "Requested content contains a non-encodable character: '" + contents.charAt(i) + "'"); - } - break; - } - } - - return extendedContent.toString(); - } - -} diff --git a/port_src/core/DONE/oned/Code93Reader.java b/port_src/core/DONE/oned/Code93Reader.java deleted file mode 100644 index 5aa203f..0000000 --- a/port_src/core/DONE/oned/Code93Reader.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitArray; - -import java.util.Arrays; -import java.util.Map; - -/** - *

Decodes Code 93 barcodes.

- * - * @author Sean Owen - * @see Code39Reader - */ -public final class Code93Reader extends OneDReader { - - // Note that 'abcd' are dummy characters in place of control characters. - static final String ALPHABET_STRING = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*"; - private static final char[] ALPHABET = ALPHABET_STRING.toCharArray(); - - /** - * These represent the encodings of characters, as patterns of wide and narrow bars. - * The 9 least-significant bits of each int correspond to the pattern of wide and narrow. - */ - static final int[] CHARACTER_ENCODINGS = { - 0x114, 0x148, 0x144, 0x142, 0x128, 0x124, 0x122, 0x150, 0x112, 0x10A, // 0-9 - 0x1A8, 0x1A4, 0x1A2, 0x194, 0x192, 0x18A, 0x168, 0x164, 0x162, 0x134, // A-J - 0x11A, 0x158, 0x14C, 0x146, 0x12C, 0x116, 0x1B4, 0x1B2, 0x1AC, 0x1A6, // K-T - 0x196, 0x19A, 0x16C, 0x166, 0x136, 0x13A, // U-Z - 0x12E, 0x1D4, 0x1D2, 0x1CA, 0x16E, 0x176, 0x1AE, // - - % - 0x126, 0x1DA, 0x1D6, 0x132, 0x15E, // Control chars? $-* - }; - static final int ASTERISK_ENCODING = CHARACTER_ENCODINGS[47]; - - private final StringBuilder decodeRowResult; - private final int[] counters; - - public Code93Reader() { - decodeRowResult = new StringBuilder(20); - counters = new int[6]; - } - - @Override - public Result decodeRow(int rowNumber, BitArray row, Map hints) - throws NotFoundException, ChecksumException, FormatException { - - int[] start = findAsteriskPattern(row); - // Read off white space - int nextStart = row.getNextSet(start[1]); - int end = row.getSize(); - - int[] theCounters = counters; - Arrays.fill(theCounters, 0); - StringBuilder result = decodeRowResult; - result.setLength(0); - - char decodedChar; - int lastStart; - do { - recordPattern(row, nextStart, theCounters); - int pattern = toPattern(theCounters); - if (pattern < 0) { - throw NotFoundException.getNotFoundInstance(); - } - decodedChar = patternToChar(pattern); - result.append(decodedChar); - lastStart = nextStart; - for (int counter : theCounters) { - nextStart += counter; - } - // Read off white space - nextStart = row.getNextSet(nextStart); - } while (decodedChar != '*'); - result.deleteCharAt(result.length() - 1); // remove asterisk - - int lastPatternSize = 0; - for (int counter : theCounters) { - lastPatternSize += counter; - } - - // Should be at least one more black module - if (nextStart == end || !row.get(nextStart)) { - throw NotFoundException.getNotFoundInstance(); - } - - if (result.length() < 2) { - // false positive -- need at least 2 checksum digits - throw NotFoundException.getNotFoundInstance(); - } - - checkChecksums(result); - // Remove checksum digits - result.setLength(result.length() - 2); - - String resultString = decodeExtended(result); - - float left = (start[1] + start[0]) / 2.0f; - float right = lastStart + lastPatternSize / 2.0f; - - Result resultObject = new Result( - resultString, - null, - new ResultPoint[]{ - new ResultPoint(left, rowNumber), - new ResultPoint(right, rowNumber)}, - BarcodeFormat.CODE_93); - resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]G0"); - return resultObject; - } - - private int[] findAsteriskPattern(BitArray row) throws NotFoundException { - int width = row.getSize(); - int rowOffset = row.getNextSet(0); - - Arrays.fill(counters, 0); - int[] theCounters = counters; - int patternStart = rowOffset; - boolean isWhite = false; - int patternLength = theCounters.length; - - int counterPosition = 0; - for (int i = rowOffset; i < width; i++) { - if (row.get(i) != isWhite) { - theCounters[counterPosition]++; - } else { - if (counterPosition == patternLength - 1) { - if (toPattern(theCounters) == ASTERISK_ENCODING) { - return new int[]{patternStart, i}; - } - patternStart += theCounters[0] + theCounters[1]; - System.arraycopy(theCounters, 2, theCounters, 0, counterPosition - 1); - theCounters[counterPosition - 1] = 0; - theCounters[counterPosition] = 0; - counterPosition--; - } else { - counterPosition++; - } - theCounters[counterPosition] = 1; - isWhite = !isWhite; - } - } - throw NotFoundException.getNotFoundInstance(); - } - - private static int toPattern(int[] counters) { - int sum = 0; - for (int counter : counters) { - sum += counter; - } - int pattern = 0; - int max = counters.length; - for (int i = 0; i < max; i++) { - int scaled = Math.round(counters[i] * 9.0f / sum); - if (scaled < 1 || scaled > 4) { - return -1; - } - if ((i & 0x01) == 0) { - for (int j = 0; j < scaled; j++) { - pattern = (pattern << 1) | 0x01; - } - } else { - pattern <<= scaled; - } - } - return pattern; - } - - private static char patternToChar(int pattern) throws NotFoundException { - for (int i = 0; i < CHARACTER_ENCODINGS.length; i++) { - if (CHARACTER_ENCODINGS[i] == pattern) { - return ALPHABET[i]; - } - } - throw NotFoundException.getNotFoundInstance(); - } - - private static String decodeExtended(CharSequence encoded) throws FormatException { - int length = encoded.length(); - StringBuilder decoded = new StringBuilder(length); - for (int i = 0; i < length; i++) { - char c = encoded.charAt(i); - if (c >= 'a' && c <= 'd') { - if (i >= length - 1) { - throw FormatException.getFormatInstance(); - } - char next = encoded.charAt(i + 1); - char decodedChar = '\0'; - switch (c) { - case 'd': - // +A to +Z map to a to z - if (next >= 'A' && next <= 'Z') { - decodedChar = (char) (next + 32); - } else { - throw FormatException.getFormatInstance(); - } - break; - case 'a': - // $A to $Z map to control codes SH to SB - if (next >= 'A' && next <= 'Z') { - decodedChar = (char) (next - 64); - } else { - throw FormatException.getFormatInstance(); - } - break; - case 'b': - if (next >= 'A' && next <= 'E') { - // %A to %E map to control codes ESC to USep - decodedChar = (char) (next - 38); - } else if (next >= 'F' && next <= 'J') { - // %F to %J map to ; < = > ? - decodedChar = (char) (next - 11); - } else if (next >= 'K' && next <= 'O') { - // %K to %O map to [ \ ] ^ _ - decodedChar = (char) (next + 16); - } else if (next >= 'P' && next <= 'T') { - // %P to %T map to { | } ~ DEL - decodedChar = (char) (next + 43); - } else if (next == 'U') { - // %U map to NUL - decodedChar = '\0'; - } else if (next == 'V') { - // %V map to @ - decodedChar = '@'; - } else if (next == 'W') { - // %W map to ` - decodedChar = '`'; - } else if (next >= 'X' && next <= 'Z') { - // %X to %Z all map to DEL (127) - decodedChar = 127; - } else { - throw FormatException.getFormatInstance(); - } - break; - case 'c': - // /A to /O map to ! to , and /Z maps to : - if (next >= 'A' && next <= 'O') { - decodedChar = (char) (next - 32); - } else if (next == 'Z') { - decodedChar = ':'; - } else { - throw FormatException.getFormatInstance(); - } - break; - } - decoded.append(decodedChar); - // bump up i again since we read two characters - i++; - } else { - decoded.append(c); - } - } - return decoded.toString(); - } - - private static void checkChecksums(CharSequence result) throws ChecksumException { - int length = result.length(); - checkOneChecksum(result, length - 2, 20); - checkOneChecksum(result, length - 1, 15); - } - - private static void checkOneChecksum(CharSequence result, int checkPosition, int weightMax) - throws ChecksumException { - int weight = 1; - int total = 0; - for (int i = checkPosition - 1; i >= 0; i--) { - total += weight * ALPHABET_STRING.indexOf(result.charAt(i)); - if (++weight > weightMax) { - weight = 1; - } - } - if (result.charAt(checkPosition) != ALPHABET[total % 47]) { - throw ChecksumException.getChecksumInstance(); - } - } - -} diff --git a/port_src/core/DONE/oned/Code93Writer.java b/port_src/core/DONE/oned/Code93Writer.java deleted file mode 100644 index 716c8b7..0000000 --- a/port_src/core/DONE/oned/Code93Writer.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2015 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; - -import java.util.Collection; -import java.util.Collections; - -/** - * This object renders a CODE93 code as a BitMatrix - */ -public class Code93Writer extends OneDimensionalCodeWriter { - - @Override - protected Collection getSupportedWriteFormats() { - return Collections.singleton(BarcodeFormat.CODE_93); - } - - /** - * @param contents barcode contents to encode. It should not be encoded for extended characters. - * @return a {@code boolean[]} of horizontal pixels (false = white, true = black) - */ - @Override - public boolean[] encode(String contents) { - contents = convertToExtended(contents); - int length = contents.length(); - if (length > 80) { - throw new IllegalArgumentException("Requested contents should be less than 80 digits long after " + - "converting to extended encoding, but got " + length); - } - - //length of code + 2 start/stop characters + 2 checksums, each of 9 bits, plus a termination bar - int codeWidth = (contents.length() + 2 + 2) * 9 + 1; - - boolean[] result = new boolean[codeWidth]; - - //start character (*) - int pos = appendPattern(result, 0, Code93Reader.ASTERISK_ENCODING); - - for (int i = 0; i < length; i++) { - int indexInString = Code93Reader.ALPHABET_STRING.indexOf(contents.charAt(i)); - pos += appendPattern(result, pos, Code93Reader.CHARACTER_ENCODINGS[indexInString]); - } - - //add two checksums - int check1 = computeChecksumIndex(contents, 20); - pos += appendPattern(result, pos, Code93Reader.CHARACTER_ENCODINGS[check1]); - - //append the contents to reflect the first checksum added - contents += Code93Reader.ALPHABET_STRING.charAt(check1); - - int check2 = computeChecksumIndex(contents, 15); - pos += appendPattern(result, pos, Code93Reader.CHARACTER_ENCODINGS[check2]); - - //end character (*) - pos += appendPattern(result, pos, Code93Reader.ASTERISK_ENCODING); - - //termination bar (single black bar) - result[pos] = true; - - return result; - } - - /** - * @param target output to append to - * @param pos start position - * @param pattern pattern to append - * @param startColor unused - * @return 9 - * @deprecated without replacement; intended as an internal-only method - */ - @Deprecated - protected static int appendPattern(boolean[] target, int pos, int[] pattern, boolean startColor) { - for (int bit : pattern) { - target[pos++] = bit != 0; - } - return 9; - } - - private static int appendPattern(boolean[] target, int pos, int a) { - for (int i = 0; i < 9; i++) { - int temp = a & (1 << (8 - i)); - target[pos + i] = temp != 0; - } - return 9; - } - - private static int computeChecksumIndex(String contents, int maxWeight) { - int weight = 1; - int total = 0; - - for (int i = contents.length() - 1; i >= 0; i--) { - int indexInString = Code93Reader.ALPHABET_STRING.indexOf(contents.charAt(i)); - total += indexInString * weight; - if (++weight > maxWeight) { - weight = 1; - } - } - return total % 47; - } - - static String convertToExtended(String contents) { - int length = contents.length(); - StringBuilder extendedContent = new StringBuilder(length * 2); - for (int i = 0; i < length; i++) { - char character = contents.charAt(i); - // ($)=a, (%)=b, (/)=c, (+)=d. see Code93Reader.ALPHABET_STRING - if (character == 0) { - // NUL: (%)U - extendedContent.append("bU"); - } else if (character <= 26) { - // SOH - SUB: ($)A - ($)Z - extendedContent.append('a'); - extendedContent.append((char) ('A' + character - 1)); - } else if (character <= 31) { - // ESC - US: (%)A - (%)E - extendedContent.append('b'); - extendedContent.append((char) ('A' + character - 27)); - } else if (character == ' ' || character == '$' || character == '%' || character == '+') { - // space $ % + - extendedContent.append(character); - } else if (character <= ',') { - // ! " # & ' ( ) * ,: (/)A - (/)L - extendedContent.append('c'); - extendedContent.append((char) ('A' + character - '!')); - } else if (character <= '9') { - extendedContent.append(character); - } else if (character == ':') { - // :: (/)Z - extendedContent.append("cZ"); - } else if (character <= '?') { - // ; - ?: (%)F - (%)J - extendedContent.append('b'); - extendedContent.append((char) ('F' + character - ';')); - } else if (character == '@') { - // @: (%)V - extendedContent.append("bV"); - } else if (character <= 'Z') { - // A - Z - extendedContent.append(character); - } else if (character <= '_') { - // [ - _: (%)K - (%)O - extendedContent.append('b'); - extendedContent.append((char) ('K' + character - '[')); - } else if (character == '`') { - // `: (%)W - extendedContent.append("bW"); - } else if (character <= 'z') { - // a - z: (*)A - (*)Z - extendedContent.append('d'); - extendedContent.append((char) ('A' + character - 'a')); - } else if (character <= 127) { - // { - DEL: (%)P - (%)T - extendedContent.append('b'); - extendedContent.append((char) ('P' + character - '{')); - } else { - throw new IllegalArgumentException( - "Requested content contains a non-encodable character: '" + character + "'"); - } - } - return extendedContent.toString(); - } - -} diff --git a/port_src/core/DONE/oned/EAN13Reader.java b/port_src/core/DONE/oned/EAN13Reader.java deleted file mode 100644 index c537eac..0000000 --- a/port_src/core/DONE/oned/EAN13Reader.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.NotFoundException; -import com.google.zxing.common.BitArray; - -/** - *

Implements decoding of the EAN-13 format.

- * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - * @author alasdair@google.com (Alasdair Mackintosh) - */ -public final class EAN13Reader extends UPCEANReader { - - // For an EAN-13 barcode, the first digit is represented by the parities used - // to encode the next six digits, according to the table below. For example, - // if the barcode is 5 123456 789012 then the value of the first digit is - // signified by using odd for '1', even for '2', even for '3', odd for '4', - // odd for '5', and even for '6'. See http://en.wikipedia.org/wiki/EAN-13 - // - // Parity of next 6 digits - // Digit 0 1 2 3 4 5 - // 0 Odd Odd Odd Odd Odd Odd - // 1 Odd Odd Even Odd Even Even - // 2 Odd Odd Even Even Odd Even - // 3 Odd Odd Even Even Even Odd - // 4 Odd Even Odd Odd Even Even - // 5 Odd Even Even Odd Odd Even - // 6 Odd Even Even Even Odd Odd - // 7 Odd Even Odd Even Odd Even - // 8 Odd Even Odd Even Even Odd - // 9 Odd Even Even Odd Even Odd - // - // Note that the encoding for '0' uses the same parity as a UPC barcode. Hence - // a UPC barcode can be converted to an EAN-13 barcode by prepending a 0. - // - // The encoding is represented by the following array, which is a bit pattern - // using Odd = 0 and Even = 1. For example, 5 is represented by: - // - // Odd Even Even Odd Odd Even - // in binary: - // 0 1 1 0 0 1 == 0x19 - // - static final int[] FIRST_DIGIT_ENCODINGS = { - 0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A - }; - - private final int[] decodeMiddleCounters; - - public EAN13Reader() { - decodeMiddleCounters = new int[4]; - } - - @Override - protected int decodeMiddle(BitArray row, - int[] startRange, - StringBuilder resultString) throws NotFoundException { - int[] counters = decodeMiddleCounters; - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - int end = row.getSize(); - int rowOffset = startRange[1]; - - int lgPatternFound = 0; - - for (int x = 0; x < 6 && rowOffset < end; x++) { - int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS); - resultString.append((char) ('0' + bestMatch % 10)); - for (int counter : counters) { - rowOffset += counter; - } - if (bestMatch >= 10) { - lgPatternFound |= 1 << (5 - x); - } - } - - determineFirstDigit(resultString, lgPatternFound); - - int[] middleRange = findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN); - rowOffset = middleRange[1]; - - for (int x = 0; x < 6 && rowOffset < end; x++) { - int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); - resultString.append((char) ('0' + bestMatch)); - for (int counter : counters) { - rowOffset += counter; - } - } - - return rowOffset; - } - - @Override - BarcodeFormat getBarcodeFormat() { - return BarcodeFormat.EAN_13; - } - - /** - * Based on pattern of odd-even ('L' and 'G') patterns used to encoded the explicitly-encoded - * digits in a barcode, determines the implicitly encoded first digit and adds it to the - * result string. - * - * @param resultString string to insert decoded first digit into - * @param lgPatternFound int whose bits indicates the pattern of odd/even L/G patterns used to - * encode digits - * @throws NotFoundException if first digit cannot be determined - */ - private static void determineFirstDigit(StringBuilder resultString, int lgPatternFound) - throws NotFoundException { - for (int d = 0; d < 10; d++) { - if (lgPatternFound == FIRST_DIGIT_ENCODINGS[d]) { - resultString.insert(0, (char) ('0' + d)); - return; - } - } - throw NotFoundException.getNotFoundInstance(); - } - -} diff --git a/port_src/core/DONE/oned/EAN13Writer.java b/port_src/core/DONE/oned/EAN13Writer.java deleted file mode 100644 index 02293f3..0000000 --- a/port_src/core/DONE/oned/EAN13Writer.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; - -import java.util.Collection; -import java.util.Collections; - -/** - * This object renders an EAN13 code as a {@link BitMatrix}. - * - * @author aripollak@gmail.com (Ari Pollak) - */ -public final class EAN13Writer extends UPCEANWriter { - - private static final int CODE_WIDTH = 3 + // start guard - (7 * 6) + // left bars - 5 + // middle guard - (7 * 6) + // right bars - 3; // end guard - - @Override - protected Collection getSupportedWriteFormats() { - return Collections.singleton(BarcodeFormat.EAN_13); - } - - @Override - public boolean[] encode(String contents) { - int length = contents.length(); - switch (length) { - case 12: - // No check digit present, calculate it and add it - int check; - try { - check = UPCEANReader.getStandardUPCEANChecksum(contents); - } catch (FormatException fe) { - throw new IllegalArgumentException(fe); - } - contents += check; - break; - case 13: - try { - if (!UPCEANReader.checkStandardUPCEANChecksum(contents)) { - throw new IllegalArgumentException("Contents do not pass checksum"); - } - } catch (FormatException ignored) { - throw new IllegalArgumentException("Illegal contents"); - } - break; - default: - throw new IllegalArgumentException( - "Requested contents should be 12 or 13 digits long, but got " + length); - } - - checkNumeric(contents); - - int firstDigit = Character.digit(contents.charAt(0), 10); - int parities = EAN13Reader.FIRST_DIGIT_ENCODINGS[firstDigit]; - boolean[] result = new boolean[CODE_WIDTH]; - int pos = 0; - - pos += appendPattern(result, pos, UPCEANReader.START_END_PATTERN, true); - - // See EAN13Reader for a description of how the first digit & left bars are encoded - for (int i = 1; i <= 6; i++) { - int digit = Character.digit(contents.charAt(i), 10); - if ((parities >> (6 - i) & 1) == 1) { - digit += 10; - } - pos += appendPattern(result, pos, UPCEANReader.L_AND_G_PATTERNS[digit], false); - } - - pos += appendPattern(result, pos, UPCEANReader.MIDDLE_PATTERN, false); - - for (int i = 7; i <= 12; i++) { - int digit = Character.digit(contents.charAt(i), 10); - pos += appendPattern(result, pos, UPCEANReader.L_PATTERNS[digit], true); - } - appendPattern(result, pos, UPCEANReader.START_END_PATTERN, true); - - return result; - } - -} diff --git a/port_src/core/DONE/oned/EAN8Reader.java b/port_src/core/DONE/oned/EAN8Reader.java deleted file mode 100644 index 8d0b7e2..0000000 --- a/port_src/core/DONE/oned/EAN8Reader.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.NotFoundException; -import com.google.zxing.common.BitArray; - -/** - *

Implements decoding of the EAN-8 format.

- * - * @author Sean Owen - */ -public final class EAN8Reader extends UPCEANReader { - - private final int[] decodeMiddleCounters; - - public EAN8Reader() { - decodeMiddleCounters = new int[4]; - } - - @Override - protected int decodeMiddle(BitArray row, - int[] startRange, - StringBuilder result) throws NotFoundException { - int[] counters = decodeMiddleCounters; - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - int end = row.getSize(); - int rowOffset = startRange[1]; - - for (int x = 0; x < 4 && rowOffset < end; x++) { - int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); - result.append((char) ('0' + bestMatch)); - for (int counter : counters) { - rowOffset += counter; - } - } - - int[] middleRange = findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN); - rowOffset = middleRange[1]; - - for (int x = 0; x < 4 && rowOffset < end; x++) { - int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); - result.append((char) ('0' + bestMatch)); - for (int counter : counters) { - rowOffset += counter; - } - } - - return rowOffset; - } - - @Override - BarcodeFormat getBarcodeFormat() { - return BarcodeFormat.EAN_8; - } - -} diff --git a/port_src/core/DONE/oned/EAN8Writer.java b/port_src/core/DONE/oned/EAN8Writer.java deleted file mode 100644 index 5050141..0000000 --- a/port_src/core/DONE/oned/EAN8Writer.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; - -import java.util.Collection; -import java.util.Collections; - -/** - * This object renders an EAN8 code as a {@link BitMatrix}. - * - * @author aripollak@gmail.com (Ari Pollak) - */ -public final class EAN8Writer extends UPCEANWriter { - - private static final int CODE_WIDTH = 3 + // start guard - (7 * 4) + // left bars - 5 + // middle guard - (7 * 4) + // right bars - 3; // end guard - - @Override - protected Collection getSupportedWriteFormats() { - return Collections.singleton(BarcodeFormat.EAN_8); - } - - /** - * @return a byte array of horizontal pixels (false = white, true = black) - */ - @Override - public boolean[] encode(String contents) { - int length = contents.length(); - switch (length) { - case 7: - // No check digit present, calculate it and add it - int check; - try { - check = UPCEANReader.getStandardUPCEANChecksum(contents); - } catch (FormatException fe) { - throw new IllegalArgumentException(fe); - } - contents += check; - break; - case 8: - try { - if (!UPCEANReader.checkStandardUPCEANChecksum(contents)) { - throw new IllegalArgumentException("Contents do not pass checksum"); - } - } catch (FormatException ignored) { - throw new IllegalArgumentException("Illegal contents"); - } - break; - default: - throw new IllegalArgumentException( - "Requested contents should be 7 or 8 digits long, but got " + length); - } - - checkNumeric(contents); - - boolean[] result = new boolean[CODE_WIDTH]; - int pos = 0; - - pos += appendPattern(result, pos, UPCEANReader.START_END_PATTERN, true); - - for (int i = 0; i <= 3; i++) { - int digit = Character.digit(contents.charAt(i), 10); - pos += appendPattern(result, pos, UPCEANReader.L_PATTERNS[digit], false); - } - - pos += appendPattern(result, pos, UPCEANReader.MIDDLE_PATTERN, false); - - for (int i = 4; i <= 7; i++) { - int digit = Character.digit(contents.charAt(i), 10); - pos += appendPattern(result, pos, UPCEANReader.L_PATTERNS[digit], true); - } - appendPattern(result, pos, UPCEANReader.START_END_PATTERN, true); - - return result; - } - -} diff --git a/port_src/core/DONE/oned/EANManufacturerOrgSupport.java b/port_src/core/DONE/oned/EANManufacturerOrgSupport.java deleted file mode 100644 index 805dbd8..0000000 --- a/port_src/core/DONE/oned/EANManufacturerOrgSupport.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import java.util.ArrayList; -import java.util.List; - -/** - * Records EAN prefix to GS1 Member Organization, where the member organization - * correlates strongly with a country. This is an imperfect means of identifying - * a country of origin by EAN-13 barcode value. See - * - * http://en.wikipedia.org/wiki/List_of_GS1_country_codes. - * - * @author Sean Owen - */ -final class EANManufacturerOrgSupport { - - private final List ranges = new ArrayList<>(); - private final List countryIdentifiers = new ArrayList<>(); - - String lookupCountryIdentifier(String productCode) { - initIfNeeded(); - int prefix = Integer.parseInt(productCode.substring(0, 3)); - int max = ranges.size(); - for (int i = 0; i < max; i++) { - int[] range = ranges.get(i); - int start = range[0]; - if (prefix < start) { - return null; - } - int end = range.length == 1 ? start : range[1]; - if (prefix <= end) { - return countryIdentifiers.get(i); - } - } - return null; - } - - private void add(int[] range, String id) { - ranges.add(range); - countryIdentifiers.add(id); - } - - private synchronized void initIfNeeded() { - if (!ranges.isEmpty()) { - return; - } - add(new int[] {0,19}, "US/CA"); - add(new int[] {30,39}, "US"); - add(new int[] {60,139}, "US/CA"); - add(new int[] {300,379}, "FR"); - add(new int[] {380}, "BG"); - add(new int[] {383}, "SI"); - add(new int[] {385}, "HR"); - add(new int[] {387}, "BA"); - add(new int[] {400,440}, "DE"); - add(new int[] {450,459}, "JP"); - add(new int[] {460,469}, "RU"); - add(new int[] {471}, "TW"); - add(new int[] {474}, "EE"); - add(new int[] {475}, "LV"); - add(new int[] {476}, "AZ"); - add(new int[] {477}, "LT"); - add(new int[] {478}, "UZ"); - add(new int[] {479}, "LK"); - add(new int[] {480}, "PH"); - add(new int[] {481}, "BY"); - add(new int[] {482}, "UA"); - add(new int[] {484}, "MD"); - add(new int[] {485}, "AM"); - add(new int[] {486}, "GE"); - add(new int[] {487}, "KZ"); - add(new int[] {489}, "HK"); - add(new int[] {490,499}, "JP"); - add(new int[] {500,509}, "GB"); - add(new int[] {520}, "GR"); - add(new int[] {528}, "LB"); - add(new int[] {529}, "CY"); - add(new int[] {531}, "MK"); - add(new int[] {535}, "MT"); - add(new int[] {539}, "IE"); - add(new int[] {540,549}, "BE/LU"); - add(new int[] {560}, "PT"); - add(new int[] {569}, "IS"); - add(new int[] {570,579}, "DK"); - add(new int[] {590}, "PL"); - add(new int[] {594}, "RO"); - add(new int[] {599}, "HU"); - add(new int[] {600,601}, "ZA"); - add(new int[] {603}, "GH"); - add(new int[] {608}, "BH"); - add(new int[] {609}, "MU"); - add(new int[] {611}, "MA"); - add(new int[] {613}, "DZ"); - add(new int[] {616}, "KE"); - add(new int[] {618}, "CI"); - add(new int[] {619}, "TN"); - add(new int[] {621}, "SY"); - add(new int[] {622}, "EG"); - add(new int[] {624}, "LY"); - add(new int[] {625}, "JO"); - add(new int[] {626}, "IR"); - add(new int[] {627}, "KW"); - add(new int[] {628}, "SA"); - add(new int[] {629}, "AE"); - add(new int[] {640,649}, "FI"); - add(new int[] {690,695}, "CN"); - add(new int[] {700,709}, "NO"); - add(new int[] {729}, "IL"); - add(new int[] {730,739}, "SE"); - add(new int[] {740}, "GT"); - add(new int[] {741}, "SV"); - add(new int[] {742}, "HN"); - add(new int[] {743}, "NI"); - add(new int[] {744}, "CR"); - add(new int[] {745}, "PA"); - add(new int[] {746}, "DO"); - add(new int[] {750}, "MX"); - add(new int[] {754,755}, "CA"); - add(new int[] {759}, "VE"); - add(new int[] {760,769}, "CH"); - add(new int[] {770}, "CO"); - add(new int[] {773}, "UY"); - add(new int[] {775}, "PE"); - add(new int[] {777}, "BO"); - add(new int[] {779}, "AR"); - add(new int[] {780}, "CL"); - add(new int[] {784}, "PY"); - add(new int[] {785}, "PE"); - add(new int[] {786}, "EC"); - add(new int[] {789,790}, "BR"); - add(new int[] {800,839}, "IT"); - add(new int[] {840,849}, "ES"); - add(new int[] {850}, "CU"); - add(new int[] {858}, "SK"); - add(new int[] {859}, "CZ"); - add(new int[] {860}, "YU"); - add(new int[] {865}, "MN"); - add(new int[] {867}, "KP"); - add(new int[] {868,869}, "TR"); - add(new int[] {870,879}, "NL"); - add(new int[] {880}, "KR"); - add(new int[] {885}, "TH"); - add(new int[] {888}, "SG"); - add(new int[] {890}, "IN"); - add(new int[] {893}, "VN"); - add(new int[] {896}, "PK"); - add(new int[] {899}, "ID"); - add(new int[] {900,919}, "AT"); - add(new int[] {930,939}, "AU"); - add(new int[] {940,949}, "AZ"); - add(new int[] {955}, "MY"); - add(new int[] {958}, "MO"); - } - -} diff --git a/port_src/core/DONE/oned/ITFReader.java b/port_src/core/DONE/oned/ITFReader.java deleted file mode 100644 index a4e6ec3..0000000 --- a/port_src/core/DONE/oned/ITFReader.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitArray; - -import java.util.Map; - -/** - *

Implements decoding of the ITF format, or Interleaved Two of Five.

- * - *

This Reader will scan ITF barcodes of certain lengths only. - * At the moment it reads length 6, 8, 10, 12, 14, 16, 18, 20, 24, and 44 as these have appeared "in the wild". Not all - * lengths are scanned, especially shorter ones, to avoid false positives. This in turn is due to a lack of - * required checksum function.

- * - *

The checksum is optional and is not applied by this Reader. The consumer of the decoded - * value will have to apply a checksum if required.

- * - *

http://en.wikipedia.org/wiki/Interleaved_2_of_5 - * is a great reference for Interleaved 2 of 5 information.

- * - * @author kevin.osullivan@sita.aero, SITA Lab. - */ -public final class ITFReader extends OneDReader { - - private static final float MAX_AVG_VARIANCE = 0.38f; - private static final float MAX_INDIVIDUAL_VARIANCE = 0.5f; - - private static final int W = 3; // Pixel width of a 3x wide line - private static final int w = 2; // Pixel width of a 2x wide line - private static final int N = 1; // Pixed width of a narrow line - - /** Valid ITF lengths. Anything longer than the largest value is also allowed. */ - private static final int[] DEFAULT_ALLOWED_LENGTHS = {6, 8, 10, 12, 14}; - - // Stores the actual narrow line width of the image being decoded. - private int narrowLineWidth = -1; - - /** - * Start/end guard pattern. - * - * Note: The end pattern is reversed because the row is reversed before - * searching for the END_PATTERN - */ - private static final int[] START_PATTERN = {N, N, N, N}; - private static final int[][] END_PATTERN_REVERSED = { - {N, N, w}, // 2x - {N, N, W} // 3x - }; - - // See ITFWriter.PATTERNS - - /** - * Patterns of Wide / Narrow lines to indicate each digit - */ - private static final int[][] PATTERNS = { - {N, N, w, w, N}, // 0 - {w, N, N, N, w}, // 1 - {N, w, N, N, w}, // 2 - {w, w, N, N, N}, // 3 - {N, N, w, N, w}, // 4 - {w, N, w, N, N}, // 5 - {N, w, w, N, N}, // 6 - {N, N, N, w, w}, // 7 - {w, N, N, w, N}, // 8 - {N, w, N, w, N}, // 9 - {N, N, W, W, N}, // 0 - {W, N, N, N, W}, // 1 - {N, W, N, N, W}, // 2 - {W, W, N, N, N}, // 3 - {N, N, W, N, W}, // 4 - {W, N, W, N, N}, // 5 - {N, W, W, N, N}, // 6 - {N, N, N, W, W}, // 7 - {W, N, N, W, N}, // 8 - {N, W, N, W, N} // 9 - }; - - @Override - public Result decodeRow(int rowNumber, BitArray row, Map hints) - throws FormatException, NotFoundException { - - // Find out where the Middle section (payload) starts & ends - int[] startRange = decodeStart(row); - int[] endRange = decodeEnd(row); - - StringBuilder result = new StringBuilder(20); - decodeMiddle(row, startRange[1], endRange[0], result); - String resultString = result.toString(); - - int[] allowedLengths = null; - if (hints != null) { - allowedLengths = (int[]) hints.get(DecodeHintType.ALLOWED_LENGTHS); - - } - if (allowedLengths == null) { - allowedLengths = DEFAULT_ALLOWED_LENGTHS; - } - - // To avoid false positives with 2D barcodes (and other patterns), make - // an assumption that the decoded string must be a 'standard' length if it's short - int length = resultString.length(); - boolean lengthOK = false; - int maxAllowedLength = 0; - for (int allowedLength : allowedLengths) { - if (length == allowedLength) { - lengthOK = true; - break; - } - if (allowedLength > maxAllowedLength) { - maxAllowedLength = allowedLength; - } - } - if (!lengthOK && length > maxAllowedLength) { - lengthOK = true; - } - if (!lengthOK) { - throw FormatException.getFormatInstance(); - } - - Result resultObject = new Result( - resultString, - null, // no natural byte representation for these barcodes - new ResultPoint[] {new ResultPoint(startRange[1], rowNumber), - new ResultPoint(endRange[0], rowNumber)}, - BarcodeFormat.ITF); - resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]I0"); - return resultObject; - } - - /** - * @param row row of black/white values to search - * @param payloadStart offset of start pattern - * @param resultString {@link StringBuilder} to append decoded chars to - * @throws NotFoundException if decoding could not complete successfully - */ - private static void decodeMiddle(BitArray row, - int payloadStart, - int payloadEnd, - StringBuilder resultString) throws NotFoundException { - - // Digits are interleaved in pairs - 5 black lines for one digit, and the - // 5 - // interleaved white lines for the second digit. - // Therefore, need to scan 10 lines and then - // split these into two arrays - int[] counterDigitPair = new int[10]; - int[] counterBlack = new int[5]; - int[] counterWhite = new int[5]; - - while (payloadStart < payloadEnd) { - - // Get 10 runs of black/white. - recordPattern(row, payloadStart, counterDigitPair); - // Split them into each array - for (int k = 0; k < 5; k++) { - int twoK = 2 * k; - counterBlack[k] = counterDigitPair[twoK]; - counterWhite[k] = counterDigitPair[twoK + 1]; - } - - int bestMatch = decodeDigit(counterBlack); - resultString.append((char) ('0' + bestMatch)); - bestMatch = decodeDigit(counterWhite); - resultString.append((char) ('0' + bestMatch)); - - for (int counterDigit : counterDigitPair) { - payloadStart += counterDigit; - } - } - } - - /** - * Identify where the start of the middle / payload section starts. - * - * @param row row of black/white values to search - * @return Array, containing index of start of 'start block' and end of - * 'start block' - */ - private int[] decodeStart(BitArray row) throws NotFoundException { - int endStart = skipWhiteSpace(row); - int[] startPattern = findGuardPattern(row, endStart, START_PATTERN); - - // Determine the width of a narrow line in pixels. We can do this by - // getting the width of the start pattern and dividing by 4 because its - // made up of 4 narrow lines. - this.narrowLineWidth = (startPattern[1] - startPattern[0]) / 4; - - validateQuietZone(row, startPattern[0]); - - return startPattern; - } - - /** - * The start & end patterns must be pre/post fixed by a quiet zone. This - * zone must be at least 10 times the width of a narrow line. Scan back until - * we either get to the start of the barcode or match the necessary number of - * quiet zone pixels. - * - * Note: Its assumed the row is reversed when using this method to find - * quiet zone after the end pattern. - * - * ref: http://www.barcode-1.net/i25code.html - * - * @param row bit array representing the scanned barcode. - * @param startPattern index into row of the start or end pattern. - * @throws NotFoundException if the quiet zone cannot be found - */ - private void validateQuietZone(BitArray row, int startPattern) throws NotFoundException { - - int quietCount = this.narrowLineWidth * 10; // expect to find this many pixels of quiet zone - - // if there are not so many pixel at all let's try as many as possible - quietCount = Math.min(quietCount, startPattern); - - for (int i = startPattern - 1; quietCount > 0 && i >= 0; i--) { - if (row.get(i)) { - break; - } - quietCount--; - } - if (quietCount != 0) { - // Unable to find the necessary number of quiet zone pixels. - throw NotFoundException.getNotFoundInstance(); - } - } - - /** - * Skip all whitespace until we get to the first black line. - * - * @param row row of black/white values to search - * @return index of the first black line. - * @throws NotFoundException Throws exception if no black lines are found in the row - */ - private static int skipWhiteSpace(BitArray row) throws NotFoundException { - int width = row.getSize(); - int endStart = row.getNextSet(0); - if (endStart == width) { - throw NotFoundException.getNotFoundInstance(); - } - - return endStart; - } - - /** - * Identify where the end of the middle / payload section ends. - * - * @param row row of black/white values to search - * @return Array, containing index of start of 'end block' and end of 'end - * block' - */ - private int[] decodeEnd(BitArray row) throws NotFoundException { - - // For convenience, reverse the row and then - // search from 'the start' for the end block - row.reverse(); - try { - int endStart = skipWhiteSpace(row); - int[] endPattern; - try { - endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED[0]); - } catch (NotFoundException nfe) { - endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED[1]); - } - - // The start & end patterns must be pre/post fixed by a quiet zone. This - // zone must be at least 10 times the width of a narrow line. - // ref: http://www.barcode-1.net/i25code.html - validateQuietZone(row, endPattern[0]); - - // Now recalculate the indices of where the 'endblock' starts & stops to - // accommodate - // the reversed nature of the search - int temp = endPattern[0]; - endPattern[0] = row.getSize() - endPattern[1]; - endPattern[1] = row.getSize() - temp; - - return endPattern; - } finally { - // Put the row back the right way. - row.reverse(); - } - } - - /** - * @param row row of black/white values to search - * @param rowOffset position to start search - * @param pattern pattern of counts of number of black and white pixels that are - * being searched for as a pattern - * @return start/end horizontal offset of guard pattern, as an array of two - * ints - * @throws NotFoundException if pattern is not found - */ - private static int[] findGuardPattern(BitArray row, - int rowOffset, - int[] pattern) throws NotFoundException { - int patternLength = pattern.length; - int[] counters = new int[patternLength]; - int width = row.getSize(); - boolean isWhite = false; - - int counterPosition = 0; - int patternStart = rowOffset; - for (int x = rowOffset; x < width; x++) { - if (row.get(x) != isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == patternLength - 1) { - if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) { - return new int[]{patternStart, x}; - } - patternStart += counters[0] + counters[1]; - System.arraycopy(counters, 2, counters, 0, counterPosition - 1); - counters[counterPosition - 1] = 0; - counters[counterPosition] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - throw NotFoundException.getNotFoundInstance(); - } - - /** - * Attempts to decode a sequence of ITF black/white lines into single - * digit. - * - * @param counters the counts of runs of observed black/white/black/... values - * @return The decoded digit - * @throws NotFoundException if digit cannot be decoded - */ - private static int decodeDigit(int[] counters) throws NotFoundException { - float bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept - int bestMatch = -1; - int max = PATTERNS.length; - for (int i = 0; i < max; i++) { - int[] pattern = PATTERNS[i]; - float variance = patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE); - if (variance < bestVariance) { - bestVariance = variance; - bestMatch = i; - } else if (variance == bestVariance) { - // if we find a second 'best match' with the same variance, we can not reliably report to have a suitable match - bestMatch = -1; - } - } - if (bestMatch >= 0) { - return bestMatch % 10; - } else { - throw NotFoundException.getNotFoundInstance(); - } - } - -} diff --git a/port_src/core/DONE/oned/ITFWriter.java b/port_src/core/DONE/oned/ITFWriter.java deleted file mode 100644 index e787faa..0000000 --- a/port_src/core/DONE/oned/ITFWriter.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.BitMatrix; - -import java.util.Collection; -import java.util.Collections; - -/** - * This object renders a ITF code as a {@link BitMatrix}. - * - * @author erik.barbara@gmail.com (Erik Barbara) - */ -public final class ITFWriter extends OneDimensionalCodeWriter { - - private static final int[] START_PATTERN = {1, 1, 1, 1}; - private static final int[] END_PATTERN = {3, 1, 1}; - - private static final int W = 3; // Pixel width of a 3x wide line - private static final int N = 1; // Pixed width of a narrow line - - // See ITFReader.PATTERNS - - private static final int[][] PATTERNS = { - {N, N, W, W, N}, // 0 - {W, N, N, N, W}, // 1 - {N, W, N, N, W}, // 2 - {W, W, N, N, N}, // 3 - {N, N, W, N, W}, // 4 - {W, N, W, N, N}, // 5 - {N, W, W, N, N}, // 6 - {N, N, N, W, W}, // 7 - {W, N, N, W, N}, // 8 - {N, W, N, W, N} // 9 - }; - - @Override - protected Collection getSupportedWriteFormats() { - return Collections.singleton(BarcodeFormat.ITF); - } - - @Override - public boolean[] encode(String contents) { - int length = contents.length(); - if (length % 2 != 0) { - throw new IllegalArgumentException("The length of the input should be even"); - } - if (length > 80) { - throw new IllegalArgumentException( - "Requested contents should be less than 80 digits long, but got " + length); - } - - checkNumeric(contents); - - boolean[] result = new boolean[9 + 9 * length]; - int pos = appendPattern(result, 0, START_PATTERN, true); - for (int i = 0; i < length; i += 2) { - int one = Character.digit(contents.charAt(i), 10); - int two = Character.digit(contents.charAt(i + 1), 10); - int[] encoding = new int[10]; - for (int j = 0; j < 5; j++) { - encoding[2 * j] = PATTERNS[one][j]; - encoding[2 * j + 1] = PATTERNS[two][j]; - } - pos += appendPattern(result, pos, encoding, true); - } - appendPattern(result, pos, END_PATTERN, true); - - return result; - } - -} diff --git a/port_src/core/DONE/oned/MultiFormatOneDReader.java b/port_src/core/DONE/oned/MultiFormatOneDReader.java deleted file mode 100644 index 1dd3394..0000000 --- a/port_src/core/DONE/oned/MultiFormatOneDReader.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.Reader; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.common.BitArray; -import com.google.zxing.oned.rss.RSS14Reader; -import com.google.zxing.oned.rss.expanded.RSSExpandedReader; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -/** - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - */ -public final class MultiFormatOneDReader extends OneDReader { - - private static final OneDReader[] EMPTY_ONED_ARRAY = new OneDReader[0]; - - private final OneDReader[] readers; - - public MultiFormatOneDReader(Map hints) { - @SuppressWarnings("unchecked") - Collection possibleFormats = hints == null ? null : - (Collection) hints.get(DecodeHintType.POSSIBLE_FORMATS); - boolean useCode39CheckDigit = hints != null && - hints.get(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) != null; - Collection readers = new ArrayList<>(); - if (possibleFormats != null) { - if (possibleFormats.contains(BarcodeFormat.EAN_13) || - possibleFormats.contains(BarcodeFormat.UPC_A) || - possibleFormats.contains(BarcodeFormat.EAN_8) || - possibleFormats.contains(BarcodeFormat.UPC_E)) { - readers.add(new MultiFormatUPCEANReader(hints)); - } - if (possibleFormats.contains(BarcodeFormat.CODE_39)) { - readers.add(new Code39Reader(useCode39CheckDigit)); - } - if (possibleFormats.contains(BarcodeFormat.CODE_93)) { - readers.add(new Code93Reader()); - } - if (possibleFormats.contains(BarcodeFormat.CODE_128)) { - readers.add(new Code128Reader()); - } - if (possibleFormats.contains(BarcodeFormat.ITF)) { - readers.add(new ITFReader()); - } - if (possibleFormats.contains(BarcodeFormat.CODABAR)) { - readers.add(new CodaBarReader()); - } - if (possibleFormats.contains(BarcodeFormat.RSS_14)) { - readers.add(new RSS14Reader()); - } - if (possibleFormats.contains(BarcodeFormat.RSS_EXPANDED)) { - readers.add(new RSSExpandedReader()); - } - } - if (readers.isEmpty()) { - readers.add(new MultiFormatUPCEANReader(hints)); - readers.add(new Code39Reader()); - readers.add(new CodaBarReader()); - readers.add(new Code93Reader()); - readers.add(new Code128Reader()); - readers.add(new ITFReader()); - readers.add(new RSS14Reader()); - readers.add(new RSSExpandedReader()); - } - this.readers = readers.toArray(EMPTY_ONED_ARRAY); - } - - @Override - public Result decodeRow(int rowNumber, - BitArray row, - Map hints) throws NotFoundException { - for (OneDReader reader : readers) { - try { - return reader.decodeRow(rowNumber, row, hints); - } catch (ReaderException re) { - // continue - } - } - - throw NotFoundException.getNotFoundInstance(); - } - - @Override - public void reset() { - for (Reader reader : readers) { - reader.reset(); - } - } - -} diff --git a/port_src/core/DONE/oned/MultiFormatUPCEANReader.java b/port_src/core/DONE/oned/MultiFormatUPCEANReader.java deleted file mode 100644 index bb82603..0000000 --- a/port_src/core/DONE/oned/MultiFormatUPCEANReader.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.Reader; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.common.BitArray; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -/** - *

A reader that can read all available UPC/EAN formats. If a caller wants to try to - * read all such formats, it is most efficient to use this implementation rather than invoke - * individual readers.

- * - * @author Sean Owen - */ -public final class MultiFormatUPCEANReader extends OneDReader { - - private static final UPCEANReader[] EMPTY_READER_ARRAY = new UPCEANReader[0]; - - private final UPCEANReader[] readers; - - public MultiFormatUPCEANReader(Map hints) { - @SuppressWarnings("unchecked") - Collection possibleFormats = hints == null ? null : - (Collection) hints.get(DecodeHintType.POSSIBLE_FORMATS); - Collection readers = new ArrayList<>(); - if (possibleFormats != null) { - if (possibleFormats.contains(BarcodeFormat.EAN_13)) { - readers.add(new EAN13Reader()); - } else if (possibleFormats.contains(BarcodeFormat.UPC_A)) { - readers.add(new UPCAReader()); - } - if (possibleFormats.contains(BarcodeFormat.EAN_8)) { - readers.add(new EAN8Reader()); - } - if (possibleFormats.contains(BarcodeFormat.UPC_E)) { - readers.add(new UPCEReader()); - } - } - if (readers.isEmpty()) { - readers.add(new EAN13Reader()); - // UPC-A is covered by EAN-13 - readers.add(new EAN8Reader()); - readers.add(new UPCEReader()); - } - this.readers = readers.toArray(EMPTY_READER_ARRAY); - } - - @Override - public Result decodeRow(int rowNumber, - BitArray row, - Map hints) throws NotFoundException { - // Compute this location once and reuse it on multiple implementations - int[] startGuardPattern = UPCEANReader.findStartGuardPattern(row); - for (UPCEANReader reader : readers) { - try { - Result result = reader.decodeRow(rowNumber, row, startGuardPattern, hints); - // Special case: a 12-digit code encoded in UPC-A is identical to a "0" - // followed by those 12 digits encoded as EAN-13. Each will recognize such a code, - // UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0". - // Individually these are correct and their readers will both read such a code - // and correctly call it EAN-13, or UPC-A, respectively. - // - // In this case, if we've been looking for both types, we'd like to call it - // a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read - // UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A - // result if appropriate. - // - // But, don't return UPC-A if UPC-A was not a requested format! - boolean ean13MayBeUPCA = - result.getBarcodeFormat() == BarcodeFormat.EAN_13 && - result.getText().charAt(0) == '0'; - @SuppressWarnings("unchecked") - Collection possibleFormats = - hints == null ? null : (Collection) hints.get(DecodeHintType.POSSIBLE_FORMATS); - boolean canReturnUPCA = possibleFormats == null || possibleFormats.contains(BarcodeFormat.UPC_A); - - if (ean13MayBeUPCA && canReturnUPCA) { - // Transfer the metadata across - Result resultUPCA = new Result(result.getText().substring(1), - result.getRawBytes(), - result.getResultPoints(), - BarcodeFormat.UPC_A); - resultUPCA.putAllMetadata(result.getResultMetadata()); - return resultUPCA; - } - return result; - } catch (ReaderException ignored) { - // continue - } - } - - throw NotFoundException.getNotFoundInstance(); - } - - @Override - public void reset() { - for (Reader reader : readers) { - reader.reset(); - } - } - -} diff --git a/port_src/core/DONE/oned/OneDReader.java b/port_src/core/DONE/oned/OneDReader.java deleted file mode 100644 index 7941e6f..0000000 --- a/port_src/core/DONE/oned/OneDReader.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BinaryBitmap; -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Reader; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitArray; - -import java.util.Arrays; -import java.util.EnumMap; -import java.util.Map; - -/** - * Encapsulates functionality and implementation that is common to all families - * of one-dimensional barcodes. - * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - */ -public abstract class OneDReader implements Reader { - - @Override - public Result decode(BinaryBitmap image) throws NotFoundException, FormatException { - return decode(image, null); - } - - // Note that we don't try rotation without the try harder flag, even if rotation was supported. - @Override - public Result decode(BinaryBitmap image, - Map hints) throws NotFoundException, FormatException { - try { - return doDecode(image, hints); - } catch (NotFoundException nfe) { - boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); - if (tryHarder && image.isRotateSupported()) { - BinaryBitmap rotatedImage = image.rotateCounterClockwise(); - Result result = doDecode(rotatedImage, hints); - // Record that we found it rotated 90 degrees CCW / 270 degrees CW - Map metadata = result.getResultMetadata(); - int orientation = 270; - if (metadata != null && metadata.containsKey(ResultMetadataType.ORIENTATION)) { - // But if we found it reversed in doDecode(), add in that result here: - orientation = (orientation + - (Integer) metadata.get(ResultMetadataType.ORIENTATION)) % 360; - } - result.putMetadata(ResultMetadataType.ORIENTATION, orientation); - // Update result points - ResultPoint[] points = result.getResultPoints(); - if (points != null) { - int height = rotatedImage.getHeight(); - for (int i = 0; i < points.length; i++) { - points[i] = new ResultPoint(height - points[i].getY() - 1, points[i].getX()); - } - } - return result; - } else { - throw nfe; - } - } - } - - @Override - public void reset() { - // do nothing - } - - /** - * We're going to examine rows from the middle outward, searching alternately above and below the - * middle, and farther out each time. rowStep is the number of rows between each successive - * attempt above and below the middle. So we'd scan row middle, then middle - rowStep, then - * middle + rowStep, then middle - (2 * rowStep), etc. - * rowStep is bigger as the image is taller, but is always at least 1. We've somewhat arbitrarily - * decided that moving up and down by about 1/16 of the image is pretty good; we try more of the - * image if "trying harder". - * - * @param image The image to decode - * @param hints Any hints that were requested - * @return The contents of the decoded barcode - * @throws NotFoundException Any spontaneous errors which occur - */ - private Result doDecode(BinaryBitmap image, - Map hints) throws NotFoundException { - int width = image.getWidth(); - int height = image.getHeight(); - BitArray row = new BitArray(width); - - boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); - int rowStep = Math.max(1, height >> (tryHarder ? 8 : 5)); - int maxLines; - if (tryHarder) { - maxLines = height; // Look at the whole image, not just the center - } else { - maxLines = 15; // 15 rows spaced 1/32 apart is roughly the middle half of the image - } - - int middle = height / 2; - for (int x = 0; x < maxLines; x++) { - - // Scanning from the middle out. Determine which row we're looking at next: - int rowStepsAboveOrBelow = (x + 1) / 2; - boolean isAbove = (x & 0x01) == 0; // i.e. is x even? - int rowNumber = middle + rowStep * (isAbove ? rowStepsAboveOrBelow : -rowStepsAboveOrBelow); - if (rowNumber < 0 || rowNumber >= height) { - // Oops, if we run off the top or bottom, stop - break; - } - - // Estimate black point for this row and load it: - try { - row = image.getBlackRow(rowNumber, row); - } catch (NotFoundException ignored) { - continue; - } - - // While we have the image data in a BitArray, it's fairly cheap to reverse it in place to - // handle decoding upside down barcodes. - for (int attempt = 0; attempt < 2; attempt++) { - if (attempt == 1) { // trying again? - row.reverse(); // reverse the row and continue - // This means we will only ever draw result points *once* in the life of this method - // since we want to avoid drawing the wrong points after flipping the row, and, - // don't want to clutter with noise from every single row scan -- just the scans - // that start on the center line. - if (hints != null && hints.containsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK)) { - Map newHints = new EnumMap<>(DecodeHintType.class); - newHints.putAll(hints); - newHints.remove(DecodeHintType.NEED_RESULT_POINT_CALLBACK); - hints = newHints; - } - } - try { - // Look for a barcode - Result result = decodeRow(rowNumber, row, hints); - // We found our barcode - if (attempt == 1) { - // But it was upside down, so note that - result.putMetadata(ResultMetadataType.ORIENTATION, 180); - // And remember to flip the result points horizontally. - ResultPoint[] points = result.getResultPoints(); - if (points != null) { - points[0] = new ResultPoint(width - points[0].getX() - 1, points[0].getY()); - points[1] = new ResultPoint(width - points[1].getX() - 1, points[1].getY()); - } - } - return result; - } catch (ReaderException re) { - // continue -- just couldn't decode this row - } - } - } - - throw NotFoundException.getNotFoundInstance(); - } - - /** - * Records the size of successive runs of white and black pixels in a row, starting at a given point. - * The values are recorded in the given array, and the number of runs recorded is equal to the size - * of the array. If the row starts on a white pixel at the given start point, then the first count - * recorded is the run of white pixels starting from that point; likewise it is the count of a run - * of black pixels if the row begin on a black pixels at that point. - * - * @param row row to count from - * @param start offset into row to start at - * @param counters array into which to record counts - * @throws NotFoundException if counters cannot be filled entirely from row before running out - * of pixels - */ - protected static void recordPattern(BitArray row, - int start, - int[] counters) throws NotFoundException { - int numCounters = counters.length; - Arrays.fill(counters, 0, numCounters, 0); - int end = row.getSize(); - if (start >= end) { - throw NotFoundException.getNotFoundInstance(); - } - boolean isWhite = !row.get(start); - int counterPosition = 0; - int i = start; - while (i < end) { - if (row.get(i) != isWhite) { - counters[counterPosition]++; - } else { - if (++counterPosition == numCounters) { - break; - } else { - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - i++; - } - // If we read fully the last section of pixels and filled up our counters -- or filled - // the last counter but ran off the side of the image, OK. Otherwise, a problem. - if (!(counterPosition == numCounters || (counterPosition == numCounters - 1 && i == end))) { - throw NotFoundException.getNotFoundInstance(); - } - } - - protected static void recordPatternInReverse(BitArray row, int start, int[] counters) - throws NotFoundException { - // This could be more efficient I guess - int numTransitionsLeft = counters.length; - boolean last = row.get(start); - while (start > 0 && numTransitionsLeft >= 0) { - if (row.get(--start) != last) { - numTransitionsLeft--; - last = !last; - } - } - if (numTransitionsLeft >= 0) { - throw NotFoundException.getNotFoundInstance(); - } - recordPattern(row, start + 1, counters); - } - - /** - * Determines how closely a set of observed counts of runs of black/white values matches a given - * target pattern. This is reported as the ratio of the total variance from the expected pattern - * proportions across all pattern elements, to the length of the pattern. - * - * @param counters observed counters - * @param pattern expected pattern - * @param maxIndividualVariance The most any counter can differ before we give up - * @return ratio of total variance between counters and pattern compared to total pattern size - */ - protected static float patternMatchVariance(int[] counters, - int[] pattern, - float maxIndividualVariance) { - int numCounters = counters.length; - int total = 0; - int patternLength = 0; - for (int i = 0; i < numCounters; i++) { - total += counters[i]; - patternLength += pattern[i]; - } - if (total < patternLength) { - // If we don't even have one pixel per unit of bar width, assume this is too small - // to reliably match, so fail: - return Float.POSITIVE_INFINITY; - } - - float unitBarWidth = (float) total / patternLength; - maxIndividualVariance *= unitBarWidth; - - float totalVariance = 0.0f; - for (int x = 0; x < numCounters; x++) { - int counter = counters[x]; - float scaledPattern = pattern[x] * unitBarWidth; - float variance = counter > scaledPattern ? counter - scaledPattern : scaledPattern - counter; - if (variance > maxIndividualVariance) { - return Float.POSITIVE_INFINITY; - } - totalVariance += variance; - } - return totalVariance / total; - } - - /** - *

Attempts to decode a one-dimensional barcode format given a single row of - * an image.

- * - * @param rowNumber row number from top of the row - * @param row the black/white pixel data of the row - * @param hints decode hints - * @return {@link Result} containing encoded string and start/end of barcode - * @throws NotFoundException if no potential barcode is found - * @throws ChecksumException if a potential barcode is found but does not pass its checksum - * @throws FormatException if a potential barcode is found but format is invalid - */ - public abstract Result decodeRow(int rowNumber, BitArray row, Map hints) - throws NotFoundException, ChecksumException, FormatException; - -} diff --git a/port_src/core/DONE/oned/OneDimensionalCodeWriter.java b/port_src/core/DONE/oned/OneDimensionalCodeWriter.java deleted file mode 100644 index d277d2e..0000000 --- a/port_src/core/DONE/oned/OneDimensionalCodeWriter.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.Writer; -import com.google.zxing.common.BitMatrix; - -import java.util.Collection; -import java.util.Map; -import java.util.regex.Pattern; - -/** - *

Encapsulates functionality and implementation that is common to one-dimensional barcodes.

- * - * @author dsbnatut@gmail.com (Kazuki Nishiura) - */ -public abstract class OneDimensionalCodeWriter implements Writer { - private static final Pattern NUMERIC = Pattern.compile("[0-9]+"); - - /** - * Encode the contents to boolean array expression of one-dimensional barcode. - * Start code and end code should be included in result, and side margins should not be included. - * - * @param contents barcode contents to encode - * @return a {@code boolean[]} of horizontal pixels (false = white, true = black) - */ - public abstract boolean[] encode(String contents); - - /** - * Can be overwritten if the encode requires to read the hints map. Otherwise it defaults to {@code encode}. - * @param contents barcode contents to encode - * @param hints encoding hints - * @return a {@code boolean[]} of horizontal pixels (false = white, true = black) - */ - protected boolean[] encode(String contents, Map hints) { - return encode(contents); - } - - @Override - public final BitMatrix encode(String contents, BarcodeFormat format, int width, int height) { - return encode(contents, format, width, height, null); - } - - /** - * Encode the contents following specified format. - * {@code width} and {@code height} are required size. This method may return bigger size - * {@code BitMatrix} when specified size is too small. The user can set both {@code width} and - * {@code height} to zero to get minimum size barcode. If negative value is set to {@code width} - * or {@code height}, {@code IllegalArgumentException} is thrown. - */ - @Override - public BitMatrix encode(String contents, - BarcodeFormat format, - int width, - int height, - Map hints) { - if (contents.isEmpty()) { - throw new IllegalArgumentException("Found empty contents"); - } - - if (width < 0 || height < 0) { - throw new IllegalArgumentException("Negative size is not allowed. Input: " - + width + 'x' + height); - } - Collection supportedFormats = getSupportedWriteFormats(); - if (supportedFormats != null && !supportedFormats.contains(format)) { - throw new IllegalArgumentException("Can only encode " + supportedFormats + - ", but got " + format); - } - - int sidesMargin = getDefaultMargin(); - if (hints != null && hints.containsKey(EncodeHintType.MARGIN)) { - sidesMargin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString()); - } - - boolean[] code = encode(contents, hints); - return renderResult(code, width, height, sidesMargin); - } - - protected Collection getSupportedWriteFormats() { - return null; - } - - /** - * @return a byte array of horizontal pixels (0 = white, 1 = black) - */ - private static BitMatrix renderResult(boolean[] code, int width, int height, int sidesMargin) { - int inputWidth = code.length; - // Add quiet zone on both sides. - int fullWidth = inputWidth + sidesMargin; - int outputWidth = Math.max(width, fullWidth); - int outputHeight = Math.max(1, height); - - int multiple = outputWidth / fullWidth; - int leftPadding = (outputWidth - (inputWidth * multiple)) / 2; - - BitMatrix output = new BitMatrix(outputWidth, outputHeight); - for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) { - if (code[inputX]) { - output.setRegion(outputX, 0, multiple, outputHeight); - } - } - return output; - } - - /** - * @param contents string to check for numeric characters - * @throws IllegalArgumentException if input contains characters other than digits 0-9. - */ - protected static void checkNumeric(String contents) { - if (!NUMERIC.matcher(contents).matches()) { - throw new IllegalArgumentException("Input should only contain digits 0-9"); - } - } - - /** - * @param target encode black/white pattern into this array - * @param pos position to start encoding at in {@code target} - * @param pattern lengths of black/white runs to encode - * @param startColor starting color - false for white, true for black - * @return the number of elements added to target. - */ - protected static int appendPattern(boolean[] target, int pos, int[] pattern, boolean startColor) { - boolean color = startColor; - int numAdded = 0; - for (int len : pattern) { - for (int j = 0; j < len; j++) { - target[pos++] = color; - } - numAdded += len; - color = !color; // flip color after each segment - } - return numAdded; - } - - public int getDefaultMargin() { - // CodaBar spec requires a side margin to be more than ten times wider than narrow space. - // This seems like a decent idea for a default for all formats. - return 10; - } -} - diff --git a/port_src/core/DONE/oned/UPCAReader.java b/port_src/core/DONE/oned/UPCAReader.java deleted file mode 100644 index c66a76c..0000000 --- a/port_src/core/DONE/oned/UPCAReader.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.common.BitArray; - -import java.util.Map; - -/** - *

Implements decoding of the UPC-A format.

- * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - */ -public final class UPCAReader extends UPCEANReader { - - private final UPCEANReader ean13Reader = new EAN13Reader(); - - @Override - public Result decodeRow(int rowNumber, - BitArray row, - int[] startGuardRange, - Map hints) - throws NotFoundException, FormatException, ChecksumException { - return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, startGuardRange, hints)); - } - - @Override - public Result decodeRow(int rowNumber, BitArray row, Map hints) - throws NotFoundException, FormatException, ChecksumException { - return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, hints)); - } - - @Override - public Result decode(BinaryBitmap image) throws NotFoundException, FormatException { - return maybeReturnResult(ean13Reader.decode(image)); - } - - @Override - public Result decode(BinaryBitmap image, Map hints) - throws NotFoundException, FormatException { - return maybeReturnResult(ean13Reader.decode(image, hints)); - } - - @Override - BarcodeFormat getBarcodeFormat() { - return BarcodeFormat.UPC_A; - } - - @Override - protected int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString) - throws NotFoundException { - return ean13Reader.decodeMiddle(row, startRange, resultString); - } - - private static Result maybeReturnResult(Result result) throws FormatException { - String text = result.getText(); - if (text.charAt(0) == '0') { - Result upcaResult = new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A); - if (result.getResultMetadata() != null) { - upcaResult.putAllMetadata(result.getResultMetadata()); - } - return upcaResult; - } else { - throw FormatException.getFormatInstance(); - } - } - -} diff --git a/port_src/core/DONE/oned/UPCAWriter.java b/port_src/core/DONE/oned/UPCAWriter.java deleted file mode 100644 index c2aa7af..0000000 --- a/port_src/core/DONE/oned/UPCAWriter.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.Writer; -import com.google.zxing.common.BitMatrix; - -import java.util.Map; - -/** - * This object renders a UPC-A code as a {@link BitMatrix}. - * - * @author qwandor@google.com (Andrew Walbran) - */ -public final class UPCAWriter implements Writer { - - private final EAN13Writer subWriter = new EAN13Writer(); - - @Override - public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) { - return encode(contents, format, width, height, null); - } - - @Override - public BitMatrix encode(String contents, - BarcodeFormat format, - int width, - int height, - Map hints) { - if (format != BarcodeFormat.UPC_A) { - throw new IllegalArgumentException("Can only encode UPC-A, but got " + format); - } - // Transform a UPC-A code into the equivalent EAN-13 code and write it that way - return subWriter.encode('0' + contents, BarcodeFormat.EAN_13, width, height, hints); - } - -} diff --git a/port_src/core/DONE/oned/UPCEANExtension2Support.java b/port_src/core/DONE/oned/UPCEANExtension2Support.java deleted file mode 100644 index 8a1c627..0000000 --- a/port_src/core/DONE/oned/UPCEANExtension2Support.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitArray; - -import java.util.EnumMap; -import java.util.Map; - -/** - * @see UPCEANExtension5Support - */ -final class UPCEANExtension2Support { - - private final int[] decodeMiddleCounters = new int[4]; - private final StringBuilder decodeRowStringBuffer = new StringBuilder(); - - Result decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException { - - StringBuilder result = decodeRowStringBuffer; - result.setLength(0); - int end = decodeMiddle(row, extensionStartRange, result); - - String resultString = result.toString(); - Map extensionData = parseExtensionString(resultString); - - Result extensionResult = - new Result(resultString, - null, - new ResultPoint[] { - new ResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, rowNumber), - new ResultPoint(end, rowNumber), - }, - BarcodeFormat.UPC_EAN_EXTENSION); - if (extensionData != null) { - extensionResult.putAllMetadata(extensionData); - } - return extensionResult; - } - - private int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString) throws NotFoundException { - int[] counters = decodeMiddleCounters; - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - int end = row.getSize(); - int rowOffset = startRange[1]; - - int checkParity = 0; - - for (int x = 0; x < 2 && rowOffset < end; x++) { - int bestMatch = UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_AND_G_PATTERNS); - resultString.append((char) ('0' + bestMatch % 10)); - for (int counter : counters) { - rowOffset += counter; - } - if (bestMatch >= 10) { - checkParity |= 1 << (1 - x); - } - if (x != 1) { - // Read off separator if not last - rowOffset = row.getNextSet(rowOffset); - rowOffset = row.getNextUnset(rowOffset); - } - } - - if (resultString.length() != 2) { - throw NotFoundException.getNotFoundInstance(); - } - - if (Integer.parseInt(resultString.toString()) % 4 != checkParity) { - throw NotFoundException.getNotFoundInstance(); - } - - return rowOffset; - } - - /** - * @param raw raw content of extension - * @return formatted interpretation of raw content as a {@link Map} mapping - * one {@link ResultMetadataType} to appropriate value, or {@code null} if not known - */ - private static Map parseExtensionString(String raw) { - if (raw.length() != 2) { - return null; - } - Map result = new EnumMap<>(ResultMetadataType.class); - result.put(ResultMetadataType.ISSUE_NUMBER, Integer.valueOf(raw)); - return result; - } - -} diff --git a/port_src/core/DONE/oned/UPCEANExtension5Support.java b/port_src/core/DONE/oned/UPCEANExtension5Support.java deleted file mode 100644 index cb55eeb..0000000 --- a/port_src/core/DONE/oned/UPCEANExtension5Support.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitArray; - -import java.util.EnumMap; -import java.util.Map; - -/** - * @see UPCEANExtension2Support - */ -final class UPCEANExtension5Support { - - private static final int[] CHECK_DIGIT_ENCODINGS = { - 0x18, 0x14, 0x12, 0x11, 0x0C, 0x06, 0x03, 0x0A, 0x09, 0x05 - }; - - private final int[] decodeMiddleCounters = new int[4]; - private final StringBuilder decodeRowStringBuffer = new StringBuilder(); - - Result decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException { - - StringBuilder result = decodeRowStringBuffer; - result.setLength(0); - int end = decodeMiddle(row, extensionStartRange, result); - - String resultString = result.toString(); - Map extensionData = parseExtensionString(resultString); - - Result extensionResult = - new Result(resultString, - null, - new ResultPoint[] { - new ResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, rowNumber), - new ResultPoint(end, rowNumber), - }, - BarcodeFormat.UPC_EAN_EXTENSION); - if (extensionData != null) { - extensionResult.putAllMetadata(extensionData); - } - return extensionResult; - } - - private int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString) throws NotFoundException { - int[] counters = decodeMiddleCounters; - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - int end = row.getSize(); - int rowOffset = startRange[1]; - - int lgPatternFound = 0; - - for (int x = 0; x < 5 && rowOffset < end; x++) { - int bestMatch = UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_AND_G_PATTERNS); - resultString.append((char) ('0' + bestMatch % 10)); - for (int counter : counters) { - rowOffset += counter; - } - if (bestMatch >= 10) { - lgPatternFound |= 1 << (4 - x); - } - if (x != 4) { - // Read off separator if not last - rowOffset = row.getNextSet(rowOffset); - rowOffset = row.getNextUnset(rowOffset); - } - } - - if (resultString.length() != 5) { - throw NotFoundException.getNotFoundInstance(); - } - - int checkDigit = determineCheckDigit(lgPatternFound); - if (extensionChecksum(resultString.toString()) != checkDigit) { - throw NotFoundException.getNotFoundInstance(); - } - - return rowOffset; - } - - private static int extensionChecksum(CharSequence s) { - int length = s.length(); - int sum = 0; - for (int i = length - 2; i >= 0; i -= 2) { - sum += s.charAt(i) - '0'; - } - sum *= 3; - for (int i = length - 1; i >= 0; i -= 2) { - sum += s.charAt(i) - '0'; - } - sum *= 3; - return sum % 10; - } - - private static int determineCheckDigit(int lgPatternFound) - throws NotFoundException { - for (int d = 0; d < 10; d++) { - if (lgPatternFound == CHECK_DIGIT_ENCODINGS[d]) { - return d; - } - } - throw NotFoundException.getNotFoundInstance(); - } - - /** - * @param raw raw content of extension - * @return formatted interpretation of raw content as a {@link Map} mapping - * one {@link ResultMetadataType} to appropriate value, or {@code null} if not known - */ - private static Map parseExtensionString(String raw) { - if (raw.length() != 5) { - return null; - } - Object value = parseExtension5String(raw); - if (value == null) { - return null; - } - Map result = new EnumMap<>(ResultMetadataType.class); - result.put(ResultMetadataType.SUGGESTED_PRICE, value); - return result; - } - - private static String parseExtension5String(String raw) { - String currency; - switch (raw.charAt(0)) { - case '0': - currency = "£"; - break; - case '5': - currency = "$"; - break; - case '9': - // Reference: http://www.jollytech.com - switch (raw) { - case "90000": - // No suggested retail price - return null; - case "99991": - // Complementary - return "0.00"; - case "99990": - return "Used"; - } - // Otherwise... unknown currency? - currency = ""; - break; - default: - currency = ""; - break; - } - int rawAmount = Integer.parseInt(raw.substring(1)); - String unitsString = String.valueOf(rawAmount / 100); - int hundredths = rawAmount % 100; - String hundredthsString = hundredths < 10 ? "0" + hundredths : String.valueOf(hundredths); - return currency + unitsString + '.' + hundredthsString; - } - -} diff --git a/port_src/core/DONE/oned/UPCEANExtensionSupport.java b/port_src/core/DONE/oned/UPCEANExtensionSupport.java deleted file mode 100644 index b36a581..0000000 --- a/port_src/core/DONE/oned/UPCEANExtensionSupport.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.NotFoundException; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.common.BitArray; - -final class UPCEANExtensionSupport { - - private static final int[] EXTENSION_START_PATTERN = {1,1,2}; - - private final UPCEANExtension2Support twoSupport = new UPCEANExtension2Support(); - private final UPCEANExtension5Support fiveSupport = new UPCEANExtension5Support(); - - Result decodeRow(int rowNumber, BitArray row, int rowOffset) throws NotFoundException { - int[] extensionStartRange = UPCEANReader.findGuardPattern(row, rowOffset, false, EXTENSION_START_PATTERN); - try { - return fiveSupport.decodeRow(rowNumber, row, extensionStartRange); - } catch (ReaderException ignored) { - return twoSupport.decodeRow(rowNumber, row, extensionStartRange); - } - } - -} diff --git a/port_src/core/DONE/oned/UPCEANReader.java b/port_src/core/DONE/oned/UPCEANReader.java deleted file mode 100644 index f2a00bb..0000000 --- a/port_src/core/DONE/oned/UPCEANReader.java +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.ResultPointCallback; -import com.google.zxing.common.BitArray; - -import java.util.Arrays; -import java.util.Map; - -/** - *

Encapsulates functionality and implementation that is common to UPC and EAN families - * of one-dimensional barcodes.

- * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - * @author alasdair@google.com (Alasdair Mackintosh) - */ -public abstract class UPCEANReader extends OneDReader { - - // These two values are critical for determining how permissive the decoding will be. - // We've arrived at these values through a lot of trial and error. Setting them any higher - // lets false positives creep in quickly. - private static final float MAX_AVG_VARIANCE = 0.48f; - private static final float MAX_INDIVIDUAL_VARIANCE = 0.7f; - - /** - * Start/end guard pattern. - */ - static final int[] START_END_PATTERN = {1, 1, 1,}; - - /** - * Pattern marking the middle of a UPC/EAN pattern, separating the two halves. - */ - static final int[] MIDDLE_PATTERN = {1, 1, 1, 1, 1}; - /** - * end guard pattern. - */ - static final int[] END_PATTERN = {1, 1, 1, 1, 1, 1}; - /** - * "Odd", or "L" patterns used to encode UPC/EAN digits. - */ - static final int[][] L_PATTERNS = { - {3, 2, 1, 1}, // 0 - {2, 2, 2, 1}, // 1 - {2, 1, 2, 2}, // 2 - {1, 4, 1, 1}, // 3 - {1, 1, 3, 2}, // 4 - {1, 2, 3, 1}, // 5 - {1, 1, 1, 4}, // 6 - {1, 3, 1, 2}, // 7 - {1, 2, 1, 3}, // 8 - {3, 1, 1, 2} // 9 - }; - - /** - * As above but also including the "even", or "G" patterns used to encode UPC/EAN digits. - */ - static final int[][] L_AND_G_PATTERNS; - - static { - L_AND_G_PATTERNS = new int[20][]; - System.arraycopy(L_PATTERNS, 0, L_AND_G_PATTERNS, 0, 10); - for (int i = 10; i < 20; i++) { - int[] widths = L_PATTERNS[i - 10]; - int[] reversedWidths = new int[widths.length]; - for (int j = 0; j < widths.length; j++) { - reversedWidths[j] = widths[widths.length - j - 1]; - } - L_AND_G_PATTERNS[i] = reversedWidths; - } - } - - private final StringBuilder decodeRowStringBuffer; - private final UPCEANExtensionSupport extensionReader; - private final EANManufacturerOrgSupport eanManSupport; - - protected UPCEANReader() { - decodeRowStringBuffer = new StringBuilder(20); - extensionReader = new UPCEANExtensionSupport(); - eanManSupport = new EANManufacturerOrgSupport(); - } - - static int[] findStartGuardPattern(BitArray row) throws NotFoundException { - boolean foundStart = false; - int[] startRange = null; - int nextStart = 0; - int[] counters = new int[START_END_PATTERN.length]; - while (!foundStart) { - Arrays.fill(counters, 0, START_END_PATTERN.length, 0); - startRange = findGuardPattern(row, nextStart, false, START_END_PATTERN, counters); - int start = startRange[0]; - nextStart = startRange[1]; - // Make sure there is a quiet zone at least as big as the start pattern before the barcode. - // If this check would run off the left edge of the image, do not accept this barcode, - // as it is very likely to be a false positive. - int quietStart = start - (nextStart - start); - if (quietStart >= 0) { - foundStart = row.isRange(quietStart, start, false); - } - } - return startRange; - } - - @Override - public Result decodeRow(int rowNumber, BitArray row, Map hints) - throws NotFoundException, ChecksumException, FormatException { - return decodeRow(rowNumber, row, findStartGuardPattern(row), hints); - } - - /** - *

Like {@link #decodeRow(int, BitArray, Map)}, but - * allows caller to inform method about where the UPC/EAN start pattern is - * found. This allows this to be computed once and reused across many implementations.

- * - * @param rowNumber row index into the image - * @param row encoding of the row of the barcode image - * @param startGuardRange start/end column where the opening start pattern was found - * @param hints optional hints that influence decoding - * @return {@link Result} encapsulating the result of decoding a barcode in the row - * @throws NotFoundException if no potential barcode is found - * @throws ChecksumException if a potential barcode is found but does not pass its checksum - * @throws FormatException if a potential barcode is found but format is invalid - */ - public Result decodeRow(int rowNumber, - BitArray row, - int[] startGuardRange, - Map hints) - throws NotFoundException, ChecksumException, FormatException { - - ResultPointCallback resultPointCallback = hints == null ? null : - (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); - int symbologyIdentifier = 0; - - if (resultPointCallback != null) { - resultPointCallback.foundPossibleResultPoint(new ResultPoint( - (startGuardRange[0] + startGuardRange[1]) / 2.0f, rowNumber - )); - } - - StringBuilder result = decodeRowStringBuffer; - result.setLength(0); - int endStart = decodeMiddle(row, startGuardRange, result); - - if (resultPointCallback != null) { - resultPointCallback.foundPossibleResultPoint(new ResultPoint( - endStart, rowNumber - )); - } - - int[] endRange = decodeEnd(row, endStart); - - if (resultPointCallback != null) { - resultPointCallback.foundPossibleResultPoint(new ResultPoint( - (endRange[0] + endRange[1]) / 2.0f, rowNumber - )); - } - - - // Make sure there is a quiet zone at least as big as the end pattern after the barcode. The - // spec might want more whitespace, but in practice this is the maximum we can count on. - int end = endRange[1]; - int quietEnd = end + (end - endRange[0]); - if (quietEnd >= row.getSize() || !row.isRange(end, quietEnd, false)) { - throw NotFoundException.getNotFoundInstance(); - } - - String resultString = result.toString(); - // UPC/EAN should never be less than 8 chars anyway - if (resultString.length() < 8) { - throw FormatException.getFormatInstance(); - } - if (!checkChecksum(resultString)) { - throw ChecksumException.getChecksumInstance(); - } - - float left = (startGuardRange[1] + startGuardRange[0]) / 2.0f; - float right = (endRange[1] + endRange[0]) / 2.0f; - BarcodeFormat format = getBarcodeFormat(); - Result decodeResult = new Result(resultString, - null, // no natural byte representation for these barcodes - new ResultPoint[]{ - new ResultPoint(left, rowNumber), - new ResultPoint(right, rowNumber)}, - format); - - int extensionLength = 0; - - try { - Result extensionResult = extensionReader.decodeRow(rowNumber, row, endRange[1]); - decodeResult.putMetadata(ResultMetadataType.UPC_EAN_EXTENSION, extensionResult.getText()); - decodeResult.putAllMetadata(extensionResult.getResultMetadata()); - decodeResult.addResultPoints(extensionResult.getResultPoints()); - extensionLength = extensionResult.getText().length(); - } catch (ReaderException re) { - // continue - } - - int[] allowedExtensions = - hints == null ? null : (int[]) hints.get(DecodeHintType.ALLOWED_EAN_EXTENSIONS); - if (allowedExtensions != null) { - boolean valid = false; - for (int length : allowedExtensions) { - if (extensionLength == length) { - valid = true; - break; - } - } - if (!valid) { - throw NotFoundException.getNotFoundInstance(); - } - } - - if (format == BarcodeFormat.EAN_13 || format == BarcodeFormat.UPC_A) { - String countryID = eanManSupport.lookupCountryIdentifier(resultString); - if (countryID != null) { - decodeResult.putMetadata(ResultMetadataType.POSSIBLE_COUNTRY, countryID); - } - } - if (format == BarcodeFormat.EAN_8) { - symbologyIdentifier = 4; - } - - decodeResult.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]E" + symbologyIdentifier); - - return decodeResult; - } - - /** - * @param s string of digits to check - * @return {@link #checkStandardUPCEANChecksum(CharSequence)} - * @throws FormatException if the string does not contain only digits - */ - boolean checkChecksum(String s) throws FormatException { - return checkStandardUPCEANChecksum(s); - } - - /** - * Computes the UPC/EAN checksum on a string of digits, and reports - * whether the checksum is correct or not. - * - * @param s string of digits to check - * @return true iff string of digits passes the UPC/EAN checksum algorithm - * @throws FormatException if the string does not contain only digits - */ - static boolean checkStandardUPCEANChecksum(CharSequence s) throws FormatException { - int length = s.length(); - if (length == 0) { - return false; - } - int check = Character.digit(s.charAt(length - 1), 10); - return getStandardUPCEANChecksum(s.subSequence(0, length - 1)) == check; - } - - static int getStandardUPCEANChecksum(CharSequence s) throws FormatException { - int length = s.length(); - int sum = 0; - for (int i = length - 1; i >= 0; i -= 2) { - int digit = s.charAt(i) - '0'; - if (digit < 0 || digit > 9) { - throw FormatException.getFormatInstance(); - } - sum += digit; - } - sum *= 3; - for (int i = length - 2; i >= 0; i -= 2) { - int digit = s.charAt(i) - '0'; - if (digit < 0 || digit > 9) { - throw FormatException.getFormatInstance(); - } - sum += digit; - } - return (1000 - sum) % 10; - } - - int[] decodeEnd(BitArray row, int endStart) throws NotFoundException { - return findGuardPattern(row, endStart, false, START_END_PATTERN); - } - - static int[] findGuardPattern(BitArray row, - int rowOffset, - boolean whiteFirst, - int[] pattern) throws NotFoundException { - return findGuardPattern(row, rowOffset, whiteFirst, pattern, new int[pattern.length]); - } - - /** - * @param row row of black/white values to search - * @param rowOffset position to start search - * @param whiteFirst if true, indicates that the pattern specifies white/black/white/... - * pixel counts, otherwise, it is interpreted as black/white/black/... - * @param pattern pattern of counts of number of black and white pixels that are being - * searched for as a pattern - * @param counters array of counters, as long as pattern, to re-use - * @return start/end horizontal offset of guard pattern, as an array of two ints - * @throws NotFoundException if pattern is not found - */ - private static int[] findGuardPattern(BitArray row, - int rowOffset, - boolean whiteFirst, - int[] pattern, - int[] counters) throws NotFoundException { - int width = row.getSize(); - rowOffset = whiteFirst ? row.getNextUnset(rowOffset) : row.getNextSet(rowOffset); - int counterPosition = 0; - int patternStart = rowOffset; - int patternLength = pattern.length; - boolean isWhite = whiteFirst; - for (int x = rowOffset; x < width; x++) { - if (row.get(x) != isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == patternLength - 1) { - if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) { - return new int[]{patternStart, x}; - } - patternStart += counters[0] + counters[1]; - System.arraycopy(counters, 2, counters, 0, counterPosition - 1); - counters[counterPosition - 1] = 0; - counters[counterPosition] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - throw NotFoundException.getNotFoundInstance(); - } - - /** - * Attempts to decode a single UPC/EAN-encoded digit. - * - * @param row row of black/white values to decode - * @param counters the counts of runs of observed black/white/black/... values - * @param rowOffset horizontal offset to start decoding from - * @param patterns the set of patterns to use to decode -- sometimes different encodings - * for the digits 0-9 are used, and this indicates the encodings for 0 to 9 that should - * be used - * @return horizontal offset of first pixel beyond the decoded digit - * @throws NotFoundException if digit cannot be decoded - */ - static int decodeDigit(BitArray row, int[] counters, int rowOffset, int[][] patterns) - throws NotFoundException { - recordPattern(row, rowOffset, counters); - float bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept - int bestMatch = -1; - int max = patterns.length; - for (int i = 0; i < max; i++) { - int[] pattern = patterns[i]; - float variance = patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE); - if (variance < bestVariance) { - bestVariance = variance; - bestMatch = i; - } - } - if (bestMatch >= 0) { - return bestMatch; - } else { - throw NotFoundException.getNotFoundInstance(); - } - } - - /** - * Get the format of this decoder. - * - * @return The 1D format. - */ - abstract BarcodeFormat getBarcodeFormat(); - - /** - * Subclasses override this to decode the portion of a barcode between the start - * and end guard patterns. - * - * @param row row of black/white values to search - * @param startRange start/end offset of start guard pattern - * @param resultString {@link StringBuilder} to append decoded chars to - * @return horizontal offset of first pixel after the "middle" that was decoded - * @throws NotFoundException if decoding could not complete successfully - */ - protected abstract int decodeMiddle(BitArray row, - int[] startRange, - StringBuilder resultString) throws NotFoundException; - -} diff --git a/port_src/core/DONE/oned/UPCEANWriter.java b/port_src/core/DONE/oned/UPCEANWriter.java deleted file mode 100644 index 6e9907a..0000000 --- a/port_src/core/DONE/oned/UPCEANWriter.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -/** - *

Encapsulates functionality and implementation that is common to UPC and EAN families - * of one-dimensional barcodes.

- * - * @author aripollak@gmail.com (Ari Pollak) - * @author dsbnatut@gmail.com (Kazuki Nishiura) - */ -public abstract class UPCEANWriter extends OneDimensionalCodeWriter { - - @Override - public int getDefaultMargin() { - // Use a different default more appropriate for UPC/EAN - return 9; - } - -} diff --git a/port_src/core/DONE/oned/UPCEReader.java b/port_src/core/DONE/oned/UPCEReader.java deleted file mode 100644 index ab8e39c..0000000 --- a/port_src/core/DONE/oned/UPCEReader.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.common.BitArray; - -/** - *

Implements decoding of the UPC-E format.

- *

This is a great reference for - * UPC-E information.

- * - * @author Sean Owen - */ -public final class UPCEReader extends UPCEANReader { - - /** - * The pattern that marks the middle, and end, of a UPC-E pattern. - * There is no "second half" to a UPC-E barcode. - */ - private static final int[] MIDDLE_END_PATTERN = {1, 1, 1, 1, 1, 1}; - - // For an UPC-E barcode, the final digit is represented by the parities used - // to encode the middle six digits, according to the table below. - // - // Parity of next 6 digits - // Digit 0 1 2 3 4 5 - // 0 Even Even Even Odd Odd Odd - // 1 Even Even Odd Even Odd Odd - // 2 Even Even Odd Odd Even Odd - // 3 Even Even Odd Odd Odd Even - // 4 Even Odd Even Even Odd Odd - // 5 Even Odd Odd Even Even Odd - // 6 Even Odd Odd Odd Even Even - // 7 Even Odd Even Odd Even Odd - // 8 Even Odd Even Odd Odd Even - // 9 Even Odd Odd Even Odd Even - // - // The encoding is represented by the following array, which is a bit pattern - // using Odd = 0 and Even = 1. For example, 5 is represented by: - // - // Odd Even Even Odd Odd Even - // in binary: - // 0 1 1 0 0 1 == 0x19 - // - - /** - * See {@link #L_AND_G_PATTERNS}; these values similarly represent patterns of - * even-odd parity encodings of digits that imply both the number system (0 or 1) - * used, and the check digit. - */ - static final int[][] NUMSYS_AND_CHECK_DIGIT_PATTERNS = { - {0x38, 0x34, 0x32, 0x31, 0x2C, 0x26, 0x23, 0x2A, 0x29, 0x25}, - {0x07, 0x0B, 0x0D, 0x0E, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A} - }; - - private final int[] decodeMiddleCounters; - - public UPCEReader() { - decodeMiddleCounters = new int[4]; - } - - @Override - protected int decodeMiddle(BitArray row, int[] startRange, StringBuilder result) - throws NotFoundException { - int[] counters = decodeMiddleCounters; - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - int end = row.getSize(); - int rowOffset = startRange[1]; - - int lgPatternFound = 0; - - for (int x = 0; x < 6 && rowOffset < end; x++) { - int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS); - result.append((char) ('0' + bestMatch % 10)); - for (int counter : counters) { - rowOffset += counter; - } - if (bestMatch >= 10) { - lgPatternFound |= 1 << (5 - x); - } - } - - determineNumSysAndCheckDigit(result, lgPatternFound); - - return rowOffset; - } - - @Override - protected int[] decodeEnd(BitArray row, int endStart) throws NotFoundException { - return findGuardPattern(row, endStart, true, MIDDLE_END_PATTERN); - } - - @Override - protected boolean checkChecksum(String s) throws FormatException { - return super.checkChecksum(convertUPCEtoUPCA(s)); - } - - private static void determineNumSysAndCheckDigit(StringBuilder resultString, int lgPatternFound) - throws NotFoundException { - - for (int numSys = 0; numSys <= 1; numSys++) { - for (int d = 0; d < 10; d++) { - if (lgPatternFound == NUMSYS_AND_CHECK_DIGIT_PATTERNS[numSys][d]) { - resultString.insert(0, (char) ('0' + numSys)); - resultString.append((char) ('0' + d)); - return; - } - } - } - throw NotFoundException.getNotFoundInstance(); - } - - @Override - BarcodeFormat getBarcodeFormat() { - return BarcodeFormat.UPC_E; - } - - /** - * Expands a UPC-E value back into its full, equivalent UPC-A code value. - * - * @param upce UPC-E code as string of digits - * @return equivalent UPC-A code as string of digits - */ - public static String convertUPCEtoUPCA(String upce) { - char[] upceChars = new char[6]; - upce.getChars(1, 7, upceChars, 0); - StringBuilder result = new StringBuilder(12); - result.append(upce.charAt(0)); - char lastChar = upceChars[5]; - switch (lastChar) { - case '0': - case '1': - case '2': - result.append(upceChars, 0, 2); - result.append(lastChar); - result.append("0000"); - result.append(upceChars, 2, 3); - break; - case '3': - result.append(upceChars, 0, 3); - result.append("00000"); - result.append(upceChars, 3, 2); - break; - case '4': - result.append(upceChars, 0, 4); - result.append("00000"); - result.append(upceChars[4]); - break; - default: - result.append(upceChars, 0, 5); - result.append("0000"); - result.append(lastChar); - break; - } - // Only append check digit in conversion if supplied - if (upce.length() >= 8) { - result.append(upce.charAt(7)); - } - return result.toString(); - } - -} diff --git a/port_src/core/DONE/oned/UPCEWriter.java b/port_src/core/DONE/oned/UPCEWriter.java deleted file mode 100644 index 48bac6f..0000000 --- a/port_src/core/DONE/oned/UPCEWriter.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import java.util.Collection; -import java.util.Collections; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; - -/** - * This object renders an UPC-E code as a {@link BitMatrix}. - * - * @author 0979097955s@gmail.com (RX) - */ -public final class UPCEWriter extends UPCEANWriter { - - private static final int CODE_WIDTH = 3 + // start guard - (7 * 6) + // bars - 6; // end guard - - @Override - protected Collection getSupportedWriteFormats() { - return Collections.singleton(BarcodeFormat.UPC_E); - } - - @Override - public boolean[] encode(String contents) { - int length = contents.length(); - switch (length) { - case 7: - // No check digit present, calculate it and add it - int check; - try { - check = UPCEANReader.getStandardUPCEANChecksum(UPCEReader.convertUPCEtoUPCA(contents)); - } catch (FormatException fe) { - throw new IllegalArgumentException(fe); - } - contents += check; - break; - case 8: - try { - if (!UPCEANReader.checkStandardUPCEANChecksum(UPCEReader.convertUPCEtoUPCA(contents))) { - throw new IllegalArgumentException("Contents do not pass checksum"); - } - } catch (FormatException ignored) { - throw new IllegalArgumentException("Illegal contents"); - } - break; - default: - throw new IllegalArgumentException( - "Requested contents should be 7 or 8 digits long, but got " + length); - } - - checkNumeric(contents); - - int firstDigit = Character.digit(contents.charAt(0), 10); - if (firstDigit != 0 && firstDigit != 1) { - throw new IllegalArgumentException("Number system must be 0 or 1"); - } - - int checkDigit = Character.digit(contents.charAt(7), 10); - int parities = UPCEReader.NUMSYS_AND_CHECK_DIGIT_PATTERNS[firstDigit][checkDigit]; - boolean[] result = new boolean[CODE_WIDTH]; - - int pos = appendPattern(result, 0, UPCEANReader.START_END_PATTERN, true); - - for (int i = 1; i <= 6; i++) { - int digit = Character.digit(contents.charAt(i), 10); - if ((parities >> (6 - i) & 1) == 1) { - digit += 10; - } - pos += appendPattern(result, pos, UPCEANReader.L_AND_G_PATTERNS[digit], false); - } - - appendPattern(result, pos, UPCEANReader.END_PATTERN, false); - - return result; - } - -} diff --git a/port_src/core/DONE/oned/rss/AbstractRSSReader.java b/port_src/core/DONE/oned/rss/AbstractRSSReader.java deleted file mode 100644 index 5c77512..0000000 --- a/port_src/core/DONE/oned/rss/AbstractRSSReader.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned.rss; - -import com.google.zxing.NotFoundException; -import com.google.zxing.common.detector.MathUtils; -import com.google.zxing.oned.OneDReader; - -/** - * Superclass of {@link OneDReader} implementations that read barcodes in the RSS family - * of formats. - */ -public abstract class AbstractRSSReader extends OneDReader { - - private static final float MAX_AVG_VARIANCE = 0.2f; - private static final float MAX_INDIVIDUAL_VARIANCE = 0.45f; - - private static final float MIN_FINDER_PATTERN_RATIO = 9.5f / 12.0f; - private static final float MAX_FINDER_PATTERN_RATIO = 12.5f / 14.0f; - - private final int[] decodeFinderCounters; - private final int[] dataCharacterCounters; - private final float[] oddRoundingErrors; - private final float[] evenRoundingErrors; - private final int[] oddCounts; - private final int[] evenCounts; - - protected AbstractRSSReader() { - decodeFinderCounters = new int[4]; - dataCharacterCounters = new int[8]; - oddRoundingErrors = new float[4]; - evenRoundingErrors = new float[4]; - oddCounts = new int[dataCharacterCounters.length / 2]; - evenCounts = new int[dataCharacterCounters.length / 2]; - } - - protected final int[] getDecodeFinderCounters() { - return decodeFinderCounters; - } - - protected final int[] getDataCharacterCounters() { - return dataCharacterCounters; - } - - protected final float[] getOddRoundingErrors() { - return oddRoundingErrors; - } - - protected final float[] getEvenRoundingErrors() { - return evenRoundingErrors; - } - - protected final int[] getOddCounts() { - return oddCounts; - } - - protected final int[] getEvenCounts() { - return evenCounts; - } - - protected static int parseFinderValue(int[] counters, - int[][] finderPatterns) throws NotFoundException { - for (int value = 0; value < finderPatterns.length; value++) { - if (patternMatchVariance(counters, finderPatterns[value], MAX_INDIVIDUAL_VARIANCE) < - MAX_AVG_VARIANCE) { - return value; - } - } - throw NotFoundException.getNotFoundInstance(); - } - - /** - * @param array values to sum - * @return sum of values - * @deprecated call {@link MathUtils#sum(int[])} - */ - @Deprecated - protected static int count(int[] array) { - return MathUtils.sum(array); - } - - protected static void increment(int[] array, float[] errors) { - int index = 0; - float biggestError = errors[0]; - for (int i = 1; i < array.length; i++) { - if (errors[i] > biggestError) { - biggestError = errors[i]; - index = i; - } - } - array[index]++; - } - - protected static void decrement(int[] array, float[] errors) { - int index = 0; - float biggestError = errors[0]; - for (int i = 1; i < array.length; i++) { - if (errors[i] < biggestError) { - biggestError = errors[i]; - index = i; - } - } - array[index]--; - } - - protected static boolean isFinderPattern(int[] counters) { - int firstTwoSum = counters[0] + counters[1]; - int sum = firstTwoSum + counters[2] + counters[3]; - float ratio = firstTwoSum / (float) sum; - if (ratio >= MIN_FINDER_PATTERN_RATIO && ratio <= MAX_FINDER_PATTERN_RATIO) { - // passes ratio test in spec, but see if the counts are unreasonable - int minCounter = Integer.MAX_VALUE; - int maxCounter = Integer.MIN_VALUE; - for (int counter : counters) { - if (counter > maxCounter) { - maxCounter = counter; - } - if (counter < minCounter) { - minCounter = counter; - } - } - return maxCounter < 10 * minCounter; - } - return false; - } -} diff --git a/port_src/core/DONE/oned/rss/DataCharacter.java b/port_src/core/DONE/oned/rss/DataCharacter.java deleted file mode 100644 index 1c3c502..0000000 --- a/port_src/core/DONE/oned/rss/DataCharacter.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned.rss; - -/** - * Encapsulates a since character value in an RSS barcode, including its checksum information. - */ -public class DataCharacter { - - private final int value; - private final int checksumPortion; - - public DataCharacter(int value, int checksumPortion) { - this.value = value; - this.checksumPortion = checksumPortion; - } - - public final int getValue() { - return value; - } - - public final int getChecksumPortion() { - return checksumPortion; - } - - @Override - public final String toString() { - return value + "(" + checksumPortion + ')'; - } - - @Override - public final boolean equals(Object o) { - if (!(o instanceof DataCharacter)) { - return false; - } - DataCharacter that = (DataCharacter) o; - return value == that.value && checksumPortion == that.checksumPortion; - } - - @Override - public final int hashCode() { - return value ^ checksumPortion; - } - -} diff --git a/port_src/core/DONE/oned/rss/FinderPattern.java b/port_src/core/DONE/oned/rss/FinderPattern.java deleted file mode 100644 index 56a8d72..0000000 --- a/port_src/core/DONE/oned/rss/FinderPattern.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned.rss; - -import com.google.zxing.ResultPoint; - -/** - * Encapsulates an RSS barcode finder pattern, including its start/end position and row. - */ -public final class FinderPattern { - - private final int value; - private final int[] startEnd; - private final ResultPoint[] resultPoints; - - public FinderPattern(int value, int[] startEnd, int start, int end, int rowNumber) { - this.value = value; - this.startEnd = startEnd; - this.resultPoints = new ResultPoint[] { - new ResultPoint(start, rowNumber), - new ResultPoint(end, rowNumber), - }; - } - - public int getValue() { - return value; - } - - public int[] getStartEnd() { - return startEnd; - } - - public ResultPoint[] getResultPoints() { - return resultPoints; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof FinderPattern)) { - return false; - } - FinderPattern that = (FinderPattern) o; - return value == that.value; - } - - @Override - public int hashCode() { - return value; - } - -} diff --git a/port_src/core/DONE/oned/rss/Pair.java b/port_src/core/DONE/oned/rss/Pair.java deleted file mode 100644 index e2371d2..0000000 --- a/port_src/core/DONE/oned/rss/Pair.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned.rss; - -final class Pair extends DataCharacter { - - private final FinderPattern finderPattern; - private int count; - - Pair(int value, int checksumPortion, FinderPattern finderPattern) { - super(value, checksumPortion); - this.finderPattern = finderPattern; - } - - FinderPattern getFinderPattern() { - return finderPattern; - } - - int getCount() { - return count; - } - - void incrementCount() { - count++; - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/oned/rss/RSS14Reader.java b/port_src/core/DONE/oned/rss/RSS14Reader.java deleted file mode 100644 index 4042244..0000000 --- a/port_src/core/DONE/oned/rss/RSS14Reader.java +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned.rss; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.ResultPointCallback; -import com.google.zxing.common.BitArray; -import com.google.zxing.common.detector.MathUtils; - -import java.util.Arrays; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * Decodes RSS-14, including truncated and stacked variants. See ISO/IEC 24724:2006. - */ -public final class RSS14Reader extends AbstractRSSReader { - - private static final int[] OUTSIDE_EVEN_TOTAL_SUBSET = {1,10,34,70,126}; - private static final int[] INSIDE_ODD_TOTAL_SUBSET = {4,20,48,81}; - private static final int[] OUTSIDE_GSUM = {0,161,961,2015,2715}; - private static final int[] INSIDE_GSUM = {0,336,1036,1516}; - private static final int[] OUTSIDE_ODD_WIDEST = {8,6,4,3,1}; - private static final int[] INSIDE_ODD_WIDEST = {2,4,6,8}; - - private static final int[][] FINDER_PATTERNS = { - {3,8,2,1}, - {3,5,5,1}, - {3,3,7,1}, - {3,1,9,1}, - {2,7,4,1}, - {2,5,6,1}, - {2,3,8,1}, - {1,5,7,1}, - {1,3,9,1}, - }; - - private final List possibleLeftPairs; - private final List possibleRightPairs; - - public RSS14Reader() { - possibleLeftPairs = new ArrayList<>(); - possibleRightPairs = new ArrayList<>(); - } - - @Override - public Result decodeRow(int rowNumber, - BitArray row, - Map hints) throws NotFoundException { - Pair leftPair = decodePair(row, false, rowNumber, hints); - addOrTally(possibleLeftPairs, leftPair); - row.reverse(); - Pair rightPair = decodePair(row, true, rowNumber, hints); - addOrTally(possibleRightPairs, rightPair); - row.reverse(); - for (Pair left : possibleLeftPairs) { - if (left.getCount() > 1) { - for (Pair right : possibleRightPairs) { - if (right.getCount() > 1 && checkChecksum(left, right)) { - return constructResult(left, right); - } - } - } - } - throw NotFoundException.getNotFoundInstance(); - } - - private static void addOrTally(Collection possiblePairs, Pair pair) { - if (pair == null) { - return; - } - boolean found = false; - for (Pair other : possiblePairs) { - if (other.getValue() == pair.getValue()) { - other.incrementCount(); - found = true; - break; - } - } - if (!found) { - possiblePairs.add(pair); - } - } - - @Override - public void reset() { - possibleLeftPairs.clear(); - possibleRightPairs.clear(); - } - - private static Result constructResult(Pair leftPair, Pair rightPair) { - long symbolValue = 4537077L * leftPair.getValue() + rightPair.getValue(); - String text = String.valueOf(symbolValue); - - StringBuilder buffer = new StringBuilder(14); - for (int i = 13 - text.length(); i > 0; i--) { - buffer.append('0'); - } - buffer.append(text); - - int checkDigit = 0; - for (int i = 0; i < 13; i++) { - int digit = buffer.charAt(i) - '0'; - checkDigit += (i & 0x01) == 0 ? 3 * digit : digit; - } - checkDigit = 10 - (checkDigit % 10); - if (checkDigit == 10) { - checkDigit = 0; - } - buffer.append(checkDigit); - - ResultPoint[] leftPoints = leftPair.getFinderPattern().getResultPoints(); - ResultPoint[] rightPoints = rightPair.getFinderPattern().getResultPoints(); - Result result = new Result( - buffer.toString(), - null, - new ResultPoint[] { leftPoints[0], leftPoints[1], rightPoints[0], rightPoints[1], }, - BarcodeFormat.RSS_14); - result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]e0"); - return result; - } - - private static boolean checkChecksum(Pair leftPair, Pair rightPair) { - int checkValue = (leftPair.getChecksumPortion() + 16 * rightPair.getChecksumPortion()) % 79; - int targetCheckValue = - 9 * leftPair.getFinderPattern().getValue() + rightPair.getFinderPattern().getValue(); - if (targetCheckValue > 72) { - targetCheckValue--; - } - if (targetCheckValue > 8) { - targetCheckValue--; - } - return checkValue == targetCheckValue; - } - - private Pair decodePair(BitArray row, boolean right, int rowNumber, Map hints) { - try { - int[] startEnd = findFinderPattern(row, right); - FinderPattern pattern = parseFoundFinderPattern(row, rowNumber, right, startEnd); - - ResultPointCallback resultPointCallback = hints == null ? null : - (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); - - if (resultPointCallback != null) { - startEnd = pattern.getStartEnd(); - float center = (startEnd[0] + startEnd[1] - 1) / 2.0f; - if (right) { - // row is actually reversed - center = row.getSize() - 1 - center; - } - resultPointCallback.foundPossibleResultPoint(new ResultPoint(center, rowNumber)); - } - - DataCharacter outside = decodeDataCharacter(row, pattern, true); - DataCharacter inside = decodeDataCharacter(row, pattern, false); - return new Pair(1597 * outside.getValue() + inside.getValue(), - outside.getChecksumPortion() + 4 * inside.getChecksumPortion(), - pattern); - } catch (NotFoundException ignored) { - return null; - } - } - - private DataCharacter decodeDataCharacter(BitArray row, FinderPattern pattern, boolean outsideChar) - throws NotFoundException { - - int[] counters = getDataCharacterCounters(); - Arrays.fill(counters, 0); - - if (outsideChar) { - recordPatternInReverse(row, pattern.getStartEnd()[0], counters); - } else { - recordPattern(row, pattern.getStartEnd()[1], counters); - // reverse it - for (int i = 0, j = counters.length - 1; i < j; i++, j--) { - int temp = counters[i]; - counters[i] = counters[j]; - counters[j] = temp; - } - } - - int numModules = outsideChar ? 16 : 15; - float elementWidth = MathUtils.sum(counters) / (float) numModules; - - int[] oddCounts = this.getOddCounts(); - int[] evenCounts = this.getEvenCounts(); - float[] oddRoundingErrors = this.getOddRoundingErrors(); - float[] evenRoundingErrors = this.getEvenRoundingErrors(); - - for (int i = 0; i < counters.length; i++) { - float value = counters[i] / elementWidth; - int count = (int) (value + 0.5f); // Round - if (count < 1) { - count = 1; - } else if (count > 8) { - count = 8; - } - int offset = i / 2; - if ((i & 0x01) == 0) { - oddCounts[offset] = count; - oddRoundingErrors[offset] = value - count; - } else { - evenCounts[offset] = count; - evenRoundingErrors[offset] = value - count; - } - } - - adjustOddEvenCounts(outsideChar, numModules); - - int oddSum = 0; - int oddChecksumPortion = 0; - for (int i = oddCounts.length - 1; i >= 0; i--) { - oddChecksumPortion *= 9; - oddChecksumPortion += oddCounts[i]; - oddSum += oddCounts[i]; - } - int evenChecksumPortion = 0; - int evenSum = 0; - for (int i = evenCounts.length - 1; i >= 0; i--) { - evenChecksumPortion *= 9; - evenChecksumPortion += evenCounts[i]; - evenSum += evenCounts[i]; - } - int checksumPortion = oddChecksumPortion + 3 * evenChecksumPortion; - - if (outsideChar) { - if ((oddSum & 0x01) != 0 || oddSum > 12 || oddSum < 4) { - throw NotFoundException.getNotFoundInstance(); - } - int group = (12 - oddSum) / 2; - int oddWidest = OUTSIDE_ODD_WIDEST[group]; - int evenWidest = 9 - oddWidest; - int vOdd = RSSUtils.getRSSvalue(oddCounts, oddWidest, false); - int vEven = RSSUtils.getRSSvalue(evenCounts, evenWidest, true); - int tEven = OUTSIDE_EVEN_TOTAL_SUBSET[group]; - int gSum = OUTSIDE_GSUM[group]; - return new DataCharacter(vOdd * tEven + vEven + gSum, checksumPortion); - } else { - if ((evenSum & 0x01) != 0 || evenSum > 10 || evenSum < 4) { - throw NotFoundException.getNotFoundInstance(); - } - int group = (10 - evenSum) / 2; - int oddWidest = INSIDE_ODD_WIDEST[group]; - int evenWidest = 9 - oddWidest; - int vOdd = RSSUtils.getRSSvalue(oddCounts, oddWidest, true); - int vEven = RSSUtils.getRSSvalue(evenCounts, evenWidest, false); - int tOdd = INSIDE_ODD_TOTAL_SUBSET[group]; - int gSum = INSIDE_GSUM[group]; - return new DataCharacter(vEven * tOdd + vOdd + gSum, checksumPortion); - } - - } - - private int[] findFinderPattern(BitArray row, boolean rightFinderPattern) - throws NotFoundException { - - int[] counters = getDecodeFinderCounters(); - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - - int width = row.getSize(); - boolean isWhite = false; - int rowOffset = 0; - while (rowOffset < width) { - isWhite = !row.get(rowOffset); - if (rightFinderPattern == isWhite) { - // Will encounter white first when searching for right finder pattern - break; - } - rowOffset++; - } - - int counterPosition = 0; - int patternStart = rowOffset; - for (int x = rowOffset; x < width; x++) { - if (row.get(x) != isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == 3) { - if (isFinderPattern(counters)) { - return new int[]{patternStart, x}; - } - patternStart += counters[0] + counters[1]; - counters[0] = counters[2]; - counters[1] = counters[3]; - counters[2] = 0; - counters[3] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - throw NotFoundException.getNotFoundInstance(); - - } - - private FinderPattern parseFoundFinderPattern(BitArray row, int rowNumber, boolean right, int[] startEnd) - throws NotFoundException { - // Actually we found elements 2-5 - boolean firstIsBlack = row.get(startEnd[0]); - int firstElementStart = startEnd[0] - 1; - // Locate element 1 - while (firstElementStart >= 0 && firstIsBlack != row.get(firstElementStart)) { - firstElementStart--; - } - firstElementStart++; - int firstCounter = startEnd[0] - firstElementStart; - // Make 'counters' hold 1-4 - int[] counters = getDecodeFinderCounters(); - System.arraycopy(counters, 0, counters, 1, counters.length - 1); - counters[0] = firstCounter; - int value = parseFinderValue(counters, FINDER_PATTERNS); - int start = firstElementStart; - int end = startEnd[1]; - if (right) { - // row is actually reversed - start = row.getSize() - 1 - start; - end = row.getSize() - 1 - end; - } - return new FinderPattern(value, new int[] {firstElementStart, startEnd[1]}, start, end, rowNumber); - } - - private void adjustOddEvenCounts(boolean outsideChar, int numModules) throws NotFoundException { - - int oddSum = MathUtils.sum(getOddCounts()); - int evenSum = MathUtils.sum(getEvenCounts()); - - boolean incrementOdd = false; - boolean decrementOdd = false; - boolean incrementEven = false; - boolean decrementEven = false; - - if (outsideChar) { - if (oddSum > 12) { - decrementOdd = true; - } else if (oddSum < 4) { - incrementOdd = true; - } - if (evenSum > 12) { - decrementEven = true; - } else if (evenSum < 4) { - incrementEven = true; - } - } else { - if (oddSum > 11) { - decrementOdd = true; - } else if (oddSum < 5) { - incrementOdd = true; - } - if (evenSum > 10) { - decrementEven = true; - } else if (evenSum < 4) { - incrementEven = true; - } - } - - int mismatch = oddSum + evenSum - numModules; - boolean oddParityBad = (oddSum & 0x01) == (outsideChar ? 1 : 0); - boolean evenParityBad = (evenSum & 0x01) == 1; - /*if (mismatch == 2) { - if (!(oddParityBad && evenParityBad)) { - throw ReaderException.getInstance(); - } - decrementOdd = true; - decrementEven = true; - } else if (mismatch == -2) { - if (!(oddParityBad && evenParityBad)) { - throw ReaderException.getInstance(); - } - incrementOdd = true; - incrementEven = true; - } else */ - switch (mismatch) { - case 1: - if (oddParityBad) { - if (evenParityBad) { - throw NotFoundException.getNotFoundInstance(); - } - decrementOdd = true; - } else { - if (!evenParityBad) { - throw NotFoundException.getNotFoundInstance(); - } - decrementEven = true; - } - break; - case -1: - if (oddParityBad) { - if (evenParityBad) { - throw NotFoundException.getNotFoundInstance(); - } - incrementOdd = true; - } else { - if (!evenParityBad) { - throw NotFoundException.getNotFoundInstance(); - } - incrementEven = true; - } - break; - case 0: - if (oddParityBad) { - if (!evenParityBad) { - throw NotFoundException.getNotFoundInstance(); - } - // Both bad - if (oddSum < evenSum) { - incrementOdd = true; - decrementEven = true; - } else { - decrementOdd = true; - incrementEven = true; - } - } else { - if (evenParityBad) { - throw NotFoundException.getNotFoundInstance(); - } - // Nothing to do! - } - break; - default: - throw NotFoundException.getNotFoundInstance(); - } - - if (incrementOdd) { - if (decrementOdd) { - throw NotFoundException.getNotFoundInstance(); - } - increment(getOddCounts(), getOddRoundingErrors()); - } - if (decrementOdd) { - decrement(getOddCounts(), getOddRoundingErrors()); - } - if (incrementEven) { - if (decrementEven) { - throw NotFoundException.getNotFoundInstance(); - } - increment(getEvenCounts(), getOddRoundingErrors()); - } - if (decrementEven) { - decrement(getEvenCounts(), getEvenRoundingErrors()); - } - - } - -} diff --git a/port_src/core/DONE/oned/rss/RSSUtils.java b/port_src/core/DONE/oned/rss/RSSUtils.java deleted file mode 100644 index 94f93e5..0000000 --- a/port_src/core/DONE/oned/rss/RSSUtils.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned.rss; - -/** Adapted from listings in ISO/IEC 24724 Appendix B and Appendix G. */ -public final class RSSUtils { - - private RSSUtils() {} - - public static int getRSSvalue(int[] widths, int maxWidth, boolean noNarrow) { - int n = 0; - for (int width : widths) { - n += width; - } - int val = 0; - int narrowMask = 0; - int elements = widths.length; - for (int bar = 0; bar < elements - 1; bar++) { - int elmWidth; - for (elmWidth = 1, narrowMask |= 1 << bar; - elmWidth < widths[bar]; - elmWidth++, narrowMask &= ~(1 << bar)) { - int subVal = combins(n - elmWidth - 1, elements - bar - 2); - if (noNarrow && (narrowMask == 0) && - (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { - subVal -= combins(n - elmWidth - (elements - bar), - elements - bar - 2); - } - if (elements - bar - 1 > 1) { - int lessVal = 0; - for (int mxwElement = n - elmWidth - (elements - bar - 2); - mxwElement > maxWidth; mxwElement--) { - lessVal += combins(n - elmWidth - mxwElement - 1, - elements - bar - 3); - } - subVal -= lessVal * (elements - 1 - bar); - } else if (n - elmWidth > maxWidth) { - subVal--; - } - val += subVal; - } - n -= elmWidth; - } - return val; - } - - private static int combins(int n, int r) { - int maxDenom; - int minDenom; - if (n - r > r) { - minDenom = r; - maxDenom = n - r; - } else { - minDenom = n - r; - maxDenom = r; - } - int val = 1; - int j = 1; - for (int i = n; i > maxDenom; i--) { - val *= i; - if (j <= minDenom) { - val /= j; - j++; - } - } - while (j <= minDenom) { - val /= j; - j++; - } - return val; - } - -} diff --git a/port_src/core/DONE/oned/rss/expanded/BitArrayBuilder.java b/port_src/core/DONE/oned/rss/expanded/BitArrayBuilder.java deleted file mode 100644 index 293af30..0000000 --- a/port_src/core/DONE/oned/rss/expanded/BitArrayBuilder.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.common.BitArray; - -import java.util.List; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -final class BitArrayBuilder { - - private BitArrayBuilder() { - } - - static BitArray buildBitArray(List pairs) { - int charNumber = (pairs.size() * 2) - 1; - if (pairs.get(pairs.size() - 1).getRightChar() == null) { - charNumber -= 1; - } - - int size = 12 * charNumber; - - BitArray binary = new BitArray(size); - int accPos = 0; - - ExpandedPair firstPair = pairs.get(0); - int firstValue = firstPair.getRightChar().getValue(); - for (int i = 11; i >= 0; --i) { - if ((firstValue & (1 << i)) != 0) { - binary.set(accPos); - } - accPos++; - } - - for (int i = 1; i < pairs.size(); ++i) { - ExpandedPair currentPair = pairs.get(i); - - int leftValue = currentPair.getLeftChar().getValue(); - for (int j = 11; j >= 0; --j) { - if ((leftValue & (1 << j)) != 0) { - binary.set(accPos); - } - accPos++; - } - - if (currentPair.getRightChar() != null) { - int rightValue = currentPair.getRightChar().getValue(); - for (int j = 11; j >= 0; --j) { - if ((rightValue & (1 << j)) != 0) { - binary.set(accPos); - } - accPos++; - } - } - } - return binary; - } -} diff --git a/port_src/core/DONE/oned/rss/expanded/ExpandedPair.java b/port_src/core/DONE/oned/rss/expanded/ExpandedPair.java deleted file mode 100644 index e22b5e3..0000000 --- a/port_src/core/DONE/oned/rss/expanded/ExpandedPair.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.oned.rss.DataCharacter; -import com.google.zxing.oned.rss.FinderPattern; - -import java.util.Objects; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -final class ExpandedPair { - - private final DataCharacter leftChar; - private final DataCharacter rightChar; - private final FinderPattern finderPattern; - - ExpandedPair(DataCharacter leftChar, - DataCharacter rightChar, - FinderPattern finderPattern) { - this.leftChar = leftChar; - this.rightChar = rightChar; - this.finderPattern = finderPattern; - } - - DataCharacter getLeftChar() { - return this.leftChar; - } - - DataCharacter getRightChar() { - return this.rightChar; - } - - FinderPattern getFinderPattern() { - return this.finderPattern; - } - - boolean mustBeLast() { - return this.rightChar == null; - } - - @Override - public String toString() { - return - "[ " + leftChar + " , " + rightChar + " : " + - (finderPattern == null ? "null" : finderPattern.getValue()) + " ]"; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof ExpandedPair)) { - return false; - } - ExpandedPair that = (ExpandedPair) o; - return Objects.equals(leftChar, that.leftChar) && - Objects.equals(rightChar, that.rightChar) && - Objects.equals(finderPattern, that.finderPattern); - } - - @Override - public int hashCode() { - return Objects.hashCode(leftChar) ^ Objects.hashCode(rightChar) ^ Objects.hashCode(finderPattern); - } - -} diff --git a/port_src/core/DONE/oned/rss/expanded/ExpandedRow.java b/port_src/core/DONE/oned/rss/expanded/ExpandedRow.java deleted file mode 100644 index 38048f4..0000000 --- a/port_src/core/DONE/oned/rss/expanded/ExpandedRow.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned.rss.expanded; - -import java.util.ArrayList; -import java.util.List; - -/** - * One row of an RSS Expanded Stacked symbol, consisting of 1+ expanded pairs. - */ -final class ExpandedRow { - - private final List pairs; - private final int rowNumber; - - ExpandedRow(List pairs, int rowNumber) { - this.pairs = new ArrayList<>(pairs); - this.rowNumber = rowNumber; - } - - List getPairs() { - return this.pairs; - } - - int getRowNumber() { - return this.rowNumber; - } - - boolean isEquivalent(List otherPairs) { - return this.pairs.equals(otherPairs); - } - - @Override - public String toString() { - return "{ " + pairs + " }"; - } - - /** - * Two rows are equal if they contain the same pairs in the same order. - */ - @Override - public boolean equals(Object o) { - if (!(o instanceof ExpandedRow)) { - return false; - } - ExpandedRow that = (ExpandedRow) o; - return this.pairs.equals(that.pairs); - } - - @Override - public int hashCode() { - return pairs.hashCode(); - } - -} diff --git a/port_src/core/DONE/oned/rss/expanded/RSSExpandedReader.java b/port_src/core/DONE/oned/rss/expanded/RSSExpandedReader.java deleted file mode 100644 index 6171885..0000000 --- a/port_src/core/DONE/oned/rss/expanded/RSSExpandedReader.java +++ /dev/null @@ -1,768 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitArray; -import com.google.zxing.common.detector.MathUtils; -import com.google.zxing.oned.rss.AbstractRSSReader; -import com.google.zxing.oned.rss.DataCharacter; -import com.google.zxing.oned.rss.FinderPattern; -import com.google.zxing.oned.rss.RSSUtils; -import com.google.zxing.oned.rss.expanded.decoders.AbstractExpandedDecoder; - -import java.util.Arrays; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Collections; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -public final class RSSExpandedReader extends AbstractRSSReader { - - private static final int[] SYMBOL_WIDEST = {7, 5, 4, 3, 1}; - private static final int[] EVEN_TOTAL_SUBSET = {4, 20, 52, 104, 204}; - private static final int[] GSUM = {0, 348, 1388, 2948, 3988}; - - private static final int[][] FINDER_PATTERNS = { - {1,8,4,1}, // A - {3,6,4,1}, // B - {3,4,6,1}, // C - {3,2,8,1}, // D - {2,6,5,1}, // E - {2,2,9,1} // F - }; - - private static final int[][] WEIGHTS = { - { 1, 3, 9, 27, 81, 32, 96, 77}, - { 20, 60, 180, 118, 143, 7, 21, 63}, - {189, 145, 13, 39, 117, 140, 209, 205}, - {193, 157, 49, 147, 19, 57, 171, 91}, - { 62, 186, 136, 197, 169, 85, 44, 132}, - {185, 133, 188, 142, 4, 12, 36, 108}, - {113, 128, 173, 97, 80, 29, 87, 50}, - {150, 28, 84, 41, 123, 158, 52, 156}, - { 46, 138, 203, 187, 139, 206, 196, 166}, - { 76, 17, 51, 153, 37, 111, 122, 155}, - { 43, 129, 176, 106, 107, 110, 119, 146}, - { 16, 48, 144, 10, 30, 90, 59, 177}, - {109, 116, 137, 200, 178, 112, 125, 164}, - { 70, 210, 208, 202, 184, 130, 179, 115}, - {134, 191, 151, 31, 93, 68, 204, 190}, - {148, 22, 66, 198, 172, 94, 71, 2}, - { 6, 18, 54, 162, 64, 192,154, 40}, - {120, 149, 25, 75, 14, 42,126, 167}, - { 79, 26, 78, 23, 69, 207,199, 175}, - {103, 98, 83, 38, 114, 131, 182, 124}, - {161, 61, 183, 127, 170, 88, 53, 159}, - { 55, 165, 73, 8, 24, 72, 5, 15}, - { 45, 135, 194, 160, 58, 174, 100, 89} - }; - - private static final int FINDER_PAT_A = 0; - private static final int FINDER_PAT_B = 1; - private static final int FINDER_PAT_C = 2; - private static final int FINDER_PAT_D = 3; - private static final int FINDER_PAT_E = 4; - private static final int FINDER_PAT_F = 5; - - @SuppressWarnings("checkstyle:lineLength") - private static final int[][] FINDER_PATTERN_SEQUENCES = { - { FINDER_PAT_A, FINDER_PAT_A }, - { FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B }, - { FINDER_PAT_A, FINDER_PAT_C, FINDER_PAT_B, FINDER_PAT_D }, - { FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_C }, - { FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_D, FINDER_PAT_F }, - { FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F }, - { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_D }, - { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_E }, - { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F }, - { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F }, - }; - - private static final int MAX_PAIRS = 11; - - private final List pairs = new ArrayList<>(MAX_PAIRS); - private final List rows = new ArrayList<>(); - private final int [] startEnd = new int[2]; - private boolean startFromEven; - - @Override - public Result decodeRow(int rowNumber, - BitArray row, - Map hints) throws NotFoundException, FormatException { - // Rows can start with even pattern in case in prev rows there where odd number of patters. - // So lets try twice - this.pairs.clear(); - this.startFromEven = false; - try { - return constructResult(decodeRow2pairs(rowNumber, row)); - } catch (NotFoundException e) { - // OK - } - - this.pairs.clear(); - this.startFromEven = true; - return constructResult(decodeRow2pairs(rowNumber, row)); - } - - @Override - public void reset() { - this.pairs.clear(); - this.rows.clear(); - } - - // Not private for testing - List decodeRow2pairs(int rowNumber, BitArray row) throws NotFoundException { - boolean done = false; - while (!done) { - try { - this.pairs.add(retrieveNextPair(row, this.pairs, rowNumber)); - } catch (NotFoundException nfe) { - if (this.pairs.isEmpty()) { - throw nfe; - } - // exit this loop when retrieveNextPair() fails and throws - done = true; - } - } - - // TODO: verify sequence of finder patterns as in checkPairSequence() - if (checkChecksum()) { - return this.pairs; - } - - boolean tryStackedDecode = !this.rows.isEmpty(); - storeRow(rowNumber); // TODO: deal with reversed rows - if (tryStackedDecode) { - // When the image is 180-rotated, then rows are sorted in wrong direction. - // Try twice with both the directions. - List ps = checkRows(false); - if (ps != null) { - return ps; - } - ps = checkRows(true); - if (ps != null) { - return ps; - } - } - - throw NotFoundException.getNotFoundInstance(); - } - - private List checkRows(boolean reverse) { - // Limit number of rows we are checking - // We use recursive algorithm with pure complexity and don't want it to take forever - // Stacked barcode can have up to 11 rows, so 25 seems reasonable enough - if (this.rows.size() > 25) { - this.rows.clear(); // We will never have a chance to get result, so clear it - return null; - } - - this.pairs.clear(); - if (reverse) { - Collections.reverse(this.rows); - } - - List ps = null; - try { - ps = checkRows(new ArrayList<>(), 0); - } catch (NotFoundException e) { - // OK - } - - if (reverse) { - Collections.reverse(this.rows); - } - - return ps; - } - - // Try to construct a valid rows sequence - // Recursion is used to implement backtracking - private List checkRows(List collectedRows, int currentRow) throws NotFoundException { - for (int i = currentRow; i < rows.size(); i++) { - ExpandedRow row = rows.get(i); - this.pairs.clear(); - for (ExpandedRow collectedRow : collectedRows) { - this.pairs.addAll(collectedRow.getPairs()); - } - this.pairs.addAll(row.getPairs()); - - if (isValidSequence(this.pairs)) { - if (checkChecksum()) { - return this.pairs; - } - - List rs = new ArrayList<>(collectedRows); - rs.add(row); - try { - // Recursion: try to add more rows - return checkRows(rs, i + 1); - } catch (NotFoundException e) { - // We failed, try the next candidate - } - } - } - - throw NotFoundException.getNotFoundInstance(); - } - - // Whether the pairs form a valid find pattern sequence, - // either complete or a prefix - private static boolean isValidSequence(List pairs) { - for (int[] sequence : FINDER_PATTERN_SEQUENCES) { - if (pairs.size() <= sequence.length) { - boolean stop = true; - for (int j = 0; j < pairs.size(); j++) { - if (pairs.get(j).getFinderPattern().getValue() != sequence[j]) { - stop = false; - break; - } - } - if (stop) { - return true; - } - } - - } - - return false; - } - - private void storeRow(int rowNumber) { - // Discard if duplicate above or below; otherwise insert in order by row number. - int insertPos = 0; - boolean prevIsSame = false; - boolean nextIsSame = false; - while (insertPos < this.rows.size()) { - ExpandedRow erow = this.rows.get(insertPos); - if (erow.getRowNumber() > rowNumber) { - nextIsSame = erow.isEquivalent(this.pairs); - break; - } - prevIsSame = erow.isEquivalent(this.pairs); - insertPos++; - } - if (nextIsSame || prevIsSame) { - return; - } - - // When the row was partially decoded (e.g. 2 pairs found instead of 3), - // it will prevent us from detecting the barcode. - // Try to merge partial rows - - // Check whether the row is part of an already detected row - if (isPartialRow(this.pairs, this.rows)) { - return; - } - - this.rows.add(insertPos, new ExpandedRow(this.pairs, rowNumber)); - - removePartialRows(this.pairs, this.rows); - } - - // Remove all the rows that contains only specified pairs - private static void removePartialRows(Collection pairs, Collection rows) { - for (Iterator iterator = rows.iterator(); iterator.hasNext();) { - ExpandedRow r = iterator.next(); - if (r.getPairs().size() != pairs.size()) { - boolean allFound = true; - for (ExpandedPair p : r.getPairs()) { - if (!pairs.contains(p)) { - allFound = false; - break; - } - } - if (allFound) { - // 'pairs' contains all the pairs from the row 'r' - iterator.remove(); - } - } - } - } - - // Returns true when one of the rows already contains all the pairs - private static boolean isPartialRow(Iterable pairs, Iterable rows) { - for (ExpandedRow r : rows) { - boolean allFound = true; - for (ExpandedPair p : pairs) { - boolean found = false; - for (ExpandedPair pp : r.getPairs()) { - if (p.equals(pp)) { - found = true; - break; - } - } - if (!found) { - allFound = false; - break; - } - } - if (allFound) { - // the row 'r' contain all the pairs from 'pairs' - return true; - } - } - return false; - } - - // Only used for unit testing - List getRows() { - return this.rows; - } - - // Not private for unit testing - static Result constructResult(List pairs) throws NotFoundException, FormatException { - BitArray binary = BitArrayBuilder.buildBitArray(pairs); - - AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(binary); - String resultingString = decoder.parseInformation(); - - ResultPoint[] firstPoints = pairs.get(0).getFinderPattern().getResultPoints(); - ResultPoint[] lastPoints = pairs.get(pairs.size() - 1).getFinderPattern().getResultPoints(); - - Result result = new Result( - resultingString, - null, - new ResultPoint[]{firstPoints[0], firstPoints[1], lastPoints[0], lastPoints[1]}, - BarcodeFormat.RSS_EXPANDED - ); - result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]e0"); - return result; - } - - private boolean checkChecksum() { - ExpandedPair firstPair = this.pairs.get(0); - DataCharacter checkCharacter = firstPair.getLeftChar(); - DataCharacter firstCharacter = firstPair.getRightChar(); - - if (firstCharacter == null) { - return false; - } - - int checksum = firstCharacter.getChecksumPortion(); - int s = 2; - - for (int i = 1; i < this.pairs.size(); ++i) { - ExpandedPair currentPair = this.pairs.get(i); - checksum += currentPair.getLeftChar().getChecksumPortion(); - s++; - DataCharacter currentRightChar = currentPair.getRightChar(); - if (currentRightChar != null) { - checksum += currentRightChar.getChecksumPortion(); - s++; - } - } - - checksum %= 211; - - int checkCharacterValue = 211 * (s - 4) + checksum; - - return checkCharacterValue == checkCharacter.getValue(); - } - - private static int getNextSecondBar(BitArray row, int initialPos) { - int currentPos; - if (row.get(initialPos)) { - currentPos = row.getNextUnset(initialPos); - currentPos = row.getNextSet(currentPos); - } else { - currentPos = row.getNextSet(initialPos); - currentPos = row.getNextUnset(currentPos); - } - return currentPos; - } - - // not private for testing - ExpandedPair retrieveNextPair(BitArray row, List previousPairs, int rowNumber) - throws NotFoundException { - boolean isOddPattern = previousPairs.size() % 2 == 0; - if (startFromEven) { - isOddPattern = !isOddPattern; - } - - FinderPattern pattern; - - boolean keepFinding = true; - int forcedOffset = -1; - do { - this.findNextPair(row, previousPairs, forcedOffset); - pattern = parseFoundFinderPattern(row, rowNumber, isOddPattern); - if (pattern == null) { - forcedOffset = getNextSecondBar(row, this.startEnd[0]); - } else { - keepFinding = false; - } - } while (keepFinding); - - // When stacked symbol is split over multiple rows, there's no way to guess if this pair can be last or not. - // boolean mayBeLast = checkPairSequence(previousPairs, pattern); - - DataCharacter leftChar = this.decodeDataCharacter(row, pattern, isOddPattern, true); - - if (!previousPairs.isEmpty() && previousPairs.get(previousPairs.size() - 1).mustBeLast()) { - throw NotFoundException.getNotFoundInstance(); - } - - DataCharacter rightChar; - try { - rightChar = this.decodeDataCharacter(row, pattern, isOddPattern, false); - } catch (NotFoundException ignored) { - rightChar = null; - } - return new ExpandedPair(leftChar, rightChar, pattern); - } - - private void findNextPair(BitArray row, List previousPairs, int forcedOffset) - throws NotFoundException { - int[] counters = this.getDecodeFinderCounters(); - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - - int width = row.getSize(); - - int rowOffset; - if (forcedOffset >= 0) { - rowOffset = forcedOffset; - } else if (previousPairs.isEmpty()) { - rowOffset = 0; - } else { - ExpandedPair lastPair = previousPairs.get(previousPairs.size() - 1); - rowOffset = lastPair.getFinderPattern().getStartEnd()[1]; - } - boolean searchingEvenPair = previousPairs.size() % 2 != 0; - if (startFromEven) { - searchingEvenPair = !searchingEvenPair; - } - - boolean isWhite = false; - while (rowOffset < width) { - isWhite = !row.get(rowOffset); - if (!isWhite) { - break; - } - rowOffset++; - } - - int counterPosition = 0; - int patternStart = rowOffset; - for (int x = rowOffset; x < width; x++) { - if (row.get(x) != isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == 3) { - if (searchingEvenPair) { - reverseCounters(counters); - } - - if (isFinderPattern(counters)) { - this.startEnd[0] = patternStart; - this.startEnd[1] = x; - return; - } - - if (searchingEvenPair) { - reverseCounters(counters); - } - - patternStart += counters[0] + counters[1]; - counters[0] = counters[2]; - counters[1] = counters[3]; - counters[2] = 0; - counters[3] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - throw NotFoundException.getNotFoundInstance(); - } - - private static void reverseCounters(int [] counters) { - int length = counters.length; - for (int i = 0; i < length / 2; ++i) { - int tmp = counters[i]; - counters[i] = counters[length - i - 1]; - counters[length - i - 1] = tmp; - } - } - - private FinderPattern parseFoundFinderPattern(BitArray row, int rowNumber, boolean oddPattern) { - // Actually we found elements 2-5. - int firstCounter; - int start; - int end; - - if (oddPattern) { - // If pattern number is odd, we need to locate element 1 *before* the current block. - - int firstElementStart = this.startEnd[0] - 1; - // Locate element 1 - while (firstElementStart >= 0 && !row.get(firstElementStart)) { - firstElementStart--; - } - - firstElementStart++; - firstCounter = this.startEnd[0] - firstElementStart; - start = firstElementStart; - end = this.startEnd[1]; - - } else { - // If pattern number is even, the pattern is reversed, so we need to locate element 1 *after* the current block. - - start = this.startEnd[0]; - - end = row.getNextUnset(this.startEnd[1] + 1); - firstCounter = end - this.startEnd[1]; - } - - // Make 'counters' hold 1-4 - int [] counters = this.getDecodeFinderCounters(); - System.arraycopy(counters, 0, counters, 1, counters.length - 1); - - counters[0] = firstCounter; - int value; - try { - value = parseFinderValue(counters, FINDER_PATTERNS); - } catch (NotFoundException ignored) { - return null; - } - return new FinderPattern(value, new int[] {start, end}, start, end, rowNumber); - } - - DataCharacter decodeDataCharacter(BitArray row, - FinderPattern pattern, - boolean isOddPattern, - boolean leftChar) throws NotFoundException { - int[] counters = this.getDataCharacterCounters(); - Arrays.fill(counters, 0); - - if (leftChar) { - recordPatternInReverse(row, pattern.getStartEnd()[0], counters); - } else { - recordPattern(row, pattern.getStartEnd()[1], counters); - // reverse it - for (int i = 0, j = counters.length - 1; i < j; i++, j--) { - int temp = counters[i]; - counters[i] = counters[j]; - counters[j] = temp; - } - } //counters[] has the pixels of the module - - int numModules = 17; //left and right data characters have all the same length - float elementWidth = MathUtils.sum(counters) / (float) numModules; - - // Sanity check: element width for pattern and the character should match - float expectedElementWidth = (pattern.getStartEnd()[1] - pattern.getStartEnd()[0]) / 15.0f; - if (Math.abs(elementWidth - expectedElementWidth) / expectedElementWidth > 0.3f) { - throw NotFoundException.getNotFoundInstance(); - } - - int[] oddCounts = this.getOddCounts(); - int[] evenCounts = this.getEvenCounts(); - float[] oddRoundingErrors = this.getOddRoundingErrors(); - float[] evenRoundingErrors = this.getEvenRoundingErrors(); - - for (int i = 0; i < counters.length; i++) { - float value = 1.0f * counters[i] / elementWidth; - int count = (int) (value + 0.5f); // Round - if (count < 1) { - if (value < 0.3f) { - throw NotFoundException.getNotFoundInstance(); - } - count = 1; - } else if (count > 8) { - if (value > 8.7f) { - throw NotFoundException.getNotFoundInstance(); - } - count = 8; - } - int offset = i / 2; - if ((i & 0x01) == 0) { - oddCounts[offset] = count; - oddRoundingErrors[offset] = value - count; - } else { - evenCounts[offset] = count; - evenRoundingErrors[offset] = value - count; - } - } - - adjustOddEvenCounts(numModules); - - int weightRowNumber = 4 * pattern.getValue() + (isOddPattern ? 0 : 2) + (leftChar ? 0 : 1) - 1; - - int oddSum = 0; - int oddChecksumPortion = 0; - for (int i = oddCounts.length - 1; i >= 0; i--) { - if (isNotA1left(pattern, isOddPattern, leftChar)) { - int weight = WEIGHTS[weightRowNumber][2 * i]; - oddChecksumPortion += oddCounts[i] * weight; - } - oddSum += oddCounts[i]; - } - int evenChecksumPortion = 0; - for (int i = evenCounts.length - 1; i >= 0; i--) { - if (isNotA1left(pattern, isOddPattern, leftChar)) { - int weight = WEIGHTS[weightRowNumber][2 * i + 1]; - evenChecksumPortion += evenCounts[i] * weight; - } - } - int checksumPortion = oddChecksumPortion + evenChecksumPortion; - - if ((oddSum & 0x01) != 0 || oddSum > 13 || oddSum < 4) { - throw NotFoundException.getNotFoundInstance(); - } - - int group = (13 - oddSum) / 2; - int oddWidest = SYMBOL_WIDEST[group]; - int evenWidest = 9 - oddWidest; - int vOdd = RSSUtils.getRSSvalue(oddCounts, oddWidest, true); - int vEven = RSSUtils.getRSSvalue(evenCounts, evenWidest, false); - int tEven = EVEN_TOTAL_SUBSET[group]; - int gSum = GSUM[group]; - int value = vOdd * tEven + vEven + gSum; - - return new DataCharacter(value, checksumPortion); - } - - private static boolean isNotA1left(FinderPattern pattern, boolean isOddPattern, boolean leftChar) { - // A1: pattern.getValue is 0 (A), and it's an oddPattern, and it is a left char - return !(pattern.getValue() == 0 && isOddPattern && leftChar); - } - - private void adjustOddEvenCounts(int numModules) throws NotFoundException { - - int oddSum = MathUtils.sum(this.getOddCounts()); - int evenSum = MathUtils.sum(this.getEvenCounts()); - - boolean incrementOdd = false; - boolean decrementOdd = false; - - if (oddSum > 13) { - decrementOdd = true; - } else if (oddSum < 4) { - incrementOdd = true; - } - boolean incrementEven = false; - boolean decrementEven = false; - if (evenSum > 13) { - decrementEven = true; - } else if (evenSum < 4) { - incrementEven = true; - } - - int mismatch = oddSum + evenSum - numModules; - boolean oddParityBad = (oddSum & 0x01) == 1; - boolean evenParityBad = (evenSum & 0x01) == 0; - switch (mismatch) { - case 1: - if (oddParityBad) { - if (evenParityBad) { - throw NotFoundException.getNotFoundInstance(); - } - decrementOdd = true; - } else { - if (!evenParityBad) { - throw NotFoundException.getNotFoundInstance(); - } - decrementEven = true; - } - break; - case -1: - if (oddParityBad) { - if (evenParityBad) { - throw NotFoundException.getNotFoundInstance(); - } - incrementOdd = true; - } else { - if (!evenParityBad) { - throw NotFoundException.getNotFoundInstance(); - } - incrementEven = true; - } - break; - case 0: - if (oddParityBad) { - if (!evenParityBad) { - throw NotFoundException.getNotFoundInstance(); - } - // Both bad - if (oddSum < evenSum) { - incrementOdd = true; - decrementEven = true; - } else { - decrementOdd = true; - incrementEven = true; - } - } else { - if (evenParityBad) { - throw NotFoundException.getNotFoundInstance(); - } - // Nothing to do! - } - break; - default: - throw NotFoundException.getNotFoundInstance(); - } - - if (incrementOdd) { - if (decrementOdd) { - throw NotFoundException.getNotFoundInstance(); - } - increment(this.getOddCounts(), this.getOddRoundingErrors()); - } - if (decrementOdd) { - decrement(this.getOddCounts(), this.getOddRoundingErrors()); - } - if (incrementEven) { - if (decrementEven) { - throw NotFoundException.getNotFoundInstance(); - } - increment(this.getEvenCounts(), this.getOddRoundingErrors()); - } - if (decrementEven) { - decrement(this.getEvenCounts(), this.getEvenRoundingErrors()); - } - } -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/AI013103decoder.java b/port_src/core/DONE/oned/rss/expanded/decoders/AI013103decoder.java deleted file mode 100644 index 759cf96..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/AI013103decoder.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.common.BitArray; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -final class AI013103decoder extends AI013x0xDecoder { - - AI013103decoder(BitArray information) { - super(information); - } - - @Override - protected void addWeightCode(StringBuilder buf, int weight) { - buf.append("(3103)"); - } - - @Override - protected int checkWeight(int weight) { - return weight; - } -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/AI01320xDecoder.java b/port_src/core/DONE/oned/rss/expanded/decoders/AI01320xDecoder.java deleted file mode 100644 index eb50f7a..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/AI01320xDecoder.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.common.BitArray; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -final class AI01320xDecoder extends AI013x0xDecoder { - - AI01320xDecoder(BitArray information) { - super(information); - } - - @Override - protected void addWeightCode(StringBuilder buf, int weight) { - if (weight < 10000) { - buf.append("(3202)"); - } else { - buf.append("(3203)"); - } - } - - @Override - protected int checkWeight(int weight) { - if (weight < 10000) { - return weight; - } - return weight - 10000; - } - -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/AI01392xDecoder.java b/port_src/core/DONE/oned/rss/expanded/decoders/AI01392xDecoder.java deleted file mode 100644 index 9ea5bba..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/AI01392xDecoder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.common.BitArray; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -final class AI01392xDecoder extends AI01decoder { - - private static final int HEADER_SIZE = 5 + 1 + 2; - private static final int LAST_DIGIT_SIZE = 2; - - AI01392xDecoder(BitArray information) { - super(information); - } - - @Override - public String parseInformation() throws NotFoundException, FormatException { - if (this.getInformation().getSize() < HEADER_SIZE + GTIN_SIZE) { - throw NotFoundException.getNotFoundInstance(); - } - - StringBuilder buf = new StringBuilder(); - - encodeCompressedGtin(buf, HEADER_SIZE); - - int lastAIdigit = - this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE); - buf.append("(392"); - buf.append(lastAIdigit); - buf.append(')'); - - DecodedInformation decodedInformation = - this.getGeneralDecoder().decodeGeneralPurposeField(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, null); - buf.append(decodedInformation.getNewString()); - - return buf.toString(); - } - -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/AI01393xDecoder.java b/port_src/core/DONE/oned/rss/expanded/decoders/AI01393xDecoder.java deleted file mode 100644 index 0767a96..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/AI01393xDecoder.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.common.BitArray; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -final class AI01393xDecoder extends AI01decoder { - - private static final int HEADER_SIZE = 5 + 1 + 2; - private static final int LAST_DIGIT_SIZE = 2; - private static final int FIRST_THREE_DIGITS_SIZE = 10; - - AI01393xDecoder(BitArray information) { - super(information); - } - - @Override - public String parseInformation() throws NotFoundException, FormatException { - if (this.getInformation().getSize() < HEADER_SIZE + GTIN_SIZE) { - throw NotFoundException.getNotFoundInstance(); - } - - StringBuilder buf = new StringBuilder(); - - encodeCompressedGtin(buf, HEADER_SIZE); - - int lastAIdigit = - this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE); - - buf.append("(393"); - buf.append(lastAIdigit); - buf.append(')'); - - int firstThreeDigits = this.getGeneralDecoder().extractNumericValueFromBitArray( - HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, FIRST_THREE_DIGITS_SIZE); - if (firstThreeDigits / 100 == 0) { - buf.append('0'); - } - if (firstThreeDigits / 10 == 0) { - buf.append('0'); - } - buf.append(firstThreeDigits); - - DecodedInformation generalInformation = this.getGeneralDecoder().decodeGeneralPurposeField( - HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE + FIRST_THREE_DIGITS_SIZE, null); - buf.append(generalInformation.getNewString()); - - return buf.toString(); - } -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/AI013x0x1xDecoder.java b/port_src/core/DONE/oned/rss/expanded/decoders/AI013x0x1xDecoder.java deleted file mode 100644 index b8e406a..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/AI013x0x1xDecoder.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.NotFoundException; -import com.google.zxing.common.BitArray; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -final class AI013x0x1xDecoder extends AI01weightDecoder { - - private static final int HEADER_SIZE = 7 + 1; - private static final int WEIGHT_SIZE = 20; - private static final int DATE_SIZE = 16; - - private final String dateCode; - private final String firstAIdigits; - - AI013x0x1xDecoder(BitArray information, String firstAIdigits, String dateCode) { - super(information); - this.dateCode = dateCode; - this.firstAIdigits = firstAIdigits; - } - - @Override - public String parseInformation() throws NotFoundException { - if (this.getInformation().getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE + DATE_SIZE) { - throw NotFoundException.getNotFoundInstance(); - } - - StringBuilder buf = new StringBuilder(); - - encodeCompressedGtin(buf, HEADER_SIZE); - encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); - encodeCompressedDate(buf, HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE); - - return buf.toString(); - } - - private void encodeCompressedDate(StringBuilder buf, int currentPos) { - int numericDate = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, DATE_SIZE); - if (numericDate == 38400) { - return; - } - - buf.append('('); - buf.append(this.dateCode); - buf.append(')'); - - int day = numericDate % 32; - numericDate /= 32; - int month = numericDate % 12 + 1; - numericDate /= 12; - int year = numericDate; - - if (year / 10 == 0) { - buf.append('0'); - } - buf.append(year); - if (month / 10 == 0) { - buf.append('0'); - } - buf.append(month); - if (day / 10 == 0) { - buf.append('0'); - } - buf.append(day); - } - - @Override - protected void addWeightCode(StringBuilder buf, int weight) { - buf.append('('); - buf.append(this.firstAIdigits); - buf.append(weight / 100000); - buf.append(')'); - } - - @Override - protected int checkWeight(int weight) { - return weight % 100000; - } -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/AI013x0xDecoder.java b/port_src/core/DONE/oned/rss/expanded/decoders/AI013x0xDecoder.java deleted file mode 100644 index 54d32d6..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/AI013x0xDecoder.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.NotFoundException; -import com.google.zxing.common.BitArray; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -abstract class AI013x0xDecoder extends AI01weightDecoder { - - private static final int HEADER_SIZE = 4 + 1; - private static final int WEIGHT_SIZE = 15; - - AI013x0xDecoder(BitArray information) { - super(information); - } - - @Override - public String parseInformation() throws NotFoundException { - if (this.getInformation().getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE) { - throw NotFoundException.getNotFoundInstance(); - } - - StringBuilder buf = new StringBuilder(); - - encodeCompressedGtin(buf, HEADER_SIZE); - encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); - - return buf.toString(); - } -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/AI01AndOtherAIs.java b/port_src/core/DONE/oned/rss/expanded/decoders/AI01AndOtherAIs.java deleted file mode 100644 index 27222a3..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/AI01AndOtherAIs.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.common.BitArray; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -final class AI01AndOtherAIs extends AI01decoder { - - private static final int HEADER_SIZE = 1 + 1 + 2; //first bit encodes the linkage flag, - //the second one is the encodation method, and the other two are for the variable length - AI01AndOtherAIs(BitArray information) { - super(information); - } - - @Override - public String parseInformation() throws NotFoundException, FormatException { - StringBuilder buff = new StringBuilder(); - - buff.append("(01)"); - int initialGtinPosition = buff.length(); - int firstGtinDigit = this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE, 4); - buff.append(firstGtinDigit); - - this.encodeCompressedGtinWithoutAI(buff, HEADER_SIZE + 4, initialGtinPosition); - - return this.getGeneralDecoder().decodeAllCodes(buff, HEADER_SIZE + 44); - } -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/AI01decoder.java b/port_src/core/DONE/oned/rss/expanded/decoders/AI01decoder.java deleted file mode 100644 index 0034500..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/AI01decoder.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.common.BitArray; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -abstract class AI01decoder extends AbstractExpandedDecoder { - - static final int GTIN_SIZE = 40; - - AI01decoder(BitArray information) { - super(information); - } - - final void encodeCompressedGtin(StringBuilder buf, int currentPos) { - buf.append("(01)"); - int initialPosition = buf.length(); - buf.append('9'); - - encodeCompressedGtinWithoutAI(buf, currentPos, initialPosition); - } - - final void encodeCompressedGtinWithoutAI(StringBuilder buf, int currentPos, int initialBufferPosition) { - for (int i = 0; i < 4; ++i) { - int currentBlock = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos + 10 * i, 10); - if (currentBlock / 100 == 0) { - buf.append('0'); - } - if (currentBlock / 10 == 0) { - buf.append('0'); - } - buf.append(currentBlock); - } - - appendCheckDigit(buf, initialBufferPosition); - } - - private static void appendCheckDigit(StringBuilder buf, int currentPos) { - int checkDigit = 0; - for (int i = 0; i < 13; i++) { - int digit = buf.charAt(i + currentPos) - '0'; - checkDigit += (i & 0x01) == 0 ? 3 * digit : digit; - } - - checkDigit = 10 - (checkDigit % 10); - if (checkDigit == 10) { - checkDigit = 0; - } - - buf.append(checkDigit); - } - -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/AI01weightDecoder.java b/port_src/core/DONE/oned/rss/expanded/decoders/AI01weightDecoder.java deleted file mode 100644 index 96f9464..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/AI01weightDecoder.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.common.BitArray; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -abstract class AI01weightDecoder extends AI01decoder { - - AI01weightDecoder(BitArray information) { - super(information); - } - - final void encodeCompressedWeight(StringBuilder buf, int currentPos, int weightSize) { - int originalWeightNumeric = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, weightSize); - addWeightCode(buf, originalWeightNumeric); - - int weightNumeric = checkWeight(originalWeightNumeric); - - int currentDivisor = 100000; - for (int i = 0; i < 5; ++i) { - if (weightNumeric / currentDivisor == 0) { - buf.append('0'); - } - currentDivisor /= 10; - } - buf.append(weightNumeric); - } - - protected abstract void addWeightCode(StringBuilder buf, int weight); - - protected abstract int checkWeight(int weight); - -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/AbstractExpandedDecoder.java b/port_src/core/DONE/oned/rss/expanded/decoders/AbstractExpandedDecoder.java deleted file mode 100644 index 771b42b..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/AbstractExpandedDecoder.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.common.BitArray; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -public abstract class AbstractExpandedDecoder { - - private final BitArray information; - private final GeneralAppIdDecoder generalDecoder; - - AbstractExpandedDecoder(BitArray information) { - this.information = information; - this.generalDecoder = new GeneralAppIdDecoder(information); - } - - protected final BitArray getInformation() { - return information; - } - - protected final GeneralAppIdDecoder getGeneralDecoder() { - return generalDecoder; - } - - public abstract String parseInformation() throws NotFoundException, FormatException; - - public static AbstractExpandedDecoder createDecoder(BitArray information) { - if (information.get(1)) { - return new AI01AndOtherAIs(information); - } - if (!information.get(2)) { - return new AnyAIDecoder(information); - } - - int fourBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 4); - - switch (fourBitEncodationMethod) { - case 4: return new AI013103decoder(information); - case 5: return new AI01320xDecoder(information); - } - - int fiveBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 5); - switch (fiveBitEncodationMethod) { - case 12: return new AI01392xDecoder(information); - case 13: return new AI01393xDecoder(information); - } - - int sevenBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 7); - switch (sevenBitEncodationMethod) { - case 56: return new AI013x0x1xDecoder(information, "310", "11"); - case 57: return new AI013x0x1xDecoder(information, "320", "11"); - case 58: return new AI013x0x1xDecoder(information, "310", "13"); - case 59: return new AI013x0x1xDecoder(information, "320", "13"); - case 60: return new AI013x0x1xDecoder(information, "310", "15"); - case 61: return new AI013x0x1xDecoder(information, "320", "15"); - case 62: return new AI013x0x1xDecoder(information, "310", "17"); - case 63: return new AI013x0x1xDecoder(information, "320", "17"); - } - - throw new IllegalStateException("unknown decoder: " + information); - } - -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/AnyAIDecoder.java b/port_src/core/DONE/oned/rss/expanded/decoders/AnyAIDecoder.java deleted file mode 100644 index 2074d8f..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/AnyAIDecoder.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.common.BitArray; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -final class AnyAIDecoder extends AbstractExpandedDecoder { - - private static final int HEADER_SIZE = 2 + 1 + 2; - - AnyAIDecoder(BitArray information) { - super(information); - } - - @Override - public String parseInformation() throws NotFoundException, FormatException { - StringBuilder buf = new StringBuilder(); - return this.getGeneralDecoder().decodeAllCodes(buf, HEADER_SIZE); - } -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/BlockParsedResult.java b/port_src/core/DONE/oned/rss/expanded/decoders/BlockParsedResult.java deleted file mode 100644 index bff40b4..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/BlockParsedResult.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -final class BlockParsedResult { - - private final DecodedInformation decodedInformation; - private final boolean finished; - - BlockParsedResult() { - this(null, false); - } - - BlockParsedResult(DecodedInformation information, boolean finished) { - this.finished = finished; - this.decodedInformation = information; - } - - DecodedInformation getDecodedInformation() { - return this.decodedInformation; - } - - boolean isFinished() { - return this.finished; - } -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/CurrentParsingState.java b/port_src/core/DONE/oned/rss/expanded/decoders/CurrentParsingState.java deleted file mode 100644 index 34e92e1..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/CurrentParsingState.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -final class CurrentParsingState { - - private int position; - private State encoding; - - private enum State { - NUMERIC, - ALPHA, - ISO_IEC_646 - } - - CurrentParsingState() { - this.position = 0; - this.encoding = State.NUMERIC; - } - - int getPosition() { - return position; - } - - void setPosition(int position) { - this.position = position; - } - - void incrementPosition(int delta) { - position += delta; - } - - boolean isAlpha() { - return this.encoding == State.ALPHA; - } - - boolean isNumeric() { - return this.encoding == State.NUMERIC; - } - - boolean isIsoIec646() { - return this.encoding == State.ISO_IEC_646; - } - - void setNumeric() { - this.encoding = State.NUMERIC; - } - - void setAlpha() { - this.encoding = State.ALPHA; - } - - void setIsoIec646() { - this.encoding = State.ISO_IEC_646; - } -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/DecodedChar.java b/port_src/core/DONE/oned/rss/expanded/decoders/DecodedChar.java deleted file mode 100644 index 2dd8995..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/DecodedChar.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -final class DecodedChar extends DecodedObject { - - private final char value; - - static final char FNC1 = '$'; // It's not in Alphanumeric neither in ISO/IEC 646 charset - - DecodedChar(int newPosition, char value) { - super(newPosition); - this.value = value; - } - - char getValue() { - return this.value; - } - - boolean isFNC1() { - return this.value == FNC1; - } - -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/DecodedInformation.java b/port_src/core/DONE/oned/rss/expanded/decoders/DecodedInformation.java deleted file mode 100644 index 0ed90fd..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/DecodedInformation.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -final class DecodedInformation extends DecodedObject { - - private final String newString; - private final int remainingValue; - private final boolean remaining; - - DecodedInformation(int newPosition, String newString) { - super(newPosition); - this.newString = newString; - this.remaining = false; - this.remainingValue = 0; - } - - DecodedInformation(int newPosition, String newString, int remainingValue) { - super(newPosition); - this.remaining = true; - this.remainingValue = remainingValue; - this.newString = newString; - } - - String getNewString() { - return this.newString; - } - - boolean isRemaining() { - return this.remaining; - } - - int getRemainingValue() { - return this.remainingValue; - } -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/DecodedNumeric.java b/port_src/core/DONE/oned/rss/expanded/decoders/DecodedNumeric.java deleted file mode 100644 index 7b8f25a..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/DecodedNumeric.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.FormatException; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -final class DecodedNumeric extends DecodedObject { - - private final int firstDigit; - private final int secondDigit; - - static final int FNC1 = 10; - - DecodedNumeric(int newPosition, int firstDigit, int secondDigit) throws FormatException { - super(newPosition); - - if (firstDigit < 0 || firstDigit > 10 || secondDigit < 0 || secondDigit > 10) { - throw FormatException.getFormatInstance(); - } - - this.firstDigit = firstDigit; - this.secondDigit = secondDigit; - } - - int getFirstDigit() { - return this.firstDigit; - } - - int getSecondDigit() { - return this.secondDigit; - } - - int getValue() { - return this.firstDigit * 10 + this.secondDigit; - } - - boolean isFirstDigitFNC1() { - return this.firstDigit == FNC1; - } - - boolean isSecondDigitFNC1() { - return this.secondDigit == FNC1; - } - -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/DecodedObject.java b/port_src/core/DONE/oned/rss/expanded/decoders/DecodedObject.java deleted file mode 100644 index cf7d7da..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/DecodedObject.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -abstract class DecodedObject { - - private final int newPosition; - - DecodedObject(int newPosition) { - this.newPosition = newPosition; - } - - final int getNewPosition() { - return this.newPosition; - } - -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/FieldParser.java b/port_src/core/DONE/oned/rss/expanded/decoders/FieldParser.java deleted file mode 100644 index 13206bc..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/FieldParser.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.NotFoundException; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -final class FieldParser { - - private static final Map TWO_DIGIT_DATA_LENGTH = new HashMap<>(); - static { - TWO_DIGIT_DATA_LENGTH.put("00", DataLength.fixed(18)); - TWO_DIGIT_DATA_LENGTH.put("01", DataLength.fixed(14)); - TWO_DIGIT_DATA_LENGTH.put("02", DataLength.fixed(14)); - TWO_DIGIT_DATA_LENGTH.put("10", DataLength.variable(20)); - TWO_DIGIT_DATA_LENGTH.put("11", DataLength.fixed(6)); - TWO_DIGIT_DATA_LENGTH.put("12", DataLength.fixed(6)); - TWO_DIGIT_DATA_LENGTH.put("13", DataLength.fixed(6)); - TWO_DIGIT_DATA_LENGTH.put("15", DataLength.fixed(6)); - TWO_DIGIT_DATA_LENGTH.put("17", DataLength.fixed(6)); - TWO_DIGIT_DATA_LENGTH.put("20", DataLength.fixed(2)); - TWO_DIGIT_DATA_LENGTH.put("21", DataLength.variable(20)); - TWO_DIGIT_DATA_LENGTH.put("22", DataLength.variable(29)); - TWO_DIGIT_DATA_LENGTH.put("30", DataLength.variable(8)); - TWO_DIGIT_DATA_LENGTH.put("37", DataLength.variable(8)); - //internal company codes - for (int i = 90; i <= 99; i++) { - TWO_DIGIT_DATA_LENGTH.put(String.valueOf(i), DataLength.variable(30)); - } - } - - private static final Map THREE_DIGIT_DATA_LENGTH = new HashMap<>(); - static { - THREE_DIGIT_DATA_LENGTH.put("240", DataLength.variable(30)); - THREE_DIGIT_DATA_LENGTH.put("241", DataLength.variable(30)); - THREE_DIGIT_DATA_LENGTH.put("242", DataLength.variable(6)); - THREE_DIGIT_DATA_LENGTH.put("250", DataLength.variable(30)); - THREE_DIGIT_DATA_LENGTH.put("251", DataLength.variable(30)); - THREE_DIGIT_DATA_LENGTH.put("253", DataLength.variable(17)); - THREE_DIGIT_DATA_LENGTH.put("254", DataLength.variable(20)); - THREE_DIGIT_DATA_LENGTH.put("400", DataLength.variable(30)); - THREE_DIGIT_DATA_LENGTH.put("401", DataLength.variable(30)); - THREE_DIGIT_DATA_LENGTH.put("402", DataLength.fixed(17)); - THREE_DIGIT_DATA_LENGTH.put("403", DataLength.variable(30)); - THREE_DIGIT_DATA_LENGTH.put("410", DataLength.fixed(13)); - THREE_DIGIT_DATA_LENGTH.put("411", DataLength.fixed(13)); - THREE_DIGIT_DATA_LENGTH.put("412", DataLength.fixed(13)); - THREE_DIGIT_DATA_LENGTH.put("413", DataLength.fixed(13)); - THREE_DIGIT_DATA_LENGTH.put("414", DataLength.fixed(13)); - THREE_DIGIT_DATA_LENGTH.put("420", DataLength.variable(20)); - THREE_DIGIT_DATA_LENGTH.put("421", DataLength.variable(15)); - THREE_DIGIT_DATA_LENGTH.put("422", DataLength.fixed(3)); - THREE_DIGIT_DATA_LENGTH.put("423", DataLength.variable(15)); - THREE_DIGIT_DATA_LENGTH.put("424", DataLength.fixed(3)); - THREE_DIGIT_DATA_LENGTH.put("425", DataLength.fixed(3)); - THREE_DIGIT_DATA_LENGTH.put("426", DataLength.fixed(3)); - } - - private static final Map THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH = new HashMap<>(); - static { - for (int i = 310; i <= 316; i++) { - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH.put(String.valueOf(i), DataLength.fixed(6)); - } - for (int i = 320; i <= 336; i++) { - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH.put(String.valueOf(i), DataLength.fixed(6)); - } - for (int i = 340; i <= 357; i++) { - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH.put(String.valueOf(i), DataLength.fixed(6)); - } - for (int i = 360; i <= 369; i++) { - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH.put(String.valueOf(i), DataLength.fixed(6)); - } - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH.put("390", DataLength.variable(15)); - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH.put("391", DataLength.variable(18)); - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH.put("392", DataLength.variable(15)); - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH.put("393", DataLength.variable(18)); - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH.put("703", DataLength.variable(30)); - } - - private static final Map FOUR_DIGIT_DATA_LENGTH = new HashMap<>(); - static { - FOUR_DIGIT_DATA_LENGTH.put("7001", DataLength.fixed(13)); - FOUR_DIGIT_DATA_LENGTH.put("7002", DataLength.variable(30)); - FOUR_DIGIT_DATA_LENGTH.put("7003", DataLength.fixed(10)); - FOUR_DIGIT_DATA_LENGTH.put("8001", DataLength.fixed(14)); - FOUR_DIGIT_DATA_LENGTH.put("8002", DataLength.variable(20)); - FOUR_DIGIT_DATA_LENGTH.put("8003", DataLength.variable(30)); - FOUR_DIGIT_DATA_LENGTH.put("8004", DataLength.variable(30)); - FOUR_DIGIT_DATA_LENGTH.put("8005", DataLength.fixed(6)); - FOUR_DIGIT_DATA_LENGTH.put("8006", DataLength.fixed(18)); - FOUR_DIGIT_DATA_LENGTH.put("8007", DataLength.variable(30)); - FOUR_DIGIT_DATA_LENGTH.put("8008", DataLength.variable(12)); - FOUR_DIGIT_DATA_LENGTH.put("8018", DataLength.fixed(18)); - FOUR_DIGIT_DATA_LENGTH.put("8020", DataLength.variable(25)); - FOUR_DIGIT_DATA_LENGTH.put("8100", DataLength.fixed(6)); - FOUR_DIGIT_DATA_LENGTH.put("8101", DataLength.fixed(10)); - FOUR_DIGIT_DATA_LENGTH.put("8102", DataLength.fixed(2)); - FOUR_DIGIT_DATA_LENGTH.put("8110", DataLength.variable(70)); - FOUR_DIGIT_DATA_LENGTH.put("8200", DataLength.variable(70)); - } - - private FieldParser() { - } - - static String parseFieldsInGeneralPurpose(String rawInformation) throws NotFoundException { - if (rawInformation.isEmpty()) { - return null; - } - - // Processing 2-digit AIs - - if (rawInformation.length() < 2) { - throw NotFoundException.getNotFoundInstance(); - } - - DataLength twoDigitDataLength = TWO_DIGIT_DATA_LENGTH.get(rawInformation.substring(0, 2)); - if (twoDigitDataLength != null) { - if (twoDigitDataLength.variable) { - return processVariableAI(2, twoDigitDataLength.length, rawInformation); - } - return processFixedAI(2, twoDigitDataLength.length, rawInformation); - } - - if (rawInformation.length() < 3) { - throw NotFoundException.getNotFoundInstance(); - } - - String firstThreeDigits = rawInformation.substring(0, 3); - DataLength threeDigitDataLength = THREE_DIGIT_DATA_LENGTH.get(firstThreeDigits); - if (threeDigitDataLength != null) { - if (threeDigitDataLength.variable) { - return processVariableAI(3, threeDigitDataLength.length, rawInformation); - } - return processFixedAI(3, threeDigitDataLength.length, rawInformation); - } - - if (rawInformation.length() < 4) { - throw NotFoundException.getNotFoundInstance(); - } - - DataLength threeDigitPlusDigitDataLength = THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH.get(firstThreeDigits); - if (threeDigitPlusDigitDataLength != null) { - if (threeDigitPlusDigitDataLength.variable) { - return processVariableAI(4, threeDigitPlusDigitDataLength.length, rawInformation); - } - return processFixedAI(4, threeDigitPlusDigitDataLength.length, rawInformation); - } - - DataLength firstFourDigitLength = FOUR_DIGIT_DATA_LENGTH.get(rawInformation.substring(0, 4)); - if (firstFourDigitLength != null) { - if (firstFourDigitLength.variable) { - return processVariableAI(4, firstFourDigitLength.length, rawInformation); - } - return processFixedAI(4, firstFourDigitLength.length, rawInformation); - } - - throw NotFoundException.getNotFoundInstance(); - } - - private static String processFixedAI(int aiSize, int fieldSize, String rawInformation) throws NotFoundException { - if (rawInformation.length() < aiSize) { - throw NotFoundException.getNotFoundInstance(); - } - - String ai = rawInformation.substring(0, aiSize); - - if (rawInformation.length() < aiSize + fieldSize) { - throw NotFoundException.getNotFoundInstance(); - } - - String field = rawInformation.substring(aiSize, aiSize + fieldSize); - String remaining = rawInformation.substring(aiSize + fieldSize); - String result = '(' + ai + ')' + field; - String parsedAI = parseFieldsInGeneralPurpose(remaining); - return parsedAI == null ? result : result + parsedAI; - } - - private static String processVariableAI(int aiSize, int variableFieldSize, String rawInformation) - throws NotFoundException { - String ai = rawInformation.substring(0, aiSize); - int maxSize = Math.min(rawInformation.length(), aiSize + variableFieldSize); - String field = rawInformation.substring(aiSize, maxSize); - String remaining = rawInformation.substring(maxSize); - String result = '(' + ai + ')' + field; - String parsedAI = parseFieldsInGeneralPurpose(remaining); - return parsedAI == null ? result : result + parsedAI; - } - - private static final class DataLength { - - final boolean variable; - final int length; - - private DataLength(boolean variable, int length) { - this.variable = variable; - this.length = length; - } - - static DataLength fixed(int length) { - return new DataLength(false, length); - } - - static DataLength variable(int length) { - return new DataLength(true, length); - } - - } - -} diff --git a/port_src/core/DONE/oned/rss/expanded/decoders/GeneralAppIdDecoder.java b/port_src/core/DONE/oned/rss/expanded/decoders/GeneralAppIdDecoder.java deleted file mode 100644 index a128860..0000000 --- a/port_src/core/DONE/oned/rss/expanded/decoders/GeneralAppIdDecoder.java +++ /dev/null @@ -1,470 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.common.BitArray; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -final class GeneralAppIdDecoder { - - private final BitArray information; - private final CurrentParsingState current = new CurrentParsingState(); - private final StringBuilder buffer = new StringBuilder(); - - GeneralAppIdDecoder(BitArray information) { - this.information = information; - } - - String decodeAllCodes(StringBuilder buff, int initialPosition) throws NotFoundException, FormatException { - int currentPosition = initialPosition; - String remaining = null; - do { - DecodedInformation info = this.decodeGeneralPurposeField(currentPosition, remaining); - String parsedFields = FieldParser.parseFieldsInGeneralPurpose(info.getNewString()); - if (parsedFields != null) { - buff.append(parsedFields); - } - if (info.isRemaining()) { - remaining = String.valueOf(info.getRemainingValue()); - } else { - remaining = null; - } - - if (currentPosition == info.getNewPosition()) { // No step forward! - break; - } - currentPosition = info.getNewPosition(); - } while (true); - - return buff.toString(); - } - - private boolean isStillNumeric(int pos) { - // It's numeric if it still has 7 positions - // and one of the first 4 bits is "1". - if (pos + 7 > this.information.getSize()) { - return pos + 4 <= this.information.getSize(); - } - - for (int i = pos; i < pos + 3; ++i) { - if (this.information.get(i)) { - return true; - } - } - - return this.information.get(pos + 3); - } - - private DecodedNumeric decodeNumeric(int pos) throws FormatException { - if (pos + 7 > this.information.getSize()) { - int numeric = extractNumericValueFromBitArray(pos, 4); - if (numeric == 0) { - return new DecodedNumeric(this.information.getSize(), DecodedNumeric.FNC1, DecodedNumeric.FNC1); - } - return new DecodedNumeric(this.information.getSize(), numeric - 1, DecodedNumeric.FNC1); - } - int numeric = extractNumericValueFromBitArray(pos, 7); - - int digit1 = (numeric - 8) / 11; - int digit2 = (numeric - 8) % 11; - - return new DecodedNumeric(pos + 7, digit1, digit2); - } - - int extractNumericValueFromBitArray(int pos, int bits) { - return extractNumericValueFromBitArray(this.information, pos, bits); - } - - static int extractNumericValueFromBitArray(BitArray information, int pos, int bits) { - int value = 0; - for (int i = 0; i < bits; ++i) { - if (information.get(pos + i)) { - value |= 1 << (bits - i - 1); - } - } - - return value; - } - - DecodedInformation decodeGeneralPurposeField(int pos, String remaining) throws FormatException { - this.buffer.setLength(0); - - if (remaining != null) { - this.buffer.append(remaining); - } - - this.current.setPosition(pos); - - DecodedInformation lastDecoded = parseBlocks(); - if (lastDecoded != null && lastDecoded.isRemaining()) { - return new DecodedInformation(this.current.getPosition(), - this.buffer.toString(), lastDecoded.getRemainingValue()); - } - return new DecodedInformation(this.current.getPosition(), this.buffer.toString()); - } - - private DecodedInformation parseBlocks() throws FormatException { - boolean isFinished; - BlockParsedResult result; - do { - int initialPosition = current.getPosition(); - - if (current.isAlpha()) { - result = parseAlphaBlock(); - isFinished = result.isFinished(); - } else if (current.isIsoIec646()) { - result = parseIsoIec646Block(); - isFinished = result.isFinished(); - } else { // it must be numeric - result = parseNumericBlock(); - isFinished = result.isFinished(); - } - - boolean positionChanged = initialPosition != current.getPosition(); - if (!positionChanged && !isFinished) { - break; - } - } while (!isFinished); - - return result.getDecodedInformation(); - } - - private BlockParsedResult parseNumericBlock() throws FormatException { - while (isStillNumeric(current.getPosition())) { - DecodedNumeric numeric = decodeNumeric(current.getPosition()); - current.setPosition(numeric.getNewPosition()); - - if (numeric.isFirstDigitFNC1()) { - DecodedInformation information; - if (numeric.isSecondDigitFNC1()) { - information = new DecodedInformation(current.getPosition(), buffer.toString()); - } else { - information = new DecodedInformation(current.getPosition(), buffer.toString(), numeric.getSecondDigit()); - } - return new BlockParsedResult(information, true); - } - buffer.append(numeric.getFirstDigit()); - - if (numeric.isSecondDigitFNC1()) { - DecodedInformation information = new DecodedInformation(current.getPosition(), buffer.toString()); - return new BlockParsedResult(information, true); - } - buffer.append(numeric.getSecondDigit()); - } - - if (isNumericToAlphaNumericLatch(current.getPosition())) { - current.setAlpha(); - current.incrementPosition(4); - } - return new BlockParsedResult(); - } - - private BlockParsedResult parseIsoIec646Block() throws FormatException { - while (isStillIsoIec646(current.getPosition())) { - DecodedChar iso = decodeIsoIec646(current.getPosition()); - current.setPosition(iso.getNewPosition()); - - if (iso.isFNC1()) { - DecodedInformation information = new DecodedInformation(current.getPosition(), buffer.toString()); - return new BlockParsedResult(information, true); - } - buffer.append(iso.getValue()); - } - - if (isAlphaOr646ToNumericLatch(current.getPosition())) { - current.incrementPosition(3); - current.setNumeric(); - } else if (isAlphaTo646ToAlphaLatch(current.getPosition())) { - if (current.getPosition() + 5 < this.information.getSize()) { - current.incrementPosition(5); - } else { - current.setPosition(this.information.getSize()); - } - - current.setAlpha(); - } - return new BlockParsedResult(); - } - - private BlockParsedResult parseAlphaBlock() { - while (isStillAlpha(current.getPosition())) { - DecodedChar alpha = decodeAlphanumeric(current.getPosition()); - current.setPosition(alpha.getNewPosition()); - - if (alpha.isFNC1()) { - DecodedInformation information = new DecodedInformation(current.getPosition(), buffer.toString()); - return new BlockParsedResult(information, true); //end of the char block - } - - buffer.append(alpha.getValue()); - } - - if (isAlphaOr646ToNumericLatch(current.getPosition())) { - current.incrementPosition(3); - current.setNumeric(); - } else if (isAlphaTo646ToAlphaLatch(current.getPosition())) { - if (current.getPosition() + 5 < this.information.getSize()) { - current.incrementPosition(5); - } else { - current.setPosition(this.information.getSize()); - } - - current.setIsoIec646(); - } - return new BlockParsedResult(); - } - - private boolean isStillIsoIec646(int pos) { - if (pos + 5 > this.information.getSize()) { - return false; - } - - int fiveBitValue = extractNumericValueFromBitArray(pos, 5); - if (fiveBitValue >= 5 && fiveBitValue < 16) { - return true; - } - - if (pos + 7 > this.information.getSize()) { - return false; - } - - int sevenBitValue = extractNumericValueFromBitArray(pos, 7); - if (sevenBitValue >= 64 && sevenBitValue < 116) { - return true; - } - - if (pos + 8 > this.information.getSize()) { - return false; - } - - int eightBitValue = extractNumericValueFromBitArray(pos, 8); - return eightBitValue >= 232 && eightBitValue < 253; - - } - - private DecodedChar decodeIsoIec646(int pos) throws FormatException { - int fiveBitValue = extractNumericValueFromBitArray(pos, 5); - if (fiveBitValue == 15) { - return new DecodedChar(pos + 5, DecodedChar.FNC1); - } - - if (fiveBitValue >= 5 && fiveBitValue < 15) { - return new DecodedChar(pos + 5, (char) ('0' + fiveBitValue - 5)); - } - - int sevenBitValue = extractNumericValueFromBitArray(pos, 7); - - if (sevenBitValue >= 64 && sevenBitValue < 90) { - return new DecodedChar(pos + 7, (char) (sevenBitValue + 1)); - } - - if (sevenBitValue >= 90 && sevenBitValue < 116) { - return new DecodedChar(pos + 7, (char) (sevenBitValue + 7)); - } - - int eightBitValue = extractNumericValueFromBitArray(pos, 8); - char c; - switch (eightBitValue) { - case 232: - c = '!'; - break; - case 233: - c = '"'; - break; - case 234: - c = '%'; - break; - case 235: - c = '&'; - break; - case 236: - c = '\''; - break; - case 237: - c = '('; - break; - case 238: - c = ')'; - break; - case 239: - c = '*'; - break; - case 240: - c = '+'; - break; - case 241: - c = ','; - break; - case 242: - c = '-'; - break; - case 243: - c = '.'; - break; - case 244: - c = '/'; - break; - case 245: - c = ':'; - break; - case 246: - c = ';'; - break; - case 247: - c = '<'; - break; - case 248: - c = '='; - break; - case 249: - c = '>'; - break; - case 250: - c = '?'; - break; - case 251: - c = '_'; - break; - case 252: - c = ' '; - break; - default: - throw FormatException.getFormatInstance(); - } - return new DecodedChar(pos + 8, c); - } - - private boolean isStillAlpha(int pos) { - if (pos + 5 > this.information.getSize()) { - return false; - } - - // We now check if it's a valid 5-bit value (0..9 and FNC1) - int fiveBitValue = extractNumericValueFromBitArray(pos, 5); - if (fiveBitValue >= 5 && fiveBitValue < 16) { - return true; - } - - if (pos + 6 > this.information.getSize()) { - return false; - } - - int sixBitValue = extractNumericValueFromBitArray(pos, 6); - return sixBitValue >= 16 && sixBitValue < 63; // 63 not included - } - - private DecodedChar decodeAlphanumeric(int pos) { - int fiveBitValue = extractNumericValueFromBitArray(pos, 5); - if (fiveBitValue == 15) { - return new DecodedChar(pos + 5, DecodedChar.FNC1); - } - - if (fiveBitValue >= 5 && fiveBitValue < 15) { - return new DecodedChar(pos + 5, (char) ('0' + fiveBitValue - 5)); - } - - int sixBitValue = extractNumericValueFromBitArray(pos, 6); - - if (sixBitValue >= 32 && sixBitValue < 58) { - return new DecodedChar(pos + 6, (char) (sixBitValue + 33)); - } - - char c; - switch (sixBitValue) { - case 58: - c = '*'; - break; - case 59: - c = ','; - break; - case 60: - c = '-'; - break; - case 61: - c = '.'; - break; - case 62: - c = '/'; - break; - default: - throw new IllegalStateException("Decoding invalid alphanumeric value: " + sixBitValue); - } - return new DecodedChar(pos + 6, c); - } - - private boolean isAlphaTo646ToAlphaLatch(int pos) { - if (pos + 1 > this.information.getSize()) { - return false; - } - - for (int i = 0; i < 5 && i + pos < this.information.getSize(); ++i) { - if (i == 2) { - if (!this.information.get(pos + 2)) { - return false; - } - } else if (this.information.get(pos + i)) { - return false; - } - } - - return true; - } - - private boolean isAlphaOr646ToNumericLatch(int pos) { - // Next is alphanumeric if there are 3 positions and they are all zeros - if (pos + 3 > this.information.getSize()) { - return false; - } - - for (int i = pos; i < pos + 3; ++i) { - if (this.information.get(i)) { - return false; - } - } - return true; - } - - private boolean isNumericToAlphaNumericLatch(int pos) { - // Next is alphanumeric if there are 4 positions and they are all zeros, or - // if there is a subset of this just before the end of the symbol - if (pos + 1 > this.information.getSize()) { - return false; - } - - for (int i = 0; i < 4 && i + pos < this.information.getSize(); ++i) { - if (this.information.get(pos + i)) { - return false; - } - } - return true; - } -} diff --git a/port_src/core/DONE/pdf417/PDF417Common.java b/port_src/core/DONE/pdf417/PDF417Common.java deleted file mode 100644 index 5e7cafd..0000000 --- a/port_src/core/DONE/pdf417/PDF417Common.java +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.zxing.pdf417; - -import java.util.Arrays; -import java.util.Collection; - -import com.google.zxing.common.detector.MathUtils; - -/** - * @author SITA Lab (kevin.osullivan@sita.aero) - * @author Guenther Grau - */ -public final class PDF417Common { - - public static final int NUMBER_OF_CODEWORDS = 929; - // Maximum Codewords (Data + Error). - public static final int MAX_CODEWORDS_IN_BARCODE = NUMBER_OF_CODEWORDS - 1; - public static final int MIN_ROWS_IN_BARCODE = 3; - public static final int MAX_ROWS_IN_BARCODE = 90; - // One left row indication column + max 30 data columns + one right row indicator column - //public static final int MAX_CODEWORDS_IN_ROW = 32; - public static final int MODULES_IN_CODEWORD = 17; - public static final int MODULES_IN_STOP_PATTERN = 18; - public static final int BARS_IN_MODULE = 8; - - private static final int[] EMPTY_INT_ARRAY = {}; - - private PDF417Common() { - } - - /** - * @param moduleBitCount values to sum - * @return sum of values - * @deprecated call {@link MathUtils#sum(int[])} - */ - @Deprecated - public static int getBitCountSum(int[] moduleBitCount) { - return MathUtils.sum(moduleBitCount); - } - - public static int[] toIntArray(Collection list) { - if (list == null || list.isEmpty()) { - return EMPTY_INT_ARRAY; - } - int[] result = new int[list.size()]; - int i = 0; - for (Integer integer : list) { - result[i++] = integer; - } - return result; - } - - /** - * @param symbol encoded symbol to translate to a codeword - * @return the codeword corresponding to the symbol. - */ - public static int getCodeword(int symbol) { - int i = Arrays.binarySearch(SYMBOL_TABLE, symbol & 0x3FFFF); - if (i < 0) { - return -1; - } - return (CODEWORD_TABLE[i] - 1) % NUMBER_OF_CODEWORDS; - } - - /** - * The sorted table of all possible symbols. Extracted from the PDF417 - * specification. The index of a symbol in this table corresponds to the - * index into the codeword table. - */ - public static final int[] SYMBOL_TABLE = { - 0x1025e, 0x1027a, 0x1029e, 0x102bc, 0x102f2, 0x102f4, 0x1032e, 0x1034e, 0x1035c, 0x10396, 0x103a6, 0x103ac, - 0x10422, 0x10428, 0x10436, 0x10442, 0x10444, 0x10448, 0x10450, 0x1045e, 0x10466, 0x1046c, 0x1047a, 0x10482, - 0x1049e, 0x104a0, 0x104bc, 0x104c6, 0x104d8, 0x104ee, 0x104f2, 0x104f4, 0x10504, 0x10508, 0x10510, 0x1051e, - 0x10520, 0x1053c, 0x10540, 0x10578, 0x10586, 0x1058c, 0x10598, 0x105b0, 0x105be, 0x105ce, 0x105dc, 0x105e2, - 0x105e4, 0x105e8, 0x105f6, 0x1062e, 0x1064e, 0x1065c, 0x1068e, 0x1069c, 0x106b8, 0x106de, 0x106fa, 0x10716, - 0x10726, 0x1072c, 0x10746, 0x1074c, 0x10758, 0x1076e, 0x10792, 0x10794, 0x107a2, 0x107a4, 0x107a8, 0x107b6, - 0x10822, 0x10828, 0x10842, 0x10848, 0x10850, 0x1085e, 0x10866, 0x1086c, 0x1087a, 0x10882, 0x10884, 0x10890, - 0x1089e, 0x108a0, 0x108bc, 0x108c6, 0x108cc, 0x108d8, 0x108ee, 0x108f2, 0x108f4, 0x10902, 0x10908, 0x1091e, - 0x10920, 0x1093c, 0x10940, 0x10978, 0x10986, 0x10998, 0x109b0, 0x109be, 0x109ce, 0x109dc, 0x109e2, 0x109e4, - 0x109e8, 0x109f6, 0x10a08, 0x10a10, 0x10a1e, 0x10a20, 0x10a3c, 0x10a40, 0x10a78, 0x10af0, 0x10b06, 0x10b0c, - 0x10b18, 0x10b30, 0x10b3e, 0x10b60, 0x10b7c, 0x10b8e, 0x10b9c, 0x10bb8, 0x10bc2, 0x10bc4, 0x10bc8, 0x10bd0, - 0x10bde, 0x10be6, 0x10bec, 0x10c2e, 0x10c4e, 0x10c5c, 0x10c62, 0x10c64, 0x10c68, 0x10c76, 0x10c8e, 0x10c9c, - 0x10cb8, 0x10cc2, 0x10cc4, 0x10cc8, 0x10cd0, 0x10cde, 0x10ce6, 0x10cec, 0x10cfa, 0x10d0e, 0x10d1c, 0x10d38, - 0x10d70, 0x10d7e, 0x10d82, 0x10d84, 0x10d88, 0x10d90, 0x10d9e, 0x10da0, 0x10dbc, 0x10dc6, 0x10dcc, 0x10dd8, - 0x10dee, 0x10df2, 0x10df4, 0x10e16, 0x10e26, 0x10e2c, 0x10e46, 0x10e58, 0x10e6e, 0x10e86, 0x10e8c, 0x10e98, - 0x10eb0, 0x10ebe, 0x10ece, 0x10edc, 0x10f0a, 0x10f12, 0x10f14, 0x10f22, 0x10f28, 0x10f36, 0x10f42, 0x10f44, - 0x10f48, 0x10f50, 0x10f5e, 0x10f66, 0x10f6c, 0x10fb2, 0x10fb4, 0x11022, 0x11028, 0x11042, 0x11048, 0x11050, - 0x1105e, 0x1107a, 0x11082, 0x11084, 0x11090, 0x1109e, 0x110a0, 0x110bc, 0x110c6, 0x110cc, 0x110d8, 0x110ee, - 0x110f2, 0x110f4, 0x11102, 0x1111e, 0x11120, 0x1113c, 0x11140, 0x11178, 0x11186, 0x11198, 0x111b0, 0x111be, - 0x111ce, 0x111dc, 0x111e2, 0x111e4, 0x111e8, 0x111f6, 0x11208, 0x1121e, 0x11220, 0x11278, 0x112f0, 0x1130c, - 0x11330, 0x1133e, 0x11360, 0x1137c, 0x1138e, 0x1139c, 0x113b8, 0x113c2, 0x113c8, 0x113d0, 0x113de, 0x113e6, - 0x113ec, 0x11408, 0x11410, 0x1141e, 0x11420, 0x1143c, 0x11440, 0x11478, 0x114f0, 0x115e0, 0x1160c, 0x11618, - 0x11630, 0x1163e, 0x11660, 0x1167c, 0x116c0, 0x116f8, 0x1171c, 0x11738, 0x11770, 0x1177e, 0x11782, 0x11784, - 0x11788, 0x11790, 0x1179e, 0x117a0, 0x117bc, 0x117c6, 0x117cc, 0x117d8, 0x117ee, 0x1182e, 0x11834, 0x1184e, - 0x1185c, 0x11862, 0x11864, 0x11868, 0x11876, 0x1188e, 0x1189c, 0x118b8, 0x118c2, 0x118c8, 0x118d0, 0x118de, - 0x118e6, 0x118ec, 0x118fa, 0x1190e, 0x1191c, 0x11938, 0x11970, 0x1197e, 0x11982, 0x11984, 0x11990, 0x1199e, - 0x119a0, 0x119bc, 0x119c6, 0x119cc, 0x119d8, 0x119ee, 0x119f2, 0x119f4, 0x11a0e, 0x11a1c, 0x11a38, 0x11a70, - 0x11a7e, 0x11ae0, 0x11afc, 0x11b08, 0x11b10, 0x11b1e, 0x11b20, 0x11b3c, 0x11b40, 0x11b78, 0x11b8c, 0x11b98, - 0x11bb0, 0x11bbe, 0x11bce, 0x11bdc, 0x11be2, 0x11be4, 0x11be8, 0x11bf6, 0x11c16, 0x11c26, 0x11c2c, 0x11c46, - 0x11c4c, 0x11c58, 0x11c6e, 0x11c86, 0x11c98, 0x11cb0, 0x11cbe, 0x11cce, 0x11cdc, 0x11ce2, 0x11ce4, 0x11ce8, - 0x11cf6, 0x11d06, 0x11d0c, 0x11d18, 0x11d30, 0x11d3e, 0x11d60, 0x11d7c, 0x11d8e, 0x11d9c, 0x11db8, 0x11dc4, - 0x11dc8, 0x11dd0, 0x11dde, 0x11de6, 0x11dec, 0x11dfa, 0x11e0a, 0x11e12, 0x11e14, 0x11e22, 0x11e24, 0x11e28, - 0x11e36, 0x11e42, 0x11e44, 0x11e50, 0x11e5e, 0x11e66, 0x11e6c, 0x11e82, 0x11e84, 0x11e88, 0x11e90, 0x11e9e, - 0x11ea0, 0x11ebc, 0x11ec6, 0x11ecc, 0x11ed8, 0x11eee, 0x11f1a, 0x11f2e, 0x11f32, 0x11f34, 0x11f4e, 0x11f5c, - 0x11f62, 0x11f64, 0x11f68, 0x11f76, 0x12048, 0x1205e, 0x12082, 0x12084, 0x12090, 0x1209e, 0x120a0, 0x120bc, - 0x120d8, 0x120f2, 0x120f4, 0x12108, 0x1211e, 0x12120, 0x1213c, 0x12140, 0x12178, 0x12186, 0x12198, 0x121b0, - 0x121be, 0x121e2, 0x121e4, 0x121e8, 0x121f6, 0x12204, 0x12210, 0x1221e, 0x12220, 0x12278, 0x122f0, 0x12306, - 0x1230c, 0x12330, 0x1233e, 0x12360, 0x1237c, 0x1238e, 0x1239c, 0x123b8, 0x123c2, 0x123c8, 0x123d0, 0x123e6, - 0x123ec, 0x1241e, 0x12420, 0x1243c, 0x124f0, 0x125e0, 0x12618, 0x1263e, 0x12660, 0x1267c, 0x126c0, 0x126f8, - 0x12738, 0x12770, 0x1277e, 0x12782, 0x12784, 0x12790, 0x1279e, 0x127a0, 0x127bc, 0x127c6, 0x127cc, 0x127d8, - 0x127ee, 0x12820, 0x1283c, 0x12840, 0x12878, 0x128f0, 0x129e0, 0x12bc0, 0x12c18, 0x12c30, 0x12c3e, 0x12c60, - 0x12c7c, 0x12cc0, 0x12cf8, 0x12df0, 0x12e1c, 0x12e38, 0x12e70, 0x12e7e, 0x12ee0, 0x12efc, 0x12f04, 0x12f08, - 0x12f10, 0x12f20, 0x12f3c, 0x12f40, 0x12f78, 0x12f86, 0x12f8c, 0x12f98, 0x12fb0, 0x12fbe, 0x12fce, 0x12fdc, - 0x1302e, 0x1304e, 0x1305c, 0x13062, 0x13068, 0x1308e, 0x1309c, 0x130b8, 0x130c2, 0x130c8, 0x130d0, 0x130de, - 0x130ec, 0x130fa, 0x1310e, 0x13138, 0x13170, 0x1317e, 0x13182, 0x13184, 0x13190, 0x1319e, 0x131a0, 0x131bc, - 0x131c6, 0x131cc, 0x131d8, 0x131f2, 0x131f4, 0x1320e, 0x1321c, 0x13270, 0x1327e, 0x132e0, 0x132fc, 0x13308, - 0x1331e, 0x13320, 0x1333c, 0x13340, 0x13378, 0x13386, 0x13398, 0x133b0, 0x133be, 0x133ce, 0x133dc, 0x133e2, - 0x133e4, 0x133e8, 0x133f6, 0x1340e, 0x1341c, 0x13438, 0x13470, 0x1347e, 0x134e0, 0x134fc, 0x135c0, 0x135f8, - 0x13608, 0x13610, 0x1361e, 0x13620, 0x1363c, 0x13640, 0x13678, 0x136f0, 0x1370c, 0x13718, 0x13730, 0x1373e, - 0x13760, 0x1377c, 0x1379c, 0x137b8, 0x137c2, 0x137c4, 0x137c8, 0x137d0, 0x137de, 0x137e6, 0x137ec, 0x13816, - 0x13826, 0x1382c, 0x13846, 0x1384c, 0x13858, 0x1386e, 0x13874, 0x13886, 0x13898, 0x138b0, 0x138be, 0x138ce, - 0x138dc, 0x138e2, 0x138e4, 0x138e8, 0x13906, 0x1390c, 0x13930, 0x1393e, 0x13960, 0x1397c, 0x1398e, 0x1399c, - 0x139b8, 0x139c8, 0x139d0, 0x139de, 0x139e6, 0x139ec, 0x139fa, 0x13a06, 0x13a0c, 0x13a18, 0x13a30, 0x13a3e, - 0x13a60, 0x13a7c, 0x13ac0, 0x13af8, 0x13b0e, 0x13b1c, 0x13b38, 0x13b70, 0x13b7e, 0x13b88, 0x13b90, 0x13b9e, - 0x13ba0, 0x13bbc, 0x13bcc, 0x13bd8, 0x13bee, 0x13bf2, 0x13bf4, 0x13c12, 0x13c14, 0x13c22, 0x13c24, 0x13c28, - 0x13c36, 0x13c42, 0x13c48, 0x13c50, 0x13c5e, 0x13c66, 0x13c6c, 0x13c82, 0x13c84, 0x13c90, 0x13c9e, 0x13ca0, - 0x13cbc, 0x13cc6, 0x13ccc, 0x13cd8, 0x13cee, 0x13d02, 0x13d04, 0x13d08, 0x13d10, 0x13d1e, 0x13d20, 0x13d3c, - 0x13d40, 0x13d78, 0x13d86, 0x13d8c, 0x13d98, 0x13db0, 0x13dbe, 0x13dce, 0x13ddc, 0x13de4, 0x13de8, 0x13df6, - 0x13e1a, 0x13e2e, 0x13e32, 0x13e34, 0x13e4e, 0x13e5c, 0x13e62, 0x13e64, 0x13e68, 0x13e76, 0x13e8e, 0x13e9c, - 0x13eb8, 0x13ec2, 0x13ec4, 0x13ec8, 0x13ed0, 0x13ede, 0x13ee6, 0x13eec, 0x13f26, 0x13f2c, 0x13f3a, 0x13f46, - 0x13f4c, 0x13f58, 0x13f6e, 0x13f72, 0x13f74, 0x14082, 0x1409e, 0x140a0, 0x140bc, 0x14104, 0x14108, 0x14110, - 0x1411e, 0x14120, 0x1413c, 0x14140, 0x14178, 0x1418c, 0x14198, 0x141b0, 0x141be, 0x141e2, 0x141e4, 0x141e8, - 0x14208, 0x14210, 0x1421e, 0x14220, 0x1423c, 0x14240, 0x14278, 0x142f0, 0x14306, 0x1430c, 0x14318, 0x14330, - 0x1433e, 0x14360, 0x1437c, 0x1438e, 0x143c2, 0x143c4, 0x143c8, 0x143d0, 0x143e6, 0x143ec, 0x14408, 0x14410, - 0x1441e, 0x14420, 0x1443c, 0x14440, 0x14478, 0x144f0, 0x145e0, 0x1460c, 0x14618, 0x14630, 0x1463e, 0x14660, - 0x1467c, 0x146c0, 0x146f8, 0x1471c, 0x14738, 0x14770, 0x1477e, 0x14782, 0x14784, 0x14788, 0x14790, 0x147a0, - 0x147bc, 0x147c6, 0x147cc, 0x147d8, 0x147ee, 0x14810, 0x14820, 0x1483c, 0x14840, 0x14878, 0x148f0, 0x149e0, - 0x14bc0, 0x14c30, 0x14c3e, 0x14c60, 0x14c7c, 0x14cc0, 0x14cf8, 0x14df0, 0x14e38, 0x14e70, 0x14e7e, 0x14ee0, - 0x14efc, 0x14f04, 0x14f08, 0x14f10, 0x14f1e, 0x14f20, 0x14f3c, 0x14f40, 0x14f78, 0x14f86, 0x14f8c, 0x14f98, - 0x14fb0, 0x14fce, 0x14fdc, 0x15020, 0x15040, 0x15078, 0x150f0, 0x151e0, 0x153c0, 0x15860, 0x1587c, 0x158c0, - 0x158f8, 0x159f0, 0x15be0, 0x15c70, 0x15c7e, 0x15ce0, 0x15cfc, 0x15dc0, 0x15df8, 0x15e08, 0x15e10, 0x15e20, - 0x15e40, 0x15e78, 0x15ef0, 0x15f0c, 0x15f18, 0x15f30, 0x15f60, 0x15f7c, 0x15f8e, 0x15f9c, 0x15fb8, 0x1604e, - 0x1605c, 0x1608e, 0x1609c, 0x160b8, 0x160c2, 0x160c4, 0x160c8, 0x160de, 0x1610e, 0x1611c, 0x16138, 0x16170, - 0x1617e, 0x16184, 0x16188, 0x16190, 0x1619e, 0x161a0, 0x161bc, 0x161c6, 0x161cc, 0x161d8, 0x161f2, 0x161f4, - 0x1620e, 0x1621c, 0x16238, 0x16270, 0x1627e, 0x162e0, 0x162fc, 0x16304, 0x16308, 0x16310, 0x1631e, 0x16320, - 0x1633c, 0x16340, 0x16378, 0x16386, 0x1638c, 0x16398, 0x163b0, 0x163be, 0x163ce, 0x163dc, 0x163e2, 0x163e4, - 0x163e8, 0x163f6, 0x1640e, 0x1641c, 0x16438, 0x16470, 0x1647e, 0x164e0, 0x164fc, 0x165c0, 0x165f8, 0x16610, - 0x1661e, 0x16620, 0x1663c, 0x16640, 0x16678, 0x166f0, 0x16718, 0x16730, 0x1673e, 0x16760, 0x1677c, 0x1678e, - 0x1679c, 0x167b8, 0x167c2, 0x167c4, 0x167c8, 0x167d0, 0x167de, 0x167e6, 0x167ec, 0x1681c, 0x16838, 0x16870, - 0x168e0, 0x168fc, 0x169c0, 0x169f8, 0x16bf0, 0x16c10, 0x16c1e, 0x16c20, 0x16c3c, 0x16c40, 0x16c78, 0x16cf0, - 0x16de0, 0x16e18, 0x16e30, 0x16e3e, 0x16e60, 0x16e7c, 0x16ec0, 0x16ef8, 0x16f1c, 0x16f38, 0x16f70, 0x16f7e, - 0x16f84, 0x16f88, 0x16f90, 0x16f9e, 0x16fa0, 0x16fbc, 0x16fc6, 0x16fcc, 0x16fd8, 0x17026, 0x1702c, 0x17046, - 0x1704c, 0x17058, 0x1706e, 0x17086, 0x1708c, 0x17098, 0x170b0, 0x170be, 0x170ce, 0x170dc, 0x170e8, 0x17106, - 0x1710c, 0x17118, 0x17130, 0x1713e, 0x17160, 0x1717c, 0x1718e, 0x1719c, 0x171b8, 0x171c2, 0x171c4, 0x171c8, - 0x171d0, 0x171de, 0x171e6, 0x171ec, 0x171fa, 0x17206, 0x1720c, 0x17218, 0x17230, 0x1723e, 0x17260, 0x1727c, - 0x172c0, 0x172f8, 0x1730e, 0x1731c, 0x17338, 0x17370, 0x1737e, 0x17388, 0x17390, 0x1739e, 0x173a0, 0x173bc, - 0x173cc, 0x173d8, 0x173ee, 0x173f2, 0x173f4, 0x1740c, 0x17418, 0x17430, 0x1743e, 0x17460, 0x1747c, 0x174c0, - 0x174f8, 0x175f0, 0x1760e, 0x1761c, 0x17638, 0x17670, 0x1767e, 0x176e0, 0x176fc, 0x17708, 0x17710, 0x1771e, - 0x17720, 0x1773c, 0x17740, 0x17778, 0x17798, 0x177b0, 0x177be, 0x177dc, 0x177e2, 0x177e4, 0x177e8, 0x17822, - 0x17824, 0x17828, 0x17836, 0x17842, 0x17844, 0x17848, 0x17850, 0x1785e, 0x17866, 0x1786c, 0x17882, 0x17884, - 0x17888, 0x17890, 0x1789e, 0x178a0, 0x178bc, 0x178c6, 0x178cc, 0x178d8, 0x178ee, 0x178f2, 0x178f4, 0x17902, - 0x17904, 0x17908, 0x17910, 0x1791e, 0x17920, 0x1793c, 0x17940, 0x17978, 0x17986, 0x1798c, 0x17998, 0x179b0, - 0x179be, 0x179ce, 0x179dc, 0x179e2, 0x179e4, 0x179e8, 0x179f6, 0x17a04, 0x17a08, 0x17a10, 0x17a1e, 0x17a20, - 0x17a3c, 0x17a40, 0x17a78, 0x17af0, 0x17b06, 0x17b0c, 0x17b18, 0x17b30, 0x17b3e, 0x17b60, 0x17b7c, 0x17b8e, - 0x17b9c, 0x17bb8, 0x17bc4, 0x17bc8, 0x17bd0, 0x17bde, 0x17be6, 0x17bec, 0x17c2e, 0x17c32, 0x17c34, 0x17c4e, - 0x17c5c, 0x17c62, 0x17c64, 0x17c68, 0x17c76, 0x17c8e, 0x17c9c, 0x17cb8, 0x17cc2, 0x17cc4, 0x17cc8, 0x17cd0, - 0x17cde, 0x17ce6, 0x17cec, 0x17d0e, 0x17d1c, 0x17d38, 0x17d70, 0x17d82, 0x17d84, 0x17d88, 0x17d90, 0x17d9e, - 0x17da0, 0x17dbc, 0x17dc6, 0x17dcc, 0x17dd8, 0x17dee, 0x17e26, 0x17e2c, 0x17e3a, 0x17e46, 0x17e4c, 0x17e58, - 0x17e6e, 0x17e72, 0x17e74, 0x17e86, 0x17e8c, 0x17e98, 0x17eb0, 0x17ece, 0x17edc, 0x17ee2, 0x17ee4, 0x17ee8, - 0x17ef6, 0x1813a, 0x18172, 0x18174, 0x18216, 0x18226, 0x1823a, 0x1824c, 0x18258, 0x1826e, 0x18272, 0x18274, - 0x18298, 0x182be, 0x182e2, 0x182e4, 0x182e8, 0x182f6, 0x1835e, 0x1837a, 0x183ae, 0x183d6, 0x18416, 0x18426, - 0x1842c, 0x1843a, 0x18446, 0x18458, 0x1846e, 0x18472, 0x18474, 0x18486, 0x184b0, 0x184be, 0x184ce, 0x184dc, - 0x184e2, 0x184e4, 0x184e8, 0x184f6, 0x18506, 0x1850c, 0x18518, 0x18530, 0x1853e, 0x18560, 0x1857c, 0x1858e, - 0x1859c, 0x185b8, 0x185c2, 0x185c4, 0x185c8, 0x185d0, 0x185de, 0x185e6, 0x185ec, 0x185fa, 0x18612, 0x18614, - 0x18622, 0x18628, 0x18636, 0x18642, 0x18650, 0x1865e, 0x1867a, 0x18682, 0x18684, 0x18688, 0x18690, 0x1869e, - 0x186a0, 0x186bc, 0x186c6, 0x186cc, 0x186d8, 0x186ee, 0x186f2, 0x186f4, 0x1872e, 0x1874e, 0x1875c, 0x18796, - 0x187a6, 0x187ac, 0x187d2, 0x187d4, 0x18826, 0x1882c, 0x1883a, 0x18846, 0x1884c, 0x18858, 0x1886e, 0x18872, - 0x18874, 0x18886, 0x18898, 0x188b0, 0x188be, 0x188ce, 0x188dc, 0x188e2, 0x188e4, 0x188e8, 0x188f6, 0x1890c, - 0x18930, 0x1893e, 0x18960, 0x1897c, 0x1898e, 0x189b8, 0x189c2, 0x189c8, 0x189d0, 0x189de, 0x189e6, 0x189ec, - 0x189fa, 0x18a18, 0x18a30, 0x18a3e, 0x18a60, 0x18a7c, 0x18ac0, 0x18af8, 0x18b1c, 0x18b38, 0x18b70, 0x18b7e, - 0x18b82, 0x18b84, 0x18b88, 0x18b90, 0x18b9e, 0x18ba0, 0x18bbc, 0x18bc6, 0x18bcc, 0x18bd8, 0x18bee, 0x18bf2, - 0x18bf4, 0x18c22, 0x18c24, 0x18c28, 0x18c36, 0x18c42, 0x18c48, 0x18c50, 0x18c5e, 0x18c66, 0x18c7a, 0x18c82, - 0x18c84, 0x18c90, 0x18c9e, 0x18ca0, 0x18cbc, 0x18ccc, 0x18cf2, 0x18cf4, 0x18d04, 0x18d08, 0x18d10, 0x18d1e, - 0x18d20, 0x18d3c, 0x18d40, 0x18d78, 0x18d86, 0x18d98, 0x18dce, 0x18de2, 0x18de4, 0x18de8, 0x18e2e, 0x18e32, - 0x18e34, 0x18e4e, 0x18e5c, 0x18e62, 0x18e64, 0x18e68, 0x18e8e, 0x18e9c, 0x18eb8, 0x18ec2, 0x18ec4, 0x18ec8, - 0x18ed0, 0x18efa, 0x18f16, 0x18f26, 0x18f2c, 0x18f46, 0x18f4c, 0x18f58, 0x18f6e, 0x18f8a, 0x18f92, 0x18f94, - 0x18fa2, 0x18fa4, 0x18fa8, 0x18fb6, 0x1902c, 0x1903a, 0x19046, 0x1904c, 0x19058, 0x19072, 0x19074, 0x19086, - 0x19098, 0x190b0, 0x190be, 0x190ce, 0x190dc, 0x190e2, 0x190e8, 0x190f6, 0x19106, 0x1910c, 0x19130, 0x1913e, - 0x19160, 0x1917c, 0x1918e, 0x1919c, 0x191b8, 0x191c2, 0x191c8, 0x191d0, 0x191de, 0x191e6, 0x191ec, 0x191fa, - 0x19218, 0x1923e, 0x19260, 0x1927c, 0x192c0, 0x192f8, 0x19338, 0x19370, 0x1937e, 0x19382, 0x19384, 0x19390, - 0x1939e, 0x193a0, 0x193bc, 0x193c6, 0x193cc, 0x193d8, 0x193ee, 0x193f2, 0x193f4, 0x19430, 0x1943e, 0x19460, - 0x1947c, 0x194c0, 0x194f8, 0x195f0, 0x19638, 0x19670, 0x1967e, 0x196e0, 0x196fc, 0x19702, 0x19704, 0x19708, - 0x19710, 0x19720, 0x1973c, 0x19740, 0x19778, 0x19786, 0x1978c, 0x19798, 0x197b0, 0x197be, 0x197ce, 0x197dc, - 0x197e2, 0x197e4, 0x197e8, 0x19822, 0x19824, 0x19842, 0x19848, 0x19850, 0x1985e, 0x19866, 0x1987a, 0x19882, - 0x19884, 0x19890, 0x1989e, 0x198a0, 0x198bc, 0x198cc, 0x198f2, 0x198f4, 0x19902, 0x19908, 0x1991e, 0x19920, - 0x1993c, 0x19940, 0x19978, 0x19986, 0x19998, 0x199ce, 0x199e2, 0x199e4, 0x199e8, 0x19a08, 0x19a10, 0x19a1e, - 0x19a20, 0x19a3c, 0x19a40, 0x19a78, 0x19af0, 0x19b18, 0x19b3e, 0x19b60, 0x19b9c, 0x19bc2, 0x19bc4, 0x19bc8, - 0x19bd0, 0x19be6, 0x19c2e, 0x19c34, 0x19c4e, 0x19c5c, 0x19c62, 0x19c64, 0x19c68, 0x19c8e, 0x19c9c, 0x19cb8, - 0x19cc2, 0x19cc8, 0x19cd0, 0x19ce6, 0x19cfa, 0x19d0e, 0x19d1c, 0x19d38, 0x19d70, 0x19d7e, 0x19d82, 0x19d84, - 0x19d88, 0x19d90, 0x19da0, 0x19dcc, 0x19df2, 0x19df4, 0x19e16, 0x19e26, 0x19e2c, 0x19e46, 0x19e4c, 0x19e58, - 0x19e74, 0x19e86, 0x19e8c, 0x19e98, 0x19eb0, 0x19ebe, 0x19ece, 0x19ee2, 0x19ee4, 0x19ee8, 0x19f0a, 0x19f12, - 0x19f14, 0x19f22, 0x19f24, 0x19f28, 0x19f42, 0x19f44, 0x19f48, 0x19f50, 0x19f5e, 0x19f6c, 0x19f9a, 0x19fae, - 0x19fb2, 0x19fb4, 0x1a046, 0x1a04c, 0x1a072, 0x1a074, 0x1a086, 0x1a08c, 0x1a098, 0x1a0b0, 0x1a0be, 0x1a0e2, - 0x1a0e4, 0x1a0e8, 0x1a0f6, 0x1a106, 0x1a10c, 0x1a118, 0x1a130, 0x1a13e, 0x1a160, 0x1a17c, 0x1a18e, 0x1a19c, - 0x1a1b8, 0x1a1c2, 0x1a1c4, 0x1a1c8, 0x1a1d0, 0x1a1de, 0x1a1e6, 0x1a1ec, 0x1a218, 0x1a230, 0x1a23e, 0x1a260, - 0x1a27c, 0x1a2c0, 0x1a2f8, 0x1a31c, 0x1a338, 0x1a370, 0x1a37e, 0x1a382, 0x1a384, 0x1a388, 0x1a390, 0x1a39e, - 0x1a3a0, 0x1a3bc, 0x1a3c6, 0x1a3cc, 0x1a3d8, 0x1a3ee, 0x1a3f2, 0x1a3f4, 0x1a418, 0x1a430, 0x1a43e, 0x1a460, - 0x1a47c, 0x1a4c0, 0x1a4f8, 0x1a5f0, 0x1a61c, 0x1a638, 0x1a670, 0x1a67e, 0x1a6e0, 0x1a6fc, 0x1a702, 0x1a704, - 0x1a708, 0x1a710, 0x1a71e, 0x1a720, 0x1a73c, 0x1a740, 0x1a778, 0x1a786, 0x1a78c, 0x1a798, 0x1a7b0, 0x1a7be, - 0x1a7ce, 0x1a7dc, 0x1a7e2, 0x1a7e4, 0x1a7e8, 0x1a830, 0x1a860, 0x1a87c, 0x1a8c0, 0x1a8f8, 0x1a9f0, 0x1abe0, - 0x1ac70, 0x1ac7e, 0x1ace0, 0x1acfc, 0x1adc0, 0x1adf8, 0x1ae04, 0x1ae08, 0x1ae10, 0x1ae20, 0x1ae3c, 0x1ae40, - 0x1ae78, 0x1aef0, 0x1af06, 0x1af0c, 0x1af18, 0x1af30, 0x1af3e, 0x1af60, 0x1af7c, 0x1af8e, 0x1af9c, 0x1afb8, - 0x1afc4, 0x1afc8, 0x1afd0, 0x1afde, 0x1b042, 0x1b05e, 0x1b07a, 0x1b082, 0x1b084, 0x1b088, 0x1b090, 0x1b09e, - 0x1b0a0, 0x1b0bc, 0x1b0cc, 0x1b0f2, 0x1b0f4, 0x1b102, 0x1b104, 0x1b108, 0x1b110, 0x1b11e, 0x1b120, 0x1b13c, - 0x1b140, 0x1b178, 0x1b186, 0x1b198, 0x1b1ce, 0x1b1e2, 0x1b1e4, 0x1b1e8, 0x1b204, 0x1b208, 0x1b210, 0x1b21e, - 0x1b220, 0x1b23c, 0x1b240, 0x1b278, 0x1b2f0, 0x1b30c, 0x1b33e, 0x1b360, 0x1b39c, 0x1b3c2, 0x1b3c4, 0x1b3c8, - 0x1b3d0, 0x1b3e6, 0x1b410, 0x1b41e, 0x1b420, 0x1b43c, 0x1b440, 0x1b478, 0x1b4f0, 0x1b5e0, 0x1b618, 0x1b660, - 0x1b67c, 0x1b6c0, 0x1b738, 0x1b782, 0x1b784, 0x1b788, 0x1b790, 0x1b79e, 0x1b7a0, 0x1b7cc, 0x1b82e, 0x1b84e, - 0x1b85c, 0x1b88e, 0x1b89c, 0x1b8b8, 0x1b8c2, 0x1b8c4, 0x1b8c8, 0x1b8d0, 0x1b8e6, 0x1b8fa, 0x1b90e, 0x1b91c, - 0x1b938, 0x1b970, 0x1b97e, 0x1b982, 0x1b984, 0x1b988, 0x1b990, 0x1b99e, 0x1b9a0, 0x1b9cc, 0x1b9f2, 0x1b9f4, - 0x1ba0e, 0x1ba1c, 0x1ba38, 0x1ba70, 0x1ba7e, 0x1bae0, 0x1bafc, 0x1bb08, 0x1bb10, 0x1bb20, 0x1bb3c, 0x1bb40, - 0x1bb98, 0x1bbce, 0x1bbe2, 0x1bbe4, 0x1bbe8, 0x1bc16, 0x1bc26, 0x1bc2c, 0x1bc46, 0x1bc4c, 0x1bc58, 0x1bc72, - 0x1bc74, 0x1bc86, 0x1bc8c, 0x1bc98, 0x1bcb0, 0x1bcbe, 0x1bcce, 0x1bce2, 0x1bce4, 0x1bce8, 0x1bd06, 0x1bd0c, - 0x1bd18, 0x1bd30, 0x1bd3e, 0x1bd60, 0x1bd7c, 0x1bd9c, 0x1bdc2, 0x1bdc4, 0x1bdc8, 0x1bdd0, 0x1bde6, 0x1bdfa, - 0x1be12, 0x1be14, 0x1be22, 0x1be24, 0x1be28, 0x1be42, 0x1be44, 0x1be48, 0x1be50, 0x1be5e, 0x1be66, 0x1be82, - 0x1be84, 0x1be88, 0x1be90, 0x1be9e, 0x1bea0, 0x1bebc, 0x1becc, 0x1bef4, 0x1bf1a, 0x1bf2e, 0x1bf32, 0x1bf34, - 0x1bf4e, 0x1bf5c, 0x1bf62, 0x1bf64, 0x1bf68, 0x1c09a, 0x1c0b2, 0x1c0b4, 0x1c11a, 0x1c132, 0x1c134, 0x1c162, - 0x1c164, 0x1c168, 0x1c176, 0x1c1ba, 0x1c21a, 0x1c232, 0x1c234, 0x1c24e, 0x1c25c, 0x1c262, 0x1c264, 0x1c268, - 0x1c276, 0x1c28e, 0x1c2c2, 0x1c2c4, 0x1c2c8, 0x1c2d0, 0x1c2de, 0x1c2e6, 0x1c2ec, 0x1c2fa, 0x1c316, 0x1c326, - 0x1c33a, 0x1c346, 0x1c34c, 0x1c372, 0x1c374, 0x1c41a, 0x1c42e, 0x1c432, 0x1c434, 0x1c44e, 0x1c45c, 0x1c462, - 0x1c464, 0x1c468, 0x1c476, 0x1c48e, 0x1c49c, 0x1c4b8, 0x1c4c2, 0x1c4c8, 0x1c4d0, 0x1c4de, 0x1c4e6, 0x1c4ec, - 0x1c4fa, 0x1c51c, 0x1c538, 0x1c570, 0x1c57e, 0x1c582, 0x1c584, 0x1c588, 0x1c590, 0x1c59e, 0x1c5a0, 0x1c5bc, - 0x1c5c6, 0x1c5cc, 0x1c5d8, 0x1c5ee, 0x1c5f2, 0x1c5f4, 0x1c616, 0x1c626, 0x1c62c, 0x1c63a, 0x1c646, 0x1c64c, - 0x1c658, 0x1c66e, 0x1c672, 0x1c674, 0x1c686, 0x1c68c, 0x1c698, 0x1c6b0, 0x1c6be, 0x1c6ce, 0x1c6dc, 0x1c6e2, - 0x1c6e4, 0x1c6e8, 0x1c712, 0x1c714, 0x1c722, 0x1c728, 0x1c736, 0x1c742, 0x1c744, 0x1c748, 0x1c750, 0x1c75e, - 0x1c766, 0x1c76c, 0x1c77a, 0x1c7ae, 0x1c7d6, 0x1c7ea, 0x1c81a, 0x1c82e, 0x1c832, 0x1c834, 0x1c84e, 0x1c85c, - 0x1c862, 0x1c864, 0x1c868, 0x1c876, 0x1c88e, 0x1c89c, 0x1c8b8, 0x1c8c2, 0x1c8c8, 0x1c8d0, 0x1c8de, 0x1c8e6, - 0x1c8ec, 0x1c8fa, 0x1c90e, 0x1c938, 0x1c970, 0x1c97e, 0x1c982, 0x1c984, 0x1c990, 0x1c99e, 0x1c9a0, 0x1c9bc, - 0x1c9c6, 0x1c9cc, 0x1c9d8, 0x1c9ee, 0x1c9f2, 0x1c9f4, 0x1ca38, 0x1ca70, 0x1ca7e, 0x1cae0, 0x1cafc, 0x1cb02, - 0x1cb04, 0x1cb08, 0x1cb10, 0x1cb20, 0x1cb3c, 0x1cb40, 0x1cb78, 0x1cb86, 0x1cb8c, 0x1cb98, 0x1cbb0, 0x1cbbe, - 0x1cbce, 0x1cbdc, 0x1cbe2, 0x1cbe4, 0x1cbe8, 0x1cbf6, 0x1cc16, 0x1cc26, 0x1cc2c, 0x1cc3a, 0x1cc46, 0x1cc58, - 0x1cc72, 0x1cc74, 0x1cc86, 0x1ccb0, 0x1ccbe, 0x1ccce, 0x1cce2, 0x1cce4, 0x1cce8, 0x1cd06, 0x1cd0c, 0x1cd18, - 0x1cd30, 0x1cd3e, 0x1cd60, 0x1cd7c, 0x1cd9c, 0x1cdc2, 0x1cdc4, 0x1cdc8, 0x1cdd0, 0x1cdde, 0x1cde6, 0x1cdfa, - 0x1ce22, 0x1ce28, 0x1ce42, 0x1ce50, 0x1ce5e, 0x1ce66, 0x1ce7a, 0x1ce82, 0x1ce84, 0x1ce88, 0x1ce90, 0x1ce9e, - 0x1cea0, 0x1cebc, 0x1cecc, 0x1cef2, 0x1cef4, 0x1cf2e, 0x1cf32, 0x1cf34, 0x1cf4e, 0x1cf5c, 0x1cf62, 0x1cf64, - 0x1cf68, 0x1cf96, 0x1cfa6, 0x1cfac, 0x1cfca, 0x1cfd2, 0x1cfd4, 0x1d02e, 0x1d032, 0x1d034, 0x1d04e, 0x1d05c, - 0x1d062, 0x1d064, 0x1d068, 0x1d076, 0x1d08e, 0x1d09c, 0x1d0b8, 0x1d0c2, 0x1d0c4, 0x1d0c8, 0x1d0d0, 0x1d0de, - 0x1d0e6, 0x1d0ec, 0x1d0fa, 0x1d11c, 0x1d138, 0x1d170, 0x1d17e, 0x1d182, 0x1d184, 0x1d188, 0x1d190, 0x1d19e, - 0x1d1a0, 0x1d1bc, 0x1d1c6, 0x1d1cc, 0x1d1d8, 0x1d1ee, 0x1d1f2, 0x1d1f4, 0x1d21c, 0x1d238, 0x1d270, 0x1d27e, - 0x1d2e0, 0x1d2fc, 0x1d302, 0x1d304, 0x1d308, 0x1d310, 0x1d31e, 0x1d320, 0x1d33c, 0x1d340, 0x1d378, 0x1d386, - 0x1d38c, 0x1d398, 0x1d3b0, 0x1d3be, 0x1d3ce, 0x1d3dc, 0x1d3e2, 0x1d3e4, 0x1d3e8, 0x1d3f6, 0x1d470, 0x1d47e, - 0x1d4e0, 0x1d4fc, 0x1d5c0, 0x1d5f8, 0x1d604, 0x1d608, 0x1d610, 0x1d620, 0x1d640, 0x1d678, 0x1d6f0, 0x1d706, - 0x1d70c, 0x1d718, 0x1d730, 0x1d73e, 0x1d760, 0x1d77c, 0x1d78e, 0x1d79c, 0x1d7b8, 0x1d7c2, 0x1d7c4, 0x1d7c8, - 0x1d7d0, 0x1d7de, 0x1d7e6, 0x1d7ec, 0x1d826, 0x1d82c, 0x1d83a, 0x1d846, 0x1d84c, 0x1d858, 0x1d872, 0x1d874, - 0x1d886, 0x1d88c, 0x1d898, 0x1d8b0, 0x1d8be, 0x1d8ce, 0x1d8e2, 0x1d8e4, 0x1d8e8, 0x1d8f6, 0x1d90c, 0x1d918, - 0x1d930, 0x1d93e, 0x1d960, 0x1d97c, 0x1d99c, 0x1d9c2, 0x1d9c4, 0x1d9c8, 0x1d9d0, 0x1d9e6, 0x1d9fa, 0x1da0c, - 0x1da18, 0x1da30, 0x1da3e, 0x1da60, 0x1da7c, 0x1dac0, 0x1daf8, 0x1db38, 0x1db82, 0x1db84, 0x1db88, 0x1db90, - 0x1db9e, 0x1dba0, 0x1dbcc, 0x1dbf2, 0x1dbf4, 0x1dc22, 0x1dc42, 0x1dc44, 0x1dc48, 0x1dc50, 0x1dc5e, 0x1dc66, - 0x1dc7a, 0x1dc82, 0x1dc84, 0x1dc88, 0x1dc90, 0x1dc9e, 0x1dca0, 0x1dcbc, 0x1dccc, 0x1dcf2, 0x1dcf4, 0x1dd04, - 0x1dd08, 0x1dd10, 0x1dd1e, 0x1dd20, 0x1dd3c, 0x1dd40, 0x1dd78, 0x1dd86, 0x1dd98, 0x1ddce, 0x1dde2, 0x1dde4, - 0x1dde8, 0x1de2e, 0x1de32, 0x1de34, 0x1de4e, 0x1de5c, 0x1de62, 0x1de64, 0x1de68, 0x1de8e, 0x1de9c, 0x1deb8, - 0x1dec2, 0x1dec4, 0x1dec8, 0x1ded0, 0x1dee6, 0x1defa, 0x1df16, 0x1df26, 0x1df2c, 0x1df46, 0x1df4c, 0x1df58, - 0x1df72, 0x1df74, 0x1df8a, 0x1df92, 0x1df94, 0x1dfa2, 0x1dfa4, 0x1dfa8, 0x1e08a, 0x1e092, 0x1e094, 0x1e0a2, - 0x1e0a4, 0x1e0a8, 0x1e0b6, 0x1e0da, 0x1e10a, 0x1e112, 0x1e114, 0x1e122, 0x1e124, 0x1e128, 0x1e136, 0x1e142, - 0x1e144, 0x1e148, 0x1e150, 0x1e166, 0x1e16c, 0x1e17a, 0x1e19a, 0x1e1b2, 0x1e1b4, 0x1e20a, 0x1e212, 0x1e214, - 0x1e222, 0x1e224, 0x1e228, 0x1e236, 0x1e242, 0x1e248, 0x1e250, 0x1e25e, 0x1e266, 0x1e26c, 0x1e27a, 0x1e282, - 0x1e284, 0x1e288, 0x1e290, 0x1e2a0, 0x1e2bc, 0x1e2c6, 0x1e2cc, 0x1e2d8, 0x1e2ee, 0x1e2f2, 0x1e2f4, 0x1e31a, - 0x1e332, 0x1e334, 0x1e35c, 0x1e362, 0x1e364, 0x1e368, 0x1e3ba, 0x1e40a, 0x1e412, 0x1e414, 0x1e422, 0x1e428, - 0x1e436, 0x1e442, 0x1e448, 0x1e450, 0x1e45e, 0x1e466, 0x1e46c, 0x1e47a, 0x1e482, 0x1e484, 0x1e490, 0x1e49e, - 0x1e4a0, 0x1e4bc, 0x1e4c6, 0x1e4cc, 0x1e4d8, 0x1e4ee, 0x1e4f2, 0x1e4f4, 0x1e502, 0x1e504, 0x1e508, 0x1e510, - 0x1e51e, 0x1e520, 0x1e53c, 0x1e540, 0x1e578, 0x1e586, 0x1e58c, 0x1e598, 0x1e5b0, 0x1e5be, 0x1e5ce, 0x1e5dc, - 0x1e5e2, 0x1e5e4, 0x1e5e8, 0x1e5f6, 0x1e61a, 0x1e62e, 0x1e632, 0x1e634, 0x1e64e, 0x1e65c, 0x1e662, 0x1e668, - 0x1e68e, 0x1e69c, 0x1e6b8, 0x1e6c2, 0x1e6c4, 0x1e6c8, 0x1e6d0, 0x1e6e6, 0x1e6fa, 0x1e716, 0x1e726, 0x1e72c, - 0x1e73a, 0x1e746, 0x1e74c, 0x1e758, 0x1e772, 0x1e774, 0x1e792, 0x1e794, 0x1e7a2, 0x1e7a4, 0x1e7a8, 0x1e7b6, - 0x1e812, 0x1e814, 0x1e822, 0x1e824, 0x1e828, 0x1e836, 0x1e842, 0x1e844, 0x1e848, 0x1e850, 0x1e85e, 0x1e866, - 0x1e86c, 0x1e87a, 0x1e882, 0x1e884, 0x1e888, 0x1e890, 0x1e89e, 0x1e8a0, 0x1e8bc, 0x1e8c6, 0x1e8cc, 0x1e8d8, - 0x1e8ee, 0x1e8f2, 0x1e8f4, 0x1e902, 0x1e904, 0x1e908, 0x1e910, 0x1e920, 0x1e93c, 0x1e940, 0x1e978, 0x1e986, - 0x1e98c, 0x1e998, 0x1e9b0, 0x1e9be, 0x1e9ce, 0x1e9dc, 0x1e9e2, 0x1e9e4, 0x1e9e8, 0x1e9f6, 0x1ea04, 0x1ea08, - 0x1ea10, 0x1ea20, 0x1ea40, 0x1ea78, 0x1eaf0, 0x1eb06, 0x1eb0c, 0x1eb18, 0x1eb30, 0x1eb3e, 0x1eb60, 0x1eb7c, - 0x1eb8e, 0x1eb9c, 0x1ebb8, 0x1ebc2, 0x1ebc4, 0x1ebc8, 0x1ebd0, 0x1ebde, 0x1ebe6, 0x1ebec, 0x1ec1a, 0x1ec2e, - 0x1ec32, 0x1ec34, 0x1ec4e, 0x1ec5c, 0x1ec62, 0x1ec64, 0x1ec68, 0x1ec8e, 0x1ec9c, 0x1ecb8, 0x1ecc2, 0x1ecc4, - 0x1ecc8, 0x1ecd0, 0x1ece6, 0x1ecfa, 0x1ed0e, 0x1ed1c, 0x1ed38, 0x1ed70, 0x1ed7e, 0x1ed82, 0x1ed84, 0x1ed88, - 0x1ed90, 0x1ed9e, 0x1eda0, 0x1edcc, 0x1edf2, 0x1edf4, 0x1ee16, 0x1ee26, 0x1ee2c, 0x1ee3a, 0x1ee46, 0x1ee4c, - 0x1ee58, 0x1ee6e, 0x1ee72, 0x1ee74, 0x1ee86, 0x1ee8c, 0x1ee98, 0x1eeb0, 0x1eebe, 0x1eece, 0x1eedc, 0x1eee2, - 0x1eee4, 0x1eee8, 0x1ef12, 0x1ef22, 0x1ef24, 0x1ef28, 0x1ef36, 0x1ef42, 0x1ef44, 0x1ef48, 0x1ef50, 0x1ef5e, - 0x1ef66, 0x1ef6c, 0x1ef7a, 0x1efae, 0x1efb2, 0x1efb4, 0x1efd6, 0x1f096, 0x1f0a6, 0x1f0ac, 0x1f0ba, 0x1f0ca, - 0x1f0d2, 0x1f0d4, 0x1f116, 0x1f126, 0x1f12c, 0x1f13a, 0x1f146, 0x1f14c, 0x1f158, 0x1f16e, 0x1f172, 0x1f174, - 0x1f18a, 0x1f192, 0x1f194, 0x1f1a2, 0x1f1a4, 0x1f1a8, 0x1f1da, 0x1f216, 0x1f226, 0x1f22c, 0x1f23a, 0x1f246, - 0x1f258, 0x1f26e, 0x1f272, 0x1f274, 0x1f286, 0x1f28c, 0x1f298, 0x1f2b0, 0x1f2be, 0x1f2ce, 0x1f2dc, 0x1f2e2, - 0x1f2e4, 0x1f2e8, 0x1f2f6, 0x1f30a, 0x1f312, 0x1f314, 0x1f322, 0x1f328, 0x1f342, 0x1f344, 0x1f348, 0x1f350, - 0x1f35e, 0x1f366, 0x1f37a, 0x1f39a, 0x1f3ae, 0x1f3b2, 0x1f3b4, 0x1f416, 0x1f426, 0x1f42c, 0x1f43a, 0x1f446, - 0x1f44c, 0x1f458, 0x1f46e, 0x1f472, 0x1f474, 0x1f486, 0x1f48c, 0x1f498, 0x1f4b0, 0x1f4be, 0x1f4ce, 0x1f4dc, - 0x1f4e2, 0x1f4e4, 0x1f4e8, 0x1f4f6, 0x1f506, 0x1f50c, 0x1f518, 0x1f530, 0x1f53e, 0x1f560, 0x1f57c, 0x1f58e, - 0x1f59c, 0x1f5b8, 0x1f5c2, 0x1f5c4, 0x1f5c8, 0x1f5d0, 0x1f5de, 0x1f5e6, 0x1f5ec, 0x1f5fa, 0x1f60a, 0x1f612, - 0x1f614, 0x1f622, 0x1f624, 0x1f628, 0x1f636, 0x1f642, 0x1f644, 0x1f648, 0x1f650, 0x1f65e, 0x1f666, 0x1f67a, - 0x1f682, 0x1f684, 0x1f688, 0x1f690, 0x1f69e, 0x1f6a0, 0x1f6bc, 0x1f6cc, 0x1f6f2, 0x1f6f4, 0x1f71a, 0x1f72e, - 0x1f732, 0x1f734, 0x1f74e, 0x1f75c, 0x1f762, 0x1f764, 0x1f768, 0x1f776, 0x1f796, 0x1f7a6, 0x1f7ac, 0x1f7ba, - 0x1f7d2, 0x1f7d4, 0x1f89a, 0x1f8ae, 0x1f8b2, 0x1f8b4, 0x1f8d6, 0x1f8ea, 0x1f91a, 0x1f92e, 0x1f932, 0x1f934, - 0x1f94e, 0x1f95c, 0x1f962, 0x1f964, 0x1f968, 0x1f976, 0x1f996, 0x1f9a6, 0x1f9ac, 0x1f9ba, 0x1f9ca, 0x1f9d2, - 0x1f9d4, 0x1fa1a, 0x1fa2e, 0x1fa32, 0x1fa34, 0x1fa4e, 0x1fa5c, 0x1fa62, 0x1fa64, 0x1fa68, 0x1fa76, 0x1fa8e, - 0x1fa9c, 0x1fab8, 0x1fac2, 0x1fac4, 0x1fac8, 0x1fad0, 0x1fade, 0x1fae6, 0x1faec, 0x1fb16, 0x1fb26, 0x1fb2c, - 0x1fb3a, 0x1fb46, 0x1fb4c, 0x1fb58, 0x1fb6e, 0x1fb72, 0x1fb74, 0x1fb8a, 0x1fb92, 0x1fb94, 0x1fba2, 0x1fba4, - 0x1fba8, 0x1fbb6, 0x1fbda}; - - /** - * This table contains to codewords for all symbols. - */ - private static final int[] CODEWORD_TABLE = { - 2627, 1819, 2622, 2621, 1813, 1812, 2729, 2724, 2723, 2779, 2774, 2773, 902, 896, 908, 868, 865, 861, 859, 2511, - 873, 871, 1780, 835, 2493, 825, 2491, 842, 837, 844, 1764, 1762, 811, 810, 809, 2483, 807, 2482, 806, 2480, 815, - 814, 813, 812, 2484, 817, 816, 1745, 1744, 1742, 1746, 2655, 2637, 2635, 2626, 2625, 2623, 2628, 1820, 2752, - 2739, 2737, 2728, 2727, 2725, 2730, 2785, 2783, 2778, 2777, 2775, 2780, 787, 781, 747, 739, 736, 2413, 754, 752, - 1719, 692, 689, 681, 2371, 678, 2369, 700, 697, 694, 703, 1688, 1686, 642, 638, 2343, 631, 2341, 627, 2338, 651, - 646, 643, 2345, 654, 652, 1652, 1650, 1647, 1654, 601, 599, 2322, 596, 2321, 594, 2319, 2317, 611, 610, 608, 606, - 2324, 603, 2323, 615, 614, 612, 1617, 1616, 1614, 1612, 616, 1619, 1618, 2575, 2538, 2536, 905, 901, 898, 909, - 2509, 2507, 2504, 870, 867, 864, 860, 2512, 875, 872, 1781, 2490, 2489, 2487, 2485, 1748, 836, 834, 832, 830, - 2494, 827, 2492, 843, 841, 839, 845, 1765, 1763, 2701, 2676, 2674, 2653, 2648, 2656, 2634, 2633, 2631, 2629, - 1821, 2638, 2636, 2770, 2763, 2761, 2750, 2745, 2753, 2736, 2735, 2733, 2731, 1848, 2740, 2738, 2786, 2784, 591, - 588, 576, 569, 566, 2296, 1590, 537, 534, 526, 2276, 522, 2274, 545, 542, 539, 548, 1572, 1570, 481, 2245, 466, - 2242, 462, 2239, 492, 485, 482, 2249, 496, 494, 1534, 1531, 1528, 1538, 413, 2196, 406, 2191, 2188, 425, 419, - 2202, 415, 2199, 432, 430, 427, 1472, 1467, 1464, 433, 1476, 1474, 368, 367, 2160, 365, 2159, 362, 2157, 2155, - 2152, 378, 377, 375, 2166, 372, 2165, 369, 2162, 383, 381, 379, 2168, 1419, 1418, 1416, 1414, 385, 1411, 384, - 1423, 1422, 1420, 1424, 2461, 802, 2441, 2439, 790, 786, 783, 794, 2409, 2406, 2403, 750, 742, 738, 2414, 756, - 753, 1720, 2367, 2365, 2362, 2359, 1663, 693, 691, 684, 2373, 680, 2370, 702, 699, 696, 704, 1690, 1687, 2337, - 2336, 2334, 2332, 1624, 2329, 1622, 640, 637, 2344, 634, 2342, 630, 2340, 650, 648, 645, 2346, 655, 653, 1653, - 1651, 1649, 1655, 2612, 2597, 2595, 2571, 2568, 2565, 2576, 2534, 2529, 2526, 1787, 2540, 2537, 907, 904, 900, - 910, 2503, 2502, 2500, 2498, 1768, 2495, 1767, 2510, 2508, 2506, 869, 866, 863, 2513, 876, 874, 1782, 2720, 2713, - 2711, 2697, 2694, 2691, 2702, 2672, 2670, 2664, 1828, 2678, 2675, 2647, 2646, 2644, 2642, 1823, 2639, 1822, 2654, - 2652, 2650, 2657, 2771, 1855, 2765, 2762, 1850, 1849, 2751, 2749, 2747, 2754, 353, 2148, 344, 342, 336, 2142, - 332, 2140, 345, 1375, 1373, 306, 2130, 299, 2128, 295, 2125, 319, 314, 311, 2132, 1354, 1352, 1349, 1356, 262, - 257, 2101, 253, 2096, 2093, 274, 273, 267, 2107, 263, 2104, 280, 278, 275, 1316, 1311, 1308, 1320, 1318, 2052, - 202, 2050, 2044, 2040, 219, 2063, 212, 2060, 208, 2055, 224, 221, 2066, 1260, 1258, 1252, 231, 1248, 229, 1266, - 1264, 1261, 1268, 155, 1998, 153, 1996, 1994, 1991, 1988, 165, 164, 2007, 162, 2006, 159, 2003, 2000, 172, 171, - 169, 2012, 166, 2010, 1186, 1184, 1182, 1179, 175, 1176, 173, 1192, 1191, 1189, 1187, 176, 1194, 1193, 2313, - 2307, 2305, 592, 589, 2294, 2292, 2289, 578, 572, 568, 2297, 580, 1591, 2272, 2267, 2264, 1547, 538, 536, 529, - 2278, 525, 2275, 547, 544, 541, 1574, 1571, 2237, 2235, 2229, 1493, 2225, 1489, 478, 2247, 470, 2244, 465, 2241, - 493, 488, 484, 2250, 498, 495, 1536, 1533, 1530, 1539, 2187, 2186, 2184, 2182, 1432, 2179, 1430, 2176, 1427, 414, - 412, 2197, 409, 2195, 405, 2193, 2190, 426, 424, 421, 2203, 418, 2201, 431, 429, 1473, 1471, 1469, 1466, 434, - 1477, 1475, 2478, 2472, 2470, 2459, 2457, 2454, 2462, 803, 2437, 2432, 2429, 1726, 2443, 2440, 792, 789, 785, - 2401, 2399, 2393, 1702, 2389, 1699, 2411, 2408, 2405, 745, 741, 2415, 758, 755, 1721, 2358, 2357, 2355, 2353, - 1661, 2350, 1660, 2347, 1657, 2368, 2366, 2364, 2361, 1666, 690, 687, 2374, 683, 2372, 701, 698, 705, 1691, 1689, - 2619, 2617, 2610, 2608, 2605, 2613, 2593, 2588, 2585, 1803, 2599, 2596, 2563, 2561, 2555, 1797, 2551, 1795, 2573, - 2570, 2567, 2577, 2525, 2524, 2522, 2520, 1786, 2517, 1785, 2514, 1783, 2535, 2533, 2531, 2528, 1788, 2541, 2539, - 906, 903, 911, 2721, 1844, 2715, 2712, 1838, 1836, 2699, 2696, 2693, 2703, 1827, 1826, 1824, 2673, 2671, 2669, - 2666, 1829, 2679, 2677, 1858, 1857, 2772, 1854, 1853, 1851, 1856, 2766, 2764, 143, 1987, 139, 1986, 135, 133, - 131, 1984, 128, 1983, 125, 1981, 138, 137, 136, 1985, 1133, 1132, 1130, 112, 110, 1974, 107, 1973, 104, 1971, - 1969, 122, 121, 119, 117, 1977, 114, 1976, 124, 1115, 1114, 1112, 1110, 1117, 1116, 84, 83, 1953, 81, 1952, 78, - 1950, 1948, 1945, 94, 93, 91, 1959, 88, 1958, 85, 1955, 99, 97, 95, 1961, 1086, 1085, 1083, 1081, 1078, 100, - 1090, 1089, 1087, 1091, 49, 47, 1917, 44, 1915, 1913, 1910, 1907, 59, 1926, 56, 1925, 53, 1922, 1919, 66, 64, - 1931, 61, 1929, 1042, 1040, 1038, 71, 1035, 70, 1032, 68, 1048, 1047, 1045, 1043, 1050, 1049, 12, 10, 1869, 1867, - 1864, 1861, 21, 1880, 19, 1877, 1874, 1871, 28, 1888, 25, 1886, 22, 1883, 982, 980, 977, 974, 32, 30, 991, 989, - 987, 984, 34, 995, 994, 992, 2151, 2150, 2147, 2146, 2144, 356, 355, 354, 2149, 2139, 2138, 2136, 2134, 1359, - 343, 341, 338, 2143, 335, 2141, 348, 347, 346, 1376, 1374, 2124, 2123, 2121, 2119, 1326, 2116, 1324, 310, 308, - 305, 2131, 302, 2129, 298, 2127, 320, 318, 316, 313, 2133, 322, 321, 1355, 1353, 1351, 1357, 2092, 2091, 2089, - 2087, 1276, 2084, 1274, 2081, 1271, 259, 2102, 256, 2100, 252, 2098, 2095, 272, 269, 2108, 266, 2106, 281, 279, - 277, 1317, 1315, 1313, 1310, 282, 1321, 1319, 2039, 2037, 2035, 2032, 1203, 2029, 1200, 1197, 207, 2053, 205, - 2051, 201, 2049, 2046, 2043, 220, 218, 2064, 215, 2062, 211, 2059, 228, 226, 223, 2069, 1259, 1257, 1254, 232, - 1251, 230, 1267, 1265, 1263, 2316, 2315, 2312, 2311, 2309, 2314, 2304, 2303, 2301, 2299, 1593, 2308, 2306, 590, - 2288, 2287, 2285, 2283, 1578, 2280, 1577, 2295, 2293, 2291, 579, 577, 574, 571, 2298, 582, 581, 1592, 2263, 2262, - 2260, 2258, 1545, 2255, 1544, 2252, 1541, 2273, 2271, 2269, 2266, 1550, 535, 532, 2279, 528, 2277, 546, 543, 549, - 1575, 1573, 2224, 2222, 2220, 1486, 2217, 1485, 2214, 1482, 1479, 2238, 2236, 2234, 2231, 1496, 2228, 1492, 480, - 477, 2248, 473, 2246, 469, 2243, 490, 487, 2251, 497, 1537, 1535, 1532, 2477, 2476, 2474, 2479, 2469, 2468, 2466, - 2464, 1730, 2473, 2471, 2453, 2452, 2450, 2448, 1729, 2445, 1728, 2460, 2458, 2456, 2463, 805, 804, 2428, 2427, - 2425, 2423, 1725, 2420, 1724, 2417, 1722, 2438, 2436, 2434, 2431, 1727, 2444, 2442, 793, 791, 788, 795, 2388, - 2386, 2384, 1697, 2381, 1696, 2378, 1694, 1692, 2402, 2400, 2398, 2395, 1703, 2392, 1701, 2412, 2410, 2407, 751, - 748, 744, 2416, 759, 757, 1807, 2620, 2618, 1806, 1805, 2611, 2609, 2607, 2614, 1802, 1801, 1799, 2594, 2592, - 2590, 2587, 1804, 2600, 2598, 1794, 1793, 1791, 1789, 2564, 2562, 2560, 2557, 1798, 2554, 1796, 2574, 2572, 2569, - 2578, 1847, 1846, 2722, 1843, 1842, 1840, 1845, 2716, 2714, 1835, 1834, 1832, 1830, 1839, 1837, 2700, 2698, 2695, - 2704, 1817, 1811, 1810, 897, 862, 1777, 829, 826, 838, 1760, 1758, 808, 2481, 1741, 1740, 1738, 1743, 2624, 1818, - 2726, 2776, 782, 740, 737, 1715, 686, 679, 695, 1682, 1680, 639, 628, 2339, 647, 644, 1645, 1643, 1640, 1648, - 602, 600, 597, 595, 2320, 593, 2318, 609, 607, 604, 1611, 1610, 1608, 1606, 613, 1615, 1613, 2328, 926, 924, 892, - 886, 899, 857, 850, 2505, 1778, 824, 823, 821, 819, 2488, 818, 2486, 833, 831, 828, 840, 1761, 1759, 2649, 2632, - 2630, 2746, 2734, 2732, 2782, 2781, 570, 567, 1587, 531, 527, 523, 540, 1566, 1564, 476, 467, 463, 2240, 486, - 483, 1524, 1521, 1518, 1529, 411, 403, 2192, 399, 2189, 423, 416, 1462, 1457, 1454, 428, 1468, 1465, 2210, 366, - 363, 2158, 360, 2156, 357, 2153, 376, 373, 370, 2163, 1410, 1409, 1407, 1405, 382, 1402, 380, 1417, 1415, 1412, - 1421, 2175, 2174, 777, 774, 771, 784, 732, 725, 722, 2404, 743, 1716, 676, 674, 668, 2363, 665, 2360, 685, 1684, - 1681, 626, 624, 622, 2335, 620, 2333, 617, 2330, 641, 635, 649, 1646, 1644, 1642, 2566, 928, 925, 2530, 2527, - 894, 891, 888, 2501, 2499, 2496, 858, 856, 854, 851, 1779, 2692, 2668, 2665, 2645, 2643, 2640, 2651, 2768, 2759, - 2757, 2744, 2743, 2741, 2748, 352, 1382, 340, 337, 333, 1371, 1369, 307, 300, 296, 2126, 315, 312, 1347, 1342, - 1350, 261, 258, 250, 2097, 246, 2094, 271, 268, 264, 1306, 1301, 1298, 276, 1312, 1309, 2115, 203, 2048, 195, - 2045, 191, 2041, 213, 209, 2056, 1246, 1244, 1238, 225, 1234, 222, 1256, 1253, 1249, 1262, 2080, 2079, 154, 1997, - 150, 1995, 147, 1992, 1989, 163, 160, 2004, 156, 2001, 1175, 1174, 1172, 1170, 1167, 170, 1164, 167, 1185, 1183, - 1180, 1177, 174, 1190, 1188, 2025, 2024, 2022, 587, 586, 564, 559, 556, 2290, 573, 1588, 520, 518, 512, 2268, - 508, 2265, 530, 1568, 1565, 461, 457, 2233, 450, 2230, 446, 2226, 479, 471, 489, 1526, 1523, 1520, 397, 395, - 2185, 392, 2183, 389, 2180, 2177, 410, 2194, 402, 422, 1463, 1461, 1459, 1456, 1470, 2455, 799, 2433, 2430, 779, - 776, 773, 2397, 2394, 2390, 734, 728, 724, 746, 1717, 2356, 2354, 2351, 2348, 1658, 677, 675, 673, 670, 667, 688, - 1685, 1683, 2606, 2589, 2586, 2559, 2556, 2552, 927, 2523, 2521, 2518, 2515, 1784, 2532, 895, 893, 890, 2718, - 2709, 2707, 2689, 2687, 2684, 2663, 2662, 2660, 2658, 1825, 2667, 2769, 1852, 2760, 2758, 142, 141, 1139, 1138, - 134, 132, 129, 126, 1982, 1129, 1128, 1126, 1131, 113, 111, 108, 105, 1972, 101, 1970, 120, 118, 115, 1109, 1108, - 1106, 1104, 123, 1113, 1111, 82, 79, 1951, 75, 1949, 72, 1946, 92, 89, 86, 1956, 1077, 1076, 1074, 1072, 98, - 1069, 96, 1084, 1082, 1079, 1088, 1968, 1967, 48, 45, 1916, 42, 1914, 39, 1911, 1908, 60, 57, 54, 1923, 50, 1920, - 1031, 1030, 1028, 1026, 67, 1023, 65, 1020, 62, 1041, 1039, 1036, 1033, 69, 1046, 1044, 1944, 1943, 1941, 11, 9, - 1868, 7, 1865, 1862, 1859, 20, 1878, 16, 1875, 13, 1872, 970, 968, 966, 963, 29, 960, 26, 23, 983, 981, 978, 975, - 33, 971, 31, 990, 988, 985, 1906, 1904, 1902, 993, 351, 2145, 1383, 331, 330, 328, 326, 2137, 323, 2135, 339, - 1372, 1370, 294, 293, 291, 289, 2122, 286, 2120, 283, 2117, 309, 303, 317, 1348, 1346, 1344, 245, 244, 242, 2090, - 239, 2088, 236, 2085, 2082, 260, 2099, 249, 270, 1307, 1305, 1303, 1300, 1314, 189, 2038, 186, 2036, 183, 2033, - 2030, 2026, 206, 198, 2047, 194, 216, 1247, 1245, 1243, 1240, 227, 1237, 1255, 2310, 2302, 2300, 2286, 2284, - 2281, 565, 563, 561, 558, 575, 1589, 2261, 2259, 2256, 2253, 1542, 521, 519, 517, 514, 2270, 511, 533, 1569, - 1567, 2223, 2221, 2218, 2215, 1483, 2211, 1480, 459, 456, 453, 2232, 449, 474, 491, 1527, 1525, 1522, 2475, 2467, - 2465, 2451, 2449, 2446, 801, 800, 2426, 2424, 2421, 2418, 1723, 2435, 780, 778, 775, 2387, 2385, 2382, 2379, - 1695, 2375, 1693, 2396, 735, 733, 730, 727, 749, 1718, 2616, 2615, 2604, 2603, 2601, 2584, 2583, 2581, 2579, - 1800, 2591, 2550, 2549, 2547, 2545, 1792, 2542, 1790, 2558, 929, 2719, 1841, 2710, 2708, 1833, 1831, 2690, 2688, - 2686, 1815, 1809, 1808, 1774, 1756, 1754, 1737, 1736, 1734, 1739, 1816, 1711, 1676, 1674, 633, 629, 1638, 1636, - 1633, 1641, 598, 1605, 1604, 1602, 1600, 605, 1609, 1607, 2327, 887, 853, 1775, 822, 820, 1757, 1755, 1584, 524, - 1560, 1558, 468, 464, 1514, 1511, 1508, 1519, 408, 404, 400, 1452, 1447, 1444, 417, 1458, 1455, 2208, 364, 361, - 358, 2154, 1401, 1400, 1398, 1396, 374, 1393, 371, 1408, 1406, 1403, 1413, 2173, 2172, 772, 726, 723, 1712, 672, - 669, 666, 682, 1678, 1675, 625, 623, 621, 618, 2331, 636, 632, 1639, 1637, 1635, 920, 918, 884, 880, 889, 849, - 848, 847, 846, 2497, 855, 852, 1776, 2641, 2742, 2787, 1380, 334, 1367, 1365, 301, 297, 1340, 1338, 1335, 1343, - 255, 251, 247, 1296, 1291, 1288, 265, 1302, 1299, 2113, 204, 196, 192, 2042, 1232, 1230, 1224, 214, 1220, 210, - 1242, 1239, 1235, 1250, 2077, 2075, 151, 148, 1993, 144, 1990, 1163, 1162, 1160, 1158, 1155, 161, 1152, 157, - 1173, 1171, 1168, 1165, 168, 1181, 1178, 2021, 2020, 2018, 2023, 585, 560, 557, 1585, 516, 509, 1562, 1559, 458, - 447, 2227, 472, 1516, 1513, 1510, 398, 396, 393, 390, 2181, 386, 2178, 407, 1453, 1451, 1449, 1446, 420, 1460, - 2209, 769, 764, 720, 712, 2391, 729, 1713, 664, 663, 661, 659, 2352, 656, 2349, 671, 1679, 1677, 2553, 922, 919, - 2519, 2516, 885, 883, 881, 2685, 2661, 2659, 2767, 2756, 2755, 140, 1137, 1136, 130, 127, 1125, 1124, 1122, 1127, - 109, 106, 102, 1103, 1102, 1100, 1098, 116, 1107, 1105, 1980, 80, 76, 73, 1947, 1068, 1067, 1065, 1063, 90, 1060, - 87, 1075, 1073, 1070, 1080, 1966, 1965, 46, 43, 40, 1912, 36, 1909, 1019, 1018, 1016, 1014, 58, 1011, 55, 1008, - 51, 1029, 1027, 1024, 1021, 63, 1037, 1034, 1940, 1939, 1937, 1942, 8, 1866, 4, 1863, 1, 1860, 956, 954, 952, - 949, 946, 17, 14, 969, 967, 964, 961, 27, 957, 24, 979, 976, 972, 1901, 1900, 1898, 1896, 986, 1905, 1903, 350, - 349, 1381, 329, 327, 324, 1368, 1366, 292, 290, 287, 284, 2118, 304, 1341, 1339, 1337, 1345, 243, 240, 237, 2086, - 233, 2083, 254, 1297, 1295, 1293, 1290, 1304, 2114, 190, 187, 184, 2034, 180, 2031, 177, 2027, 199, 1233, 1231, - 1229, 1226, 217, 1223, 1241, 2078, 2076, 584, 555, 554, 552, 550, 2282, 562, 1586, 507, 506, 504, 502, 2257, 499, - 2254, 515, 1563, 1561, 445, 443, 441, 2219, 438, 2216, 435, 2212, 460, 454, 475, 1517, 1515, 1512, 2447, 798, - 797, 2422, 2419, 770, 768, 766, 2383, 2380, 2376, 721, 719, 717, 714, 731, 1714, 2602, 2582, 2580, 2548, 2546, - 2543, 923, 921, 2717, 2706, 2705, 2683, 2682, 2680, 1771, 1752, 1750, 1733, 1732, 1731, 1735, 1814, 1707, 1670, - 1668, 1631, 1629, 1626, 1634, 1599, 1598, 1596, 1594, 1603, 1601, 2326, 1772, 1753, 1751, 1581, 1554, 1552, 1504, - 1501, 1498, 1509, 1442, 1437, 1434, 401, 1448, 1445, 2206, 1392, 1391, 1389, 1387, 1384, 359, 1399, 1397, 1394, - 1404, 2171, 2170, 1708, 1672, 1669, 619, 1632, 1630, 1628, 1773, 1378, 1363, 1361, 1333, 1328, 1336, 1286, 1281, - 1278, 248, 1292, 1289, 2111, 1218, 1216, 1210, 197, 1206, 193, 1228, 1225, 1221, 1236, 2073, 2071, 1151, 1150, - 1148, 1146, 152, 1143, 149, 1140, 145, 1161, 1159, 1156, 1153, 158, 1169, 1166, 2017, 2016, 2014, 2019, 1582, - 510, 1556, 1553, 452, 448, 1506, 1500, 394, 391, 387, 1443, 1441, 1439, 1436, 1450, 2207, 765, 716, 713, 1709, - 662, 660, 657, 1673, 1671, 916, 914, 879, 878, 877, 882, 1135, 1134, 1121, 1120, 1118, 1123, 1097, 1096, 1094, - 1092, 103, 1101, 1099, 1979, 1059, 1058, 1056, 1054, 77, 1051, 74, 1066, 1064, 1061, 1071, 1964, 1963, 1007, - 1006, 1004, 1002, 999, 41, 996, 37, 1017, 1015, 1012, 1009, 52, 1025, 1022, 1936, 1935, 1933, 1938, 942, 940, - 938, 935, 932, 5, 2, 955, 953, 950, 947, 18, 943, 15, 965, 962, 958, 1895, 1894, 1892, 1890, 973, 1899, 1897, - 1379, 325, 1364, 1362, 288, 285, 1334, 1332, 1330, 241, 238, 234, 1287, 1285, 1283, 1280, 1294, 2112, 188, 185, - 181, 178, 2028, 1219, 1217, 1215, 1212, 200, 1209, 1227, 2074, 2072, 583, 553, 551, 1583, 505, 503, 500, 513, - 1557, 1555, 444, 442, 439, 436, 2213, 455, 451, 1507, 1505, 1502, 796, 763, 762, 760, 767, 711, 710, 708, 706, - 2377, 718, 715, 1710, 2544, 917, 915, 2681, 1627, 1597, 1595, 2325, 1769, 1749, 1747, 1499, 1438, 1435, 2204, - 1390, 1388, 1385, 1395, 2169, 2167, 1704, 1665, 1662, 1625, 1623, 1620, 1770, 1329, 1282, 1279, 2109, 1214, 1207, - 1222, 2068, 2065, 1149, 1147, 1144, 1141, 146, 1157, 1154, 2013, 2011, 2008, 2015, 1579, 1549, 1546, 1495, 1487, - 1433, 1431, 1428, 1425, 388, 1440, 2205, 1705, 658, 1667, 1664, 1119, 1095, 1093, 1978, 1057, 1055, 1052, 1062, - 1962, 1960, 1005, 1003, 1000, 997, 38, 1013, 1010, 1932, 1930, 1927, 1934, 941, 939, 936, 933, 6, 930, 3, 951, - 948, 944, 1889, 1887, 1884, 1881, 959, 1893, 1891, 35, 1377, 1360, 1358, 1327, 1325, 1322, 1331, 1277, 1275, - 1272, 1269, 235, 1284, 2110, 1205, 1204, 1201, 1198, 182, 1195, 179, 1213, 2070, 2067, 1580, 501, 1551, 1548, - 440, 437, 1497, 1494, 1490, 1503, 761, 709, 707, 1706, 913, 912, 2198, 1386, 2164, 2161, 1621, 1766, 2103, 1208, - 2058, 2054, 1145, 1142, 2005, 2002, 1999, 2009, 1488, 1429, 1426, 2200, 1698, 1659, 1656, 1975, 1053, 1957, 1954, - 1001, 998, 1924, 1921, 1918, 1928, 937, 934, 931, 1879, 1876, 1873, 1870, 945, 1885, 1882, 1323, 1273, 1270, - 2105, 1202, 1199, 1196, 1211, 2061, 2057, 1576, 1543, 1540, 1484, 1481, 1478, 1491, 1700}; -} diff --git a/port_src/core/DONE/pdf417/PDF417Reader.java b/port_src/core/DONE/pdf417/PDF417Reader.java deleted file mode 100644 index 142e3be..0000000 --- a/port_src/core/DONE/pdf417/PDF417Reader.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Reader; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.multi.MultipleBarcodeReader; -import com.google.zxing.pdf417.decoder.PDF417ScanningDecoder; -import com.google.zxing.pdf417.detector.Detector; -import com.google.zxing.pdf417.detector.PDF417DetectorResult; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * This implementation can detect and decode PDF417 codes in an image. - * - * @author Guenther Grau - */ -public final class PDF417Reader implements Reader, MultipleBarcodeReader { - - private static final Result[] EMPTY_RESULT_ARRAY = new Result[0]; - - /** - * Locates and decodes a PDF417 code in an image. - * - * @return a String representing the content encoded by the PDF417 code - * @throws NotFoundException if a PDF417 code cannot be found, - * @throws FormatException if a PDF417 cannot be decoded - */ - @Override - public Result decode(BinaryBitmap image) throws NotFoundException, FormatException, ChecksumException { - return decode(image, null); - } - - @Override - public Result decode(BinaryBitmap image, Map hints) throws NotFoundException, FormatException, - ChecksumException { - Result[] result = decode(image, hints, false); - if (result.length == 0 || result[0] == null) { - throw NotFoundException.getNotFoundInstance(); - } - return result[0]; - } - - @Override - public Result[] decodeMultiple(BinaryBitmap image) throws NotFoundException { - return decodeMultiple(image, null); - } - - @Override - public Result[] decodeMultiple(BinaryBitmap image, Map hints) throws NotFoundException { - try { - return decode(image, hints, true); - } catch (FormatException | ChecksumException ignored) { - throw NotFoundException.getNotFoundInstance(); - } - } - - private static Result[] decode(BinaryBitmap image, Map hints, boolean multiple) - throws NotFoundException, FormatException, ChecksumException { - List results = new ArrayList<>(); - PDF417DetectorResult detectorResult = Detector.detect(image, hints, multiple); - for (ResultPoint[] points : detectorResult.getPoints()) { - DecoderResult decoderResult = PDF417ScanningDecoder.decode(detectorResult.getBits(), points[4], points[5], - points[6], points[7], getMinCodewordWidth(points), getMaxCodewordWidth(points)); - Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.PDF_417); - result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.getECLevel()); - PDF417ResultMetadata pdf417ResultMetadata = (PDF417ResultMetadata) decoderResult.getOther(); - if (pdf417ResultMetadata != null) { - result.putMetadata(ResultMetadataType.PDF417_EXTRA_METADATA, pdf417ResultMetadata); - } - result.putMetadata(ResultMetadataType.ORIENTATION, detectorResult.getRotation()); - result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]L" + decoderResult.getSymbologyModifier()); - results.add(result); - } - return results.toArray(EMPTY_RESULT_ARRAY); - } - - private static int getMaxWidth(ResultPoint p1, ResultPoint p2) { - if (p1 == null || p2 == null) { - return 0; - } - return (int) Math.abs(p1.getX() - p2.getX()); - } - - private static int getMinWidth(ResultPoint p1, ResultPoint p2) { - if (p1 == null || p2 == null) { - return Integer.MAX_VALUE; - } - return (int) Math.abs(p1.getX() - p2.getX()); - } - - private static int getMaxCodewordWidth(ResultPoint[] p) { - return Math.max( - Math.max(getMaxWidth(p[0], p[4]), getMaxWidth(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD / - PDF417Common.MODULES_IN_STOP_PATTERN), - Math.max(getMaxWidth(p[1], p[5]), getMaxWidth(p[7], p[3]) * PDF417Common.MODULES_IN_CODEWORD / - PDF417Common.MODULES_IN_STOP_PATTERN)); - } - - private static int getMinCodewordWidth(ResultPoint[] p) { - return Math.min( - Math.min(getMinWidth(p[0], p[4]), getMinWidth(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD / - PDF417Common.MODULES_IN_STOP_PATTERN), - Math.min(getMinWidth(p[1], p[5]), getMinWidth(p[7], p[3]) * PDF417Common.MODULES_IN_CODEWORD / - PDF417Common.MODULES_IN_STOP_PATTERN)); - } - - @Override - public void reset() { - // nothing needs to be reset - } - -} diff --git a/port_src/core/DONE/pdf417/PDF417ResultMetadata.java b/port_src/core/DONE/pdf417/PDF417ResultMetadata.java deleted file mode 100644 index 5684c33..0000000 --- a/port_src/core/DONE/pdf417/PDF417ResultMetadata.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417; - -/** - * @author Guenther Grau - */ -public final class PDF417ResultMetadata { - - private int segmentIndex; - private String fileId; - private boolean lastSegment; - private int segmentCount = -1; - private String sender; - private String addressee; - private String fileName; - private long fileSize = -1; - private long timestamp = -1; - private int checksum = -1; - private int[] optionalData; - - /** - * The Segment ID represents the segment of the whole file distributed over different symbols. - * - * @return File segment index - */ - public int getSegmentIndex() { - return segmentIndex; - } - - public void setSegmentIndex(int segmentIndex) { - this.segmentIndex = segmentIndex; - } - - /** - * Is the same for each related PDF417 symbol - * - * @return File ID - */ - public String getFileId() { - return fileId; - } - - public void setFileId(String fileId) { - this.fileId = fileId; - } - - /** - * @return always null - * @deprecated use dedicated already parsed fields - */ - @Deprecated - public int[] getOptionalData() { - return optionalData; - } - - /** - * @param optionalData old optional data format as int array - * @deprecated parse and use new fields - */ - @Deprecated - public void setOptionalData(int[] optionalData) { - this.optionalData = optionalData; - } - - - /** - * @return true if it is the last segment - */ - public boolean isLastSegment() { - return lastSegment; - } - - public void setLastSegment(boolean lastSegment) { - this.lastSegment = lastSegment; - } - - /** - * @return count of segments, -1 if not set - */ - public int getSegmentCount() { - return segmentCount; - } - - public void setSegmentCount(int segmentCount) { - this.segmentCount = segmentCount; - } - - public String getSender() { - return sender; - } - - public void setSender(String sender) { - this.sender = sender; - } - - public String getAddressee() { - return addressee; - } - - public void setAddressee(String addressee) { - this.addressee = addressee; - } - - /** - * Filename of the encoded file - * - * @return filename - */ - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - /** - * filesize in bytes of the encoded file - * - * @return filesize in bytes, -1 if not set - */ - public long getFileSize() { - return fileSize; - } - - public void setFileSize(long fileSize) { - this.fileSize = fileSize; - } - - /** - * 16-bit CRC checksum using CCITT-16 - * - * @return crc checksum, -1 if not set - */ - public int getChecksum() { - return checksum; - } - - public void setChecksum(int checksum) { - this.checksum = checksum; - } - - /** - * unix epock timestamp, elapsed seconds since 1970-01-01 - * - * @return elapsed seconds, -1 if not set - */ - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - -} diff --git a/port_src/core/DONE/pdf417/PDF417Writer.java b/port_src/core/DONE/pdf417/PDF417Writer.java deleted file mode 100644 index 80e6ff7..0000000 --- a/port_src/core/DONE/pdf417/PDF417Writer.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.Writer; -import com.google.zxing.WriterException; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.pdf417.encoder.Compaction; -import com.google.zxing.pdf417.encoder.Dimensions; -import com.google.zxing.pdf417.encoder.PDF417; - -import java.nio.charset.Charset; -import java.util.Map; - -/** - * @author Jacob Haynes - * @author qwandor@google.com (Andrew Walbran) - */ -public final class PDF417Writer implements Writer { - - /** - * default white space (margin) around the code - */ - private static final int WHITE_SPACE = 30; - - /** - * default error correction level - */ - private static final int DEFAULT_ERROR_CORRECTION_LEVEL = 2; - - @Override - public BitMatrix encode(String contents, - BarcodeFormat format, - int width, - int height, - Map hints) throws WriterException { - if (format != BarcodeFormat.PDF_417) { - throw new IllegalArgumentException("Can only encode PDF_417, but got " + format); - } - - PDF417 encoder = new PDF417(); - int margin = WHITE_SPACE; - int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL; - boolean autoECI = false; - - if (hints != null) { - if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) { - encoder.setCompact(Boolean.parseBoolean(hints.get(EncodeHintType.PDF417_COMPACT).toString())); - } - if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) { - encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString())); - } - if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) { - Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS); - encoder.setDimensions(dimensions.getMaxCols(), - dimensions.getMinCols(), - dimensions.getMaxRows(), - dimensions.getMinRows()); - } - if (hints.containsKey(EncodeHintType.MARGIN)) { - margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString()); - } - if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) { - errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString()); - } - if (hints.containsKey(EncodeHintType.CHARACTER_SET)) { - Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString()); - encoder.setEncoding(encoding); - } - autoECI = hints.containsKey(EncodeHintType.PDF417_AUTO_ECI) && - Boolean.parseBoolean(hints.get(EncodeHintType.PDF417_AUTO_ECI).toString()); - } - - return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin, autoECI); - } - - @Override - public BitMatrix encode(String contents, - BarcodeFormat format, - int width, - int height) throws WriterException { - return encode(contents, format, width, height, null); - } - - /** - * Takes encoder, accounts for width/height, and retrieves bit matrix - */ - private static BitMatrix bitMatrixFromEncoder(PDF417 encoder, - String contents, - int errorCorrectionLevel, - int width, - int height, - int margin, - boolean autoECI) throws WriterException { - encoder.generateBarcodeLogic(contents, errorCorrectionLevel, autoECI); - - int aspectRatio = 4; - byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, aspectRatio); - boolean rotated = false; - if ((height > width) != (originalScale[0].length < originalScale.length)) { - originalScale = rotateArray(originalScale); - rotated = true; - } - - int scaleX = width / originalScale[0].length; - int scaleY = height / originalScale.length; - int scale = Math.min(scaleX, scaleY); - - if (scale > 1) { - byte[][] scaledMatrix = - encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * aspectRatio); - if (rotated) { - scaledMatrix = rotateArray(scaledMatrix); - } - return bitMatrixFromBitArray(scaledMatrix, margin); - } - return bitMatrixFromBitArray(originalScale, margin); - } - - /** - * This takes an array holding the values of the PDF 417 - * - * @param input a byte array of information with 0 is black, and 1 is white - * @param margin border around the barcode - * @return BitMatrix of the input - */ - private static BitMatrix bitMatrixFromBitArray(byte[][] input, int margin) { - // Creates the bit matrix with extra space for whitespace - BitMatrix output = new BitMatrix(input[0].length + 2 * margin, input.length + 2 * margin); - output.clear(); - for (int y = 0, yOutput = output.getHeight() - margin - 1; y < input.length; y++, yOutput--) { - byte[] inputY = input[y]; - for (int x = 0; x < input[0].length; x++) { - // Zero is white in the byte matrix - if (inputY[x] == 1) { - output.set(x + margin, yOutput); - } - } - } - return output; - } - - /** - * Takes and rotates the it 90 degrees - */ - private static byte[][] rotateArray(byte[][] bitarray) { - byte[][] temp = new byte[bitarray[0].length][bitarray.length]; - for (int ii = 0; ii < bitarray.length; ii++) { - // This makes the direction consistent on screen when rotating the - // screen; - int inverseii = bitarray.length - ii - 1; - for (int jj = 0; jj < bitarray[0].length; jj++) { - temp[jj][inverseii] = bitarray[ii][jj]; - } - } - return temp; - } - -} diff --git a/port_src/core/DONE/pdf417/decoder/BarcodeMetadata.java b/port_src/core/DONE/pdf417/decoder/BarcodeMetadata.java deleted file mode 100644 index 9c1acbf..0000000 --- a/port_src/core/DONE/pdf417/decoder/BarcodeMetadata.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder; - -/** - * @author Guenther Grau - */ -final class BarcodeMetadata { - - private final int columnCount; - private final int errorCorrectionLevel; - private final int rowCountUpperPart; - private final int rowCountLowerPart; - private final int rowCount; - - BarcodeMetadata(int columnCount, int rowCountUpperPart, int rowCountLowerPart, int errorCorrectionLevel) { - this.columnCount = columnCount; - this.errorCorrectionLevel = errorCorrectionLevel; - this.rowCountUpperPart = rowCountUpperPart; - this.rowCountLowerPart = rowCountLowerPart; - this.rowCount = rowCountUpperPart + rowCountLowerPart; - } - - int getColumnCount() { - return columnCount; - } - - int getErrorCorrectionLevel() { - return errorCorrectionLevel; - } - - int getRowCount() { - return rowCount; - } - - int getRowCountUpperPart() { - return rowCountUpperPart; - } - - int getRowCountLowerPart() { - return rowCountLowerPart; - } - -} diff --git a/port_src/core/DONE/pdf417/decoder/BarcodeValue.java b/port_src/core/DONE/pdf417/decoder/BarcodeValue.java deleted file mode 100644 index 55a1c68..0000000 --- a/port_src/core/DONE/pdf417/decoder/BarcodeValue.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder; - -import com.google.zxing.pdf417.PDF417Common; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -/** - * @author Guenther Grau - */ -final class BarcodeValue { - private final Map values = new HashMap<>(); - - /** - * Add an occurrence of a value - */ - void setValue(int value) { - Integer confidence = values.get(value); - if (confidence == null) { - confidence = 0; - } - confidence++; - values.put(value, confidence); - } - - /** - * Determines the maximum occurrence of a set value and returns all values which were set with this occurrence. - * @return an array of int, containing the values with the highest occurrence, or null, if no value was set - */ - int[] getValue() { - int maxConfidence = -1; - Collection result = new ArrayList<>(); - for (Entry entry : values.entrySet()) { - if (entry.getValue() > maxConfidence) { - maxConfidence = entry.getValue(); - result.clear(); - result.add(entry.getKey()); - } else if (entry.getValue() == maxConfidence) { - result.add(entry.getKey()); - } - } - return PDF417Common.toIntArray(result); - } - - Integer getConfidence(int value) { - return values.get(value); - } - -} diff --git a/port_src/core/DONE/pdf417/decoder/BoundingBox.java b/port_src/core/DONE/pdf417/decoder/BoundingBox.java deleted file mode 100644 index 624a539..0000000 --- a/port_src/core/DONE/pdf417/decoder/BoundingBox.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder; - -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; - -/** - * @author Guenther Grau - */ -final class BoundingBox { - - private final BitMatrix image; - private final ResultPoint topLeft; - private final ResultPoint bottomLeft; - private final ResultPoint topRight; - private final ResultPoint bottomRight; - private final int minX; - private final int maxX; - private final int minY; - private final int maxY; - - BoundingBox(BitMatrix image, - ResultPoint topLeft, - ResultPoint bottomLeft, - ResultPoint topRight, - ResultPoint bottomRight) throws NotFoundException { - boolean leftUnspecified = topLeft == null || bottomLeft == null; - boolean rightUnspecified = topRight == null || bottomRight == null; - if (leftUnspecified && rightUnspecified) { - throw NotFoundException.getNotFoundInstance(); - } - if (leftUnspecified) { - topLeft = new ResultPoint(0, topRight.getY()); - bottomLeft = new ResultPoint(0, bottomRight.getY()); - } else if (rightUnspecified) { - topRight = new ResultPoint(image.getWidth() - 1, topLeft.getY()); - bottomRight = new ResultPoint(image.getWidth() - 1, bottomLeft.getY()); - } - this.image = image; - this.topLeft = topLeft; - this.bottomLeft = bottomLeft; - this.topRight = topRight; - this.bottomRight = bottomRight; - this.minX = (int) Math.min(topLeft.getX(), bottomLeft.getX()); - this.maxX = (int) Math.max(topRight.getX(), bottomRight.getX()); - this.minY = (int) Math.min(topLeft.getY(), topRight.getY()); - this.maxY = (int) Math.max(bottomLeft.getY(), bottomRight.getY()); - } - - BoundingBox(BoundingBox boundingBox) { - this.image = boundingBox.image; - this.topLeft = boundingBox.topLeft; - this.bottomLeft = boundingBox.bottomLeft; - this.topRight = boundingBox.topRight; - this.bottomRight = boundingBox.bottomRight; - this.minX = boundingBox.minX; - this.maxX = boundingBox.maxX; - this.minY = boundingBox.minY; - this.maxY = boundingBox.maxY; - } - - static BoundingBox merge(BoundingBox leftBox, BoundingBox rightBox) throws NotFoundException { - if (leftBox == null) { - return rightBox; - } - if (rightBox == null) { - return leftBox; - } - return new BoundingBox(leftBox.image, leftBox.topLeft, leftBox.bottomLeft, rightBox.topRight, rightBox.bottomRight); - } - - BoundingBox addMissingRows(int missingStartRows, int missingEndRows, boolean isLeft) throws NotFoundException { - ResultPoint newTopLeft = topLeft; - ResultPoint newBottomLeft = bottomLeft; - ResultPoint newTopRight = topRight; - ResultPoint newBottomRight = bottomRight; - - if (missingStartRows > 0) { - ResultPoint top = isLeft ? topLeft : topRight; - int newMinY = (int) top.getY() - missingStartRows; - if (newMinY < 0) { - newMinY = 0; - } - ResultPoint newTop = new ResultPoint(top.getX(), newMinY); - if (isLeft) { - newTopLeft = newTop; - } else { - newTopRight = newTop; - } - } - - if (missingEndRows > 0) { - ResultPoint bottom = isLeft ? bottomLeft : bottomRight; - int newMaxY = (int) bottom.getY() + missingEndRows; - if (newMaxY >= image.getHeight()) { - newMaxY = image.getHeight() - 1; - } - ResultPoint newBottom = new ResultPoint(bottom.getX(), newMaxY); - if (isLeft) { - newBottomLeft = newBottom; - } else { - newBottomRight = newBottom; - } - } - - return new BoundingBox(image, newTopLeft, newBottomLeft, newTopRight, newBottomRight); - } - - int getMinX() { - return minX; - } - - int getMaxX() { - return maxX; - } - - int getMinY() { - return minY; - } - - int getMaxY() { - return maxY; - } - - ResultPoint getTopLeft() { - return topLeft; - } - - ResultPoint getTopRight() { - return topRight; - } - - ResultPoint getBottomLeft() { - return bottomLeft; - } - - ResultPoint getBottomRight() { - return bottomRight; - } - -} diff --git a/port_src/core/DONE/pdf417/decoder/Codeword.java b/port_src/core/DONE/pdf417/decoder/Codeword.java deleted file mode 100644 index bb5477d..0000000 --- a/port_src/core/DONE/pdf417/decoder/Codeword.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder; - -/** - * @author Guenther Grau - */ -final class Codeword { - - private static final int BARCODE_ROW_UNKNOWN = -1; - - private final int startX; - private final int endX; - private final int bucket; - private final int value; - private int rowNumber = BARCODE_ROW_UNKNOWN; - - Codeword(int startX, int endX, int bucket, int value) { - this.startX = startX; - this.endX = endX; - this.bucket = bucket; - this.value = value; - } - - boolean hasValidRowNumber() { - return isValidRowNumber(rowNumber); - } - - boolean isValidRowNumber(int rowNumber) { - return rowNumber != BARCODE_ROW_UNKNOWN && bucket == (rowNumber % 3) * 3; - } - - void setRowNumberAsRowIndicatorColumn() { - rowNumber = (value / 30) * 3 + bucket / 3; - } - - int getWidth() { - return endX - startX; - } - - int getStartX() { - return startX; - } - - int getEndX() { - return endX; - } - - int getBucket() { - return bucket; - } - - int getValue() { - return value; - } - - int getRowNumber() { - return rowNumber; - } - - void setRowNumber(int rowNumber) { - this.rowNumber = rowNumber; - } - - @Override - public String toString() { - return rowNumber + "|" + value; - } - -} diff --git a/port_src/core/DONE/pdf417/decoder/DecodedBitStreamParser.java b/port_src/core/DONE/pdf417/decoder/DecodedBitStreamParser.java deleted file mode 100644 index 56a7e2e..0000000 --- a/port_src/core/DONE/pdf417/decoder/DecodedBitStreamParser.java +++ /dev/null @@ -1,698 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.common.ECIStringBuilder; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.pdf417.PDF417ResultMetadata; - -import java.math.BigInteger; -import java.util.Arrays; - -/** - *

This class contains the methods for decoding the PDF417 codewords.

- * - * @author SITA Lab (kevin.osullivan@sita.aero) - * @author Guenther Grau - */ -final class DecodedBitStreamParser { - - private enum Mode { - ALPHA, - LOWER, - MIXED, - PUNCT, - ALPHA_SHIFT, - PUNCT_SHIFT - } - - private static final int TEXT_COMPACTION_MODE_LATCH = 900; - private static final int BYTE_COMPACTION_MODE_LATCH = 901; - private static final int NUMERIC_COMPACTION_MODE_LATCH = 902; - private static final int BYTE_COMPACTION_MODE_LATCH_6 = 924; - private static final int ECI_USER_DEFINED = 925; - private static final int ECI_GENERAL_PURPOSE = 926; - private static final int ECI_CHARSET = 927; - private static final int BEGIN_MACRO_PDF417_CONTROL_BLOCK = 928; - private static final int BEGIN_MACRO_PDF417_OPTIONAL_FIELD = 923; - private static final int MACRO_PDF417_TERMINATOR = 922; - private static final int MODE_SHIFT_TO_BYTE_COMPACTION_MODE = 913; - private static final int MAX_NUMERIC_CODEWORDS = 15; - - private static final int MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME = 0; - private static final int MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT = 1; - private static final int MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP = 2; - private static final int MACRO_PDF417_OPTIONAL_FIELD_SENDER = 3; - private static final int MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE = 4; - private static final int MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE = 5; - private static final int MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM = 6; - - private static final int PL = 25; - private static final int LL = 27; - private static final int AS = 27; - private static final int ML = 28; - private static final int AL = 28; - private static final int PS = 29; - private static final int PAL = 29; - - private static final char[] PUNCT_CHARS = - ";<>@[\\]_`~!\r\t,:\n-.$/\"|*()?{}'".toCharArray(); - - private static final char[] MIXED_CHARS = - "0123456789&\r\t,:#-.$/+%*=^".toCharArray(); - - /** - * Table containing values for the exponent of 900. - * This is used in the numeric compaction decode algorithm. - */ - private static final BigInteger[] EXP900; - - static { - EXP900 = new BigInteger[16]; - EXP900[0] = BigInteger.ONE; - BigInteger nineHundred = BigInteger.valueOf(900); - EXP900[1] = nineHundred; - for (int i = 2; i < EXP900.length; i++) { - EXP900[i] = EXP900[i - 1].multiply(nineHundred); - } - } - - private static final int NUMBER_OF_SEQUENCE_CODEWORDS = 2; - - private DecodedBitStreamParser() { - } - - static DecoderResult decode(int[] codewords, String ecLevel) throws FormatException { - ECIStringBuilder result = new ECIStringBuilder(codewords.length * 2); - int codeIndex = textCompaction(codewords, 1, result); - PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); - while (codeIndex < codewords[0]) { - int code = codewords[codeIndex++]; - switch (code) { - case TEXT_COMPACTION_MODE_LATCH: - codeIndex = textCompaction(codewords, codeIndex, result); - break; - case BYTE_COMPACTION_MODE_LATCH: - case BYTE_COMPACTION_MODE_LATCH_6: - codeIndex = byteCompaction(code, codewords, codeIndex, result); - break; - case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: - result.append((char) codewords[codeIndex++]); - break; - case NUMERIC_COMPACTION_MODE_LATCH: - codeIndex = numericCompaction(codewords, codeIndex, result); - break; - case ECI_CHARSET: - result.appendECI(codewords[codeIndex++]); - break; - case ECI_GENERAL_PURPOSE: - // Can't do anything with generic ECI; skip its 2 characters - codeIndex += 2; - break; - case ECI_USER_DEFINED: - // Can't do anything with user ECI; skip its 1 character - codeIndex++; - break; - case BEGIN_MACRO_PDF417_CONTROL_BLOCK: - codeIndex = decodeMacroBlock(codewords, codeIndex, resultMetadata); - break; - case BEGIN_MACRO_PDF417_OPTIONAL_FIELD: - case MACRO_PDF417_TERMINATOR: - // Should not see these outside a macro block - throw FormatException.getFormatInstance(); - default: - // Default to text compaction. During testing numerous barcodes - // appeared to be missing the starting mode. In these cases defaulting - // to text compaction seems to work. - codeIndex--; - codeIndex = textCompaction(codewords, codeIndex, result); - break; - } - } - if (result.isEmpty() && resultMetadata.getFileId() == null) { - throw FormatException.getFormatInstance(); - } - DecoderResult decoderResult = new DecoderResult(null, result.toString(), null, ecLevel); - decoderResult.setOther(resultMetadata); - return decoderResult; - } - - @SuppressWarnings("deprecation") - static int decodeMacroBlock(int[] codewords, int codeIndex, PDF417ResultMetadata resultMetadata) - throws FormatException { - if (codeIndex + NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0]) { - // we must have at least two bytes left for the segment index - throw FormatException.getFormatInstance(); - } - int[] segmentIndexArray = new int[NUMBER_OF_SEQUENCE_CODEWORDS]; - for (int i = 0; i < NUMBER_OF_SEQUENCE_CODEWORDS; i++, codeIndex++) { - segmentIndexArray[i] = codewords[codeIndex]; - } - String segmentIndexString = decodeBase900toBase10(segmentIndexArray, NUMBER_OF_SEQUENCE_CODEWORDS); - if (segmentIndexString.isEmpty()) { - resultMetadata.setSegmentIndex(0); - } else { - try { - resultMetadata.setSegmentIndex(Integer.parseInt(segmentIndexString)); - } catch (NumberFormatException nfe) { - // too large; bad input? - throw FormatException.getFormatInstance(); - } - } - - // Decoding the fileId codewords as 0-899 numbers, each 0-filled to width 3. This follows the spec - // (See ISO/IEC 15438:2015 Annex H.6) and preserves all info, but some generators (e.g. TEC-IT) write - // the fileId using text compaction, so in those cases the fileId will appear mangled. - StringBuilder fileId = new StringBuilder(); - while (codeIndex < codewords[0] && - codeIndex < codewords.length && - codewords[codeIndex] != MACRO_PDF417_TERMINATOR && - codewords[codeIndex] != BEGIN_MACRO_PDF417_OPTIONAL_FIELD) { - fileId.append(String.format("%03d", codewords[codeIndex])); - codeIndex++; - } - if (fileId.length() == 0) { - // at least one fileId codeword is required (Annex H.2) - throw FormatException.getFormatInstance(); - } - resultMetadata.setFileId(fileId.toString()); - - int optionalFieldsStart = -1; - if (codewords[codeIndex] == BEGIN_MACRO_PDF417_OPTIONAL_FIELD) { - optionalFieldsStart = codeIndex + 1; - } - - while (codeIndex < codewords[0]) { - switch (codewords[codeIndex]) { - case BEGIN_MACRO_PDF417_OPTIONAL_FIELD: - codeIndex++; - switch (codewords[codeIndex]) { - case MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME: - ECIStringBuilder fileName = new ECIStringBuilder(); - codeIndex = textCompaction(codewords, codeIndex + 1, fileName); - resultMetadata.setFileName(fileName.toString()); - break; - case MACRO_PDF417_OPTIONAL_FIELD_SENDER: - ECIStringBuilder sender = new ECIStringBuilder(); - codeIndex = textCompaction(codewords, codeIndex + 1, sender); - resultMetadata.setSender(sender.toString()); - break; - case MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE: - ECIStringBuilder addressee = new ECIStringBuilder(); - codeIndex = textCompaction(codewords, codeIndex + 1, addressee); - resultMetadata.setAddressee(addressee.toString()); - break; - case MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT: - ECIStringBuilder segmentCount = new ECIStringBuilder(); - codeIndex = numericCompaction(codewords, codeIndex + 1, segmentCount); - resultMetadata.setSegmentCount(Integer.parseInt(segmentCount.toString())); - break; - case MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP: - ECIStringBuilder timestamp = new ECIStringBuilder(); - codeIndex = numericCompaction(codewords, codeIndex + 1, timestamp); - resultMetadata.setTimestamp(Long.parseLong(timestamp.toString())); - break; - case MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM: - ECIStringBuilder checksum = new ECIStringBuilder(); - codeIndex = numericCompaction(codewords, codeIndex + 1, checksum); - resultMetadata.setChecksum(Integer.parseInt(checksum.toString())); - break; - case MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE: - ECIStringBuilder fileSize = new ECIStringBuilder(); - codeIndex = numericCompaction(codewords, codeIndex + 1, fileSize); - resultMetadata.setFileSize(Long.parseLong(fileSize.toString())); - break; - default: - throw FormatException.getFormatInstance(); - } - break; - case MACRO_PDF417_TERMINATOR: - codeIndex++; - resultMetadata.setLastSegment(true); - break; - default: - throw FormatException.getFormatInstance(); - } - } - - // copy optional fields to additional options - if (optionalFieldsStart != -1) { - int optionalFieldsLength = codeIndex - optionalFieldsStart; - if (resultMetadata.isLastSegment()) { - // do not include terminator - optionalFieldsLength--; - } - resultMetadata.setOptionalData( - Arrays.copyOfRange(codewords, optionalFieldsStart, optionalFieldsStart + optionalFieldsLength)); - } - - return codeIndex; - } - - /** - * Text Compaction mode (see 5.4.1.5) permits all printable ASCII characters to be - * encoded, i.e. values 32 - 126 inclusive in accordance with ISO/IEC 646 (IRV), as - * well as selected control characters. - * - * @param codewords The array of codewords (data + error) - * @param codeIndex The current index into the codeword array. - * @param result The decoded data is appended to the result. - * @return The next index into the codeword array. - */ - private static int textCompaction(int[] codewords, int codeIndex, ECIStringBuilder result) throws FormatException { - // 2 character per codeword - int[] textCompactionData = new int[(codewords[0] - codeIndex) * 2]; - // Used to hold the byte compaction value if there is a mode shift - int[] byteCompactionData = new int[(codewords[0] - codeIndex) * 2]; - - int index = 0; - boolean end = false; - Mode subMode = Mode.ALPHA; - while ((codeIndex < codewords[0]) && !end) { - int code = codewords[codeIndex++]; - if (code < TEXT_COMPACTION_MODE_LATCH) { - textCompactionData[index] = code / 30; - textCompactionData[index + 1] = code % 30; - index += 2; - } else { - switch (code) { - case TEXT_COMPACTION_MODE_LATCH: - // reinitialize text compaction mode to alpha sub mode - textCompactionData[index++] = TEXT_COMPACTION_MODE_LATCH; - break; - case BYTE_COMPACTION_MODE_LATCH: - case BYTE_COMPACTION_MODE_LATCH_6: - case NUMERIC_COMPACTION_MODE_LATCH: - case BEGIN_MACRO_PDF417_CONTROL_BLOCK: - case BEGIN_MACRO_PDF417_OPTIONAL_FIELD: - case MACRO_PDF417_TERMINATOR: - codeIndex--; - end = true; - break; - case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: - // The Mode Shift codeword 913 shall cause a temporary - // switch from Text Compaction mode to Byte Compaction mode. - // This switch shall be in effect for only the next codeword, - // after which the mode shall revert to the prevailing sub-mode - // of the Text Compaction mode. Codeword 913 is only available - // in Text Compaction mode; its use is described in 5.4.2.4. - textCompactionData[index] = MODE_SHIFT_TO_BYTE_COMPACTION_MODE; - code = codewords[codeIndex++]; - byteCompactionData[index] = code; - index++; - break; - case ECI_CHARSET: - subMode = decodeTextCompaction(textCompactionData, byteCompactionData, index, result, subMode); - result.appendECI(codewords[codeIndex++]); - textCompactionData = new int[(codewords[0] - codeIndex) * 2]; - byteCompactionData = new int[(codewords[0] - codeIndex) * 2]; - index = 0; - break; - } - } - } - decodeTextCompaction(textCompactionData, byteCompactionData, index, result, subMode); - return codeIndex; - } - - /** - * The Text Compaction mode includes all the printable ASCII characters - * (i.e. values from 32 to 126) and three ASCII control characters: HT or tab - * (ASCII value 9), LF or line feed (ASCII value 10), and CR or carriage - * return (ASCII value 13). The Text Compaction mode also includes various latch - * and shift characters which are used exclusively within the mode. The Text - * Compaction mode encodes up to 2 characters per codeword. The compaction rules - * for converting data into PDF417 codewords are defined in 5.4.2.2. The sub-mode - * switches are defined in 5.4.2.3. - * - * @param textCompactionData The text compaction data. - * @param byteCompactionData The byte compaction data if there - * was a mode shift. - * @param length The size of the text compaction and byte compaction data. - * @param result The decoded data is appended to the result. - * @param startMode The mode in which decoding starts - * @return The mode in which decoding ended - */ - private static Mode decodeTextCompaction(int[] textCompactionData, - int[] byteCompactionData, - int length, - ECIStringBuilder result, - Mode startMode) { - // Beginning from an initial state - // The default compaction mode for PDF417 in effect at the start of each symbol shall always be Text - // Compaction mode Alpha sub-mode (uppercase alphabetic). A latch codeword from another mode to the Text - // Compaction mode shall always switch to the Text Compaction Alpha sub-mode. - Mode subMode = startMode; - Mode priorToShiftMode = startMode; - Mode latchedMode = startMode; - int i = 0; - while (i < length) { - int subModeCh = textCompactionData[i]; - char ch = 0; - switch (subMode) { - case ALPHA: - // Alpha (uppercase alphabetic) - if (subModeCh < 26) { - // Upper case Alpha Character - ch = (char) ('A' + subModeCh); - } else { - switch (subModeCh) { - case 26: - ch = ' '; - break; - case LL: - subMode = Mode.LOWER; - latchedMode = subMode; - break; - case ML: - subMode = Mode.MIXED; - latchedMode = subMode; - break; - case PS: - // Shift to punctuation - priorToShiftMode = subMode; - subMode = Mode.PUNCT_SHIFT; - break; - case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: - result.append((char) byteCompactionData[i]); - break; - case TEXT_COMPACTION_MODE_LATCH: - subMode = Mode.ALPHA; - latchedMode = subMode; - break; - } - } - break; - - case LOWER: - // Lower (lowercase alphabetic) - if (subModeCh < 26) { - ch = (char) ('a' + subModeCh); - } else { - switch (subModeCh) { - case 26: - ch = ' '; - break; - case AS: - // Shift to alpha - priorToShiftMode = subMode; - subMode = Mode.ALPHA_SHIFT; - break; - case ML: - subMode = Mode.MIXED; - latchedMode = subMode; - break; - case PS: - // Shift to punctuation - priorToShiftMode = subMode; - subMode = Mode.PUNCT_SHIFT; - break; - case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: - result.append((char) byteCompactionData[i]); - break; - case TEXT_COMPACTION_MODE_LATCH: - subMode = Mode.ALPHA; - latchedMode = subMode; - break; - } - } - break; - - case MIXED: - // Mixed (numeric and some punctuation) - if (subModeCh < PL) { - ch = MIXED_CHARS[subModeCh]; - } else { - switch (subModeCh) { - case PL: - subMode = Mode.PUNCT; - latchedMode = subMode; - break; - case 26: - ch = ' '; - break; - case LL: - subMode = Mode.LOWER; - latchedMode = subMode; - break; - case AL: - case TEXT_COMPACTION_MODE_LATCH: - subMode = Mode.ALPHA; - latchedMode = subMode; - break; - case PS: - // Shift to punctuation - priorToShiftMode = subMode; - subMode = Mode.PUNCT_SHIFT; - break; - case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: - result.append((char) byteCompactionData[i]); - break; - } - } - break; - - case PUNCT: - // Punctuation - if (subModeCh < PAL) { - ch = PUNCT_CHARS[subModeCh]; - } else { - switch (subModeCh) { - case PAL: - case TEXT_COMPACTION_MODE_LATCH: - subMode = Mode.ALPHA; - latchedMode = subMode; - break; - case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: - result.append((char) byteCompactionData[i]); - break; - } - } - break; - - case ALPHA_SHIFT: - // Restore sub-mode - subMode = priorToShiftMode; - if (subModeCh < 26) { - ch = (char) ('A' + subModeCh); - } else { - switch (subModeCh) { - case 26: - ch = ' '; - break; - case TEXT_COMPACTION_MODE_LATCH: - subMode = Mode.ALPHA; - break; - } - } - break; - - case PUNCT_SHIFT: - // Restore sub-mode - subMode = priorToShiftMode; - if (subModeCh < PAL) { - ch = PUNCT_CHARS[subModeCh]; - } else { - switch (subModeCh) { - case PAL: - case TEXT_COMPACTION_MODE_LATCH: - subMode = Mode.ALPHA; - break; - case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: - // PS before Shift-to-Byte is used as a padding character, - // see 5.4.2.4 of the specification - result.append((char) byteCompactionData[i]); - break; - } - } - break; - } - if (ch != 0) { - // Append decoded character to result - result.append(ch); - } - i++; - } - return latchedMode; - } - - /** - * Byte Compaction mode (see 5.4.3) permits all 256 possible 8-bit byte values to be encoded. - * This includes all ASCII characters value 0 to 127 inclusive and provides for international - * character set support. - * - * @param mode The byte compaction mode i.e. 901 or 924 - * @param codewords The array of codewords (data + error) - * @param codeIndex The current index into the codeword array. - * @param result The decoded data is appended to the result. - * @return The next index into the codeword array. - */ - private static int byteCompaction(int mode, - int[] codewords, - int codeIndex, - ECIStringBuilder result) throws FormatException { - boolean end = false; - - while (codeIndex < codewords[0] && !end) { - //handle leading ECIs - while (codeIndex < codewords[0] && codewords[codeIndex] == ECI_CHARSET) { - result.appendECI(codewords[++codeIndex]); - codeIndex++; - } - - if (codeIndex >= codewords[0] || codewords[codeIndex] >= TEXT_COMPACTION_MODE_LATCH) { - end = true; - } else { - //decode one block of 5 codewords to 6 bytes - long value = 0; - int count = 0; - do { - value = 900 * value + codewords[codeIndex++]; - count++; - } while (count < 5 && - codeIndex < codewords[0] && - codewords[codeIndex] < TEXT_COMPACTION_MODE_LATCH); - if (count == 5 && (mode == BYTE_COMPACTION_MODE_LATCH_6 || - codeIndex < codewords[0] && - codewords[codeIndex] < TEXT_COMPACTION_MODE_LATCH)) { - for (int i = 0; i < 6; i++) { - result.append((byte) (value >> (8 * (5 - i)))); - } - } else { - codeIndex -= count; - while ((codeIndex < codewords[0]) && !end) { - int code = codewords[codeIndex++]; - if (code < TEXT_COMPACTION_MODE_LATCH) { - result.append((byte) code); - } else if (code == ECI_CHARSET) { - result.appendECI(codewords[codeIndex++]); - } else { - codeIndex--; - end = true; - } - } - } - } - } - return codeIndex; - } - - /** - * Numeric Compaction mode (see 5.4.4) permits efficient encoding of numeric data strings. - * - * @param codewords The array of codewords (data + error) - * @param codeIndex The current index into the codeword array. - * @param result The decoded data is appended to the result. - * @return The next index into the codeword array. - */ - private static int numericCompaction(int[] codewords, int codeIndex, ECIStringBuilder result) throws FormatException { - int count = 0; - boolean end = false; - - int[] numericCodewords = new int[MAX_NUMERIC_CODEWORDS]; - - while (codeIndex < codewords[0] && !end) { - int code = codewords[codeIndex++]; - if (codeIndex == codewords[0]) { - end = true; - } - if (code < TEXT_COMPACTION_MODE_LATCH) { - numericCodewords[count] = code; - count++; - } else { - switch (code) { - case TEXT_COMPACTION_MODE_LATCH: - case BYTE_COMPACTION_MODE_LATCH: - case BYTE_COMPACTION_MODE_LATCH_6: - case BEGIN_MACRO_PDF417_CONTROL_BLOCK: - case BEGIN_MACRO_PDF417_OPTIONAL_FIELD: - case MACRO_PDF417_TERMINATOR: - case ECI_CHARSET: - codeIndex--; - end = true; - break; - } - } - if ((count % MAX_NUMERIC_CODEWORDS == 0 || code == NUMERIC_COMPACTION_MODE_LATCH || end) && count > 0) { - // Re-invoking Numeric Compaction mode (by using codeword 902 - // while in Numeric Compaction mode) serves to terminate the - // current Numeric Compaction mode grouping as described in 5.4.4.2, - // and then to start a new one grouping. - result.append(decodeBase900toBase10(numericCodewords, count)); - count = 0; - } - } - return codeIndex; - } - - /** - * Convert a list of Numeric Compacted codewords from Base 900 to Base 10. - * - * @param codewords The array of codewords - * @param count The number of codewords - * @return The decoded string representing the Numeric data. - */ - /* - EXAMPLE - Encode the fifteen digit numeric string 000213298174000 - Prefix the numeric string with a 1 and set the initial value of - t = 1 000 213 298 174 000 - Calculate codeword 0 - d0 = 1 000 213 298 174 000 mod 900 = 200 - - t = 1 000 213 298 174 000 div 900 = 1 111 348 109 082 - Calculate codeword 1 - d1 = 1 111 348 109 082 mod 900 = 282 - - t = 1 111 348 109 082 div 900 = 1 234 831 232 - Calculate codeword 2 - d2 = 1 234 831 232 mod 900 = 632 - - t = 1 234 831 232 div 900 = 1 372 034 - Calculate codeword 3 - d3 = 1 372 034 mod 900 = 434 - - t = 1 372 034 div 900 = 1 524 - Calculate codeword 4 - d4 = 1 524 mod 900 = 624 - - t = 1 524 div 900 = 1 - Calculate codeword 5 - d5 = 1 mod 900 = 1 - t = 1 div 900 = 0 - Codeword sequence is: 1, 624, 434, 632, 282, 200 - - Decode the above codewords involves - 1 x 900 power of 5 + 624 x 900 power of 4 + 434 x 900 power of 3 + - 632 x 900 power of 2 + 282 x 900 power of 1 + 200 x 900 power of 0 = 1000213298174000 - - Remove leading 1 => Result is 000213298174000 - */ - private static String decodeBase900toBase10(int[] codewords, int count) throws FormatException { - BigInteger result = BigInteger.ZERO; - for (int i = 0; i < count; i++) { - result = result.add(EXP900[count - i - 1].multiply(BigInteger.valueOf(codewords[i]))); - } - String resultString = result.toString(); - if (resultString.charAt(0) != '1') { - throw FormatException.getFormatInstance(); - } - return resultString.substring(1); - } - -} diff --git a/port_src/core/DONE/pdf417/decoder/DetectionResult.java b/port_src/core/DONE/pdf417/decoder/DetectionResult.java deleted file mode 100644 index 685475b..0000000 --- a/port_src/core/DONE/pdf417/decoder/DetectionResult.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder; - -import com.google.zxing.pdf417.PDF417Common; - -import java.util.Formatter; - -/** - * @author Guenther Grau - */ -final class DetectionResult { - - private static final int ADJUST_ROW_NUMBER_SKIP = 2; - - private final BarcodeMetadata barcodeMetadata; - private final DetectionResultColumn[] detectionResultColumns; - private BoundingBox boundingBox; - private final int barcodeColumnCount; - - DetectionResult(BarcodeMetadata barcodeMetadata, BoundingBox boundingBox) { - this.barcodeMetadata = barcodeMetadata; - this.barcodeColumnCount = barcodeMetadata.getColumnCount(); - this.boundingBox = boundingBox; - detectionResultColumns = new DetectionResultColumn[barcodeColumnCount + 2]; - } - - DetectionResultColumn[] getDetectionResultColumns() { - adjustIndicatorColumnRowNumbers(detectionResultColumns[0]); - adjustIndicatorColumnRowNumbers(detectionResultColumns[barcodeColumnCount + 1]); - int unadjustedCodewordCount = PDF417Common.MAX_CODEWORDS_IN_BARCODE; - int previousUnadjustedCount; - do { - previousUnadjustedCount = unadjustedCodewordCount; - unadjustedCodewordCount = adjustRowNumbers(); - } while (unadjustedCodewordCount > 0 && unadjustedCodewordCount < previousUnadjustedCount); - return detectionResultColumns; - } - - private void adjustIndicatorColumnRowNumbers(DetectionResultColumn detectionResultColumn) { - if (detectionResultColumn != null) { - ((DetectionResultRowIndicatorColumn) detectionResultColumn) - .adjustCompleteIndicatorColumnRowNumbers(barcodeMetadata); - } - } - - // TODO ensure that no detected codewords with unknown row number are left - // we should be able to estimate the row height and use it as a hint for the row number - // we should also fill the rows top to bottom and bottom to top - /** - * @return number of codewords which don't have a valid row number. Note that the count is not accurate as codewords - * will be counted several times. It just serves as an indicator to see when we can stop adjusting row numbers - */ - private int adjustRowNumbers() { - int unadjustedCount = adjustRowNumbersByRow(); - if (unadjustedCount == 0) { - return 0; - } - for (int barcodeColumn = 1; barcodeColumn < barcodeColumnCount + 1; barcodeColumn++) { - Codeword[] codewords = detectionResultColumns[barcodeColumn].getCodewords(); - for (int codewordsRow = 0; codewordsRow < codewords.length; codewordsRow++) { - if (codewords[codewordsRow] == null) { - continue; - } - if (!codewords[codewordsRow].hasValidRowNumber()) { - adjustRowNumbers(barcodeColumn, codewordsRow, codewords); - } - } - } - return unadjustedCount; - } - - private int adjustRowNumbersByRow() { - adjustRowNumbersFromBothRI(); - // TODO we should only do full row adjustments if row numbers of left and right row indicator column match. - // Maybe it's even better to calculated the height (in codeword rows) and divide it by the number of barcode - // rows. This, together with the LRI and RRI row numbers should allow us to get a good estimate where a row - // number starts and ends. - int unadjustedCount = adjustRowNumbersFromLRI(); - return unadjustedCount + adjustRowNumbersFromRRI(); - } - - private void adjustRowNumbersFromBothRI() { - if (detectionResultColumns[0] == null || detectionResultColumns[barcodeColumnCount + 1] == null) { - return; - } - Codeword[] LRIcodewords = detectionResultColumns[0].getCodewords(); - Codeword[] RRIcodewords = detectionResultColumns[barcodeColumnCount + 1].getCodewords(); - for (int codewordsRow = 0; codewordsRow < LRIcodewords.length; codewordsRow++) { - if (LRIcodewords[codewordsRow] != null && - RRIcodewords[codewordsRow] != null && - LRIcodewords[codewordsRow].getRowNumber() == RRIcodewords[codewordsRow].getRowNumber()) { - for (int barcodeColumn = 1; barcodeColumn <= barcodeColumnCount; barcodeColumn++) { - Codeword codeword = detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow]; - if (codeword == null) { - continue; - } - codeword.setRowNumber(LRIcodewords[codewordsRow].getRowNumber()); - if (!codeword.hasValidRowNumber()) { - detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow] = null; - } - } - } - } - } - - private int adjustRowNumbersFromRRI() { - if (detectionResultColumns[barcodeColumnCount + 1] == null) { - return 0; - } - int unadjustedCount = 0; - Codeword[] codewords = detectionResultColumns[barcodeColumnCount + 1].getCodewords(); - for (int codewordsRow = 0; codewordsRow < codewords.length; codewordsRow++) { - if (codewords[codewordsRow] == null) { - continue; - } - int rowIndicatorRowNumber = codewords[codewordsRow].getRowNumber(); - int invalidRowCounts = 0; - for (int barcodeColumn = barcodeColumnCount + 1; - barcodeColumn > 0 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; - barcodeColumn--) { - Codeword codeword = detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow]; - if (codeword != null) { - invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword); - if (!codeword.hasValidRowNumber()) { - unadjustedCount++; - } - } - } - } - return unadjustedCount; - } - - private int adjustRowNumbersFromLRI() { - if (detectionResultColumns[0] == null) { - return 0; - } - int unadjustedCount = 0; - Codeword[] codewords = detectionResultColumns[0].getCodewords(); - for (int codewordsRow = 0; codewordsRow < codewords.length; codewordsRow++) { - if (codewords[codewordsRow] == null) { - continue; - } - int rowIndicatorRowNumber = codewords[codewordsRow].getRowNumber(); - int invalidRowCounts = 0; - for (int barcodeColumn = 1; - barcodeColumn < barcodeColumnCount + 1 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; - barcodeColumn++) { - Codeword codeword = detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow]; - if (codeword != null) { - invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword); - if (!codeword.hasValidRowNumber()) { - unadjustedCount++; - } - } - } - } - return unadjustedCount; - } - - private static int adjustRowNumberIfValid(int rowIndicatorRowNumber, int invalidRowCounts, Codeword codeword) { - if (codeword == null) { - return invalidRowCounts; - } - if (!codeword.hasValidRowNumber()) { - if (codeword.isValidRowNumber(rowIndicatorRowNumber)) { - codeword.setRowNumber(rowIndicatorRowNumber); - invalidRowCounts = 0; - } else { - ++invalidRowCounts; - } - } - return invalidRowCounts; - } - - private void adjustRowNumbers(int barcodeColumn, int codewordsRow, Codeword[] codewords) { - Codeword codeword = codewords[codewordsRow]; - Codeword[] previousColumnCodewords = detectionResultColumns[barcodeColumn - 1].getCodewords(); - Codeword[] nextColumnCodewords = previousColumnCodewords; - if (detectionResultColumns[barcodeColumn + 1] != null) { - nextColumnCodewords = detectionResultColumns[barcodeColumn + 1].getCodewords(); - } - - Codeword[] otherCodewords = new Codeword[14]; - - otherCodewords[2] = previousColumnCodewords[codewordsRow]; - otherCodewords[3] = nextColumnCodewords[codewordsRow]; - - if (codewordsRow > 0) { - otherCodewords[0] = codewords[codewordsRow - 1]; - otherCodewords[4] = previousColumnCodewords[codewordsRow - 1]; - otherCodewords[5] = nextColumnCodewords[codewordsRow - 1]; - } - if (codewordsRow > 1) { - otherCodewords[8] = codewords[codewordsRow - 2]; - otherCodewords[10] = previousColumnCodewords[codewordsRow - 2]; - otherCodewords[11] = nextColumnCodewords[codewordsRow - 2]; - } - if (codewordsRow < codewords.length - 1) { - otherCodewords[1] = codewords[codewordsRow + 1]; - otherCodewords[6] = previousColumnCodewords[codewordsRow + 1]; - otherCodewords[7] = nextColumnCodewords[codewordsRow + 1]; - } - if (codewordsRow < codewords.length - 2) { - otherCodewords[9] = codewords[codewordsRow + 2]; - otherCodewords[12] = previousColumnCodewords[codewordsRow + 2]; - otherCodewords[13] = nextColumnCodewords[codewordsRow + 2]; - } - for (Codeword otherCodeword : otherCodewords) { - if (adjustRowNumber(codeword, otherCodeword)) { - return; - } - } - } - - /** - * @return true, if row number was adjusted, false otherwise - */ - private static boolean adjustRowNumber(Codeword codeword, Codeword otherCodeword) { - if (otherCodeword == null) { - return false; - } - if (otherCodeword.hasValidRowNumber() && otherCodeword.getBucket() == codeword.getBucket()) { - codeword.setRowNumber(otherCodeword.getRowNumber()); - return true; - } - return false; - } - - int getBarcodeColumnCount() { - return barcodeColumnCount; - } - - int getBarcodeRowCount() { - return barcodeMetadata.getRowCount(); - } - - int getBarcodeECLevel() { - return barcodeMetadata.getErrorCorrectionLevel(); - } - - void setBoundingBox(BoundingBox boundingBox) { - this.boundingBox = boundingBox; - } - - BoundingBox getBoundingBox() { - return boundingBox; - } - - void setDetectionResultColumn(int barcodeColumn, DetectionResultColumn detectionResultColumn) { - detectionResultColumns[barcodeColumn] = detectionResultColumn; - } - - DetectionResultColumn getDetectionResultColumn(int barcodeColumn) { - return detectionResultColumns[barcodeColumn]; - } - - @Override - public String toString() { - DetectionResultColumn rowIndicatorColumn = detectionResultColumns[0]; - if (rowIndicatorColumn == null) { - rowIndicatorColumn = detectionResultColumns[barcodeColumnCount + 1]; - } - try (Formatter formatter = new Formatter()) { - for (int codewordsRow = 0; codewordsRow < rowIndicatorColumn.getCodewords().length; codewordsRow++) { - formatter.format("CW %3d:", codewordsRow); - for (int barcodeColumn = 0; barcodeColumn < barcodeColumnCount + 2; barcodeColumn++) { - if (detectionResultColumns[barcodeColumn] == null) { - formatter.format(" | "); - continue; - } - Codeword codeword = detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow]; - if (codeword == null) { - formatter.format(" | "); - continue; - } - formatter.format(" %3d|%3d", codeword.getRowNumber(), codeword.getValue()); - } - formatter.format("%n"); - } - return formatter.toString(); - } - } - -} diff --git a/port_src/core/DONE/pdf417/decoder/DetectionResultColumn.java b/port_src/core/DONE/pdf417/decoder/DetectionResultColumn.java deleted file mode 100644 index bcf5119..0000000 --- a/port_src/core/DONE/pdf417/decoder/DetectionResultColumn.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder; - -import java.util.Formatter; - -/** - * @author Guenther Grau - */ -class DetectionResultColumn { - - private static final int MAX_NEARBY_DISTANCE = 5; - - private final BoundingBox boundingBox; - private final Codeword[] codewords; - - DetectionResultColumn(BoundingBox boundingBox) { - this.boundingBox = new BoundingBox(boundingBox); - codewords = new Codeword[boundingBox.getMaxY() - boundingBox.getMinY() + 1]; - } - - final Codeword getCodewordNearby(int imageRow) { - Codeword codeword = getCodeword(imageRow); - if (codeword != null) { - return codeword; - } - for (int i = 1; i < MAX_NEARBY_DISTANCE; i++) { - int nearImageRow = imageRowToCodewordIndex(imageRow) - i; - if (nearImageRow >= 0) { - codeword = codewords[nearImageRow]; - if (codeword != null) { - return codeword; - } - } - nearImageRow = imageRowToCodewordIndex(imageRow) + i; - if (nearImageRow < codewords.length) { - codeword = codewords[nearImageRow]; - if (codeword != null) { - return codeword; - } - } - } - return null; - } - - final int imageRowToCodewordIndex(int imageRow) { - return imageRow - boundingBox.getMinY(); - } - - final void setCodeword(int imageRow, Codeword codeword) { - codewords[imageRowToCodewordIndex(imageRow)] = codeword; - } - - final Codeword getCodeword(int imageRow) { - return codewords[imageRowToCodewordIndex(imageRow)]; - } - - final BoundingBox getBoundingBox() { - return boundingBox; - } - - final Codeword[] getCodewords() { - return codewords; - } - - @Override - public String toString() { - try (Formatter formatter = new Formatter()) { - int row = 0; - for (Codeword codeword : codewords) { - if (codeword == null) { - formatter.format("%3d: | %n", row++); - continue; - } - formatter.format("%3d: %3d|%3d%n", row++, codeword.getRowNumber(), codeword.getValue()); - } - return formatter.toString(); - } - } - -} diff --git a/port_src/core/DONE/pdf417/decoder/DetectionResultRowIndicatorColumn.java b/port_src/core/DONE/pdf417/decoder/DetectionResultRowIndicatorColumn.java deleted file mode 100644 index becaf37..0000000 --- a/port_src/core/DONE/pdf417/decoder/DetectionResultRowIndicatorColumn.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder; - -import com.google.zxing.ResultPoint; -import com.google.zxing.pdf417.PDF417Common; - -/** - * @author Guenther Grau - */ -final class DetectionResultRowIndicatorColumn extends DetectionResultColumn { - - private final boolean isLeft; - - DetectionResultRowIndicatorColumn(BoundingBox boundingBox, boolean isLeft) { - super(boundingBox); - this.isLeft = isLeft; - } - - private void setRowNumbers() { - for (Codeword codeword : getCodewords()) { - if (codeword != null) { - codeword.setRowNumberAsRowIndicatorColumn(); - } - } - } - - // TODO implement properly - // TODO maybe we should add missing codewords to store the correct row number to make - // finding row numbers for other columns easier - // use row height count to make detection of invalid row numbers more reliable - void adjustCompleteIndicatorColumnRowNumbers(BarcodeMetadata barcodeMetadata) { - Codeword[] codewords = getCodewords(); - setRowNumbers(); - removeIncorrectCodewords(codewords, barcodeMetadata); - BoundingBox boundingBox = getBoundingBox(); - ResultPoint top = isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight(); - ResultPoint bottom = isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight(); - int firstRow = imageRowToCodewordIndex((int) top.getY()); - int lastRow = imageRowToCodewordIndex((int) bottom.getY()); - // We need to be careful using the average row height. Barcode could be skewed so that we have smaller and - // taller rows - //float averageRowHeight = (lastRow - firstRow) / (float) barcodeMetadata.getRowCount(); - int barcodeRow = -1; - int maxRowHeight = 1; - int currentRowHeight = 0; - for (int codewordsRow = firstRow; codewordsRow < lastRow; codewordsRow++) { - if (codewords[codewordsRow] == null) { - continue; - } - Codeword codeword = codewords[codewordsRow]; - - int rowDifference = codeword.getRowNumber() - barcodeRow; - - // TODO improve handling with case where first row indicator doesn't start with 0 - - if (rowDifference == 0) { - currentRowHeight++; - } else if (rowDifference == 1) { - maxRowHeight = Math.max(maxRowHeight, currentRowHeight); - currentRowHeight = 1; - barcodeRow = codeword.getRowNumber(); - } else if (rowDifference < 0 || - codeword.getRowNumber() >= barcodeMetadata.getRowCount() || - rowDifference > codewordsRow) { - codewords[codewordsRow] = null; - } else { - int checkedRows; - if (maxRowHeight > 2) { - checkedRows = (maxRowHeight - 2) * rowDifference; - } else { - checkedRows = rowDifference; - } - boolean closePreviousCodewordFound = checkedRows >= codewordsRow; - for (int i = 1; i <= checkedRows && !closePreviousCodewordFound; i++) { - // there must be (height * rowDifference) number of codewords missing. For now we assume height = 1. - // This should hopefully get rid of most problems already. - closePreviousCodewordFound = codewords[codewordsRow - i] != null; - } - if (closePreviousCodewordFound) { - codewords[codewordsRow] = null; - } else { - barcodeRow = codeword.getRowNumber(); - currentRowHeight = 1; - } - } - } - //return (int) (averageRowHeight + 0.5); - } - - int[] getRowHeights() { - BarcodeMetadata barcodeMetadata = getBarcodeMetadata(); - if (barcodeMetadata == null) { - return null; - } - adjustIncompleteIndicatorColumnRowNumbers(barcodeMetadata); - int[] result = new int[barcodeMetadata.getRowCount()]; - for (Codeword codeword : getCodewords()) { - if (codeword != null) { - int rowNumber = codeword.getRowNumber(); - if (rowNumber >= result.length) { - // We have more rows than the barcode metadata allows for, ignore them. - continue; - } - result[rowNumber]++; - } // else throw exception? - } - return result; - } - - // TODO maybe we should add missing codewords to store the correct row number to make - // finding row numbers for other columns easier - // use row height count to make detection of invalid row numbers more reliable - private void adjustIncompleteIndicatorColumnRowNumbers(BarcodeMetadata barcodeMetadata) { - BoundingBox boundingBox = getBoundingBox(); - ResultPoint top = isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight(); - ResultPoint bottom = isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight(); - int firstRow = imageRowToCodewordIndex((int) top.getY()); - int lastRow = imageRowToCodewordIndex((int) bottom.getY()); - //float averageRowHeight = (lastRow - firstRow) / (float) barcodeMetadata.getRowCount(); - Codeword[] codewords = getCodewords(); - int barcodeRow = -1; - int maxRowHeight = 1; - int currentRowHeight = 0; - for (int codewordsRow = firstRow; codewordsRow < lastRow; codewordsRow++) { - if (codewords[codewordsRow] == null) { - continue; - } - Codeword codeword = codewords[codewordsRow]; - - codeword.setRowNumberAsRowIndicatorColumn(); - - int rowDifference = codeword.getRowNumber() - barcodeRow; - - // TODO improve handling with case where first row indicator doesn't start with 0 - - if (rowDifference == 0) { - currentRowHeight++; - } else if (rowDifference == 1) { - maxRowHeight = Math.max(maxRowHeight, currentRowHeight); - currentRowHeight = 1; - barcodeRow = codeword.getRowNumber(); - } else if (codeword.getRowNumber() >= barcodeMetadata.getRowCount()) { - codewords[codewordsRow] = null; - } else { - barcodeRow = codeword.getRowNumber(); - currentRowHeight = 1; - } - } - //return (int) (averageRowHeight + 0.5); - } - - BarcodeMetadata getBarcodeMetadata() { - Codeword[] codewords = getCodewords(); - BarcodeValue barcodeColumnCount = new BarcodeValue(); - BarcodeValue barcodeRowCountUpperPart = new BarcodeValue(); - BarcodeValue barcodeRowCountLowerPart = new BarcodeValue(); - BarcodeValue barcodeECLevel = new BarcodeValue(); - for (Codeword codeword : codewords) { - if (codeword == null) { - continue; - } - codeword.setRowNumberAsRowIndicatorColumn(); - int rowIndicatorValue = codeword.getValue() % 30; - int codewordRowNumber = codeword.getRowNumber(); - if (!isLeft) { - codewordRowNumber += 2; - } - switch (codewordRowNumber % 3) { - case 0: - barcodeRowCountUpperPart.setValue(rowIndicatorValue * 3 + 1); - break; - case 1: - barcodeECLevel.setValue(rowIndicatorValue / 3); - barcodeRowCountLowerPart.setValue(rowIndicatorValue % 3); - break; - case 2: - barcodeColumnCount.setValue(rowIndicatorValue + 1); - break; - } - } - // Maybe we should check if we have ambiguous values? - if ((barcodeColumnCount.getValue().length == 0) || - (barcodeRowCountUpperPart.getValue().length == 0) || - (barcodeRowCountLowerPart.getValue().length == 0) || - (barcodeECLevel.getValue().length == 0) || - barcodeColumnCount.getValue()[0] < 1 || - barcodeRowCountUpperPart.getValue()[0] + barcodeRowCountLowerPart.getValue()[0] < - PDF417Common.MIN_ROWS_IN_BARCODE || - barcodeRowCountUpperPart.getValue()[0] + barcodeRowCountLowerPart.getValue()[0] > - PDF417Common.MAX_ROWS_IN_BARCODE) { - return null; - } - BarcodeMetadata barcodeMetadata = new BarcodeMetadata(barcodeColumnCount.getValue()[0], - barcodeRowCountUpperPart.getValue()[0], barcodeRowCountLowerPart.getValue()[0], barcodeECLevel.getValue()[0]); - removeIncorrectCodewords(codewords, barcodeMetadata); - return barcodeMetadata; - } - - private void removeIncorrectCodewords(Codeword[] codewords, BarcodeMetadata barcodeMetadata) { - // Remove codewords which do not match the metadata - // TODO Maybe we should keep the incorrect codewords for the start and end positions? - for (int codewordRow = 0; codewordRow < codewords.length; codewordRow++) { - Codeword codeword = codewords[codewordRow]; - if (codewords[codewordRow] == null) { - continue; - } - int rowIndicatorValue = codeword.getValue() % 30; - int codewordRowNumber = codeword.getRowNumber(); - if (codewordRowNumber > barcodeMetadata.getRowCount()) { - codewords[codewordRow] = null; - continue; - } - if (!isLeft) { - codewordRowNumber += 2; - } - switch (codewordRowNumber % 3) { - case 0: - if (rowIndicatorValue * 3 + 1 != barcodeMetadata.getRowCountUpperPart()) { - codewords[codewordRow] = null; - } - break; - case 1: - if (rowIndicatorValue / 3 != barcodeMetadata.getErrorCorrectionLevel() || - rowIndicatorValue % 3 != barcodeMetadata.getRowCountLowerPart()) { - codewords[codewordRow] = null; - } - break; - case 2: - if (rowIndicatorValue + 1 != barcodeMetadata.getColumnCount()) { - codewords[codewordRow] = null; - } - break; - } - } - } - - boolean isLeft() { - return isLeft; - } - - @Override - public String toString() { - return "IsLeft: " + isLeft + '\n' + super.toString(); - } - -} diff --git a/port_src/core/DONE/pdf417/decoder/PDF417CodewordDecoder.java b/port_src/core/DONE/pdf417/decoder/PDF417CodewordDecoder.java deleted file mode 100644 index e4dee58..0000000 --- a/port_src/core/DONE/pdf417/decoder/PDF417CodewordDecoder.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder; - -import com.google.zxing.common.detector.MathUtils; -import com.google.zxing.pdf417.PDF417Common; - -/** - * @author Guenther Grau - * @author creatale GmbH (christoph.schulz@creatale.de) - */ -final class PDF417CodewordDecoder { - - private static final float[][] RATIOS_TABLE = - new float[PDF417Common.SYMBOL_TABLE.length][PDF417Common.BARS_IN_MODULE]; - - static { - // Pre-computes the symbol ratio table. - for (int i = 0; i < PDF417Common.SYMBOL_TABLE.length; i++) { - int currentSymbol = PDF417Common.SYMBOL_TABLE[i]; - int currentBit = currentSymbol & 0x1; - for (int j = 0; j < PDF417Common.BARS_IN_MODULE; j++) { - float size = 0.0f; - while ((currentSymbol & 0x1) == currentBit) { - size += 1.0f; - currentSymbol >>= 1; - } - currentBit = currentSymbol & 0x1; - RATIOS_TABLE[i][PDF417Common.BARS_IN_MODULE - j - 1] = size / PDF417Common.MODULES_IN_CODEWORD; - } - } - } - - private PDF417CodewordDecoder() { - } - - static int getDecodedValue(int[] moduleBitCount) { - int decodedValue = getDecodedCodewordValue(sampleBitCounts(moduleBitCount)); - if (decodedValue != -1) { - return decodedValue; - } - return getClosestDecodedValue(moduleBitCount); - } - - private static int[] sampleBitCounts(int[] moduleBitCount) { - float bitCountSum = MathUtils.sum(moduleBitCount); - int[] result = new int[PDF417Common.BARS_IN_MODULE]; - int bitCountIndex = 0; - int sumPreviousBits = 0; - for (int i = 0; i < PDF417Common.MODULES_IN_CODEWORD; i++) { - float sampleIndex = - bitCountSum / (2 * PDF417Common.MODULES_IN_CODEWORD) + - (i * bitCountSum) / PDF417Common.MODULES_IN_CODEWORD; - if (sumPreviousBits + moduleBitCount[bitCountIndex] <= sampleIndex) { - sumPreviousBits += moduleBitCount[bitCountIndex]; - bitCountIndex++; - } - result[bitCountIndex]++; - } - return result; - } - - private static int getDecodedCodewordValue(int[] moduleBitCount) { - int decodedValue = getBitValue(moduleBitCount); - return PDF417Common.getCodeword(decodedValue) == -1 ? -1 : decodedValue; - } - - private static int getBitValue(int[] moduleBitCount) { - long result = 0; - for (int i = 0; i < moduleBitCount.length; i++) { - for (int bit = 0; bit < moduleBitCount[i]; bit++) { - result = (result << 1) | (i % 2 == 0 ? 1 : 0); - } - } - return (int) result; - } - - private static int getClosestDecodedValue(int[] moduleBitCount) { - int bitCountSum = MathUtils.sum(moduleBitCount); - float[] bitCountRatios = new float[PDF417Common.BARS_IN_MODULE]; - if (bitCountSum > 1) { - for (int i = 0; i < bitCountRatios.length; i++) { - bitCountRatios[i] = moduleBitCount[i] / (float) bitCountSum; - } - } - float bestMatchError = Float.MAX_VALUE; - int bestMatch = -1; - for (int j = 0; j < RATIOS_TABLE.length; j++) { - float error = 0.0f; - float[] ratioTableRow = RATIOS_TABLE[j]; - for (int k = 0; k < PDF417Common.BARS_IN_MODULE; k++) { - float diff = ratioTableRow[k] - bitCountRatios[k]; - error += diff * diff; - if (error >= bestMatchError) { - break; - } - } - if (error < bestMatchError) { - bestMatchError = error; - bestMatch = PDF417Common.SYMBOL_TABLE[j]; - } - } - return bestMatch; - } - -} diff --git a/port_src/core/DONE/pdf417/decoder/PDF417ScanningDecoder.java b/port_src/core/DONE/pdf417/decoder/PDF417ScanningDecoder.java deleted file mode 100644 index 9248193..0000000 --- a/port_src/core/DONE/pdf417/decoder/PDF417ScanningDecoder.java +++ /dev/null @@ -1,634 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder; - -import com.google.zxing.ChecksumException; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.detector.MathUtils; -import com.google.zxing.pdf417.PDF417Common; -import com.google.zxing.pdf417.decoder.ec.ErrorCorrection; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Formatter; -import java.util.List; - -/** - * @author Guenther Grau - */ -public final class PDF417ScanningDecoder { - - private static final int CODEWORD_SKEW_SIZE = 2; - - private static final int MAX_ERRORS = 3; - private static final int MAX_EC_CODEWORDS = 512; - private static final ErrorCorrection errorCorrection = new ErrorCorrection(); - - private PDF417ScanningDecoder() { - } - - // TODO don't pass in minCodewordWidth and maxCodewordWidth, pass in barcode columns for start and stop pattern - // columns. That way width can be deducted from the pattern column. - // This approach also allows to detect more details about the barcode, e.g. if a bar type (white or black) is wider - // than it should be. This can happen if the scanner used a bad blackpoint. - public static DecoderResult decode(BitMatrix image, - ResultPoint imageTopLeft, - ResultPoint imageBottomLeft, - ResultPoint imageTopRight, - ResultPoint imageBottomRight, - int minCodewordWidth, - int maxCodewordWidth) - throws NotFoundException, FormatException, ChecksumException { - BoundingBox boundingBox = new BoundingBox(image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight); - DetectionResultRowIndicatorColumn leftRowIndicatorColumn = null; - DetectionResultRowIndicatorColumn rightRowIndicatorColumn = null; - DetectionResult detectionResult; - for (boolean firstPass = true; ; firstPass = false) { - if (imageTopLeft != null) { - leftRowIndicatorColumn = getRowIndicatorColumn(image, boundingBox, imageTopLeft, true, minCodewordWidth, - maxCodewordWidth); - } - if (imageTopRight != null) { - rightRowIndicatorColumn = getRowIndicatorColumn(image, boundingBox, imageTopRight, false, minCodewordWidth, - maxCodewordWidth); - } - detectionResult = merge(leftRowIndicatorColumn, rightRowIndicatorColumn); - if (detectionResult == null) { - throw NotFoundException.getNotFoundInstance(); - } - BoundingBox resultBox = detectionResult.getBoundingBox(); - if (firstPass && resultBox != null && - (resultBox.getMinY() < boundingBox.getMinY() || resultBox.getMaxY() > boundingBox.getMaxY())) { - boundingBox = resultBox; - } else { - break; - } - } - detectionResult.setBoundingBox(boundingBox); - int maxBarcodeColumn = detectionResult.getBarcodeColumnCount() + 1; - detectionResult.setDetectionResultColumn(0, leftRowIndicatorColumn); - detectionResult.setDetectionResultColumn(maxBarcodeColumn, rightRowIndicatorColumn); - - boolean leftToRight = leftRowIndicatorColumn != null; - for (int barcodeColumnCount = 1; barcodeColumnCount <= maxBarcodeColumn; barcodeColumnCount++) { - int barcodeColumn = leftToRight ? barcodeColumnCount : maxBarcodeColumn - barcodeColumnCount; - if (detectionResult.getDetectionResultColumn(barcodeColumn) != null) { - // This will be the case for the opposite row indicator column, which doesn't need to be decoded again. - continue; - } - DetectionResultColumn detectionResultColumn; - if (barcodeColumn == 0 || barcodeColumn == maxBarcodeColumn) { - detectionResultColumn = new DetectionResultRowIndicatorColumn(boundingBox, barcodeColumn == 0); - } else { - detectionResultColumn = new DetectionResultColumn(boundingBox); - } - detectionResult.setDetectionResultColumn(barcodeColumn, detectionResultColumn); - int startColumn = -1; - int previousStartColumn = startColumn; - // TODO start at a row for which we know the start position, then detect upwards and downwards from there. - for (int imageRow = boundingBox.getMinY(); imageRow <= boundingBox.getMaxY(); imageRow++) { - startColumn = getStartColumn(detectionResult, barcodeColumn, imageRow, leftToRight); - if (startColumn < 0 || startColumn > boundingBox.getMaxX()) { - if (previousStartColumn == -1) { - continue; - } - startColumn = previousStartColumn; - } - Codeword codeword = detectCodeword(image, boundingBox.getMinX(), boundingBox.getMaxX(), leftToRight, - startColumn, imageRow, minCodewordWidth, maxCodewordWidth); - if (codeword != null) { - detectionResultColumn.setCodeword(imageRow, codeword); - previousStartColumn = startColumn; - minCodewordWidth = Math.min(minCodewordWidth, codeword.getWidth()); - maxCodewordWidth = Math.max(maxCodewordWidth, codeword.getWidth()); - } - } - } - return createDecoderResult(detectionResult); - } - - private static DetectionResult merge(DetectionResultRowIndicatorColumn leftRowIndicatorColumn, - DetectionResultRowIndicatorColumn rightRowIndicatorColumn) - throws NotFoundException { - if (leftRowIndicatorColumn == null && rightRowIndicatorColumn == null) { - return null; - } - BarcodeMetadata barcodeMetadata = getBarcodeMetadata(leftRowIndicatorColumn, rightRowIndicatorColumn); - if (barcodeMetadata == null) { - return null; - } - BoundingBox boundingBox = BoundingBox.merge(adjustBoundingBox(leftRowIndicatorColumn), - adjustBoundingBox(rightRowIndicatorColumn)); - return new DetectionResult(barcodeMetadata, boundingBox); - } - - private static BoundingBox adjustBoundingBox(DetectionResultRowIndicatorColumn rowIndicatorColumn) - throws NotFoundException { - if (rowIndicatorColumn == null) { - return null; - } - int[] rowHeights = rowIndicatorColumn.getRowHeights(); - if (rowHeights == null) { - return null; - } - int maxRowHeight = getMax(rowHeights); - int missingStartRows = 0; - for (int rowHeight : rowHeights) { - missingStartRows += maxRowHeight - rowHeight; - if (rowHeight > 0) { - break; - } - } - Codeword[] codewords = rowIndicatorColumn.getCodewords(); - for (int row = 0; missingStartRows > 0 && codewords[row] == null; row++) { - missingStartRows--; - } - int missingEndRows = 0; - for (int row = rowHeights.length - 1; row >= 0; row--) { - missingEndRows += maxRowHeight - rowHeights[row]; - if (rowHeights[row] > 0) { - break; - } - } - for (int row = codewords.length - 1; missingEndRows > 0 && codewords[row] == null; row--) { - missingEndRows--; - } - return rowIndicatorColumn.getBoundingBox().addMissingRows(missingStartRows, missingEndRows, - rowIndicatorColumn.isLeft()); - } - - private static int getMax(int[] values) { - int maxValue = -1; - for (int value : values) { - maxValue = Math.max(maxValue, value); - } - return maxValue; - } - - private static BarcodeMetadata getBarcodeMetadata(DetectionResultRowIndicatorColumn leftRowIndicatorColumn, - DetectionResultRowIndicatorColumn rightRowIndicatorColumn) { - BarcodeMetadata leftBarcodeMetadata; - if (leftRowIndicatorColumn == null || - (leftBarcodeMetadata = leftRowIndicatorColumn.getBarcodeMetadata()) == null) { - return rightRowIndicatorColumn == null ? null : rightRowIndicatorColumn.getBarcodeMetadata(); - } - BarcodeMetadata rightBarcodeMetadata; - if (rightRowIndicatorColumn == null || - (rightBarcodeMetadata = rightRowIndicatorColumn.getBarcodeMetadata()) == null) { - return leftBarcodeMetadata; - } - - if (leftBarcodeMetadata.getColumnCount() != rightBarcodeMetadata.getColumnCount() && - leftBarcodeMetadata.getErrorCorrectionLevel() != rightBarcodeMetadata.getErrorCorrectionLevel() && - leftBarcodeMetadata.getRowCount() != rightBarcodeMetadata.getRowCount()) { - return null; - } - return leftBarcodeMetadata; - } - - private static DetectionResultRowIndicatorColumn getRowIndicatorColumn(BitMatrix image, - BoundingBox boundingBox, - ResultPoint startPoint, - boolean leftToRight, - int minCodewordWidth, - int maxCodewordWidth) { - DetectionResultRowIndicatorColumn rowIndicatorColumn = new DetectionResultRowIndicatorColumn(boundingBox, - leftToRight); - for (int i = 0; i < 2; i++) { - int increment = i == 0 ? 1 : -1; - int startColumn = (int) startPoint.getX(); - for (int imageRow = (int) startPoint.getY(); imageRow <= boundingBox.getMaxY() && - imageRow >= boundingBox.getMinY(); imageRow += increment) { - Codeword codeword = detectCodeword(image, 0, image.getWidth(), leftToRight, startColumn, imageRow, - minCodewordWidth, maxCodewordWidth); - if (codeword != null) { - rowIndicatorColumn.setCodeword(imageRow, codeword); - if (leftToRight) { - startColumn = codeword.getStartX(); - } else { - startColumn = codeword.getEndX(); - } - } - } - } - return rowIndicatorColumn; - } - - private static void adjustCodewordCount(DetectionResult detectionResult, BarcodeValue[][] barcodeMatrix) - throws NotFoundException { - BarcodeValue barcodeMatrix01 = barcodeMatrix[0][1]; - int[] numberOfCodewords = barcodeMatrix01.getValue(); - int calculatedNumberOfCodewords = detectionResult.getBarcodeColumnCount() * - detectionResult.getBarcodeRowCount() - - getNumberOfECCodeWords(detectionResult.getBarcodeECLevel()); - if (numberOfCodewords.length == 0) { - if (calculatedNumberOfCodewords < 1 || calculatedNumberOfCodewords > PDF417Common.MAX_CODEWORDS_IN_BARCODE) { - throw NotFoundException.getNotFoundInstance(); - } - barcodeMatrix01.setValue(calculatedNumberOfCodewords); - } else if (numberOfCodewords[0] != calculatedNumberOfCodewords) { - if (calculatedNumberOfCodewords >= 1 && calculatedNumberOfCodewords <= PDF417Common.MAX_CODEWORDS_IN_BARCODE) { - // The calculated one is more reliable as it is derived from the row indicator columns - barcodeMatrix01.setValue(calculatedNumberOfCodewords); - } - } - } - - private static DecoderResult createDecoderResult(DetectionResult detectionResult) throws FormatException, - ChecksumException, NotFoundException { - BarcodeValue[][] barcodeMatrix = createBarcodeMatrix(detectionResult); - adjustCodewordCount(detectionResult, barcodeMatrix); - Collection erasures = new ArrayList<>(); - int[] codewords = new int[detectionResult.getBarcodeRowCount() * detectionResult.getBarcodeColumnCount()]; - List ambiguousIndexValuesList = new ArrayList<>(); - Collection ambiguousIndexesList = new ArrayList<>(); - for (int row = 0; row < detectionResult.getBarcodeRowCount(); row++) { - for (int column = 0; column < detectionResult.getBarcodeColumnCount(); column++) { - int[] values = barcodeMatrix[row][column + 1].getValue(); - int codewordIndex = row * detectionResult.getBarcodeColumnCount() + column; - if (values.length == 0) { - erasures.add(codewordIndex); - } else if (values.length == 1) { - codewords[codewordIndex] = values[0]; - } else { - ambiguousIndexesList.add(codewordIndex); - ambiguousIndexValuesList.add(values); - } - } - } - int[][] ambiguousIndexValues = new int[ambiguousIndexValuesList.size()][]; - for (int i = 0; i < ambiguousIndexValues.length; i++) { - ambiguousIndexValues[i] = ambiguousIndexValuesList.get(i); - } - return createDecoderResultFromAmbiguousValues(detectionResult.getBarcodeECLevel(), codewords, - PDF417Common.toIntArray(erasures), PDF417Common.toIntArray(ambiguousIndexesList), ambiguousIndexValues); - } - - /** - * This method deals with the fact, that the decoding process doesn't always yield a single most likely value. The - * current error correction implementation doesn't deal with erasures very well, so it's better to provide a value - * for these ambiguous codewords instead of treating it as an erasure. The problem is that we don't know which of - * the ambiguous values to choose. We try decode using the first value, and if that fails, we use another of the - * ambiguous values and try to decode again. This usually only happens on very hard to read and decode barcodes, - * so decoding the normal barcodes is not affected by this. - * - * @param erasureArray contains the indexes of erasures - * @param ambiguousIndexes array with the indexes that have more than one most likely value - * @param ambiguousIndexValues two dimensional array that contains the ambiguous values. The first dimension must - * be the same length as the ambiguousIndexes array - */ - private static DecoderResult createDecoderResultFromAmbiguousValues(int ecLevel, - int[] codewords, - int[] erasureArray, - int[] ambiguousIndexes, - int[][] ambiguousIndexValues) - throws FormatException, ChecksumException { - int[] ambiguousIndexCount = new int[ambiguousIndexes.length]; - - int tries = 100; - while (tries-- > 0) { - for (int i = 0; i < ambiguousIndexCount.length; i++) { - codewords[ambiguousIndexes[i]] = ambiguousIndexValues[i][ambiguousIndexCount[i]]; - } - try { - return decodeCodewords(codewords, ecLevel, erasureArray); - } catch (ChecksumException ignored) { - // - } - if (ambiguousIndexCount.length == 0) { - throw ChecksumException.getChecksumInstance(); - } - for (int i = 0; i < ambiguousIndexCount.length; i++) { - if (ambiguousIndexCount[i] < ambiguousIndexValues[i].length - 1) { - ambiguousIndexCount[i]++; - break; - } else { - ambiguousIndexCount[i] = 0; - if (i == ambiguousIndexCount.length - 1) { - throw ChecksumException.getChecksumInstance(); - } - } - } - } - throw ChecksumException.getChecksumInstance(); - } - - private static BarcodeValue[][] createBarcodeMatrix(DetectionResult detectionResult) { - BarcodeValue[][] barcodeMatrix = - new BarcodeValue[detectionResult.getBarcodeRowCount()][detectionResult.getBarcodeColumnCount() + 2]; - for (int row = 0; row < barcodeMatrix.length; row++) { - for (int column = 0; column < barcodeMatrix[row].length; column++) { - barcodeMatrix[row][column] = new BarcodeValue(); - } - } - - int column = 0; - for (DetectionResultColumn detectionResultColumn : detectionResult.getDetectionResultColumns()) { - if (detectionResultColumn != null) { - for (Codeword codeword : detectionResultColumn.getCodewords()) { - if (codeword != null) { - int rowNumber = codeword.getRowNumber(); - if (rowNumber >= 0) { - if (rowNumber >= barcodeMatrix.length) { - // We have more rows than the barcode metadata allows for, ignore them. - continue; - } - barcodeMatrix[rowNumber][column].setValue(codeword.getValue()); - } - } - } - } - column++; - } - return barcodeMatrix; - } - - private static boolean isValidBarcodeColumn(DetectionResult detectionResult, int barcodeColumn) { - return barcodeColumn >= 0 && barcodeColumn <= detectionResult.getBarcodeColumnCount() + 1; - } - - private static int getStartColumn(DetectionResult detectionResult, - int barcodeColumn, - int imageRow, - boolean leftToRight) { - int offset = leftToRight ? 1 : -1; - Codeword codeword = null; - if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { - codeword = detectionResult.getDetectionResultColumn(barcodeColumn - offset).getCodeword(imageRow); - } - if (codeword != null) { - return leftToRight ? codeword.getEndX() : codeword.getStartX(); - } - codeword = detectionResult.getDetectionResultColumn(barcodeColumn).getCodewordNearby(imageRow); - if (codeword != null) { - return leftToRight ? codeword.getStartX() : codeword.getEndX(); - } - if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { - codeword = detectionResult.getDetectionResultColumn(barcodeColumn - offset).getCodewordNearby(imageRow); - } - if (codeword != null) { - return leftToRight ? codeword.getEndX() : codeword.getStartX(); - } - int skippedColumns = 0; - - while (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { - barcodeColumn -= offset; - for (Codeword previousRowCodeword : detectionResult.getDetectionResultColumn(barcodeColumn).getCodewords()) { - if (previousRowCodeword != null) { - return (leftToRight ? previousRowCodeword.getEndX() : previousRowCodeword.getStartX()) + - offset * - skippedColumns * - (previousRowCodeword.getEndX() - previousRowCodeword.getStartX()); - } - } - skippedColumns++; - } - return leftToRight ? detectionResult.getBoundingBox().getMinX() : detectionResult.getBoundingBox().getMaxX(); - } - - private static Codeword detectCodeword(BitMatrix image, - int minColumn, - int maxColumn, - boolean leftToRight, - int startColumn, - int imageRow, - int minCodewordWidth, - int maxCodewordWidth) { - startColumn = adjustCodewordStartColumn(image, minColumn, maxColumn, leftToRight, startColumn, imageRow); - // we usually know fairly exact now how long a codeword is. We should provide minimum and maximum expected length - // and try to adjust the read pixels, e.g. remove single pixel errors or try to cut off exceeding pixels. - // min and maxCodewordWidth should not be used as they are calculated for the whole barcode an can be inaccurate - // for the current position - int[] moduleBitCount = getModuleBitCount(image, minColumn, maxColumn, leftToRight, startColumn, imageRow); - if (moduleBitCount == null) { - return null; - } - int endColumn; - int codewordBitCount = MathUtils.sum(moduleBitCount); - if (leftToRight) { - endColumn = startColumn + codewordBitCount; - } else { - for (int i = 0; i < moduleBitCount.length / 2; i++) { - int tmpCount = moduleBitCount[i]; - moduleBitCount[i] = moduleBitCount[moduleBitCount.length - 1 - i]; - moduleBitCount[moduleBitCount.length - 1 - i] = tmpCount; - } - endColumn = startColumn; - startColumn = endColumn - codewordBitCount; - } - // TODO implement check for width and correction of black and white bars - // use start (and maybe stop pattern) to determine if black bars are wider than white bars. If so, adjust. - // should probably done only for codewords with a lot more than 17 bits. - // The following fixes 10-1.png, which has wide black bars and small white bars - // for (int i = 0; i < moduleBitCount.length; i++) { - // if (i % 2 == 0) { - // moduleBitCount[i]--; - // } else { - // moduleBitCount[i]++; - // } - // } - - // We could also use the width of surrounding codewords for more accurate results, but this seems - // sufficient for now - if (!checkCodewordSkew(codewordBitCount, minCodewordWidth, maxCodewordWidth)) { - // We could try to use the startX and endX position of the codeword in the same column in the previous row, - // create the bit count from it and normalize it to 8. This would help with single pixel errors. - return null; - } - - int decodedValue = PDF417CodewordDecoder.getDecodedValue(moduleBitCount); - int codeword = PDF417Common.getCodeword(decodedValue); - if (codeword == -1) { - return null; - } - return new Codeword(startColumn, endColumn, getCodewordBucketNumber(decodedValue), codeword); - } - - private static int[] getModuleBitCount(BitMatrix image, - int minColumn, - int maxColumn, - boolean leftToRight, - int startColumn, - int imageRow) { - int imageColumn = startColumn; - int[] moduleBitCount = new int[8]; - int moduleNumber = 0; - int increment = leftToRight ? 1 : -1; - boolean previousPixelValue = leftToRight; - while ((leftToRight ? imageColumn < maxColumn : imageColumn >= minColumn) && - moduleNumber < moduleBitCount.length) { - if (image.get(imageColumn, imageRow) == previousPixelValue) { - moduleBitCount[moduleNumber]++; - imageColumn += increment; - } else { - moduleNumber++; - previousPixelValue = !previousPixelValue; - } - } - if (moduleNumber == moduleBitCount.length || - ((imageColumn == (leftToRight ? maxColumn : minColumn)) && - moduleNumber == moduleBitCount.length - 1)) { - return moduleBitCount; - } - return null; - } - - private static int getNumberOfECCodeWords(int barcodeECLevel) { - return 2 << barcodeECLevel; - } - - private static int adjustCodewordStartColumn(BitMatrix image, - int minColumn, - int maxColumn, - boolean leftToRight, - int codewordStartColumn, - int imageRow) { - int correctedStartColumn = codewordStartColumn; - int increment = leftToRight ? -1 : 1; - // there should be no black pixels before the start column. If there are, then we need to start earlier. - for (int i = 0; i < 2; i++) { - while ((leftToRight ? correctedStartColumn >= minColumn : correctedStartColumn < maxColumn) && - leftToRight == image.get(correctedStartColumn, imageRow)) { - if (Math.abs(codewordStartColumn - correctedStartColumn) > CODEWORD_SKEW_SIZE) { - return codewordStartColumn; - } - correctedStartColumn += increment; - } - increment = -increment; - leftToRight = !leftToRight; - } - return correctedStartColumn; - } - - private static boolean checkCodewordSkew(int codewordSize, int minCodewordWidth, int maxCodewordWidth) { - return minCodewordWidth - CODEWORD_SKEW_SIZE <= codewordSize && - codewordSize <= maxCodewordWidth + CODEWORD_SKEW_SIZE; - } - - private static DecoderResult decodeCodewords(int[] codewords, int ecLevel, int[] erasures) throws FormatException, - ChecksumException { - if (codewords.length == 0) { - throw FormatException.getFormatInstance(); - } - - int numECCodewords = 1 << (ecLevel + 1); - int correctedErrorsCount = correctErrors(codewords, erasures, numECCodewords); - verifyCodewordCount(codewords, numECCodewords); - - // Decode the codewords - DecoderResult decoderResult = DecodedBitStreamParser.decode(codewords, String.valueOf(ecLevel)); - decoderResult.setErrorsCorrected(correctedErrorsCount); - decoderResult.setErasures(erasures.length); - return decoderResult; - } - - /** - *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to - * correct the errors in-place.

- * - * @param codewords data and error correction codewords - * @param erasures positions of any known erasures - * @param numECCodewords number of error correction codewords that are available in codewords - * @throws ChecksumException if error correction fails - */ - private static int correctErrors(int[] codewords, int[] erasures, int numECCodewords) throws ChecksumException { - if (erasures != null && - erasures.length > numECCodewords / 2 + MAX_ERRORS || - numECCodewords < 0 || - numECCodewords > MAX_EC_CODEWORDS) { - // Too many errors or EC Codewords is corrupted - throw ChecksumException.getChecksumInstance(); - } - return errorCorrection.decode(codewords, numECCodewords, erasures); - } - - /** - * Verify that all is OK with the codeword array. - */ - private static void verifyCodewordCount(int[] codewords, int numECCodewords) throws FormatException { - if (codewords.length < 4) { - // Codeword array size should be at least 4 allowing for - // Count CW, At least one Data CW, Error Correction CW, Error Correction CW - throw FormatException.getFormatInstance(); - } - // The first codeword, the Symbol Length Descriptor, shall always encode the total number of data - // codewords in the symbol, including the Symbol Length Descriptor itself, data codewords and pad - // codewords, but excluding the number of error correction codewords. - int numberOfCodewords = codewords[0]; - if (numberOfCodewords > codewords.length) { - throw FormatException.getFormatInstance(); - } - if (numberOfCodewords == 0) { - // Reset to the length of the array - 8 (Allow for at least level 3 Error Correction (8 Error Codewords) - if (numECCodewords < codewords.length) { - codewords[0] = codewords.length - numECCodewords; - } else { - throw FormatException.getFormatInstance(); - } - } - } - - private static int[] getBitCountForCodeword(int codeword) { - int[] result = new int[8]; - int previousValue = 0; - int i = result.length - 1; - while (true) { - if ((codeword & 0x1) != previousValue) { - previousValue = codeword & 0x1; - i--; - if (i < 0) { - break; - } - } - result[i]++; - codeword >>= 1; - } - return result; - } - - private static int getCodewordBucketNumber(int codeword) { - return getCodewordBucketNumber(getBitCountForCodeword(codeword)); - } - - private static int getCodewordBucketNumber(int[] moduleBitCount) { - return (moduleBitCount[0] - moduleBitCount[2] + moduleBitCount[4] - moduleBitCount[6] + 9) % 9; - } - - public static String toString(BarcodeValue[][] barcodeMatrix) { - try (Formatter formatter = new Formatter()) { - for (int row = 0; row < barcodeMatrix.length; row++) { - formatter.format("Row %2d: ", row); - for (int column = 0; column < barcodeMatrix[row].length; column++) { - BarcodeValue barcodeValue = barcodeMatrix[row][column]; - if (barcodeValue.getValue().length == 0) { - formatter.format(" ", (Object[]) null); - } else { - formatter.format("%4d(%2d)", barcodeValue.getValue()[0], - barcodeValue.getConfidence(barcodeValue.getValue()[0])); - } - } - formatter.format("%n"); - } - return formatter.toString(); - } - } - -} diff --git a/port_src/core/DONE/pdf417/decoder/ec/ErrorCorrection.java b/port_src/core/DONE/pdf417/decoder/ec/ErrorCorrection.java deleted file mode 100644 index 06bd06d..0000000 --- a/port_src/core/DONE/pdf417/decoder/ec/ErrorCorrection.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder.ec; - -import com.google.zxing.ChecksumException; - -/** - *

PDF417 error correction implementation.

- * - *

This example - * is quite useful in understanding the algorithm.

- * - * @author Sean Owen - * @see com.google.zxing.common.reedsolomon.ReedSolomonDecoder - */ -public final class ErrorCorrection { - - private final ModulusGF field; - - public ErrorCorrection() { - this.field = ModulusGF.PDF417_GF; - } - - /** - * @param received received codewords - * @param numECCodewords number of those codewords used for EC - * @param erasures location of erasures - * @return number of errors - * @throws ChecksumException if errors cannot be corrected, maybe because of too many errors - */ - public int decode(int[] received, - int numECCodewords, - int[] erasures) throws ChecksumException { - - ModulusPoly poly = new ModulusPoly(field, received); - int[] S = new int[numECCodewords]; - boolean error = false; - for (int i = numECCodewords; i > 0; i--) { - int eval = poly.evaluateAt(field.exp(i)); - S[numECCodewords - i] = eval; - if (eval != 0) { - error = true; - } - } - - if (!error) { - return 0; - } - - ModulusPoly knownErrors = field.getOne(); - if (erasures != null) { - for (int erasure : erasures) { - int b = field.exp(received.length - 1 - erasure); - // Add (1 - bx) term: - ModulusPoly term = new ModulusPoly(field, new int[]{field.subtract(0, b), 1}); - knownErrors = knownErrors.multiply(term); - } - } - - ModulusPoly syndrome = new ModulusPoly(field, S); - //syndrome = syndrome.multiply(knownErrors); - - ModulusPoly[] sigmaOmega = - runEuclideanAlgorithm(field.buildMonomial(numECCodewords, 1), syndrome, numECCodewords); - ModulusPoly sigma = sigmaOmega[0]; - ModulusPoly omega = sigmaOmega[1]; - - //sigma = sigma.multiply(knownErrors); - - int[] errorLocations = findErrorLocations(sigma); - int[] errorMagnitudes = findErrorMagnitudes(omega, sigma, errorLocations); - - for (int i = 0; i < errorLocations.length; i++) { - int position = received.length - 1 - field.log(errorLocations[i]); - if (position < 0) { - throw ChecksumException.getChecksumInstance(); - } - received[position] = field.subtract(received[position], errorMagnitudes[i]); - } - return errorLocations.length; - } - - private ModulusPoly[] runEuclideanAlgorithm(ModulusPoly a, ModulusPoly b, int R) - throws ChecksumException { - // Assume a's degree is >= b's - if (a.getDegree() < b.getDegree()) { - ModulusPoly temp = a; - a = b; - b = temp; - } - - ModulusPoly rLast = a; - ModulusPoly r = b; - ModulusPoly tLast = field.getZero(); - ModulusPoly t = field.getOne(); - - // Run Euclidean algorithm until r's degree is less than R/2 - while (r.getDegree() >= R / 2) { - ModulusPoly rLastLast = rLast; - ModulusPoly tLastLast = tLast; - rLast = r; - tLast = t; - - // Divide rLastLast by rLast, with quotient in q and remainder in r - if (rLast.isZero()) { - // Oops, Euclidean algorithm already terminated? - throw ChecksumException.getChecksumInstance(); - } - r = rLastLast; - ModulusPoly q = field.getZero(); - int denominatorLeadingTerm = rLast.getCoefficient(rLast.getDegree()); - int dltInverse = field.inverse(denominatorLeadingTerm); - while (r.getDegree() >= rLast.getDegree() && !r.isZero()) { - int degreeDiff = r.getDegree() - rLast.getDegree(); - int scale = field.multiply(r.getCoefficient(r.getDegree()), dltInverse); - q = q.add(field.buildMonomial(degreeDiff, scale)); - r = r.subtract(rLast.multiplyByMonomial(degreeDiff, scale)); - } - - t = q.multiply(tLast).subtract(tLastLast).negative(); - } - - int sigmaTildeAtZero = t.getCoefficient(0); - if (sigmaTildeAtZero == 0) { - throw ChecksumException.getChecksumInstance(); - } - - int inverse = field.inverse(sigmaTildeAtZero); - ModulusPoly sigma = t.multiply(inverse); - ModulusPoly omega = r.multiply(inverse); - return new ModulusPoly[]{sigma, omega}; - } - - private int[] findErrorLocations(ModulusPoly errorLocator) throws ChecksumException { - // This is a direct application of Chien's search - int numErrors = errorLocator.getDegree(); - int[] result = new int[numErrors]; - int e = 0; - for (int i = 1; i < field.getSize() && e < numErrors; i++) { - if (errorLocator.evaluateAt(i) == 0) { - result[e] = field.inverse(i); - e++; - } - } - if (e != numErrors) { - throw ChecksumException.getChecksumInstance(); - } - return result; - } - - private int[] findErrorMagnitudes(ModulusPoly errorEvaluator, - ModulusPoly errorLocator, - int[] errorLocations) { - int errorLocatorDegree = errorLocator.getDegree(); - if (errorLocatorDegree < 1) { - return new int[0]; - } - int[] formalDerivativeCoefficients = new int[errorLocatorDegree]; - for (int i = 1; i <= errorLocatorDegree; i++) { - formalDerivativeCoefficients[errorLocatorDegree - i] = - field.multiply(i, errorLocator.getCoefficient(i)); - } - ModulusPoly formalDerivative = new ModulusPoly(field, formalDerivativeCoefficients); - - // This is directly applying Forney's Formula - int s = errorLocations.length; - int[] result = new int[s]; - for (int i = 0; i < s; i++) { - int xiInverse = field.inverse(errorLocations[i]); - int numerator = field.subtract(0, errorEvaluator.evaluateAt(xiInverse)); - int denominator = field.inverse(formalDerivative.evaluateAt(xiInverse)); - result[i] = field.multiply(numerator, denominator); - } - return result; - } -} diff --git a/port_src/core/DONE/pdf417/decoder/ec/ModulusGF.java b/port_src/core/DONE/pdf417/decoder/ec/ModulusGF.java deleted file mode 100644 index 61c86c5..0000000 --- a/port_src/core/DONE/pdf417/decoder/ec/ModulusGF.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder.ec; - -import com.google.zxing.pdf417.PDF417Common; - -/** - *

A field based on powers of a generator integer, modulo some modulus.

- * - * @author Sean Owen - * @see com.google.zxing.common.reedsolomon.GenericGF - */ -public final class ModulusGF { - - public static final ModulusGF PDF417_GF = new ModulusGF(PDF417Common.NUMBER_OF_CODEWORDS, 3); - - private final int[] expTable; - private final int[] logTable; - private final ModulusPoly zero; - private final ModulusPoly one; - private final int modulus; - - private ModulusGF(int modulus, int generator) { - this.modulus = modulus; - expTable = new int[modulus]; - logTable = new int[modulus]; - int x = 1; - for (int i = 0; i < modulus; i++) { - expTable[i] = x; - x = (x * generator) % modulus; - } - for (int i = 0; i < modulus - 1; i++) { - logTable[expTable[i]] = i; - } - // logTable[0] == 0 but this should never be used - zero = new ModulusPoly(this, new int[]{0}); - one = new ModulusPoly(this, new int[]{1}); - } - - - ModulusPoly getZero() { - return zero; - } - - ModulusPoly getOne() { - return one; - } - - ModulusPoly buildMonomial(int degree, int coefficient) { - if (degree < 0) { - throw new IllegalArgumentException(); - } - if (coefficient == 0) { - return zero; - } - int[] coefficients = new int[degree + 1]; - coefficients[0] = coefficient; - return new ModulusPoly(this, coefficients); - } - - int add(int a, int b) { - return (a + b) % modulus; - } - - int subtract(int a, int b) { - return (modulus + a - b) % modulus; - } - - int exp(int a) { - return expTable[a]; - } - - int log(int a) { - if (a == 0) { - throw new IllegalArgumentException(); - } - return logTable[a]; - } - - int inverse(int a) { - if (a == 0) { - throw new ArithmeticException(); - } - return expTable[modulus - logTable[a] - 1]; - } - - int multiply(int a, int b) { - if (a == 0 || b == 0) { - return 0; - } - return expTable[(logTable[a] + logTable[b]) % (modulus - 1)]; - } - - int getSize() { - return modulus; - } - -} diff --git a/port_src/core/DONE/pdf417/decoder/ec/ModulusPoly.java b/port_src/core/DONE/pdf417/decoder/ec/ModulusPoly.java deleted file mode 100644 index acc49b7..0000000 --- a/port_src/core/DONE/pdf417/decoder/ec/ModulusPoly.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder.ec; - -/** - * @author Sean Owen - */ -final class ModulusPoly { - - private final ModulusGF field; - private final int[] coefficients; - - ModulusPoly(ModulusGF field, int[] coefficients) { - if (coefficients.length == 0) { - throw new IllegalArgumentException(); - } - this.field = field; - int coefficientsLength = coefficients.length; - if (coefficientsLength > 1 && coefficients[0] == 0) { - // Leading term must be non-zero for anything except the constant polynomial "0" - int firstNonZero = 1; - while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) { - firstNonZero++; - } - if (firstNonZero == coefficientsLength) { - this.coefficients = new int[]{0}; - } else { - this.coefficients = new int[coefficientsLength - firstNonZero]; - System.arraycopy(coefficients, - firstNonZero, - this.coefficients, - 0, - this.coefficients.length); - } - } else { - this.coefficients = coefficients; - } - } - - int[] getCoefficients() { - return coefficients; - } - - /** - * @return degree of this polynomial - */ - int getDegree() { - return coefficients.length - 1; - } - - /** - * @return true iff this polynomial is the monomial "0" - */ - boolean isZero() { - return coefficients[0] == 0; - } - - /** - * @return coefficient of x^degree term in this polynomial - */ - int getCoefficient(int degree) { - return coefficients[coefficients.length - 1 - degree]; - } - - /** - * @return evaluation of this polynomial at a given point - */ - int evaluateAt(int a) { - if (a == 0) { - // Just return the x^0 coefficient - return getCoefficient(0); - } - if (a == 1) { - // Just the sum of the coefficients - int result = 0; - for (int coefficient : coefficients) { - result = field.add(result, coefficient); - } - return result; - } - int result = coefficients[0]; - int size = coefficients.length; - for (int i = 1; i < size; i++) { - result = field.add(field.multiply(a, result), coefficients[i]); - } - return result; - } - - ModulusPoly add(ModulusPoly other) { - if (!field.equals(other.field)) { - throw new IllegalArgumentException("ModulusPolys do not have same ModulusGF field"); - } - if (isZero()) { - return other; - } - if (other.isZero()) { - return this; - } - - int[] smallerCoefficients = this.coefficients; - int[] largerCoefficients = other.coefficients; - if (smallerCoefficients.length > largerCoefficients.length) { - int[] temp = smallerCoefficients; - smallerCoefficients = largerCoefficients; - largerCoefficients = temp; - } - int[] sumDiff = new int[largerCoefficients.length]; - int lengthDiff = largerCoefficients.length - smallerCoefficients.length; - // Copy high-order terms only found in higher-degree polynomial's coefficients - System.arraycopy(largerCoefficients, 0, sumDiff, 0, lengthDiff); - - for (int i = lengthDiff; i < largerCoefficients.length; i++) { - sumDiff[i] = field.add(smallerCoefficients[i - lengthDiff], largerCoefficients[i]); - } - - return new ModulusPoly(field, sumDiff); - } - - ModulusPoly subtract(ModulusPoly other) { - if (!field.equals(other.field)) { - throw new IllegalArgumentException("ModulusPolys do not have same ModulusGF field"); - } - if (other.isZero()) { - return this; - } - return add(other.negative()); - } - - ModulusPoly multiply(ModulusPoly other) { - if (!field.equals(other.field)) { - throw new IllegalArgumentException("ModulusPolys do not have same ModulusGF field"); - } - if (isZero() || other.isZero()) { - return field.getZero(); - } - int[] aCoefficients = this.coefficients; - int aLength = aCoefficients.length; - int[] bCoefficients = other.coefficients; - int bLength = bCoefficients.length; - int[] product = new int[aLength + bLength - 1]; - for (int i = 0; i < aLength; i++) { - int aCoeff = aCoefficients[i]; - for (int j = 0; j < bLength; j++) { - product[i + j] = field.add(product[i + j], field.multiply(aCoeff, bCoefficients[j])); - } - } - return new ModulusPoly(field, product); - } - - ModulusPoly negative() { - int size = coefficients.length; - int[] negativeCoefficients = new int[size]; - for (int i = 0; i < size; i++) { - negativeCoefficients[i] = field.subtract(0, coefficients[i]); - } - return new ModulusPoly(field, negativeCoefficients); - } - - ModulusPoly multiply(int scalar) { - if (scalar == 0) { - return field.getZero(); - } - if (scalar == 1) { - return this; - } - int size = coefficients.length; - int[] product = new int[size]; - for (int i = 0; i < size; i++) { - product[i] = field.multiply(coefficients[i], scalar); - } - return new ModulusPoly(field, product); - } - - ModulusPoly multiplyByMonomial(int degree, int coefficient) { - if (degree < 0) { - throw new IllegalArgumentException(); - } - if (coefficient == 0) { - return field.getZero(); - } - int size = coefficients.length; - int[] product = new int[size + degree]; - for (int i = 0; i < size; i++) { - product[i] = field.multiply(coefficients[i], coefficient); - } - return new ModulusPoly(field, product); - } - - @Override - public String toString() { - StringBuilder result = new StringBuilder(8 * getDegree()); - for (int degree = getDegree(); degree >= 0; degree--) { - int coefficient = getCoefficient(degree); - if (coefficient != 0) { - if (coefficient < 0) { - result.append(" - "); - coefficient = -coefficient; - } else { - if (result.length() > 0) { - result.append(" + "); - } - } - if (degree == 0 || coefficient != 1) { - result.append(coefficient); - } - if (degree != 0) { - if (degree == 1) { - result.append('x'); - } else { - result.append("x^"); - result.append(degree); - } - } - } - } - return result.toString(); - } - -} diff --git a/port_src/core/DONE/pdf417/detector/Detector.java b/port_src/core/DONE/pdf417/detector/Detector.java deleted file mode 100644 index 8b771a5..0000000 --- a/port_src/core/DONE/pdf417/detector/Detector.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.detector; - -import com.google.zxing.BinaryBitmap; -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - *

Encapsulates logic that can detect a PDF417 Code in an image, even if the - * PDF417 Code is rotated or skewed, or partially obscured.

- * - * @author SITA Lab (kevin.osullivan@sita.aero) - * @author dswitkin@google.com (Daniel Switkin) - * @author Guenther Grau - */ -public final class Detector { - - private static final int[] INDEXES_START_PATTERN = {0, 4, 1, 5}; - private static final int[] INDEXES_STOP_PATTERN = {6, 2, 7, 3}; - private static final float MAX_AVG_VARIANCE = 0.42f; - private static final float MAX_INDIVIDUAL_VARIANCE = 0.8f; - - // B S B S B S B S Bar/Space pattern - // 11111111 0 1 0 1 0 1 000 - private static final int[] START_PATTERN = {8, 1, 1, 1, 1, 1, 1, 3}; - // 1111111 0 1 000 1 0 1 00 1 - private static final int[] STOP_PATTERN = {7, 1, 1, 3, 1, 1, 1, 2, 1}; - private static final int MAX_PIXEL_DRIFT = 3; - private static final int MAX_PATTERN_DRIFT = 5; - // if we set the value too low, then we don't detect the correct height of the bar if the start patterns are damaged. - // if we set the value too high, then we might detect the start pattern from a neighbor barcode. - private static final int SKIPPED_ROW_COUNT_MAX = 25; - // A PDF471 barcode should have at least 3 rows, with each row being >= 3 times the module width. - // Therefore it should be at least 9 pixels tall. To be conservative, we use about half the size to - // ensure we don't miss it. - private static final int ROW_STEP = 5; - private static final int BARCODE_MIN_HEIGHT = 10; - private static final int[] ROTATIONS = {0, 180, 270, 90}; - - private Detector() { - } - - /** - *

Detects a PDF417 Code in an image. Checks 0, 90, 180, and 270 degree rotations.

- * - * @param image barcode image to decode - * @param hints optional hints to detector - * @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will - * be found and returned - * @return {@link PDF417DetectorResult} encapsulating results of detecting a PDF417 code - * @throws NotFoundException if no PDF417 Code can be found - */ - public static PDF417DetectorResult detect(BinaryBitmap image, Map hints, boolean multiple) - throws NotFoundException { - // TODO detection improvement, tryHarder could try several different luminance thresholds/blackpoints or even - // different binarizers - //boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); - - BitMatrix originalMatrix = image.getBlackMatrix(); - for (int rotation : ROTATIONS) { - BitMatrix bitMatrix = applyRotation(originalMatrix, rotation); - List barcodeCoordinates = detect(multiple, bitMatrix); - if (!barcodeCoordinates.isEmpty()) { - return new PDF417DetectorResult(bitMatrix, barcodeCoordinates, rotation); - } - } - return new PDF417DetectorResult(originalMatrix, new ArrayList<>(), 0); - } - - /** - * Applies a rotation to the supplied BitMatrix. - * @param matrix bit matrix to apply rotation to - * @param rotation the degrees of rotation to apply - * @return BitMatrix with applied rotation - */ - private static BitMatrix applyRotation(BitMatrix matrix, int rotation) { - if (rotation % 360 == 0) { - return matrix; - } - - BitMatrix newMatrix = matrix.clone(); - newMatrix.rotate(rotation); - return newMatrix; - } - - /** - * Detects PDF417 codes in an image. Only checks 0 degree rotation - * @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will - * be found and returned - * @param bitMatrix bit matrix to detect barcodes in - * @return List of ResultPoint arrays containing the coordinates of found barcodes - */ - private static List detect(boolean multiple, BitMatrix bitMatrix) { - List barcodeCoordinates = new ArrayList<>(); - int row = 0; - int column = 0; - boolean foundBarcodeInRow = false; - while (row < bitMatrix.getHeight()) { - ResultPoint[] vertices = findVertices(bitMatrix, row, column); - - if (vertices[0] == null && vertices[3] == null) { - if (!foundBarcodeInRow) { - // we didn't find any barcode so that's the end of searching - break; - } - // we didn't find a barcode starting at the given column and row. Try again from the first column and slightly - // below the lowest barcode we found so far. - foundBarcodeInRow = false; - column = 0; - for (ResultPoint[] barcodeCoordinate : barcodeCoordinates) { - if (barcodeCoordinate[1] != null) { - row = (int) Math.max(row, barcodeCoordinate[1].getY()); - } - if (barcodeCoordinate[3] != null) { - row = Math.max(row, (int) barcodeCoordinate[3].getY()); - } - } - row += ROW_STEP; - continue; - } - foundBarcodeInRow = true; - barcodeCoordinates.add(vertices); - if (!multiple) { - break; - } - // if we didn't find a right row indicator column, then continue the search for the next barcode after the - // start pattern of the barcode just found. - if (vertices[2] != null) { - column = (int) vertices[2].getX(); - row = (int) vertices[2].getY(); - } else { - column = (int) vertices[4].getX(); - row = (int) vertices[4].getY(); - } - } - return barcodeCoordinates; - } - - /** - * Locate the vertices and the codewords area of a black blob using the Start - * and Stop patterns as locators. - * - * @param matrix the scanned barcode image. - * @return an array containing the vertices: - * vertices[0] x, y top left barcode - * vertices[1] x, y bottom left barcode - * vertices[2] x, y top right barcode - * vertices[3] x, y bottom right barcode - * vertices[4] x, y top left codeword area - * vertices[5] x, y bottom left codeword area - * vertices[6] x, y top right codeword area - * vertices[7] x, y bottom right codeword area - */ - private static ResultPoint[] findVertices(BitMatrix matrix, int startRow, int startColumn) { - int height = matrix.getHeight(); - int width = matrix.getWidth(); - - ResultPoint[] result = new ResultPoint[8]; - copyToResult(result, findRowsWithPattern(matrix, height, width, startRow, startColumn, START_PATTERN), - INDEXES_START_PATTERN); - - if (result[4] != null) { - startColumn = (int) result[4].getX(); - startRow = (int) result[4].getY(); - } - copyToResult(result, findRowsWithPattern(matrix, height, width, startRow, startColumn, STOP_PATTERN), - INDEXES_STOP_PATTERN); - return result; - } - - private static void copyToResult(ResultPoint[] result, ResultPoint[] tmpResult, int[] destinationIndexes) { - for (int i = 0; i < destinationIndexes.length; i++) { - result[destinationIndexes[i]] = tmpResult[i]; - } - } - - private static ResultPoint[] findRowsWithPattern(BitMatrix matrix, - int height, - int width, - int startRow, - int startColumn, - int[] pattern) { - ResultPoint[] result = new ResultPoint[4]; - boolean found = false; - int[] counters = new int[pattern.length]; - for (; startRow < height; startRow += ROW_STEP) { - int[] loc = findGuardPattern(matrix, startColumn, startRow, width, pattern, counters); - if (loc != null) { - while (startRow > 0) { - int[] previousRowLoc = findGuardPattern(matrix, startColumn, --startRow, width, pattern, counters); - if (previousRowLoc != null) { - loc = previousRowLoc; - } else { - startRow++; - break; - } - } - result[0] = new ResultPoint(loc[0], startRow); - result[1] = new ResultPoint(loc[1], startRow); - found = true; - break; - } - } - int stopRow = startRow + 1; - // Last row of the current symbol that contains pattern - if (found) { - int skippedRowCount = 0; - int[] previousRowLoc = {(int) result[0].getX(), (int) result[1].getX()}; - for (; stopRow < height; stopRow++) { - int[] loc = findGuardPattern(matrix, previousRowLoc[0], stopRow, width, pattern, counters); - // a found pattern is only considered to belong to the same barcode if the start and end positions - // don't differ too much. Pattern drift should be not bigger than two for consecutive rows. With - // a higher number of skipped rows drift could be larger. To keep it simple for now, we allow a slightly - // larger drift and don't check for skipped rows. - if (loc != null && - Math.abs(previousRowLoc[0] - loc[0]) < MAX_PATTERN_DRIFT && - Math.abs(previousRowLoc[1] - loc[1]) < MAX_PATTERN_DRIFT) { - previousRowLoc = loc; - skippedRowCount = 0; - } else { - if (skippedRowCount > SKIPPED_ROW_COUNT_MAX) { - break; - } else { - skippedRowCount++; - } - } - } - stopRow -= skippedRowCount + 1; - result[2] = new ResultPoint(previousRowLoc[0], stopRow); - result[3] = new ResultPoint(previousRowLoc[1], stopRow); - } - if (stopRow - startRow < BARCODE_MIN_HEIGHT) { - Arrays.fill(result, null); - } - return result; - } - - /** - * @param matrix row of black/white values to search - * @param column x position to start search - * @param row y position to start search - * @param width the number of pixels to search on this row - * @param pattern pattern of counts of number of black and white pixels that are - * being searched for as a pattern - * @param counters array of counters, as long as pattern, to re-use - * @return start/end horizontal offset of guard pattern, as an array of two ints. - */ - private static int[] findGuardPattern(BitMatrix matrix, - int column, - int row, - int width, - int[] pattern, - int[] counters) { - Arrays.fill(counters, 0, counters.length, 0); - int patternStart = column; - int pixelDrift = 0; - - // if there are black pixels left of the current pixel shift to the left, but only for MAX_PIXEL_DRIFT pixels - while (matrix.get(patternStart, row) && patternStart > 0 && pixelDrift++ < MAX_PIXEL_DRIFT) { - patternStart--; - } - int x = patternStart; - int counterPosition = 0; - int patternLength = pattern.length; - for (boolean isWhite = false; x < width; x++) { - boolean pixel = matrix.get(x, row); - if (pixel != isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == patternLength - 1) { - if (patternMatchVariance(counters, pattern) < MAX_AVG_VARIANCE) { - return new int[] {patternStart, x}; - } - patternStart += counters[0] + counters[1]; - System.arraycopy(counters, 2, counters, 0, counterPosition - 1); - counters[counterPosition - 1] = 0; - counters[counterPosition] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - if (counterPosition == patternLength - 1 && - patternMatchVariance(counters, pattern) < MAX_AVG_VARIANCE) { - return new int[] {patternStart, x - 1}; - } - return null; - } - - /** - * Determines how closely a set of observed counts of runs of black/white - * values matches a given target pattern. This is reported as the ratio of - * the total variance from the expected pattern proportions across all - * pattern elements, to the length of the pattern. - * - * @param counters observed counters - * @param pattern expected pattern - * @return ratio of total variance between counters and pattern compared to total pattern size - */ - private static float patternMatchVariance(int[] counters, int[] pattern) { - int numCounters = counters.length; - int total = 0; - int patternLength = 0; - for (int i = 0; i < numCounters; i++) { - total += counters[i]; - patternLength += pattern[i]; - } - if (total < patternLength) { - // If we don't even have one pixel per unit of bar width, assume this - // is too small to reliably match, so fail: - return Float.POSITIVE_INFINITY; - } - // We're going to fake floating-point math in integers. We just need to use more bits. - // Scale up patternLength so that intermediate values below like scaledCounter will have - // more "significant digits". - float unitBarWidth = (float) total / patternLength; - float maxIndividualVariance = MAX_INDIVIDUAL_VARIANCE * unitBarWidth; - - float totalVariance = 0.0f; - for (int x = 0; x < numCounters; x++) { - int counter = counters[x]; - float scaledPattern = pattern[x] * unitBarWidth; - float variance = counter > scaledPattern ? counter - scaledPattern : scaledPattern - counter; - if (variance > maxIndividualVariance) { - return Float.POSITIVE_INFINITY; - } - totalVariance += variance; - } - return totalVariance / total; - } -} diff --git a/port_src/core/DONE/pdf417/detector/PDF417DetectorResult.java b/port_src/core/DONE/pdf417/detector/PDF417DetectorResult.java deleted file mode 100644 index 7aa82c5..0000000 --- a/port_src/core/DONE/pdf417/detector/PDF417DetectorResult.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.detector; - -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; - -import java.util.List; - -/** - * @author Guenther Grau - */ -public final class PDF417DetectorResult { - - private final BitMatrix bits; - private final List points; - private final int rotation; - - public PDF417DetectorResult(BitMatrix bits, List points, int rotation) { - this.bits = bits; - this.points = points; - this.rotation = rotation; - } - - public PDF417DetectorResult(BitMatrix bits, List points) { - this(bits, points, 0); - } - - public BitMatrix getBits() { - return bits; - } - - public List getPoints() { - return points; - } - - public int getRotation() { - return rotation; - } - -} diff --git a/port_src/core/DONE/pdf417/encoder/BarcodeMatrix.java b/port_src/core/DONE/pdf417/encoder/BarcodeMatrix.java deleted file mode 100644 index b4f6980..0000000 --- a/port_src/core/DONE/pdf417/encoder/BarcodeMatrix.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.encoder; - -/** - * Holds all of the information for a barcode in a format where it can be easily accessible - * - * @author Jacob Haynes - */ -public final class BarcodeMatrix { - - private final BarcodeRow[] matrix; - private int currentRow; - private final int height; - private final int width; - - /** - * @param height the height of the matrix (Rows) - * @param width the width of the matrix (Cols) - */ - BarcodeMatrix(int height, int width) { - matrix = new BarcodeRow[height]; - //Initializes the array to the correct width - for (int i = 0, matrixLength = matrix.length; i < matrixLength; i++) { - matrix[i] = new BarcodeRow((width + 4) * 17 + 1); - } - this.width = width * 17; - this.height = height; - this.currentRow = -1; - } - - void set(int x, int y, byte value) { - matrix[y].set(x, value); - } - - void startRow() { - ++currentRow; - } - - BarcodeRow getCurrentRow() { - return matrix[currentRow]; - } - - public byte[][] getMatrix() { - return getScaledMatrix(1, 1); - } - - public byte[][] getScaledMatrix(int xScale, int yScale) { - byte[][] matrixOut = new byte[height * yScale][width * xScale]; - int yMax = height * yScale; - for (int i = 0; i < yMax; i++) { - matrixOut[yMax - i - 1] = matrix[i / yScale].getScaledRow(xScale); - } - return matrixOut; - } -} diff --git a/port_src/core/DONE/pdf417/encoder/BarcodeRow.java b/port_src/core/DONE/pdf417/encoder/BarcodeRow.java deleted file mode 100644 index ad93d27..0000000 --- a/port_src/core/DONE/pdf417/encoder/BarcodeRow.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.encoder; - -/** - * @author Jacob Haynes - */ -final class BarcodeRow { - - private final byte[] row; - //A tacker for position in the bar - private int currentLocation; - - /** - * Creates a Barcode row of the width - */ - BarcodeRow(int width) { - this.row = new byte[width]; - currentLocation = 0; - } - - /** - * Sets a specific location in the bar - * - * @param x The location in the bar - * @param value Black if true, white if false; - */ - void set(int x, byte value) { - row[x] = value; - } - - /** - * Sets a specific location in the bar - * - * @param x The location in the bar - * @param black Black if true, white if false; - */ - private void set(int x, boolean black) { - row[x] = (byte) (black ? 1 : 0); - } - - /** - * @param black A boolean which is true if the bar black false if it is white - * @param width How many spots wide the bar is. - */ - void addBar(boolean black, int width) { - for (int ii = 0; ii < width; ii++) { - set(currentLocation++, black); - } - } - - /** - * This function scales the row - * - * @param scale How much you want the image to be scaled, must be greater than or equal to 1. - * @return the scaled row - */ - byte[] getScaledRow(int scale) { - byte[] output = new byte[row.length * scale]; - for (int i = 0; i < output.length; i++) { - output[i] = row[i / scale]; - } - return output; - } -} diff --git a/port_src/core/DONE/pdf417/encoder/Compaction.java b/port_src/core/DONE/pdf417/encoder/Compaction.java deleted file mode 100644 index 67cf4b8..0000000 --- a/port_src/core/DONE/pdf417/encoder/Compaction.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.encoder; - -/** - * Represents possible PDF417 barcode compaction types. - */ -public enum Compaction { - - AUTO, - TEXT, - BYTE, - NUMERIC - -} diff --git a/port_src/core/DONE/pdf417/encoder/Dimensions.java b/port_src/core/DONE/pdf417/encoder/Dimensions.java deleted file mode 100644 index 83a736b..0000000 --- a/port_src/core/DONE/pdf417/encoder/Dimensions.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.encoder; - -/** - * Data object to specify the minimum and maximum number of rows and columns for a PDF417 barcode. - * - * @author qwandor@google.com (Andrew Walbran) - */ -public final class Dimensions { - - private final int minCols; - private final int maxCols; - private final int minRows; - private final int maxRows; - - public Dimensions(int minCols, int maxCols, int minRows, int maxRows) { - this.minCols = minCols; - this.maxCols = maxCols; - this.minRows = minRows; - this.maxRows = maxRows; - } - - public int getMinCols() { - return minCols; - } - - public int getMaxCols() { - return maxCols; - } - - public int getMinRows() { - return minRows; - } - - public int getMaxRows() { - return maxRows; - } - -} diff --git a/port_src/core/DONE/pdf417/encoder/PDF417.java b/port_src/core/DONE/pdf417/encoder/PDF417.java deleted file mode 100644 index a9d63dc..0000000 --- a/port_src/core/DONE/pdf417/encoder/PDF417.java +++ /dev/null @@ -1,778 +0,0 @@ -/* - * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * This file has been modified from its original form in Barcode4J. - */ - -package com.google.zxing.pdf417.encoder; - -import com.google.zxing.WriterException; - -import java.nio.charset.Charset; - -/** - * Top-level class for the logic part of the PDF417 implementation. - */ -public final class PDF417 { - - /** - * The start pattern (17 bits) - */ - private static final int START_PATTERN = 0x1fea8; - /** - * The stop pattern (18 bits) - */ - private static final int STOP_PATTERN = 0x3fa29; - - /** - * The codeword table from the Annex A of ISO/IEC 15438:2001(E). - */ - private static final int[][] CODEWORD_TABLE = { - {0x1d5c0, 0x1eaf0, 0x1f57c, 0x1d4e0, 0x1ea78, 0x1f53e, - 0x1a8c0, 0x1d470, 0x1a860, 0x15040, 0x1a830, 0x15020, - 0x1adc0, 0x1d6f0, 0x1eb7c, 0x1ace0, 0x1d678, 0x1eb3e, - 0x158c0, 0x1ac70, 0x15860, 0x15dc0, 0x1aef0, 0x1d77c, - 0x15ce0, 0x1ae78, 0x1d73e, 0x15c70, 0x1ae3c, 0x15ef0, - 0x1af7c, 0x15e78, 0x1af3e, 0x15f7c, 0x1f5fa, 0x1d2e0, - 0x1e978, 0x1f4be, 0x1a4c0, 0x1d270, 0x1e93c, 0x1a460, - 0x1d238, 0x14840, 0x1a430, 0x1d21c, 0x14820, 0x1a418, - 0x14810, 0x1a6e0, 0x1d378, 0x1e9be, 0x14cc0, 0x1a670, - 0x1d33c, 0x14c60, 0x1a638, 0x1d31e, 0x14c30, 0x1a61c, - 0x14ee0, 0x1a778, 0x1d3be, 0x14e70, 0x1a73c, 0x14e38, - 0x1a71e, 0x14f78, 0x1a7be, 0x14f3c, 0x14f1e, 0x1a2c0, - 0x1d170, 0x1e8bc, 0x1a260, 0x1d138, 0x1e89e, 0x14440, - 0x1a230, 0x1d11c, 0x14420, 0x1a218, 0x14410, 0x14408, - 0x146c0, 0x1a370, 0x1d1bc, 0x14660, 0x1a338, 0x1d19e, - 0x14630, 0x1a31c, 0x14618, 0x1460c, 0x14770, 0x1a3bc, - 0x14738, 0x1a39e, 0x1471c, 0x147bc, 0x1a160, 0x1d0b8, - 0x1e85e, 0x14240, 0x1a130, 0x1d09c, 0x14220, 0x1a118, - 0x1d08e, 0x14210, 0x1a10c, 0x14208, 0x1a106, 0x14360, - 0x1a1b8, 0x1d0de, 0x14330, 0x1a19c, 0x14318, 0x1a18e, - 0x1430c, 0x14306, 0x1a1de, 0x1438e, 0x14140, 0x1a0b0, - 0x1d05c, 0x14120, 0x1a098, 0x1d04e, 0x14110, 0x1a08c, - 0x14108, 0x1a086, 0x14104, 0x141b0, 0x14198, 0x1418c, - 0x140a0, 0x1d02e, 0x1a04c, 0x1a046, 0x14082, 0x1cae0, - 0x1e578, 0x1f2be, 0x194c0, 0x1ca70, 0x1e53c, 0x19460, - 0x1ca38, 0x1e51e, 0x12840, 0x19430, 0x12820, 0x196e0, - 0x1cb78, 0x1e5be, 0x12cc0, 0x19670, 0x1cb3c, 0x12c60, - 0x19638, 0x12c30, 0x12c18, 0x12ee0, 0x19778, 0x1cbbe, - 0x12e70, 0x1973c, 0x12e38, 0x12e1c, 0x12f78, 0x197be, - 0x12f3c, 0x12fbe, 0x1dac0, 0x1ed70, 0x1f6bc, 0x1da60, - 0x1ed38, 0x1f69e, 0x1b440, 0x1da30, 0x1ed1c, 0x1b420, - 0x1da18, 0x1ed0e, 0x1b410, 0x1da0c, 0x192c0, 0x1c970, - 0x1e4bc, 0x1b6c0, 0x19260, 0x1c938, 0x1e49e, 0x1b660, - 0x1db38, 0x1ed9e, 0x16c40, 0x12420, 0x19218, 0x1c90e, - 0x16c20, 0x1b618, 0x16c10, 0x126c0, 0x19370, 0x1c9bc, - 0x16ec0, 0x12660, 0x19338, 0x1c99e, 0x16e60, 0x1b738, - 0x1db9e, 0x16e30, 0x12618, 0x16e18, 0x12770, 0x193bc, - 0x16f70, 0x12738, 0x1939e, 0x16f38, 0x1b79e, 0x16f1c, - 0x127bc, 0x16fbc, 0x1279e, 0x16f9e, 0x1d960, 0x1ecb8, - 0x1f65e, 0x1b240, 0x1d930, 0x1ec9c, 0x1b220, 0x1d918, - 0x1ec8e, 0x1b210, 0x1d90c, 0x1b208, 0x1b204, 0x19160, - 0x1c8b8, 0x1e45e, 0x1b360, 0x19130, 0x1c89c, 0x16640, - 0x12220, 0x1d99c, 0x1c88e, 0x16620, 0x12210, 0x1910c, - 0x16610, 0x1b30c, 0x19106, 0x12204, 0x12360, 0x191b8, - 0x1c8de, 0x16760, 0x12330, 0x1919c, 0x16730, 0x1b39c, - 0x1918e, 0x16718, 0x1230c, 0x12306, 0x123b8, 0x191de, - 0x167b8, 0x1239c, 0x1679c, 0x1238e, 0x1678e, 0x167de, - 0x1b140, 0x1d8b0, 0x1ec5c, 0x1b120, 0x1d898, 0x1ec4e, - 0x1b110, 0x1d88c, 0x1b108, 0x1d886, 0x1b104, 0x1b102, - 0x12140, 0x190b0, 0x1c85c, 0x16340, 0x12120, 0x19098, - 0x1c84e, 0x16320, 0x1b198, 0x1d8ce, 0x16310, 0x12108, - 0x19086, 0x16308, 0x1b186, 0x16304, 0x121b0, 0x190dc, - 0x163b0, 0x12198, 0x190ce, 0x16398, 0x1b1ce, 0x1638c, - 0x12186, 0x16386, 0x163dc, 0x163ce, 0x1b0a0, 0x1d858, - 0x1ec2e, 0x1b090, 0x1d84c, 0x1b088, 0x1d846, 0x1b084, - 0x1b082, 0x120a0, 0x19058, 0x1c82e, 0x161a0, 0x12090, - 0x1904c, 0x16190, 0x1b0cc, 0x19046, 0x16188, 0x12084, - 0x16184, 0x12082, 0x120d8, 0x161d8, 0x161cc, 0x161c6, - 0x1d82c, 0x1d826, 0x1b042, 0x1902c, 0x12048, 0x160c8, - 0x160c4, 0x160c2, 0x18ac0, 0x1c570, 0x1e2bc, 0x18a60, - 0x1c538, 0x11440, 0x18a30, 0x1c51c, 0x11420, 0x18a18, - 0x11410, 0x11408, 0x116c0, 0x18b70, 0x1c5bc, 0x11660, - 0x18b38, 0x1c59e, 0x11630, 0x18b1c, 0x11618, 0x1160c, - 0x11770, 0x18bbc, 0x11738, 0x18b9e, 0x1171c, 0x117bc, - 0x1179e, 0x1cd60, 0x1e6b8, 0x1f35e, 0x19a40, 0x1cd30, - 0x1e69c, 0x19a20, 0x1cd18, 0x1e68e, 0x19a10, 0x1cd0c, - 0x19a08, 0x1cd06, 0x18960, 0x1c4b8, 0x1e25e, 0x19b60, - 0x18930, 0x1c49c, 0x13640, 0x11220, 0x1cd9c, 0x1c48e, - 0x13620, 0x19b18, 0x1890c, 0x13610, 0x11208, 0x13608, - 0x11360, 0x189b8, 0x1c4de, 0x13760, 0x11330, 0x1cdde, - 0x13730, 0x19b9c, 0x1898e, 0x13718, 0x1130c, 0x1370c, - 0x113b8, 0x189de, 0x137b8, 0x1139c, 0x1379c, 0x1138e, - 0x113de, 0x137de, 0x1dd40, 0x1eeb0, 0x1f75c, 0x1dd20, - 0x1ee98, 0x1f74e, 0x1dd10, 0x1ee8c, 0x1dd08, 0x1ee86, - 0x1dd04, 0x19940, 0x1ccb0, 0x1e65c, 0x1bb40, 0x19920, - 0x1eedc, 0x1e64e, 0x1bb20, 0x1dd98, 0x1eece, 0x1bb10, - 0x19908, 0x1cc86, 0x1bb08, 0x1dd86, 0x19902, 0x11140, - 0x188b0, 0x1c45c, 0x13340, 0x11120, 0x18898, 0x1c44e, - 0x17740, 0x13320, 0x19998, 0x1ccce, 0x17720, 0x1bb98, - 0x1ddce, 0x18886, 0x17710, 0x13308, 0x19986, 0x17708, - 0x11102, 0x111b0, 0x188dc, 0x133b0, 0x11198, 0x188ce, - 0x177b0, 0x13398, 0x199ce, 0x17798, 0x1bbce, 0x11186, - 0x13386, 0x111dc, 0x133dc, 0x111ce, 0x177dc, 0x133ce, - 0x1dca0, 0x1ee58, 0x1f72e, 0x1dc90, 0x1ee4c, 0x1dc88, - 0x1ee46, 0x1dc84, 0x1dc82, 0x198a0, 0x1cc58, 0x1e62e, - 0x1b9a0, 0x19890, 0x1ee6e, 0x1b990, 0x1dccc, 0x1cc46, - 0x1b988, 0x19884, 0x1b984, 0x19882, 0x1b982, 0x110a0, - 0x18858, 0x1c42e, 0x131a0, 0x11090, 0x1884c, 0x173a0, - 0x13190, 0x198cc, 0x18846, 0x17390, 0x1b9cc, 0x11084, - 0x17388, 0x13184, 0x11082, 0x13182, 0x110d8, 0x1886e, - 0x131d8, 0x110cc, 0x173d8, 0x131cc, 0x110c6, 0x173cc, - 0x131c6, 0x110ee, 0x173ee, 0x1dc50, 0x1ee2c, 0x1dc48, - 0x1ee26, 0x1dc44, 0x1dc42, 0x19850, 0x1cc2c, 0x1b8d0, - 0x19848, 0x1cc26, 0x1b8c8, 0x1dc66, 0x1b8c4, 0x19842, - 0x1b8c2, 0x11050, 0x1882c, 0x130d0, 0x11048, 0x18826, - 0x171d0, 0x130c8, 0x19866, 0x171c8, 0x1b8e6, 0x11042, - 0x171c4, 0x130c2, 0x171c2, 0x130ec, 0x171ec, 0x171e6, - 0x1ee16, 0x1dc22, 0x1cc16, 0x19824, 0x19822, 0x11028, - 0x13068, 0x170e8, 0x11022, 0x13062, 0x18560, 0x10a40, - 0x18530, 0x10a20, 0x18518, 0x1c28e, 0x10a10, 0x1850c, - 0x10a08, 0x18506, 0x10b60, 0x185b8, 0x1c2de, 0x10b30, - 0x1859c, 0x10b18, 0x1858e, 0x10b0c, 0x10b06, 0x10bb8, - 0x185de, 0x10b9c, 0x10b8e, 0x10bde, 0x18d40, 0x1c6b0, - 0x1e35c, 0x18d20, 0x1c698, 0x18d10, 0x1c68c, 0x18d08, - 0x1c686, 0x18d04, 0x10940, 0x184b0, 0x1c25c, 0x11b40, - 0x10920, 0x1c6dc, 0x1c24e, 0x11b20, 0x18d98, 0x1c6ce, - 0x11b10, 0x10908, 0x18486, 0x11b08, 0x18d86, 0x10902, - 0x109b0, 0x184dc, 0x11bb0, 0x10998, 0x184ce, 0x11b98, - 0x18dce, 0x11b8c, 0x10986, 0x109dc, 0x11bdc, 0x109ce, - 0x11bce, 0x1cea0, 0x1e758, 0x1f3ae, 0x1ce90, 0x1e74c, - 0x1ce88, 0x1e746, 0x1ce84, 0x1ce82, 0x18ca0, 0x1c658, - 0x19da0, 0x18c90, 0x1c64c, 0x19d90, 0x1cecc, 0x1c646, - 0x19d88, 0x18c84, 0x19d84, 0x18c82, 0x19d82, 0x108a0, - 0x18458, 0x119a0, 0x10890, 0x1c66e, 0x13ba0, 0x11990, - 0x18ccc, 0x18446, 0x13b90, 0x19dcc, 0x10884, 0x13b88, - 0x11984, 0x10882, 0x11982, 0x108d8, 0x1846e, 0x119d8, - 0x108cc, 0x13bd8, 0x119cc, 0x108c6, 0x13bcc, 0x119c6, - 0x108ee, 0x119ee, 0x13bee, 0x1ef50, 0x1f7ac, 0x1ef48, - 0x1f7a6, 0x1ef44, 0x1ef42, 0x1ce50, 0x1e72c, 0x1ded0, - 0x1ef6c, 0x1e726, 0x1dec8, 0x1ef66, 0x1dec4, 0x1ce42, - 0x1dec2, 0x18c50, 0x1c62c, 0x19cd0, 0x18c48, 0x1c626, - 0x1bdd0, 0x19cc8, 0x1ce66, 0x1bdc8, 0x1dee6, 0x18c42, - 0x1bdc4, 0x19cc2, 0x1bdc2, 0x10850, 0x1842c, 0x118d0, - 0x10848, 0x18426, 0x139d0, 0x118c8, 0x18c66, 0x17bd0, - 0x139c8, 0x19ce6, 0x10842, 0x17bc8, 0x1bde6, 0x118c2, - 0x17bc4, 0x1086c, 0x118ec, 0x10866, 0x139ec, 0x118e6, - 0x17bec, 0x139e6, 0x17be6, 0x1ef28, 0x1f796, 0x1ef24, - 0x1ef22, 0x1ce28, 0x1e716, 0x1de68, 0x1ef36, 0x1de64, - 0x1ce22, 0x1de62, 0x18c28, 0x1c616, 0x19c68, 0x18c24, - 0x1bce8, 0x19c64, 0x18c22, 0x1bce4, 0x19c62, 0x1bce2, - 0x10828, 0x18416, 0x11868, 0x18c36, 0x138e8, 0x11864, - 0x10822, 0x179e8, 0x138e4, 0x11862, 0x179e4, 0x138e2, - 0x179e2, 0x11876, 0x179f6, 0x1ef12, 0x1de34, 0x1de32, - 0x19c34, 0x1bc74, 0x1bc72, 0x11834, 0x13874, 0x178f4, - 0x178f2, 0x10540, 0x10520, 0x18298, 0x10510, 0x10508, - 0x10504, 0x105b0, 0x10598, 0x1058c, 0x10586, 0x105dc, - 0x105ce, 0x186a0, 0x18690, 0x1c34c, 0x18688, 0x1c346, - 0x18684, 0x18682, 0x104a0, 0x18258, 0x10da0, 0x186d8, - 0x1824c, 0x10d90, 0x186cc, 0x10d88, 0x186c6, 0x10d84, - 0x10482, 0x10d82, 0x104d8, 0x1826e, 0x10dd8, 0x186ee, - 0x10dcc, 0x104c6, 0x10dc6, 0x104ee, 0x10dee, 0x1c750, - 0x1c748, 0x1c744, 0x1c742, 0x18650, 0x18ed0, 0x1c76c, - 0x1c326, 0x18ec8, 0x1c766, 0x18ec4, 0x18642, 0x18ec2, - 0x10450, 0x10cd0, 0x10448, 0x18226, 0x11dd0, 0x10cc8, - 0x10444, 0x11dc8, 0x10cc4, 0x10442, 0x11dc4, 0x10cc2, - 0x1046c, 0x10cec, 0x10466, 0x11dec, 0x10ce6, 0x11de6, - 0x1e7a8, 0x1e7a4, 0x1e7a2, 0x1c728, 0x1cf68, 0x1e7b6, - 0x1cf64, 0x1c722, 0x1cf62, 0x18628, 0x1c316, 0x18e68, - 0x1c736, 0x19ee8, 0x18e64, 0x18622, 0x19ee4, 0x18e62, - 0x19ee2, 0x10428, 0x18216, 0x10c68, 0x18636, 0x11ce8, - 0x10c64, 0x10422, 0x13de8, 0x11ce4, 0x10c62, 0x13de4, - 0x11ce2, 0x10436, 0x10c76, 0x11cf6, 0x13df6, 0x1f7d4, - 0x1f7d2, 0x1e794, 0x1efb4, 0x1e792, 0x1efb2, 0x1c714, - 0x1cf34, 0x1c712, 0x1df74, 0x1cf32, 0x1df72, 0x18614, - 0x18e34, 0x18612, 0x19e74, 0x18e32, 0x1bef4}, - {0x1f560, 0x1fab8, 0x1ea40, 0x1f530, 0x1fa9c, 0x1ea20, - 0x1f518, 0x1fa8e, 0x1ea10, 0x1f50c, 0x1ea08, 0x1f506, - 0x1ea04, 0x1eb60, 0x1f5b8, 0x1fade, 0x1d640, 0x1eb30, - 0x1f59c, 0x1d620, 0x1eb18, 0x1f58e, 0x1d610, 0x1eb0c, - 0x1d608, 0x1eb06, 0x1d604, 0x1d760, 0x1ebb8, 0x1f5de, - 0x1ae40, 0x1d730, 0x1eb9c, 0x1ae20, 0x1d718, 0x1eb8e, - 0x1ae10, 0x1d70c, 0x1ae08, 0x1d706, 0x1ae04, 0x1af60, - 0x1d7b8, 0x1ebde, 0x15e40, 0x1af30, 0x1d79c, 0x15e20, - 0x1af18, 0x1d78e, 0x15e10, 0x1af0c, 0x15e08, 0x1af06, - 0x15f60, 0x1afb8, 0x1d7de, 0x15f30, 0x1af9c, 0x15f18, - 0x1af8e, 0x15f0c, 0x15fb8, 0x1afde, 0x15f9c, 0x15f8e, - 0x1e940, 0x1f4b0, 0x1fa5c, 0x1e920, 0x1f498, 0x1fa4e, - 0x1e910, 0x1f48c, 0x1e908, 0x1f486, 0x1e904, 0x1e902, - 0x1d340, 0x1e9b0, 0x1f4dc, 0x1d320, 0x1e998, 0x1f4ce, - 0x1d310, 0x1e98c, 0x1d308, 0x1e986, 0x1d304, 0x1d302, - 0x1a740, 0x1d3b0, 0x1e9dc, 0x1a720, 0x1d398, 0x1e9ce, - 0x1a710, 0x1d38c, 0x1a708, 0x1d386, 0x1a704, 0x1a702, - 0x14f40, 0x1a7b0, 0x1d3dc, 0x14f20, 0x1a798, 0x1d3ce, - 0x14f10, 0x1a78c, 0x14f08, 0x1a786, 0x14f04, 0x14fb0, - 0x1a7dc, 0x14f98, 0x1a7ce, 0x14f8c, 0x14f86, 0x14fdc, - 0x14fce, 0x1e8a0, 0x1f458, 0x1fa2e, 0x1e890, 0x1f44c, - 0x1e888, 0x1f446, 0x1e884, 0x1e882, 0x1d1a0, 0x1e8d8, - 0x1f46e, 0x1d190, 0x1e8cc, 0x1d188, 0x1e8c6, 0x1d184, - 0x1d182, 0x1a3a0, 0x1d1d8, 0x1e8ee, 0x1a390, 0x1d1cc, - 0x1a388, 0x1d1c6, 0x1a384, 0x1a382, 0x147a0, 0x1a3d8, - 0x1d1ee, 0x14790, 0x1a3cc, 0x14788, 0x1a3c6, 0x14784, - 0x14782, 0x147d8, 0x1a3ee, 0x147cc, 0x147c6, 0x147ee, - 0x1e850, 0x1f42c, 0x1e848, 0x1f426, 0x1e844, 0x1e842, - 0x1d0d0, 0x1e86c, 0x1d0c8, 0x1e866, 0x1d0c4, 0x1d0c2, - 0x1a1d0, 0x1d0ec, 0x1a1c8, 0x1d0e6, 0x1a1c4, 0x1a1c2, - 0x143d0, 0x1a1ec, 0x143c8, 0x1a1e6, 0x143c4, 0x143c2, - 0x143ec, 0x143e6, 0x1e828, 0x1f416, 0x1e824, 0x1e822, - 0x1d068, 0x1e836, 0x1d064, 0x1d062, 0x1a0e8, 0x1d076, - 0x1a0e4, 0x1a0e2, 0x141e8, 0x1a0f6, 0x141e4, 0x141e2, - 0x1e814, 0x1e812, 0x1d034, 0x1d032, 0x1a074, 0x1a072, - 0x1e540, 0x1f2b0, 0x1f95c, 0x1e520, 0x1f298, 0x1f94e, - 0x1e510, 0x1f28c, 0x1e508, 0x1f286, 0x1e504, 0x1e502, - 0x1cb40, 0x1e5b0, 0x1f2dc, 0x1cb20, 0x1e598, 0x1f2ce, - 0x1cb10, 0x1e58c, 0x1cb08, 0x1e586, 0x1cb04, 0x1cb02, - 0x19740, 0x1cbb0, 0x1e5dc, 0x19720, 0x1cb98, 0x1e5ce, - 0x19710, 0x1cb8c, 0x19708, 0x1cb86, 0x19704, 0x19702, - 0x12f40, 0x197b0, 0x1cbdc, 0x12f20, 0x19798, 0x1cbce, - 0x12f10, 0x1978c, 0x12f08, 0x19786, 0x12f04, 0x12fb0, - 0x197dc, 0x12f98, 0x197ce, 0x12f8c, 0x12f86, 0x12fdc, - 0x12fce, 0x1f6a0, 0x1fb58, 0x16bf0, 0x1f690, 0x1fb4c, - 0x169f8, 0x1f688, 0x1fb46, 0x168fc, 0x1f684, 0x1f682, - 0x1e4a0, 0x1f258, 0x1f92e, 0x1eda0, 0x1e490, 0x1fb6e, - 0x1ed90, 0x1f6cc, 0x1f246, 0x1ed88, 0x1e484, 0x1ed84, - 0x1e482, 0x1ed82, 0x1c9a0, 0x1e4d8, 0x1f26e, 0x1dba0, - 0x1c990, 0x1e4cc, 0x1db90, 0x1edcc, 0x1e4c6, 0x1db88, - 0x1c984, 0x1db84, 0x1c982, 0x1db82, 0x193a0, 0x1c9d8, - 0x1e4ee, 0x1b7a0, 0x19390, 0x1c9cc, 0x1b790, 0x1dbcc, - 0x1c9c6, 0x1b788, 0x19384, 0x1b784, 0x19382, 0x1b782, - 0x127a0, 0x193d8, 0x1c9ee, 0x16fa0, 0x12790, 0x193cc, - 0x16f90, 0x1b7cc, 0x193c6, 0x16f88, 0x12784, 0x16f84, - 0x12782, 0x127d8, 0x193ee, 0x16fd8, 0x127cc, 0x16fcc, - 0x127c6, 0x16fc6, 0x127ee, 0x1f650, 0x1fb2c, 0x165f8, - 0x1f648, 0x1fb26, 0x164fc, 0x1f644, 0x1647e, 0x1f642, - 0x1e450, 0x1f22c, 0x1ecd0, 0x1e448, 0x1f226, 0x1ecc8, - 0x1f666, 0x1ecc4, 0x1e442, 0x1ecc2, 0x1c8d0, 0x1e46c, - 0x1d9d0, 0x1c8c8, 0x1e466, 0x1d9c8, 0x1ece6, 0x1d9c4, - 0x1c8c2, 0x1d9c2, 0x191d0, 0x1c8ec, 0x1b3d0, 0x191c8, - 0x1c8e6, 0x1b3c8, 0x1d9e6, 0x1b3c4, 0x191c2, 0x1b3c2, - 0x123d0, 0x191ec, 0x167d0, 0x123c8, 0x191e6, 0x167c8, - 0x1b3e6, 0x167c4, 0x123c2, 0x167c2, 0x123ec, 0x167ec, - 0x123e6, 0x167e6, 0x1f628, 0x1fb16, 0x162fc, 0x1f624, - 0x1627e, 0x1f622, 0x1e428, 0x1f216, 0x1ec68, 0x1f636, - 0x1ec64, 0x1e422, 0x1ec62, 0x1c868, 0x1e436, 0x1d8e8, - 0x1c864, 0x1d8e4, 0x1c862, 0x1d8e2, 0x190e8, 0x1c876, - 0x1b1e8, 0x1d8f6, 0x1b1e4, 0x190e2, 0x1b1e2, 0x121e8, - 0x190f6, 0x163e8, 0x121e4, 0x163e4, 0x121e2, 0x163e2, - 0x121f6, 0x163f6, 0x1f614, 0x1617e, 0x1f612, 0x1e414, - 0x1ec34, 0x1e412, 0x1ec32, 0x1c834, 0x1d874, 0x1c832, - 0x1d872, 0x19074, 0x1b0f4, 0x19072, 0x1b0f2, 0x120f4, - 0x161f4, 0x120f2, 0x161f2, 0x1f60a, 0x1e40a, 0x1ec1a, - 0x1c81a, 0x1d83a, 0x1903a, 0x1b07a, 0x1e2a0, 0x1f158, - 0x1f8ae, 0x1e290, 0x1f14c, 0x1e288, 0x1f146, 0x1e284, - 0x1e282, 0x1c5a0, 0x1e2d8, 0x1f16e, 0x1c590, 0x1e2cc, - 0x1c588, 0x1e2c6, 0x1c584, 0x1c582, 0x18ba0, 0x1c5d8, - 0x1e2ee, 0x18b90, 0x1c5cc, 0x18b88, 0x1c5c6, 0x18b84, - 0x18b82, 0x117a0, 0x18bd8, 0x1c5ee, 0x11790, 0x18bcc, - 0x11788, 0x18bc6, 0x11784, 0x11782, 0x117d8, 0x18bee, - 0x117cc, 0x117c6, 0x117ee, 0x1f350, 0x1f9ac, 0x135f8, - 0x1f348, 0x1f9a6, 0x134fc, 0x1f344, 0x1347e, 0x1f342, - 0x1e250, 0x1f12c, 0x1e6d0, 0x1e248, 0x1f126, 0x1e6c8, - 0x1f366, 0x1e6c4, 0x1e242, 0x1e6c2, 0x1c4d0, 0x1e26c, - 0x1cdd0, 0x1c4c8, 0x1e266, 0x1cdc8, 0x1e6e6, 0x1cdc4, - 0x1c4c2, 0x1cdc2, 0x189d0, 0x1c4ec, 0x19bd0, 0x189c8, - 0x1c4e6, 0x19bc8, 0x1cde6, 0x19bc4, 0x189c2, 0x19bc2, - 0x113d0, 0x189ec, 0x137d0, 0x113c8, 0x189e6, 0x137c8, - 0x19be6, 0x137c4, 0x113c2, 0x137c2, 0x113ec, 0x137ec, - 0x113e6, 0x137e6, 0x1fba8, 0x175f0, 0x1bafc, 0x1fba4, - 0x174f8, 0x1ba7e, 0x1fba2, 0x1747c, 0x1743e, 0x1f328, - 0x1f996, 0x132fc, 0x1f768, 0x1fbb6, 0x176fc, 0x1327e, - 0x1f764, 0x1f322, 0x1767e, 0x1f762, 0x1e228, 0x1f116, - 0x1e668, 0x1e224, 0x1eee8, 0x1f776, 0x1e222, 0x1eee4, - 0x1e662, 0x1eee2, 0x1c468, 0x1e236, 0x1cce8, 0x1c464, - 0x1dde8, 0x1cce4, 0x1c462, 0x1dde4, 0x1cce2, 0x1dde2, - 0x188e8, 0x1c476, 0x199e8, 0x188e4, 0x1bbe8, 0x199e4, - 0x188e2, 0x1bbe4, 0x199e2, 0x1bbe2, 0x111e8, 0x188f6, - 0x133e8, 0x111e4, 0x177e8, 0x133e4, 0x111e2, 0x177e4, - 0x133e2, 0x177e2, 0x111f6, 0x133f6, 0x1fb94, 0x172f8, - 0x1b97e, 0x1fb92, 0x1727c, 0x1723e, 0x1f314, 0x1317e, - 0x1f734, 0x1f312, 0x1737e, 0x1f732, 0x1e214, 0x1e634, - 0x1e212, 0x1ee74, 0x1e632, 0x1ee72, 0x1c434, 0x1cc74, - 0x1c432, 0x1dcf4, 0x1cc72, 0x1dcf2, 0x18874, 0x198f4, - 0x18872, 0x1b9f4, 0x198f2, 0x1b9f2, 0x110f4, 0x131f4, - 0x110f2, 0x173f4, 0x131f2, 0x173f2, 0x1fb8a, 0x1717c, - 0x1713e, 0x1f30a, 0x1f71a, 0x1e20a, 0x1e61a, 0x1ee3a, - 0x1c41a, 0x1cc3a, 0x1dc7a, 0x1883a, 0x1987a, 0x1b8fa, - 0x1107a, 0x130fa, 0x171fa, 0x170be, 0x1e150, 0x1f0ac, - 0x1e148, 0x1f0a6, 0x1e144, 0x1e142, 0x1c2d0, 0x1e16c, - 0x1c2c8, 0x1e166, 0x1c2c4, 0x1c2c2, 0x185d0, 0x1c2ec, - 0x185c8, 0x1c2e6, 0x185c4, 0x185c2, 0x10bd0, 0x185ec, - 0x10bc8, 0x185e6, 0x10bc4, 0x10bc2, 0x10bec, 0x10be6, - 0x1f1a8, 0x1f8d6, 0x11afc, 0x1f1a4, 0x11a7e, 0x1f1a2, - 0x1e128, 0x1f096, 0x1e368, 0x1e124, 0x1e364, 0x1e122, - 0x1e362, 0x1c268, 0x1e136, 0x1c6e8, 0x1c264, 0x1c6e4, - 0x1c262, 0x1c6e2, 0x184e8, 0x1c276, 0x18de8, 0x184e4, - 0x18de4, 0x184e2, 0x18de2, 0x109e8, 0x184f6, 0x11be8, - 0x109e4, 0x11be4, 0x109e2, 0x11be2, 0x109f6, 0x11bf6, - 0x1f9d4, 0x13af8, 0x19d7e, 0x1f9d2, 0x13a7c, 0x13a3e, - 0x1f194, 0x1197e, 0x1f3b4, 0x1f192, 0x13b7e, 0x1f3b2, - 0x1e114, 0x1e334, 0x1e112, 0x1e774, 0x1e332, 0x1e772, - 0x1c234, 0x1c674, 0x1c232, 0x1cef4, 0x1c672, 0x1cef2, - 0x18474, 0x18cf4, 0x18472, 0x19df4, 0x18cf2, 0x19df2, - 0x108f4, 0x119f4, 0x108f2, 0x13bf4, 0x119f2, 0x13bf2, - 0x17af0, 0x1bd7c, 0x17a78, 0x1bd3e, 0x17a3c, 0x17a1e, - 0x1f9ca, 0x1397c, 0x1fbda, 0x17b7c, 0x1393e, 0x17b3e, - 0x1f18a, 0x1f39a, 0x1f7ba, 0x1e10a, 0x1e31a, 0x1e73a, - 0x1ef7a, 0x1c21a, 0x1c63a, 0x1ce7a, 0x1defa, 0x1843a, - 0x18c7a, 0x19cfa, 0x1bdfa, 0x1087a, 0x118fa, 0x139fa, - 0x17978, 0x1bcbe, 0x1793c, 0x1791e, 0x138be, 0x179be, - 0x178bc, 0x1789e, 0x1785e, 0x1e0a8, 0x1e0a4, 0x1e0a2, - 0x1c168, 0x1e0b6, 0x1c164, 0x1c162, 0x182e8, 0x1c176, - 0x182e4, 0x182e2, 0x105e8, 0x182f6, 0x105e4, 0x105e2, - 0x105f6, 0x1f0d4, 0x10d7e, 0x1f0d2, 0x1e094, 0x1e1b4, - 0x1e092, 0x1e1b2, 0x1c134, 0x1c374, 0x1c132, 0x1c372, - 0x18274, 0x186f4, 0x18272, 0x186f2, 0x104f4, 0x10df4, - 0x104f2, 0x10df2, 0x1f8ea, 0x11d7c, 0x11d3e, 0x1f0ca, - 0x1f1da, 0x1e08a, 0x1e19a, 0x1e3ba, 0x1c11a, 0x1c33a, - 0x1c77a, 0x1823a, 0x1867a, 0x18efa, 0x1047a, 0x10cfa, - 0x11dfa, 0x13d78, 0x19ebe, 0x13d3c, 0x13d1e, 0x11cbe, - 0x13dbe, 0x17d70, 0x1bebc, 0x17d38, 0x1be9e, 0x17d1c, - 0x17d0e, 0x13cbc, 0x17dbc, 0x13c9e, 0x17d9e, 0x17cb8, - 0x1be5e, 0x17c9c, 0x17c8e, 0x13c5e, 0x17cde, 0x17c5c, - 0x17c4e, 0x17c2e, 0x1c0b4, 0x1c0b2, 0x18174, 0x18172, - 0x102f4, 0x102f2, 0x1e0da, 0x1c09a, 0x1c1ba, 0x1813a, - 0x1837a, 0x1027a, 0x106fa, 0x10ebe, 0x11ebc, 0x11e9e, - 0x13eb8, 0x19f5e, 0x13e9c, 0x13e8e, 0x11e5e, 0x13ede, - 0x17eb0, 0x1bf5c, 0x17e98, 0x1bf4e, 0x17e8c, 0x17e86, - 0x13e5c, 0x17edc, 0x13e4e, 0x17ece, 0x17e58, 0x1bf2e, - 0x17e4c, 0x17e46, 0x13e2e, 0x17e6e, 0x17e2c, 0x17e26, - 0x10f5e, 0x11f5c, 0x11f4e, 0x13f58, 0x19fae, 0x13f4c, - 0x13f46, 0x11f2e, 0x13f6e, 0x13f2c, 0x13f26}, - {0x1abe0, 0x1d5f8, 0x153c0, 0x1a9f0, 0x1d4fc, 0x151e0, - 0x1a8f8, 0x1d47e, 0x150f0, 0x1a87c, 0x15078, 0x1fad0, - 0x15be0, 0x1adf8, 0x1fac8, 0x159f0, 0x1acfc, 0x1fac4, - 0x158f8, 0x1ac7e, 0x1fac2, 0x1587c, 0x1f5d0, 0x1faec, - 0x15df8, 0x1f5c8, 0x1fae6, 0x15cfc, 0x1f5c4, 0x15c7e, - 0x1f5c2, 0x1ebd0, 0x1f5ec, 0x1ebc8, 0x1f5e6, 0x1ebc4, - 0x1ebc2, 0x1d7d0, 0x1ebec, 0x1d7c8, 0x1ebe6, 0x1d7c4, - 0x1d7c2, 0x1afd0, 0x1d7ec, 0x1afc8, 0x1d7e6, 0x1afc4, - 0x14bc0, 0x1a5f0, 0x1d2fc, 0x149e0, 0x1a4f8, 0x1d27e, - 0x148f0, 0x1a47c, 0x14878, 0x1a43e, 0x1483c, 0x1fa68, - 0x14df0, 0x1a6fc, 0x1fa64, 0x14cf8, 0x1a67e, 0x1fa62, - 0x14c7c, 0x14c3e, 0x1f4e8, 0x1fa76, 0x14efc, 0x1f4e4, - 0x14e7e, 0x1f4e2, 0x1e9e8, 0x1f4f6, 0x1e9e4, 0x1e9e2, - 0x1d3e8, 0x1e9f6, 0x1d3e4, 0x1d3e2, 0x1a7e8, 0x1d3f6, - 0x1a7e4, 0x1a7e2, 0x145e0, 0x1a2f8, 0x1d17e, 0x144f0, - 0x1a27c, 0x14478, 0x1a23e, 0x1443c, 0x1441e, 0x1fa34, - 0x146f8, 0x1a37e, 0x1fa32, 0x1467c, 0x1463e, 0x1f474, - 0x1477e, 0x1f472, 0x1e8f4, 0x1e8f2, 0x1d1f4, 0x1d1f2, - 0x1a3f4, 0x1a3f2, 0x142f0, 0x1a17c, 0x14278, 0x1a13e, - 0x1423c, 0x1421e, 0x1fa1a, 0x1437c, 0x1433e, 0x1f43a, - 0x1e87a, 0x1d0fa, 0x14178, 0x1a0be, 0x1413c, 0x1411e, - 0x141be, 0x140bc, 0x1409e, 0x12bc0, 0x195f0, 0x1cafc, - 0x129e0, 0x194f8, 0x1ca7e, 0x128f0, 0x1947c, 0x12878, - 0x1943e, 0x1283c, 0x1f968, 0x12df0, 0x196fc, 0x1f964, - 0x12cf8, 0x1967e, 0x1f962, 0x12c7c, 0x12c3e, 0x1f2e8, - 0x1f976, 0x12efc, 0x1f2e4, 0x12e7e, 0x1f2e2, 0x1e5e8, - 0x1f2f6, 0x1e5e4, 0x1e5e2, 0x1cbe8, 0x1e5f6, 0x1cbe4, - 0x1cbe2, 0x197e8, 0x1cbf6, 0x197e4, 0x197e2, 0x1b5e0, - 0x1daf8, 0x1ed7e, 0x169c0, 0x1b4f0, 0x1da7c, 0x168e0, - 0x1b478, 0x1da3e, 0x16870, 0x1b43c, 0x16838, 0x1b41e, - 0x1681c, 0x125e0, 0x192f8, 0x1c97e, 0x16de0, 0x124f0, - 0x1927c, 0x16cf0, 0x1b67c, 0x1923e, 0x16c78, 0x1243c, - 0x16c3c, 0x1241e, 0x16c1e, 0x1f934, 0x126f8, 0x1937e, - 0x1fb74, 0x1f932, 0x16ef8, 0x1267c, 0x1fb72, 0x16e7c, - 0x1263e, 0x16e3e, 0x1f274, 0x1277e, 0x1f6f4, 0x1f272, - 0x16f7e, 0x1f6f2, 0x1e4f4, 0x1edf4, 0x1e4f2, 0x1edf2, - 0x1c9f4, 0x1dbf4, 0x1c9f2, 0x1dbf2, 0x193f4, 0x193f2, - 0x165c0, 0x1b2f0, 0x1d97c, 0x164e0, 0x1b278, 0x1d93e, - 0x16470, 0x1b23c, 0x16438, 0x1b21e, 0x1641c, 0x1640e, - 0x122f0, 0x1917c, 0x166f0, 0x12278, 0x1913e, 0x16678, - 0x1b33e, 0x1663c, 0x1221e, 0x1661e, 0x1f91a, 0x1237c, - 0x1fb3a, 0x1677c, 0x1233e, 0x1673e, 0x1f23a, 0x1f67a, - 0x1e47a, 0x1ecfa, 0x1c8fa, 0x1d9fa, 0x191fa, 0x162e0, - 0x1b178, 0x1d8be, 0x16270, 0x1b13c, 0x16238, 0x1b11e, - 0x1621c, 0x1620e, 0x12178, 0x190be, 0x16378, 0x1213c, - 0x1633c, 0x1211e, 0x1631e, 0x121be, 0x163be, 0x16170, - 0x1b0bc, 0x16138, 0x1b09e, 0x1611c, 0x1610e, 0x120bc, - 0x161bc, 0x1209e, 0x1619e, 0x160b8, 0x1b05e, 0x1609c, - 0x1608e, 0x1205e, 0x160de, 0x1605c, 0x1604e, 0x115e0, - 0x18af8, 0x1c57e, 0x114f0, 0x18a7c, 0x11478, 0x18a3e, - 0x1143c, 0x1141e, 0x1f8b4, 0x116f8, 0x18b7e, 0x1f8b2, - 0x1167c, 0x1163e, 0x1f174, 0x1177e, 0x1f172, 0x1e2f4, - 0x1e2f2, 0x1c5f4, 0x1c5f2, 0x18bf4, 0x18bf2, 0x135c0, - 0x19af0, 0x1cd7c, 0x134e0, 0x19a78, 0x1cd3e, 0x13470, - 0x19a3c, 0x13438, 0x19a1e, 0x1341c, 0x1340e, 0x112f0, - 0x1897c, 0x136f0, 0x11278, 0x1893e, 0x13678, 0x19b3e, - 0x1363c, 0x1121e, 0x1361e, 0x1f89a, 0x1137c, 0x1f9ba, - 0x1377c, 0x1133e, 0x1373e, 0x1f13a, 0x1f37a, 0x1e27a, - 0x1e6fa, 0x1c4fa, 0x1cdfa, 0x189fa, 0x1bae0, 0x1dd78, - 0x1eebe, 0x174c0, 0x1ba70, 0x1dd3c, 0x17460, 0x1ba38, - 0x1dd1e, 0x17430, 0x1ba1c, 0x17418, 0x1ba0e, 0x1740c, - 0x132e0, 0x19978, 0x1ccbe, 0x176e0, 0x13270, 0x1993c, - 0x17670, 0x1bb3c, 0x1991e, 0x17638, 0x1321c, 0x1761c, - 0x1320e, 0x1760e, 0x11178, 0x188be, 0x13378, 0x1113c, - 0x17778, 0x1333c, 0x1111e, 0x1773c, 0x1331e, 0x1771e, - 0x111be, 0x133be, 0x177be, 0x172c0, 0x1b970, 0x1dcbc, - 0x17260, 0x1b938, 0x1dc9e, 0x17230, 0x1b91c, 0x17218, - 0x1b90e, 0x1720c, 0x17206, 0x13170, 0x198bc, 0x17370, - 0x13138, 0x1989e, 0x17338, 0x1b99e, 0x1731c, 0x1310e, - 0x1730e, 0x110bc, 0x131bc, 0x1109e, 0x173bc, 0x1319e, - 0x1739e, 0x17160, 0x1b8b8, 0x1dc5e, 0x17130, 0x1b89c, - 0x17118, 0x1b88e, 0x1710c, 0x17106, 0x130b8, 0x1985e, - 0x171b8, 0x1309c, 0x1719c, 0x1308e, 0x1718e, 0x1105e, - 0x130de, 0x171de, 0x170b0, 0x1b85c, 0x17098, 0x1b84e, - 0x1708c, 0x17086, 0x1305c, 0x170dc, 0x1304e, 0x170ce, - 0x17058, 0x1b82e, 0x1704c, 0x17046, 0x1302e, 0x1706e, - 0x1702c, 0x17026, 0x10af0, 0x1857c, 0x10a78, 0x1853e, - 0x10a3c, 0x10a1e, 0x10b7c, 0x10b3e, 0x1f0ba, 0x1e17a, - 0x1c2fa, 0x185fa, 0x11ae0, 0x18d78, 0x1c6be, 0x11a70, - 0x18d3c, 0x11a38, 0x18d1e, 0x11a1c, 0x11a0e, 0x10978, - 0x184be, 0x11b78, 0x1093c, 0x11b3c, 0x1091e, 0x11b1e, - 0x109be, 0x11bbe, 0x13ac0, 0x19d70, 0x1cebc, 0x13a60, - 0x19d38, 0x1ce9e, 0x13a30, 0x19d1c, 0x13a18, 0x19d0e, - 0x13a0c, 0x13a06, 0x11970, 0x18cbc, 0x13b70, 0x11938, - 0x18c9e, 0x13b38, 0x1191c, 0x13b1c, 0x1190e, 0x13b0e, - 0x108bc, 0x119bc, 0x1089e, 0x13bbc, 0x1199e, 0x13b9e, - 0x1bd60, 0x1deb8, 0x1ef5e, 0x17a40, 0x1bd30, 0x1de9c, - 0x17a20, 0x1bd18, 0x1de8e, 0x17a10, 0x1bd0c, 0x17a08, - 0x1bd06, 0x17a04, 0x13960, 0x19cb8, 0x1ce5e, 0x17b60, - 0x13930, 0x19c9c, 0x17b30, 0x1bd9c, 0x19c8e, 0x17b18, - 0x1390c, 0x17b0c, 0x13906, 0x17b06, 0x118b8, 0x18c5e, - 0x139b8, 0x1189c, 0x17bb8, 0x1399c, 0x1188e, 0x17b9c, - 0x1398e, 0x17b8e, 0x1085e, 0x118de, 0x139de, 0x17bde, - 0x17940, 0x1bcb0, 0x1de5c, 0x17920, 0x1bc98, 0x1de4e, - 0x17910, 0x1bc8c, 0x17908, 0x1bc86, 0x17904, 0x17902, - 0x138b0, 0x19c5c, 0x179b0, 0x13898, 0x19c4e, 0x17998, - 0x1bcce, 0x1798c, 0x13886, 0x17986, 0x1185c, 0x138dc, - 0x1184e, 0x179dc, 0x138ce, 0x179ce, 0x178a0, 0x1bc58, - 0x1de2e, 0x17890, 0x1bc4c, 0x17888, 0x1bc46, 0x17884, - 0x17882, 0x13858, 0x19c2e, 0x178d8, 0x1384c, 0x178cc, - 0x13846, 0x178c6, 0x1182e, 0x1386e, 0x178ee, 0x17850, - 0x1bc2c, 0x17848, 0x1bc26, 0x17844, 0x17842, 0x1382c, - 0x1786c, 0x13826, 0x17866, 0x17828, 0x1bc16, 0x17824, - 0x17822, 0x13816, 0x17836, 0x10578, 0x182be, 0x1053c, - 0x1051e, 0x105be, 0x10d70, 0x186bc, 0x10d38, 0x1869e, - 0x10d1c, 0x10d0e, 0x104bc, 0x10dbc, 0x1049e, 0x10d9e, - 0x11d60, 0x18eb8, 0x1c75e, 0x11d30, 0x18e9c, 0x11d18, - 0x18e8e, 0x11d0c, 0x11d06, 0x10cb8, 0x1865e, 0x11db8, - 0x10c9c, 0x11d9c, 0x10c8e, 0x11d8e, 0x1045e, 0x10cde, - 0x11dde, 0x13d40, 0x19eb0, 0x1cf5c, 0x13d20, 0x19e98, - 0x1cf4e, 0x13d10, 0x19e8c, 0x13d08, 0x19e86, 0x13d04, - 0x13d02, 0x11cb0, 0x18e5c, 0x13db0, 0x11c98, 0x18e4e, - 0x13d98, 0x19ece, 0x13d8c, 0x11c86, 0x13d86, 0x10c5c, - 0x11cdc, 0x10c4e, 0x13ddc, 0x11cce, 0x13dce, 0x1bea0, - 0x1df58, 0x1efae, 0x1be90, 0x1df4c, 0x1be88, 0x1df46, - 0x1be84, 0x1be82, 0x13ca0, 0x19e58, 0x1cf2e, 0x17da0, - 0x13c90, 0x19e4c, 0x17d90, 0x1becc, 0x19e46, 0x17d88, - 0x13c84, 0x17d84, 0x13c82, 0x17d82, 0x11c58, 0x18e2e, - 0x13cd8, 0x11c4c, 0x17dd8, 0x13ccc, 0x11c46, 0x17dcc, - 0x13cc6, 0x17dc6, 0x10c2e, 0x11c6e, 0x13cee, 0x17dee, - 0x1be50, 0x1df2c, 0x1be48, 0x1df26, 0x1be44, 0x1be42, - 0x13c50, 0x19e2c, 0x17cd0, 0x13c48, 0x19e26, 0x17cc8, - 0x1be66, 0x17cc4, 0x13c42, 0x17cc2, 0x11c2c, 0x13c6c, - 0x11c26, 0x17cec, 0x13c66, 0x17ce6, 0x1be28, 0x1df16, - 0x1be24, 0x1be22, 0x13c28, 0x19e16, 0x17c68, 0x13c24, - 0x17c64, 0x13c22, 0x17c62, 0x11c16, 0x13c36, 0x17c76, - 0x1be14, 0x1be12, 0x13c14, 0x17c34, 0x13c12, 0x17c32, - 0x102bc, 0x1029e, 0x106b8, 0x1835e, 0x1069c, 0x1068e, - 0x1025e, 0x106de, 0x10eb0, 0x1875c, 0x10e98, 0x1874e, - 0x10e8c, 0x10e86, 0x1065c, 0x10edc, 0x1064e, 0x10ece, - 0x11ea0, 0x18f58, 0x1c7ae, 0x11e90, 0x18f4c, 0x11e88, - 0x18f46, 0x11e84, 0x11e82, 0x10e58, 0x1872e, 0x11ed8, - 0x18f6e, 0x11ecc, 0x10e46, 0x11ec6, 0x1062e, 0x10e6e, - 0x11eee, 0x19f50, 0x1cfac, 0x19f48, 0x1cfa6, 0x19f44, - 0x19f42, 0x11e50, 0x18f2c, 0x13ed0, 0x19f6c, 0x18f26, - 0x13ec8, 0x11e44, 0x13ec4, 0x11e42, 0x13ec2, 0x10e2c, - 0x11e6c, 0x10e26, 0x13eec, 0x11e66, 0x13ee6, 0x1dfa8, - 0x1efd6, 0x1dfa4, 0x1dfa2, 0x19f28, 0x1cf96, 0x1bf68, - 0x19f24, 0x1bf64, 0x19f22, 0x1bf62, 0x11e28, 0x18f16, - 0x13e68, 0x11e24, 0x17ee8, 0x13e64, 0x11e22, 0x17ee4, - 0x13e62, 0x17ee2, 0x10e16, 0x11e36, 0x13e76, 0x17ef6, - 0x1df94, 0x1df92, 0x19f14, 0x1bf34, 0x19f12, 0x1bf32, - 0x11e14, 0x13e34, 0x11e12, 0x17e74, 0x13e32, 0x17e72, - 0x1df8a, 0x19f0a, 0x1bf1a, 0x11e0a, 0x13e1a, 0x17e3a, - 0x1035c, 0x1034e, 0x10758, 0x183ae, 0x1074c, 0x10746, - 0x1032e, 0x1076e, 0x10f50, 0x187ac, 0x10f48, 0x187a6, - 0x10f44, 0x10f42, 0x1072c, 0x10f6c, 0x10726, 0x10f66, - 0x18fa8, 0x1c7d6, 0x18fa4, 0x18fa2, 0x10f28, 0x18796, - 0x11f68, 0x18fb6, 0x11f64, 0x10f22, 0x11f62, 0x10716, - 0x10f36, 0x11f76, 0x1cfd4, 0x1cfd2, 0x18f94, 0x19fb4, - 0x18f92, 0x19fb2, 0x10f14, 0x11f34, 0x10f12, 0x13f74, - 0x11f32, 0x13f72, 0x1cfca, 0x18f8a, 0x19f9a, 0x10f0a, - 0x11f1a, 0x13f3a, 0x103ac, 0x103a6, 0x107a8, 0x183d6, - 0x107a4, 0x107a2, 0x10396, 0x107b6, 0x187d4, 0x187d2, - 0x10794, 0x10fb4, 0x10792, 0x10fb2, 0x1c7ea}}; - - private static final float PREFERRED_RATIO = 3.0f; - private static final float DEFAULT_MODULE_WIDTH = 0.357f; //1px in mm - private static final float HEIGHT = 2.0f; //mm - - private BarcodeMatrix barcodeMatrix; - private boolean compact; - private Compaction compaction; - private Charset encoding; - private int minCols; - private int maxCols; - private int maxRows; - private int minRows; - - public PDF417() { - this(false); - } - - public PDF417(boolean compact) { - this.compact = compact; - compaction = Compaction.AUTO; - encoding = null; // Use default - minCols = 2; - maxCols = 30; - maxRows = 30; - minRows = 2; - } - - public BarcodeMatrix getBarcodeMatrix() { - return barcodeMatrix; - } - - /** - * Calculates the necessary number of rows as described in annex Q of ISO/IEC 15438:2001(E). - * - * @param m the number of source codewords prior to the additional of the Symbol Length - * Descriptor and any pad codewords - * @param k the number of error correction codewords - * @param c the number of columns in the symbol in the data region (excluding start, stop and - * row indicator codewords) - * @return the number of rows in the symbol (r) - */ - private static int calculateNumberOfRows(int m, int k, int c) { - int r = ((m + 1 + k) / c) + 1; - if (c * r >= (m + 1 + k + c)) { - r--; - } - return r; - } - - /** - * Calculates the number of pad codewords as described in 4.9.2 of ISO/IEC 15438:2001(E). - * - * @param m the number of source codewords prior to the additional of the Symbol Length - * Descriptor and any pad codewords - * @param k the number of error correction codewords - * @param c the number of columns in the symbol in the data region (excluding start, stop and - * row indicator codewords) - * @param r the number of rows in the symbol - * @return the number of pad codewords - */ - private static int getNumberOfPadCodewords(int m, int k, int c, int r) { - int n = c * r - k; - return n > m + 1 ? n - m - 1 : 0; - } - - private static void encodeChar(int pattern, int len, BarcodeRow logic) { - int map = 1 << len - 1; - boolean last = (pattern & map) != 0; //Initialize to inverse of first bit - int width = 0; - for (int i = 0; i < len; i++) { - boolean black = (pattern & map) != 0; - if (last == black) { - width++; - } else { - logic.addBar(last, width); - - last = black; - width = 1; - } - map >>= 1; - } - logic.addBar(last, width); - } - - private void encodeLowLevel(CharSequence fullCodewords, - int c, - int r, - int errorCorrectionLevel, - BarcodeMatrix logic) { - - int idx = 0; - for (int y = 0; y < r; y++) { - int cluster = y % 3; - logic.startRow(); - encodeChar(START_PATTERN, 17, logic.getCurrentRow()); - - int left; - int right; - if (cluster == 0) { - left = (30 * (y / 3)) + ((r - 1) / 3); - right = (30 * (y / 3)) + (c - 1); - } else if (cluster == 1) { - left = (30 * (y / 3)) + (errorCorrectionLevel * 3) + ((r - 1) % 3); - right = (30 * (y / 3)) + ((r - 1) / 3); - } else { - left = (30 * (y / 3)) + (c - 1); - right = (30 * (y / 3)) + (errorCorrectionLevel * 3) + ((r - 1) % 3); - } - - int pattern = CODEWORD_TABLE[cluster][left]; - encodeChar(pattern, 17, logic.getCurrentRow()); - - for (int x = 0; x < c; x++) { - pattern = CODEWORD_TABLE[cluster][fullCodewords.charAt(idx)]; - encodeChar(pattern, 17, logic.getCurrentRow()); - idx++; - } - - if (compact) { - encodeChar(STOP_PATTERN, 1, logic.getCurrentRow()); // encodes stop line for compact pdf417 - } else { - pattern = CODEWORD_TABLE[cluster][right]; - encodeChar(pattern, 17, logic.getCurrentRow()); - - encodeChar(STOP_PATTERN, 18, logic.getCurrentRow()); - } - } - } - - /** - * @param msg message to encode - * @param errorCorrectionLevel PDF417 error correction level to use - * @throws WriterException if the contents cannot be encoded in this format - */ - public void generateBarcodeLogic(String msg, int errorCorrectionLevel) throws WriterException { - generateBarcodeLogic(msg, errorCorrectionLevel, false); - } - - /** - * @param msg message to encode - * @param errorCorrectionLevel PDF417 error correction level to use - * @param autoECI automatically insert ECIs if needed - * @throws WriterException if the contents cannot be encoded in this format - */ - public void generateBarcodeLogic(String msg, int errorCorrectionLevel, boolean autoECI) throws WriterException { - - //1. step: High-level encoding - int errorCorrectionCodeWords = PDF417ErrorCorrection.getErrorCorrectionCodewordCount(errorCorrectionLevel); - String highLevel = PDF417HighLevelEncoder.encodeHighLevel(msg, compaction, encoding, autoECI); - int sourceCodeWords = highLevel.length(); - - int[] dimension = determineDimensions(sourceCodeWords, errorCorrectionCodeWords); - - int cols = dimension[0]; - int rows = dimension[1]; - - int pad = getNumberOfPadCodewords(sourceCodeWords, errorCorrectionCodeWords, cols, rows); - - //2. step: construct data codewords - if (sourceCodeWords + errorCorrectionCodeWords + 1 > 929) { // +1 for symbol length CW - throw new WriterException( - "Encoded message contains too many code words, message too big (" + msg.length() + " bytes)"); - } - int n = sourceCodeWords + pad + 1; - StringBuilder sb = new StringBuilder(n); - sb.append((char) n); - sb.append(highLevel); - for (int i = 0; i < pad; i++) { - sb.append((char) 900); //PAD characters - } - String dataCodewords = sb.toString(); - - //3. step: Error correction - String ec = PDF417ErrorCorrection.generateErrorCorrection(dataCodewords, errorCorrectionLevel); - - //4. step: low-level encoding - barcodeMatrix = new BarcodeMatrix(rows, cols); - encodeLowLevel(dataCodewords + ec, cols, rows, errorCorrectionLevel, barcodeMatrix); - } - - /** - * Determine optimal nr of columns and rows for the specified number of - * codewords. - * - * @param sourceCodeWords number of code words - * @param errorCorrectionCodeWords number of error correction code words - * @return dimension object containing cols as width and rows as height - */ - private int[] determineDimensions(int sourceCodeWords, int errorCorrectionCodeWords) throws WriterException { - float ratio = 0.0f; - int[] dimension = null; - - for (int cols = minCols; cols <= maxCols; cols++) { - - int rows = calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, cols); - - if (rows < minRows) { - break; - } - - if (rows > maxRows) { - continue; - } - - float newRatio = ((float) (17 * cols + 69) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT); - - // ignore if previous ratio is closer to preferred ratio - if (dimension != null && Math.abs(newRatio - PREFERRED_RATIO) > Math.abs(ratio - PREFERRED_RATIO)) { - continue; - } - - ratio = newRatio; - dimension = new int[] {cols, rows}; - } - - // Handle case when min values were larger than necessary - if (dimension == null) { - int rows = calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, minCols); - if (rows < minRows) { - dimension = new int[]{minCols, minRows}; - } - } - - if (dimension == null) { - throw new WriterException("Unable to fit message in columns"); - } - - return dimension; - } - - /** - * Sets max/min row/col values - * - * @param maxCols maximum allowed columns - * @param minCols minimum allowed columns - * @param maxRows maximum allowed rows - * @param minRows minimum allowed rows - */ - public void setDimensions(int maxCols, int minCols, int maxRows, int minRows) { - this.maxCols = maxCols; - this.minCols = minCols; - this.maxRows = maxRows; - this.minRows = minRows; - } - - /** - * @param compaction compaction mode to use - */ - public void setCompaction(Compaction compaction) { - this.compaction = compaction; - } - - /** - * @param compact if true, enables compaction - */ - public void setCompact(boolean compact) { - this.compact = compact; - } - - /** - * @param encoding sets character encoding to use - */ - public void setEncoding(Charset encoding) { - this.encoding = encoding; - } - -} - diff --git a/port_src/core/DONE/pdf417/encoder/PDF417ErrorCorrection.java b/port_src/core/DONE/pdf417/encoder/PDF417ErrorCorrection.java deleted file mode 100644 index 6528172..0000000 --- a/port_src/core/DONE/pdf417/encoder/PDF417ErrorCorrection.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * This file has been modified from its original form in Barcode4J. - */ - -package com.google.zxing.pdf417.encoder; - -import com.google.zxing.WriterException; - -/** - * PDF417 error correction code following the algorithm described in ISO/IEC 15438:2001(E) in - * chapter 4.10. - */ -final class PDF417ErrorCorrection { - - /** - * Tables of coefficients for calculating error correction words - * (see annex F, ISO/IEC 15438:2001(E)) - */ - private static final int[][] EC_COEFFICIENTS = { - {27, 917}, - {522, 568, 723, 809}, - {237, 308, 436, 284, 646, 653, 428, 379}, - {274, 562, 232, 755, 599, 524, 801, 132, 295, 116, 442, 428, 295, - 42, 176, 65}, - {361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677, 742, 687, - 284, 193, 517, 273, 494, 263, 147, 593, 800, 571, 320, 803, - 133, 231, 390, 685, 330, 63, 410}, - {539, 422, 6, 93, 862, 771, 453, 106, 610, 287, 107, 505, 733, - 877, 381, 612, 723, 476, 462, 172, 430, 609, 858, 822, 543, - 376, 511, 400, 672, 762, 283, 184, 440, 35, 519, 31, 460, - 594, 225, 535, 517, 352, 605, 158, 651, 201, 488, 502, 648, - 733, 717, 83, 404, 97, 280, 771, 840, 629, 4, 381, 843, - 623, 264, 543}, - {521, 310, 864, 547, 858, 580, 296, 379, 53, 779, 897, 444, 400, - 925, 749, 415, 822, 93, 217, 208, 928, 244, 583, 620, 246, - 148, 447, 631, 292, 908, 490, 704, 516, 258, 457, 907, 594, - 723, 674, 292, 272, 96, 684, 432, 686, 606, 860, 569, 193, - 219, 129, 186, 236, 287, 192, 775, 278, 173, 40, 379, 712, - 463, 646, 776, 171, 491, 297, 763, 156, 732, 95, 270, 447, - 90, 507, 48, 228, 821, 808, 898, 784, 663, 627, 378, 382, - 262, 380, 602, 754, 336, 89, 614, 87, 432, 670, 616, 157, - 374, 242, 726, 600, 269, 375, 898, 845, 454, 354, 130, 814, - 587, 804, 34, 211, 330, 539, 297, 827, 865, 37, 517, 834, - 315, 550, 86, 801, 4, 108, 539}, - {524, 894, 75, 766, 882, 857, 74, 204, 82, 586, 708, 250, 905, - 786, 138, 720, 858, 194, 311, 913, 275, 190, 375, 850, 438, - 733, 194, 280, 201, 280, 828, 757, 710, 814, 919, 89, 68, - 569, 11, 204, 796, 605, 540, 913, 801, 700, 799, 137, 439, - 418, 592, 668, 353, 859, 370, 694, 325, 240, 216, 257, 284, - 549, 209, 884, 315, 70, 329, 793, 490, 274, 877, 162, 749, - 812, 684, 461, 334, 376, 849, 521, 307, 291, 803, 712, 19, - 358, 399, 908, 103, 511, 51, 8, 517, 225, 289, 470, 637, - 731, 66, 255, 917, 269, 463, 830, 730, 433, 848, 585, 136, - 538, 906, 90, 2, 290, 743, 199, 655, 903, 329, 49, 802, - 580, 355, 588, 188, 462, 10, 134, 628, 320, 479, 130, 739, - 71, 263, 318, 374, 601, 192, 605, 142, 673, 687, 234, 722, - 384, 177, 752, 607, 640, 455, 193, 689, 707, 805, 641, 48, - 60, 732, 621, 895, 544, 261, 852, 655, 309, 697, 755, 756, - 60, 231, 773, 434, 421, 726, 528, 503, 118, 49, 795, 32, - 144, 500, 238, 836, 394, 280, 566, 319, 9, 647, 550, 73, - 914, 342, 126, 32, 681, 331, 792, 620, 60, 609, 441, 180, - 791, 893, 754, 605, 383, 228, 749, 760, 213, 54, 297, 134, - 54, 834, 299, 922, 191, 910, 532, 609, 829, 189, 20, 167, - 29, 872, 449, 83, 402, 41, 656, 505, 579, 481, 173, 404, - 251, 688, 95, 497, 555, 642, 543, 307, 159, 924, 558, 648, - 55, 497, 10}, - {352, 77, 373, 504, 35, 599, 428, 207, 409, 574, 118, 498, 285, - 380, 350, 492, 197, 265, 920, 155, 914, 299, 229, 643, 294, - 871, 306, 88, 87, 193, 352, 781, 846, 75, 327, 520, 435, - 543, 203, 666, 249, 346, 781, 621, 640, 268, 794, 534, 539, - 781, 408, 390, 644, 102, 476, 499, 290, 632, 545, 37, 858, - 916, 552, 41, 542, 289, 122, 272, 383, 800, 485, 98, 752, - 472, 761, 107, 784, 860, 658, 741, 290, 204, 681, 407, 855, - 85, 99, 62, 482, 180, 20, 297, 451, 593, 913, 142, 808, - 684, 287, 536, 561, 76, 653, 899, 729, 567, 744, 390, 513, - 192, 516, 258, 240, 518, 794, 395, 768, 848, 51, 610, 384, - 168, 190, 826, 328, 596, 786, 303, 570, 381, 415, 641, 156, - 237, 151, 429, 531, 207, 676, 710, 89, 168, 304, 402, 40, - 708, 575, 162, 864, 229, 65, 861, 841, 512, 164, 477, 221, - 92, 358, 785, 288, 357, 850, 836, 827, 736, 707, 94, 8, - 494, 114, 521, 2, 499, 851, 543, 152, 729, 771, 95, 248, - 361, 578, 323, 856, 797, 289, 51, 684, 466, 533, 820, 669, - 45, 902, 452, 167, 342, 244, 173, 35, 463, 651, 51, 699, - 591, 452, 578, 37, 124, 298, 332, 552, 43, 427, 119, 662, - 777, 475, 850, 764, 364, 578, 911, 283, 711, 472, 420, 245, - 288, 594, 394, 511, 327, 589, 777, 699, 688, 43, 408, 842, - 383, 721, 521, 560, 644, 714, 559, 62, 145, 873, 663, 713, - 159, 672, 729, 624, 59, 193, 417, 158, 209, 563, 564, 343, - 693, 109, 608, 563, 365, 181, 772, 677, 310, 248, 353, 708, - 410, 579, 870, 617, 841, 632, 860, 289, 536, 35, 777, 618, - 586, 424, 833, 77, 597, 346, 269, 757, 632, 695, 751, 331, - 247, 184, 45, 787, 680, 18, 66, 407, 369, 54, 492, 228, - 613, 830, 922, 437, 519, 644, 905, 789, 420, 305, 441, 207, - 300, 892, 827, 141, 537, 381, 662, 513, 56, 252, 341, 242, - 797, 838, 837, 720, 224, 307, 631, 61, 87, 560, 310, 756, - 665, 397, 808, 851, 309, 473, 795, 378, 31, 647, 915, 459, - 806, 590, 731, 425, 216, 548, 249, 321, 881, 699, 535, 673, - 782, 210, 815, 905, 303, 843, 922, 281, 73, 469, 791, 660, - 162, 498, 308, 155, 422, 907, 817, 187, 62, 16, 425, 535, - 336, 286, 437, 375, 273, 610, 296, 183, 923, 116, 667, 751, - 353, 62, 366, 691, 379, 687, 842, 37, 357, 720, 742, 330, - 5, 39, 923, 311, 424, 242, 749, 321, 54, 669, 316, 342, - 299, 534, 105, 667, 488, 640, 672, 576, 540, 316, 486, 721, - 610, 46, 656, 447, 171, 616, 464, 190, 531, 297, 321, 762, - 752, 533, 175, 134, 14, 381, 433, 717, 45, 111, 20, 596, - 284, 736, 138, 646, 411, 877, 669, 141, 919, 45, 780, 407, - 164, 332, 899, 165, 726, 600, 325, 498, 655, 357, 752, 768, - 223, 849, 647, 63, 310, 863, 251, 366, 304, 282, 738, 675, - 410, 389, 244, 31, 121, 303, 263}}; - - private PDF417ErrorCorrection() { - } - - /** - * Determines the number of error correction codewords for a specified error correction - * level. - * - * @param errorCorrectionLevel the error correction level (0-8) - * @return the number of codewords generated for error correction - */ - static int getErrorCorrectionCodewordCount(int errorCorrectionLevel) { - if (errorCorrectionLevel < 0 || errorCorrectionLevel > 8) { - throw new IllegalArgumentException("Error correction level must be between 0 and 8!"); - } - return 1 << (errorCorrectionLevel + 1); - } - - /** - * Returns the recommended minimum error correction level as described in annex E of - * ISO/IEC 15438:2001(E). - * - * @param n the number of data codewords - * @return the recommended minimum error correction level - */ - static int getRecommendedMinimumErrorCorrectionLevel(int n) throws WriterException { - if (n <= 0) { - throw new IllegalArgumentException("n must be > 0"); - } - if (n <= 40) { - return 2; - } - if (n <= 160) { - return 3; - } - if (n <= 320) { - return 4; - } - if (n <= 863) { - return 5; - } - throw new WriterException("No recommendation possible"); - } - - /** - * Generates the error correction codewords according to 4.10 in ISO/IEC 15438:2001(E). - * - * @param dataCodewords the data codewords - * @param errorCorrectionLevel the error correction level (0-8) - * @return the String representing the error correction codewords - */ - static String generateErrorCorrection(CharSequence dataCodewords, int errorCorrectionLevel) { - int k = getErrorCorrectionCodewordCount(errorCorrectionLevel); - char[] e = new char[k]; - int sld = dataCodewords.length(); - for (int i = 0; i < sld; i++) { - int t1 = (dataCodewords.charAt(i) + e[e.length - 1]) % 929; - int t2; - int t3; - for (int j = k - 1; j >= 1; j--) { - t2 = (t1 * EC_COEFFICIENTS[errorCorrectionLevel][j]) % 929; - t3 = 929 - t2; - e[j] = (char) ((e[j - 1] + t3) % 929); - } - t2 = (t1 * EC_COEFFICIENTS[errorCorrectionLevel][0]) % 929; - t3 = 929 - t2; - e[0] = (char) (t3 % 929); - } - StringBuilder sb = new StringBuilder(k); - for (int j = k - 1; j >= 0; j--) { - if (e[j] != 0) { - e[j] = (char) (929 - e[j]); - } - sb.append(e[j]); - } - return sb.toString(); - } - -} diff --git a/port_src/core/DONE/pdf417/encoder/PDF417HighLevelEncoder.java b/port_src/core/DONE/pdf417/encoder/PDF417HighLevelEncoder.java deleted file mode 100644 index 282cc73..0000000 --- a/port_src/core/DONE/pdf417/encoder/PDF417HighLevelEncoder.java +++ /dev/null @@ -1,712 +0,0 @@ -/* - * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * This file has been modified from its original form in Barcode4J. - */ - -package com.google.zxing.pdf417.encoder; - -import com.google.zxing.WriterException; -import com.google.zxing.common.CharacterSetECI; -import com.google.zxing.common.ECIInput; -import com.google.zxing.common.MinimalECIInput; - -import java.math.BigInteger; -import java.nio.charset.Charset; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; - -/** - * PDF417 high-level encoder following the algorithm described in ISO/IEC 15438:2001(E) in - * annex P. - */ -final class PDF417HighLevelEncoder { - - /** - * code for Text compaction - */ - private static final int TEXT_COMPACTION = 0; - - /** - * code for Byte compaction - */ - private static final int BYTE_COMPACTION = 1; - - /** - * code for Numeric compaction - */ - private static final int NUMERIC_COMPACTION = 2; - - /** - * Text compaction submode Alpha - */ - private static final int SUBMODE_ALPHA = 0; - - /** - * Text compaction submode Lower - */ - private static final int SUBMODE_LOWER = 1; - - /** - * Text compaction submode Mixed - */ - private static final int SUBMODE_MIXED = 2; - - /** - * Text compaction submode Punctuation - */ - private static final int SUBMODE_PUNCTUATION = 3; - - /** - * mode latch to Text Compaction mode - */ - private static final int LATCH_TO_TEXT = 900; - - /** - * mode latch to Byte Compaction mode (number of characters NOT a multiple of 6) - */ - private static final int LATCH_TO_BYTE_PADDED = 901; - - /** - * mode latch to Numeric Compaction mode - */ - private static final int LATCH_TO_NUMERIC = 902; - - /** - * mode shift to Byte Compaction mode - */ - private static final int SHIFT_TO_BYTE = 913; - - /** - * mode latch to Byte Compaction mode (number of characters a multiple of 6) - */ - private static final int LATCH_TO_BYTE = 924; - - /** - * identifier for a user defined Extended Channel Interpretation (ECI) - */ - private static final int ECI_USER_DEFINED = 925; - - /** - * identifier for a general purpose ECO format - */ - private static final int ECI_GENERAL_PURPOSE = 926; - - /** - * identifier for an ECI of a character set of code page - */ - private static final int ECI_CHARSET = 927; - - /** - * Raw code table for text compaction Mixed sub-mode - */ - private static final byte[] TEXT_MIXED_RAW = { - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 38, 13, 9, 44, 58, - 35, 45, 46, 36, 47, 43, 37, 42, 61, 94, 0, 32, 0, 0, 0}; - - /** - * Raw code table for text compaction: Punctuation sub-mode - */ - private static final byte[] TEXT_PUNCTUATION_RAW = { - 59, 60, 62, 64, 91, 92, 93, 95, 96, 126, 33, 13, 9, 44, 58, - 10, 45, 46, 36, 47, 34, 124, 42, 40, 41, 63, 123, 125, 39, 0}; - - private static final byte[] MIXED = new byte[128]; - private static final byte[] PUNCTUATION = new byte[128]; - - private static final Charset DEFAULT_ENCODING = StandardCharsets.ISO_8859_1; - - private PDF417HighLevelEncoder() { - } - - static { - //Construct inverse lookups - Arrays.fill(MIXED, (byte) -1); - for (int i = 0; i < TEXT_MIXED_RAW.length; i++) { - byte b = TEXT_MIXED_RAW[i]; - if (b > 0) { - MIXED[b] = (byte) i; - } - } - Arrays.fill(PUNCTUATION, (byte) -1); - for (int i = 0; i < TEXT_PUNCTUATION_RAW.length; i++) { - byte b = TEXT_PUNCTUATION_RAW[i]; - if (b > 0) { - PUNCTUATION[b] = (byte) i; - } - } - } - - /** - * Performs high-level encoding of a PDF417 message using the algorithm described in annex P - * of ISO/IEC 15438:2001(E). If byte compaction has been selected, then only byte compaction - * is used. - * - * @param msg the message - * @param compaction compaction mode to use - * @param encoding character encoding used to encode in default or byte compaction - * or {@code null} for default / not applicable - * @param autoECI encode input minimally using multiple ECIs if needed - * If autoECI encoding is specified and additionally {@code encoding} is specified, then the encoder - * will use the specified {@link Charset} for any character that can be encoded by it, regardless - * if a different encoding would lead to a more compact encoding. When no {@code encoding} is specified - * then charsets will be chosen so that the byte representation is minimal. - * @return the encoded message (the char values range from 0 to 928) - */ - static String encodeHighLevel(String msg, Compaction compaction, Charset encoding, boolean autoECI) - throws WriterException { - - if (msg.isEmpty()) { - throw new WriterException("Empty message not allowed"); - } - - if (encoding == null && !autoECI) { - for (int i = 0; i < msg.length(); i++) { - if (msg.charAt(i) > 255) { - throw new WriterException("Non-encodable character detected: " + msg.charAt(i) + " (Unicode: " + - (int) msg.charAt(i) + - "). Consider specifying EncodeHintType.PDF417_AUTO_ECI and/or EncodeTypeHint.CHARACTER_SET."); - } - } - } - //the codewords 0..928 are encoded as Unicode characters - StringBuilder sb = new StringBuilder(msg.length()); - - ECIInput input; - if (autoECI) { - input = new MinimalECIInput(msg, encoding, -1); - } else { - input = new NoECIInput(msg); - if (encoding == null) { - encoding = DEFAULT_ENCODING; - } else if (!DEFAULT_ENCODING.equals(encoding)) { - CharacterSetECI eci = CharacterSetECI.getCharacterSetECI(encoding); - if (eci != null) { - encodingECI(eci.getValue(), sb); - } - } - } - - int len = input.length(); - int p = 0; - int textSubMode = SUBMODE_ALPHA; - - // User selected encoding mode - switch (compaction) { - case TEXT: - encodeText(input, p, len, sb, textSubMode); - break; - case BYTE: - if (autoECI) { - encodeMultiECIBinary(input, 0, input.length(), TEXT_COMPACTION, sb); - } else { - byte[] msgBytes = input.toString().getBytes(encoding); - encodeBinary(msgBytes, p, msgBytes.length, BYTE_COMPACTION, sb); - } - break; - case NUMERIC: - sb.append((char) LATCH_TO_NUMERIC); - encodeNumeric(input, p, len, sb); - break; - default: - int encodingMode = TEXT_COMPACTION; //Default mode, see 4.4.2.1 - while (p < len) { - while (p < len && input.isECI(p)) { - encodingECI(input.getECIValue(p), sb); - p++; - } - if (p >= len) { - break; - } - int n = determineConsecutiveDigitCount(input, p); - if (n >= 13) { - sb.append((char) LATCH_TO_NUMERIC); - encodingMode = NUMERIC_COMPACTION; - textSubMode = SUBMODE_ALPHA; //Reset after latch - encodeNumeric(input, p, n, sb); - p += n; - } else { - int t = determineConsecutiveTextCount(input, p); - if (t >= 5 || n == len) { - if (encodingMode != TEXT_COMPACTION) { - sb.append((char) LATCH_TO_TEXT); - encodingMode = TEXT_COMPACTION; - textSubMode = SUBMODE_ALPHA; //start with submode alpha after latch - } - textSubMode = encodeText(input, p, t, sb, textSubMode); - p += t; - } else { - int b = determineConsecutiveBinaryCount(input, p, autoECI ? null : encoding); - if (b == 0) { - b = 1; - } - byte[] bytes = autoECI ? null : input.subSequence(p, p + b).toString().getBytes(encoding); - if (((bytes == null && b == 1) || (bytes != null && bytes.length == 1)) - && encodingMode == TEXT_COMPACTION) { - //Switch for one byte (instead of latch) - if (autoECI) { - encodeMultiECIBinary(input, p, 1, TEXT_COMPACTION, sb); - } else { - encodeBinary(bytes, 0, 1, TEXT_COMPACTION, sb); - } - } else { - //Mode latch performed by encodeBinary() - if (autoECI) { - encodeMultiECIBinary(input, p, p + b, encodingMode, sb); - } else { - encodeBinary(bytes, 0, bytes.length, encodingMode, sb); - } - encodingMode = BYTE_COMPACTION; - textSubMode = SUBMODE_ALPHA; //Reset after latch - } - p += b; - } - } - } - break; - } - - return sb.toString(); - } - - /** - * Encode parts of the message using Text Compaction as described in ISO/IEC 15438:2001(E), - * chapter 4.4.2. - * - * @param input the input - * @param startpos the start position within the message - * @param count the number of characters to encode - * @param sb receives the encoded codewords - * @param initialSubmode should normally be SUBMODE_ALPHA - * @return the text submode in which this method ends - */ - private static int encodeText(ECIInput input, - int startpos, - int count, - StringBuilder sb, - int initialSubmode) throws WriterException { - StringBuilder tmp = new StringBuilder(count); - int submode = initialSubmode; - int idx = 0; - while (true) { - if (input.isECI(startpos + idx)) { - encodingECI(input.getECIValue(startpos + idx), sb); - idx++; - } else { - char ch = input.charAt(startpos + idx); - switch (submode) { - case SUBMODE_ALPHA: - if (isAlphaUpper(ch)) { - if (ch == ' ') { - tmp.append((char) 26); //space - } else { - tmp.append((char) (ch - 65)); - } - } else { - if (isAlphaLower(ch)) { - submode = SUBMODE_LOWER; - tmp.append((char) 27); //ll - continue; - } else if (isMixed(ch)) { - submode = SUBMODE_MIXED; - tmp.append((char) 28); //ml - continue; - } else { - tmp.append((char) 29); //ps - tmp.append((char) PUNCTUATION[ch]); - break; - } - } - break; - case SUBMODE_LOWER: - if (isAlphaLower(ch)) { - if (ch == ' ') { - tmp.append((char) 26); //space - } else { - tmp.append((char) (ch - 97)); - } - } else { - if (isAlphaUpper(ch)) { - tmp.append((char) 27); //as - tmp.append((char) (ch - 65)); - //space cannot happen here, it is also in "Lower" - break; - } else if (isMixed(ch)) { - submode = SUBMODE_MIXED; - tmp.append((char) 28); //ml - continue; - } else { - tmp.append((char) 29); //ps - tmp.append((char) PUNCTUATION[ch]); - break; - } - } - break; - case SUBMODE_MIXED: - if (isMixed(ch)) { - tmp.append((char) MIXED[ch]); - } else { - if (isAlphaUpper(ch)) { - submode = SUBMODE_ALPHA; - tmp.append((char) 28); //al - continue; - } else if (isAlphaLower(ch)) { - submode = SUBMODE_LOWER; - tmp.append((char) 27); //ll - continue; - } else { - if (startpos + idx + 1 < count) { - if (!input.isECI(startpos + idx + 1) && isPunctuation(input.charAt(startpos + idx + 1))) { - submode = SUBMODE_PUNCTUATION; - tmp.append((char) 25); //pl - continue; - } - } - tmp.append((char) 29); //ps - tmp.append((char) PUNCTUATION[ch]); - } - } - break; - default: //SUBMODE_PUNCTUATION - if (isPunctuation(ch)) { - tmp.append((char) PUNCTUATION[ch]); - } else { - submode = SUBMODE_ALPHA; - tmp.append((char) 29); //al - continue; - } - } - idx++; - if (idx >= count) { - break; - } - } - } - char h = 0; - int len = tmp.length(); - for (int i = 0; i < len; i++) { - boolean odd = (i % 2) != 0; - if (odd) { - h = (char) ((h * 30) + tmp.charAt(i)); - sb.append(h); - } else { - h = tmp.charAt(i); - } - } - if ((len % 2) != 0) { - sb.append((char) ((h * 30) + 29)); //ps - } - return submode; - } - - /** - * Encode all of the message using Byte Compaction as described in ISO/IEC 15438:2001(E) - * - * @param input the input - * @param startpos the start position within the message - * @param count the number of bytes to encode - * @param startmode the mode from which this method starts - * @param sb receives the encoded codewords - */ - private static void encodeMultiECIBinary(ECIInput input, - int startpos, - int count, - int startmode, - StringBuilder sb) throws WriterException { - final int end = Math.min(startpos + count, input.length()); - int localStart = startpos; - while (true) { - //encode all leading ECIs and advance localStart - while (localStart < end && input.isECI(localStart)) { - encodingECI(input.getECIValue(localStart), sb); - localStart++; - } - int localEnd = localStart; - //advance end until before the next ECI - while (localEnd < end && !input.isECI(localEnd)) { - localEnd++; - } - - final int localCount = localEnd - localStart; - if (localCount <= 0) { - //done - break; - } else { - //encode the segment - encodeBinary(subBytes(input, localStart, localEnd), - 0, localCount, localStart == startpos ? startmode : BYTE_COMPACTION, sb); - localStart = localEnd; - } - } - } - - static byte[] subBytes(ECIInput input, int start, int end) { - final int count = end - start; - byte[] result = new byte[count]; - for (int i = start; i < end; i++) { - result[i - start] = (byte) (input.charAt(i) & 0xff); - } - return result; - } - - /** - * Encode parts of the message using Byte Compaction as described in ISO/IEC 15438:2001(E), - * chapter 4.4.3. The Unicode characters will be converted to binary using the cp437 - * codepage. - * - * @param bytes the message converted to a byte array - * @param startpos the start position within the message - * @param count the number of bytes to encode - * @param startmode the mode from which this method starts - * @param sb receives the encoded codewords - */ - private static void encodeBinary(byte[] bytes, - int startpos, - int count, - int startmode, - StringBuilder sb) { - if (count == 1 && startmode == TEXT_COMPACTION) { - sb.append((char) SHIFT_TO_BYTE); - } else { - if ((count % 6) == 0) { - sb.append((char) LATCH_TO_BYTE); - } else { - sb.append((char) LATCH_TO_BYTE_PADDED); - } - } - - int idx = startpos; - // Encode sixpacks - if (count >= 6) { - char[] chars = new char[5]; - while ((startpos + count - idx) >= 6) { - long t = 0; - for (int i = 0; i < 6; i++) { - t <<= 8; - t += bytes[idx + i] & 0xff; - } - for (int i = 0; i < 5; i++) { - chars[i] = (char) (t % 900); - t /= 900; - } - for (int i = chars.length - 1; i >= 0; i--) { - sb.append(chars[i]); - } - idx += 6; - } - } - //Encode rest (remaining n<5 bytes if any) - for (int i = idx; i < startpos + count; i++) { - int ch = bytes[i] & 0xff; - sb.append((char) ch); - } - } - - private static void encodeNumeric(ECIInput input, int startpos, int count, StringBuilder sb) { - int idx = 0; - StringBuilder tmp = new StringBuilder(count / 3 + 1); - BigInteger num900 = BigInteger.valueOf(900); - BigInteger num0 = BigInteger.valueOf(0); - while (idx < count) { - tmp.setLength(0); - int len = Math.min(44, count - idx); - String part = "1" + input.subSequence(startpos + idx, startpos + idx + len); - BigInteger bigint = new BigInteger(part); - do { - tmp.append((char) bigint.mod(num900).intValue()); - bigint = bigint.divide(num900); - } while (!bigint.equals(num0)); - - //Reverse temporary string - for (int i = tmp.length() - 1; i >= 0; i--) { - sb.append(tmp.charAt(i)); - } - idx += len; - } - } - - - private static boolean isDigit(char ch) { - return ch >= '0' && ch <= '9'; - } - - private static boolean isAlphaUpper(char ch) { - return ch == ' ' || (ch >= 'A' && ch <= 'Z'); - } - - private static boolean isAlphaLower(char ch) { - return ch == ' ' || (ch >= 'a' && ch <= 'z'); - } - - private static boolean isMixed(char ch) { - return MIXED[ch] != -1; - } - - private static boolean isPunctuation(char ch) { - return PUNCTUATION[ch] != -1; - } - - private static boolean isText(char ch) { - return ch == '\t' || ch == '\n' || ch == '\r' || (ch >= 32 && ch <= 126); - } - - /** - * Determines the number of consecutive characters that are encodable using numeric compaction. - * - * @param input the input - * @param startpos the start position within the input - * @return the requested character count - */ - private static int determineConsecutiveDigitCount(ECIInput input, int startpos) { - int count = 0; - final int len = input.length(); - int idx = startpos; - if (idx < len) { - while (idx < len && !input.isECI(idx) && isDigit(input.charAt(idx))) { - count++; - idx++; - } - } - return count; - } - - /** - * Determines the number of consecutive characters that are encodable using text compaction. - * - * @param input the input - * @param startpos the start position within the input - * @return the requested character count - */ - private static int determineConsecutiveTextCount(ECIInput input, int startpos) { - final int len = input.length(); - int idx = startpos; - while (idx < len) { - int numericCount = 0; - while (numericCount < 13 && idx < len && !input.isECI(idx) && isDigit(input.charAt(idx))) { - numericCount++; - idx++; - } - if (numericCount >= 13) { - return idx - startpos - numericCount; - } - if (numericCount > 0) { - //Heuristic: All text-encodable chars or digits are binary encodable - continue; - } - - //Check if character is encodable - if (input.isECI(idx) || !isText(input.charAt(idx))) { - break; - } - idx++; - } - return idx - startpos; - } - - /** - * Determines the number of consecutive characters that are encodable using binary compaction. - * - * @param input the input - * @param startpos the start position within the message - * @param encoding the charset used to convert the message to a byte array - * @return the requested character count - */ - private static int determineConsecutiveBinaryCount(ECIInput input, int startpos, Charset encoding) - throws WriterException { - CharsetEncoder encoder = encoding == null ? null : encoding.newEncoder(); - int len = input.length(); - int idx = startpos; - while (idx < len) { - int numericCount = 0; - - int i = idx; - while (numericCount < 13 && !input.isECI(i) && isDigit(input.charAt(i))) { - numericCount++; - //textCount++; - i = idx + numericCount; - if (i >= len) { - break; - } - } - if (numericCount >= 13) { - return idx - startpos; - } - - if (encoder != null && !encoder.canEncode(input.charAt(idx))) { - assert input instanceof NoECIInput; - char ch = input.charAt(idx); - throw new WriterException("Non-encodable character detected: " + ch + " (Unicode: " + (int) ch + ')'); - } - idx++; - } - return idx - startpos; - } - - private static void encodingECI(int eci, StringBuilder sb) throws WriterException { - if (eci >= 0 && eci < 900) { - sb.append((char) ECI_CHARSET); - sb.append((char) eci); - } else if (eci < 810900) { - sb.append((char) ECI_GENERAL_PURPOSE); - sb.append((char) (eci / 900 - 1)); - sb.append((char) (eci % 900)); - } else if (eci < 811800) { - sb.append((char) ECI_USER_DEFINED); - sb.append((char) (810900 - eci)); - } else { - throw new WriterException("ECI number not in valid range from 0..811799, but was " + eci); - } - } - - private static final class NoECIInput implements ECIInput { - - String input; - - private NoECIInput(String input) { - this.input = input; - } - - public int length() { - return input.length(); - } - - public char charAt(int index) { - return input.charAt(index); - } - - public boolean isECI(int index) { - return false; - } - - public int getECIValue(int index) { - return -1; - } - - public boolean haveNCharacters(int index, int n) { - return index + n <= input.length(); - } - - public CharSequence subSequence(int start, int end) { - return input.subSequence(start, end); - } - - public String toString() { - return input; - } - } -} diff --git a/port_src/core/DONE/pdf417/encoder/PDF417HighLevelEncoderTestAdapter.java b/port_src/core/DONE/pdf417/encoder/PDF417HighLevelEncoderTestAdapter.java deleted file mode 100644 index 6ba7992..0000000 --- a/port_src/core/DONE/pdf417/encoder/PDF417HighLevelEncoderTestAdapter.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2022 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.encoder; - -import com.google.zxing.WriterException; - -import java.nio.charset.Charset; - -/** - * Test adapter for PDF417HighLevelEncoder to be called solely from unit tests. - */ - -public final class PDF417HighLevelEncoderTestAdapter { - - private PDF417HighLevelEncoderTestAdapter() { - } - - public static String encodeHighLevel(String msg, - Compaction compaction, - Charset encoding, - boolean autoECI) throws WriterException { - return PDF417HighLevelEncoder.encodeHighLevel(msg, compaction, encoding, autoECI); - } -} diff --git a/port_src/core/DONE/qrcode/QRCodeReader.java b/port_src/core/DONE/qrcode/QRCodeReader.java deleted file mode 100644 index f6a765f..0000000 --- a/port_src/core/DONE/qrcode/QRCodeReader.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Reader; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.DetectorResult; -import com.google.zxing.qrcode.decoder.Decoder; -import com.google.zxing.qrcode.decoder.QRCodeDecoderMetaData; -import com.google.zxing.qrcode.detector.Detector; - -import java.util.List; -import java.util.Map; - -/** - * This implementation can detect and decode QR Codes in an image. - * - * @author Sean Owen - */ -public class QRCodeReader implements Reader { - - private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; - - private final Decoder decoder = new Decoder(); - - protected final Decoder getDecoder() { - return decoder; - } - - /** - * Locates and decodes a QR code in an image. - * - * @return a String representing the content encoded by the QR code - * @throws NotFoundException if a QR code cannot be found - * @throws FormatException if a QR code cannot be decoded - * @throws ChecksumException if error correction fails - */ - @Override - public Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException { - return decode(image, null); - } - - @Override - public final Result decode(BinaryBitmap image, Map hints) - throws NotFoundException, ChecksumException, FormatException { - DecoderResult decoderResult; - ResultPoint[] points; - if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { - BitMatrix bits = extractPureBits(image.getBlackMatrix()); - decoderResult = decoder.decode(bits, hints); - points = NO_POINTS; - } else { - DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(hints); - decoderResult = decoder.decode(detectorResult.getBits(), hints); - points = detectorResult.getPoints(); - } - - // If the code was mirrored: swap the bottom-left and the top-right points. - if (decoderResult.getOther() instanceof QRCodeDecoderMetaData) { - ((QRCodeDecoderMetaData) decoderResult.getOther()).applyMirroredCorrection(points); - } - - Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.QR_CODE); - List byteSegments = decoderResult.getByteSegments(); - if (byteSegments != null) { - result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); - } - String ecLevel = decoderResult.getECLevel(); - if (ecLevel != null) { - result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); - } - if (decoderResult.hasStructuredAppend()) { - result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, - decoderResult.getStructuredAppendSequenceNumber()); - result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_PARITY, - decoderResult.getStructuredAppendParity()); - } - result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]Q" + decoderResult.getSymbologyModifier()); - return result; - } - - @Override - public void reset() { - // do nothing - } - - /** - * This method detects a code in a "pure" image -- that is, pure monochrome image - * which contains only an unrotated, unskewed, image of a code, with some white border - * around it. This is a specialized method that works exceptionally fast in this special - * case. - */ - private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException { - - int[] leftTopBlack = image.getTopLeftOnBit(); - int[] rightBottomBlack = image.getBottomRightOnBit(); - if (leftTopBlack == null || rightBottomBlack == null) { - throw NotFoundException.getNotFoundInstance(); - } - - float moduleSize = moduleSize(leftTopBlack, image); - - int top = leftTopBlack[1]; - int bottom = rightBottomBlack[1]; - int left = leftTopBlack[0]; - int right = rightBottomBlack[0]; - - // Sanity check! - if (left >= right || top >= bottom) { - throw NotFoundException.getNotFoundInstance(); - } - - if (bottom - top != right - left) { - // Special case, where bottom-right module wasn't black so we found something else in the last row - // Assume it's a square, so use height as the width - right = left + (bottom - top); - if (right >= image.getWidth()) { - // Abort if that would not make sense -- off image - throw NotFoundException.getNotFoundInstance(); - } - } - - int matrixWidth = Math.round((right - left + 1) / moduleSize); - int matrixHeight = Math.round((bottom - top + 1) / moduleSize); - if (matrixWidth <= 0 || matrixHeight <= 0) { - throw NotFoundException.getNotFoundInstance(); - } - if (matrixHeight != matrixWidth) { - // Only possibly decode square regions - throw NotFoundException.getNotFoundInstance(); - } - - // Push in the "border" by half the module width so that we start - // sampling in the middle of the module. Just in case the image is a - // little off, this will help recover. - int nudge = (int) (moduleSize / 2.0f); - top += nudge; - left += nudge; - - // But careful that this does not sample off the edge - // "right" is the farthest-right valid pixel location -- right+1 is not necessarily - // This is positive by how much the inner x loop below would be too large - int nudgedTooFarRight = left + (int) ((matrixWidth - 1) * moduleSize) - right; - if (nudgedTooFarRight > 0) { - if (nudgedTooFarRight > nudge) { - // Neither way fits; abort - throw NotFoundException.getNotFoundInstance(); - } - left -= nudgedTooFarRight; - } - // See logic above - int nudgedTooFarDown = top + (int) ((matrixHeight - 1) * moduleSize) - bottom; - if (nudgedTooFarDown > 0) { - if (nudgedTooFarDown > nudge) { - // Neither way fits; abort - throw NotFoundException.getNotFoundInstance(); - } - top -= nudgedTooFarDown; - } - - // Now just read off the bits - BitMatrix bits = new BitMatrix(matrixWidth, matrixHeight); - for (int y = 0; y < matrixHeight; y++) { - int iOffset = top + (int) (y * moduleSize); - for (int x = 0; x < matrixWidth; x++) { - if (image.get(left + (int) (x * moduleSize), iOffset)) { - bits.set(x, y); - } - } - } - return bits; - } - - private static float moduleSize(int[] leftTopBlack, BitMatrix image) throws NotFoundException { - int height = image.getHeight(); - int width = image.getWidth(); - int x = leftTopBlack[0]; - int y = leftTopBlack[1]; - boolean inBlack = true; - int transitions = 0; - while (x < width && y < height) { - if (inBlack != image.get(x, y)) { - if (++transitions == 5) { - break; - } - inBlack = !inBlack; - } - x++; - y++; - } - if (x == width || y == height) { - throw NotFoundException.getNotFoundInstance(); - } - return (x - leftTopBlack[0]) / 7.0f; - } - -} diff --git a/port_src/core/DONE/qrcode/QRCodeWriter.java b/port_src/core/DONE/qrcode/QRCodeWriter.java deleted file mode 100644 index ce7ee07..0000000 --- a/port_src/core/DONE/qrcode/QRCodeWriter.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.Writer; -import com.google.zxing.WriterException; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.qrcode.encoder.ByteMatrix; -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; -import com.google.zxing.qrcode.encoder.Encoder; -import com.google.zxing.qrcode.encoder.QRCode; - -import java.util.Map; - -/** - * This object renders a QR Code as a BitMatrix 2D array of greyscale values. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class QRCodeWriter implements Writer { - - private static final int QUIET_ZONE_SIZE = 4; - - @Override - public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) - throws WriterException { - - return encode(contents, format, width, height, null); - } - - @Override - public BitMatrix encode(String contents, - BarcodeFormat format, - int width, - int height, - Map hints) throws WriterException { - - if (contents.isEmpty()) { - throw new IllegalArgumentException("Found empty contents"); - } - - if (format != BarcodeFormat.QR_CODE) { - throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format); - } - - if (width < 0 || height < 0) { - throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + - height); - } - - ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L; - int quietZone = QUIET_ZONE_SIZE; - if (hints != null) { - if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) { - errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString()); - } - if (hints.containsKey(EncodeHintType.MARGIN)) { - quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString()); - } - } - - QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints); - return renderResult(code, width, height, quietZone); - } - - // Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses - // 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap). - private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) { - ByteMatrix input = code.getMatrix(); - if (input == null) { - throw new IllegalStateException(); - } - int inputWidth = input.getWidth(); - int inputHeight = input.getHeight(); - int qrWidth = inputWidth + (quietZone * 2); - int qrHeight = inputHeight + (quietZone * 2); - int outputWidth = Math.max(width, qrWidth); - int outputHeight = Math.max(height, qrHeight); - - int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight); - // Padding includes both the quiet zone and the extra white pixels to accommodate the requested - // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone. - // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will - // handle all the padding from 100x100 (the actual QR) up to 200x160. - int leftPadding = (outputWidth - (inputWidth * multiple)) / 2; - int topPadding = (outputHeight - (inputHeight * multiple)) / 2; - - BitMatrix output = new BitMatrix(outputWidth, outputHeight); - - for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) { - // Write the contents of this row of the barcode - for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) { - if (input.get(inputX, inputY) == 1) { - output.setRegion(outputX, outputY, multiple, multiple); - } - } - } - - return output; - } - -} diff --git a/port_src/core/DONE/qrcode/decoder/BitMatrixParser.java b/port_src/core/DONE/qrcode/decoder/BitMatrixParser.java deleted file mode 100644 index 2298695..0000000 --- a/port_src/core/DONE/qrcode/decoder/BitMatrixParser.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; - -/** - * @author Sean Owen - */ -final class BitMatrixParser { - - private final BitMatrix bitMatrix; - private Version parsedVersion; - private FormatInformation parsedFormatInfo; - private boolean mirror; - - /** - * @param bitMatrix {@link BitMatrix} to parse - * @throws FormatException if dimension is not >= 21 and 1 mod 4 - */ - BitMatrixParser(BitMatrix bitMatrix) throws FormatException { - int dimension = bitMatrix.getHeight(); - if (dimension < 21 || (dimension & 0x03) != 1) { - throw FormatException.getFormatInstance(); - } - this.bitMatrix = bitMatrix; - } - - /** - *

Reads format information from one of its two locations within the QR Code.

- * - * @return {@link FormatInformation} encapsulating the QR Code's format info - * @throws FormatException if both format information locations cannot be parsed as - * the valid encoding of format information - */ - FormatInformation readFormatInformation() throws FormatException { - - if (parsedFormatInfo != null) { - return parsedFormatInfo; - } - - // Read top-left format info bits - int formatInfoBits1 = 0; - for (int i = 0; i < 6; i++) { - formatInfoBits1 = copyBit(i, 8, formatInfoBits1); - } - // .. and skip a bit in the timing pattern ... - formatInfoBits1 = copyBit(7, 8, formatInfoBits1); - formatInfoBits1 = copyBit(8, 8, formatInfoBits1); - formatInfoBits1 = copyBit(8, 7, formatInfoBits1); - // .. and skip a bit in the timing pattern ... - for (int j = 5; j >= 0; j--) { - formatInfoBits1 = copyBit(8, j, formatInfoBits1); - } - - // Read the top-right/bottom-left pattern too - int dimension = bitMatrix.getHeight(); - int formatInfoBits2 = 0; - int jMin = dimension - 7; - for (int j = dimension - 1; j >= jMin; j--) { - formatInfoBits2 = copyBit(8, j, formatInfoBits2); - } - for (int i = dimension - 8; i < dimension; i++) { - formatInfoBits2 = copyBit(i, 8, formatInfoBits2); - } - - parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits1, formatInfoBits2); - if (parsedFormatInfo != null) { - return parsedFormatInfo; - } - throw FormatException.getFormatInstance(); - } - - /** - *

Reads version information from one of its two locations within the QR Code.

- * - * @return {@link Version} encapsulating the QR Code's version - * @throws FormatException if both version information locations cannot be parsed as - * the valid encoding of version information - */ - Version readVersion() throws FormatException { - - if (parsedVersion != null) { - return parsedVersion; - } - - int dimension = bitMatrix.getHeight(); - - int provisionalVersion = (dimension - 17) / 4; - if (provisionalVersion <= 6) { - return Version.getVersionForNumber(provisionalVersion); - } - - // Read top-right version info: 3 wide by 6 tall - int versionBits = 0; - int ijMin = dimension - 11; - for (int j = 5; j >= 0; j--) { - for (int i = dimension - 9; i >= ijMin; i--) { - versionBits = copyBit(i, j, versionBits); - } - } - - Version theParsedVersion = Version.decodeVersionInformation(versionBits); - if (theParsedVersion != null && theParsedVersion.getDimensionForVersion() == dimension) { - parsedVersion = theParsedVersion; - return theParsedVersion; - } - - // Hmm, failed. Try bottom left: 6 wide by 3 tall - versionBits = 0; - for (int i = 5; i >= 0; i--) { - for (int j = dimension - 9; j >= ijMin; j--) { - versionBits = copyBit(i, j, versionBits); - } - } - - theParsedVersion = Version.decodeVersionInformation(versionBits); - if (theParsedVersion != null && theParsedVersion.getDimensionForVersion() == dimension) { - parsedVersion = theParsedVersion; - return theParsedVersion; - } - throw FormatException.getFormatInstance(); - } - - private int copyBit(int i, int j, int versionBits) { - boolean bit = mirror ? bitMatrix.get(j, i) : bitMatrix.get(i, j); - return bit ? (versionBits << 1) | 0x1 : versionBits << 1; - } - - /** - *

Reads the bits in the {@link BitMatrix} representing the finder pattern in the - * correct order in order to reconstruct the codewords bytes contained within the - * QR Code.

- * - * @return bytes encoded within the QR Code - * @throws FormatException if the exact number of bytes expected is not read - */ - byte[] readCodewords() throws FormatException { - - FormatInformation formatInfo = readFormatInformation(); - Version version = readVersion(); - - // Get the data mask for the format used in this QR Code. This will exclude - // some bits from reading as we wind through the bit matrix. - DataMask dataMask = DataMask.values()[formatInfo.getDataMask()]; - int dimension = bitMatrix.getHeight(); - dataMask.unmaskBitMatrix(bitMatrix, dimension); - - BitMatrix functionPattern = version.buildFunctionPattern(); - - boolean readingUp = true; - byte[] result = new byte[version.getTotalCodewords()]; - int resultOffset = 0; - int currentByte = 0; - int bitsRead = 0; - // Read columns in pairs, from right to left - for (int j = dimension - 1; j > 0; j -= 2) { - if (j == 6) { - // Skip whole column with vertical alignment pattern; - // saves time and makes the other code proceed more cleanly - j--; - } - // Read alternatingly from bottom to top then top to bottom - for (int count = 0; count < dimension; count++) { - int i = readingUp ? dimension - 1 - count : count; - for (int col = 0; col < 2; col++) { - // Ignore bits covered by the function pattern - if (!functionPattern.get(j - col, i)) { - // Read a bit - bitsRead++; - currentByte <<= 1; - if (bitMatrix.get(j - col, i)) { - currentByte |= 1; - } - // If we've made a whole byte, save it off - if (bitsRead == 8) { - result[resultOffset++] = (byte) currentByte; - bitsRead = 0; - currentByte = 0; - } - } - } - } - readingUp ^= true; // readingUp = !readingUp; // switch directions - } - if (resultOffset != version.getTotalCodewords()) { - throw FormatException.getFormatInstance(); - } - return result; - } - - /** - * Revert the mask removal done while reading the code words. The bit matrix should revert to its original state. - */ - void remask() { - if (parsedFormatInfo == null) { - return; // We have no format information, and have no data mask - } - DataMask dataMask = DataMask.values()[parsedFormatInfo.getDataMask()]; - int dimension = bitMatrix.getHeight(); - dataMask.unmaskBitMatrix(bitMatrix, dimension); - } - - /** - * Prepare the parser for a mirrored operation. - * This flag has effect only on the {@link #readFormatInformation()} and the - * {@link #readVersion()}. Before proceeding with {@link #readCodewords()} the - * {@link #mirror()} method should be called. - * - * @param mirror Whether to read version and format information mirrored. - */ - void setMirror(boolean mirror) { - parsedVersion = null; - parsedFormatInfo = null; - this.mirror = mirror; - } - - /** Mirror the bit matrix in order to attempt a second reading. */ - void mirror() { - for (int x = 0; x < bitMatrix.getWidth(); x++) { - for (int y = x + 1; y < bitMatrix.getHeight(); y++) { - if (bitMatrix.get(x, y) != bitMatrix.get(y, x)) { - bitMatrix.flip(y, x); - bitMatrix.flip(x, y); - } - } - } - } - -} diff --git a/port_src/core/DONE/qrcode/decoder/DataBlock.java b/port_src/core/DONE/qrcode/decoder/DataBlock.java deleted file mode 100755 index 8f5cdcb..0000000 --- a/port_src/core/DONE/qrcode/decoder/DataBlock.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -/** - *

Encapsulates a block of data within a QR Code. QR Codes may split their data into - * multiple blocks, each of which is a unit of data and error-correction codewords. Each - * is represented by an instance of this class.

- * - * @author Sean Owen - */ -final class DataBlock { - - private final int numDataCodewords; - private final byte[] codewords; - - private DataBlock(int numDataCodewords, byte[] codewords) { - this.numDataCodewords = numDataCodewords; - this.codewords = codewords; - } - - /** - *

When QR Codes use multiple data blocks, they are actually interleaved. - * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This - * method will separate the data into original blocks.

- * - * @param rawCodewords bytes as read directly from the QR Code - * @param version version of the QR Code - * @param ecLevel error-correction level of the QR Code - * @return DataBlocks containing original bytes, "de-interleaved" from representation in the - * QR Code - */ - static DataBlock[] getDataBlocks(byte[] rawCodewords, - Version version, - ErrorCorrectionLevel ecLevel) { - - if (rawCodewords.length != version.getTotalCodewords()) { - throw new IllegalArgumentException(); - } - - // Figure out the number and size of data blocks used by this version and - // error correction level - Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel); - - // First count the total number of data blocks - int totalBlocks = 0; - Version.ECB[] ecBlockArray = ecBlocks.getECBlocks(); - for (Version.ECB ecBlock : ecBlockArray) { - totalBlocks += ecBlock.getCount(); - } - - // Now establish DataBlocks of the appropriate size and number of data codewords - DataBlock[] result = new DataBlock[totalBlocks]; - int numResultBlocks = 0; - for (Version.ECB ecBlock : ecBlockArray) { - for (int i = 0; i < ecBlock.getCount(); i++) { - int numDataCodewords = ecBlock.getDataCodewords(); - int numBlockCodewords = ecBlocks.getECCodewordsPerBlock() + numDataCodewords; - result[numResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]); - } - } - - // All blocks have the same amount of data, except that the last n - // (where n may be 0) have 1 more byte. Figure out where these start. - int shorterBlocksTotalCodewords = result[0].codewords.length; - int longerBlocksStartAt = result.length - 1; - while (longerBlocksStartAt >= 0) { - int numCodewords = result[longerBlocksStartAt].codewords.length; - if (numCodewords == shorterBlocksTotalCodewords) { - break; - } - longerBlocksStartAt--; - } - longerBlocksStartAt++; - - int shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.getECCodewordsPerBlock(); - // The last elements of result may be 1 element longer; - // first fill out as many elements as all of them have - int rawCodewordsOffset = 0; - for (int i = 0; i < shorterBlocksNumDataCodewords; i++) { - for (int j = 0; j < numResultBlocks; j++) { - result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; - } - } - // Fill out the last data block in the longer ones - for (int j = longerBlocksStartAt; j < numResultBlocks; j++) { - result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++]; - } - // Now add in error correction blocks - int max = result[0].codewords.length; - for (int i = shorterBlocksNumDataCodewords; i < max; i++) { - for (int j = 0; j < numResultBlocks; j++) { - int iOffset = j < longerBlocksStartAt ? i : i + 1; - result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; - } - } - return result; - } - - int getNumDataCodewords() { - return numDataCodewords; - } - - byte[] getCodewords() { - return codewords; - } - -} diff --git a/port_src/core/DONE/qrcode/decoder/DataMask.java b/port_src/core/DONE/qrcode/decoder/DataMask.java deleted file mode 100755 index e60868d..0000000 --- a/port_src/core/DONE/qrcode/decoder/DataMask.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -import com.google.zxing.common.BitMatrix; - -/** - *

Encapsulates data masks for the data bits in a QR code, per ISO 18004:2006 6.8. Implementations - * of this class can un-mask a raw BitMatrix. For simplicity, they will unmask the entire BitMatrix, - * including areas used for finder patterns, timing patterns, etc. These areas should be unused - * after the point they are unmasked anyway.

- * - *

Note that the diagram in section 6.8.1 is misleading since it indicates that i is column position - * and j is row position. In fact, as the text says, i is row position and j is column position.

- * - * @author Sean Owen - */ -enum DataMask { - - // See ISO 18004:2006 6.8.1 - - /** - * 000: mask bits for which (x + y) mod 2 == 0 - */ - DATA_MASK_000() { - @Override - boolean isMasked(int i, int j) { - return ((i + j) & 0x01) == 0; - } - }, - - /** - * 001: mask bits for which x mod 2 == 0 - */ - DATA_MASK_001() { - @Override - boolean isMasked(int i, int j) { - return (i & 0x01) == 0; - } - }, - - /** - * 010: mask bits for which y mod 3 == 0 - */ - DATA_MASK_010() { - @Override - boolean isMasked(int i, int j) { - return j % 3 == 0; - } - }, - - /** - * 011: mask bits for which (x + y) mod 3 == 0 - */ - DATA_MASK_011() { - @Override - boolean isMasked(int i, int j) { - return (i + j) % 3 == 0; - } - }, - - /** - * 100: mask bits for which (x/2 + y/3) mod 2 == 0 - */ - DATA_MASK_100() { - @Override - boolean isMasked(int i, int j) { - return (((i / 2) + (j / 3)) & 0x01) == 0; - } - }, - - /** - * 101: mask bits for which xy mod 2 + xy mod 3 == 0 - * equivalently, such that xy mod 6 == 0 - */ - DATA_MASK_101() { - @Override - boolean isMasked(int i, int j) { - return (i * j) % 6 == 0; - } - }, - - /** - * 110: mask bits for which (xy mod 2 + xy mod 3) mod 2 == 0 - * equivalently, such that xy mod 6 < 3 - */ - DATA_MASK_110() { - @Override - boolean isMasked(int i, int j) { - return ((i * j) % 6) < 3; - } - }, - - /** - * 111: mask bits for which ((x+y)mod 2 + xy mod 3) mod 2 == 0 - * equivalently, such that (x + y + xy mod 3) mod 2 == 0 - */ - DATA_MASK_111() { - @Override - boolean isMasked(int i, int j) { - return ((i + j + ((i * j) % 3)) & 0x01) == 0; - } - }; - - // End of enum constants. - - - /** - *

Implementations of this method reverse the data masking process applied to a QR Code and - * make its bits ready to read.

- * - * @param bits representation of QR Code bits - * @param dimension dimension of QR Code, represented by bits, being unmasked - */ - final void unmaskBitMatrix(BitMatrix bits, int dimension) { - for (int i = 0; i < dimension; i++) { - for (int j = 0; j < dimension; j++) { - if (isMasked(i, j)) { - bits.flip(j, i); - } - } - } - } - - abstract boolean isMasked(int i, int j); - -} diff --git a/port_src/core/DONE/qrcode/decoder/DecodedBitStreamParser.java b/port_src/core/DONE/qrcode/decoder/DecodedBitStreamParser.java deleted file mode 100644 index bba9e44..0000000 --- a/port_src/core/DONE/qrcode/decoder/DecodedBitStreamParser.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.common.BitSource; -import com.google.zxing.common.CharacterSetECI; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.StringUtils; - -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - *

QR Codes can encode text as bits in one of several modes, and can use multiple modes - * in one QR Code. This class decodes the bits back into text.

- * - *

See ISO 18004:2006, 6.4.3 - 6.4.7

- * - * @author Sean Owen - */ -final class DecodedBitStreamParser { - - /** - * See ISO 18004:2006, 6.4.4 Table 5 - */ - private static final char[] ALPHANUMERIC_CHARS = - "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".toCharArray(); - private static final int GB2312_SUBSET = 1; - - private DecodedBitStreamParser() { - } - - static DecoderResult decode(byte[] bytes, - Version version, - ErrorCorrectionLevel ecLevel, - Map hints) throws FormatException { - BitSource bits = new BitSource(bytes); - StringBuilder result = new StringBuilder(50); - List byteSegments = new ArrayList<>(1); - int symbolSequence = -1; - int parityData = -1; - int symbologyModifier; - - try { - CharacterSetECI currentCharacterSetECI = null; - boolean fc1InEffect = false; - boolean hasFNC1first = false; - boolean hasFNC1second = false; - Mode mode; - do { - // While still another segment to read... - if (bits.available() < 4) { - // OK, assume we're done. Really, a TERMINATOR mode should have been recorded here - mode = Mode.TERMINATOR; - } else { - mode = Mode.forBits(bits.readBits(4)); // mode is encoded by 4 bits - } - switch (mode) { - case TERMINATOR: - break; - case FNC1_FIRST_POSITION: - hasFNC1first = true; // symbology detection - // We do little with FNC1 except alter the parsed result a bit according to the spec - fc1InEffect = true; - break; - case FNC1_SECOND_POSITION: - hasFNC1second = true; // symbology detection - // We do little with FNC1 except alter the parsed result a bit according to the spec - fc1InEffect = true; - break; - case STRUCTURED_APPEND: - if (bits.available() < 16) { - throw FormatException.getFormatInstance(); - } - // sequence number and parity is added later to the result metadata - // Read next 8 bits (symbol sequence #) and 8 bits (parity data), then continue - symbolSequence = bits.readBits(8); - parityData = bits.readBits(8); - break; - case ECI: - // Count doesn't apply to ECI - int value = parseECIValue(bits); - currentCharacterSetECI = CharacterSetECI.getCharacterSetECIByValue(value); - if (currentCharacterSetECI == null) { - throw FormatException.getFormatInstance(); - } - break; - case HANZI: - // First handle Hanzi mode which does not start with character count - // Chinese mode contains a sub set indicator right after mode indicator - int subset = bits.readBits(4); - int countHanzi = bits.readBits(mode.getCharacterCountBits(version)); - if (subset == GB2312_SUBSET) { - decodeHanziSegment(bits, result, countHanzi); - } - break; - default: - // "Normal" QR code modes: - // How many characters will follow, encoded in this mode? - int count = bits.readBits(mode.getCharacterCountBits(version)); - switch (mode) { - case NUMERIC: - decodeNumericSegment(bits, result, count); - break; - case ALPHANUMERIC: - decodeAlphanumericSegment(bits, result, count, fc1InEffect); - break; - case BYTE: - decodeByteSegment(bits, result, count, currentCharacterSetECI, byteSegments, hints); - break; - case KANJI: - decodeKanjiSegment(bits, result, count); - break; - default: - throw FormatException.getFormatInstance(); - } - break; - } - } while (mode != Mode.TERMINATOR); - - if (currentCharacterSetECI != null) { - if (hasFNC1first) { - symbologyModifier = 4; - } else if (hasFNC1second) { - symbologyModifier = 6; - } else { - symbologyModifier = 2; - } - } else { - if (hasFNC1first) { - symbologyModifier = 3; - } else if (hasFNC1second) { - symbologyModifier = 5; - } else { - symbologyModifier = 1; - } - } - - } catch (IllegalArgumentException iae) { - // from readBits() calls - throw FormatException.getFormatInstance(); - } - - return new DecoderResult(bytes, - result.toString(), - byteSegments.isEmpty() ? null : byteSegments, - ecLevel == null ? null : ecLevel.toString(), - symbolSequence, - parityData, - symbologyModifier); - } - - /** - * See specification GBT 18284-2000 - */ - private static void decodeHanziSegment(BitSource bits, - StringBuilder result, - int count) throws FormatException { - // Don't crash trying to read more bits than we have available. - if (count * 13 > bits.available()) { - throw FormatException.getFormatInstance(); - } - - // Each character will require 2 bytes. Read the characters as 2-byte pairs - // and decode as GB2312 afterwards - byte[] buffer = new byte[2 * count]; - int offset = 0; - while (count > 0) { - // Each 13 bits encodes a 2-byte character - int twoBytes = bits.readBits(13); - int assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060); - if (assembledTwoBytes < 0x00A00) { - // In the 0xA1A1 to 0xAAFE range - assembledTwoBytes += 0x0A1A1; - } else { - // In the 0xB0A1 to 0xFAFE range - assembledTwoBytes += 0x0A6A1; - } - buffer[offset] = (byte) ((assembledTwoBytes >> 8) & 0xFF); - buffer[offset + 1] = (byte) (assembledTwoBytes & 0xFF); - offset += 2; - count--; - } - - result.append(new String(buffer, StringUtils.GB2312_CHARSET)); - } - - private static void decodeKanjiSegment(BitSource bits, - StringBuilder result, - int count) throws FormatException { - // Don't crash trying to read more bits than we have available. - if (count * 13 > bits.available()) { - throw FormatException.getFormatInstance(); - } - - // Each character will require 2 bytes. Read the characters as 2-byte pairs - // and decode as Shift_JIS afterwards - byte[] buffer = new byte[2 * count]; - int offset = 0; - while (count > 0) { - // Each 13 bits encodes a 2-byte character - int twoBytes = bits.readBits(13); - int assembledTwoBytes = ((twoBytes / 0x0C0) << 8) | (twoBytes % 0x0C0); - if (assembledTwoBytes < 0x01F00) { - // In the 0x8140 to 0x9FFC range - assembledTwoBytes += 0x08140; - } else { - // In the 0xE040 to 0xEBBF range - assembledTwoBytes += 0x0C140; - } - buffer[offset] = (byte) (assembledTwoBytes >> 8); - buffer[offset + 1] = (byte) assembledTwoBytes; - offset += 2; - count--; - } - result.append(new String(buffer, StringUtils.SHIFT_JIS_CHARSET)); - } - - private static void decodeByteSegment(BitSource bits, - StringBuilder result, - int count, - CharacterSetECI currentCharacterSetECI, - Collection byteSegments, - Map hints) throws FormatException { - // Don't crash trying to read more bits than we have available. - if (8 * count > bits.available()) { - throw FormatException.getFormatInstance(); - } - - byte[] readBytes = new byte[count]; - for (int i = 0; i < count; i++) { - readBytes[i] = (byte) bits.readBits(8); - } - Charset encoding; - if (currentCharacterSetECI == null) { - // The spec isn't clear on this mode; see - // section 6.4.5: t does not say which encoding to assuming - // upon decoding. I have seen ISO-8859-1 used as well as - // Shift_JIS -- without anything like an ECI designator to - // give a hint. - encoding = StringUtils.guessCharset(readBytes, hints); - } else { - encoding = currentCharacterSetECI.getCharset(); - } - result.append(new String(readBytes, encoding)); - byteSegments.add(readBytes); - } - - private static char toAlphaNumericChar(int value) throws FormatException { - if (value >= ALPHANUMERIC_CHARS.length) { - throw FormatException.getFormatInstance(); - } - return ALPHANUMERIC_CHARS[value]; - } - - private static void decodeAlphanumericSegment(BitSource bits, - StringBuilder result, - int count, - boolean fc1InEffect) throws FormatException { - // Read two characters at a time - int start = result.length(); - while (count > 1) { - if (bits.available() < 11) { - throw FormatException.getFormatInstance(); - } - int nextTwoCharsBits = bits.readBits(11); - result.append(toAlphaNumericChar(nextTwoCharsBits / 45)); - result.append(toAlphaNumericChar(nextTwoCharsBits % 45)); - count -= 2; - } - if (count == 1) { - // special case: one character left - if (bits.available() < 6) { - throw FormatException.getFormatInstance(); - } - result.append(toAlphaNumericChar(bits.readBits(6))); - } - // See section 6.4.8.1, 6.4.8.2 - if (fc1InEffect) { - // We need to massage the result a bit if in an FNC1 mode: - for (int i = start; i < result.length(); i++) { - if (result.charAt(i) == '%') { - if (i < result.length() - 1 && result.charAt(i + 1) == '%') { - // %% is rendered as % - result.deleteCharAt(i + 1); - } else { - // In alpha mode, % should be converted to FNC1 separator 0x1D - result.setCharAt(i, (char) 0x1D); - } - } - } - } - } - - private static void decodeNumericSegment(BitSource bits, - StringBuilder result, - int count) throws FormatException { - // Read three digits at a time - while (count >= 3) { - // Each 10 bits encodes three digits - if (bits.available() < 10) { - throw FormatException.getFormatInstance(); - } - int threeDigitsBits = bits.readBits(10); - if (threeDigitsBits >= 1000) { - throw FormatException.getFormatInstance(); - } - result.append(toAlphaNumericChar(threeDigitsBits / 100)); - result.append(toAlphaNumericChar((threeDigitsBits / 10) % 10)); - result.append(toAlphaNumericChar(threeDigitsBits % 10)); - count -= 3; - } - if (count == 2) { - // Two digits left over to read, encoded in 7 bits - if (bits.available() < 7) { - throw FormatException.getFormatInstance(); - } - int twoDigitsBits = bits.readBits(7); - if (twoDigitsBits >= 100) { - throw FormatException.getFormatInstance(); - } - result.append(toAlphaNumericChar(twoDigitsBits / 10)); - result.append(toAlphaNumericChar(twoDigitsBits % 10)); - } else if (count == 1) { - // One digit left over to read - if (bits.available() < 4) { - throw FormatException.getFormatInstance(); - } - int digitBits = bits.readBits(4); - if (digitBits >= 10) { - throw FormatException.getFormatInstance(); - } - result.append(toAlphaNumericChar(digitBits)); - } - } - - private static int parseECIValue(BitSource bits) throws FormatException { - int firstByte = bits.readBits(8); - if ((firstByte & 0x80) == 0) { - // just one byte - return firstByte & 0x7F; - } - if ((firstByte & 0xC0) == 0x80) { - // two bytes - int secondByte = bits.readBits(8); - return ((firstByte & 0x3F) << 8) | secondByte; - } - if ((firstByte & 0xE0) == 0xC0) { - // three bytes - int secondThirdBytes = bits.readBits(16); - return ((firstByte & 0x1F) << 16) | secondThirdBytes; - } - throw FormatException.getFormatInstance(); - } - -} diff --git a/port_src/core/DONE/qrcode/decoder/Decoder.java b/port_src/core/DONE/qrcode/decoder/Decoder.java deleted file mode 100644 index 7fcb7d2..0000000 --- a/port_src/core/DONE/qrcode/decoder/Decoder.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.reedsolomon.GenericGF; -import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; -import com.google.zxing.common.reedsolomon.ReedSolomonException; - -import java.util.Map; - -/** - *

The main class which implements QR Code decoding -- as opposed to locating and extracting - * the QR Code from an image.

- * - * @author Sean Owen - */ -public final class Decoder { - - private final ReedSolomonDecoder rsDecoder; - - public Decoder() { - rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256); - } - - public DecoderResult decode(boolean[][] image) throws ChecksumException, FormatException { - return decode(image, null); - } - - /** - *

Convenience method that can decode a QR Code represented as a 2D array of booleans. - * "true" is taken to mean a black module.

- * - * @param image booleans representing white/black QR Code modules - * @param hints decoding hints that should be used to influence decoding - * @return text and bytes encoded within the QR Code - * @throws FormatException if the QR Code cannot be decoded - * @throws ChecksumException if error correction fails - */ - public DecoderResult decode(boolean[][] image, Map hints) - throws ChecksumException, FormatException { - return decode(BitMatrix.parse(image), hints); - } - - public DecoderResult decode(BitMatrix bits) throws ChecksumException, FormatException { - return decode(bits, null); - } - - /** - *

Decodes a QR Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.

- * - * @param bits booleans representing white/black QR Code modules - * @param hints decoding hints that should be used to influence decoding - * @return text and bytes encoded within the QR Code - * @throws FormatException if the QR Code cannot be decoded - * @throws ChecksumException if error correction fails - */ - public DecoderResult decode(BitMatrix bits, Map hints) - throws FormatException, ChecksumException { - - // Construct a parser and read version, error-correction level - BitMatrixParser parser = new BitMatrixParser(bits); - FormatException fe = null; - ChecksumException ce = null; - try { - return decode(parser, hints); - } catch (FormatException e) { - fe = e; - } catch (ChecksumException e) { - ce = e; - } - - try { - - // Revert the bit matrix - parser.remask(); - - // Will be attempting a mirrored reading of the version and format info. - parser.setMirror(true); - - // Preemptively read the version. - parser.readVersion(); - - // Preemptively read the format information. - parser.readFormatInformation(); - - /* - * Since we're here, this means we have successfully detected some kind - * of version and format information when mirrored. This is a good sign, - * that the QR code may be mirrored, and we should try once more with a - * mirrored content. - */ - // Prepare for a mirrored reading. - parser.mirror(); - - DecoderResult result = decode(parser, hints); - - // Success! Notify the caller that the code was mirrored. - result.setOther(new QRCodeDecoderMetaData(true)); - - return result; - - } catch (FormatException | ChecksumException e) { - // Throw the exception from the original reading - if (fe != null) { - throw fe; - } - throw ce; // If fe is null, this can't be - } - } - - private DecoderResult decode(BitMatrixParser parser, Map hints) - throws FormatException, ChecksumException { - Version version = parser.readVersion(); - ErrorCorrectionLevel ecLevel = parser.readFormatInformation().getErrorCorrectionLevel(); - - // Read codewords - byte[] codewords = parser.readCodewords(); - // Separate into data blocks - DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version, ecLevel); - - // Count total number of data bytes - int totalBytes = 0; - for (DataBlock dataBlock : dataBlocks) { - totalBytes += dataBlock.getNumDataCodewords(); - } - byte[] resultBytes = new byte[totalBytes]; - int resultOffset = 0; - - // Error-correct and copy data blocks together into a stream of bytes - for (DataBlock dataBlock : dataBlocks) { - byte[] codewordBytes = dataBlock.getCodewords(); - int numDataCodewords = dataBlock.getNumDataCodewords(); - correctErrors(codewordBytes, numDataCodewords); - for (int i = 0; i < numDataCodewords; i++) { - resultBytes[resultOffset++] = codewordBytes[i]; - } - } - - // Decode the contents of that stream of bytes - return DecodedBitStreamParser.decode(resultBytes, version, ecLevel, hints); - } - - /** - *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to - * correct the errors in-place using Reed-Solomon error correction.

- * - * @param codewordBytes data and error correction codewords - * @param numDataCodewords number of codewords that are data bytes - * @throws ChecksumException if error correction fails - */ - private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException { - int numCodewords = codewordBytes.length; - // First read into an array of ints - int[] codewordsInts = new int[numCodewords]; - for (int i = 0; i < numCodewords; i++) { - codewordsInts[i] = codewordBytes[i] & 0xFF; - } - try { - rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords); - } catch (ReedSolomonException ignored) { - throw ChecksumException.getChecksumInstance(); - } - // Copy back into array of bytes -- only need to worry about the bytes that were data - // We don't care about errors in the error-correction codewords - for (int i = 0; i < numDataCodewords; i++) { - codewordBytes[i] = (byte) codewordsInts[i]; - } - } - -} diff --git a/port_src/core/DONE/qrcode/decoder/ErrorCorrectionLevel.java b/port_src/core/DONE/qrcode/decoder/ErrorCorrectionLevel.java deleted file mode 100644 index 0f1e113..0000000 --- a/port_src/core/DONE/qrcode/decoder/ErrorCorrectionLevel.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -/** - *

See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels - * defined by the QR code standard.

- * - * @author Sean Owen - */ -public enum ErrorCorrectionLevel { - - /** L = ~7% correction */ - L(0x01), - /** M = ~15% correction */ - M(0x00), - /** Q = ~25% correction */ - Q(0x03), - /** H = ~30% correction */ - H(0x02); - - private static final ErrorCorrectionLevel[] FOR_BITS = {M, L, H, Q}; - - private final int bits; - - ErrorCorrectionLevel(int bits) { - this.bits = bits; - } - - public int getBits() { - return bits; - } - - /** - * @param bits int containing the two bits encoding a QR Code's error correction level - * @return ErrorCorrectionLevel representing the encoded error correction level - */ - public static ErrorCorrectionLevel forBits(int bits) { - if (bits < 0 || bits >= FOR_BITS.length) { - throw new IllegalArgumentException(); - } - return FOR_BITS[bits]; - } - - -} diff --git a/port_src/core/DONE/qrcode/decoder/FormatInformation.java b/port_src/core/DONE/qrcode/decoder/FormatInformation.java deleted file mode 100644 index 95ee701..0000000 --- a/port_src/core/DONE/qrcode/decoder/FormatInformation.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -/** - *

Encapsulates a QR Code's format information, including the data mask used and - * error correction level.

- * - * @author Sean Owen - * @see DataMask - * @see ErrorCorrectionLevel - */ -final class FormatInformation { - - private static final int FORMAT_INFO_MASK_QR = 0x5412; - - /** - * See ISO 18004:2006, Annex C, Table C.1 - */ - private static final int[][] FORMAT_INFO_DECODE_LOOKUP = { - {0x5412, 0x00}, - {0x5125, 0x01}, - {0x5E7C, 0x02}, - {0x5B4B, 0x03}, - {0x45F9, 0x04}, - {0x40CE, 0x05}, - {0x4F97, 0x06}, - {0x4AA0, 0x07}, - {0x77C4, 0x08}, - {0x72F3, 0x09}, - {0x7DAA, 0x0A}, - {0x789D, 0x0B}, - {0x662F, 0x0C}, - {0x6318, 0x0D}, - {0x6C41, 0x0E}, - {0x6976, 0x0F}, - {0x1689, 0x10}, - {0x13BE, 0x11}, - {0x1CE7, 0x12}, - {0x19D0, 0x13}, - {0x0762, 0x14}, - {0x0255, 0x15}, - {0x0D0C, 0x16}, - {0x083B, 0x17}, - {0x355F, 0x18}, - {0x3068, 0x19}, - {0x3F31, 0x1A}, - {0x3A06, 0x1B}, - {0x24B4, 0x1C}, - {0x2183, 0x1D}, - {0x2EDA, 0x1E}, - {0x2BED, 0x1F}, - }; - - private final ErrorCorrectionLevel errorCorrectionLevel; - private final byte dataMask; - - private FormatInformation(int formatInfo) { - // Bits 3,4 - errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03); - // Bottom 3 bits - dataMask = (byte) (formatInfo & 0x07); - } - - static int numBitsDiffering(int a, int b) { - return Integer.bitCount(a ^ b); - } - - /** - * @param maskedFormatInfo1 format info indicator, with mask still applied - * @param maskedFormatInfo2 second copy of same info; both are checked at the same time - * to establish best match - * @return information about the format it specifies, or {@code null} - * if doesn't seem to match any known pattern - */ - static FormatInformation decodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2) { - FormatInformation formatInfo = doDecodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2); - if (formatInfo != null) { - return formatInfo; - } - // Should return null, but, some QR codes apparently - // do not mask this info. Try again by actually masking the pattern - // first - return doDecodeFormatInformation(maskedFormatInfo1 ^ FORMAT_INFO_MASK_QR, - maskedFormatInfo2 ^ FORMAT_INFO_MASK_QR); - } - - private static FormatInformation doDecodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2) { - // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing - int bestDifference = Integer.MAX_VALUE; - int bestFormatInfo = 0; - for (int[] decodeInfo : FORMAT_INFO_DECODE_LOOKUP) { - int targetInfo = decodeInfo[0]; - if (targetInfo == maskedFormatInfo1 || targetInfo == maskedFormatInfo2) { - // Found an exact match - return new FormatInformation(decodeInfo[1]); - } - int bitsDifference = numBitsDiffering(maskedFormatInfo1, targetInfo); - if (bitsDifference < bestDifference) { - bestFormatInfo = decodeInfo[1]; - bestDifference = bitsDifference; - } - if (maskedFormatInfo1 != maskedFormatInfo2) { - // also try the other option - bitsDifference = numBitsDiffering(maskedFormatInfo2, targetInfo); - if (bitsDifference < bestDifference) { - bestFormatInfo = decodeInfo[1]; - bestDifference = bitsDifference; - } - } - } - // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits - // differing means we found a match - if (bestDifference <= 3) { - return new FormatInformation(bestFormatInfo); - } - return null; - } - - ErrorCorrectionLevel getErrorCorrectionLevel() { - return errorCorrectionLevel; - } - - byte getDataMask() { - return dataMask; - } - - @Override - public int hashCode() { - return (errorCorrectionLevel.ordinal() << 3) | dataMask; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof FormatInformation)) { - return false; - } - FormatInformation other = (FormatInformation) o; - return this.errorCorrectionLevel == other.errorCorrectionLevel && - this.dataMask == other.dataMask; - } - -} diff --git a/port_src/core/DONE/qrcode/decoder/Mode.java b/port_src/core/DONE/qrcode/decoder/Mode.java deleted file mode 100644 index b7e9ab3..0000000 --- a/port_src/core/DONE/qrcode/decoder/Mode.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -/** - *

See ISO 18004:2006, 6.4.1, Tables 2 and 3. This enum encapsulates the various modes in which - * data can be encoded to bits in the QR code standard.

- * - * @author Sean Owen - */ -public enum Mode { - - TERMINATOR(new int[]{0, 0, 0}, 0x00), // Not really a mode... - NUMERIC(new int[]{10, 12, 14}, 0x01), - ALPHANUMERIC(new int[]{9, 11, 13}, 0x02), - STRUCTURED_APPEND(new int[]{0, 0, 0}, 0x03), // Not supported - BYTE(new int[]{8, 16, 16}, 0x04), - ECI(new int[]{0, 0, 0}, 0x07), // character counts don't apply - KANJI(new int[]{8, 10, 12}, 0x08), - FNC1_FIRST_POSITION(new int[]{0, 0, 0}, 0x05), - FNC1_SECOND_POSITION(new int[]{0, 0, 0}, 0x09), - /** See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. */ - HANZI(new int[]{8, 10, 12}, 0x0D); - - private final int[] characterCountBitsForVersions; - private final int bits; - - Mode(int[] characterCountBitsForVersions, int bits) { - this.characterCountBitsForVersions = characterCountBitsForVersions; - this.bits = bits; - } - - /** - * @param bits four bits encoding a QR Code data mode - * @return Mode encoded by these bits - * @throws IllegalArgumentException if bits do not correspond to a known mode - */ - public static Mode forBits(int bits) { - switch (bits) { - case 0x0: - return TERMINATOR; - case 0x1: - return NUMERIC; - case 0x2: - return ALPHANUMERIC; - case 0x3: - return STRUCTURED_APPEND; - case 0x4: - return BYTE; - case 0x5: - return FNC1_FIRST_POSITION; - case 0x7: - return ECI; - case 0x8: - return KANJI; - case 0x9: - return FNC1_SECOND_POSITION; - case 0xD: - // 0xD is defined in GBT 18284-2000, may not be supported in foreign country - return HANZI; - default: - throw new IllegalArgumentException(); - } - } - - /** - * @param version version in question - * @return number of bits used, in this QR Code symbol {@link Version}, to encode the - * count of characters that will follow encoded in this Mode - */ - public int getCharacterCountBits(Version version) { - int number = version.getVersionNumber(); - int offset; - if (number <= 9) { - offset = 0; - } else if (number <= 26) { - offset = 1; - } else { - offset = 2; - } - return characterCountBitsForVersions[offset]; - } - - public int getBits() { - return bits; - } - -} diff --git a/port_src/core/DONE/qrcode/decoder/QRCodeDecoderMetaData.java b/port_src/core/DONE/qrcode/decoder/QRCodeDecoderMetaData.java deleted file mode 100644 index 299bb65..0000000 --- a/port_src/core/DONE/qrcode/decoder/QRCodeDecoderMetaData.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -import com.google.zxing.ResultPoint; - -/** - * Meta-data container for QR Code decoding. Instances of this class may be used to convey information back to the - * decoding caller. Callers are expected to process this. - * - * @see com.google.zxing.common.DecoderResult#getOther() - */ -public final class QRCodeDecoderMetaData { - - private final boolean mirrored; - - QRCodeDecoderMetaData(boolean mirrored) { - this.mirrored = mirrored; - } - - /** - * @return true if the QR Code was mirrored. - */ - public boolean isMirrored() { - return mirrored; - } - - /** - * Apply the result points' order correction due to mirroring. - * - * @param points Array of points to apply mirror correction to. - */ - public void applyMirroredCorrection(ResultPoint[] points) { - if (!mirrored || points == null || points.length < 3) { - return; - } - ResultPoint bottomLeft = points[0]; - points[0] = points[2]; - points[2] = bottomLeft; - // No need to 'fix' top-left and alignment pattern. - } - -} diff --git a/port_src/core/DONE/qrcode/decoder/Version.java b/port_src/core/DONE/qrcode/decoder/Version.java deleted file mode 100755 index 169e3fd..0000000 --- a/port_src/core/DONE/qrcode/decoder/Version.java +++ /dev/null @@ -1,577 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; - -/** - * See ISO 18004:2006 Annex D - * - * @author Sean Owen - */ -public final class Version { - - /** - * See ISO 18004:2006 Annex D. - * Element i represents the raw version bits that specify version i + 7 - */ - private static final int[] VERSION_DECODE_INFO = { - 0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, - 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, - 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, - 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, - 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, - 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, - 0x2542E, 0x26A64, 0x27541, 0x28C69 - }; - - private static final Version[] VERSIONS = buildVersions(); - - private final int versionNumber; - private final int[] alignmentPatternCenters; - private final ECBlocks[] ecBlocks; - private final int totalCodewords; - - private Version(int versionNumber, - int[] alignmentPatternCenters, - ECBlocks... ecBlocks) { - this.versionNumber = versionNumber; - this.alignmentPatternCenters = alignmentPatternCenters; - this.ecBlocks = ecBlocks; - int total = 0; - int ecCodewords = ecBlocks[0].getECCodewordsPerBlock(); - ECB[] ecbArray = ecBlocks[0].getECBlocks(); - for (ECB ecBlock : ecbArray) { - total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords); - } - this.totalCodewords = total; - } - - public int getVersionNumber() { - return versionNumber; - } - - public int[] getAlignmentPatternCenters() { - return alignmentPatternCenters; - } - - public int getTotalCodewords() { - return totalCodewords; - } - - public int getDimensionForVersion() { - return 17 + 4 * versionNumber; - } - - public ECBlocks getECBlocksForLevel(ErrorCorrectionLevel ecLevel) { - return ecBlocks[ecLevel.ordinal()]; - } - - /** - *

Deduces version information purely from QR Code dimensions.

- * - * @param dimension dimension in modules - * @return Version for a QR Code of that dimension - * @throws FormatException if dimension is not 1 mod 4 - */ - public static Version getProvisionalVersionForDimension(int dimension) throws FormatException { - if (dimension % 4 != 1) { - throw FormatException.getFormatInstance(); - } - try { - return getVersionForNumber((dimension - 17) / 4); - } catch (IllegalArgumentException ignored) { - throw FormatException.getFormatInstance(); - } - } - - public static Version getVersionForNumber(int versionNumber) { - if (versionNumber < 1 || versionNumber > 40) { - throw new IllegalArgumentException(); - } - return VERSIONS[versionNumber - 1]; - } - - static Version decodeVersionInformation(int versionBits) { - int bestDifference = Integer.MAX_VALUE; - int bestVersion = 0; - for (int i = 0; i < VERSION_DECODE_INFO.length; i++) { - int targetVersion = VERSION_DECODE_INFO[i]; - // Do the version info bits match exactly? done. - if (targetVersion == versionBits) { - return getVersionForNumber(i + 7); - } - // Otherwise see if this is the closest to a real version info bit string - // we have seen so far - int bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion); - if (bitsDifference < bestDifference) { - bestVersion = i + 7; - bestDifference = bitsDifference; - } - } - // We can tolerate up to 3 bits of error since no two version info codewords will - // differ in less than 8 bits. - if (bestDifference <= 3) { - return getVersionForNumber(bestVersion); - } - // If we didn't find a close enough match, fail - return null; - } - - /** - * See ISO 18004:2006 Annex E - */ - BitMatrix buildFunctionPattern() { - int dimension = getDimensionForVersion(); - BitMatrix bitMatrix = new BitMatrix(dimension); - - // Top left finder pattern + separator + format - bitMatrix.setRegion(0, 0, 9, 9); - // Top right finder pattern + separator + format - bitMatrix.setRegion(dimension - 8, 0, 8, 9); - // Bottom left finder pattern + separator + format - bitMatrix.setRegion(0, dimension - 8, 9, 8); - - // Alignment patterns - int max = alignmentPatternCenters.length; - for (int x = 0; x < max; x++) { - int i = alignmentPatternCenters[x] - 2; - for (int y = 0; y < max; y++) { - if ((x != 0 || (y != 0 && y != max - 1)) && (x != max - 1 || y != 0)) { - bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5); - } - // else no o alignment patterns near the three finder patterns - } - } - - // Vertical timing pattern - bitMatrix.setRegion(6, 9, 1, dimension - 17); - // Horizontal timing pattern - bitMatrix.setRegion(9, 6, dimension - 17, 1); - - if (versionNumber > 6) { - // Version info, top right - bitMatrix.setRegion(dimension - 11, 0, 3, 6); - // Version info, bottom left - bitMatrix.setRegion(0, dimension - 11, 6, 3); - } - - return bitMatrix; - } - - /** - *

Encapsulates a set of error-correction blocks in one symbol version. Most versions will - * use blocks of differing sizes within one version, so, this encapsulates the parameters for - * each set of blocks. It also holds the number of error-correction codewords per block since it - * will be the same across all blocks within one version.

- */ - public static final class ECBlocks { - private final int ecCodewordsPerBlock; - private final ECB[] ecBlocks; - - ECBlocks(int ecCodewordsPerBlock, ECB... ecBlocks) { - this.ecCodewordsPerBlock = ecCodewordsPerBlock; - this.ecBlocks = ecBlocks; - } - - public int getECCodewordsPerBlock() { - return ecCodewordsPerBlock; - } - - public int getNumBlocks() { - int total = 0; - for (ECB ecBlock : ecBlocks) { - total += ecBlock.getCount(); - } - return total; - } - - public int getTotalECCodewords() { - return ecCodewordsPerBlock * getNumBlocks(); - } - - public ECB[] getECBlocks() { - return ecBlocks; - } - } - - /** - *

Encapsulates the parameters for one error-correction block in one symbol version. - * This includes the number of data codewords, and the number of times a block with these - * parameters is used consecutively in the QR code version's format.

- */ - public static final class ECB { - private final int count; - private final int dataCodewords; - - ECB(int count, int dataCodewords) { - this.count = count; - this.dataCodewords = dataCodewords; - } - - public int getCount() { - return count; - } - - public int getDataCodewords() { - return dataCodewords; - } - } - - @Override - public String toString() { - return String.valueOf(versionNumber); - } - - /** - * See ISO 18004:2006 6.5.1 Table 9 - */ - private static Version[] buildVersions() { - return new Version[]{ - new Version(1, new int[]{}, - new ECBlocks(7, new ECB(1, 19)), - new ECBlocks(10, new ECB(1, 16)), - new ECBlocks(13, new ECB(1, 13)), - new ECBlocks(17, new ECB(1, 9))), - new Version(2, new int[]{6, 18}, - new ECBlocks(10, new ECB(1, 34)), - new ECBlocks(16, new ECB(1, 28)), - new ECBlocks(22, new ECB(1, 22)), - new ECBlocks(28, new ECB(1, 16))), - new Version(3, new int[]{6, 22}, - new ECBlocks(15, new ECB(1, 55)), - new ECBlocks(26, new ECB(1, 44)), - new ECBlocks(18, new ECB(2, 17)), - new ECBlocks(22, new ECB(2, 13))), - new Version(4, new int[]{6, 26}, - new ECBlocks(20, new ECB(1, 80)), - new ECBlocks(18, new ECB(2, 32)), - new ECBlocks(26, new ECB(2, 24)), - new ECBlocks(16, new ECB(4, 9))), - new Version(5, new int[]{6, 30}, - new ECBlocks(26, new ECB(1, 108)), - new ECBlocks(24, new ECB(2, 43)), - new ECBlocks(18, new ECB(2, 15), - new ECB(2, 16)), - new ECBlocks(22, new ECB(2, 11), - new ECB(2, 12))), - new Version(6, new int[]{6, 34}, - new ECBlocks(18, new ECB(2, 68)), - new ECBlocks(16, new ECB(4, 27)), - new ECBlocks(24, new ECB(4, 19)), - new ECBlocks(28, new ECB(4, 15))), - new Version(7, new int[]{6, 22, 38}, - new ECBlocks(20, new ECB(2, 78)), - new ECBlocks(18, new ECB(4, 31)), - new ECBlocks(18, new ECB(2, 14), - new ECB(4, 15)), - new ECBlocks(26, new ECB(4, 13), - new ECB(1, 14))), - new Version(8, new int[]{6, 24, 42}, - new ECBlocks(24, new ECB(2, 97)), - new ECBlocks(22, new ECB(2, 38), - new ECB(2, 39)), - new ECBlocks(22, new ECB(4, 18), - new ECB(2, 19)), - new ECBlocks(26, new ECB(4, 14), - new ECB(2, 15))), - new Version(9, new int[]{6, 26, 46}, - new ECBlocks(30, new ECB(2, 116)), - new ECBlocks(22, new ECB(3, 36), - new ECB(2, 37)), - new ECBlocks(20, new ECB(4, 16), - new ECB(4, 17)), - new ECBlocks(24, new ECB(4, 12), - new ECB(4, 13))), - new Version(10, new int[]{6, 28, 50}, - new ECBlocks(18, new ECB(2, 68), - new ECB(2, 69)), - new ECBlocks(26, new ECB(4, 43), - new ECB(1, 44)), - new ECBlocks(24, new ECB(6, 19), - new ECB(2, 20)), - new ECBlocks(28, new ECB(6, 15), - new ECB(2, 16))), - new Version(11, new int[]{6, 30, 54}, - new ECBlocks(20, new ECB(4, 81)), - new ECBlocks(30, new ECB(1, 50), - new ECB(4, 51)), - new ECBlocks(28, new ECB(4, 22), - new ECB(4, 23)), - new ECBlocks(24, new ECB(3, 12), - new ECB(8, 13))), - new Version(12, new int[]{6, 32, 58}, - new ECBlocks(24, new ECB(2, 92), - new ECB(2, 93)), - new ECBlocks(22, new ECB(6, 36), - new ECB(2, 37)), - new ECBlocks(26, new ECB(4, 20), - new ECB(6, 21)), - new ECBlocks(28, new ECB(7, 14), - new ECB(4, 15))), - new Version(13, new int[]{6, 34, 62}, - new ECBlocks(26, new ECB(4, 107)), - new ECBlocks(22, new ECB(8, 37), - new ECB(1, 38)), - new ECBlocks(24, new ECB(8, 20), - new ECB(4, 21)), - new ECBlocks(22, new ECB(12, 11), - new ECB(4, 12))), - new Version(14, new int[]{6, 26, 46, 66}, - new ECBlocks(30, new ECB(3, 115), - new ECB(1, 116)), - new ECBlocks(24, new ECB(4, 40), - new ECB(5, 41)), - new ECBlocks(20, new ECB(11, 16), - new ECB(5, 17)), - new ECBlocks(24, new ECB(11, 12), - new ECB(5, 13))), - new Version(15, new int[]{6, 26, 48, 70}, - new ECBlocks(22, new ECB(5, 87), - new ECB(1, 88)), - new ECBlocks(24, new ECB(5, 41), - new ECB(5, 42)), - new ECBlocks(30, new ECB(5, 24), - new ECB(7, 25)), - new ECBlocks(24, new ECB(11, 12), - new ECB(7, 13))), - new Version(16, new int[]{6, 26, 50, 74}, - new ECBlocks(24, new ECB(5, 98), - new ECB(1, 99)), - new ECBlocks(28, new ECB(7, 45), - new ECB(3, 46)), - new ECBlocks(24, new ECB(15, 19), - new ECB(2, 20)), - new ECBlocks(30, new ECB(3, 15), - new ECB(13, 16))), - new Version(17, new int[]{6, 30, 54, 78}, - new ECBlocks(28, new ECB(1, 107), - new ECB(5, 108)), - new ECBlocks(28, new ECB(10, 46), - new ECB(1, 47)), - new ECBlocks(28, new ECB(1, 22), - new ECB(15, 23)), - new ECBlocks(28, new ECB(2, 14), - new ECB(17, 15))), - new Version(18, new int[]{6, 30, 56, 82}, - new ECBlocks(30, new ECB(5, 120), - new ECB(1, 121)), - new ECBlocks(26, new ECB(9, 43), - new ECB(4, 44)), - new ECBlocks(28, new ECB(17, 22), - new ECB(1, 23)), - new ECBlocks(28, new ECB(2, 14), - new ECB(19, 15))), - new Version(19, new int[]{6, 30, 58, 86}, - new ECBlocks(28, new ECB(3, 113), - new ECB(4, 114)), - new ECBlocks(26, new ECB(3, 44), - new ECB(11, 45)), - new ECBlocks(26, new ECB(17, 21), - new ECB(4, 22)), - new ECBlocks(26, new ECB(9, 13), - new ECB(16, 14))), - new Version(20, new int[]{6, 34, 62, 90}, - new ECBlocks(28, new ECB(3, 107), - new ECB(5, 108)), - new ECBlocks(26, new ECB(3, 41), - new ECB(13, 42)), - new ECBlocks(30, new ECB(15, 24), - new ECB(5, 25)), - new ECBlocks(28, new ECB(15, 15), - new ECB(10, 16))), - new Version(21, new int[]{6, 28, 50, 72, 94}, - new ECBlocks(28, new ECB(4, 116), - new ECB(4, 117)), - new ECBlocks(26, new ECB(17, 42)), - new ECBlocks(28, new ECB(17, 22), - new ECB(6, 23)), - new ECBlocks(30, new ECB(19, 16), - new ECB(6, 17))), - new Version(22, new int[]{6, 26, 50, 74, 98}, - new ECBlocks(28, new ECB(2, 111), - new ECB(7, 112)), - new ECBlocks(28, new ECB(17, 46)), - new ECBlocks(30, new ECB(7, 24), - new ECB(16, 25)), - new ECBlocks(24, new ECB(34, 13))), - new Version(23, new int[]{6, 30, 54, 78, 102}, - new ECBlocks(30, new ECB(4, 121), - new ECB(5, 122)), - new ECBlocks(28, new ECB(4, 47), - new ECB(14, 48)), - new ECBlocks(30, new ECB(11, 24), - new ECB(14, 25)), - new ECBlocks(30, new ECB(16, 15), - new ECB(14, 16))), - new Version(24, new int[]{6, 28, 54, 80, 106}, - new ECBlocks(30, new ECB(6, 117), - new ECB(4, 118)), - new ECBlocks(28, new ECB(6, 45), - new ECB(14, 46)), - new ECBlocks(30, new ECB(11, 24), - new ECB(16, 25)), - new ECBlocks(30, new ECB(30, 16), - new ECB(2, 17))), - new Version(25, new int[]{6, 32, 58, 84, 110}, - new ECBlocks(26, new ECB(8, 106), - new ECB(4, 107)), - new ECBlocks(28, new ECB(8, 47), - new ECB(13, 48)), - new ECBlocks(30, new ECB(7, 24), - new ECB(22, 25)), - new ECBlocks(30, new ECB(22, 15), - new ECB(13, 16))), - new Version(26, new int[]{6, 30, 58, 86, 114}, - new ECBlocks(28, new ECB(10, 114), - new ECB(2, 115)), - new ECBlocks(28, new ECB(19, 46), - new ECB(4, 47)), - new ECBlocks(28, new ECB(28, 22), - new ECB(6, 23)), - new ECBlocks(30, new ECB(33, 16), - new ECB(4, 17))), - new Version(27, new int[]{6, 34, 62, 90, 118}, - new ECBlocks(30, new ECB(8, 122), - new ECB(4, 123)), - new ECBlocks(28, new ECB(22, 45), - new ECB(3, 46)), - new ECBlocks(30, new ECB(8, 23), - new ECB(26, 24)), - new ECBlocks(30, new ECB(12, 15), - new ECB(28, 16))), - new Version(28, new int[]{6, 26, 50, 74, 98, 122}, - new ECBlocks(30, new ECB(3, 117), - new ECB(10, 118)), - new ECBlocks(28, new ECB(3, 45), - new ECB(23, 46)), - new ECBlocks(30, new ECB(4, 24), - new ECB(31, 25)), - new ECBlocks(30, new ECB(11, 15), - new ECB(31, 16))), - new Version(29, new int[]{6, 30, 54, 78, 102, 126}, - new ECBlocks(30, new ECB(7, 116), - new ECB(7, 117)), - new ECBlocks(28, new ECB(21, 45), - new ECB(7, 46)), - new ECBlocks(30, new ECB(1, 23), - new ECB(37, 24)), - new ECBlocks(30, new ECB(19, 15), - new ECB(26, 16))), - new Version(30, new int[]{6, 26, 52, 78, 104, 130}, - new ECBlocks(30, new ECB(5, 115), - new ECB(10, 116)), - new ECBlocks(28, new ECB(19, 47), - new ECB(10, 48)), - new ECBlocks(30, new ECB(15, 24), - new ECB(25, 25)), - new ECBlocks(30, new ECB(23, 15), - new ECB(25, 16))), - new Version(31, new int[]{6, 30, 56, 82, 108, 134}, - new ECBlocks(30, new ECB(13, 115), - new ECB(3, 116)), - new ECBlocks(28, new ECB(2, 46), - new ECB(29, 47)), - new ECBlocks(30, new ECB(42, 24), - new ECB(1, 25)), - new ECBlocks(30, new ECB(23, 15), - new ECB(28, 16))), - new Version(32, new int[]{6, 34, 60, 86, 112, 138}, - new ECBlocks(30, new ECB(17, 115)), - new ECBlocks(28, new ECB(10, 46), - new ECB(23, 47)), - new ECBlocks(30, new ECB(10, 24), - new ECB(35, 25)), - new ECBlocks(30, new ECB(19, 15), - new ECB(35, 16))), - new Version(33, new int[]{6, 30, 58, 86, 114, 142}, - new ECBlocks(30, new ECB(17, 115), - new ECB(1, 116)), - new ECBlocks(28, new ECB(14, 46), - new ECB(21, 47)), - new ECBlocks(30, new ECB(29, 24), - new ECB(19, 25)), - new ECBlocks(30, new ECB(11, 15), - new ECB(46, 16))), - new Version(34, new int[]{6, 34, 62, 90, 118, 146}, - new ECBlocks(30, new ECB(13, 115), - new ECB(6, 116)), - new ECBlocks(28, new ECB(14, 46), - new ECB(23, 47)), - new ECBlocks(30, new ECB(44, 24), - new ECB(7, 25)), - new ECBlocks(30, new ECB(59, 16), - new ECB(1, 17))), - new Version(35, new int[]{6, 30, 54, 78, 102, 126, 150}, - new ECBlocks(30, new ECB(12, 121), - new ECB(7, 122)), - new ECBlocks(28, new ECB(12, 47), - new ECB(26, 48)), - new ECBlocks(30, new ECB(39, 24), - new ECB(14, 25)), - new ECBlocks(30, new ECB(22, 15), - new ECB(41, 16))), - new Version(36, new int[]{6, 24, 50, 76, 102, 128, 154}, - new ECBlocks(30, new ECB(6, 121), - new ECB(14, 122)), - new ECBlocks(28, new ECB(6, 47), - new ECB(34, 48)), - new ECBlocks(30, new ECB(46, 24), - new ECB(10, 25)), - new ECBlocks(30, new ECB(2, 15), - new ECB(64, 16))), - new Version(37, new int[]{6, 28, 54, 80, 106, 132, 158}, - new ECBlocks(30, new ECB(17, 122), - new ECB(4, 123)), - new ECBlocks(28, new ECB(29, 46), - new ECB(14, 47)), - new ECBlocks(30, new ECB(49, 24), - new ECB(10, 25)), - new ECBlocks(30, new ECB(24, 15), - new ECB(46, 16))), - new Version(38, new int[]{6, 32, 58, 84, 110, 136, 162}, - new ECBlocks(30, new ECB(4, 122), - new ECB(18, 123)), - new ECBlocks(28, new ECB(13, 46), - new ECB(32, 47)), - new ECBlocks(30, new ECB(48, 24), - new ECB(14, 25)), - new ECBlocks(30, new ECB(42, 15), - new ECB(32, 16))), - new Version(39, new int[]{6, 26, 54, 82, 110, 138, 166}, - new ECBlocks(30, new ECB(20, 117), - new ECB(4, 118)), - new ECBlocks(28, new ECB(40, 47), - new ECB(7, 48)), - new ECBlocks(30, new ECB(43, 24), - new ECB(22, 25)), - new ECBlocks(30, new ECB(10, 15), - new ECB(67, 16))), - new Version(40, new int[]{6, 30, 58, 86, 114, 142, 170}, - new ECBlocks(30, new ECB(19, 118), - new ECB(6, 119)), - new ECBlocks(28, new ECB(18, 47), - new ECB(31, 48)), - new ECBlocks(30, new ECB(34, 24), - new ECB(34, 25)), - new ECBlocks(30, new ECB(20, 15), - new ECB(61, 16))) - }; - } - -} diff --git a/port_src/core/DONE/qrcode/detector/AlignmentPattern.java b/port_src/core/DONE/qrcode/detector/AlignmentPattern.java deleted file mode 100644 index 96d9194..0000000 --- a/port_src/core/DONE/qrcode/detector/AlignmentPattern.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.detector; - -import com.google.zxing.ResultPoint; - -/** - *

Encapsulates an alignment pattern, which are the smaller square patterns found in - * all but the simplest QR Codes.

- * - * @author Sean Owen - */ -public final class AlignmentPattern extends ResultPoint { - - private final float estimatedModuleSize; - - AlignmentPattern(float posX, float posY, float estimatedModuleSize) { - super(posX, posY); - this.estimatedModuleSize = estimatedModuleSize; - } - - /** - *

Determines if this alignment pattern "about equals" an alignment pattern at the stated - * position and size -- meaning, it is at nearly the same center with nearly the same size.

- */ - boolean aboutEquals(float moduleSize, float i, float j) { - if (Math.abs(i - getY()) <= moduleSize && Math.abs(j - getX()) <= moduleSize) { - float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize); - return moduleSizeDiff <= 1.0f || moduleSizeDiff <= estimatedModuleSize; - } - return false; - } - - /** - * Combines this object's current estimate of a finder pattern position and module size - * with a new estimate. It returns a new {@code FinderPattern} containing an average of the two. - */ - AlignmentPattern combineEstimate(float i, float j, float newModuleSize) { - float combinedX = (getX() + j) / 2.0f; - float combinedY = (getY() + i) / 2.0f; - float combinedModuleSize = (estimatedModuleSize + newModuleSize) / 2.0f; - return new AlignmentPattern(combinedX, combinedY, combinedModuleSize); - } - -} \ No newline at end of file diff --git a/port_src/core/DONE/qrcode/detector/AlignmentPatternFinder.java b/port_src/core/DONE/qrcode/detector/AlignmentPatternFinder.java deleted file mode 100644 index c4f9aa0..0000000 --- a/port_src/core/DONE/qrcode/detector/AlignmentPatternFinder.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.detector; - -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPointCallback; -import com.google.zxing.common.BitMatrix; - -import java.util.ArrayList; -import java.util.List; - -/** - *

This class attempts to find alignment patterns in a QR Code. Alignment patterns look like finder - * patterns but are smaller and appear at regular intervals throughout the image.

- * - *

At the moment this only looks for the bottom-right alignment pattern.

- * - *

This is mostly a simplified copy of {@link FinderPatternFinder}. It is copied, - * pasted and stripped down here for maximum performance but does unfortunately duplicate - * some code.

- * - *

This class is thread-safe but not reentrant. Each thread must allocate its own object.

- * - * @author Sean Owen - */ -final class AlignmentPatternFinder { - - private final BitMatrix image; - private final List possibleCenters; - private final int startX; - private final int startY; - private final int width; - private final int height; - private final float moduleSize; - private final int[] crossCheckStateCount; - private final ResultPointCallback resultPointCallback; - - /** - *

Creates a finder that will look in a portion of the whole image.

- * - * @param image image to search - * @param startX left column from which to start searching - * @param startY top row from which to start searching - * @param width width of region to search - * @param height height of region to search - * @param moduleSize estimated module size so far - */ - AlignmentPatternFinder(BitMatrix image, - int startX, - int startY, - int width, - int height, - float moduleSize, - ResultPointCallback resultPointCallback) { - this.image = image; - this.possibleCenters = new ArrayList<>(5); - this.startX = startX; - this.startY = startY; - this.width = width; - this.height = height; - this.moduleSize = moduleSize; - this.crossCheckStateCount = new int[3]; - this.resultPointCallback = resultPointCallback; - } - - /** - *

This method attempts to find the bottom-right alignment pattern in the image. It is a bit messy since - * it's pretty performance-critical and so is written to be fast foremost.

- * - * @return {@link AlignmentPattern} if found - * @throws NotFoundException if not found - */ - AlignmentPattern find() throws NotFoundException { - int startX = this.startX; - int height = this.height; - int maxJ = startX + width; - int middleI = startY + (height / 2); - // We are looking for black/white/black modules in 1:1:1 ratio; - // this tracks the number of black/white/black modules seen so far - int[] stateCount = new int[3]; - for (int iGen = 0; iGen < height; iGen++) { - // Search from middle outwards - int i = middleI + ((iGen & 0x01) == 0 ? (iGen + 1) / 2 : -((iGen + 1) / 2)); - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - int j = startX; - // Burn off leading white pixels before anything else; if we start in the middle of - // a white run, it doesn't make sense to count its length, since we don't know if the - // white run continued to the left of the start point - while (j < maxJ && !image.get(j, i)) { - j++; - } - int currentState = 0; - while (j < maxJ) { - if (image.get(j, i)) { - // Black pixel - if (currentState == 1) { // Counting black pixels - stateCount[1]++; - } else { // Counting white pixels - if (currentState == 2) { // A winner? - if (foundPatternCross(stateCount)) { // Yes - AlignmentPattern confirmed = handlePossibleCenter(stateCount, i, j); - if (confirmed != null) { - return confirmed; - } - } - stateCount[0] = stateCount[2]; - stateCount[1] = 1; - stateCount[2] = 0; - currentState = 1; - } else { - stateCount[++currentState]++; - } - } - } else { // White pixel - if (currentState == 1) { // Counting black pixels - currentState++; - } - stateCount[currentState]++; - } - j++; - } - if (foundPatternCross(stateCount)) { - AlignmentPattern confirmed = handlePossibleCenter(stateCount, i, maxJ); - if (confirmed != null) { - return confirmed; - } - } - - } - - // Hmm, nothing we saw was observed and confirmed twice. If we had - // any guess at all, return it. - if (!possibleCenters.isEmpty()) { - return possibleCenters.get(0); - } - - throw NotFoundException.getNotFoundInstance(); - } - - /** - * Given a count of black/white/black pixels just seen and an end position, - * figures the location of the center of this black/white/black run. - */ - private static float centerFromEnd(int[] stateCount, int end) { - return (end - stateCount[2]) - stateCount[1] / 2.0f; - } - - /** - * @param stateCount count of black/white/black pixels just read - * @return true iff the proportions of the counts is close enough to the 1/1/1 ratios - * used by alignment patterns to be considered a match - */ - private boolean foundPatternCross(int[] stateCount) { - float moduleSize = this.moduleSize; - float maxVariance = moduleSize / 2.0f; - for (int i = 0; i < 3; i++) { - if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) { - return false; - } - } - return true; - } - - /** - *

After a horizontal scan finds a potential alignment pattern, this method - * "cross-checks" by scanning down vertically through the center of the possible - * alignment pattern to see if the same proportion is detected.

- * - * @param startI row where an alignment pattern was detected - * @param centerJ center of the section that appears to cross an alignment pattern - * @param maxCount maximum reasonable number of modules that should be - * observed in any reading state, based on the results of the horizontal scan - * @return vertical center of alignment pattern, or {@link Float#NaN} if not found - */ - private float crossCheckVertical(int startI, int centerJ, int maxCount, - int originalStateCountTotal) { - BitMatrix image = this.image; - - int maxI = image.getHeight(); - int[] stateCount = crossCheckStateCount; - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - - // Start counting up from center - int i = startI; - while (i >= 0 && image.get(centerJ, i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i--; - } - // If already too many modules in this state or ran off the edge: - if (i < 0 || stateCount[1] > maxCount) { - return Float.NaN; - } - while (i >= 0 && !image.get(centerJ, i) && stateCount[0] <= maxCount) { - stateCount[0]++; - i--; - } - if (stateCount[0] > maxCount) { - return Float.NaN; - } - - // Now also count down from center - i = startI + 1; - while (i < maxI && image.get(centerJ, i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i++; - } - if (i == maxI || stateCount[1] > maxCount) { - return Float.NaN; - } - while (i < maxI && !image.get(centerJ, i) && stateCount[2] <= maxCount) { - stateCount[2]++; - i++; - } - if (stateCount[2] > maxCount) { - return Float.NaN; - } - - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; - if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { - return Float.NaN; - } - - return foundPatternCross(stateCount) ? centerFromEnd(stateCount, i) : Float.NaN; - } - - /** - *

This is called when a horizontal scan finds a possible alignment pattern. It will - * cross check with a vertical scan, and if successful, will see if this pattern had been - * found on a previous horizontal scan. If so, we consider it confirmed and conclude we have - * found the alignment pattern.

- * - * @param stateCount reading state module counts from horizontal scan - * @param i row where alignment pattern may be found - * @param j end of possible alignment pattern in row - * @return {@link AlignmentPattern} if we have found the same pattern twice, or null if not - */ - private AlignmentPattern handlePossibleCenter(int[] stateCount, int i, int j) { - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; - float centerJ = centerFromEnd(stateCount, j); - float centerI = crossCheckVertical(i, (int) centerJ, 2 * stateCount[1], stateCountTotal); - if (!Float.isNaN(centerI)) { - float estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0f; - for (AlignmentPattern center : possibleCenters) { - // Look for about the same center and module size: - if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) { - return center.combineEstimate(centerI, centerJ, estimatedModuleSize); - } - } - // Hadn't found this before; save it - AlignmentPattern point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize); - possibleCenters.add(point); - if (resultPointCallback != null) { - resultPointCallback.foundPossibleResultPoint(point); - } - } - return null; - } - -} diff --git a/port_src/core/DONE/qrcode/detector/Detector.java b/port_src/core/DONE/qrcode/detector/Detector.java deleted file mode 100644 index 9648883..0000000 --- a/port_src/core/DONE/qrcode/detector/Detector.java +++ /dev/null @@ -1,405 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.detector; - -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPoint; -import com.google.zxing.ResultPointCallback; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DetectorResult; -import com.google.zxing.common.GridSampler; -import com.google.zxing.common.PerspectiveTransform; -import com.google.zxing.common.detector.MathUtils; -import com.google.zxing.qrcode.decoder.Version; - -import java.util.Map; - -/** - *

Encapsulates logic that can detect a QR Code in an image, even if the QR Code - * is rotated or skewed, or partially obscured.

- * - * @author Sean Owen - */ -public class Detector { - - private final BitMatrix image; - private ResultPointCallback resultPointCallback; - - public Detector(BitMatrix image) { - this.image = image; - } - - protected final BitMatrix getImage() { - return image; - } - - protected final ResultPointCallback getResultPointCallback() { - return resultPointCallback; - } - - /** - *

Detects a QR Code in an image.

- * - * @return {@link DetectorResult} encapsulating results of detecting a QR Code - * @throws NotFoundException if QR Code cannot be found - * @throws FormatException if a QR Code cannot be decoded - */ - public DetectorResult detect() throws NotFoundException, FormatException { - return detect(null); - } - - /** - *

Detects a QR Code in an image.

- * - * @param hints optional hints to detector - * @return {@link DetectorResult} encapsulating results of detecting a QR Code - * @throws NotFoundException if QR Code cannot be found - * @throws FormatException if a QR Code cannot be decoded - */ - public final DetectorResult detect(Map hints) throws NotFoundException, FormatException { - - resultPointCallback = hints == null ? null : - (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); - - FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback); - FinderPatternInfo info = finder.find(hints); - - return processFinderPatternInfo(info); - } - - protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info) - throws NotFoundException, FormatException { - - FinderPattern topLeft = info.getTopLeft(); - FinderPattern topRight = info.getTopRight(); - FinderPattern bottomLeft = info.getBottomLeft(); - - float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft); - if (moduleSize < 1.0f) { - throw NotFoundException.getNotFoundInstance(); - } - int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize); - Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension); - int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7; - - AlignmentPattern alignmentPattern = null; - // Anything above version 1 has an alignment pattern - if (provisionalVersion.getAlignmentPatternCenters().length > 0) { - - // Guess where a "bottom right" finder pattern would have been - float bottomRightX = topRight.getX() - topLeft.getX() + bottomLeft.getX(); - float bottomRightY = topRight.getY() - topLeft.getY() + bottomLeft.getY(); - - // Estimate that alignment pattern is closer by 3 modules - // from "bottom right" to known top left location - float correctionToTopLeft = 1.0f - 3.0f / modulesBetweenFPCenters; - int estAlignmentX = (int) (topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX())); - int estAlignmentY = (int) (topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY())); - - // Kind of arbitrary -- expand search radius before giving up - for (int i = 4; i <= 16; i <<= 1) { - try { - alignmentPattern = findAlignmentInRegion(moduleSize, - estAlignmentX, - estAlignmentY, - i); - break; - } catch (NotFoundException re) { - // try next round - } - } - // If we didn't find alignment pattern... well try anyway without it - } - - PerspectiveTransform transform = - createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension); - - BitMatrix bits = sampleGrid(image, transform, dimension); - - ResultPoint[] points; - if (alignmentPattern == null) { - points = new ResultPoint[]{bottomLeft, topLeft, topRight}; - } else { - points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern}; - } - return new DetectorResult(bits, points); - } - - private static PerspectiveTransform createTransform(ResultPoint topLeft, - ResultPoint topRight, - ResultPoint bottomLeft, - ResultPoint alignmentPattern, - int dimension) { - float dimMinusThree = dimension - 3.5f; - float bottomRightX; - float bottomRightY; - float sourceBottomRightX; - float sourceBottomRightY; - if (alignmentPattern != null) { - bottomRightX = alignmentPattern.getX(); - bottomRightY = alignmentPattern.getY(); - sourceBottomRightX = dimMinusThree - 3.0f; - sourceBottomRightY = sourceBottomRightX; - } else { - // Don't have an alignment pattern, just make up the bottom-right point - bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX(); - bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY(); - sourceBottomRightX = dimMinusThree; - sourceBottomRightY = dimMinusThree; - } - - return PerspectiveTransform.quadrilateralToQuadrilateral( - 3.5f, - 3.5f, - dimMinusThree, - 3.5f, - sourceBottomRightX, - sourceBottomRightY, - 3.5f, - dimMinusThree, - topLeft.getX(), - topLeft.getY(), - topRight.getX(), - topRight.getY(), - bottomRightX, - bottomRightY, - bottomLeft.getX(), - bottomLeft.getY()); - } - - private static BitMatrix sampleGrid(BitMatrix image, - PerspectiveTransform transform, - int dimension) throws NotFoundException { - - GridSampler sampler = GridSampler.getInstance(); - return sampler.sampleGrid(image, dimension, dimension, transform); - } - - /** - *

Computes the dimension (number of modules on a size) of the QR Code based on the position - * of the finder patterns and estimated module size.

- */ - private static int computeDimension(ResultPoint topLeft, - ResultPoint topRight, - ResultPoint bottomLeft, - float moduleSize) throws NotFoundException { - int tltrCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleSize); - int tlblCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleSize); - int dimension = ((tltrCentersDimension + tlblCentersDimension) / 2) + 7; - switch (dimension & 0x03) { // mod 4 - case 0: - dimension++; - break; - // 1? do nothing - case 2: - dimension--; - break; - case 3: - throw NotFoundException.getNotFoundInstance(); - } - return dimension; - } - - /** - *

Computes an average estimated module size based on estimated derived from the positions - * of the three finder patterns.

- * - * @param topLeft detected top-left finder pattern center - * @param topRight detected top-right finder pattern center - * @param bottomLeft detected bottom-left finder pattern center - * @return estimated module size - */ - protected final float calculateModuleSize(ResultPoint topLeft, - ResultPoint topRight, - ResultPoint bottomLeft) { - // Take the average - return (calculateModuleSizeOneWay(topLeft, topRight) + - calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0f; - } - - /** - *

Estimates module size based on two finder patterns -- it uses - * {@link #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int)} to figure the - * width of each, measuring along the axis between their centers.

- */ - private float calculateModuleSizeOneWay(ResultPoint pattern, ResultPoint otherPattern) { - float moduleSizeEst1 = sizeOfBlackWhiteBlackRunBothWays((int) pattern.getX(), - (int) pattern.getY(), - (int) otherPattern.getX(), - (int) otherPattern.getY()); - float moduleSizeEst2 = sizeOfBlackWhiteBlackRunBothWays((int) otherPattern.getX(), - (int) otherPattern.getY(), - (int) pattern.getX(), - (int) pattern.getY()); - if (Float.isNaN(moduleSizeEst1)) { - return moduleSizeEst2 / 7.0f; - } - if (Float.isNaN(moduleSizeEst2)) { - return moduleSizeEst1 / 7.0f; - } - // Average them, and divide by 7 since we've counted the width of 3 black modules, - // and 1 white and 1 black module on either side. Ergo, divide sum by 14. - return (moduleSizeEst1 + moduleSizeEst2) / 14.0f; - } - - /** - * See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of - * a finder pattern by looking for a black-white-black run from the center in the direction - * of another point (another finder pattern center), and in the opposite direction too. - */ - private float sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, int toY) { - - float result = sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY); - - // Now count other way -- don't run off image though of course - float scale = 1.0f; - int otherToX = fromX - (toX - fromX); - if (otherToX < 0) { - scale = fromX / (float) (fromX - otherToX); - otherToX = 0; - } else if (otherToX >= image.getWidth()) { - scale = (image.getWidth() - 1 - fromX) / (float) (otherToX - fromX); - otherToX = image.getWidth() - 1; - } - int otherToY = (int) (fromY - (toY - fromY) * scale); - - scale = 1.0f; - if (otherToY < 0) { - scale = fromY / (float) (fromY - otherToY); - otherToY = 0; - } else if (otherToY >= image.getHeight()) { - scale = (image.getHeight() - 1 - fromY) / (float) (otherToY - fromY); - otherToY = image.getHeight() - 1; - } - otherToX = (int) (fromX + (otherToX - fromX) * scale); - - result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY); - - // Middle pixel is double-counted this way; subtract 1 - return result - 1.0f; - } - - /** - *

This method traces a line from a point in the image, in the direction towards another point. - * It begins in a black region, and keeps going until it finds white, then black, then white again. - * It reports the distance from the start to this point.

- * - *

This is used when figuring out how wide a finder pattern is, when the finder pattern - * may be skewed or rotated.

- */ - private float sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY) { - // Mild variant of Bresenham's algorithm; - // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm - boolean steep = Math.abs(toY - fromY) > Math.abs(toX - fromX); - if (steep) { - int temp = fromX; - fromX = fromY; - fromY = temp; - temp = toX; - toX = toY; - toY = temp; - } - - int dx = Math.abs(toX - fromX); - int dy = Math.abs(toY - fromY); - int error = -dx / 2; - int xstep = fromX < toX ? 1 : -1; - int ystep = fromY < toY ? 1 : -1; - - // In black pixels, looking for white, first or second time. - int state = 0; - // Loop up until x == toX, but not beyond - int xLimit = toX + xstep; - for (int x = fromX, y = fromY; x != xLimit; x += xstep) { - int realX = steep ? y : x; - int realY = steep ? x : y; - - // Does current pixel mean we have moved white to black or vice versa? - // Scanning black in state 0,2 and white in state 1, so if we find the wrong - // color, advance to next state or end if we are in state 2 already - if ((state == 1) == image.get(realX, realY)) { - if (state == 2) { - return MathUtils.distance(x, y, fromX, fromY); - } - state++; - } - - error += dy; - if (error > 0) { - if (y == toY) { - break; - } - y += ystep; - error -= dx; - } - } - // Found black-white-black; give the benefit of the doubt that the next pixel outside the image - // is "white" so this last point at (toX+xStep,toY) is the right ending. This is really a - // small approximation; (toX+xStep,toY+yStep) might be really correct. Ignore this. - if (state == 2) { - return MathUtils.distance(toX + xstep, toY, fromX, fromY); - } - // else we didn't find even black-white-black; no estimate is really possible - return Float.NaN; - } - - /** - *

Attempts to locate an alignment pattern in a limited region of the image, which is - * guessed to contain it. This method uses {@link AlignmentPattern}.

- * - * @param overallEstModuleSize estimated module size so far - * @param estAlignmentX x coordinate of center of area probably containing alignment pattern - * @param estAlignmentY y coordinate of above - * @param allowanceFactor number of pixels in all directions to search from the center - * @return {@link AlignmentPattern} if found, or null otherwise - * @throws NotFoundException if an unexpected error occurs during detection - */ - protected final AlignmentPattern findAlignmentInRegion(float overallEstModuleSize, - int estAlignmentX, - int estAlignmentY, - float allowanceFactor) - throws NotFoundException { - // Look for an alignment pattern (3 modules in size) around where it - // should be - int allowance = (int) (allowanceFactor * overallEstModuleSize); - int alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance); - int alignmentAreaRightX = Math.min(image.getWidth() - 1, estAlignmentX + allowance); - if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) { - throw NotFoundException.getNotFoundInstance(); - } - - int alignmentAreaTopY = Math.max(0, estAlignmentY - allowance); - int alignmentAreaBottomY = Math.min(image.getHeight() - 1, estAlignmentY + allowance); - if (alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize * 3) { - throw NotFoundException.getNotFoundInstance(); - } - - AlignmentPatternFinder alignmentFinder = - new AlignmentPatternFinder( - image, - alignmentAreaLeftX, - alignmentAreaTopY, - alignmentAreaRightX - alignmentAreaLeftX, - alignmentAreaBottomY - alignmentAreaTopY, - overallEstModuleSize, - resultPointCallback); - return alignmentFinder.find(); - } - -} diff --git a/port_src/core/DONE/qrcode/detector/FinderPattern.java b/port_src/core/DONE/qrcode/detector/FinderPattern.java deleted file mode 100644 index 7d43833..0000000 --- a/port_src/core/DONE/qrcode/detector/FinderPattern.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.detector; - -import com.google.zxing.ResultPoint; - -/** - *

Encapsulates a finder pattern, which are the three square patterns found in - * the corners of QR Codes. It also encapsulates a count of similar finder patterns, - * as a convenience to the finder's bookkeeping.

- * - * @author Sean Owen - */ -public final class FinderPattern extends ResultPoint { - - private final float estimatedModuleSize; - private final int count; - - FinderPattern(float posX, float posY, float estimatedModuleSize) { - this(posX, posY, estimatedModuleSize, 1); - } - - private FinderPattern(float posX, float posY, float estimatedModuleSize, int count) { - super(posX, posY); - this.estimatedModuleSize = estimatedModuleSize; - this.count = count; - } - - public float getEstimatedModuleSize() { - return estimatedModuleSize; - } - - public int getCount() { - return count; - } - - /** - *

Determines if this finder pattern "about equals" a finder pattern at the stated - * position and size -- meaning, it is at nearly the same center with nearly the same size.

- */ - boolean aboutEquals(float moduleSize, float i, float j) { - if (Math.abs(i - getY()) <= moduleSize && Math.abs(j - getX()) <= moduleSize) { - float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize); - return moduleSizeDiff <= 1.0f || moduleSizeDiff <= estimatedModuleSize; - } - return false; - } - - /** - * Combines this object's current estimate of a finder pattern position and module size - * with a new estimate. It returns a new {@code FinderPattern} containing a weighted average - * based on count. - */ - FinderPattern combineEstimate(float i, float j, float newModuleSize) { - int combinedCount = count + 1; - float combinedX = (count * getX() + j) / combinedCount; - float combinedY = (count * getY() + i) / combinedCount; - float combinedModuleSize = (count * estimatedModuleSize + newModuleSize) / combinedCount; - return new FinderPattern(combinedX, combinedY, combinedModuleSize, combinedCount); - } - -} diff --git a/port_src/core/DONE/qrcode/detector/FinderPatternFinder.java b/port_src/core/DONE/qrcode/detector/FinderPatternFinder.java deleted file mode 100755 index 2ab3e86..0000000 --- a/port_src/core/DONE/qrcode/detector/FinderPatternFinder.java +++ /dev/null @@ -1,715 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.detector; - -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPoint; -import com.google.zxing.ResultPointCallback; -import com.google.zxing.common.BitMatrix; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -/** - *

This class attempts to find finder patterns in a QR Code. Finder patterns are the square - * markers at three corners of a QR Code.

- * - *

This class is thread-safe but not reentrant. Each thread must allocate its own object. - * - * @author Sean Owen - */ -public class FinderPatternFinder { - - private static final int CENTER_QUORUM = 2; - private static final EstimatedModuleComparator moduleComparator = new EstimatedModuleComparator(); - protected static final int MIN_SKIP = 3; // 1 pixel/module times 3 modules/center - protected static final int MAX_MODULES = 97; // support up to version 20 for mobile clients - - private final BitMatrix image; - private final List possibleCenters; - private boolean hasSkipped; - private final int[] crossCheckStateCount; - private final ResultPointCallback resultPointCallback; - - /** - *

Creates a finder that will search the image for three finder patterns.

- * - * @param image image to search - */ - public FinderPatternFinder(BitMatrix image) { - this(image, null); - } - - public FinderPatternFinder(BitMatrix image, ResultPointCallback resultPointCallback) { - this.image = image; - this.possibleCenters = new ArrayList<>(); - this.crossCheckStateCount = new int[5]; - this.resultPointCallback = resultPointCallback; - } - - protected final BitMatrix getImage() { - return image; - } - - protected final List getPossibleCenters() { - return possibleCenters; - } - - final FinderPatternInfo find(Map hints) throws NotFoundException { - boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); - int maxI = image.getHeight(); - int maxJ = image.getWidth(); - // We are looking for black/white/black/white/black modules in - // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far - - // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the - // image, and then account for the center being 3 modules in size. This gives the smallest - // number of pixels the center could be, so skip this often. When trying harder, look for all - // QR versions regardless of how dense they are. - int iSkip = (3 * maxI) / (4 * MAX_MODULES); - if (iSkip < MIN_SKIP || tryHarder) { - iSkip = MIN_SKIP; - } - - boolean done = false; - int[] stateCount = new int[5]; - for (int i = iSkip - 1; i < maxI && !done; i += iSkip) { - // Get a row of black/white values - doClearCounts(stateCount); - int currentState = 0; - for (int j = 0; j < maxJ; j++) { - if (image.get(j, i)) { - // Black pixel - if ((currentState & 1) == 1) { // Counting white pixels - currentState++; - } - stateCount[currentState]++; - } else { // White pixel - if ((currentState & 1) == 0) { // Counting black pixels - if (currentState == 4) { // A winner? - if (foundPatternCross(stateCount)) { // Yes - boolean confirmed = handlePossibleCenter(stateCount, i, j); - if (confirmed) { - // Start examining every other line. Checking each line turned out to be too - // expensive and didn't improve performance. - iSkip = 2; - if (hasSkipped) { - done = haveMultiplyConfirmedCenters(); - } else { - int rowSkip = findRowSkip(); - if (rowSkip > stateCount[2]) { - // Skip rows between row of lower confirmed center - // and top of presumed third confirmed center - // but back up a bit to get a full chance of detecting - // it, entire width of center of finder pattern - - // Skip by rowSkip, but back off by stateCount[2] (size of last center - // of pattern we saw) to be conservative, and also back off by iSkip which - // is about to be re-added - i += rowSkip - stateCount[2] - iSkip; - j = maxJ - 1; - } - } - } else { - doShiftCounts2(stateCount); - currentState = 3; - continue; - } - // Clear state to start looking again - currentState = 0; - doClearCounts(stateCount); - } else { // No, shift counts back by two - doShiftCounts2(stateCount); - currentState = 3; - } - } else { - stateCount[++currentState]++; - } - } else { // Counting white pixels - stateCount[currentState]++; - } - } - } - if (foundPatternCross(stateCount)) { - boolean confirmed = handlePossibleCenter(stateCount, i, maxJ); - if (confirmed) { - iSkip = stateCount[0]; - if (hasSkipped) { - // Found a third one - done = haveMultiplyConfirmedCenters(); - } - } - } - } - - FinderPattern[] patternInfo = selectBestPatterns(); - ResultPoint.orderBestPatterns(patternInfo); - - return new FinderPatternInfo(patternInfo); - } - - /** - * Given a count of black/white/black/white/black pixels just seen and an end position, - * figures the location of the center of this run. - */ - private static float centerFromEnd(int[] stateCount, int end) { - return (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0f; - } - - /** - * @param stateCount count of black/white/black/white/black pixels just read - * @return true iff the proportions of the counts is close enough to the 1/1/3/1/1 ratios - * used by finder patterns to be considered a match - */ - protected static boolean foundPatternCross(int[] stateCount) { - int totalModuleSize = 0; - for (int i = 0; i < 5; i++) { - int count = stateCount[i]; - if (count == 0) { - return false; - } - totalModuleSize += count; - } - if (totalModuleSize < 7) { - return false; - } - float moduleSize = totalModuleSize / 7.0f; - float maxVariance = moduleSize / 2.0f; - // Allow less than 50% variance from 1-1-3-1-1 proportions - return - Math.abs(moduleSize - stateCount[0]) < maxVariance && - Math.abs(moduleSize - stateCount[1]) < maxVariance && - Math.abs(3.0f * moduleSize - stateCount[2]) < 3 * maxVariance && - Math.abs(moduleSize - stateCount[3]) < maxVariance && - Math.abs(moduleSize - stateCount[4]) < maxVariance; - } - - /** - * @param stateCount count of black/white/black/white/black pixels just read - * @return true iff the proportions of the counts is close enough to the 1/1/3/1/1 ratios - * used by finder patterns to be considered a match - */ - protected static boolean foundPatternDiagonal(int[] stateCount) { - int totalModuleSize = 0; - for (int i = 0; i < 5; i++) { - int count = stateCount[i]; - if (count == 0) { - return false; - } - totalModuleSize += count; - } - if (totalModuleSize < 7) { - return false; - } - float moduleSize = totalModuleSize / 7.0f; - float maxVariance = moduleSize / 1.333f; - // Allow less than 75% variance from 1-1-3-1-1 proportions - return - Math.abs(moduleSize - stateCount[0]) < maxVariance && - Math.abs(moduleSize - stateCount[1]) < maxVariance && - Math.abs(3.0f * moduleSize - stateCount[2]) < 3 * maxVariance && - Math.abs(moduleSize - stateCount[3]) < maxVariance && - Math.abs(moduleSize - stateCount[4]) < maxVariance; - } - - private int[] getCrossCheckStateCount() { - doClearCounts(crossCheckStateCount); - return crossCheckStateCount; - } - - @Deprecated - protected final void clearCounts(int[] counts) { - doClearCounts(counts); - } - - @Deprecated - protected final void shiftCounts2(int[] stateCount) { - doShiftCounts2(stateCount); - } - - protected static void doClearCounts(int[] counts) { - Arrays.fill(counts, 0); - } - - protected static void doShiftCounts2(int[] stateCount) { - stateCount[0] = stateCount[2]; - stateCount[1] = stateCount[3]; - stateCount[2] = stateCount[4]; - stateCount[3] = 1; - stateCount[4] = 0; - } - - /** - * After a vertical and horizontal scan finds a potential finder pattern, this method - * "cross-cross-cross-checks" by scanning down diagonally through the center of the possible - * finder pattern to see if the same proportion is detected. - * - * @param centerI row where a finder pattern was detected - * @param centerJ center of the section that appears to cross a finder pattern - * @return true if proportions are withing expected limits - */ - private boolean crossCheckDiagonal(int centerI, int centerJ) { - int[] stateCount = getCrossCheckStateCount(); - - // Start counting up, left from center finding black center mass - int i = 0; - while (centerI >= i && centerJ >= i && image.get(centerJ - i, centerI - i)) { - stateCount[2]++; - i++; - } - if (stateCount[2] == 0) { - return false; - } - - // Continue up, left finding white space - while (centerI >= i && centerJ >= i && !image.get(centerJ - i, centerI - i)) { - stateCount[1]++; - i++; - } - if (stateCount[1] == 0) { - return false; - } - - // Continue up, left finding black border - while (centerI >= i && centerJ >= i && image.get(centerJ - i, centerI - i)) { - stateCount[0]++; - i++; - } - if (stateCount[0] == 0) { - return false; - } - - int maxI = image.getHeight(); - int maxJ = image.getWidth(); - - // Now also count down, right from center - i = 1; - while (centerI + i < maxI && centerJ + i < maxJ && image.get(centerJ + i, centerI + i)) { - stateCount[2]++; - i++; - } - - while (centerI + i < maxI && centerJ + i < maxJ && !image.get(centerJ + i, centerI + i)) { - stateCount[3]++; - i++; - } - if (stateCount[3] == 0) { - return false; - } - - while (centerI + i < maxI && centerJ + i < maxJ && image.get(centerJ + i, centerI + i)) { - stateCount[4]++; - i++; - } - if (stateCount[4] == 0) { - return false; - } - - return foundPatternDiagonal(stateCount); - } - - /** - *

After a horizontal scan finds a potential finder pattern, this method - * "cross-checks" by scanning down vertically through the center of the possible - * finder pattern to see if the same proportion is detected.

- * - * @param startI row where a finder pattern was detected - * @param centerJ center of the section that appears to cross a finder pattern - * @param maxCount maximum reasonable number of modules that should be - * observed in any reading state, based on the results of the horizontal scan - * @return vertical center of finder pattern, or {@link Float#NaN} if not found - */ - private float crossCheckVertical(int startI, int centerJ, int maxCount, - int originalStateCountTotal) { - BitMatrix image = this.image; - - int maxI = image.getHeight(); - int[] stateCount = getCrossCheckStateCount(); - - // Start counting up from center - int i = startI; - while (i >= 0 && image.get(centerJ, i)) { - stateCount[2]++; - i--; - } - if (i < 0) { - return Float.NaN; - } - while (i >= 0 && !image.get(centerJ, i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i--; - } - // If already too many modules in this state or ran off the edge: - if (i < 0 || stateCount[1] > maxCount) { - return Float.NaN; - } - while (i >= 0 && image.get(centerJ, i) && stateCount[0] <= maxCount) { - stateCount[0]++; - i--; - } - if (stateCount[0] > maxCount) { - return Float.NaN; - } - - // Now also count down from center - i = startI + 1; - while (i < maxI && image.get(centerJ, i)) { - stateCount[2]++; - i++; - } - if (i == maxI) { - return Float.NaN; - } - while (i < maxI && !image.get(centerJ, i) && stateCount[3] < maxCount) { - stateCount[3]++; - i++; - } - if (i == maxI || stateCount[3] >= maxCount) { - return Float.NaN; - } - while (i < maxI && image.get(centerJ, i) && stateCount[4] < maxCount) { - stateCount[4]++; - i++; - } - if (stateCount[4] >= maxCount) { - return Float.NaN; - } - - // If we found a finder-pattern-like section, but its size is more than 40% different than - // the original, assume it's a false positive - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + - stateCount[4]; - if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { - return Float.NaN; - } - - return foundPatternCross(stateCount) ? centerFromEnd(stateCount, i) : Float.NaN; - } - - /** - *

Like {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical, - * except it reads horizontally instead of vertically. This is used to cross-cross - * check a vertical cross check and locate the real center of the alignment pattern.

- */ - private float crossCheckHorizontal(int startJ, int centerI, int maxCount, - int originalStateCountTotal) { - BitMatrix image = this.image; - - int maxJ = image.getWidth(); - int[] stateCount = getCrossCheckStateCount(); - - int j = startJ; - while (j >= 0 && image.get(j, centerI)) { - stateCount[2]++; - j--; - } - if (j < 0) { - return Float.NaN; - } - while (j >= 0 && !image.get(j, centerI) && stateCount[1] <= maxCount) { - stateCount[1]++; - j--; - } - if (j < 0 || stateCount[1] > maxCount) { - return Float.NaN; - } - while (j >= 0 && image.get(j, centerI) && stateCount[0] <= maxCount) { - stateCount[0]++; - j--; - } - if (stateCount[0] > maxCount) { - return Float.NaN; - } - - j = startJ + 1; - while (j < maxJ && image.get(j, centerI)) { - stateCount[2]++; - j++; - } - if (j == maxJ) { - return Float.NaN; - } - while (j < maxJ && !image.get(j, centerI) && stateCount[3] < maxCount) { - stateCount[3]++; - j++; - } - if (j == maxJ || stateCount[3] >= maxCount) { - return Float.NaN; - } - while (j < maxJ && image.get(j, centerI) && stateCount[4] < maxCount) { - stateCount[4]++; - j++; - } - if (stateCount[4] >= maxCount) { - return Float.NaN; - } - - // If we found a finder-pattern-like section, but its size is significantly different than - // the original, assume it's a false positive - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + - stateCount[4]; - if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal) { - return Float.NaN; - } - - return foundPatternCross(stateCount) ? centerFromEnd(stateCount, j) : Float.NaN; - } - - /** - * @param stateCount reading state module counts from horizontal scan - * @param i row where finder pattern may be found - * @param j end of possible finder pattern in row - * @param pureBarcode ignored - * @return true if a finder pattern candidate was found this time - * @deprecated only exists for backwards compatibility - * @see #handlePossibleCenter(int[], int, int) - */ - @Deprecated - protected final boolean handlePossibleCenter(int[] stateCount, int i, int j, boolean pureBarcode) { - return handlePossibleCenter(stateCount, i, j); - } - - /** - *

This is called when a horizontal scan finds a possible alignment pattern. It will - * cross check with a vertical scan, and if successful, will, ah, cross-cross-check - * with another horizontal scan. This is needed primarily to locate the real horizontal - * center of the pattern in cases of extreme skew. - * And then we cross-cross-cross check with another diagonal scan.

- * - *

If that succeeds the finder pattern location is added to a list that tracks - * the number of times each location has been nearly-matched as a finder pattern. - * Each additional find is more evidence that the location is in fact a finder - * pattern center - * - * @param stateCount reading state module counts from horizontal scan - * @param i row where finder pattern may be found - * @param j end of possible finder pattern in row - * @return true if a finder pattern candidate was found this time - */ - protected final boolean handlePossibleCenter(int[] stateCount, int i, int j) { - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + - stateCount[4]; - float centerJ = centerFromEnd(stateCount, j); - float centerI = crossCheckVertical(i, (int) centerJ, stateCount[2], stateCountTotal); - if (!Float.isNaN(centerI)) { - // Re-cross check - centerJ = crossCheckHorizontal((int) centerJ, (int) centerI, stateCount[2], stateCountTotal); - if (!Float.isNaN(centerJ) && crossCheckDiagonal((int) centerI, (int) centerJ)) { - float estimatedModuleSize = stateCountTotal / 7.0f; - boolean found = false; - for (int index = 0; index < possibleCenters.size(); index++) { - FinderPattern center = possibleCenters.get(index); - // Look for about the same center and module size: - if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) { - possibleCenters.set(index, center.combineEstimate(centerI, centerJ, estimatedModuleSize)); - found = true; - break; - } - } - if (!found) { - FinderPattern point = new FinderPattern(centerJ, centerI, estimatedModuleSize); - possibleCenters.add(point); - if (resultPointCallback != null) { - resultPointCallback.foundPossibleResultPoint(point); - } - } - return true; - } - } - return false; - } - - /** - * @return number of rows we could safely skip during scanning, based on the first - * two finder patterns that have been located. In some cases their position will - * allow us to infer that the third pattern must lie below a certain point farther - * down in the image. - */ - private int findRowSkip() { - int max = possibleCenters.size(); - if (max <= 1) { - return 0; - } - ResultPoint firstConfirmedCenter = null; - for (FinderPattern center : possibleCenters) { - if (center.getCount() >= CENTER_QUORUM) { - if (firstConfirmedCenter == null) { - firstConfirmedCenter = center; - } else { - // We have two confirmed centers - // How far down can we skip before resuming looking for the next - // pattern? In the worst case, only the difference between the - // difference in the x / y coordinates of the two centers. - // This is the case where you find top left last. - hasSkipped = true; - return (int) (Math.abs(firstConfirmedCenter.getX() - center.getX()) - - Math.abs(firstConfirmedCenter.getY() - center.getY())) / 2; - } - } - } - return 0; - } - - /** - * @return true iff we have found at least 3 finder patterns that have been detected - * at least {@link #CENTER_QUORUM} times each, and, the estimated module size of the - * candidates is "pretty similar" - */ - private boolean haveMultiplyConfirmedCenters() { - int confirmedCount = 0; - float totalModuleSize = 0.0f; - int max = possibleCenters.size(); - for (FinderPattern pattern : possibleCenters) { - if (pattern.getCount() >= CENTER_QUORUM) { - confirmedCount++; - totalModuleSize += pattern.getEstimatedModuleSize(); - } - } - if (confirmedCount < 3) { - return false; - } - // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive" - // and that we need to keep looking. We detect this by asking if the estimated module sizes - // vary too much. We arbitrarily say that when the total deviation from average exceeds - // 5% of the total module size estimates, it's too much. - float average = totalModuleSize / max; - float totalDeviation = 0.0f; - for (FinderPattern pattern : possibleCenters) { - totalDeviation += Math.abs(pattern.getEstimatedModuleSize() - average); - } - return totalDeviation <= 0.05f * totalModuleSize; - } - - /** - * Get square of distance between a and b. - */ - private static double squaredDistance(FinderPattern a, FinderPattern b) { - double x = a.getX() - b.getX(); - double y = a.getY() - b.getY(); - return x * x + y * y; - } - - /** - * @return the 3 best {@link FinderPattern}s from our list of candidates. The "best" are - * those have similar module size and form a shape closer to a isosceles right triangle. - * @throws NotFoundException if 3 such finder patterns do not exist - */ - private FinderPattern[] selectBestPatterns() throws NotFoundException { - - int startSize = possibleCenters.size(); - if (startSize < 3) { - // Couldn't find enough finder patterns - throw NotFoundException.getNotFoundInstance(); - } - - possibleCenters.sort(moduleComparator); - - double distortion = Double.MAX_VALUE; - FinderPattern[] bestPatterns = new FinderPattern[3]; - - for (int i = 0; i < possibleCenters.size() - 2; i++) { - FinderPattern fpi = possibleCenters.get(i); - float minModuleSize = fpi.getEstimatedModuleSize(); - - for (int j = i + 1; j < possibleCenters.size() - 1; j++) { - FinderPattern fpj = possibleCenters.get(j); - double squares0 = squaredDistance(fpi, fpj); - - for (int k = j + 1; k < possibleCenters.size(); k++) { - FinderPattern fpk = possibleCenters.get(k); - float maxModuleSize = fpk.getEstimatedModuleSize(); - if (maxModuleSize > minModuleSize * 1.4f) { - // module size is not similar - continue; - } - - double a = squares0; - double b = squaredDistance(fpj, fpk); - double c = squaredDistance(fpi, fpk); - - // sorts ascending - inlined - if (a < b) { - if (b > c) { - if (a < c) { - double temp = b; - b = c; - c = temp; - } else { - double temp = a; - a = c; - c = b; - b = temp; - } - } - } else { - if (b < c) { - if (a < c) { - double temp = a; - a = b; - b = temp; - } else { - double temp = a; - a = b; - b = c; - c = temp; - } - } else { - double temp = a; - a = c; - c = temp; - } - } - - // a^2 + b^2 = c^2 (Pythagorean theorem), and a = b (isosceles triangle). - // Since any right triangle satisfies the formula c^2 - b^2 - a^2 = 0, - // we need to check both two equal sides separately. - // The value of |c^2 - 2 * b^2| + |c^2 - 2 * a^2| increases as dissimilarity - // from isosceles right triangle. - double d = Math.abs(c - 2 * b) + Math.abs(c - 2 * a); - if (d < distortion) { - distortion = d; - bestPatterns[0] = fpi; - bestPatterns[1] = fpj; - bestPatterns[2] = fpk; - } - } - } - } - - if (distortion == Double.MAX_VALUE) { - throw NotFoundException.getNotFoundInstance(); - } - - return bestPatterns; - } - - /** - *

Orders by {@link FinderPattern#getEstimatedModuleSize()}

- */ - private static final class EstimatedModuleComparator implements Comparator, Serializable { - @Override - public int compare(FinderPattern center1, FinderPattern center2) { - return Float.compare(center1.getEstimatedModuleSize(), center2.getEstimatedModuleSize()); - } - } - -} diff --git a/port_src/core/DONE/qrcode/detector/FinderPatternInfo.java b/port_src/core/DONE/qrcode/detector/FinderPatternInfo.java deleted file mode 100644 index 3c34010..0000000 --- a/port_src/core/DONE/qrcode/detector/FinderPatternInfo.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.detector; - -/** - *

Encapsulates information about finder patterns in an image, including the location of - * the three finder patterns, and their estimated module size.

- * - * @author Sean Owen - */ -public final class FinderPatternInfo { - - private final FinderPattern bottomLeft; - private final FinderPattern topLeft; - private final FinderPattern topRight; - - public FinderPatternInfo(FinderPattern[] patternCenters) { - this.bottomLeft = patternCenters[0]; - this.topLeft = patternCenters[1]; - this.topRight = patternCenters[2]; - } - - public FinderPattern getBottomLeft() { - return bottomLeft; - } - - public FinderPattern getTopLeft() { - return topLeft; - } - - public FinderPattern getTopRight() { - return topRight; - } - -} diff --git a/port_src/core/DONE/qrcode/encoder/BlockPair.java b/port_src/core/DONE/qrcode/encoder/BlockPair.java deleted file mode 100644 index 5714d9c..0000000 --- a/port_src/core/DONE/qrcode/encoder/BlockPair.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.encoder; - -final class BlockPair { - - private final byte[] dataBytes; - private final byte[] errorCorrectionBytes; - - BlockPair(byte[] data, byte[] errorCorrection) { - dataBytes = data; - errorCorrectionBytes = errorCorrection; - } - - public byte[] getDataBytes() { - return dataBytes; - } - - public byte[] getErrorCorrectionBytes() { - return errorCorrectionBytes; - } - -} diff --git a/port_src/core/DONE/qrcode/encoder/ByteMatrix.java b/port_src/core/DONE/qrcode/encoder/ByteMatrix.java deleted file mode 100644 index 35f344c..0000000 --- a/port_src/core/DONE/qrcode/encoder/ByteMatrix.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -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 - * -1, 0, and 1, I'm going to use less memory and go with bytes. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class ByteMatrix { - - private final byte[][] bytes; - private final int width; - private final int height; - - public ByteMatrix(int width, int height) { - bytes = new byte[height][width]; - this.width = width; - this.height = height; - } - - public int getHeight() { - return height; - } - - public int getWidth() { - return width; - } - - public byte get(int x, int y) { - return bytes[y][x]; - } - - /** - * @return an internal representation as bytes, in row-major order. array[y][x] represents point (x,y) - */ - public byte[][] getArray() { - return bytes; - } - - public void set(int x, int y, byte value) { - bytes[y][x] = value; - } - - public void set(int x, int y, int value) { - bytes[y][x] = (byte) value; - } - - public void set(int x, int y, boolean value) { - bytes[y][x] = (byte) (value ? 1 : 0); - } - - public void clear(byte value) { - for (byte[] aByte : bytes) { - Arrays.fill(aByte, value); - } - } - - @Override - public String toString() { - StringBuilder result = new StringBuilder(2 * width * height + 2); - for (int y = 0; y < height; ++y) { - byte[] bytesY = bytes[y]; - for (int x = 0; x < width; ++x) { - switch (bytesY[x]) { - case 0: - result.append(" 0"); - break; - case 1: - result.append(" 1"); - break; - default: - result.append(" "); - break; - } - } - result.append('\n'); - } - return result.toString(); - } - -} diff --git a/port_src/core/DONE/qrcode/encoder/Encoder.java b/port_src/core/DONE/qrcode/encoder/Encoder.java deleted file mode 100644 index cc09320..0000000 --- a/port_src/core/DONE/qrcode/encoder/Encoder.java +++ /dev/null @@ -1,637 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.encoder; - -import com.google.zxing.EncodeHintType; -import com.google.zxing.WriterException; -import com.google.zxing.common.BitArray; -import com.google.zxing.common.StringUtils; -import com.google.zxing.common.CharacterSetECI; -import com.google.zxing.common.reedsolomon.GenericGF; -import com.google.zxing.common.reedsolomon.ReedSolomonEncoder; -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; -import com.google.zxing.qrcode.decoder.Mode; -import com.google.zxing.qrcode.decoder.Version; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author dswitkin@google.com (Daniel Switkin) - ported from C++ - */ -public final class Encoder { - - // The original table is defined in the table 5 of JISX0510:2004 (p.19). - private static final int[] ALPHANUMERIC_TABLE = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x00-0x0f - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x10-0x1f - 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, // 0x20-0x2f - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, // 0x30-0x3f - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, // 0x40-0x4f - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, // 0x50-0x5f - }; - - static final Charset DEFAULT_BYTE_MODE_ENCODING = StandardCharsets.ISO_8859_1; - - private Encoder() { - } - - // The mask penalty calculation is complicated. See Table 21 of JISX0510:2004 (p.45) for details. - // Basically it applies four rules and summate all penalties. - private static int calculateMaskPenalty(ByteMatrix matrix) { - return MaskUtil.applyMaskPenaltyRule1(matrix) - + MaskUtil.applyMaskPenaltyRule2(matrix) - + MaskUtil.applyMaskPenaltyRule3(matrix) - + MaskUtil.applyMaskPenaltyRule4(matrix); - } - - /** - * @param content text to encode - * @param ecLevel error correction level to use - * @return {@link QRCode} representing the encoded QR code - * @throws WriterException if encoding can't succeed, because of for example invalid content - * or configuration - */ - public static QRCode encode(String content, ErrorCorrectionLevel ecLevel) throws WriterException { - return encode(content, ecLevel, null); - } - - public static QRCode encode(String content, - ErrorCorrectionLevel ecLevel, - Map hints) throws WriterException { - - Version version; - BitArray headerAndDataBits; - Mode mode; - - boolean hasGS1FormatHint = hints != null && hints.containsKey(EncodeHintType.GS1_FORMAT) && - Boolean.parseBoolean(hints.get(EncodeHintType.GS1_FORMAT).toString()); - boolean hasCompactionHint = hints != null && hints.containsKey(EncodeHintType.QR_COMPACT) && - Boolean.parseBoolean(hints.get(EncodeHintType.QR_COMPACT).toString()); - - // Determine what character encoding has been specified by the caller, if any - Charset encoding = DEFAULT_BYTE_MODE_ENCODING; - boolean hasEncodingHint = hints != null && hints.containsKey(EncodeHintType.CHARACTER_SET); - if (hasEncodingHint) { - encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString()); - } - - if (hasCompactionHint) { - mode = Mode.BYTE; - - Charset priorityEncoding = encoding.equals(DEFAULT_BYTE_MODE_ENCODING) ? null : encoding; - MinimalEncoder.ResultList rn = MinimalEncoder.encode(content, null, priorityEncoding, hasGS1FormatHint, ecLevel); - - headerAndDataBits = new BitArray(); - rn.getBits(headerAndDataBits); - version = rn.getVersion(); - - } else { - - // Pick an encoding mode appropriate for the content. Note that this will not attempt to use - // multiple modes / segments even if that were more efficient. - mode = chooseMode(content, encoding); - - // This will store the header information, like mode and - // length, as well as "header" segments like an ECI segment. - BitArray headerBits = new BitArray(); - - // Append ECI segment if applicable - if (mode == Mode.BYTE && hasEncodingHint) { - CharacterSetECI eci = CharacterSetECI.getCharacterSetECI(encoding); - if (eci != null) { - appendECI(eci, headerBits); - } - } - - // Append the FNC1 mode header for GS1 formatted data if applicable - if (hasGS1FormatHint) { - // 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 - appendModeInfo(mode, headerBits); - - // Collect data within the main segment, separately, to count its size if needed. Don't add it to - // main payload yet. - BitArray dataBits = new BitArray(); - appendBytes(content, mode, dataBits, encoding); - - if (hints != null && hints.containsKey(EncodeHintType.QR_VERSION)) { - int versionNumber = Integer.parseInt(hints.get(EncodeHintType.QR_VERSION).toString()); - version = Version.getVersionForNumber(versionNumber); - int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, version); - if (!willFit(bitsNeeded, version, ecLevel)) { - throw new WriterException("Data too big for requested version"); - } - } else { - version = recommendVersion(ecLevel, mode, headerBits, dataBits); - } - - headerAndDataBits = new BitArray(); - headerAndDataBits.appendBitArray(headerBits); - // Find "length" of main segment and write it - int numLetters = mode == Mode.BYTE ? dataBits.getSizeInBytes() : content.length(); - appendLengthInfo(numLetters, version, mode, headerAndDataBits); - // Put data together into the overall payload - headerAndDataBits.appendBitArray(dataBits); - } - - Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel); - int numDataBytes = version.getTotalCodewords() - ecBlocks.getTotalECCodewords(); - - // Terminate the bits properly. - terminateBits(numDataBytes, headerAndDataBits); - - // Interleave data bits with error correction code. - BitArray finalBits = interleaveWithECBytes(headerAndDataBits, - version.getTotalCodewords(), - numDataBytes, - ecBlocks.getNumBlocks()); - - QRCode qrCode = new QRCode(); - - qrCode.setECLevel(ecLevel); - qrCode.setMode(mode); - qrCode.setVersion(version); - - // Choose the mask pattern and set to "qrCode". - int dimension = version.getDimensionForVersion(); - ByteMatrix matrix = new ByteMatrix(dimension, dimension); - - // 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); - - // Build the matrix and set it to "qrCode". - MatrixUtil.buildMatrix(finalBits, ecLevel, version, maskPattern, matrix); - qrCode.setMatrix(matrix); - - return qrCode; - } - - /** - * Decides the smallest version of QR code that will contain all of the provided data. - * - * @throws WriterException if the data cannot fit in any version - */ - private static Version recommendVersion(ErrorCorrectionLevel ecLevel, - Mode mode, - BitArray headerBits, - BitArray dataBits) throws WriterException { - // Hard part: need to know version to know how many bits length takes. But need to know how many - // bits it takes to know version. First we take a guess at version by assuming version will be - // the minimum, 1: - int provisionalBitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, Version.getVersionForNumber(1)); - Version provisionalVersion = chooseVersion(provisionalBitsNeeded, ecLevel); - - // Use that guess to calculate the right version. I am still not sure this works in 100% of cases. - int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, provisionalVersion); - return chooseVersion(bitsNeeded, ecLevel); - } - - private static int calculateBitsNeeded(Mode mode, - BitArray headerBits, - BitArray dataBits, - Version version) { - return headerBits.getSize() + mode.getCharacterCountBits(version) + dataBits.getSize(); - } - - /** - * @return the code point of the table used in alphanumeric mode or - * -1 if there is no corresponding code in the table. - */ - static int getAlphanumericCode(int code) { - if (code < ALPHANUMERIC_TABLE.length) { - return ALPHANUMERIC_TABLE[code]; - } - return -1; - } - - public static Mode chooseMode(String content) { - return chooseMode(content, null); - } - - /** - * Choose the best mode by examining the content. Note that 'encoding' is used as a hint; - * if it is Shift_JIS, and the input is only double-byte Kanji, then we return {@link Mode#KANJI}. - */ - private static Mode chooseMode(String content, Charset encoding) { - if (StringUtils.SHIFT_JIS_CHARSET.equals(encoding) && isOnlyDoubleByteKanji(content)) { - // Choose Kanji mode if all input are double-byte characters - return Mode.KANJI; - } - boolean hasNumeric = false; - boolean hasAlphanumeric = false; - for (int i = 0; i < content.length(); ++i) { - char c = content.charAt(i); - if (c >= '0' && c <= '9') { - hasNumeric = true; - } else if (getAlphanumericCode(c) != -1) { - hasAlphanumeric = true; - } else { - return Mode.BYTE; - } - } - if (hasAlphanumeric) { - return Mode.ALPHANUMERIC; - } - if (hasNumeric) { - return Mode.NUMERIC; - } - return Mode.BYTE; - } - - static boolean isOnlyDoubleByteKanji(String content) { - byte[] bytes = content.getBytes(StringUtils.SHIFT_JIS_CHARSET); - int length = bytes.length; - if (length % 2 != 0) { - return false; - } - for (int i = 0; i < length; i += 2) { - int byte1 = bytes[i] & 0xFF; - if ((byte1 < 0x81 || byte1 > 0x9F) && (byte1 < 0xE0 || byte1 > 0xEB)) { - return false; - } - } - return true; - } - - private static int chooseMaskPattern(BitArray bits, - ErrorCorrectionLevel ecLevel, - Version version, - ByteMatrix matrix) throws WriterException { - - int minPenalty = Integer.MAX_VALUE; // Lower penalty is better. - int bestMaskPattern = -1; - // We try all mask patterns to choose the best one. - for (int maskPattern = 0; maskPattern < QRCode.NUM_MASK_PATTERNS; maskPattern++) { - MatrixUtil.buildMatrix(bits, ecLevel, version, maskPattern, matrix); - int penalty = calculateMaskPenalty(matrix); - if (penalty < minPenalty) { - minPenalty = penalty; - bestMaskPattern = maskPattern; - } - } - return bestMaskPattern; - } - - private static Version chooseVersion(int numInputBits, ErrorCorrectionLevel ecLevel) throws WriterException { - for (int versionNum = 1; versionNum <= 40; versionNum++) { - Version version = Version.getVersionForNumber(versionNum); - if (willFit(numInputBits, version, ecLevel)) { - return version; - } - } - throw new WriterException("Data too big"); - } - - /** - * @return true if the number of input bits will fit in a code with the specified version and - * error correction level. - */ - static boolean willFit(int numInputBits, Version version, ErrorCorrectionLevel ecLevel) { - // In the following comments, we use numbers of Version 7-H. - // numBytes = 196 - int numBytes = version.getTotalCodewords(); - // getNumECBytes = 130 - Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel); - int numEcBytes = ecBlocks.getTotalECCodewords(); - // getNumDataBytes = 196 - 130 = 66 - int numDataBytes = numBytes - numEcBytes; - int totalInputBytes = (numInputBits + 7) / 8; - return numDataBytes >= totalInputBytes; - } - - /** - * Terminate bits as described in 8.4.8 and 8.4.9 of JISX0510:2004 (p.24). - */ - static void terminateBits(int numDataBytes, BitArray bits) throws WriterException { - int capacity = numDataBytes * 8; - if (bits.getSize() > capacity) { - throw new WriterException("data bits cannot fit in the QR Code" + bits.getSize() + " > " + - capacity); - } - // Append Mode.TERMINATE if there is enough space (value is 0000) - for (int i = 0; i < 4 && bits.getSize() < capacity; ++i) { - bits.appendBit(false); - } - // Append termination bits. See 8.4.8 of JISX0510:2004 (p.24) for details. - // If the last byte isn't 8-bit aligned, we'll add padding bits. - int numBitsInLastByte = bits.getSize() & 0x07; - if (numBitsInLastByte > 0) { - for (int i = numBitsInLastByte; i < 8; i++) { - bits.appendBit(false); - } - } - // If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24). - int numPaddingBytes = numDataBytes - bits.getSizeInBytes(); - for (int i = 0; i < numPaddingBytes; ++i) { - bits.appendBits((i & 0x01) == 0 ? 0xEC : 0x11, 8); - } - if (bits.getSize() != capacity) { - throw new WriterException("Bits size does not equal capacity"); - } - } - - /** - * Get number of data bytes and number of error correction bytes for block id "blockID". Store - * the result in "numDataBytesInBlock", and "numECBytesInBlock". See table 12 in 8.5.1 of - * JISX0510:2004 (p.30) - */ - static void getNumDataBytesAndNumECBytesForBlockID(int numTotalBytes, - int numDataBytes, - int numRSBlocks, - int blockID, - int[] numDataBytesInBlock, - int[] numECBytesInBlock) throws WriterException { - if (blockID >= numRSBlocks) { - throw new WriterException("Block ID too large"); - } - // numRsBlocksInGroup2 = 196 % 5 = 1 - int numRsBlocksInGroup2 = numTotalBytes % numRSBlocks; - // numRsBlocksInGroup1 = 5 - 1 = 4 - int numRsBlocksInGroup1 = numRSBlocks - numRsBlocksInGroup2; - // numTotalBytesInGroup1 = 196 / 5 = 39 - int numTotalBytesInGroup1 = numTotalBytes / numRSBlocks; - // numTotalBytesInGroup2 = 39 + 1 = 40 - int numTotalBytesInGroup2 = numTotalBytesInGroup1 + 1; - // numDataBytesInGroup1 = 66 / 5 = 13 - int numDataBytesInGroup1 = numDataBytes / numRSBlocks; - // numDataBytesInGroup2 = 13 + 1 = 14 - int numDataBytesInGroup2 = numDataBytesInGroup1 + 1; - // numEcBytesInGroup1 = 39 - 13 = 26 - int numEcBytesInGroup1 = numTotalBytesInGroup1 - numDataBytesInGroup1; - // numEcBytesInGroup2 = 40 - 14 = 26 - int numEcBytesInGroup2 = numTotalBytesInGroup2 - numDataBytesInGroup2; - // Sanity checks. - // 26 = 26 - if (numEcBytesInGroup1 != numEcBytesInGroup2) { - throw new WriterException("EC bytes mismatch"); - } - // 5 = 4 + 1. - if (numRSBlocks != numRsBlocksInGroup1 + numRsBlocksInGroup2) { - throw new WriterException("RS blocks mismatch"); - } - // 196 = (13 + 26) * 4 + (14 + 26) * 1 - if (numTotalBytes != - ((numDataBytesInGroup1 + numEcBytesInGroup1) * - numRsBlocksInGroup1) + - ((numDataBytesInGroup2 + numEcBytesInGroup2) * - numRsBlocksInGroup2)) { - throw new WriterException("Total bytes mismatch"); - } - - if (blockID < numRsBlocksInGroup1) { - numDataBytesInBlock[0] = numDataBytesInGroup1; - numECBytesInBlock[0] = numEcBytesInGroup1; - } else { - numDataBytesInBlock[0] = numDataBytesInGroup2; - numECBytesInBlock[0] = numEcBytesInGroup2; - } - } - - /** - * Interleave "bits" with corresponding error correction bytes. On success, store the result in - * "result". The interleave rule is complicated. See 8.6 of JISX0510:2004 (p.37) for details. - */ - static BitArray interleaveWithECBytes(BitArray bits, - int numTotalBytes, - int numDataBytes, - int numRSBlocks) throws WriterException { - - // "bits" must have "getNumDataBytes" bytes of data. - if (bits.getSizeInBytes() != numDataBytes) { - throw new WriterException("Number of bits and data bytes does not match"); - } - - // Step 1. Divide data bytes into blocks and generate error correction bytes for them. We'll - // store the divided data bytes blocks and error correction bytes blocks into "blocks". - int dataBytesOffset = 0; - int maxNumDataBytes = 0; - int maxNumEcBytes = 0; - - // Since, we know the number of reedsolmon blocks, we can initialize the vector with the number. - Collection blocks = new ArrayList<>(numRSBlocks); - - for (int i = 0; i < numRSBlocks; ++i) { - int[] numDataBytesInBlock = new int[1]; - int[] numEcBytesInBlock = new int[1]; - getNumDataBytesAndNumECBytesForBlockID( - numTotalBytes, numDataBytes, numRSBlocks, i, - numDataBytesInBlock, numEcBytesInBlock); - - int size = numDataBytesInBlock[0]; - byte[] dataBytes = new byte[size]; - bits.toBytes(8 * dataBytesOffset, dataBytes, 0, size); - byte[] ecBytes = generateECBytes(dataBytes, numEcBytesInBlock[0]); - blocks.add(new BlockPair(dataBytes, ecBytes)); - - maxNumDataBytes = Math.max(maxNumDataBytes, size); - maxNumEcBytes = Math.max(maxNumEcBytes, ecBytes.length); - dataBytesOffset += numDataBytesInBlock[0]; - } - if (numDataBytes != dataBytesOffset) { - throw new WriterException("Data bytes does not match offset"); - } - - BitArray result = new BitArray(); - - // First, place data blocks. - for (int i = 0; i < maxNumDataBytes; ++i) { - for (BlockPair block : blocks) { - byte[] dataBytes = block.getDataBytes(); - if (i < dataBytes.length) { - result.appendBits(dataBytes[i], 8); - } - } - } - // Then, place error correction blocks. - for (int i = 0; i < maxNumEcBytes; ++i) { - for (BlockPair block : blocks) { - byte[] ecBytes = block.getErrorCorrectionBytes(); - if (i < ecBytes.length) { - result.appendBits(ecBytes[i], 8); - } - } - } - if (numTotalBytes != result.getSizeInBytes()) { // Should be same. - throw new WriterException("Interleaving error: " + numTotalBytes + " and " + - result.getSizeInBytes() + " differ."); - } - - return result; - } - - static byte[] generateECBytes(byte[] dataBytes, int numEcBytesInBlock) { - int numDataBytes = dataBytes.length; - int[] toEncode = new int[numDataBytes + numEcBytesInBlock]; - for (int i = 0; i < numDataBytes; i++) { - toEncode[i] = dataBytes[i] & 0xFF; - } - new ReedSolomonEncoder(GenericGF.QR_CODE_FIELD_256).encode(toEncode, numEcBytesInBlock); - - byte[] ecBytes = new byte[numEcBytesInBlock]; - for (int i = 0; i < numEcBytesInBlock; i++) { - ecBytes[i] = (byte) toEncode[numDataBytes + i]; - } - return ecBytes; - } - - /** - * Append mode info. On success, store the result in "bits". - */ - static void appendModeInfo(Mode mode, BitArray bits) { - bits.appendBits(mode.getBits(), 4); - } - - - /** - * Append length info. On success, store the result in "bits". - */ - static void appendLengthInfo(int numLetters, Version version, Mode mode, BitArray bits) throws WriterException { - int numBits = mode.getCharacterCountBits(version); - if (numLetters >= (1 << numBits)) { - throw new WriterException(numLetters + " is bigger than " + ((1 << numBits) - 1)); - } - bits.appendBits(numLetters, numBits); - } - - /** - * Append "bytes" in "mode" mode (encoding) into "bits". On success, store the result in "bits". - */ - static void appendBytes(String content, - Mode mode, - BitArray bits, - Charset encoding) throws WriterException { - switch (mode) { - case NUMERIC: - appendNumericBytes(content, bits); - break; - case ALPHANUMERIC: - appendAlphanumericBytes(content, bits); - break; - case BYTE: - append8BitBytes(content, bits, encoding); - break; - case KANJI: - appendKanjiBytes(content, bits); - break; - default: - throw new WriterException("Invalid mode: " + mode); - } - } - - static void appendNumericBytes(CharSequence content, BitArray bits) { - int length = content.length(); - int i = 0; - while (i < length) { - int num1 = content.charAt(i) - '0'; - if (i + 2 < length) { - // Encode three numeric letters in ten bits. - int num2 = content.charAt(i + 1) - '0'; - int num3 = content.charAt(i + 2) - '0'; - bits.appendBits(num1 * 100 + num2 * 10 + num3, 10); - i += 3; - } else if (i + 1 < length) { - // Encode two numeric letters in seven bits. - int num2 = content.charAt(i + 1) - '0'; - bits.appendBits(num1 * 10 + num2, 7); - i += 2; - } else { - // Encode one numeric letter in four bits. - bits.appendBits(num1, 4); - i++; - } - } - } - - static void appendAlphanumericBytes(CharSequence content, BitArray bits) throws WriterException { - int length = content.length(); - int i = 0; - while (i < length) { - int code1 = getAlphanumericCode(content.charAt(i)); - if (code1 == -1) { - throw new WriterException(); - } - if (i + 1 < length) { - int code2 = getAlphanumericCode(content.charAt(i + 1)); - if (code2 == -1) { - throw new WriterException(); - } - // Encode two alphanumeric letters in 11 bits. - bits.appendBits(code1 * 45 + code2, 11); - i += 2; - } else { - // Encode one alphanumeric letter in six bits. - bits.appendBits(code1, 6); - i++; - } - } - } - - static void append8BitBytes(String content, BitArray bits, Charset encoding) { - byte[] bytes = content.getBytes(encoding); - for (byte b : bytes) { - bits.appendBits(b, 8); - } - } - - static void appendKanjiBytes(String content, BitArray bits) throws WriterException { - byte[] bytes = content.getBytes(StringUtils.SHIFT_JIS_CHARSET); - if (bytes.length % 2 != 0) { - 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 byte2 = bytes[i + 1] & 0xFF; - int code = (byte1 << 8) | byte2; - int subtracted = -1; - if (code >= 0x8140 && code <= 0x9ffc) { - subtracted = code - 0x8140; - } else if (code >= 0xe040 && code <= 0xebbf) { - subtracted = code - 0xc140; - } - if (subtracted == -1) { - throw new WriterException("Invalid byte sequence"); - } - int encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff); - bits.appendBits(encoded, 13); - } - } - - private static void appendECI(CharacterSetECI eci, BitArray bits) { - bits.appendBits(Mode.ECI.getBits(), 4); - // This is correct for values up to 127, which is all we need now. - bits.appendBits(eci.getValue(), 8); - } - -} diff --git a/port_src/core/DONE/qrcode/encoder/MaskUtil.java b/port_src/core/DONE/qrcode/encoder/MaskUtil.java deleted file mode 100644 index 568f6ff..0000000 --- a/port_src/core/DONE/qrcode/encoder/MaskUtil.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.encoder; - -/** - * @author Satoru Takabayashi - * @author Daniel Switkin - * @author Sean Owen - */ -final class MaskUtil { - - // Penalty weights from section 6.8.2.1 - private static final int N1 = 3; - private static final int N2 = 3; - private static final int N3 = 40; - private static final int N4 = 10; - - private MaskUtil() { - // do nothing - } - - /** - * Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and - * give penalty to them. Example: 00000 or 11111. - */ - static int applyMaskPenaltyRule1(ByteMatrix matrix) { - return applyMaskPenaltyRule1Internal(matrix, true) + applyMaskPenaltyRule1Internal(matrix, false); - } - - /** - * Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give - * penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a - * penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block. - */ - static int applyMaskPenaltyRule2(ByteMatrix matrix) { - int penalty = 0; - byte[][] array = matrix.getArray(); - int width = matrix.getWidth(); - int height = matrix.getHeight(); - for (int y = 0; y < height - 1; y++) { - byte[] arrayY = array[y]; - for (int x = 0; x < width - 1; x++) { - int value = arrayY[x]; - if (value == arrayY[x + 1] && value == array[y + 1][x] && value == array[y + 1][x + 1]) { - penalty++; - } - } - } - return N2 * penalty; - } - - /** - * Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4 - * starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we - * find patterns like 000010111010000, we give penalty once. - */ - static int applyMaskPenaltyRule3(ByteMatrix matrix) { - int numPenalties = 0; - byte[][] array = matrix.getArray(); - int width = matrix.getWidth(); - int height = matrix.getHeight(); - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - byte[] arrayY = array[y]; // We can at least optimize this access - if (x + 6 < width && - arrayY[x] == 1 && - arrayY[x + 1] == 0 && - arrayY[x + 2] == 1 && - arrayY[x + 3] == 1 && - arrayY[x + 4] == 1 && - arrayY[x + 5] == 0 && - arrayY[x + 6] == 1 && - (isWhiteHorizontal(arrayY, x - 4, x) || isWhiteHorizontal(arrayY, x + 7, x + 11))) { - numPenalties++; - } - if (y + 6 < height && - array[y][x] == 1 && - array[y + 1][x] == 0 && - array[y + 2][x] == 1 && - array[y + 3][x] == 1 && - array[y + 4][x] == 1 && - array[y + 5][x] == 0 && - array[y + 6][x] == 1 && - (isWhiteVertical(array, x, y - 4, y) || isWhiteVertical(array, x, y + 7, y + 11))) { - numPenalties++; - } - } - } - return numPenalties * N3; - } - - private static boolean isWhiteHorizontal(byte[] rowArray, int from, int to) { - if (from < 0 || rowArray.length < to) { - return false; - } - for (int i = from; i < to; i++) { - if (rowArray[i] == 1) { - return false; - } - } - return true; - } - - private static boolean isWhiteVertical(byte[][] array, int col, int from, int to) { - if (from < 0 || array.length < to) { - return false; - } - for (int i = from; i < to; i++) { - if (array[i][col] == 1) { - return false; - } - } - return true; - } - - /** - * Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give - * penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance. - */ - static int applyMaskPenaltyRule4(ByteMatrix matrix) { - int numDarkCells = 0; - byte[][] array = matrix.getArray(); - int width = matrix.getWidth(); - int height = matrix.getHeight(); - for (int y = 0; y < height; y++) { - byte[] arrayY = array[y]; - for (int x = 0; x < width; x++) { - if (arrayY[x] == 1) { - numDarkCells++; - } - } - } - int numTotalCells = matrix.getHeight() * matrix.getWidth(); - int fivePercentVariances = Math.abs(numDarkCells * 2 - numTotalCells) * 10 / numTotalCells; - return fivePercentVariances * N4; - } - - /** - * Return the mask bit for "getMaskPattern" at "x" and "y". See 8.8 of JISX0510:2004 for mask - * pattern conditions. - */ - static boolean getDataMaskBit(int maskPattern, int x, int y) { - int intermediate; - int temp; - switch (maskPattern) { - case 0: - intermediate = (y + x) & 0x1; - break; - case 1: - intermediate = y & 0x1; - break; - case 2: - intermediate = x % 3; - break; - case 3: - intermediate = (y + x) % 3; - break; - case 4: - intermediate = ((y / 2) + (x / 3)) & 0x1; - break; - case 5: - temp = y * x; - intermediate = (temp & 0x1) + (temp % 3); - break; - case 6: - temp = y * x; - intermediate = ((temp & 0x1) + (temp % 3)) & 0x1; - break; - case 7: - temp = y * x; - intermediate = ((temp % 3) + ((y + x) & 0x1)) & 0x1; - break; - default: - throw new IllegalArgumentException("Invalid mask pattern: " + maskPattern); - } - return intermediate == 0; - } - - /** - * Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both - * vertical and horizontal orders respectively. - */ - private static int applyMaskPenaltyRule1Internal(ByteMatrix matrix, boolean isHorizontal) { - int penalty = 0; - int iLimit = isHorizontal ? matrix.getHeight() : matrix.getWidth(); - int jLimit = isHorizontal ? matrix.getWidth() : matrix.getHeight(); - byte[][] array = matrix.getArray(); - for (int i = 0; i < iLimit; i++) { - int numSameBitCells = 0; - int prevBit = -1; - for (int j = 0; j < jLimit; j++) { - int bit = isHorizontal ? array[i][j] : array[j][i]; - if (bit == prevBit) { - numSameBitCells++; - } else { - if (numSameBitCells >= 5) { - penalty += N1 + (numSameBitCells - 5); - } - numSameBitCells = 1; // Include the cell itself. - prevBit = bit; - } - } - if (numSameBitCells >= 5) { - penalty += N1 + (numSameBitCells - 5); - } - } - return penalty; - } - -} diff --git a/port_src/core/DONE/qrcode/encoder/MatrixUtil.java b/port_src/core/DONE/qrcode/encoder/MatrixUtil.java deleted file mode 100644 index 7bac2d8..0000000 --- a/port_src/core/DONE/qrcode/encoder/MatrixUtil.java +++ /dev/null @@ -1,477 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.encoder; - -import com.google.zxing.WriterException; -import com.google.zxing.common.BitArray; -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; -import com.google.zxing.qrcode.decoder.Version; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author dswitkin@google.com (Daniel Switkin) - ported from C++ - */ -final class MatrixUtil { - - private static final int[][] POSITION_DETECTION_PATTERN = { - {1, 1, 1, 1, 1, 1, 1}, - {1, 0, 0, 0, 0, 0, 1}, - {1, 0, 1, 1, 1, 0, 1}, - {1, 0, 1, 1, 1, 0, 1}, - {1, 0, 1, 1, 1, 0, 1}, - {1, 0, 0, 0, 0, 0, 1}, - {1, 1, 1, 1, 1, 1, 1}, - }; - - private static final int[][] POSITION_ADJUSTMENT_PATTERN = { - {1, 1, 1, 1, 1}, - {1, 0, 0, 0, 1}, - {1, 0, 1, 0, 1}, - {1, 0, 0, 0, 1}, - {1, 1, 1, 1, 1}, - }; - - // From Appendix E. Table 1, JIS0510X:2004 (p 71). The table was double-checked by komatsu. - private static final int[][] POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE = { - {-1, -1, -1, -1, -1, -1, -1}, // Version 1 - { 6, 18, -1, -1, -1, -1, -1}, // Version 2 - { 6, 22, -1, -1, -1, -1, -1}, // Version 3 - { 6, 26, -1, -1, -1, -1, -1}, // Version 4 - { 6, 30, -1, -1, -1, -1, -1}, // Version 5 - { 6, 34, -1, -1, -1, -1, -1}, // Version 6 - { 6, 22, 38, -1, -1, -1, -1}, // Version 7 - { 6, 24, 42, -1, -1, -1, -1}, // Version 8 - { 6, 26, 46, -1, -1, -1, -1}, // Version 9 - { 6, 28, 50, -1, -1, -1, -1}, // Version 10 - { 6, 30, 54, -1, -1, -1, -1}, // Version 11 - { 6, 32, 58, -1, -1, -1, -1}, // Version 12 - { 6, 34, 62, -1, -1, -1, -1}, // Version 13 - { 6, 26, 46, 66, -1, -1, -1}, // Version 14 - { 6, 26, 48, 70, -1, -1, -1}, // Version 15 - { 6, 26, 50, 74, -1, -1, -1}, // Version 16 - { 6, 30, 54, 78, -1, -1, -1}, // Version 17 - { 6, 30, 56, 82, -1, -1, -1}, // Version 18 - { 6, 30, 58, 86, -1, -1, -1}, // Version 19 - { 6, 34, 62, 90, -1, -1, -1}, // Version 20 - { 6, 28, 50, 72, 94, -1, -1}, // Version 21 - { 6, 26, 50, 74, 98, -1, -1}, // Version 22 - { 6, 30, 54, 78, 102, -1, -1}, // Version 23 - { 6, 28, 54, 80, 106, -1, -1}, // Version 24 - { 6, 32, 58, 84, 110, -1, -1}, // Version 25 - { 6, 30, 58, 86, 114, -1, -1}, // Version 26 - { 6, 34, 62, 90, 118, -1, -1}, // Version 27 - { 6, 26, 50, 74, 98, 122, -1}, // Version 28 - { 6, 30, 54, 78, 102, 126, -1}, // Version 29 - { 6, 26, 52, 78, 104, 130, -1}, // Version 30 - { 6, 30, 56, 82, 108, 134, -1}, // Version 31 - { 6, 34, 60, 86, 112, 138, -1}, // Version 32 - { 6, 30, 58, 86, 114, 142, -1}, // Version 33 - { 6, 34, 62, 90, 118, 146, -1}, // Version 34 - { 6, 30, 54, 78, 102, 126, 150}, // Version 35 - { 6, 24, 50, 76, 102, 128, 154}, // Version 36 - { 6, 28, 54, 80, 106, 132, 158}, // Version 37 - { 6, 32, 58, 84, 110, 136, 162}, // Version 38 - { 6, 26, 54, 82, 110, 138, 166}, // Version 39 - { 6, 30, 58, 86, 114, 142, 170}, // Version 40 - }; - - // Type info cells at the left top corner. - private static final int[][] TYPE_INFO_COORDINATES = { - {8, 0}, - {8, 1}, - {8, 2}, - {8, 3}, - {8, 4}, - {8, 5}, - {8, 7}, - {8, 8}, - {7, 8}, - {5, 8}, - {4, 8}, - {3, 8}, - {2, 8}, - {1, 8}, - {0, 8}, - }; - - // From Appendix D in JISX0510:2004 (p. 67) - private static final int VERSION_INFO_POLY = 0x1f25; // 1 1111 0010 0101 - - // From Appendix C in JISX0510:2004 (p.65). - private static final int TYPE_INFO_POLY = 0x537; - 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). - // - // JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding - // with the ByteMatrix initialized all to zero. - static void clearMatrix(ByteMatrix matrix) { - matrix.clear((byte) -1); - } - - // Build 2D matrix of QR Code from "dataBits" with "ecLevel", "version" and "getMaskPattern". On - // success, store the result in "matrix" and return true. - static void buildMatrix(BitArray dataBits, - ErrorCorrectionLevel ecLevel, - Version version, - int maskPattern, - ByteMatrix matrix) throws WriterException { - clearMatrix(matrix); - embedBasicPatterns(version, matrix); - // Type information appear with any version. - embedTypeInfo(ecLevel, maskPattern, matrix); - // Version info appear if version >= 7. - maybeEmbedVersionInfo(version, matrix); - // Data should be embedded at end. - embedDataBits(dataBits, maskPattern, matrix); - } - - // Embed basic patterns. On success, modify the matrix and return true. - // The basic patterns are: - // - Position detection patterns - // - Timing patterns - // - Dark dot at the left bottom corner - // - Position adjustment patterns, if need be - static void embedBasicPatterns(Version version, ByteMatrix matrix) throws WriterException { - // Let's get started with embedding big squares at corners. - embedPositionDetectionPatternsAndSeparators(matrix); - // Then, embed the dark dot at the left bottom corner. - embedDarkDotAtLeftBottomCorner(matrix); - - // Position adjustment patterns appear if version >= 2. - maybeEmbedPositionAdjustmentPatterns(version, matrix); - // Timing patterns should be embedded after position adj. patterns. - embedTimingPatterns(matrix); - } - - // Embed type information. On success, modify the matrix. - static void embedTypeInfo(ErrorCorrectionLevel ecLevel, int maskPattern, ByteMatrix matrix) - throws WriterException { - BitArray typeInfoBits = new BitArray(); - makeTypeInfoBits(ecLevel, maskPattern, typeInfoBits); - - for (int i = 0; i < typeInfoBits.getSize(); ++i) { - // Place bits in LSB to MSB order. LSB (least significant bit) is the last value in - // "typeInfoBits". - boolean bit = typeInfoBits.get(typeInfoBits.getSize() - 1 - i); - - // Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46). - int[] coordinates = TYPE_INFO_COORDINATES[i]; - int x1 = coordinates[0]; - int y1 = coordinates[1]; - matrix.set(x1, y1, bit); - - int x2; - int y2; - if (i < 8) { - // Right top corner. - x2 = matrix.getWidth() - i - 1; - y2 = 8; - } else { - // Left bottom corner. - x2 = 8; - y2 = matrix.getHeight() - 7 + (i - 8); - } - matrix.set(x2, y2, bit); - } - } - - // Embed version information if need be. On success, modify the matrix and return true. - // See 8.10 of JISX0510:2004 (p.47) for how to embed version information. - static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) throws WriterException { - if (version.getVersionNumber() < 7) { // Version info is necessary if version >= 7. - return; // Don't need version info. - } - BitArray versionInfoBits = new BitArray(); - makeVersionInfoBits(version, versionInfoBits); - - int bitIndex = 6 * 3 - 1; // It will decrease from 17 to 0. - for (int i = 0; i < 6; ++i) { - for (int j = 0; j < 3; ++j) { - // Place bits in LSB (least significant bit) to MSB order. - boolean bit = versionInfoBits.get(bitIndex); - bitIndex--; - // Left bottom corner. - matrix.set(i, matrix.getHeight() - 11 + j, bit); - // Right bottom corner. - matrix.set(matrix.getHeight() - 11 + j, i, bit); - } - } - } - - // Embed "dataBits" using "getMaskPattern". On success, modify the matrix and return true. - // For debugging purposes, it skips masking process if "getMaskPattern" is -1. - // See 8.7 of JISX0510:2004 (p.38) for how to embed data bits. - static void embedDataBits(BitArray dataBits, int maskPattern, ByteMatrix matrix) - throws WriterException { - int bitIndex = 0; - int direction = -1; - // Start from the right bottom cell. - int x = matrix.getWidth() - 1; - int y = matrix.getHeight() - 1; - while (x > 0) { - // Skip the vertical timing pattern. - if (x == 6) { - x -= 1; - } - while (y >= 0 && y < matrix.getHeight()) { - for (int i = 0; i < 2; ++i) { - int xx = x - i; - // Skip the cell if it's not empty. - if (!isEmpty(matrix.get(xx, y))) { - continue; - } - boolean bit; - if (bitIndex < dataBits.getSize()) { - bit = dataBits.get(bitIndex); - ++bitIndex; - } else { - // Padding bit. If there is no bit left, we'll fill the left cells with 0, as described - // in 8.4.9 of JISX0510:2004 (p. 24). - bit = false; - } - - // Skip masking if mask_pattern is -1. - if (maskPattern != -1 && MaskUtil.getDataMaskBit(maskPattern, xx, y)) { - bit = !bit; - } - matrix.set(xx, y, bit); - } - y += direction; - } - direction = -direction; // Reverse the direction. - y += direction; - x -= 2; // Move to the left. - } - // All bits should be consumed. - if (bitIndex != dataBits.getSize()) { - throw new WriterException("Not all bits consumed: " + bitIndex + '/' + dataBits.getSize()); - } - } - - // Return the position of the most significant bit set (to one) in the "value". The most - // significant bit is position 32. If there is no bit set, return 0. Examples: - // - findMSBSet(0) => 0 - // - findMSBSet(1) => 1 - // - findMSBSet(255) => 8 - static int findMSBSet(int value) { - return 32 - Integer.numberOfLeadingZeros(value); - } - - // Calculate BCH (Bose-Chaudhuri-Hocquenghem) code for "value" using polynomial "poly". The BCH - // code is used for encoding type information and version information. - // Example: Calculation of version information of 7. - // f(x) is created from 7. - // - 7 = 000111 in 6 bits - // - f(x) = x^2 + x^1 + x^0 - // g(x) is given by the standard (p. 67) - // - g(x) = x^12 + x^11 + x^10 + x^9 + x^8 + x^5 + x^2 + 1 - // Multiply f(x) by x^(18 - 6) - // - f'(x) = f(x) * x^(18 - 6) - // - f'(x) = x^14 + x^13 + x^12 - // Calculate the remainder of f'(x) / g(x) - // x^2 - // __________________________________________________ - // g(x) )x^14 + x^13 + x^12 - // x^14 + x^13 + x^12 + x^11 + x^10 + x^7 + x^4 + x^2 - // -------------------------------------------------- - // x^11 + x^10 + x^7 + x^4 + x^2 - // - // The remainder is x^11 + x^10 + x^7 + x^4 + x^2 - // Encode it in binary: 110010010100 - // 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 - // operations. We don't care if coefficients are positive or negative. - static int calculateBCHCode(int value, int poly) { - if (poly == 0) { - throw new IllegalArgumentException("0 polynomial"); - } - // If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1 - // from 13 to make it 12. - int msbSetInPoly = findMSBSet(poly); - value <<= msbSetInPoly - 1; - // Do the division business using exclusive-or operations. - while (findMSBSet(value) >= msbSetInPoly) { - value ^= poly << (findMSBSet(value) - msbSetInPoly); - } - // Now the "value" is the remainder (i.e. the BCH code) - return value; - } - - // Make bit vector of type information. On success, store the result in "bits" and return true. - // Encode error correction level and mask pattern. See 8.9 of - // JISX0510:2004 (p.45) for details. - static void makeTypeInfoBits(ErrorCorrectionLevel ecLevel, int maskPattern, BitArray bits) - throws WriterException { - if (!QRCode.isValidMaskPattern(maskPattern)) { - throw new WriterException("Invalid mask pattern"); - } - int typeInfo = (ecLevel.getBits() << 3) | maskPattern; - bits.appendBits(typeInfo, 5); - - int bchCode = calculateBCHCode(typeInfo, TYPE_INFO_POLY); - bits.appendBits(bchCode, 10); - - BitArray maskBits = new BitArray(); - maskBits.appendBits(TYPE_INFO_MASK_PATTERN, 15); - bits.xor(maskBits); - - if (bits.getSize() != 15) { // Just in case. - throw new WriterException("should not happen but we got: " + bits.getSize()); - } - } - - // Make bit vector of version information. On success, store the result in "bits" and return true. - // See 8.10 of JISX0510:2004 (p.45) for details. - static void makeVersionInfoBits(Version version, BitArray bits) throws WriterException { - bits.appendBits(version.getVersionNumber(), 6); - int bchCode = calculateBCHCode(version.getVersionNumber(), VERSION_INFO_POLY); - bits.appendBits(bchCode, 12); - - if (bits.getSize() != 18) { // Just in case. - throw new WriterException("should not happen but we got: " + bits.getSize()); - } - } - - // Check if "value" is empty. - private static boolean isEmpty(int value) { - return value == -1; - } - - private static void embedTimingPatterns(ByteMatrix matrix) { - // -8 is for skipping position detection patterns (size 7), and two horizontal/vertical - // separation patterns (size 1). Thus, 8 = 7 + 1. - for (int i = 8; i < matrix.getWidth() - 8; ++i) { - int bit = (i + 1) % 2; - // Horizontal line. - if (isEmpty(matrix.get(i, 6))) { - matrix.set(i, 6, bit); - } - // Vertical line. - if (isEmpty(matrix.get(6, i))) { - matrix.set(6, i, bit); - } - } - } - - // Embed the lonely dark dot at left bottom corner. JISX0510:2004 (p.46) - private static void embedDarkDotAtLeftBottomCorner(ByteMatrix matrix) throws WriterException { - if (matrix.get(8, matrix.getHeight() - 8) == 0) { - throw new WriterException(); - } - matrix.set(8, matrix.getHeight() - 8, 1); - } - - private static void embedHorizontalSeparationPattern(int xStart, - int yStart, - ByteMatrix matrix) throws WriterException { - for (int x = 0; x < 8; ++x) { - if (!isEmpty(matrix.get(xStart + x, yStart))) { - throw new WriterException(); - } - matrix.set(xStart + x, yStart, 0); - } - } - - private static void embedVerticalSeparationPattern(int xStart, - int yStart, - ByteMatrix matrix) throws WriterException { - for (int y = 0; y < 7; ++y) { - if (!isEmpty(matrix.get(xStart, yStart + y))) { - throw new WriterException(); - } - matrix.set(xStart, yStart + y, 0); - } - } - - private static void embedPositionAdjustmentPattern(int xStart, int yStart, ByteMatrix matrix) { - for (int y = 0; y < 5; ++y) { - int[] patternY = POSITION_ADJUSTMENT_PATTERN[y]; - for (int x = 0; x < 5; ++x) { - matrix.set(xStart + x, yStart + y, patternY[x]); - } - } - } - - private static void embedPositionDetectionPattern(int xStart, int yStart, ByteMatrix matrix) { - for (int y = 0; y < 7; ++y) { - int[] patternY = POSITION_DETECTION_PATTERN[y]; - for (int x = 0; x < 7; ++x) { - matrix.set(xStart + x, yStart + y, patternY[x]); - } - } - } - - // Embed position detection patterns and surrounding vertical/horizontal separators. - private static void embedPositionDetectionPatternsAndSeparators(ByteMatrix matrix) throws WriterException { - // Embed three big squares at corners. - int pdpWidth = POSITION_DETECTION_PATTERN[0].length; - // Left top corner. - embedPositionDetectionPattern(0, 0, matrix); - // Right top corner. - embedPositionDetectionPattern(matrix.getWidth() - pdpWidth, 0, matrix); - // Left bottom corner. - embedPositionDetectionPattern(0, matrix.getWidth() - pdpWidth, matrix); - - // Embed horizontal separation patterns around the squares. - int hspWidth = 8; - // Left top corner. - embedHorizontalSeparationPattern(0, hspWidth - 1, matrix); - // Right top corner. - embedHorizontalSeparationPattern(matrix.getWidth() - hspWidth, - hspWidth - 1, matrix); - // Left bottom corner. - embedHorizontalSeparationPattern(0, matrix.getWidth() - hspWidth, matrix); - - // Embed vertical separation patterns around the squares. - int vspSize = 7; - // Left top corner. - embedVerticalSeparationPattern(vspSize, 0, matrix); - // Right top corner. - embedVerticalSeparationPattern(matrix.getHeight() - vspSize - 1, 0, matrix); - // Left bottom corner. - embedVerticalSeparationPattern(vspSize, matrix.getHeight() - vspSize, - matrix); - } - - // Embed position adjustment patterns if need be. - private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) { - if (version.getVersionNumber() < 2) { // The patterns appear if version >= 2 - return; - } - int index = version.getVersionNumber() - 1; - int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index]; - for (int y : coordinates) { - if (y >= 0) { - for (int x : coordinates) { - if (x >= 0 && isEmpty(matrix.get(x, y))) { - // If the cell is unset, we embed the position adjustment pattern here. - // -2 is necessary since the x/y coordinates point to the center of the pattern, not the - // left top corner. - embedPositionAdjustmentPattern(x - 2, y - 2, matrix); - } - } - } - } - } - -} diff --git a/port_src/core/DONE/qrcode/encoder/MinimalEncoder.java b/port_src/core/DONE/qrcode/encoder/MinimalEncoder.java deleted file mode 100644 index 4de1d0b..0000000 --- a/port_src/core/DONE/qrcode/encoder/MinimalEncoder.java +++ /dev/null @@ -1,667 +0,0 @@ -/* - * Copyright 2021 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.encoder; - -import com.google.zxing.qrcode.decoder.Mode; -import com.google.zxing.qrcode.decoder.Version; -import com.google.zxing.common.BitArray; -import com.google.zxing.common.ECIEncoderSet; -import com.google.zxing.WriterException; -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; - -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; - - -/** - * Encoder that encodes minimally - * - * Algorithm: - * - * The eleventh commandment was "Thou Shalt Compute" or "Thou Shalt Not Compute" - I forget which (Alan Perilis). - * - * This implementation computes. As an alternative, the QR-Code specification suggests heuristics like this one: - * - * If initial input data is in the exclusive subset of the Alphanumeric character set AND if there are less than - * [6,7,8] characters followed by data from the remainder of the 8-bit byte character set, THEN select the 8- - * bit byte mode ELSE select Alphanumeric mode; - * - * This is probably right for 99.99% of cases but there is at least this one counter example: The string "AAAAAAa" - * encodes 2 bits smaller as ALPHANUMERIC(AAAAAA), BYTE(a) than by encoding it as BYTE(AAAAAAa). - * Perhaps that is the only counter example but without having proof, it remains unclear. - * - * ECI switching: - * - * In multi language content the algorithm selects the most compact representation using ECI modes. - * For example the most compact representation of the string "\u0150\u015C" (O-double-acute, S-circumflex) is - * ECI(UTF-8), BYTE(\u0150\u015C) while prepending one or more times the same leading character as in - * "\u0150\u0150\u015C", the most compact representation uses two ECIs so that the string is encoded as - * ECI(ISO-8859-2), BYTE(\u0150\u0150), ECI(ISO-8859-3), BYTE(\u015C). - * - * @author Alex Geller - */ -final class MinimalEncoder { - - private enum VersionSize { - SMALL("version 1-9"), - MEDIUM("version 10-26"), - LARGE("version 27-40"); - - private final String description; - - VersionSize(String description) { - this.description = description; - } - - public String toString() { - return description; - } - } - - private final String stringToEncode; - private final boolean isGS1; - private final ECIEncoderSet encoders; - private final ErrorCorrectionLevel ecLevel; - - /** - * Creates a MinimalEncoder - * - * @param stringToEncode The string to encode - * @param priorityCharset The preferred {@link Charset}. When the value of the argument is null, the algorithm - * chooses charsets that leads to a minimal representation. Otherwise the algorithm will use the priority - * charset to encode any character in the input that can be encoded by it if the charset is among the - * supported charsets. - * @param isGS1 {@code true} if a FNC1 is to be prepended; {@code false} otherwise - * @param ecLevel The error correction level. - * @see ResultList#getVersion - */ - MinimalEncoder(String stringToEncode, Charset priorityCharset, boolean isGS1, ErrorCorrectionLevel ecLevel) { - this.stringToEncode = stringToEncode; - this.isGS1 = isGS1; - this.encoders = new ECIEncoderSet(stringToEncode, priorityCharset, -1); - this.ecLevel = ecLevel; - } - - /** - * Encodes the string minimally - * - * @param stringToEncode The string to encode - * @param version The preferred {@link Version}. A minimal version is computed (see - * {@link ResultList#getVersion method} when the value of the argument is null - * @param priorityCharset The preferred {@link Charset}. When the value of the argument is null, the algorithm - * chooses charsets that leads to a minimal representation. Otherwise the algorithm will use the priority - * charset to encode any character in the input that can be encoded by it if the charset is among the - * supported charsets. - * @param isGS1 {@code true} if a FNC1 is to be prepended; {@code false} otherwise - * @param ecLevel The error correction level. - * @return An instance of {@code ResultList} representing the minimal solution. - * @see ResultList#getBits - * @see ResultList#getVersion - * @see ResultList#getSize - */ - static ResultList encode(String stringToEncode, Version version, Charset priorityCharset, boolean isGS1, - ErrorCorrectionLevel ecLevel) throws WriterException { - return new MinimalEncoder(stringToEncode, priorityCharset, isGS1, ecLevel).encode(version); - } - - ResultList encode(Version version) throws WriterException { - if (version == null) { // compute minimal encoding trying the three version sizes. - Version[] versions = { getVersion(VersionSize.SMALL), - getVersion(VersionSize.MEDIUM), - getVersion(VersionSize.LARGE) }; - ResultList[] results = { encodeSpecificVersion(versions[0]), - encodeSpecificVersion(versions[1]), - encodeSpecificVersion(versions[2]) }; - int smallestSize = Integer.MAX_VALUE; - int smallestResult = -1; - for (int i = 0; i < 3; i++) { - int size = results[i].getSize(); - if (Encoder.willFit(size, versions[i], ecLevel) && size < smallestSize) { - smallestSize = size; - smallestResult = i; - } - } - if (smallestResult < 0) { - throw new WriterException("Data too big for any version"); - } - return results[smallestResult]; - } else { // compute minimal encoding for a given version - ResultList result = encodeSpecificVersion(version); - if (!Encoder.willFit(result.getSize(), getVersion(getVersionSize(result.getVersion())), ecLevel)) { - throw new WriterException("Data too big for version" + version); - } - return result; - } - } - - static VersionSize getVersionSize(Version version) { - return version.getVersionNumber() <= 9 ? VersionSize.SMALL : version.getVersionNumber() <= 26 ? - VersionSize.MEDIUM : VersionSize.LARGE; - } - - static Version getVersion(VersionSize versionSize) { - switch (versionSize) { - case SMALL: - return Version.getVersionForNumber(9); - case MEDIUM: - return Version.getVersionForNumber(26); - case LARGE: - default: - return Version.getVersionForNumber(40); - } - } - - static boolean isNumeric(char c) { - return c >= '0' && c <= '9'; - } - - static boolean isDoubleByteKanji(char c) { - return Encoder.isOnlyDoubleByteKanji(String.valueOf(c)); - } - - static boolean isAlphanumeric(char c) { - return Encoder.getAlphanumericCode(c) != -1; - } - - boolean canEncode(Mode mode, char c) { - switch (mode) { - case KANJI: return isDoubleByteKanji(c); - case ALPHANUMERIC: return isAlphanumeric(c); - case NUMERIC: return isNumeric(c); - case BYTE: return true; // any character can be encoded as byte(s). Up to the caller to manage splitting into - // multiple bytes when String.getBytes(Charset) return more than one byte. - default: - return false; - } - } - - static int getCompactedOrdinal(Mode mode) { - if (mode == null) { - return 0; - } - switch (mode) { - case KANJI: - return 0; - case ALPHANUMERIC: - return 1; - case NUMERIC: - return 2; - case BYTE: - return 3; - default: - throw new IllegalStateException("Illegal mode " + mode); - } - } - - void addEdge(Edge[][][] edges, int position, Edge edge) { - int vertexIndex = position + edge.characterLength; - Edge[] modeEdges = edges[vertexIndex][edge.charsetEncoderIndex]; - int modeOrdinal = getCompactedOrdinal(edge.mode); - if (modeEdges[modeOrdinal] == null || modeEdges[modeOrdinal].cachedTotalSize > edge.cachedTotalSize) { - modeEdges[modeOrdinal] = edge; - } - } - - void addEdges(Version version, Edge[][][] edges, int from, Edge previous) { - int start = 0; - int end = encoders.length(); - int priorityEncoderIndex = encoders.getPriorityEncoderIndex(); - if (priorityEncoderIndex >= 0 && encoders.canEncode(stringToEncode.charAt(from),priorityEncoderIndex)) { - start = priorityEncoderIndex; - end = priorityEncoderIndex + 1; - } - - for (int i = start; i < end; i++) { - if (encoders.canEncode(stringToEncode.charAt(from), i)) { - addEdge(edges, from, new Edge(Mode.BYTE, from, i, 1, previous, version)); - } - } - - if (canEncode(Mode.KANJI, stringToEncode.charAt(from))) { - addEdge(edges, from, new Edge(Mode.KANJI, from, 0, 1, previous, version)); - } - - int inputLength = stringToEncode.length(); - if (canEncode(Mode.ALPHANUMERIC, stringToEncode.charAt(from))) { - addEdge(edges, from, new Edge(Mode.ALPHANUMERIC, from, 0, from + 1 >= inputLength || - !canEncode(Mode.ALPHANUMERIC, stringToEncode.charAt(from + 1)) ? 1 : 2, previous, version)); - } - - if (canEncode(Mode.NUMERIC, stringToEncode.charAt(from))) { - addEdge(edges, from, new Edge(Mode.NUMERIC, from, 0, from + 1 >= inputLength || - !canEncode(Mode.NUMERIC, stringToEncode.charAt(from + 1)) ? 1 : from + 2 >= inputLength || - !canEncode(Mode.NUMERIC, stringToEncode.charAt(from + 2)) ? 2 : 3, previous, version)); - } - } - ResultList encodeSpecificVersion(Version version) throws WriterException { - - @SuppressWarnings("checkstyle:lineLength") - /* A vertex represents a tuple of a position in the input, a mode and a character encoding where position 0 - * denotes the position left of the first character, 1 the position left of the second character and so on. - * Likewise the end vertices are located after the last character at position stringToEncode.length(). - * - * An edge leading to such a vertex encodes one or more of the characters left of the position that the vertex - * represents and encodes it in the same encoding and mode as the vertex on which the edge ends. In other words, - * all edges leading to a particular vertex encode the same characters in the same mode with the same character - * encoding. They differ only by their source vertices who are all located at i+1 minus the number of encoded - * characters. - * - * The edges leading to a vertex are stored in such a way that there is a fast way to enumerate the edges ending - * on a particular vertex. - * - * The algorithm processes the vertices in order of their position thereby performing the following: - * - * For every vertex at position i the algorithm enumerates the edges ending on the vertex and removes all but the - * shortest from that list. - * Then it processes the vertices for the position i+1. If i+1 == stringToEncode.length() then the algorithm ends - * and chooses the the edge with the smallest size from any of the edges leading to vertices at this position. - * Otherwise the algorithm computes all possible outgoing edges for the vertices at the position i+1 - * - * Examples: - * The process is illustrated by showing the graph (edges) after each iteration from left to right over the input: - * An edge is drawn as follows "(" + fromVertex + ") -- " + encodingMode + "(" + encodedInput + ") (" + - * accumulatedSize + ") --> (" + toVertex + ")" - * - * Example 1 encoding the string "ABCDE": - * Note: This example assumes that alphanumeric encoding is only possible in multiples of two characters so that - * the example is both short and showing the principle. In reality this restriction does not exist. - * - * Initial situation - * (initial) -- BYTE(A) (20) --> (1_BYTE) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) - * - * Situation after adding edges to vertices at position 1 - * (initial) -- BYTE(A) (20) --> (1_BYTE) -- BYTE(B) (28) --> (2_BYTE) - * (1_BYTE) -- ALPHANUMERIC(BC) (44) --> (3_ALPHANUMERIC) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) - * - * Situation after adding edges to vertices at position 2 - * (initial) -- BYTE(A) (20) --> (1_BYTE) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) - * (initial) -- BYTE(A) (20) --> (1_BYTE) -- BYTE(B) (28) --> (2_BYTE) - * (1_BYTE) -- ALPHANUMERIC(BC) (44) --> (3_ALPHANUMERIC) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) -- BYTE(C) (44) --> (3_BYTE) - * (2_ALPHANUMERIC) -- ALPHANUMERIC(CD) (35) --> (4_ALPHANUMERIC) - * - * Situation after adding edges to vertices at position 3 - * (initial) -- BYTE(A) (20) --> (1_BYTE) -- BYTE(B) (28) --> (2_BYTE) -- BYTE(C) (36) --> (3_BYTE) - * (1_BYTE) -- ALPHANUMERIC(BC) (44) --> (3_ALPHANUMERIC) -- BYTE(D) (64) --> (4_BYTE) - * (3_ALPHANUMERIC) -- ALPHANUMERIC(DE) (55) --> (5_ALPHANUMERIC) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) -- ALPHANUMERIC(CD) (35) --> (4_ALPHANUMERIC) - * (2_ALPHANUMERIC) -- ALPHANUMERIC(CD) (35) --> (4_ALPHANUMERIC) - * - * Situation after adding edges to vertices at position 4 - * (initial) -- BYTE(A) (20) --> (1_BYTE) -- BYTE(B) (28) --> (2_BYTE) -- BYTE(C) (36) --> (3_BYTE) -- BYTE(D) (44) --> (4_BYTE) - * (1_BYTE) -- ALPHANUMERIC(BC) (44) --> (3_ALPHANUMERIC) -- ALPHANUMERIC(DE) (55) --> (5_ALPHANUMERIC) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) -- ALPHANUMERIC(CD) (35) --> (4_ALPHANUMERIC) -- BYTE(E) (55) --> (5_BYTE) - * - * Situation after adding edges to vertices at position 5 - * (initial) -- BYTE(A) (20) --> (1_BYTE) -- BYTE(B) (28) --> (2_BYTE) -- BYTE(C) (36) --> (3_BYTE) -- BYTE(D) (44) --> (4_BYTE) -- BYTE(E) (52) --> (5_BYTE) - * (1_BYTE) -- ALPHANUMERIC(BC) (44) --> (3_ALPHANUMERIC) -- ALPHANUMERIC(DE) (55) --> (5_ALPHANUMERIC) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) -- ALPHANUMERIC(CD) (35) --> (4_ALPHANUMERIC) - * - * Encoding as BYTE(ABCDE) has the smallest size of 52 and is hence chosen. The encodation ALPHANUMERIC(ABCD), - * BYTE(E) is longer with a size of 55. - * - * Example 2 encoding the string "XXYY" where X denotes a character unique to character set ISO-8859-2 and Y a - * character unique to ISO-8859-3. Both characters encode as double byte in UTF-8: - * - * Initial situation - * (initial) -- BYTE(X) (32) --> (1_BYTE_ISO-8859-2) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-8) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-16BE) - * - * Situation after adding edges to vertices at position 1 - * (initial) -- BYTE(X) (32) --> (1_BYTE_ISO-8859-2) -- BYTE(X) (40) --> (2_BYTE_ISO-8859-2) - * (1_BYTE_ISO-8859-2) -- BYTE(X) (72) --> (2_BYTE_UTF-8) - * (1_BYTE_ISO-8859-2) -- BYTE(X) (72) --> (2_BYTE_UTF-16BE) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-8) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-16BE) - * - * Situation after adding edges to vertices at position 2 - * (initial) -- BYTE(X) (32) --> (1_BYTE_ISO-8859-2) -- BYTE(X) (40) --> (2_BYTE_ISO-8859-2) - * (2_BYTE_ISO-8859-2) -- BYTE(Y) (72) --> (3_BYTE_ISO-8859-3) - * (2_BYTE_ISO-8859-2) -- BYTE(Y) (80) --> (3_BYTE_UTF-8) - * (2_BYTE_ISO-8859-2) -- BYTE(Y) (80) --> (3_BYTE_UTF-16BE) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-8) -- BYTE(X) (56) --> (2_BYTE_UTF-8) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-16BE) -- BYTE(X) (56) --> (2_BYTE_UTF-16BE) - * - * Situation after adding edges to vertices at position 3 - * (initial) -- BYTE(X) (32) --> (1_BYTE_ISO-8859-2) -- BYTE(X) (40) --> (2_BYTE_ISO-8859-2) -- BYTE(Y) (72) --> (3_BYTE_ISO-8859-3) - * (3_BYTE_ISO-8859-3) -- BYTE(Y) (80) --> (4_BYTE_ISO-8859-3) - * (3_BYTE_ISO-8859-3) -- BYTE(Y) (112) --> (4_BYTE_UTF-8) - * (3_BYTE_ISO-8859-3) -- BYTE(Y) (112) --> (4_BYTE_UTF-16BE) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-8) -- BYTE(X) (56) --> (2_BYTE_UTF-8) -- BYTE(Y) (72) --> (3_BYTE_UTF-8) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-16BE) -- BYTE(X) (56) --> (2_BYTE_UTF-16BE) -- BYTE(Y) (72) --> (3_BYTE_UTF-16BE) - * - * Situation after adding edges to vertices at position 4 - * (initial) -- BYTE(X) (32) --> (1_BYTE_ISO-8859-2) -- BYTE(X) (40) --> (2_BYTE_ISO-8859-2) -- BYTE(Y) (72) --> (3_BYTE_ISO-8859-3) -- BYTE(Y) (80) --> (4_BYTE_ISO-8859-3) - * (3_BYTE_UTF-8) -- BYTE(Y) (88) --> (4_BYTE_UTF-8) - * (3_BYTE_UTF-16BE) -- BYTE(Y) (88) --> (4_BYTE_UTF-16BE) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-8) -- BYTE(X) (56) --> (2_BYTE_UTF-8) -- BYTE(Y) (72) --> (3_BYTE_UTF-8) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-16BE) -- BYTE(X) (56) --> (2_BYTE_UTF-16BE) -- BYTE(Y) (72) --> (3_BYTE_UTF-16BE) - * - * Encoding as ECI(ISO-8859-2),BYTE(XX),ECI(ISO-8859-3),BYTE(YY) has the smallest size of 80 and is hence chosen. - * The encodation ECI(UTF-8),BYTE(XXYY) is longer with a size of 88. - */ - - int inputLength = stringToEncode.length(); - - // Array that represents vertices. There is a vertex for every character, encoding and mode. The vertex contains - // a list of all edges that lead to it that have the same encoding and mode. - // The lists are created lazily - - // The last dimension in the array below encodes the 4 modes KANJI, ALPHANUMERIC, NUMERIC and BYTE via the - // function getCompactedOrdinal(Mode) - Edge[][][] edges = new Edge[inputLength + 1][encoders.length()][4]; - addEdges(version, edges, 0, null); - - for (int i = 1; i <= inputLength; i++) { - for (int j = 0; j < encoders.length(); j++) { - for (int k = 0; k < 4; k++) { - if (edges[i][j][k] != null && i < inputLength) { - addEdges(version, edges, i, edges[i][j][k]); - } - } - } - - } - int minimalJ = -1; - int minimalK = -1; - int minimalSize = Integer.MAX_VALUE; - for (int j = 0; j < encoders.length(); j++) { - for (int k = 0; k < 4; k++) { - if (edges[inputLength][j][k] != null) { - Edge edge = edges[inputLength][j][k]; - if (edge.cachedTotalSize < minimalSize) { - minimalSize = edge.cachedTotalSize; - minimalJ = j; - minimalK = k; - } - } - } - } - if (minimalJ < 0) { - throw new WriterException("Internal error: failed to encode \"" + stringToEncode + "\""); - } - return new ResultList(version, edges[inputLength][minimalJ][minimalK]); - } - - private final class Edge { - private final Mode mode; - private final int fromPosition; - private final int charsetEncoderIndex; - private final int characterLength; - private final Edge previous; - private final int cachedTotalSize; - - private Edge(Mode mode, int fromPosition, int charsetEncoderIndex, int characterLength, Edge previous, - Version version) { - this.mode = mode; - this.fromPosition = fromPosition; - this.charsetEncoderIndex = mode == Mode.BYTE || previous == null ? charsetEncoderIndex : - previous.charsetEncoderIndex; // inherit the encoding if not of type BYTE - this.characterLength = characterLength; - this.previous = previous; - - int size = previous != null ? previous.cachedTotalSize : 0; - - boolean needECI = mode == Mode.BYTE && - (previous == null && this.charsetEncoderIndex != 0) || // at the beginning and charset is not ISO-8859-1 - (previous != null && this.charsetEncoderIndex != previous.charsetEncoderIndex); - - if (previous == null || mode != previous.mode || needECI) { - size += 4 + mode.getCharacterCountBits(version); - } - switch (mode) { - case KANJI: - size += 13; - break; - case ALPHANUMERIC: - size += characterLength == 1 ? 6 : 11; - break; - case NUMERIC: - size += characterLength == 1 ? 4 : characterLength == 2 ? 7 : 10; - break; - case BYTE: - size += 8 * encoders.encode(stringToEncode.substring(fromPosition, fromPosition + characterLength), - charsetEncoderIndex).length; - if (needECI) { - size += 4 + 8; // the ECI assignment numbers for ISO-8859-x, UTF-8 and UTF-16 are all 8 bit long - } - break; - } - cachedTotalSize = size; - } - } - - final class ResultList { - - private final List list = new ArrayList<>(); - private final Version version; - - ResultList(Version version, Edge solution) { - int length = 0; - Edge current = solution; - boolean containsECI = false; - - while (current != null) { - length += current.characterLength; - Edge previous = current.previous; - - boolean needECI = current.mode == Mode.BYTE && - (previous == null && current.charsetEncoderIndex != 0) || // at the beginning and charset is not ISO-8859-1 - (previous != null && current.charsetEncoderIndex != previous.charsetEncoderIndex); - - if (needECI) { - containsECI = true; - } - - if (previous == null || previous.mode != current.mode || needECI) { - list.add(0, new ResultNode(current.mode, current.fromPosition, current.charsetEncoderIndex, length)); - length = 0; - } - - if (needECI) { - list.add(0, new ResultNode(Mode.ECI, current.fromPosition, current.charsetEncoderIndex, 0)); - } - current = previous; - } - - // prepend FNC1 if needed. If the bits contain an ECI then the FNC1 must be preceeded by an ECI. - // If there is no ECI at the beginning then we put an ECI to the default charset (ISO-8859-1) - if (isGS1) { - ResultNode first = list.get(0); - if (first != null && first.mode != Mode.ECI && containsECI) { - // prepend a default character set ECI - list.add(0, new ResultNode(Mode.ECI, 0, 0, 0)); - } - first = list.get(0); - // prepend or insert a FNC1_FIRST_POSITION after the ECI (if any) - list.add(first.mode != Mode.ECI ? 0 : 1, new ResultNode(Mode.FNC1_FIRST_POSITION, 0, 0, 0)); - } - - // set version to smallest version into which the bits fit. - int versionNumber = version.getVersionNumber(); - int lowerLimit; - int upperLimit; - switch (getVersionSize(version)) { - case SMALL: - lowerLimit = 1; - upperLimit = 9; - break; - case MEDIUM: - lowerLimit = 10; - upperLimit = 26; - break; - case LARGE: - default: - lowerLimit = 27; - upperLimit = 40; - break; - } - int size = getSize(version); - // increase version if needed - while (versionNumber < upperLimit && !Encoder.willFit(size, Version.getVersionForNumber(versionNumber), - ecLevel)) { - versionNumber++; - } - // shrink version if possible - while (versionNumber > lowerLimit && Encoder.willFit(size, Version.getVersionForNumber(versionNumber - 1), - ecLevel)) { - versionNumber--; - } - this.version = Version.getVersionForNumber(versionNumber); - } - - /** - * returns the size in bits - */ - int getSize() { - return getSize(version); - } - - private int getSize(Version version) { - int result = 0; - for (ResultNode resultNode : list) { - result += resultNode.getSize(version); - } - return result; - } - - /** - * appends the bits - */ - void getBits(BitArray bits) throws WriterException { - for (ResultNode resultNode : list) { - resultNode.getBits(bits); - } - } - - Version getVersion() { - return version; - } - - public String toString() { - StringBuilder result = new StringBuilder(); - ResultNode previous = null; - for (ResultNode current : list) { - if (previous != null) { - result.append(","); - } - result.append(current.toString()); - previous = current; - } - return result.toString(); - } - - final class ResultNode { - - private final Mode mode; - private final int fromPosition; - private final int charsetEncoderIndex; - private final int characterLength; - - ResultNode(Mode mode, int fromPosition, int charsetEncoderIndex, int characterLength) { - this.mode = mode; - this.fromPosition = fromPosition; - this.charsetEncoderIndex = charsetEncoderIndex; - this.characterLength = characterLength; - } - - /** - * returns the size in bits - */ - private int getSize(Version version) { - int size = 4 + mode.getCharacterCountBits(version); - switch (mode) { - case KANJI: - size += 13 * characterLength; - break; - case ALPHANUMERIC: - size += (characterLength / 2) * 11; - size += (characterLength % 2) == 1 ? 6 : 0; - break; - case NUMERIC: - size += (characterLength / 3) * 10; - int rest = characterLength % 3; - size += rest == 1 ? 4 : rest == 2 ? 7 : 0; - break; - case BYTE: - size += 8 * getCharacterCountIndicator(); - break; - case ECI: - size += 8; // the ECI assignment numbers for ISO-8859-x, UTF-8 and UTF-16 are all 8 bit long - } - return size; - } - - /** - * returns the length in characters according to the specification (differs from getCharacterLength() in BYTE mode - * for multi byte encoded characters) - */ - private int getCharacterCountIndicator() { - return mode == Mode.BYTE ? - encoders.encode(stringToEncode.substring(fromPosition, fromPosition + characterLength), - charsetEncoderIndex).length : characterLength; - } - - /** - * appends the bits - */ - private void getBits(BitArray bits) throws WriterException { - bits.appendBits(mode.getBits(), 4); - if (characterLength > 0) { - int length = getCharacterCountIndicator(); - bits.appendBits(length, mode.getCharacterCountBits(version)); - } - if (mode == Mode.ECI) { - bits.appendBits(encoders.getECIValue(charsetEncoderIndex), 8); - } else if (characterLength > 0) { - // append data - Encoder.appendBytes(stringToEncode.substring(fromPosition, fromPosition + characterLength), mode, bits, - encoders.getCharset(charsetEncoderIndex)); - } - } - - public String toString() { - StringBuilder result = new StringBuilder(); - result.append(mode).append('('); - if (mode == Mode.ECI) { - result.append(encoders.getCharset(charsetEncoderIndex).displayName()); - } else { - result.append(makePrintable(stringToEncode.substring(fromPosition, fromPosition + characterLength))); - } - result.append(')'); - return result.toString(); - } - - private String makePrintable(String s) { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < s.length(); i++) { - if (s.charAt(i) < 32 || s.charAt(i) > 126) { - result.append('.'); - } else { - result.append(s.charAt(i)); - } - } - return result.toString(); - } - } - } -} diff --git a/port_src/core/DONE/qrcode/encoder/QRCode.java b/port_src/core/DONE/qrcode/encoder/QRCode.java deleted file mode 100644 index 4298703..0000000 --- a/port_src/core/DONE/qrcode/encoder/QRCode.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.encoder; - -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; -import com.google.zxing.qrcode.decoder.Mode; -import com.google.zxing.qrcode.decoder.Version; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author dswitkin@google.com (Daniel Switkin) - ported from C++ - */ -public final class QRCode { - - public static final int NUM_MASK_PATTERNS = 8; - - private Mode mode; - private ErrorCorrectionLevel ecLevel; - private Version version; - private int maskPattern; - private ByteMatrix matrix; - - public QRCode() { - maskPattern = -1; - } - - /** - * @return the mode. Not relevant if {@link com.google.zxing.EncodeHintType#QR_COMPACT} is selected. - */ - public Mode getMode() { - return mode; - } - - public ErrorCorrectionLevel getECLevel() { - return ecLevel; - } - - public Version getVersion() { - return version; - } - - public int getMaskPattern() { - return maskPattern; - } - - public ByteMatrix getMatrix() { - return matrix; - } - - @Override - public String toString() { - StringBuilder result = new StringBuilder(200); - result.append("<<\n"); - result.append(" mode: "); - result.append(mode); - result.append("\n ecLevel: "); - result.append(ecLevel); - result.append("\n version: "); - result.append(version); - result.append("\n maskPattern: "); - result.append(maskPattern); - if (matrix == null) { - result.append("\n matrix: null\n"); - } else { - result.append("\n matrix:\n"); - result.append(matrix); - } - result.append(">>\n"); - return result.toString(); - } - - public void setMode(Mode value) { - mode = value; - } - - public void setECLevel(ErrorCorrectionLevel value) { - ecLevel = value; - } - - public void setVersion(Version version) { - this.version = version; - } - - public void setMaskPattern(int value) { - maskPattern = value; - } - - public void setMatrix(ByteMatrix value) { - matrix = value; - } - - // Check if "mask_pattern" is valid. - public static boolean isValidMaskPattern(int maskPattern) { - return maskPattern >= 0 && maskPattern < NUM_MASK_PATTERNS; - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/BufferedImageLuminanceSource.java b/port_src/core/src/test/java/com/google/zxing/BufferedImageLuminanceSource.java deleted file mode 100644 index a777be5..0000000 --- a/port_src/core/src/test/java/com/google/zxing/BufferedImageLuminanceSource.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import java.awt.Graphics2D; -import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; -import java.awt.image.WritableRaster; - -/** - * This LuminanceSource implementation is meant for J2SE clients and our blackbox unit tests. - * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - * @author code@elektrowolle.de (Wolfgang Jung) - */ -public final class BufferedImageLuminanceSource extends LuminanceSource { - - private static final double MINUS_45_IN_RADIANS = -0.7853981633974483; // Math.toRadians(-45.0) - - private final BufferedImage image; - private final int left; - private final int top; - - public BufferedImageLuminanceSource(BufferedImage image) { - this(image, 0, 0, image.getWidth(), image.getHeight()); - } - - public BufferedImageLuminanceSource(BufferedImage image, int left, int top, int width, int height) { - super(width, height); - - if (image.getType() == BufferedImage.TYPE_BYTE_GRAY) { - this.image = image; - } else { - int sourceWidth = image.getWidth(); - int sourceHeight = image.getHeight(); - if (left + width > sourceWidth || top + height > sourceHeight) { - throw new IllegalArgumentException("Crop rectangle does not fit within image data."); - } - - this.image = new BufferedImage(sourceWidth, sourceHeight, BufferedImage.TYPE_BYTE_GRAY); - - WritableRaster raster = this.image.getRaster(); - int[] buffer = new int[width]; - for (int y = top; y < top + height; y++) { - image.getRGB(left, y, width, 1, buffer, 0, sourceWidth); - for (int x = 0; x < width; x++) { - int pixel = buffer[x]; - - // The color of fully-transparent pixels is irrelevant. They are often, technically, fully-transparent - // black (0 alpha, and then 0 RGB). They are often used, of course as the "white" area in a - // barcode image. Force any such pixel to be white: - if ((pixel & 0xFF000000) == 0) { - // white, so we know its luminance is 255 - buffer[x] = 0xFF; - } else { - // .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC), - // (306*R) >> 10 is approximately equal to R*0.299, and so on. - // 0x200 >> 10 is 0.5, it implements rounding. - buffer[x] = - (306 * ((pixel >> 16) & 0xFF) + - 601 * ((pixel >> 8) & 0xFF) + - 117 * (pixel & 0xFF) + - 0x200) >> 10; - } - } - raster.setPixels(left, y, width, 1, buffer); - } - - } - this.left = left; - this.top = top; - } - - @Override - public byte[] getRow(int y, byte[] row) { - if (y < 0 || y >= getHeight()) { - throw new IllegalArgumentException("Requested row is outside the image: " + y); - } - int width = getWidth(); - if (row == null || row.length < width) { - row = new byte[width]; - } - // The underlying raster of image consists of bytes with the luminance values - image.getRaster().getDataElements(left, top + y, width, 1, row); - return row; - } - - @Override - public byte[] getMatrix() { - int width = getWidth(); - int height = getHeight(); - int area = width * height; - byte[] matrix = new byte[area]; - // The underlying raster of image consists of area bytes with the luminance values - image.getRaster().getDataElements(left, top, width, height, matrix); - return matrix; - } - - @Override - public boolean isCropSupported() { - return true; - } - - @Override - public LuminanceSource crop(int left, int top, int width, int height) { - return new BufferedImageLuminanceSource(image, this.left + left, this.top + top, width, height); - } - - /** - * This is always true, since the image is a gray-scale image. - * - * @return true - */ - @Override - public boolean isRotateSupported() { - return true; - } - - @Override - public LuminanceSource rotateCounterClockwise() { - int sourceWidth = image.getWidth(); - int sourceHeight = image.getHeight(); - - // Rotate 90 degrees counterclockwise. - AffineTransform transform = new AffineTransform(0.0, -1.0, 1.0, 0.0, 0.0, sourceWidth); - - // Note width/height are flipped since we are rotating 90 degrees. - BufferedImage rotatedImage = new BufferedImage(sourceHeight, sourceWidth, BufferedImage.TYPE_BYTE_GRAY); - - // Draw the original image into rotated, via transformation - Graphics2D g = rotatedImage.createGraphics(); - g.drawImage(image, transform, null); - g.dispose(); - - // Maintain the cropped region, but rotate it too. - int width = getWidth(); - return new BufferedImageLuminanceSource(rotatedImage, top, sourceWidth - (left + width), getHeight(), width); - } - - @Override - public LuminanceSource rotateCounterClockwise45() { - int width = getWidth(); - int height = getHeight(); - - int oldCenterX = left + width / 2; - int oldCenterY = top + height / 2; - - // Rotate 45 degrees counterclockwise. - AffineTransform transform = AffineTransform.getRotateInstance(MINUS_45_IN_RADIANS, oldCenterX, oldCenterY); - - int sourceDimension = Math.max(image.getWidth(), image.getHeight()); - BufferedImage rotatedImage = new BufferedImage(sourceDimension, sourceDimension, BufferedImage.TYPE_BYTE_GRAY); - - // Draw the original image into rotated, via transformation - Graphics2D g = rotatedImage.createGraphics(); - g.drawImage(image, transform, null); - g.dispose(); - - int halfDimension = Math.max(width, height) / 2; - int newLeft = Math.max(0, oldCenterX - halfDimension); - int newTop = Math.max(0, oldCenterY - halfDimension); - int newRight = Math.min(sourceDimension - 1, oldCenterX + halfDimension); - int newBottom = Math.min(sourceDimension - 1, oldCenterY + halfDimension); - - return new BufferedImageLuminanceSource(rotatedImage, newLeft, newTop, newRight - newLeft, newBottom - newTop); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/InvertedLuminanceSourceTestCase.java b/port_src/core/src/test/java/com/google/zxing/InvertedLuminanceSourceTestCase.java deleted file mode 100644 index 932a7e2..0000000 --- a/port_src/core/src/test/java/com/google/zxing/InvertedLuminanceSourceTestCase.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2020 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import org.junit.Assert; -import org.junit.Test; - -import java.awt.image.BufferedImage; - -/** - * Tests {@link InvertedLuminanceSource}. - */ -public final class InvertedLuminanceSourceTestCase extends Assert { - - @Test - public void testInverted() { - BufferedImage image = new BufferedImage(2, 1, BufferedImage.TYPE_INT_RGB); - image.setRGB(0, 0, 0xFFFFFF); - LuminanceSource source = new BufferedImageLuminanceSource(image); - assertArrayEquals(new byte[] { (byte) 0xFF, 0 }, source.getRow(0, null)); - LuminanceSource inverted = new InvertedLuminanceSource(source); - assertArrayEquals(new byte[] { 0, (byte) 0xFF }, inverted.getRow(0, null)); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/PlanarYUVLuminanceSourceTestCase.java b/port_src/core/src/test/java/com/google/zxing/PlanarYUVLuminanceSourceTestCase.java deleted file mode 100644 index 4d5912a..0000000 --- a/port_src/core/src/test/java/com/google/zxing/PlanarYUVLuminanceSourceTestCase.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2014 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link PlanarYUVLuminanceSource}. - */ -public final class PlanarYUVLuminanceSourceTestCase extends Assert { - - private static final byte[] YUV = { - 0, 1, 1, 2, 3, 5, - 8, 13, 21, 34, 55, 89, - 0, -1, -1, -2, -3, -5, - -8, -13, -21, -34, -55, -89, - 127, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 127, 127, - }; - private static final int COLS = 6; - private static final int ROWS = 4; - private static final byte[] Y = new byte[COLS * ROWS]; - static { - System.arraycopy(YUV, 0, Y, 0, Y.length); - } - - @Test - public void testNoCrop() { - PlanarYUVLuminanceSource source = - new PlanarYUVLuminanceSource(YUV, COLS, ROWS, 0, 0, COLS, ROWS, false); - assertEquals(Y, 0, source.getMatrix(), 0, Y.length); - for (int r = 0; r < ROWS; r++) { - assertEquals(Y, r * COLS, source.getRow(r, null), 0, COLS); - } - } - - @Test - public void testCrop() { - PlanarYUVLuminanceSource source = - new PlanarYUVLuminanceSource(YUV, COLS, ROWS, 1, 1, COLS - 2, ROWS - 2, false); - assertTrue(source.isCropSupported()); - byte[] cropMatrix = source.getMatrix(); - for (int r = 0; r < ROWS - 2; r++) { - assertEquals(Y, (r + 1) * COLS + 1, cropMatrix, r * (COLS - 2), COLS - 2); - } - for (int r = 0; r < ROWS - 2; r++) { - assertEquals(Y, (r + 1) * COLS + 1, source.getRow(r, null), 0, COLS - 2); - } - } - - @Test - public void testThumbnail() { - PlanarYUVLuminanceSource source = - new PlanarYUVLuminanceSource(YUV, COLS, ROWS, 0, 0, COLS, ROWS, false); - assertArrayEquals( - new int[] { 0xFF000000, 0xFF010101, 0xFF030303, 0xFF000000, 0xFFFFFFFF, 0xFFFDFDFD }, - source.renderThumbnail()); - } - - private static void assertEquals(byte[] expected, int expectedFrom, - byte[] actual, int actualFrom, - int length) { - for (int i = 0; i < length; i++) { - assertEquals(expected[expectedFrom + i], actual[actualFrom + i]); - } - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/RGBLuminanceSourceTestCase.java b/port_src/core/src/test/java/com/google/zxing/RGBLuminanceSourceTestCase.java deleted file mode 100644 index 97f9794..0000000 --- a/port_src/core/src/test/java/com/google/zxing/RGBLuminanceSourceTestCase.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2014 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing; - -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link RGBLuminanceSource}. - */ -public final class RGBLuminanceSourceTestCase extends Assert { - - private static final RGBLuminanceSource SOURCE = new RGBLuminanceSource(3, 3, new int[] { - 0x000000, 0x7F7F7F, 0xFFFFFF, - 0xFF0000, 0x00FF00, 0x0000FF, - 0x0000FF, 0x00FF00, 0xFF0000}); - - @Test - public void testCrop() { - assertTrue(SOURCE.isCropSupported()); - LuminanceSource cropped = SOURCE.crop(1, 1, 1, 1); - assertEquals(1, cropped.getHeight()); - assertEquals(1, cropped.getWidth()); - assertArrayEquals(new byte[] { 0x7F }, cropped.getRow(0, null)); - } - - @Test - public void testMatrix() { - assertArrayEquals(new byte[] { 0x00, 0x7F, (byte) 0xFF, 0x3F, 0x7F, 0x3F, 0x3F, 0x7F, 0x3F }, - SOURCE.getMatrix()); - LuminanceSource croppedFullWidth = SOURCE.crop(0, 1, 3, 2); - assertArrayEquals(new byte[] { 0x3F, 0x7F, 0x3F, 0x3F, 0x7F, 0x3F }, - croppedFullWidth.getMatrix()); - LuminanceSource croppedCorner = SOURCE.crop(1, 1, 2, 2); - assertArrayEquals(new byte[] { 0x7F, 0x3F, 0x7F, 0x3F }, - croppedCorner.getMatrix()); - } - - @Test - public void testGetRow() { - assertArrayEquals(new byte[] { 0x3F, 0x7F, 0x3F }, SOURCE.getRow(2, new byte[3])); - } - - @Test - public void testToString() { - assertEquals("#+ \n#+#\n#+#\n", SOURCE.toString()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/aztec/AztecBlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/aztec/AztecBlackBox1TestCase.java deleted file mode 100644 index 029abf2..0000000 --- a/port_src/core/src/test/java/com/google/zxing/aztec/AztecBlackBox1TestCase.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author David Olivier - */ -public final class AztecBlackBox1TestCase extends AbstractBlackBoxTestCase { - - public AztecBlackBox1TestCase() { - super("src/test/resources/blackbox/aztec-1", new AztecReader(), BarcodeFormat.AZTEC); - addTest(14, 14, 0.0f); - addTest(14, 14, 90.0f); - addTest(14, 14, 180.0f); - addTest(14, 14, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/aztec/AztecBlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/aztec/AztecBlackBox2TestCase.java deleted file mode 100644 index e250ae2..0000000 --- a/port_src/core/src/test/java/com/google/zxing/aztec/AztecBlackBox2TestCase.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A test of Aztec barcodes under real world lighting conditions, taken with a mobile phone. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class AztecBlackBox2TestCase extends AbstractBlackBoxTestCase { - - public AztecBlackBox2TestCase() { - super("src/test/resources/blackbox/aztec-2", new AztecReader(), BarcodeFormat.AZTEC); - addTest(5, 5, 0.0f); - addTest(4, 4, 90.0f); - addTest(6, 6, 180.0f); - addTest(3, 3, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java b/port_src/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java deleted file mode 100644 index e7cafa2..0000000 --- a/port_src/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2014 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.zxing.aztec.decoder; - -import com.google.zxing.aztec.encoder.EncoderTest; - -import com.google.zxing.FormatException; -import com.google.zxing.ResultPoint; -import com.google.zxing.aztec.AztecDetectorResult; -import com.google.zxing.common.BitArray; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import org.junit.Test; -import org.junit.Assert; - -/** - * Tests {@link Decoder}. - */ -public final class DecoderTest extends Assert { - - private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; - - @Test - public void testHighLevelDecode() throws FormatException { - // no ECI codes - testHighLevelDecodeString("A. b.", - // 'A' P/S '. ' L/L b D/L '.' - "...X. ..... ...XX XXX.. ...XX XXXX. XX.X"); - - // initial ECI code 26 (switch to UTF-8) - testHighLevelDecodeString("Ça", - // P/S FLG(n) 2 '2' '6' B/S 2 0xc3 0x87 L/L 'a' - "..... ..... .X. .X.. X... XXXXX ...X. XX....XX X....XXX XXX.. ...X."); - - // initial character without ECI (must be interpreted as ISO_8859_1) - // followed by ECI code 26 (= UTF-8) and UTF-8 text - testHighLevelDecodeString("±Ça", - // B/S 1 0xb1 P/S FLG(n) 2 '2' '6' B/S 2 0xc3 0x87 L/L 'a' - "XXXXX ....X X.XX...X ..... ..... .X. .X.. X... XXXXX ...X. XX....XX X....XXX XXX.. ...X."); - - // GS1 data - testHighLevelDecodeString("101233742", - // P/S FLG(n) 0 D/L 1 0 1 2 3 P/S FLG(n) 0 3 7 4 2 - "..... ..... ... XXXX. ..XX ..X. ..XX .X.. .X.X .... ..... ... .X.X X..X .XX. .X.."); - } - - private static void testHighLevelDecodeString(String expectedString, String b) throws FormatException { - BitArray bits = EncoderTest.toBitArray(EncoderTest.stripSpace(b)); - assertEquals("highLevelDecode() failed for input bits: " + b, - expectedString, Decoder.highLevelDecode(EncoderTest.toBooleanArray(bits))); - } - - @Test - public void testAztecResult() throws FormatException { - BitMatrix matrix = BitMatrix.parse( - "X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X \n" + - " X X X X X X X X X X \n" + - " X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X \n" + - " X X X X X X X X X X X \n" + - " X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X \n" + - " X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X \n", - "X ", " "); - AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, false, 30, 2); - DecoderResult result = new Decoder().decode(r); - assertEquals("88888TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT", result.getText()); - assertArrayEquals( - new byte[] {-11, 85, 85, 117, 107, 90, -42, -75, -83, 107, - 90, -42, -75, -83, 107, 90, -42, -75, -83, 107, - 90, -42, -80}, - result.getRawBytes()); - assertEquals(180, result.getNumBits()); - } - - @Test - public void testAztecResultECI() throws FormatException { - BitMatrix matrix = BitMatrix.parse( - " X X X X X X \n" + - " X X X X X X X X X X X X \n" + - " X X X X \n" + - " X X X X X X X X X X X X X X X X X \n" + - " X X \n" + - " X X X X X X X X X X X X \n" + - " X X X X X X X X \n" + - " X X X X X X X X X X X X \n" + - " X X X X X X X X \n" + - " X X X X X X X X X \n" + - "X X X X X X X X X \n" + - " X X X X X X X X X X X X \n" + - " X X X X X X \n" + - " X X X X X X X X X X X X X \n" + - " X X X \n" + - "X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X \n" + - " X X X X X X X X X X X \n" + - "X X X X X X X X \n", - "X ", " "); - AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, false, 15, 1); - DecoderResult result = new Decoder().decode(r); - assertEquals("Français", result.getText()); - } - - @Test(expected = FormatException.class) - public void testDecodeTooManyErrors() throws FormatException { - BitMatrix matrix = BitMatrix.parse("" - + "X X . X . . . X X . . . X . . X X X . X . X X X X X . \n" - + "X X . . X X . . . . . X X . . . X X . . . X . X . . X \n" - + "X . . . X X . . X X X . X X . X X X X . X X . . X . . \n" - + ". . . . X . X X . . X X . X X . X . X X X X . X . . X \n" - + "X X X . . X X X X X . . . . . X X . . . X . X . X . X \n" - + "X X . . . . . . . . X . . . X . X X X . X . . X . . . \n" - + "X X . . X . . . . . X X . . . . . X . . . . X . . X X \n" - + ". . . X . X . X . . . . . X X X X X X . . . . . . X X \n" - + "X . . . X . X X X X X X . . X X X . X . X X X X X X . \n" - + "X . . X X X . X X X X X X X X X X X X X . . . X . X X \n" - + ". . . . X X . . . X . . . . . . . X X . . . X X . X . \n" - + ". . . X X X . . X X . X X X X X . X . . X . . . . . . \n" - + "X . . . . X . X . X . X . . . X . X . X X . X X . X X \n" - + "X . X . . X . X . X . X . X . X . X . . . . . X . X X \n" - + "X . X X X . . X . X . X . . . X . X . X X X . . . X X \n" - + "X X X X X X X X . X . X X X X X . X . X . X . X X X . \n" - + ". . . . . . . X . X . . . . . . . X X X X . . . X X X \n" - + "X X . . X . . X . X X X X X X X X X X X X X . . X . X \n" - + "X X X . X X X X . . X X X X . . X . . . . X . . X X X \n" - + ". . . . X . X X X . . . . X X X X . . X X X X . . . . \n" - + ". . X . . X . X . . . X . X X . X X . X . . . X . X . \n" - + "X X . . X . . X X X X X X X . . X . X X X X X X X . . \n" - + "X . X X . . X X . . . . . X . . . . . . X X . X X X . \n" - + "X . . X X . . X X . X . X . . . . X . X . . X . . X . \n" - + "X . X . X . . X . X X X X X X X X . X X X X . . X X . \n" - + "X X X X . . . X . . X X X . X X . . X . . . . X X X . \n" - + "X X . X . X . . . X . X . . . . X X . X . . X X . . . \n", - "X ", ". "); - AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, true, 16, 4); - new Decoder().decode(r); - } - - @Test(expected = FormatException.class) - public void testDecodeTooManyErrors2() throws FormatException { - BitMatrix matrix = BitMatrix.parse("" - + ". X X . . X . X X . . . X . . X X X . . . X X . X X . \n" - + "X X . X X . . X . . . X X . . . X X . X X X . X . X X \n" - + ". . . . X . . . X X X . X X . X X X X . X X . . X . . \n" - + "X . X X . . X . . . X X . X X . X . X X . . . . . X . \n" - + "X X . X . . X . X X . . . . . X X . . . . . X . . . X \n" - + "X . . X . . . . . . X . . . X . X X X X X X X . . . X \n" - + "X . . X X . . X . . X X . . . . . X . . . . . X X X . \n" - + ". . X X X X . X . . . . . X X X X X X . . . . . . X X \n" - + "X . . . X . X X X X X X . . X X X . X . X X X X X X . \n" - + "X . . X X X . X X X X X X X X X X X X X . . . X . X X \n" - + ". . . . X X . . . X . . . . . . . X X . . . X X . X . \n" - + ". . . X X X . . X X . X X X X X . X . . X . . . . . . \n" - + "X . . . . X . X . X . X . . . X . X . X X . X X . X X \n" - + "X . X . . X . X . X . X . X . X . X . . . . . X . X X \n" - + "X . X X X . . X . X . X . . . X . X . X X X . . . X X \n" - + "X X X X X X X X . X . X X X X X . X . X . X . X X X . \n" - + ". . . . . . . X . X . . . . . . . X X X X . . . X X X \n" - + "X X . . X . . X . X X X X X X X X X X X X X . . X . X \n" - + "X X X . X X X X . . X X X X . . X . . . . X . . X X X \n" - + ". . X X X X X . X . . . . X X X X . . X X X . X . X . \n" - + ". . X X . X . X . . . X . X X . X X . . . . X X . . . \n" - + "X . . . X . X . X X X X X X . . X . X X X X X . X . . \n" - + ". X . . . X X X . . . . . X . . . . . X X X X X . X . \n" - + "X . . X . X X X X . X . X . . . . X . X X . X . . X . \n" - + "X . . . X X . X . X X X X X X X X . X X X X . . X X . \n" - + ". X X X X . . X . . X X X . X X . . X . . . . X X X . \n" - + "X X . . . X X . . X . X . . . . X X . X . . X . X . X \n", - "X ", ". "); - AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, true, 16, 4); - new Decoder().decode(r); - } - - @Test - public void testRawBytes() { - boolean[] bool0 = {}; - boolean[] bool1 = { true }; - boolean[] bool7 = { true, false, true, false, true, false, true }; - boolean[] bool8 = { true, false, true, false, true, false, true, false }; - boolean[] bool9 = { true, false, true, false, true, false, true, false, - true }; - boolean[] bool16 = { false, true, true, false, false, false, true, true, - true, true, false, false, false, false, false, true }; - byte[] byte0 = {}; - byte[] byte1 = { -128 }; - byte[] byte7 = { -86 }; - byte[] byte8 = { -86 }; - byte[] byte9 = { -86, -128 }; - byte[] byte16 = { 99, -63 }; - - assertArrayEquals(byte0, Decoder.convertBoolArrayToByteArray(bool0)); - assertArrayEquals(byte1, Decoder.convertBoolArrayToByteArray(bool1)); - assertArrayEquals(byte7, Decoder.convertBoolArrayToByteArray(bool7)); - assertArrayEquals(byte8, Decoder.convertBoolArrayToByteArray(bool8)); - assertArrayEquals(byte9, Decoder.convertBoolArrayToByteArray(bool9)); - assertArrayEquals(byte16, Decoder.convertBoolArrayToByteArray(bool16)); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/aztec/detector/DetectorTest.java b/port_src/core/src/test/java/com/google/zxing/aztec/detector/DetectorTest.java deleted file mode 100644 index 6d3afa6..0000000 --- a/port_src/core/src/test/java/com/google/zxing/aztec/detector/DetectorTest.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec.detector; - -import com.google.zxing.NotFoundException; -import com.google.zxing.aztec.AztecDetectorResult; -import com.google.zxing.aztec.decoder.Decoder; -import com.google.zxing.aztec.detector.Detector.Point; -import com.google.zxing.aztec.encoder.AztecCode; -import com.google.zxing.aztec.encoder.Encoder; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Random; -import java.util.TreeSet; - -/** - * Tests for the Detector - * - * @author Frank Yellin - */ -public final class DetectorTest extends Assert { - - @Test - public void testErrorInParameterLocatorZeroZero() throws Exception { - // Layers=1, CodeWords=1. So the parameter info and its Reed-Solomon info - // will be completely zero! - testErrorInParameterLocator("X"); - } - - @Test - public void testErrorInParameterLocatorCompact() throws Exception { - testErrorInParameterLocator("This is an example Aztec symbol for Wikipedia."); - } - - @Test - public void testErrorInParameterLocatorNotCompact() throws Exception { - String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxyz"; - testErrorInParameterLocator(alphabet + alphabet + alphabet); - } - - // Test that we can tolerate errors in the parameter locator bits - private static void testErrorInParameterLocator(String data) throws Exception { - AztecCode aztec = Encoder.encode(data, 25, Encoder.DEFAULT_AZTEC_LAYERS); - Random random = new Random(aztec.getMatrix().hashCode()); // pseudo-random, but deterministic - int layers = aztec.getLayers(); - boolean compact = aztec.isCompact(); - List orientationPoints = getOrientationPoints(aztec); - for (boolean isMirror : new boolean[] { false, true }) { - for (BitMatrix matrix : getRotations(aztec.getMatrix())) { - // Systematically try every possible 1- and 2-bit error. - for (int error1 = 0; error1 < orientationPoints.size(); error1++) { - for (int error2 = error1; error2 < orientationPoints.size(); error2++) { - BitMatrix copy = isMirror ? transpose(matrix) : clone(matrix); - copy.flip(orientationPoints.get(error1).getX(), orientationPoints.get(error1).getY()); - if (error2 > error1) { - // if error2 == error1, we only test a single error - copy.flip(orientationPoints.get(error2).getX(), orientationPoints.get(error2).getY()); - } - // The detector doesn't seem to work when matrix bits are only 1x1. So magnify. - AztecDetectorResult r = new Detector(makeLarger(copy, 3)).detect(isMirror); - assertNotNull(r); - assertEquals(r.getNbLayers(), layers); - assertEquals(r.isCompact(), compact); - DecoderResult res = new Decoder().decode(r); - assertEquals(data, res.getText()); - } - } - // Try a few random three-bit errors; - for (int i = 0; i < 5; i++) { - BitMatrix copy = clone(matrix); - Collection errors = new TreeSet<>(); - while (errors.size() < 3) { - // Quick and dirty way of getting three distinct integers between 1 and n. - errors.add(random.nextInt(orientationPoints.size())); - } - for (int error : errors) { - copy.flip(orientationPoints.get(error).getX(), orientationPoints.get(error).getY()); - } - try { - new Detector(makeLarger(copy, 3)).detect(false); - fail("Should not reach here"); - } catch (NotFoundException expected) { - // continue - } - } - } - } - } - - // Zooms a bit matrix so that each bit is factor x factor - private static BitMatrix makeLarger(BitMatrix input, int factor) { - int width = input.getWidth(); - BitMatrix output = new BitMatrix(width * factor); - for (int inputY = 0; inputY < width; inputY++) { - for (int inputX = 0; inputX < width; inputX++) { - if (input.get(inputX, inputY)) { - output.setRegion(inputX * factor, inputY * factor, factor, factor); - } - } - } - return output; - } - - // Returns a list of the four rotations of the BitMatrix. - private static Iterable getRotations(BitMatrix matrix0) { - BitMatrix matrix90 = rotateRight(matrix0); - BitMatrix matrix180 = rotateRight(matrix90); - BitMatrix matrix270 = rotateRight(matrix180); - return Arrays.asList(matrix0, matrix90, matrix180, matrix270); - } - - // Rotates a square BitMatrix to the right by 90 degrees - private static BitMatrix rotateRight(BitMatrix input) { - int width = input.getWidth(); - BitMatrix result = new BitMatrix(width); - for (int x = 0; x < width; x++) { - for (int y = 0; y < width; y++) { - if (input.get(x,y)) { - result.set(y, width - x - 1); - } - } - } - return result; - } - - // Returns the transpose of a bit matrix, which is equivalent to rotating the - // matrix to the right, and then flipping it left-to-right - private static BitMatrix transpose(BitMatrix input) { - int width = input.getWidth(); - BitMatrix result = new BitMatrix(width); - for (int x = 0; x < width; x++) { - for (int y = 0; y < width; y++) { - if (input.get(x, y)) { - result.set(y, x); - } - } - } - return result; - } - - private static BitMatrix clone(BitMatrix input) { - int width = input.getWidth(); - BitMatrix result = new BitMatrix(width); - for (int x = 0; x < width; x++) { - for (int y = 0; y < width; y++) { - if (input.get(x,y)) { - result.set(x,y); - } - } - } - return result; - } - - private static List getOrientationPoints(AztecCode code) { - int center = code.getMatrix().getWidth() / 2; - int offset = code.isCompact() ? 5 : 7; - List result = new ArrayList<>(); - for (int xSign = -1; xSign <= 1; xSign += 2) { - for (int ySign = -1; ySign <= 1; ySign += 2) { - result.add(new Point(center + xSign * offset, center + ySign * offset)); - result.add(new Point(center + xSign * (offset - 1), center + ySign * offset)); - result.add(new Point(center + xSign * offset, center + ySign * (offset - 1))); - } - } - return result; - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java b/port_src/core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java deleted file mode 100644 index b8aa838..0000000 --- a/port_src/core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java +++ /dev/null @@ -1,603 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.aztec.encoder; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.ResultPoint; -import com.google.zxing.aztec.AztecDetectorResult; -import com.google.zxing.aztec.AztecWriter; -import com.google.zxing.aztec.decoder.Decoder; -import com.google.zxing.common.BitArray; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import org.junit.Assert; -import org.junit.Test; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.EnumMap; -import java.util.Map; -import java.util.Random; -import java.util.regex.Pattern; - -/** - * Aztec 2D generator unit tests. - * - * @author Rustam Abdullaev - * @author Frank Yellin - */ -public final class EncoderTest extends Assert { - - private static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1; - private static final Charset UTF_8 = StandardCharsets.UTF_8; - private static final Charset SHIFT_JIS = Charset.forName("Shift_JIS"); - private static final Charset ISO_8859_15 = Charset.forName("ISO-8859-15"); - private static final Charset WINDOWS_1252 = Charset.forName("Windows-1252"); - - private static final Pattern DOTX = Pattern.compile("[^.X]"); - private static final Pattern SPACES = Pattern.compile("\\s+"); - private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; - - // real life tests - - @Test - public void testEncode1() { - testEncode("This is an example Aztec symbol for Wikipedia.", true, 3, - "X X X X X X X X \n" + - "X X X X X X X X X X \n" + - "X X X X X X X X X X X \n" + - "X X X X X X X X X X X \n" + - " X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X \n" + - "X X X X X X X X X X \n" + - " X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X \n" + - " X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X \n" + - " X X X \n" + - " X X X X X X X X X X \n" + - " X X X X X X X X X X \n"); - } - - @Test - public void testEncode2() { - testEncode("Aztec Code is a public domain 2D matrix barcode symbology" + - " of nominally square symbols built on a square grid with a " + - "distinctive square bullseye pattern at their center.", false, 6, - " X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X \n" + - " X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X \n"); - } - - @Test - public void testAztecWriter() throws Exception { - testWriter("Espa\u00F1ol", null, 25, true, 1); // Without ECI (implicit ISO-8859-1) - testWriter("Espa\u00F1ol", ISO_8859_1, 25, true, 1); // Explicit ISO-8859-1 - testWriter("\u20AC 1 sample data.", WINDOWS_1252, 25, true, 2); // ISO-8859-1 can't encode Euro; Windows-1252 can - testWriter("\u20AC 1 sample data.", ISO_8859_15, 25, true, 2); - testWriter("\u20AC 1 sample data.", UTF_8, 25, true, 2); - testWriter("\u20AC 1 sample data.", UTF_8, 100, true, 3); - testWriter("\u20AC 1 sample data.", UTF_8, 300, true, 4); - testWriter("\u20AC 1 sample data.", UTF_8, 500, false, 5); - testWriter("The capital of Japan is named \u6771\u4EAC.", SHIFT_JIS, 25, true, 3); - // Test AztecWriter defaults - String data = "In ut magna vel mauris malesuada"; - AztecWriter writer = new AztecWriter(); - BitMatrix matrix = writer.encode(data, BarcodeFormat.AZTEC, 0, 0); - AztecCode aztec = Encoder.encode(data, - Encoder.DEFAULT_EC_PERCENT, Encoder.DEFAULT_AZTEC_LAYERS); - BitMatrix expectedMatrix = aztec.getMatrix(); - assertEquals(matrix, expectedMatrix); - } - - // synthetic tests (encode-decode round-trip) - - @Test - public void testEncodeDecode1() throws Exception { - testEncodeDecode("Abc123!", true, 1); - } - - @Test - public void testEncodeDecode2() throws Exception { - testEncodeDecode("Lorem ipsum. http://test/", true, 2); - } - - @Test - public void testEncodeDecode3() throws Exception { - testEncodeDecode("AAAANAAAANAAAANAAAANAAAANAAAANAAAANAAAANAAAANAAAAN", true, 3); - } - - @Test - public void testEncodeDecode4() throws Exception { - testEncodeDecode("http://test/~!@#*^%&)__ ;:'\"[]{}\\|-+-=`1029384", true, 4); - } - - @Test - public void testEncodeDecode5() throws Exception { - testEncodeDecode("http://test/~!@#*^%&)__ ;:'\"[]{}\\|-+-=`1029384756<>/?abc" - + "Four score and seven our forefathers brought forth", false, 5); - } - - @Test - public void testEncodeDecode10() throws Exception { - testEncodeDecode("In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam" + - " cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum" + - " est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue" + - " auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla" + - " ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id" + - " elementum sapien dolor et diam.", false, 10); - } - - @Test - public void testEncodeDecode23() throws Exception { - testEncodeDecode("In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam" + - " cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum" + - " est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue" + - " auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla" + - " ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id" + - " elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend." + - " Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus" + - " justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu" + - " tristique ac, p.In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus" + - " quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec" + - " laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida," + - " justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec" + - " lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar" + - " nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat" + - " eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra" + - " fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo" + - " diam, lobortis eu tristique ac, p. In ut magna vel mauris malesuada dictum. Nulla" + - " ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum" + - " sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet." + - " Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit" + - " felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo" + - " erat pulvinar nisi, id elementum sapien dolor et diam.", false, 23); - } - - @Test - public void testEncodeDecode31() throws Exception { - testEncodeDecode("In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam" + - " cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum" + - " est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue" + - " auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla" + - " ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id" + - " elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend." + - " Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus" + - " justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu" + - " tristique ac, p.In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus" + - " quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec" + - " laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida," + - " justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec" + - " lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar" + - " nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat" + - " eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra" + - " fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo" + - " diam, lobortis eu tristique ac, p. In ut magna vel mauris malesuada dictum. Nulla" + - " ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum" + - " sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet." + - " Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit" + - " felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo" + - " erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit" + - " placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at" + - " pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est." + - " Ut justo diam, lobortis eu tristique ac, p.In ut magna vel mauris malesuada" + - " dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id" + - " justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum" + - " sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat," + - " eget hendrerit felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet" + - " laoreet, justo erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac" + - " nunc sodales elit placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula," + - " massa at pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus" + - " sed est. Ut justo diam, lobortis eu tris. In ut magna vel mauris malesuada dictum." + - " Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum" + - " sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet." + - " Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget" + - " hendrerit felis turpis nec lorem.", false, 31); - } - - @Test - public void testGenerateModeMessage() { - testModeMessage(true, 2, 29, ".X .XXX.. ...X XX.. ..X .XX. .XX.X"); - testModeMessage(true, 4, 64, "XX XXXXXX .X.. ...X ..XX .X.. XX.."); - testModeMessage(false, 21, 660, "X.X.. .X.X..X..XX .XXX ..X.. .XXX. .X... ..XXX"); - testModeMessage(false, 32, 4096, "XXXXX XXXXXXXXXXX X.X. ..... XXX.X ..X.. X.XXX"); - } - - @Test - public void testStuffBits() { - testStuffBits(5, ".X.X. X.X.X .X.X.", - ".X.X. X.X.X .X.X."); - testStuffBits(5, ".X.X. ..... .X.X", - ".X.X. ....X ..X.X"); - testStuffBits(3, "XX. ... ... ..X XXX .X. ..", - "XX. ..X ..X ..X ..X .XX XX. .X. ..X"); - testStuffBits(6, ".X.X.. ...... ..X.XX", - ".X.X.. .....X. ..X.XX XXXX."); - testStuffBits(6, ".X.X.. ...... ...... ..X.X.", - ".X.X.. .....X .....X ....X. X.XXXX"); - testStuffBits(6, ".X.X.. XXXXXX ...... ..X.XX", - ".X.X.. XXXXX. X..... ...X.X XXXXX."); - testStuffBits(6, - "...... ..XXXX X..XX. .X.... .X.X.X .....X .X.... ...X.X .....X ....XX ..X... ....X. X..XXX X.XX.X", - ".....X ...XXX XX..XX ..X... ..X.X. X..... X.X... ....X. X..... X....X X..X.. .....X X.X..X XXX.XX .XXXXX"); - } - - @Test - public void testHighLevelEncode() throws FormatException { - testHighLevelEncodeString("A. b.", - // 'A' P/S '. ' L/L b D/L '.' - "...X. ..... ...XX XXX.. ...XX XXXX. XX.X"); - testHighLevelEncodeString("Lorem ipsum.", - // 'L' L/L 'o' 'r' 'e' 'm' ' ' 'i' 'p' 's' 'u' 'm' D/L '.' - ".XX.X XXX.. X.... X..XX ..XX. .XXX. ....X .X.X. X...X X.X.. X.XX. .XXX. XXXX. XX.X"); - testHighLevelEncodeString("Lo. Test 123.", - // 'L' L/L 'o' P/S '. ' U/S 'T' 'e' 's' 't' D/L ' ' '1' '2' '3' '.' - ".XX.X XXX.. X.... ..... ...XX XXX.. X.X.X ..XX. X.X.. X.X.X XXXX. ...X ..XX .X.. .X.X XX.X"); - testHighLevelEncodeString("Lo...x", - // 'L' L/L 'o' D/L '.' '.' '.' U/L L/L 'x' - ".XX.X XXX.. X.... XXXX. XX.X XX.X XX.X XXX. XXX.. XX..X"); - testHighLevelEncodeString(". x://abc/.", - //P/S '. ' L/L 'x' P/S ':' P/S '/' P/S '/' 'a' 'b' 'c' P/S '/' D/L '.' - "..... ...XX XXX.. XX..X ..... X.X.X ..... X.X.. ..... X.X.. ...X. ...XX ..X.. ..... X.X.. XXXX. XX.X"); - // Uses Binary/Shift rather than Lower/Shift to save two bits. - testHighLevelEncodeString("ABCdEFG", - //'A' 'B' 'C' B/S =1 'd' 'E' 'F' 'G' - "...X. ...XX ..X.. XXXXX ....X .XX..X.. ..XX. ..XXX .X..."); - - testHighLevelEncodeString( - // Found on an airline boarding pass. Several stretches of Binary shift are - // necessary to keep the bitcount so low. - "09 UAG ^160MEUCIQC0sYS/HpKxnBELR1uB85R20OoqqwFGa0q2uEi" - + "Ygh6utAIgLl1aBVM4EOTQtMQQYH9M2Z3Dp4qnA/fwWuQ+M8L3V8U=", - 823); - } - - @Test - public void testHighLevelEncodeBinary() throws FormatException { - // binary short form single byte - testHighLevelEncodeString("N\0N", - // 'N' B/S =1 '\0' N - ".XXXX XXXXX ....X ........ .XXXX"); // Encode "N" in UPPER - - testHighLevelEncodeString("N\0n", - // 'N' B/S =2 '\0' 'n' - ".XXXX XXXXX ...X. ........ .XX.XXX."); // Encode "n" in BINARY - - // binary short form consecutive bytes - testHighLevelEncodeString("N\0\u0080 A", - // 'N' B/S =2 '\0' \u0080 ' ' 'A' - ".XXXX XXXXX ...X. ........ X....... ....X ...X."); - - // binary skipping over single character - testHighLevelEncodeString("\0a\u00FF\u0080 A", - // B/S =4 '\0' 'a' '\3ff' '\200' ' ' 'A' - "XXXXX ..X.. ........ .XX....X XXXXXXXX X....... ....X ...X."); - - // getting into binary mode from digit mode - testHighLevelEncodeString("1234\0", - //D/L '1' '2' '3' '4' U/L B/S =1 \0 - "XXXX. ..XX .X.. .X.X .XX. XXX. XXXXX ....X ........" - ); - - // Create a string in which every character requires binary - StringBuilder sb = new StringBuilder(); - for (int i = 0; i <= 3000; i++) { - sb.append((char) (128 + (i % 30))); - } - // Test the output generated by Binary/Switch, particularly near the - // places where the encoding changes: 31, 62, and 2047+31=2078 - for (int i : new int[] { 1, 2, 3, 10, 29, 30, 31, 32, 33, - 60, 61, 62, 63, 64, 2076, 2077, 2078, 2079, 2080, 2100 }) { - // This is the expected length of a binary string of length "i" - int expectedLength = (8 * i) + - ((i <= 31) ? 10 : (i <= 62) ? 20 : (i <= 2078) ? 21 : 31); - // Verify that we are correct about the length. - testHighLevelEncodeString(sb.substring(0, i), expectedLength); - if (i != 1 && i != 32 && i != 2079) { - // The addition of an 'a' at the beginning or end gets merged into the binary code - // in those cases where adding another binary character only adds 8 or 9 bits to the result. - // So we exclude the border cases i=1,32,2079 - // A lower case letter at the beginning will be merged into binary mode - testHighLevelEncodeString('a' + sb.substring(0, i - 1), expectedLength); - // A lower case letter at the end will also be merged into binary mode - testHighLevelEncodeString(sb.substring(0, i - 1) + 'a', expectedLength); - } - // A lower case letter at both ends will enough to latch us into LOWER. - testHighLevelEncodeString('a' + sb.substring(0, i) + 'b', expectedLength + 15); - } - - sb = new StringBuilder(); - for (int i = 0; i < 32; i++) { - sb.append('§'); // § forces binary encoding - } - sb.setCharAt(1, 'A'); - // expect B/S(1) A B/S(30) - testHighLevelEncodeString(sb.toString(), 5 + 20 + 31 * 8); - - sb = new StringBuilder(); - for (int i = 0; i < 31; i++) { - sb.append('§'); - } - sb.setCharAt(1, 'A'); - // expect B/S(31) - testHighLevelEncodeString(sb.toString(), 10 + 31 * 8); - - sb = new StringBuilder(); - for (int i = 0; i < 34; i++) { - sb.append('§'); - } - sb.setCharAt(1, 'A'); - // expect B/S(31) B/S(3) - testHighLevelEncodeString(sb.toString(), 20 + 34 * 8); - - sb = new StringBuilder(); - for (int i = 0; i < 64; i++) { - sb.append('§'); - } - sb.setCharAt(30, 'A'); - // expect B/S(64) - testHighLevelEncodeString(sb.toString(), 21 + 64 * 8); - } - - @Test - public void testHighLevelEncodePairs() throws FormatException { - // Typical usage - testHighLevelEncodeString("ABC. DEF\r\n", - // A B C P/S . D E F P/S \r\n - "...X. ...XX ..X.. ..... ...XX ..X.X ..XX. ..XXX ..... ...X."); - - // We should latch to PUNCT mode, rather than shift. Also check all pairs - testHighLevelEncodeString("A. : , \r\n", - // 'A' M/L P/L ". " ": " ", " "\r\n" - "...X. XXX.X XXXX. ...XX ..X.X ..X.. ...X."); - - // Latch to DIGIT rather than shift to PUNCT - testHighLevelEncodeString("A. 1234", - // 'A' D/L '.' ' ' '1' '2' '3' '4' - "...X. XXXX. XX.X ...X ..XX .X.. .X.X .X X."); - // Don't bother leaving Binary Shift. - testHighLevelEncodeString("A\200. \200", - // 'A' B/S =2 \200 "." " " \200 - "...X. XXXXX ..X.. X....... ..X.XXX. ..X..... X......."); - } - - @Test(expected = IllegalArgumentException.class) - public void testUserSpecifiedLayers() { - doTestUserSpecifiedLayers(33); - } - - @Test(expected = IllegalArgumentException.class) - public void testUserSpecifiedLayers2() { - doTestUserSpecifiedLayers(-1); - } - - private void doTestUserSpecifiedLayers(int userSpecifiedLayers) { - String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - AztecCode aztec = Encoder.encode(alphabet, 25, -2); - assertEquals(2, aztec.getLayers()); - assertTrue(aztec.isCompact()); - - aztec = Encoder.encode(alphabet, 25, 32); - assertEquals(32, aztec.getLayers()); - assertFalse(aztec.isCompact()); - - Encoder.encode(alphabet, 25, userSpecifiedLayers); - } - - @Test(expected = IllegalArgumentException.class) - public void testBorderCompact4CaseFailed() { - // Compact(4) con hold 608 bits of information, but at most 504 can be data. Rest must - // be error correction - String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - // encodes as 26 * 5 * 4 = 520 bits of data - String alphabet4 = alphabet + alphabet + alphabet + alphabet; - Encoder.encode(alphabet4, 0, -4); - } - - @Test - public void testBorderCompact4Case() { - // Compact(4) con hold 608 bits of information, but at most 504 can be data. Rest must - // be error correction - String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - // encodes as 26 * 5 * 4 = 520 bits of data - String alphabet4 = alphabet + alphabet + alphabet + alphabet; - - // If we just try to encode it normally, it will go to a non-compact 4 layer - AztecCode aztecCode = Encoder.encode(alphabet4, 0, Encoder.DEFAULT_AZTEC_LAYERS); - assertFalse(aztecCode.isCompact()); - assertEquals(4, aztecCode.getLayers()); - - // But shortening the string to 100 bytes (500 bits of data), compact works fine, even if we - // include more error checking. - aztecCode = Encoder.encode(alphabet4.substring(0, 100), 10, Encoder.DEFAULT_AZTEC_LAYERS); - assertTrue(aztecCode.isCompact()); - assertEquals(4, aztecCode.getLayers()); - } - - // Helper routines - - private static void testEncode(String data, boolean compact, int layers, String expected) { - AztecCode aztec = Encoder.encode(data, 33, Encoder.DEFAULT_AZTEC_LAYERS); - assertEquals("Unexpected symbol format (compact)", compact, aztec.isCompact()); - assertEquals("Unexpected nr. of layers", layers, aztec.getLayers()); - BitMatrix matrix = aztec.getMatrix(); - assertEquals("encode() failed", expected, matrix.toString()); - } - - private static void testEncodeDecode(String data, boolean compact, int layers) throws Exception { - AztecCode aztec = Encoder.encode(data, 25, Encoder.DEFAULT_AZTEC_LAYERS); - assertEquals("Unexpected symbol format (compact)", compact, aztec.isCompact()); - assertEquals("Unexpected nr. of layers", layers, aztec.getLayers()); - BitMatrix matrix = aztec.getMatrix(); - AztecDetectorResult r = - new AztecDetectorResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers()); - DecoderResult res = new Decoder().decode(r); - assertEquals(data, res.getText()); - // Check error correction by introducing a few minor errors - Random random = getPseudoRandom(); - matrix.flip(random.nextInt(matrix.getWidth()), random.nextInt(2)); - matrix.flip(random.nextInt(matrix.getWidth()), matrix.getHeight() - 2 + random.nextInt(2)); - matrix.flip(random.nextInt(2), random.nextInt(matrix.getHeight())); - matrix.flip(matrix.getWidth() - 2 + random.nextInt(2), random.nextInt(matrix.getHeight())); - r = new AztecDetectorResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers()); - res = new Decoder().decode(r); - assertEquals(data, res.getText()); - } - - private static void testWriter(String data, - Charset charset, - int eccPercent, - boolean compact, - int layers) throws FormatException { - // Perform an encode-decode round-trip because it can be lossy. - Map hints = new EnumMap<>(EncodeHintType.class); - if (null != charset) { - hints.put(EncodeHintType.CHARACTER_SET, charset.name()); - } - hints.put(EncodeHintType.ERROR_CORRECTION, eccPercent); - AztecWriter writer = new AztecWriter(); - BitMatrix matrix = writer.encode(data, BarcodeFormat.AZTEC, 0, 0, hints); - AztecCode aztec = Encoder.encode(data, eccPercent, - Encoder.DEFAULT_AZTEC_LAYERS, charset); - assertEquals("Unexpected symbol format (compact)", compact, aztec.isCompact()); - assertEquals("Unexpected nr. of layers", layers, aztec.getLayers()); - BitMatrix matrix2 = aztec.getMatrix(); - assertEquals(matrix, matrix2); - AztecDetectorResult r = - new AztecDetectorResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers()); - DecoderResult res = new Decoder().decode(r); - assertEquals(data, res.getText()); - // Check error correction by introducing up to eccPercent/2 errors - int ecWords = aztec.getCodeWords() * eccPercent / 100 / 2; - Random random = getPseudoRandom(); - for (int i = 0; i < ecWords; i++) { - // don't touch the core - int x = random.nextBoolean() ? - random.nextInt(aztec.getLayers() * 2) - : matrix.getWidth() - 1 - random.nextInt(aztec.getLayers() * 2); - int y = random.nextBoolean() ? - random.nextInt(aztec.getLayers() * 2) - : matrix.getHeight() - 1 - random.nextInt(aztec.getLayers() * 2); - matrix.flip(x, y); - } - r = new AztecDetectorResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers()); - res = new Decoder().decode(r); - assertEquals(data, res.getText()); - } - - private static Random getPseudoRandom() { - return new Random(0xDEADBEEF); - } - - private static void testModeMessage(boolean compact, int layers, int words, String expected) { - BitArray in = Encoder.generateModeMessage(compact, layers, words); - assertEquals("generateModeMessage() failed", stripSpace(expected), stripSpace(in.toString())); - } - - private static void testStuffBits(int wordSize, String bits, String expected) { - BitArray in = toBitArray(bits); - BitArray stuffed = Encoder.stuffBits(in, wordSize); - assertEquals("stuffBits() failed for input string: " + bits, - stripSpace(expected), stripSpace(stuffed.toString())); - } - - public static BitArray toBitArray(CharSequence bits) { - BitArray in = new BitArray(); - char[] str = DOTX.matcher(bits).replaceAll("").toCharArray(); - for (char aStr : str) { - in.appendBit(aStr == 'X'); - } - return in; - } - - public static boolean[] toBooleanArray(BitArray bitArray) { - boolean[] result = new boolean[bitArray.getSize()]; - for (int i = 0; i < result.length; i++) { - result[i] = bitArray.get(i); - } - return result; - } - - private static void testHighLevelEncodeString(String s, String expectedBits) throws FormatException { - BitArray bits = new HighLevelEncoder(s.getBytes(StandardCharsets.ISO_8859_1)).encode(); - String receivedBits = stripSpace(bits.toString()); - assertEquals("highLevelEncode() failed for input string: " + s, stripSpace(expectedBits), receivedBits); - assertEquals(s, Decoder.highLevelDecode(toBooleanArray(bits))); - } - - private static void testHighLevelEncodeString(String s, int expectedReceivedBits) throws FormatException { - BitArray bits = new HighLevelEncoder(s.getBytes(StandardCharsets.ISO_8859_1)).encode(); - int receivedBitCount = stripSpace(bits.toString()).length(); - assertEquals("highLevelEncode() failed for input string: " + s, - expectedReceivedBits, receivedBitCount); - assertEquals(s, Decoder.highLevelDecode(toBooleanArray(bits))); - } - - public static String stripSpace(String s) { - return SPACES.matcher(s).replaceAll(""); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/AddressBookParsedResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/AddressBookParsedResultTestCase.java deleted file mode 100644 index 2e090a5..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/AddressBookParsedResultTestCase.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link AddressBookParsedResult}. - * - * @author Sean Owen - */ -public final class AddressBookParsedResultTestCase extends Assert { - - @Test - public void testAddressBookDocomo() { - doTest("MECARD:N:Sean Owen;;", null, new String[] {"Sean Owen"}, - null, null, null, null, null, null, null, null, null); - doTest("MECARD:NOTE:ZXing Team;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;;", - null, new String[] {"Sean Owen"}, null, null, new String[] {"srowen@example.org"}, null, null, null, - new String[] {"google.com"}, null, "ZXing Team"); - } - - @Test - public void testAddressBookAU() { - doTest("MEMORY:foo\r\nNAME1:Sean\r\nTEL1:+12125551212\r\n", - null, new String[] {"Sean"}, null, null, null, new String[] {"+12125551212"}, null, null, null, null, "foo"); - } - - @Test - public void testVCard() { - doTest("BEGIN:VCARD\r\nADR;HOME:123 Main St\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", - null, new String[] {"Sean Owen"}, null, new String[] {"123 Main St"}, - null, null, null, null, null, null, null); - } - - @Test - public void testVCardFullN() { - doTest("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Owen;Sean;T;Mr.;Esq.\r\nEND:VCARD", - null, new String[] {"Mr. Sean T Owen Esq."}, null, null, null, null, null, null, null, null, null); - } - - @Test - public void testVCardFullN2() { - doTest("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Owen;Sean;;;\r\nEND:VCARD", - null, new String[] {"Sean Owen"}, null, null, null, null, null, null, null, null, null); - } - - @Test - public void testVCardFullN3() { - doTest("BEGIN:VCARD\r\nVERSION:2.1\r\nN:;Sean;;;\r\nEND:VCARD", - null, new String[] {"Sean"}, null, null, null, null, null, null, null, null, null); - } - - @Test - public void testVCardCaseInsensitive() { - doTest("begin:vcard\r\nadr;HOME:123 Main St\r\nVersion:2.1\r\nn:Owen;Sean\r\nEND:VCARD", - null, new String[] {"Sean Owen"}, null, new String[] {"123 Main St"}, - null, null, null, null, null, null, null); - } - - @Test - public void testEscapedVCard() { - doTest("BEGIN:VCARD\r\nADR;HOME:123\\;\\\\ Main\\, St\\nHome\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", - null, new String[] {"Sean Owen"}, null, new String[] {"123;\\ Main, St\nHome"}, - null, null, null, null, null, null, null); - } - - @Test - public void testBizcard() { - doTest("BIZCARD:N:Sean;X:Owen;C:Google;A:123 Main St;M:+12125551212;E:srowen@example.org;", - null, new String[] {"Sean Owen"}, null, new String[] {"123 Main St"}, new String[] {"srowen@example.org"}, - new String[] {"+12125551212"}, null, "Google", null, null, null); - } - - @Test - public void testSeveralAddresses() { - doTest("MECARD:N:Foo Bar;ORG:Company;TEL:5555555555;EMAIL:foo.bar@xyz.com;ADR:City, 10001;" + - "ADR:City, 10001;NOTE:This is the memo.;;", - null, new String[] {"Foo Bar"}, null, new String[] {"City, 10001", "City, 10001"}, - new String[] {"foo.bar@xyz.com"}, - new String[] {"5555555555" }, null, "Company", null, null, "This is the memo."); - } - - @Test - public void testQuotedPrintable() { - doTest("BEGIN:VCARD\r\nADR;HOME;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;;" + - "=38=38=20=4C=79=6E=62=72=6F=6F=6B=0D=0A=43=\r\n" + - "=4F=20=36=39=39=\r\n" + - "=39=39;;;\r\nEND:VCARD", - null, null, null, new String[] {"88 Lynbrook\r\nCO 69999"}, - null, null, null, null, null, null, null); - } - - @Test - public void testVCardEscape() { - doTest("BEGIN:VCARD\r\nNOTE:foo\\nbar\r\nEND:VCARD", - null, null, null, null, null, null, null, null, null, null, "foo\nbar"); - doTest("BEGIN:VCARD\r\nNOTE:foo\\;bar\r\nEND:VCARD", - null, null, null, null, null, null, null, null, null, null, "foo;bar"); - doTest("BEGIN:VCARD\r\nNOTE:foo\\\\bar\r\nEND:VCARD", - null, null, null, null, null, null, null, null, null, null, "foo\\bar"); - doTest("BEGIN:VCARD\r\nNOTE:foo\\,bar\r\nEND:VCARD", - null, null, null, null, null, null, null, null, null, null, "foo,bar"); - } - - @Test - public void testVCardValueURI() { - doTest("BEGIN:VCARD\r\nTEL;VALUE=uri:tel:+1-555-555-1212\r\nEND:VCARD", - null, null, null, null, null, new String[] { "+1-555-555-1212" }, new String[] { null }, - null, null, null, null); - - doTest("BEGIN:VCARD\r\nN;VALUE=text:Owen;Sean\r\nEND:VCARD", - null, new String[] {"Sean Owen"}, null, null, null, null, null, null, null, null, null); - } - - @Test - public void testVCardTypes() { - doTest("BEGIN:VCARD\r\nTEL;HOME:\r\nTEL;WORK:10\r\nTEL:20\r\nTEL;CELL:30\r\nEND:VCARD", - null, null, null, null, null, new String[] { "10", "20", "30" }, - new String[] { "WORK", null, "CELL" }, null, null, null, null); - } - - private static void doTest(String contents, - String title, - String[] names, - String pronunciation, - String[] addresses, - String[] emails, - String[] phoneNumbers, - String[] phoneTypes, - String org, - String[] urls, - String birthday, - String note) { - Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(ParsedResultType.ADDRESSBOOK, result.getType()); - AddressBookParsedResult addressResult = (AddressBookParsedResult) result; - assertEquals(title, addressResult.getTitle()); - assertArrayEquals(names, addressResult.getNames()); - assertEquals(pronunciation, addressResult.getPronunciation()); - assertArrayEquals(addresses, addressResult.getAddresses()); - assertArrayEquals(emails, addressResult.getEmails()); - assertArrayEquals(phoneNumbers, addressResult.getPhoneNumbers()); - assertArrayEquals(phoneTypes, addressResult.getPhoneTypes()); - assertEquals(org, addressResult.getOrg()); - assertArrayEquals(urls, addressResult.getURLs()); - assertEquals(birthday, addressResult.getBirthday()); - assertEquals(note, addressResult.getNote()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/CalendarParsedResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/CalendarParsedResultTestCase.java deleted file mode 100644 index 2b79107..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/CalendarParsedResultTestCase.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Locale; -import java.util.TimeZone; - -/** - * Tests {@link CalendarParsedResult}. - * - * @author Sean Owen - */ -public final class CalendarParsedResultTestCase extends Assert { - - private static final double EPSILON = 1.0E-10; - - private static DateFormat makeGMTFormat() { - DateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'", Locale.ENGLISH); - format.setTimeZone(TimeZone.getTimeZone("GMT")); - return format; - } - - @Before - public void setUp() { - Locale.setDefault(Locale.ENGLISH); - TimeZone.setDefault(TimeZone.getTimeZone("GMT")); - } - - @Test - public void testStartEnd() { - doTest( - "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + - "DTSTART:20080504T123456Z\r\n" + - "DTEND:20080505T234555Z\r\n" + - "END:VEVENT\r\nEND:VCALENDAR", - null, null, null, "20080504T123456Z", "20080505T234555Z"); - } - - @Test - public void testNoVCalendar() { - doTest( - "BEGIN:VEVENT\r\n" + - "DTSTART:20080504T123456Z\r\n" + - "DTEND:20080505T234555Z\r\n" + - "END:VEVENT", - null, null, null, "20080504T123456Z", "20080505T234555Z"); - } - - @Test - public void testStart() { - doTest( - "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + - "DTSTART:20080504T123456Z\r\n" + - "END:VEVENT\r\nEND:VCALENDAR", - null, null, null, "20080504T123456Z", null); - } - - @Test - public void testDuration() { - doTest( - "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + - "DTSTART:20080504T123456Z\r\n" + - "DURATION:P1D\r\n" + - "END:VEVENT\r\nEND:VCALENDAR", - null, null, null, "20080504T123456Z", "20080505T123456Z"); - doTest( - "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + - "DTSTART:20080504T123456Z\r\n" + - "DURATION:P1DT2H3M4S\r\n" + - "END:VEVENT\r\nEND:VCALENDAR", - null, null, null, "20080504T123456Z", "20080505T143800Z"); - } - - @Test - public void testSummary() { - doTest( - "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + - "SUMMARY:foo\r\n" + - "DTSTART:20080504T123456Z\r\n" + - "END:VEVENT\r\nEND:VCALENDAR", - null, "foo", null, "20080504T123456Z", null); - } - - @Test - public void testLocation() { - doTest( - "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + - "LOCATION:Miami\r\n" + - "DTSTART:20080504T123456Z\r\n" + - "END:VEVENT\r\nEND:VCALENDAR", - null, null, "Miami", "20080504T123456Z", null); - } - - @Test - public void testDescription() { - doTest( - "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + - "DTSTART:20080504T123456Z\r\n" + - "DESCRIPTION:This is a test\r\n" + - "END:VEVENT\r\nEND:VCALENDAR", - "This is a test", null, null, "20080504T123456Z", null); - doTest( - "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + - "DTSTART:20080504T123456Z\r\n" + - "DESCRIPTION:This is a test\r\n\t with a continuation\r\n" + - "END:VEVENT\r\nEND:VCALENDAR", - "This is a test with a continuation", null, null, "20080504T123456Z", null); - } - - @Test - public void testGeo() { - doTest( - "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + - "DTSTART:20080504T123456Z\r\n" + - "GEO:-12.345;-45.678\r\n" + - "END:VEVENT\r\nEND:VCALENDAR", - null, null, null, "20080504T123456Z", null, null, null, -12.345, -45.678); - } - - @Test - public void testBadGeo() { - // Not parsed as VEVENT - Result fakeResult = new Result("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + - "GEO:-12.345\r\n" + - "END:VEVENT\r\nEND:VCALENDAR", null, null, BarcodeFormat.QR_CODE); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(ParsedResultType.TEXT, result.getType()); - } - - @Test - public void testOrganizer() { - doTest( - "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + - "DTSTART:20080504T123456Z\r\n" + - "ORGANIZER:mailto:bob@example.org\r\n" + - "END:VEVENT\r\nEND:VCALENDAR", - null, null, null, "20080504T123456Z", null, "bob@example.org", null, Double.NaN, Double.NaN); - } - - @Test - public void testAttendees() { - doTest( - "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + - "DTSTART:20080504T123456Z\r\n" + - "ATTENDEE:mailto:bob@example.org\r\n" + - "ATTENDEE:mailto:alice@example.org\r\n" + - "END:VEVENT\r\nEND:VCALENDAR", - null, null, null, "20080504T123456Z", null, null, - new String[] {"bob@example.org", "alice@example.org"}, Double.NaN, Double.NaN); - } - - @Test - public void testVEventEscapes() { - doTest("BEGIN:VEVENT\n" + - "CREATED:20111109T110351Z\n" + - "LAST-MODIFIED:20111109T170034Z\n" + - "DTSTAMP:20111109T170034Z\n" + - "UID:0f6d14ef-6cb7-4484-9080-61447ccdf9c2\n" + - "SUMMARY:Summary line\n" + - "CATEGORIES:Private\n" + - "DTSTART;TZID=Europe/Vienna:20111110T110000\n" + - "DTEND;TZID=Europe/Vienna:20111110T120000\n" + - "LOCATION:Location\\, with\\, escaped\\, commas\n" + - "DESCRIPTION:Meeting with a friend\\nlook at homepage first\\n\\n\n" + - " \\n\n" + - "SEQUENCE:1\n" + - "X-MOZ-GENERATION:1\n" + - "END:VEVENT", - "Meeting with a friend\nlook at homepage first\n\n\n \n", - "Summary line", - "Location, with, escaped, commas", - "20111110T110000Z", - "20111110T120000Z"); - } - - @Test - public void testAllDayValueDate() { - doTest("BEGIN:VEVENT\n" + - "DTSTART;VALUE=DATE:20111110\n" + - "DTEND;VALUE=DATE:20111110\n" + - "END:VEVENT", - null, null, null, "20111110T000000Z", "20111110T000000Z"); - } - - private static void doTest(String contents, - String description, - String summary, - String location, - String startString, - String endString) { - doTest(contents, description, summary, location, startString, endString, null, null, Double.NaN, Double.NaN); - } - - private static void doTest(String contents, - String description, - String summary, - String location, - String startString, - String endString, - String organizer, - String[] attendees, - double latitude, - double longitude) { - Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(ParsedResultType.CALENDAR, result.getType()); - CalendarParsedResult calResult = (CalendarParsedResult) result; - assertEquals(description, calResult.getDescription()); - assertEquals(summary, calResult.getSummary()); - assertEquals(location, calResult.getLocation()); - DateFormat dateFormat = makeGMTFormat(); - assertEquals(startString, dateFormat.format(calResult.getStartTimestamp())); - assertEquals(endString, calResult.getEndTimestamp() < 0L ? null : dateFormat.format(calResult.getEndTimestamp())); - assertEquals(organizer, calResult.getOrganizer()); - assertArrayEquals(attendees, calResult.getAttendees()); - assertEqualOrNaN(latitude, calResult.getLatitude()); - assertEqualOrNaN(longitude, calResult.getLongitude()); - } - - private static void assertEqualOrNaN(double expected, double actual) { - if (Double.isNaN(expected)) { - assertTrue(Double.isNaN(actual)); - } else { - assertEquals(expected, actual, EPSILON); - } - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/EmailAddressParsedResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/EmailAddressParsedResultTestCase.java deleted file mode 100644 index 28e5da7..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/EmailAddressParsedResultTestCase.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link EmailAddressParsedResult}. - * - * @author Sean Owen - */ -public final class EmailAddressParsedResultTestCase extends Assert { - - @Test - public void testEmailAddress() { - doTest("srowen@example.org", "srowen@example.org", null, null); - doTest("mailto:srowen@example.org", "srowen@example.org", null, null); - } - - @Test - public void testTos() { - doTest("mailto:srowen@example.org,bob@example.org", - new String[] {"srowen@example.org", "bob@example.org"}, - null, null, null, null); - doTest("mailto:?to=srowen@example.org,bob@example.org", - new String[] {"srowen@example.org", "bob@example.org"}, - null, null, null, null); - } - - @Test - public void testCCs() { - doTest("mailto:?cc=srowen@example.org", - null, - new String[] {"srowen@example.org"}, - null, null, null); - doTest("mailto:?cc=srowen@example.org,bob@example.org", - null, - new String[] {"srowen@example.org", "bob@example.org"}, - null, null, null); - } - - @Test - public void testBCCs() { - doTest("mailto:?bcc=srowen@example.org", - null, null, - new String[] {"srowen@example.org"}, - null, null); - doTest("mailto:?bcc=srowen@example.org,bob@example.org", - null, null, - new String[] {"srowen@example.org", "bob@example.org"}, - null, null); - } - - @Test - public void testAll() { - doTest("mailto:bob@example.org?cc=foo@example.org&bcc=srowen@example.org&subject=baz&body=buzz", - new String[] {"bob@example.org"}, - new String[] {"foo@example.org"}, - new String[] {"srowen@example.org"}, - "baz", - "buzz"); - } - - @Test - public void testEmailDocomo() { - doTest("MATMSG:TO:srowen@example.org;;", "srowen@example.org", null, null); - doTest("MATMSG:TO:srowen@example.org;SUB:Stuff;;", "srowen@example.org", "Stuff", null); - doTest("MATMSG:TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;", "srowen@example.org", - "Stuff", "This is some text"); - } - - @Test - public void testSMTP() { - doTest("smtp:srowen@example.org", "srowen@example.org", null, null); - doTest("SMTP:srowen@example.org", "srowen@example.org", null, null); - doTest("smtp:srowen@example.org:foo", "srowen@example.org", "foo", null); - doTest("smtp:srowen@example.org:foo:bar", "srowen@example.org", "foo", "bar"); - } - - private static void doTest(String contents, - String to, - String subject, - String body) { - doTest(contents, new String[] {to}, null, null, subject, body); - } - - private static void doTest(String contents, - String[] tos, - String[] ccs, - String[] bccs, - String subject, - String body) { - Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(ParsedResultType.EMAIL_ADDRESS, result.getType()); - EmailAddressParsedResult emailResult = (EmailAddressParsedResult) result; - assertArrayEquals(tos, emailResult.getTos()); - assertArrayEquals(ccs, emailResult.getCCs()); - assertArrayEquals(bccs, emailResult.getBCCs()); - assertEquals(subject, emailResult.getSubject()); - assertEquals(body, emailResult.getBody()); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/ExpandedProductParsedResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/ExpandedProductParsedResultTestCase.java deleted file mode 100644 index 861e663..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/ExpandedProductParsedResultTestCase.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Antonio Manuel Benjumea Conde, Servinform, S.A. - * @author Agustín Delgado, Servinform, S.A. - */ -public final class ExpandedProductParsedResultTestCase extends Assert { - - @Test - public void testRSSExpanded() { - Map uncommonAIs = new HashMap<>(); - uncommonAIs.put("123", "544654"); - Result result = - new Result("(01)66546(13)001205(3932)4455(3102)6544(123)544654", null, null, BarcodeFormat.RSS_EXPANDED); - ExpandedProductParsedResult o = new ExpandedProductResultParser().parse(result); - assertNotNull(o); - assertEquals("66546", o.getProductID()); - assertNull(o.getSscc()); - assertNull(o.getLotNumber()); - assertNull(o.getProductionDate()); - assertEquals("001205", o.getPackagingDate()); - assertNull(o.getBestBeforeDate()); - assertNull(o.getExpirationDate()); - assertEquals("6544", o.getWeight()); - assertEquals("KG", o.getWeightType()); - assertEquals("2", o.getWeightIncrement()); - assertEquals("5", o.getPrice()); - assertEquals("2", o.getPriceIncrement()); - assertEquals("445", o.getPriceCurrency()); - assertEquals(uncommonAIs, o.getUncommonAIs()); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/GeoParsedResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/GeoParsedResultTestCase.java deleted file mode 100644 index 5280f4c..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/GeoParsedResultTestCase.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import java.util.Locale; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link GeoParsedResult}. - * - * @author Sean Owen - */ -public final class GeoParsedResultTestCase extends Assert { - - private static final double EPSILON = 1.0E-10; - - @Test - public void testGeo() { - doTest("geo:1,2", 1.0, 2.0, 0.0, null, "geo:1.0,2.0"); - doTest("geo:80.33,-32.3344,3.35", 80.33, -32.3344, 3.35, null, null); - doTest("geo:-20.33,132.3344,0.01", -20.33, 132.3344, 0.01, null, null); - doTest("geo:-20.33,132.3344,0.01?q=foobar", -20.33, 132.3344, 0.01, "q=foobar", null); - doTest("GEO:-20.33,132.3344,0.01?q=foobar", -20.33, 132.3344, 0.01, "q=foobar", null); - } - - private static void doTest(String contents, - double latitude, - double longitude, - double altitude, - String query, - String uri) { - Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(ParsedResultType.GEO, result.getType()); - GeoParsedResult geoResult = (GeoParsedResult) result; - assertEquals(latitude, geoResult.getLatitude(), EPSILON); - assertEquals(longitude, geoResult.getLongitude(), EPSILON); - assertEquals(altitude, geoResult.getAltitude(), EPSILON); - assertEquals(query, geoResult.getQuery()); - assertEquals(uri == null ? contents.toLowerCase(Locale.ENGLISH) : uri, geoResult.getGeoURI()); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/ISBNParsedResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/ISBNParsedResultTestCase.java deleted file mode 100644 index 76d096b..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/ISBNParsedResultTestCase.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link ISBNParsedResult}. - * - * @author Sean Owen - */ -public final class ISBNParsedResultTestCase extends Assert { - - @Test - public void testISBN() { - doTest("9784567890123"); - } - - private static void doTest(String contents) { - Result fakeResult = new Result(contents, null, null, BarcodeFormat.EAN_13); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(ParsedResultType.ISBN, result.getType()); - ISBNParsedResult isbnResult = (ISBNParsedResult) result; - assertEquals(contents, isbnResult.getISBN()); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/ParsedReaderResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/ParsedReaderResultTestCase.java deleted file mode 100644 index 1363aee..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/ParsedReaderResultTestCase.java +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.text.DateFormat; -import java.util.Calendar; -import java.util.Locale; -import java.util.TimeZone; - -/** - * Tests {@link ParsedResult}. - * - * @author Sean Owen - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class ParsedReaderResultTestCase extends Assert { - - @Before - public void setUp() { - Locale.setDefault(Locale.ENGLISH); - TimeZone.setDefault(TimeZone.getTimeZone("GMT")); - } - - @Test - public void testTextType() { - doTestResult("", "", ParsedResultType.TEXT); - doTestResult("foo", "foo", ParsedResultType.TEXT); - doTestResult("Hi.", "Hi.", ParsedResultType.TEXT); - doTestResult("This is a test", "This is a test", ParsedResultType.TEXT); - doTestResult("This is a test\nwith newlines", "This is a test\nwith newlines", - ParsedResultType.TEXT); - doTestResult("This: a test with lots of @ nearly-random punctuation! No? OK then.", - "This: a test with lots of @ nearly-random punctuation! No? OK then.", - ParsedResultType.TEXT); - } - - @Test - public void testBookmarkType() { - doTestResult("MEBKM:URL:google.com;;", "http://google.com", ParsedResultType.URI); - doTestResult("MEBKM:URL:google.com;TITLE:Google;;", "Google\nhttp://google.com", - ParsedResultType.URI); - doTestResult("MEBKM:TITLE:Google;URL:google.com;;", "Google\nhttp://google.com", - ParsedResultType.URI); - doTestResult("MEBKM:URL:http://google.com;;", "http://google.com", ParsedResultType.URI); - doTestResult("MEBKM:URL:HTTPS://google.com;;", "HTTPS://google.com", ParsedResultType.URI); - } - - @Test - public void testURLTOType() { - doTestResult("urlto:foo:bar.com", "foo\nhttp://bar.com", ParsedResultType.URI); - doTestResult("URLTO:foo:bar.com", "foo\nhttp://bar.com", ParsedResultType.URI); - doTestResult("URLTO::bar.com", "http://bar.com", ParsedResultType.URI); - doTestResult("URLTO::http://bar.com", "http://bar.com", ParsedResultType.URI); - } - - @Test - public void testEmailType() { - doTestResult("MATMSG:TO:srowen@example.org;;", - "srowen@example.org", ParsedResultType.EMAIL_ADDRESS); - doTestResult("MATMSG:TO:srowen@example.org;SUB:Stuff;;", "srowen@example.org\nStuff", - ParsedResultType.EMAIL_ADDRESS); - doTestResult("MATMSG:TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;", - "srowen@example.org\nStuff\nThis is some text", ParsedResultType.EMAIL_ADDRESS); - doTestResult("MATMSG:SUB:Stuff;BODY:This is some text;TO:srowen@example.org;;", - "srowen@example.org\nStuff\nThis is some text", ParsedResultType.EMAIL_ADDRESS); - doTestResult("TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;", - "TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;", ParsedResultType.TEXT); - } - - @Test - public void testEmailAddressType() { - doTestResult("srowen@example.org", "srowen@example.org", ParsedResultType.EMAIL_ADDRESS); - doTestResult("mailto:srowen@example.org", "srowen@example.org", ParsedResultType.EMAIL_ADDRESS); - doTestResult("MAILTO:srowen@example.org", "srowen@example.org", ParsedResultType.EMAIL_ADDRESS); - doTestResult("srowen@example", "srowen@example", ParsedResultType.EMAIL_ADDRESS); - doTestResult("srowen", "srowen", ParsedResultType.TEXT); - doTestResult("Let's meet @ 2", "Let's meet @ 2", ParsedResultType.TEXT); - } - - @Test - public void testAddressBookType() { - doTestResult("MECARD:N:Sean Owen;;", "Sean Owen", ParsedResultType.ADDRESSBOOK); - doTestResult("MECARD:TEL:+12125551212;N:Sean Owen;;", "Sean Owen\n+12125551212", - ParsedResultType.ADDRESSBOOK); - doTestResult("MECARD:TEL:+12125551212;N:Sean Owen;URL:google.com;;", - "Sean Owen\n+12125551212\ngoogle.com", ParsedResultType.ADDRESSBOOK); - doTestResult("MECARD:TEL:+12125551212;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;", - "Sean Owen\n+12125551212\nsrowen@example.org\ngoogle.com", ParsedResultType.ADDRESSBOOK); - doTestResult("MECARD:ADR:76 9th Ave;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;", - "Sean Owen\n76 9th Ave\nsrowen@example.org\ngoogle.com", ParsedResultType.ADDRESSBOOK); - doTestResult("MECARD:BDAY:19760520;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;", - "Sean Owen\nsrowen@example.org\ngoogle.com\n19760520", ParsedResultType.ADDRESSBOOK); - doTestResult("MECARD:ORG:Google;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;", - "Sean Owen\nGoogle\nsrowen@example.org\ngoogle.com", ParsedResultType.ADDRESSBOOK); - doTestResult("MECARD:NOTE:ZXing Team;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;", - "Sean Owen\nsrowen@example.org\ngoogle.com\nZXing Team", ParsedResultType.ADDRESSBOOK); - doTestResult("N:Sean Owen;TEL:+12125551212;;", "N:Sean Owen;TEL:+12125551212;;", - ParsedResultType.TEXT); - } - - @Test - public void testAddressBookAUType() { - doTestResult("MEMORY:\r\n", "", ParsedResultType.ADDRESSBOOK); - doTestResult("MEMORY:foo\r\nNAME1:Sean\r\n", "Sean\nfoo", ParsedResultType.ADDRESSBOOK); - doTestResult("TEL1:+12125551212\r\nMEMORY:\r\n", "+12125551212", ParsedResultType.ADDRESSBOOK); - } - - @Test - public void testBizcard() { - doTestResult("BIZCARD:N:Sean;X:Owen;C:Google;A:123 Main St;M:+12225551212;E:srowen@example.org;", - "Sean Owen\nGoogle\n123 Main St\n+12225551212\nsrowen@example.org", ParsedResultType.ADDRESSBOOK); - } - - @Test - public void testUPCA() { - doTestResult("123456789012", "123456789012", ParsedResultType.PRODUCT, BarcodeFormat.UPC_A); - doTestResult("1234567890123", "1234567890123", ParsedResultType.PRODUCT, BarcodeFormat.UPC_A); - doTestResult("12345678901", "12345678901", ParsedResultType.TEXT); - } - - @Test - public void testUPCE() { - doTestResult("01234565", "01234565", ParsedResultType.PRODUCT, BarcodeFormat.UPC_E); - } - - @Test - public void testEAN() { - doTestResult("00393157", "00393157", ParsedResultType.PRODUCT, BarcodeFormat.EAN_8); - doTestResult("00393158", "00393158", ParsedResultType.TEXT); - doTestResult("5051140178499", "5051140178499", ParsedResultType.PRODUCT, BarcodeFormat.EAN_13); - doTestResult("5051140178490", "5051140178490", ParsedResultType.TEXT); - } - - @Test - public void testISBN() { - doTestResult("9784567890123", "9784567890123", ParsedResultType.ISBN, BarcodeFormat.EAN_13); - doTestResult("9794567890123", "9794567890123", ParsedResultType.ISBN, BarcodeFormat.EAN_13); - doTestResult("97845678901", "97845678901", ParsedResultType.TEXT); - doTestResult("97945678901", "97945678901", ParsedResultType.TEXT); - } - - @Test - public void testURI() { - doTestResult("http://google.com", "http://google.com", ParsedResultType.URI); - doTestResult("google.com", "http://google.com", ParsedResultType.URI); - doTestResult("https://google.com", "https://google.com", ParsedResultType.URI); - doTestResult("HTTP://google.com", "HTTP://google.com", ParsedResultType.URI); - doTestResult("http://google.com/foobar", "http://google.com/foobar", ParsedResultType.URI); - doTestResult("https://google.com:443/foobar", "https://google.com:443/foobar", ParsedResultType.URI); - doTestResult("google.com:443", "http://google.com:443", ParsedResultType.URI); - doTestResult("google.com:443/", "http://google.com:443/", ParsedResultType.URI); - doTestResult("google.com:443/foobar", "http://google.com:443/foobar", ParsedResultType.URI); - doTestResult("http://google.com:443/foobar", "http://google.com:443/foobar", ParsedResultType.URI); - doTestResult("https://google.com:443/foobar", "https://google.com:443/foobar", ParsedResultType.URI); - doTestResult("ftp://google.com/fake", "ftp://google.com/fake", ParsedResultType.URI); - doTestResult("gopher://google.com/obsolete", "gopher://google.com/obsolete", ParsedResultType.URI); - } - - @Test - public void testGeo() { - doTestResult("geo:1,2", "1.0, 2.0", ParsedResultType.GEO); - doTestResult("GEO:1,2", "1.0, 2.0", ParsedResultType.GEO); - doTestResult("geo:1,2,3", "1.0, 2.0, 3.0m", ParsedResultType.GEO); - doTestResult("geo:80.33,-32.3344,3.35", "80.33, -32.3344, 3.35m", ParsedResultType.GEO); - doTestResult("geo", "geo", ParsedResultType.TEXT); - doTestResult("geography", "geography", ParsedResultType.TEXT); - } - - @Test - public void testTel() { - doTestResult("tel:+15551212", "+15551212", ParsedResultType.TEL); - doTestResult("TEL:+15551212", "+15551212", ParsedResultType.TEL); - doTestResult("tel:212 555 1212", "212 555 1212", ParsedResultType.TEL); - doTestResult("tel:2125551212", "2125551212", ParsedResultType.TEL); - doTestResult("tel:212-555-1212", "212-555-1212", ParsedResultType.TEL); - doTestResult("tel", "tel", ParsedResultType.TEXT); - doTestResult("telephone", "telephone", ParsedResultType.TEXT); - } - - @Test - public void testVCard() { - doTestResult("BEGIN:VCARD\r\nEND:VCARD", "", ParsedResultType.ADDRESSBOOK); - doTestResult("BEGIN:VCARD\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen", - ParsedResultType.ADDRESSBOOK); - doTestResult("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen", - ParsedResultType.ADDRESSBOOK); - doTestResult("BEGIN:VCARD\r\nADR;HOME:123 Main St\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", - "Sean Owen\n123 Main St", ParsedResultType.ADDRESSBOOK); - doTestResult("BEGIN:VCARD", "", ParsedResultType.ADDRESSBOOK); - } - - @Test - public void testVEvent() { - // UTC times - doTestResult("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" + - "DTEND:20080505T234555Z\r\nEND:VEVENT\r\nEND:VCALENDAR", - "foo\n" + formatTime(2008, 5, 4, 12, 34, 56) + "\n" + formatTime(2008, 5, 5, 23, 45, 55), - ParsedResultType.CALENDAR); - doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" + - "DTEND:20080505T234555Z\r\nEND:VEVENT", "foo\n" + formatTime(2008, 5, 4, 12, 34, 56) + "\n" + - formatTime(2008, 5, 5, 23, 45, 55), - ParsedResultType.CALENDAR); - // Local times - doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\n" + - "DTEND:20080505T234555\r\nEND:VEVENT", "foo\n" + formatTime(2008, 5, 4, 12, 34, 56) + "\n" + - formatTime(2008, 5, 5, 23, 45, 55), - ParsedResultType.CALENDAR); - // Date only (all day event) - doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\n" + - "DTEND:20080505\r\nEND:VEVENT", "foo\n" + formatDate(2008, 5, 4) + "\n" + - formatDate(2008, 5, 5), - ParsedResultType.CALENDAR); - // Start time only - doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nEND:VEVENT", - "foo\n" + formatTime(2008, 5, 4, 12, 34, 56), ParsedResultType.CALENDAR); - doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\nEND:VEVENT", - "foo\n" + formatTime(2008, 5, 4, 12, 34, 56), ParsedResultType.CALENDAR); - doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\nEND:VEVENT", - "foo\n" + formatDate(2008, 5, 4), ParsedResultType.CALENDAR); - doTestResult("BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT", - "BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT", ParsedResultType.TEXT); - // Yeah, it's OK that this is thought of as maybe a URI as long as it's not CALENDAR - // Make sure illegal entries without newlines don't crash - doTestResult( - "BEGIN:VEVENTSUMMARY:EventDTSTART:20081030T122030ZDTEND:20081030T132030ZEND:VEVENT", - "BEGIN:VEVENTSUMMARY:EventDTSTART:20081030T122030ZDTEND:20081030T132030ZEND:VEVENT", - ParsedResultType.URI); - } - - private static String formatDate(int year, int month, int day) { - Calendar cal = Calendar.getInstance(); - cal.clear(); - cal.set(year, month - 1, day); - return DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).format(cal.getTime()); - } - - private static String formatTime(int year, int month, int day, int hour, int min, int sec) { - Calendar cal = Calendar.getInstance(); - cal.clear(); - cal.set(year, month - 1, day, hour, min, sec); - return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US).format(cal.getTime()); - } - - @Test - public void testSMS() { - doTestResult("sms:+15551212", "+15551212", ParsedResultType.SMS); - doTestResult("SMS:+15551212", "+15551212", ParsedResultType.SMS); - doTestResult("sms:+15551212;via=999333", "+15551212", ParsedResultType.SMS); - doTestResult("sms:+15551212?subject=foo&body=bar", "+15551212\nfoo\nbar", ParsedResultType.SMS); - doTestResult("sms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedResultType.SMS); - } - - @Test - public void testSMSTO() { - doTestResult("SMSTO:+15551212", "+15551212", ParsedResultType.SMS); - doTestResult("smsto:+15551212", "+15551212", ParsedResultType.SMS); - doTestResult("smsto:+15551212:subject", "+15551212\nsubject", ParsedResultType.SMS); - doTestResult("smsto:+15551212:My message", "+15551212\nMy message", ParsedResultType.SMS); - // Need to handle question mark in the subject - doTestResult("smsto:+15551212:What's up?", "+15551212\nWhat's up?", ParsedResultType.SMS); - // Need to handle colon in the subject - doTestResult("smsto:+15551212:Directions: Do this", "+15551212\nDirections: Do this", - ParsedResultType.SMS); - doTestResult("smsto:212-555-1212:Here's a longer message. Should be fine.", - "212-555-1212\nHere's a longer message. Should be fine.", - ParsedResultType.SMS); - } - - @Test - public void testMMS() { - doTestResult("mms:+15551212", "+15551212", ParsedResultType.SMS); - doTestResult("MMS:+15551212", "+15551212", ParsedResultType.SMS); - doTestResult("mms:+15551212;via=999333", "+15551212", ParsedResultType.SMS); - doTestResult("mms:+15551212?subject=foo&body=bar", "+15551212\nfoo\nbar", ParsedResultType.SMS); - doTestResult("mms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedResultType.SMS); - } - - @Test - public void testMMSTO() { - doTestResult("MMSTO:+15551212", "+15551212", ParsedResultType.SMS); - doTestResult("mmsto:+15551212", "+15551212", ParsedResultType.SMS); - doTestResult("mmsto:+15551212:subject", "+15551212\nsubject", ParsedResultType.SMS); - doTestResult("mmsto:+15551212:My message", "+15551212\nMy message", ParsedResultType.SMS); - doTestResult("mmsto:+15551212:What's up?", "+15551212\nWhat's up?", ParsedResultType.SMS); - doTestResult("mmsto:+15551212:Directions: Do this", "+15551212\nDirections: Do this", - ParsedResultType.SMS); - doTestResult("mmsto:212-555-1212:Here's a longer message. Should be fine.", - "212-555-1212\nHere's a longer message. Should be fine.", ParsedResultType.SMS); - } - - private static void doTestResult(String contents, - String goldenResult, - ParsedResultType type) { - doTestResult(contents, goldenResult, type, BarcodeFormat.QR_CODE); // QR code is arbitrary - } - - private static void doTestResult(String contents, - String goldenResult, - ParsedResultType type, - BarcodeFormat format) { - Result fakeResult = new Result(contents, null, null, format); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertNotNull(result); - assertSame(type, result.getType()); - - String displayResult = result.getDisplayResult(); - assertEquals(goldenResult, displayResult); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/ProductParsedResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/ProductParsedResultTestCase.java deleted file mode 100644 index b11bae6..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/ProductParsedResultTestCase.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link ProductParsedResult}. - * - * @author Sean Owen - */ -public final class ProductParsedResultTestCase extends Assert { - - @Test - public void testProduct() { - doTest("123456789012", "123456789012", BarcodeFormat.UPC_A); - doTest("00393157", "00393157", BarcodeFormat.EAN_8); - doTest("5051140178499", "5051140178499", BarcodeFormat.EAN_13); - doTest("01234565", "012345000065", BarcodeFormat.UPC_E); - } - - private static void doTest(String contents, String normalized, BarcodeFormat format) { - Result fakeResult = new Result(contents, null, null, format); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(ParsedResultType.PRODUCT, result.getType()); - ProductParsedResult productResult = (ProductParsedResult) result; - assertEquals(contents, productResult.getProductID()); - assertEquals(normalized, productResult.getNormalizedProductID()); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/SMSMMSParsedResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/SMSMMSParsedResultTestCase.java deleted file mode 100644 index 34354b1..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/SMSMMSParsedResultTestCase.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link SMSParsedResult}. - * - * @author Sean Owen - */ -public final class SMSMMSParsedResultTestCase extends Assert { - - @Test - public void testSMS() { - doTest("sms:+15551212", "+15551212", null, null, null, "sms:+15551212"); - doTest("sms:+15551212?subject=foo&body=bar", "+15551212", "foo", "bar", null, - "sms:+15551212?body=bar&subject=foo"); - doTest("sms:+15551212;via=999333", "+15551212", null, null, "999333", - "sms:+15551212;via=999333"); - } - - @Test - public void testMMS() { - doTest("mms:+15551212", "+15551212", null, null, null, "sms:+15551212"); - doTest("mms:+15551212?subject=foo&body=bar", "+15551212", "foo", "bar", null, - "sms:+15551212?body=bar&subject=foo"); - doTest("mms:+15551212;via=999333", "+15551212", null, null, "999333", - "sms:+15551212;via=999333"); - } - - private static void doTest(String contents, - String number, - String subject, - String body, - String via, - String parsedURI) { - Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(ParsedResultType.SMS, result.getType()); - SMSParsedResult smsResult = (SMSParsedResult) result; - assertArrayEquals(new String[] { number }, smsResult.getNumbers()); - assertEquals(subject, smsResult.getSubject()); - assertEquals(body, smsResult.getBody()); - assertArrayEquals(new String[] { via }, smsResult.getVias()); - assertEquals(parsedURI, smsResult.getSMSURI()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/TelParsedResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/TelParsedResultTestCase.java deleted file mode 100644 index e7508fb..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/TelParsedResultTestCase.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link TelParsedResult}. - * - * @author Sean Owen - */ -public final class TelParsedResultTestCase extends Assert { - - @Test - public void testTel() { - doTest("tel:+15551212", "+15551212", null); - doTest("tel:2125551212", "2125551212", null); - } - - private static void doTest(String contents, String number, String title) { - Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(ParsedResultType.TEL, result.getType()); - TelParsedResult telResult = (TelParsedResult) result; - assertEquals(number, telResult.getNumber()); - assertEquals(title, telResult.getTitle()); - assertEquals("tel:" + number, telResult.getTelURI()); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/URIParsedResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/URIParsedResultTestCase.java deleted file mode 100644 index 168acbf..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/URIParsedResultTestCase.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link URIParsedResult}. - * - * @author Sean Owen - */ -public final class URIParsedResultTestCase extends Assert { - - @Test - public void testBookmarkDocomo() { - doTest("MEBKM:URL:google.com;;", "http://google.com", null); - doTest("MEBKM:URL:http://google.com;;", "http://google.com", null); - doTest("MEBKM:URL:google.com;TITLE:Google;", "http://google.com", "Google"); - } - - @SuppressWarnings("checkstyle:lineLength") - @Test - public void testURI() { - doTest("google.com", "http://google.com", null); - doTest("123.com", "http://123.com", null); - doTest("http://google.com", "http://google.com", null); - doTest("https://google.com", "https://google.com", null); - doTest("google.com:443", "http://google.com:443", null); - doTest("https://www.google.com/calendar/hosted/google.com/embed?mode=AGENDA&force_login=true&src=google.com_726f6f6d5f6265707075@resource.calendar.google.com", - "https://www.google.com/calendar/hosted/google.com/embed?mode=AGENDA&force_login=true&src=google.com_726f6f6d5f6265707075@resource.calendar.google.com", - null); - doTest("otpauth://remoteaccess?devaddr=00%a1b2%c3d4&devname=foo&key=bar", - "otpauth://remoteaccess?devaddr=00%a1b2%c3d4&devname=foo&key=bar", - null); - doTest("s3://amazon.com:8123", "s3://amazon.com:8123", null); - doTest("HTTP://R.BEETAGG.COM/?12345", "HTTP://R.BEETAGG.COM/?12345", null); - } - - @Test - public void testNotURI() { - doTestNotUri("google.c"); - doTestNotUri(".com"); - doTestNotUri(":80/"); - doTestNotUri("ABC,20.3,AB,AD"); - doTestNotUri("http://google.com?q=foo bar"); - doTestNotUri("12756.501"); - doTestNotUri("google.50"); - doTestNotUri("foo.bar.bing.baz.foo.bar.bing.baz"); - } - - @Test - public void testURLTO() { - doTest("urlto::bar.com", "http://bar.com", null); - doTest("urlto::http://bar.com", "http://bar.com", null); - doTest("urlto:foo:bar.com", "http://bar.com", "foo"); - } - - @Test - public void testGarbage() { - doTestNotUri("Da65cV1g^>%^f0bAbPn1CJB6lV7ZY8hs0Sm:DXU0cd]GyEeWBz8]bUHLB"); - doTestNotUri("DEA\u0003\u0019M\u0006\u0000\bå\u0000‡HO\u0000X$\u0001\u0000\u001Fwfc\u0007!þ“˜" + - "\u0013\u0013¾Z{ùÎÝڗZ§¨+y_zbñk\u00117¬âˆ\u000E†Ü\u0000\u0000\u0000\u0000" + - "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + - "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000£.ux"); - } - - @Test - public void testIsPossiblyMalicious() { - doTestIsPossiblyMalicious("http://google.com", false); - doTestIsPossiblyMalicious("http://google.com@evil.com", true); - doTestIsPossiblyMalicious("http://google.com:@evil.com", true); - doTestIsPossiblyMalicious("google.com:@evil.com", false); - doTestIsPossiblyMalicious("https://google.com:443", false); - doTestIsPossiblyMalicious("https://google.com:443/", false); - doTestIsPossiblyMalicious("https://evil@google.com:443", true); - doTestIsPossiblyMalicious("http://google.com/foo@bar", false); - doTestIsPossiblyMalicious("http://google.com/@@", false); - } - - @Test - public void testMaliciousUnicode() { - doTestIsPossiblyMalicious("https://google.com\u2215.evil.com/stuff", true); - doTestIsPossiblyMalicious("\u202ehttps://dylankatz.com/moc.elgoog.www//:sptth", true); - } - - @Test - public void testExotic() { - doTest("bitcoin:mySD89iqpmptrK3PhHFW9fa7BXiP7ANy3Y", "bitcoin:mySD89iqpmptrK3PhHFW9fa7BXiP7ANy3Y", null); - doTest("BTCTX:-TC4TO3$ZYZTC5NC83/SYOV+YGUGK:$BSF0P8/STNTKTKS.V84+JSA$LB+EHCG+8A725.2AZ-NAVX3VBV5K4MH7UL2.2M:" + - "F*M9HSL*$2P7T*FX.ZT80GWDRV0QZBPQ+O37WDCNZBRM3EQ0S9SZP+3BPYZG02U/LA*89C2U.V1TS.CT1VF3DIN*HN3W-O-" + - "0ZAKOAB32/.8:J501GJJTTWOA+5/6$MIYBERPZ41NJ6-WSG/*Z48ZH*LSAOEM*IXP81L:$F*W08Z60CR*C*P.JEEVI1F02J07L6+" + - "W4L1G$/IC*$16GK6A+:I1-:LJ:Z-P3NW6Z6ADFB-F2AKE$2DWN23GYCYEWX9S8L+LF$VXEKH7/R48E32PU+A:9H:8O5", - "BTCTX:-TC4TO3$ZYZTC5NC83/SYOV+YGUGK:$BSF0P8/STNTKTKS.V84+JSA$LB+EHCG+8A725.2AZ-NAVX3VBV5K4MH7UL2.2M:" + - "F*M9HSL*$2P7T*FX.ZT80GWDRV0QZBPQ+O37WDCNZBRM3EQ0S9SZP+3BPYZG02U/LA*89C2U.V1TS.CT1VF3DIN*HN3W-O-" + - "0ZAKOAB32/.8:J501GJJTTWOA+5/6$MIYBERPZ41NJ6-WSG/*Z48ZH*LSAOEM*IXP81L:$F*W08Z60CR*C*P.JEEVI1F02J07L6+" + - "W4L1G$/IC*$16GK6A+:I1-:LJ:Z-P3NW6Z6ADFB-F2AKE$2DWN23GYCYEWX9S8L+LF$VXEKH7/R48E32PU+A:9H:8O5", - null); - doTest("opc.tcp://test.samplehost.com:4841", "opc.tcp://test.samplehost.com:4841", null); - } - - private static void doTest(String contents, String uri, String title) { - Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(ParsedResultType.URI, result.getType()); - URIParsedResult uriResult = (URIParsedResult) result; - assertEquals(uri, uriResult.getURI()); - assertEquals(title, uriResult.getTitle()); - } - - private static void doTestNotUri(String text) { - Result fakeResult = new Result(text, null, null, BarcodeFormat.QR_CODE); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(ParsedResultType.TEXT, result.getType()); - assertEquals(text, result.getDisplayResult()); - } - - private static void doTestIsPossiblyMalicious(String uri, boolean malicious) { - Result fakeResult = new Result(uri, null, null, BarcodeFormat.QR_CODE); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(malicious ? ParsedResultType.TEXT : ParsedResultType.URI, result.getType()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/VINParsedResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/VINParsedResultTestCase.java deleted file mode 100644 index 1897736..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/VINParsedResultTestCase.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2014 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link VINParsedResult}. - */ -public final class VINParsedResultTestCase extends Assert { - - @Test - public void testNotVIN() { - Result fakeResult = new Result("1M8GDM9A1KP042788", null, null, BarcodeFormat.CODE_39); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertEquals(ParsedResultType.TEXT, result.getType()); - fakeResult = new Result("1M8GDM9AXKP042788", null, null, BarcodeFormat.CODE_128); - result = ResultParser.parseResult(fakeResult); - assertEquals(ParsedResultType.TEXT, result.getType()); - } - - @Test - public void testVIN() { - doTest("1M8GDM9AXKP042788", "1M8", "GDM9AX", "KP042788", "US", "GDM9A", 1989, 'P', "042788"); - doTest("I1M8GDM9AXKP042788", "1M8", "GDM9AX", "KP042788", "US", "GDM9A", 1989, 'P', "042788"); - doTest("LJCPCBLCX11000237", "LJC", "PCBLCX", "11000237", "CN", "PCBLC", 2001, '1', "000237"); - } - - private static void doTest(String contents, - String wmi, - String vds, - String vis, - String country, - String attributes, - int year, - char plant, - String sequential) { - Result fakeResult = new Result(contents, null, null, BarcodeFormat.CODE_39); - ParsedResult result = ResultParser.parseResult(fakeResult); - assertSame(ParsedResultType.VIN, result.getType()); - VINParsedResult vinResult = (VINParsedResult) result; - assertEquals(wmi, vinResult.getWorldManufacturerID()); - assertEquals(vds, vinResult.getVehicleDescriptorSection()); - assertEquals(vis, vinResult.getVehicleIdentifierSection()); - assertEquals(country, vinResult.getCountryCode()); - assertEquals(attributes, vinResult.getVehicleAttributes()); - assertEquals(year, vinResult.getModelYear()); - assertEquals(plant, vinResult.getPlantCode()); - assertEquals(sequential, vinResult.getSequentialNumber()); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/client/result/WifiParsedResultTestCase.java b/port_src/core/src/test/java/com/google/zxing/client/result/WifiParsedResultTestCase.java deleted file mode 100644 index 66642d4..0000000 --- a/port_src/core/src/test/java/com/google/zxing/client/result/WifiParsedResultTestCase.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.client.result; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link WifiParsedResult}. - * - * @author Vikram Aggarwal - */ -public final class WifiParsedResultTestCase extends Assert { - - @Test - public void testNoPassword() { - doTest("WIFI:S:NoPassword;P:;T:;;", "NoPassword", null, "nopass"); - doTest("WIFI:S:No Password;P:;T:;;", "No Password", null, "nopass"); - } - - @Test - public void testWep() { - doTest("WIFI:S:TenChars;P:0123456789;T:WEP;;", "TenChars", "0123456789", "WEP"); - doTest("WIFI:S:TenChars;P:abcde56789;T:WEP;;", "TenChars", "abcde56789", "WEP"); - // Non hex should not fail at this level - doTest("WIFI:S:TenChars;P:hellothere;T:WEP;;", "TenChars", "hellothere", "WEP"); - - // Escaped semicolons - doTest("WIFI:S:Ten\\;\\;Chars;P:0123456789;T:WEP;;", "Ten;;Chars", "0123456789", "WEP"); - // Escaped colons - doTest("WIFI:S:Ten\\:\\:Chars;P:0123456789;T:WEP;;", "Ten::Chars", "0123456789", "WEP"); - - // TODO(vikrama) Need a test for SB as well. - } - - /** - * Put in checks for the length of the password for wep. - */ - @Test - public void testWpa() { - doTest("WIFI:S:TenChars;P:wow;T:WPA;;", "TenChars", "wow", "WPA"); - doTest("WIFI:S:TenChars;P:space is silent;T:WPA;;", "TenChars", "space is silent", "WPA"); - doTest("WIFI:S:TenChars;P:hellothere;T:WEP;;", "TenChars", "hellothere", "WEP"); - - // Escaped semicolons - doTest("WIFI:S:TenChars;P:hello\\;there;T:WEP;;", "TenChars", "hello;there", "WEP"); - // Escaped colons - doTest("WIFI:S:TenChars;P:hello\\:there;T:WEP;;", "TenChars", "hello:there", "WEP"); - } - - @Test - public void testEscape() { - doTest("WIFI:T:WPA;S:test;P:my_password\\\\;;", "test", "my_password\\", "WPA"); - doTest("WIFI:T:WPA;S:My_WiFi_SSID;P:abc123/;;", "My_WiFi_SSID", "abc123/", "WPA"); - doTest("WIFI:T:WPA;S:\"foo\\;bar\\\\baz\";;", "\"foo;bar\\baz\"", null, "WPA"); - doTest("WIFI:T:WPA;S:test;P:\\\"abcd\\\";;", "test", "\"abcd\"", "WPA"); - } - - /** - * Given the string contents for the barcode, check that it matches our expectations - */ - private static void doTest(String contents, - String ssid, - String password, - String type) { - Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); - ParsedResult result = ResultParser.parseResult(fakeResult); - - // Ensure it is a wifi code - assertSame(ParsedResultType.WIFI, result.getType()); - WifiParsedResult wifiResult = (WifiParsedResult) result; - - assertEquals(ssid, wifiResult.getSsid()); - assertEquals(password, wifiResult.getPassword()); - assertEquals(type, wifiResult.getNetworkEncryption()); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java b/port_src/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java deleted file mode 100644 index f295f31..0000000 --- a/port_src/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.BufferedImageLuminanceSource; -import com.google.zxing.DecodeHintType; -import com.google.zxing.LuminanceSource; -import com.google.zxing.Reader; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import org.junit.Assert; -import org.junit.Test; - -import javax.imageio.ImageIO; -import java.awt.Graphics; -import java.awt.geom.AffineTransform; -import java.awt.geom.RectangularShape; -import java.awt.image.AffineTransformOp; -import java.awt.image.BufferedImage; -import java.awt.image.BufferedImageOp; -import java.io.BufferedReader; -import java.io.IOException; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.nio.file.DirectoryStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.logging.Logger; - -/** - * @author Sean Owen - * @author dswitkin@google.com (Daniel Switkin) - */ -public abstract class AbstractBlackBoxTestCase extends Assert { - - private static final Logger log = Logger.getLogger(AbstractBlackBoxTestCase.class.getSimpleName()); - - private final Path testBase; - private final Reader barcodeReader; - private final BarcodeFormat expectedFormat; - private final List testResults; - private final EnumMap hints = new EnumMap<>(DecodeHintType.class); - - public static Path buildTestBase(String testBasePathSuffix) { - // A little workaround to prevent aggravation in my IDE - Path testBase = Paths.get(testBasePathSuffix); - if (!Files.exists(testBase)) { - // try starting with 'core' since the test base is often given as the project root - testBase = Paths.get("core").resolve(testBasePathSuffix); - } - return testBase; - } - - protected AbstractBlackBoxTestCase(String testBasePathSuffix, - Reader barcodeReader, - BarcodeFormat expectedFormat) { - this.testBase = buildTestBase(testBasePathSuffix); - this.barcodeReader = barcodeReader; - this.expectedFormat = expectedFormat; - testResults = new ArrayList<>(); - - System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s%6$s%n"); - } - - protected final Path getTestBase() { - return testBase; - } - - protected final void addTest(int mustPassCount, int tryHarderCount, float rotation) { - addTest(mustPassCount, tryHarderCount, 0, 0, rotation); - } - - protected void addHint(DecodeHintType hint) { - hints.put(hint, Boolean.TRUE); - } - - /** - * Adds a new test for the current directory of images. - * - * @param mustPassCount The number of images which must decode for the test to pass. - * @param tryHarderCount The number of images which must pass using the try harder flag. - * @param maxMisreads Maximum number of images which can fail due to successfully reading the wrong contents - * @param maxTryHarderMisreads Maximum number of images which can fail due to successfully - * reading the wrong contents using the try harder flag - * @param rotation The rotation in degrees clockwise to use for this test. - */ - protected final void addTest(int mustPassCount, - int tryHarderCount, - int maxMisreads, - int maxTryHarderMisreads, - float rotation) { - testResults.add(new TestResult(mustPassCount, tryHarderCount, maxMisreads, maxTryHarderMisreads, rotation)); - } - - protected final List getImageFiles() throws IOException { - assertTrue("Please download and install test images, and run from the 'core' directory", Files.exists(testBase)); - List paths = new ArrayList<>(); - try (DirectoryStream pathIt = Files.newDirectoryStream(testBase, "*.{jpg,jpeg,gif,png,JPG,JPEG,GIF,PNG}")) { - for (Path path : pathIt) { - paths.add(path); - } - } - return paths; - } - - final Reader getReader() { - return barcodeReader; - } - - @Test - public void testBlackBox() throws IOException { - assertFalse(testResults.isEmpty()); - - List imageFiles = getImageFiles(); - int testCount = testResults.size(); - - int[] passedCounts = new int[testCount]; - int[] misreadCounts = new int[testCount]; - int[] tryHarderCounts = new int[testCount]; - int[] tryHarderMisreadCounts = new int[testCount]; - - for (Path testImage : imageFiles) { - log.info(String.format("Starting %s", testImage)); - - BufferedImage image = ImageIO.read(testImage.toFile()); - - String testImageFileName = testImage.getFileName().toString(); - String fileBaseName = testImageFileName.substring(0, testImageFileName.indexOf('.')); - Path expectedTextFile = testBase.resolve(fileBaseName + ".txt"); - String expectedText; - if (Files.exists(expectedTextFile)) { - expectedText = readFileAsString(expectedTextFile, StandardCharsets.UTF_8); - } else { - expectedTextFile = testBase.resolve(fileBaseName + ".bin"); - assertTrue(Files.exists(expectedTextFile)); - expectedText = readFileAsString(expectedTextFile, StandardCharsets.ISO_8859_1); - } - - Path expectedMetadataFile = testBase.resolve(fileBaseName + ".metadata.txt"); - Properties expectedMetadata = new Properties(); - if (Files.exists(expectedMetadataFile)) { - try (BufferedReader reader = Files.newBufferedReader(expectedMetadataFile, StandardCharsets.UTF_8)) { - expectedMetadata.load(reader); - } - } - - for (int x = 0; x < testCount; x++) { - float rotation = testResults.get(x).getRotation(); - BufferedImage rotatedImage = rotateImage(image, rotation); - LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage); - BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); - try { - if (decode(bitmap, rotation, expectedText, expectedMetadata, false)) { - passedCounts[x]++; - } else { - misreadCounts[x]++; - } - } catch (ReaderException ignored) { - log.fine(String.format("could not read at rotation %f", rotation)); - } - try { - if (decode(bitmap, rotation, expectedText, expectedMetadata, true)) { - tryHarderCounts[x]++; - } else { - tryHarderMisreadCounts[x]++; - } - } catch (ReaderException ignored) { - log.fine(String.format("could not read at rotation %f w/TH", rotation)); - } - } - } - - // Print the results of all tests first - int totalFound = 0; - int totalMustPass = 0; - int totalMisread = 0; - int totalMaxMisread = 0; - - for (int x = 0; x < testResults.size(); x++) { - TestResult testResult = testResults.get(x); - log.info(String.format("Rotation %d degrees:", (int) testResult.getRotation())); - log.info(String.format(" %d of %d images passed (%d required)", - passedCounts[x], imageFiles.size(), testResult.getMustPassCount())); - int failed = imageFiles.size() - passedCounts[x]; - log.info(String.format(" %d failed due to misreads, %d not detected", - misreadCounts[x], failed - misreadCounts[x])); - log.info(String.format(" %d of %d images passed with try harder (%d required)", - tryHarderCounts[x], imageFiles.size(), testResult.getTryHarderCount())); - failed = imageFiles.size() - tryHarderCounts[x]; - log.info(String.format(" %d failed due to misreads, %d not detected", - tryHarderMisreadCounts[x], failed - tryHarderMisreadCounts[x])); - totalFound += passedCounts[x] + tryHarderCounts[x]; - totalMustPass += testResult.getMustPassCount() + testResult.getTryHarderCount(); - totalMisread += misreadCounts[x] + tryHarderMisreadCounts[x]; - totalMaxMisread += testResult.getMaxMisreads() + testResult.getMaxTryHarderMisreads(); - } - - int totalTests = imageFiles.size() * testCount * 2; - log.info(String.format("Decoded %d images out of %d (%d%%, %d required)", - totalFound, totalTests, totalFound * 100 / totalTests, totalMustPass)); - if (totalFound > totalMustPass) { - log.warning(String.format("+++ Test too lax by %d images", totalFound - totalMustPass)); - } else if (totalFound < totalMustPass) { - log.warning(String.format("--- Test failed by %d images", totalMustPass - totalFound)); - } - - if (totalMisread < totalMaxMisread) { - log.warning(String.format("+++ Test expects too many misreads by %d images", totalMaxMisread - totalMisread)); - } else if (totalMisread > totalMaxMisread) { - log.warning(String.format("--- Test had too many misreads by %d images", totalMisread - totalMaxMisread)); - } - - // Then run through again and assert if any failed - for (int x = 0; x < testCount; x++) { - TestResult testResult = testResults.get(x); - String label = "Rotation " + testResult.getRotation() + " degrees: Too many images failed"; - assertTrue(label, - passedCounts[x] >= testResult.getMustPassCount()); - assertTrue("Try harder, " + label, - tryHarderCounts[x] >= testResult.getTryHarderCount()); - label = "Rotation " + testResult.getRotation() + " degrees: Too many images misread"; - assertTrue(label, - misreadCounts[x] <= testResult.getMaxMisreads()); - assertTrue("Try harder, " + label, - tryHarderMisreadCounts[x] <= testResult.getMaxTryHarderMisreads()); - } - } - - private boolean decode(BinaryBitmap source, - float rotation, - String expectedText, - Map expectedMetadata, - boolean tryHarder) throws ReaderException { - - String suffix = String.format(" (%srotation: %d)", tryHarder ? "try harder, " : "", (int) rotation); - - Map hints = this.hints.clone(); - if (tryHarder) { - hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); - } - - // Try in 'pure' mode mostly to exercise PURE_BARCODE code paths for exceptions; - // not expected to pass, generally - Result result = null; - try { - Map pureHints = new EnumMap<>(hints); - pureHints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE); - result = barcodeReader.decode(source, pureHints); - } catch (ReaderException re) { - // continue - } - - if (result == null) { - result = barcodeReader.decode(source, hints); - } - - if (expectedFormat != result.getBarcodeFormat()) { - log.info(String.format("Format mismatch: expected '%s' but got '%s'%s", - expectedFormat, result.getBarcodeFormat(), suffix)); - return false; - } - - String resultText = result.getText(); - if (!expectedText.equals(resultText)) { - log.info(String.format("Content mismatch: expected '%s' but got '%s'%s", - expectedText, resultText, suffix)); - return false; - } - - Map resultMetadata = result.getResultMetadata(); - for (Map.Entry metadatum : expectedMetadata.entrySet()) { - ResultMetadataType key = ResultMetadataType.valueOf(metadatum.getKey().toString()); - Object expectedValue = metadatum.getValue(); - Object actualValue = resultMetadata == null ? null : resultMetadata.get(key); - if (!expectedValue.equals(actualValue)) { - log.info(String.format("Metadata mismatch for key '%s': expected '%s' but got '%s'", - key, expectedValue, actualValue)); - return false; - } - } - - return true; - } - - protected static String readFileAsString(Path file, Charset charset) throws IOException { - String stringContents = new String(Files.readAllBytes(file), charset); - if (stringContents.endsWith("\n")) { - log.info("String contents of file " + file + " end with a newline. " + - "This may not be intended and cause a test failure"); - } - return stringContents; - } - - protected static BufferedImage rotateImage(BufferedImage original, float degrees) { - if (degrees == 0.0f) { - return original; - } - - switch (original.getType()) { - case BufferedImage.TYPE_BYTE_INDEXED: - case BufferedImage.TYPE_BYTE_BINARY: - BufferedImage argb = new BufferedImage(original.getWidth(), - original.getHeight(), - BufferedImage.TYPE_INT_ARGB); - Graphics g = argb.createGraphics(); - g.drawImage(original, 0, 0, null); - g.dispose(); - original = argb; - break; - } - - double radians = Math.toRadians(degrees); - - // Transform simply to find out the new bounding box (don't actually run the image through it) - AffineTransform at = new AffineTransform(); - at.rotate(radians, original.getWidth() / 2.0, original.getHeight() / 2.0); - BufferedImageOp op = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC); - - RectangularShape r = op.getBounds2D(original); - int width = (int) Math.ceil(r.getWidth()); - int height = (int) Math.ceil(r.getHeight()); - - // Real transform, now that we know the size of the new image and how to translate after we rotate - // to keep it centered - at = new AffineTransform(); - at.rotate(radians, width / 2.0, height / 2.0); - at.translate((width - original.getWidth()) / 2.0, - (height - original.getHeight()) / 2.0); - op = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC); - - return op.filter(original, new BufferedImage(width, height, original.getType())); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/common/AbstractNegativeBlackBoxTestCase.java b/port_src/core/src/test/java/com/google/zxing/common/AbstractNegativeBlackBoxTestCase.java deleted file mode 100644 index ba37a9b..0000000 --- a/port_src/core/src/test/java/com/google/zxing/common/AbstractNegativeBlackBoxTestCase.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import com.google.zxing.BinaryBitmap; -import com.google.zxing.BufferedImageLuminanceSource; -import com.google.zxing.DecodeHintType; -import com.google.zxing.LuminanceSource; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import org.junit.Test; - -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -/** - * This abstract class looks for negative results, i.e. it only allows a certain number of false - * positives in images which should not decode. This helps ensure that we are not too lenient. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxTestCase { - - private static final Logger log = Logger.getLogger(AbstractNegativeBlackBoxTestCase.class.getSimpleName()); - - private final List testResults; - - private static final class TestResult { - private final int falsePositivesAllowed; - private final float rotation; - - TestResult(int falsePositivesAllowed, float rotation) { - this.falsePositivesAllowed = falsePositivesAllowed; - this.rotation = rotation; - } - - int getFalsePositivesAllowed() { - return falsePositivesAllowed; - } - - float getRotation() { - return rotation; - } - } - - // Use the multiformat reader to evaluate all decoders in the system. - protected AbstractNegativeBlackBoxTestCase(String testBasePathSuffix) { - super(testBasePathSuffix, new MultiFormatReader(), null); - testResults = new ArrayList<>(); - } - - protected final void addTest(int falsePositivesAllowed, float rotation) { - testResults.add(new TestResult(falsePositivesAllowed, rotation)); - } - - @Override - @Test - public void testBlackBox() throws IOException { - assertFalse(testResults.isEmpty()); - - List imageFiles = getImageFiles(); - int[] falsePositives = new int[testResults.size()]; - for (Path testImage : imageFiles) { - log.info(String.format("Starting %s", testImage)); - BufferedImage image = ImageIO.read(testImage.toFile()); - if (image == null) { - throw new IOException("Could not read image: " + testImage); - } - for (int x = 0; x < testResults.size(); x++) { - TestResult testResult = testResults.get(x); - if (!checkForFalsePositives(image, testResult.getRotation())) { - falsePositives[x]++; - } - } - } - - int totalFalsePositives = 0; - int totalAllowed = 0; - - for (int x = 0; x < testResults.size(); x++) { - TestResult testResult = testResults.get(x); - totalFalsePositives += falsePositives[x]; - totalAllowed += testResult.getFalsePositivesAllowed(); - } - - if (totalFalsePositives < totalAllowed) { - log.warning(String.format("+++ Test too lax by %d images", totalAllowed - totalFalsePositives)); - } else if (totalFalsePositives > totalAllowed) { - log.warning(String.format("--- Test failed by %d images", totalFalsePositives - totalAllowed)); - } - - for (int x = 0; x < testResults.size(); x++) { - TestResult testResult = testResults.get(x); - log.info(String.format("Rotation %d degrees: %d of %d images were false positives (%d allowed)", - (int) testResult.getRotation(), falsePositives[x], imageFiles.size(), - testResult.getFalsePositivesAllowed())); - assertTrue("Rotation " + testResult.getRotation() + " degrees: Too many false positives found", - falsePositives[x] <= testResult.getFalsePositivesAllowed()); - } - } - - /** - * Make sure ZXing does NOT find a barcode in the image. - * - * @param image The image to test - * @param rotationInDegrees The amount of rotation to apply - * @return true if nothing found, false if a non-existent barcode was detected - */ - private boolean checkForFalsePositives(BufferedImage image, float rotationInDegrees) { - BufferedImage rotatedImage = rotateImage(image, rotationInDegrees); - LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage); - BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); - Result result; - try { - result = getReader().decode(bitmap); - log.info(String.format("Found false positive: '%s' with format '%s' (rotation: %d)", - result.getText(), result.getBarcodeFormat(), (int) rotationInDegrees)); - return false; - } catch (ReaderException re) { - // continue - } - - // Try "try harder" getMode - Map hints = new EnumMap<>(DecodeHintType.class); - hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); - try { - result = getReader().decode(bitmap, hints); - log.info(String.format("Try harder found false positive: '%s' with format '%s' (rotation: %d)", - result.getText(), result.getBarcodeFormat(), (int) rotationInDegrees)); - return false; - } catch (ReaderException re) { - // continue - } - return true; - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/common/BitArrayTestCase.java b/port_src/core/src/test/java/com/google/zxing/common/BitArrayTestCase.java deleted file mode 100644 index d800e6d..0000000 --- a/port_src/core/src/test/java/com/google/zxing/common/BitArrayTestCase.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.Random; - -/** - * @author Sean Owen - */ -public final class BitArrayTestCase extends Assert { - - @Test - public void testGetSet() { - BitArray array = new BitArray(33); - for (int i = 0; i < 33; i++) { - assertFalse(array.get(i)); - array.set(i); - assertTrue(array.get(i)); - } - } - - @Test - public void testGetNextSet1() { - BitArray array = new BitArray(32); - for (int i = 0; i < array.getSize(); i++) { - assertEquals(String.valueOf(i), 32, array.getNextSet(i)); - } - array = new BitArray(33); - for (int i = 0; i < array.getSize(); i++) { - assertEquals(String.valueOf(i), 33, array.getNextSet(i)); - } - } - - @Test - public void testGetNextSet2() { - BitArray array = new BitArray(33); - array.set(31); - for (int i = 0; i < array.getSize(); i++) { - assertEquals(String.valueOf(i), i <= 31 ? 31 : 33, array.getNextSet(i)); - } - array = new BitArray(33); - array.set(32); - for (int i = 0; i < array.getSize(); i++) { - assertEquals(String.valueOf(i), 32, array.getNextSet(i)); - } - } - - @Test - public void testGetNextSet3() { - BitArray array = new BitArray(63); - array.set(31); - array.set(32); - for (int i = 0; i < array.getSize(); i++) { - int expected; - if (i <= 31) { - expected = 31; - } else if (i == 32) { - expected = 32; - } else { - expected = 63; - } - assertEquals(String.valueOf(i), expected, array.getNextSet(i)); - } - } - - @Test - public void testGetNextSet4() { - BitArray array = new BitArray(63); - array.set(33); - array.set(40); - for (int i = 0; i < array.getSize(); i++) { - int expected; - if (i <= 33) { - expected = 33; - } else if (i <= 40) { - expected = 40; - } else { - expected = 63; - } - assertEquals(String.valueOf(i), expected, array.getNextSet(i)); - } - } - - @Test - public void testGetNextSet5() { - Random r = new Random(0xDEADBEEF); - for (int i = 0; i < 10; i++) { - BitArray array = new BitArray(1 + r.nextInt(100)); - int numSet = r.nextInt(20); - for (int j = 0; j < numSet; j++) { - array.set(r.nextInt(array.getSize())); - } - int numQueries = r.nextInt(20); - for (int j = 0; j < numQueries; j++) { - int query = r.nextInt(array.getSize()); - int expected = query; - while (expected < array.getSize() && !array.get(expected)) { - expected++; - } - int actual = array.getNextSet(query); - assertEquals(expected, actual); - } - } - } - - - @Test - public void testSetBulk() { - BitArray array = new BitArray(64); - array.setBulk(32, 0xFFFF0000); - for (int i = 0; i < 48; i++) { - assertFalse(array.get(i)); - } - for (int i = 48; i < 64; i++) { - assertTrue(array.get(i)); - } - } - - @Test - public void testSetRange() { - BitArray array = new BitArray(64); - array.setRange(28, 36); - assertFalse(array.get(27)); - for (int i = 28; i < 36; i++) { - assertTrue(array.get(i)); - } - assertFalse(array.get(36)); - } - - @Test - public void testClear() { - BitArray array = new BitArray(32); - for (int i = 0; i < 32; i++) { - array.set(i); - } - array.clear(); - for (int i = 0; i < 32; i++) { - assertFalse(array.get(i)); - } - } - - @Test - public void testFlip() { - BitArray array = new BitArray(32); - assertFalse(array.get(5)); - array.flip(5); - assertTrue(array.get(5)); - array.flip(5); - assertFalse(array.get(5)); - } - - @Test - public void testGetArray() { - BitArray array = new BitArray(64); - array.set(0); - array.set(63); - int[] ints = array.getBitArray(); - assertEquals(1, ints[0]); - assertEquals(Integer.MIN_VALUE, ints[1]); - } - - @Test - public void testIsRange() { - BitArray array = new BitArray(64); - assertTrue(array.isRange(0, 64, false)); - assertFalse(array.isRange(0, 64, true)); - array.set(32); - assertTrue(array.isRange(32, 33, true)); - array.set(31); - assertTrue(array.isRange(31, 33, true)); - array.set(34); - assertFalse(array.isRange(31, 35, true)); - for (int i = 0; i < 31; i++) { - array.set(i); - } - assertTrue(array.isRange(0, 33, true)); - for (int i = 33; i < 64; i++) { - array.set(i); - } - assertTrue(array.isRange(0, 64, true)); - assertFalse(array.isRange(0, 64, false)); - } - - @Test - public void reverseAlgorithmTest() { - int[] oldBits = {128, 256, 512, 6453324, 50934953}; - for (int size = 1; size < 160; size++) { - int[] newBitsOriginal = reverseOriginal(oldBits.clone(), size); - BitArray newBitArray = new BitArray(oldBits.clone(), size); - newBitArray.reverse(); - int[] newBitsNew = newBitArray.getBitArray(); - assertTrue(arraysAreEqual(newBitsOriginal, newBitsNew, size / 32 + 1)); - } - } - - @Test - public void testClone() { - BitArray array = new BitArray(32); - array.clone().set(0); - assertFalse(array.get(0)); - } - - @Test - public void testEquals() { - BitArray a = new BitArray(32); - BitArray b = new BitArray(32); - assertEquals(a, b); - assertEquals(a.hashCode(), b.hashCode()); - assertNotEquals(a, new BitArray(31)); - a.set(16); - assertNotEquals(a, b); - assertNotEquals(a.hashCode(), b.hashCode()); - b.set(16); - assertEquals(a, b); - assertEquals(a.hashCode(), b.hashCode()); - } - - private static int[] reverseOriginal(int[] oldBits, int size) { - int[] newBits = new int[oldBits.length]; - for (int i = 0; i < size; i++) { - if (bitSet(oldBits, size - i - 1)) { - newBits[i / 32] |= 1 << (i & 0x1F); - } - } - return newBits; - } - - private static boolean bitSet(int[] bits, int i) { - return (bits[i / 32] & (1 << (i & 0x1F))) != 0; - } - - private static boolean arraysAreEqual(int[] left, int[] right, int size) { - for (int i = 0; i < size; i++) { - if (left[i] != right[i]) { - return false; - } - } - return true; - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/common/BitMatrixTestCase.java b/port_src/core/src/test/java/com/google/zxing/common/BitMatrixTestCase.java deleted file mode 100644 index b92705e..0000000 --- a/port_src/core/src/test/java/com/google/zxing/common/BitMatrixTestCase.java +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.Arrays; - -/** - * @author Sean Owen - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class BitMatrixTestCase extends Assert { - - private static final int[] BIT_MATRIX_POINTS = { 1, 2, 2, 0, 3, 1 }; - - @Test - public void testGetSet() { - BitMatrix matrix = new BitMatrix(33); - assertEquals(33, matrix.getHeight()); - for (int y = 0; y < 33; y++) { - for (int x = 0; x < 33; x++) { - if (y * x % 3 == 0) { - matrix.set(x, y); - } - } - } - for (int y = 0; y < 33; y++) { - for (int x = 0; x < 33; x++) { - assertEquals(y * x % 3 == 0, matrix.get(x, y)); - } - } - } - - @Test - public void testSetRegion() { - BitMatrix matrix = new BitMatrix(5); - matrix.setRegion(1, 1, 3, 3); - for (int y = 0; y < 5; y++) { - for (int x = 0; x < 5; x++) { - assertEquals(y >= 1 && y <= 3 && x >= 1 && x <= 3, matrix.get(x, y)); - } - } - } - - @Test - public void testEnclosing() { - BitMatrix matrix = new BitMatrix(5); - assertNull(matrix.getEnclosingRectangle()); - matrix.setRegion(1, 1, 1, 1); - assertArrayEquals(new int[] { 1, 1, 1, 1 }, matrix.getEnclosingRectangle()); - matrix.setRegion(1, 1, 3, 2); - assertArrayEquals(new int[] { 1, 1, 3, 2 }, matrix.getEnclosingRectangle()); - matrix.setRegion(0, 0, 5, 5); - assertArrayEquals(new int[] { 0, 0, 5, 5 }, matrix.getEnclosingRectangle()); - } - - @Test - public void testOnBit() { - BitMatrix matrix = new BitMatrix(5); - assertNull(matrix.getTopLeftOnBit()); - assertNull(matrix.getBottomRightOnBit()); - matrix.setRegion(1, 1, 1, 1); - assertArrayEquals(new int[] { 1, 1 }, matrix.getTopLeftOnBit()); - assertArrayEquals(new int[] { 1, 1 }, matrix.getBottomRightOnBit()); - matrix.setRegion(1, 1, 3, 2); - assertArrayEquals(new int[] { 1, 1 }, matrix.getTopLeftOnBit()); - assertArrayEquals(new int[] { 3, 2 }, matrix.getBottomRightOnBit()); - matrix.setRegion(0, 0, 5, 5); - assertArrayEquals(new int[] { 0, 0 }, matrix.getTopLeftOnBit()); - assertArrayEquals(new int[] { 4, 4 }, matrix.getBottomRightOnBit()); - } - - @Test - public void testRectangularMatrix() { - BitMatrix matrix = new BitMatrix(75, 20); - assertEquals(75, matrix.getWidth()); - assertEquals(20, matrix.getHeight()); - matrix.set(10, 0); - matrix.set(11, 1); - matrix.set(50, 2); - matrix.set(51, 3); - matrix.flip(74, 4); - matrix.flip(0, 5); - - // Should all be on - assertTrue(matrix.get(10, 0)); - assertTrue(matrix.get(11, 1)); - assertTrue(matrix.get(50, 2)); - assertTrue(matrix.get(51, 3)); - assertTrue(matrix.get(74, 4)); - assertTrue(matrix.get(0, 5)); - - // Flip a couple back off - matrix.flip(50, 2); - matrix.flip(51, 3); - assertFalse(matrix.get(50, 2)); - assertFalse(matrix.get(51, 3)); - } - - @Test - public void testRectangularSetRegion() { - BitMatrix matrix = new BitMatrix(320, 240); - assertEquals(320, matrix.getWidth()); - assertEquals(240, matrix.getHeight()); - matrix.setRegion(105, 22, 80, 12); - - // Only bits in the region should be on - for (int y = 0; y < 240; y++) { - for (int x = 0; x < 320; x++) { - assertEquals(y >= 22 && y < 34 && x >= 105 && x < 185, matrix.get(x, y)); - } - } - } - - @Test - public void testGetRow() { - BitMatrix matrix = new BitMatrix(102, 5); - for (int x = 0; x < 102; x++) { - if ((x & 0x03) == 0) { - matrix.set(x, 2); - } - } - - // Should allocate - BitArray array = matrix.getRow(2, null); - assertEquals(102, array.getSize()); - - // Should reallocate - BitArray array2 = new BitArray(60); - array2 = matrix.getRow(2, array2); - assertEquals(102, array2.getSize()); - - // Should use provided object, with original BitArray size - BitArray array3 = new BitArray(200); - array3 = matrix.getRow(2, array3); - assertEquals(200, array3.getSize()); - - for (int x = 0; x < 102; x++) { - boolean on = (x & 0x03) == 0; - assertEquals(on, array.get(x)); - assertEquals(on, array2.get(x)); - assertEquals(on, array3.get(x)); - } - } - - @Test - public void testRotate90Simple() { - BitMatrix matrix = new BitMatrix(3, 3); - matrix.set(0, 0); - matrix.set(0, 1); - matrix.set(1, 2); - matrix.set(2, 1); - - matrix.rotate90(); - - assertTrue(matrix.get(0, 2)); - assertTrue(matrix.get(1, 2)); - assertTrue(matrix.get(2, 1)); - assertTrue(matrix.get(1, 0)); - } - - @Test - public void testRotate180Simple() { - BitMatrix matrix = new BitMatrix(3, 3); - matrix.set(0, 0); - matrix.set(0, 1); - matrix.set(1, 2); - matrix.set(2, 1); - - matrix.rotate180(); - - assertTrue(matrix.get(2, 2)); - assertTrue(matrix.get(2, 1)); - assertTrue(matrix.get(1, 0)); - assertTrue(matrix.get(0, 1)); - } - - @Test - public void testRotate180() { - testRotate180(7, 4); - testRotate180(7, 5); - testRotate180(8, 4); - testRotate180(8, 5); - } - - @Test - public void testParse() { - BitMatrix emptyMatrix = new BitMatrix(3, 3); - BitMatrix fullMatrix = new BitMatrix(3, 3); - fullMatrix.setRegion(0, 0, 3, 3); - BitMatrix centerMatrix = new BitMatrix(3, 3); - centerMatrix.setRegion(1, 1, 1, 1); - BitMatrix emptyMatrix24 = new BitMatrix(2, 4); - - assertEquals(emptyMatrix, BitMatrix.parse(" \n \n \n", "x", " ")); - assertEquals(emptyMatrix, BitMatrix.parse(" \n \r\r\n \n\r", "x", " ")); - assertEquals(emptyMatrix, BitMatrix.parse(" \n \n ", "x", " ")); - - assertEquals(fullMatrix, BitMatrix.parse("xxx\nxxx\nxxx\n", "x", " ")); - - assertEquals(centerMatrix, BitMatrix.parse(" \n x \n \n", "x", " ")); - assertEquals(centerMatrix, BitMatrix.parse(" \n x \n \n", "x ", " ")); - try { - assertEquals(centerMatrix, BitMatrix.parse(" \n xy\n \n", "x", " ")); - fail(); - } catch (IllegalArgumentException ex) { - // good - } - - assertEquals(emptyMatrix24, BitMatrix.parse(" \n \n \n \n", "x", " ")); - - assertEquals(centerMatrix, BitMatrix.parse(centerMatrix.toString("x", "."), "x", ".")); - } - - @Test - public void testParseBoolean() { - BitMatrix emptyMatrix = new BitMatrix(3, 3); - BitMatrix fullMatrix = new BitMatrix(3, 3); - fullMatrix.setRegion(0, 0, 3, 3); - BitMatrix centerMatrix = new BitMatrix(3, 3); - centerMatrix.setRegion(1, 1, 1, 1); - BitMatrix emptyMatrix24 = new BitMatrix(2, 4); - - boolean[][] matrix = new boolean[3][3]; - assertEquals(emptyMatrix, BitMatrix.parse(matrix)); - matrix[1][1] = true; - assertEquals(centerMatrix, BitMatrix.parse(matrix)); - for (boolean[] arr : matrix) { - Arrays.fill(arr, true); - } - assertEquals(fullMatrix, BitMatrix.parse(matrix)); - } - - @Test - public void testUnset() { - BitMatrix emptyMatrix = new BitMatrix(3, 3); - BitMatrix matrix = emptyMatrix.clone(); - matrix.set(1, 1); - assertNotEquals(emptyMatrix, matrix); - matrix.unset(1, 1); - assertEquals(emptyMatrix, matrix); - matrix.unset(1, 1); - assertEquals(emptyMatrix, matrix); - } - - @Test - public void testXOR() { - BitMatrix emptyMatrix = new BitMatrix(3, 3); - BitMatrix fullMatrix = new BitMatrix(3, 3); - fullMatrix.setRegion(0, 0, 3, 3); - BitMatrix centerMatrix = new BitMatrix(3, 3); - centerMatrix.setRegion(1, 1, 1, 1); - BitMatrix invertedCenterMatrix = fullMatrix.clone(); - invertedCenterMatrix.unset(1, 1); - BitMatrix badMatrix = new BitMatrix(4, 4); - - testXOR(emptyMatrix, emptyMatrix, emptyMatrix); - testXOR(emptyMatrix, centerMatrix, centerMatrix); - testXOR(emptyMatrix, fullMatrix, fullMatrix); - - testXOR(centerMatrix, emptyMatrix, centerMatrix); - testXOR(centerMatrix, centerMatrix, emptyMatrix); - testXOR(centerMatrix, fullMatrix, invertedCenterMatrix); - - testXOR(invertedCenterMatrix, emptyMatrix, invertedCenterMatrix); - testXOR(invertedCenterMatrix, centerMatrix, fullMatrix); - testXOR(invertedCenterMatrix, fullMatrix, centerMatrix); - - testXOR(fullMatrix, emptyMatrix, fullMatrix); - testXOR(fullMatrix, centerMatrix, invertedCenterMatrix); - testXOR(fullMatrix, fullMatrix, emptyMatrix); - - try { - emptyMatrix.clone().xor(badMatrix); - fail(); - } catch (IllegalArgumentException ex) { - // good - } - - try { - badMatrix.clone().xor(emptyMatrix); - fail(); - } catch (IllegalArgumentException ex) { - // good - } - } - - public static String matrixToString(BitMatrix result) { - assertEquals(1, result.getHeight()); - StringBuilder builder = new StringBuilder(result.getWidth()); - for (int i = 0; i < result.getWidth(); i++) { - builder.append(result.get(i, 0) ? '1' : '0'); - } - return builder.toString(); - } - - private static void testXOR(BitMatrix dataMatrix, BitMatrix flipMatrix, BitMatrix expectedMatrix) { - BitMatrix matrix = dataMatrix.clone(); - matrix.xor(flipMatrix); - assertEquals(expectedMatrix, matrix); - } - - private static void testRotate180(int width, int height) { - BitMatrix input = getInput(width, height); - input.rotate180(); - BitMatrix expected = getExpected(width, height); - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - assertEquals("(" + x + ',' + y + ')', expected.get(x, y), input.get(x, y)); - } - } - } - - private static BitMatrix getExpected(int width, int height) { - BitMatrix result = new BitMatrix(width, height); - for (int i = 0; i < BIT_MATRIX_POINTS.length; i += 2) { - result.set(width - 1 - BIT_MATRIX_POINTS[i], height - 1 - BIT_MATRIX_POINTS[i + 1]); - } - return result; - } - - private static BitMatrix getInput(int width, int height) { - BitMatrix result = new BitMatrix(width, height); - for (int i = 0; i < BIT_MATRIX_POINTS.length; i += 2) { - result.set(BIT_MATRIX_POINTS[i], BIT_MATRIX_POINTS[i + 1]); - } - return result; - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/common/BitSourceBuilder.java b/port_src/core/src/test/java/com/google/zxing/common/BitSourceBuilder.java deleted file mode 100755 index 9f02f7f..0000000 --- a/port_src/core/src/test/java/com/google/zxing/common/BitSourceBuilder.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import java.io.ByteArrayOutputStream; - -/** - * Class that lets one easily build an array of bytes by appending bits at a time. - * - * @author Sean Owen - */ -public final class BitSourceBuilder { - - private final ByteArrayOutputStream output; - private int nextByte; - private int bitsLeftInNextByte; - - public BitSourceBuilder() { - output = new ByteArrayOutputStream(); - nextByte = 0; - bitsLeftInNextByte = 8; - } - - public void write(int value, int numBits) { - if (numBits <= bitsLeftInNextByte) { - nextByte <<= numBits; - nextByte |= value; - bitsLeftInNextByte -= numBits; - if (bitsLeftInNextByte == 0) { - output.write(nextByte); - nextByte = 0; - bitsLeftInNextByte = 8; - } - } else { - int bitsToWriteNow = bitsLeftInNextByte; - int numRestOfBits = numBits - bitsToWriteNow; - int mask = 0xFF >> (8 - bitsToWriteNow); - int valueToWriteNow = (value >>> numRestOfBits) & mask; - write(valueToWriteNow, bitsToWriteNow); - write(value, numRestOfBits); - } - } - - public byte[] toByteArray() { - if (bitsLeftInNextByte < 8) { - write(0, bitsLeftInNextByte); - } - return output.toByteArray(); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/common/BitSourceTestCase.java b/port_src/core/src/test/java/com/google/zxing/common/BitSourceTestCase.java deleted file mode 100644 index 1ff714a..0000000 --- a/port_src/core/src/test/java/com/google/zxing/common/BitSourceTestCase.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Sean Owen - */ -public final class BitSourceTestCase extends Assert { - - @Test - public void testSource() { - byte[] bytes = {(byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5}; - BitSource source = new BitSource(bytes); - assertEquals(40, source.available()); - assertEquals(0, source.readBits(1)); - assertEquals(39, source.available()); - assertEquals(0, source.readBits(6)); - assertEquals(33, source.available()); - assertEquals(1, source.readBits(1)); - assertEquals(32, source.available()); - assertEquals(2, source.readBits(8)); - assertEquals(24, source.available()); - assertEquals(12, source.readBits(10)); - assertEquals(14, source.available()); - assertEquals(16, source.readBits(8)); - assertEquals(6, source.available()); - assertEquals(5, source.readBits(6)); - assertEquals(0, source.available()); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/common/PerspectiveTransformTestCase.java b/port_src/core/src/test/java/com/google/zxing/common/PerspectiveTransformTestCase.java deleted file mode 100644 index 651c6fb..0000000 --- a/port_src/core/src/test/java/com/google/zxing/common/PerspectiveTransformTestCase.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Sean Owen - */ -public final class PerspectiveTransformTestCase extends Assert { - - private static final float EPSILON = 1.0E-4f; - - @Test - public void testSquareToQuadrilateral() { - PerspectiveTransform pt = PerspectiveTransform.squareToQuadrilateral( - 2.0f, 3.0f, 10.0f, 4.0f, 16.0f, 15.0f, 4.0f, 9.0f); - assertPointEquals(2.0f, 3.0f, 0.0f, 0.0f, pt); - assertPointEquals(10.0f, 4.0f, 1.0f, 0.0f, pt); - assertPointEquals(4.0f, 9.0f, 0.0f, 1.0f, pt); - assertPointEquals(16.0f, 15.0f, 1.0f, 1.0f, pt); - assertPointEquals(6.535211f, 6.8873234f, 0.5f, 0.5f, pt); - assertPointEquals(48.0f, 42.42857f, 1.5f, 1.5f, pt); - } - - @Test - public void testQuadrilateralToQuadrilateral() { - PerspectiveTransform pt = PerspectiveTransform.quadrilateralToQuadrilateral( - 2.0f, 3.0f, 10.0f, 4.0f, 16.0f, 15.0f, 4.0f, 9.0f, - 103.0f, 110.0f, 300.0f, 120.0f, 290.0f, 270.0f, 150.0f, 280.0f); - assertPointEquals(103.0f, 110.0f, 2.0f, 3.0f, pt); - assertPointEquals(300.0f, 120.0f, 10.0f, 4.0f, pt); - assertPointEquals(290.0f, 270.0f, 16.0f, 15.0f, pt); - assertPointEquals(150.0f, 280.0f, 4.0f, 9.0f, pt); - assertPointEquals(7.1516876f, -64.60185f, 0.5f, 0.5f, pt); - assertPointEquals(328.09116f, 334.16385f, 50.0f, 50.0f, pt); - } - - private static void assertPointEquals(float expectedX, - float expectedY, - float sourceX, - float sourceY, - PerspectiveTransform pt) { - float[] points = {sourceX, sourceY}; - pt.transformPoints(points); - assertEquals(expectedX, points[0], EPSILON); - assertEquals(expectedY, points[1], EPSILON); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/common/StringUtilsTestCase.java b/port_src/core/src/test/java/com/google/zxing/common/StringUtilsTestCase.java deleted file mode 100644 index f845148..0000000 --- a/port_src/core/src/test/java/com/google/zxing/common/StringUtilsTestCase.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -import org.junit.Assert; -import org.junit.Test; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.Random; - -/** - * Tests {@link StringUtils}. - */ -public final class StringUtilsTestCase extends Assert { - - @Test - public void testRandom() { - Random r = new Random(1234L); - byte[] bytes = new byte[1000]; - r.nextBytes(bytes); - assertEquals(Charset.defaultCharset(), StringUtils.guessCharset(bytes, null)); - } - - @Test - public void testShortShiftJIS1() { - // 金魚 - doTest(new byte[] { (byte) 0x8b, (byte) 0xe0, (byte) 0x8b, (byte) 0x9b, }, StringUtils.SHIFT_JIS_CHARSET, "SJIS"); - } - - @Test - public void testShortISO885911() { - // bÃ¥d - doTest(new byte[] { (byte) 0x62, (byte) 0xe5, (byte) 0x64, }, StandardCharsets.ISO_8859_1, "ISO8859_1"); - } - - @Test - public void testShortUTF81() { - // Español - doTest(new byte[] { (byte) 0x45, (byte) 0x73, (byte) 0x70, (byte) 0x61, (byte) 0xc3, - (byte) 0xb1, (byte) 0x6f, (byte) 0x6c }, - StandardCharsets.UTF_8, "UTF8"); - } - - @Test - public void testMixedShiftJIS1() { - // Hello 金! - doTest(new byte[] { (byte) 0x48, (byte) 0x65, (byte) 0x6c, (byte) 0x6c, (byte) 0x6f, - (byte) 0x20, (byte) 0x8b, (byte) 0xe0, (byte) 0x21, }, - StringUtils.SHIFT_JIS_CHARSET, "SJIS"); - } - - @Test - public void testUTF16BE() { - // 调压柜 - doTest(new byte[] { (byte) 0xFE, (byte) 0xFF, (byte) 0x8c, (byte) 0x03, (byte) 0x53, (byte) 0x8b, - (byte) 0x67, (byte) 0xdc, }, - StandardCharsets.UTF_16, - StandardCharsets.UTF_16.name()); - } - - @Test - public void testUTF16LE() { - // 调压柜 - doTest(new byte[] { (byte) 0xFF, (byte) 0xFE, (byte) 0x03, (byte) 0x8c, (byte) 0x8b, (byte) 0x53, - (byte) 0xdc, (byte) 0x67, }, - StandardCharsets.UTF_16, - StandardCharsets.UTF_16.name()); - } - - private static void doTest(byte[] bytes, Charset charset, String encoding) { - Charset guessedCharset = StringUtils.guessCharset(bytes, null); - String guessedEncoding = StringUtils.guessEncoding(bytes, null); - assertEquals(charset, guessedCharset); - assertEquals(encoding, guessedEncoding); - } - - /** - * Utility for printing out a string in given encoding as a Java statement, since it's better - * to write that into the Java source file rather than risk character encoding issues in the - * source file itself. - * - * @param args command line arguments - */ - public static void main(String[] args) { - String text = args[0]; - Charset charset = Charset.forName(args[1]); - StringBuilder declaration = new StringBuilder(); - declaration.append("new byte[] { "); - for (byte b : text.getBytes(charset)) { - declaration.append("(byte) 0x"); - int value = b & 0xFF; - if (value < 0x10) { - declaration.append('0'); - } - declaration.append(Integer.toHexString(value)); - declaration.append(", "); - } - declaration.append('}'); - System.out.println(declaration); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/common/TestResult.java b/port_src/core/src/test/java/com/google/zxing/common/TestResult.java deleted file mode 100644 index cc1ad52..0000000 --- a/port_src/core/src/test/java/com/google/zxing/common/TestResult.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common; - -/** - * Encapsulates the result of one test over a batch of black-box images. - */ -public final class TestResult { - - private final int mustPassCount; - private final int tryHarderCount; - private final int maxMisreads; - private final int maxTryHarderMisreads; - private final float rotation; - - public TestResult(int mustPassCount, int tryHarderCount, int maxMisreads, int maxTryHarderMisreads, float rotation) { - this.mustPassCount = mustPassCount; - this.tryHarderCount = tryHarderCount; - this.maxMisreads = maxMisreads; - this.maxTryHarderMisreads = maxTryHarderMisreads; - this.rotation = rotation; - } - - public int getMustPassCount() { - return mustPassCount; - } - - public int getTryHarderCount() { - return tryHarderCount; - } - - public int getMaxMisreads() { - return maxMisreads; - } - - public int getMaxTryHarderMisreads() { - return maxTryHarderMisreads; - } - - public float getRotation() { - return rotation; - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/common/detector/MathUtilsTestCase.java b/port_src/core/src/test/java/com/google/zxing/common/detector/MathUtilsTestCase.java deleted file mode 100644 index 03c8a55..0000000 --- a/port_src/core/src/test/java/com/google/zxing/common/detector/MathUtilsTestCase.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2014 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common.detector; - -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link MathUtils}. - */ -public final class MathUtilsTestCase extends Assert { - - private static final float EPSILON = 1.0E-8f; - - @Test - public void testRound() { - assertEquals(-1, MathUtils.round(-1.0f)); - assertEquals(0, MathUtils.round(0.0f)); - assertEquals(1, MathUtils.round(1.0f)); - - assertEquals(2, MathUtils.round(1.9f)); - assertEquals(2, MathUtils.round(2.1f)); - - assertEquals(3, MathUtils.round(2.5f)); - - assertEquals(-2, MathUtils.round(-1.9f)); - assertEquals(-2, MathUtils.round(-2.1f)); - - assertEquals(-3, MathUtils.round(-2.5f)); // This differs from Math.round() - - assertEquals(Integer.MAX_VALUE, MathUtils.round(Integer.MAX_VALUE)); - assertEquals(Integer.MIN_VALUE, MathUtils.round(Integer.MIN_VALUE)); - - assertEquals(Integer.MAX_VALUE, MathUtils.round(Float.POSITIVE_INFINITY)); - assertEquals(Integer.MIN_VALUE, MathUtils.round(Float.NEGATIVE_INFINITY)); - - assertEquals(0, MathUtils.round(Float.NaN)); - } - - @Test - public void testDistance() { - assertEquals((float) Math.sqrt(8.0), MathUtils.distance(1.0f, 2.0f, 3.0f, 4.0f), EPSILON); - assertEquals(0.0f, MathUtils.distance(1.0f, 2.0f, 1.0f, 2.0f), EPSILON); - - assertEquals((float) Math.sqrt(8.0), MathUtils.distance(1, 2, 3, 4), EPSILON); - assertEquals(0.0f, MathUtils.distance(1, 2, 1, 2), EPSILON); - } - - @Test - public void testSum() { - assertEquals(0, MathUtils.sum(new int[] {})); - assertEquals(1, MathUtils.sum(new int[] {1})); - assertEquals(4, MathUtils.sum(new int[] {1, 3})); - assertEquals(0, MathUtils.sum(new int[] {-1, 1})); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/common/reedsolomon/GenericGFPolyTestCase.java b/port_src/core/src/test/java/com/google/zxing/common/reedsolomon/GenericGFPolyTestCase.java deleted file mode 100644 index 9174b84..0000000 --- a/port_src/core/src/test/java/com/google/zxing/common/reedsolomon/GenericGFPolyTestCase.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2018 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common.reedsolomon; - -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link GenericGFPoly}. - */ -public final class GenericGFPolyTestCase extends Assert { - - private static final GenericGF FIELD = GenericGF.QR_CODE_FIELD_256; - - @Test - public void testPolynomialString() { - assertEquals("0", FIELD.getZero().toString()); - assertEquals("-1", FIELD.buildMonomial(0, -1).toString()); - GenericGFPoly p = new GenericGFPoly(FIELD, new int[] {3, 0, -2, 1, 1}); - assertEquals("a^25x^4 - ax^2 + x + 1", p.toString()); - p = new GenericGFPoly(FIELD, new int[] {3}); - assertEquals("a^25", p.toString()); - } - - @Test - public void testZero() { - assertEquals(FIELD.getZero(),FIELD.buildMonomial(1, 0)); - assertEquals(FIELD.getZero(), FIELD.buildMonomial(1, 2).multiply(0)); - } - - @Test - public void testEvaluate() { - assertEquals(3, FIELD.buildMonomial(0, 3).evaluateAt(0)); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/common/reedsolomon/ReedSolomonTestCase.java b/port_src/core/src/test/java/com/google/zxing/common/reedsolomon/ReedSolomonTestCase.java deleted file mode 100644 index 5d62072..0000000 --- a/port_src/core/src/test/java/com/google/zxing/common/reedsolomon/ReedSolomonTestCase.java +++ /dev/null @@ -1,525 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.common.reedsolomon; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.Arrays; -import java.util.BitSet; -import java.util.Random; - -/** - * @author Rustam Abdullaev - */ -public final class ReedSolomonTestCase extends Assert { - - private static final int DECODER_RANDOM_TEST_ITERATIONS = 3; - private static final int DECODER_TEST_ITERATIONS = 10; - - @Test - public void testDataMatrix() { - // real life test cases - testEncodeDecode(GenericGF.DATA_MATRIX_FIELD_256, - new int[] { 142, 164, 186 }, new int[] { 114, 25, 5, 88, 102 }); - testEncodeDecode(GenericGF.DATA_MATRIX_FIELD_256, - new int[] { - 0x69, 0x75, 0x75, 0x71, 0x3B, 0x30, 0x30, 0x64, - 0x70, 0x65, 0x66, 0x2F, 0x68, 0x70, 0x70, 0x68, - 0x6D, 0x66, 0x2F, 0x64, 0x70, 0x6E, 0x30, 0x71, - 0x30, 0x7B, 0x79, 0x6A, 0x6F, 0x68, 0x30, 0x81, - 0xF0, 0x88, 0x1F, 0xB5 - }, - new int[] { - 0x1C, 0x64, 0xEE, 0xEB, 0xD0, 0x1D, 0x00, 0x03, - 0xF0, 0x1C, 0xF1, 0xD0, 0x6D, 0x00, 0x98, 0xDA, - 0x80, 0x88, 0xBE, 0xFF, 0xB7, 0xFA, 0xA9, 0x95 - }); - // synthetic test cases - testEncodeDecodeRandom(GenericGF.DATA_MATRIX_FIELD_256, 10, 240); - testEncodeDecodeRandom(GenericGF.DATA_MATRIX_FIELD_256, 128, 127); - testEncodeDecodeRandom(GenericGF.DATA_MATRIX_FIELD_256, 220, 35); - } - - @Test - public void testQRCode() { - // Test case from example given in ISO 18004, Annex I - testEncodeDecode(GenericGF.QR_CODE_FIELD_256, - new int[] { - 0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11, - 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11 - }, - new int[] { - 0xA5, 0x24, 0xD4, 0xC1, 0xED, 0x36, 0xC7, 0x87, - 0x2C, 0x55 - }); - testEncodeDecode(GenericGF.QR_CODE_FIELD_256, - new int[] { - 0x72, 0x67, 0x2F, 0x77, 0x69, 0x6B, 0x69, 0x2F, - 0x4D, 0x61, 0x69, 0x6E, 0x5F, 0x50, 0x61, 0x67, - 0x65, 0x3B, 0x3B, 0x00, 0xEC, 0x11, 0xEC, 0x11, - 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11 - }, - new int[] { - 0xD8, 0xB8, 0xEF, 0x14, 0xEC, 0xD0, 0xCC, 0x85, - 0x73, 0x40, 0x0B, 0xB5, 0x5A, 0xB8, 0x8B, 0x2E, - 0x08, 0x62 - }); - // real life test cases - // synthetic test cases - testEncodeDecodeRandom(GenericGF.QR_CODE_FIELD_256, 10, 240); - testEncodeDecodeRandom(GenericGF.QR_CODE_FIELD_256, 128, 127); - testEncodeDecodeRandom(GenericGF.QR_CODE_FIELD_256, 220, 35); - } - - @Test - public void testAztec() { - // real life test cases - testEncodeDecode(GenericGF.AZTEC_PARAM, - new int[] { 0x5, 0x6 }, new int[] { 0x3, 0x2, 0xB, 0xB, 0x7 }); - testEncodeDecode(GenericGF.AZTEC_PARAM, - new int[] { 0x0, 0x0, 0x0, 0x9 }, new int[] { 0xA, 0xD, 0x8, 0x6, 0x5, 0x6 }); - testEncodeDecode(GenericGF.AZTEC_PARAM, - new int[] { 0x2, 0x8, 0x8, 0x7 }, new int[] { 0xE, 0xC, 0xA, 0x9, 0x6, 0x8 }); - testEncodeDecode(GenericGF.AZTEC_DATA_6, new int[] { - 0x9, 0x32, 0x1, 0x29, 0x2F, 0x2, 0x27, 0x25, 0x1, 0x1B }, - new int[] { - 0x2C, 0x2, 0xD, 0xD, 0xA, 0x16, 0x28, 0x9, 0x22, 0xA, 0x14 - }); - testEncodeDecode(GenericGF.AZTEC_DATA_8, - new int[] { - 0xE0, 0x86, 0x42, 0x98, 0xE8, 0x4A, 0x96, 0xC6, - 0xB9, 0xF0, 0x8C, 0xA7, 0x4A, 0xDA, 0xF8, 0xCE, - 0xB7, 0xDE, 0x88, 0x64, 0x29, 0x8E, 0x84, 0xA9, - 0x6C, 0x6B, 0x9F, 0x08, 0xCA, 0x74, 0xAD, 0xAF, - 0x8C, 0xEB, 0x7C, 0x10, 0xC8, 0x53, 0x1D, 0x09, - 0x52, 0xD8, 0xD7, 0x3E, 0x11, 0x94, 0xE9, 0x5B, - 0x5F, 0x19, 0xD6, 0xFB, 0xD1, 0x0C, 0x85, 0x31, - 0xD0, 0x95, 0x2D, 0x8D, 0x73, 0xE1, 0x19, 0x4E, - 0x95, 0xB5, 0xF1, 0x9D, 0x6F - }, - new int[] { - 0x31, 0xD7, 0x04, 0x46, 0xB2, 0xC1, 0x06, 0x94, - 0x17, 0xE5, 0x0C, 0x2B, 0xA3, 0x99, 0x15, 0x7F, - 0x16, 0x3C, 0x66, 0xBA, 0x33, 0xD9, 0xE8, 0x87, - 0x86, 0xBB, 0x4B, 0x15, 0x4E, 0x4A, 0xDE, 0xD4, - 0xED, 0xA1, 0xF8, 0x47, 0x2A, 0x50, 0xA6, 0xBC, - 0x53, 0x7D, 0x29, 0xFE, 0x06, 0x49, 0xF3, 0x73, - 0x9F, 0xC1, 0x75 - }); - testEncodeDecode(GenericGF.AZTEC_DATA_10, - new int[] { - 0x15C, 0x1E1, 0x2D5, 0x02E, 0x048, 0x1E2, 0x037, 0x0CD, - 0x02E, 0x056, 0x26A, 0x281, 0x1C2, 0x1A6, 0x296, 0x045, - 0x041, 0x0AA, 0x095, 0x2CE, 0x003, 0x38F, 0x2CD, 0x1A2, - 0x036, 0x1AD, 0x04E, 0x090, 0x271, 0x0D3, 0x02E, 0x0D5, - 0x2D4, 0x032, 0x2CA, 0x281, 0x0AA, 0x04E, 0x024, 0x2D3, - 0x296, 0x281, 0x0E2, 0x08A, 0x1AA, 0x28A, 0x280, 0x07C, - 0x286, 0x0A1, 0x1D0, 0x1AD, 0x154, 0x032, 0x2C2, 0x1C1, - 0x145, 0x02B, 0x2D4, 0x2B0, 0x033, 0x2D5, 0x276, 0x1C1, - 0x282, 0x10A, 0x2B5, 0x154, 0x003, 0x385, 0x20F, 0x0C4, - 0x02D, 0x050, 0x266, 0x0D5, 0x033, 0x2D5, 0x276, 0x1C1, - 0x0D4, 0x2A0, 0x08F, 0x0C4, 0x024, 0x20F, 0x2E2, 0x1AD, - 0x154, 0x02E, 0x056, 0x26A, 0x281, 0x090, 0x1E5, 0x14E, - 0x0CF, 0x2B6, 0x1C1, 0x28A, 0x2A1, 0x04E, 0x0D5, 0x003, - 0x391, 0x122, 0x286, 0x1AD, 0x2D4, 0x028, 0x262, 0x2EA, - 0x0A2, 0x004, 0x176, 0x295, 0x201, 0x0D5, 0x024, 0x20F, - 0x116, 0x0C1, 0x056, 0x095, 0x213, 0x004, 0x1EA, 0x28A, - 0x02A, 0x234, 0x2CE, 0x037, 0x157, 0x0D3, 0x262, 0x026, - 0x262, 0x2A0, 0x086, 0x106, 0x2A1, 0x126, 0x1E5, 0x266, - 0x26A, 0x2A1, 0x0E6, 0x1AA, 0x281, 0x2B6, 0x271, 0x154, - 0x02F, 0x0C4, 0x02D, 0x213, 0x0CE, 0x003, 0x38F, 0x2CD, - 0x1A2, 0x036, 0x1B5, 0x26A, 0x086, 0x280, 0x086, 0x1AA, - 0x2A1, 0x226, 0x1AD, 0x0CF, 0x2A6, 0x292, 0x2C6, 0x022, - 0x1AA, 0x256, 0x0D5, 0x02D, 0x050, 0x266, 0x0D5, 0x004, - 0x176, 0x295, 0x201, 0x0D3, 0x055, 0x031, 0x2CD, 0x2EA, - 0x1E2, 0x261, 0x1EA, 0x28A, 0x004, 0x145, 0x026, 0x1A6, - 0x1C6, 0x1F5, 0x2CE, 0x034, 0x051, 0x146, 0x1E1, 0x0B0, - 0x1B0, 0x261, 0x0D5, 0x025, 0x142, 0x1C0, 0x07C, 0x0B0, - 0x1E6, 0x081, 0x044, 0x02F, 0x2CF, 0x081, 0x290, 0x0A2, - 0x1A6, 0x281, 0x0CD, 0x155, 0x031, 0x1A2, 0x086, 0x262, - 0x2A1, 0x0CD, 0x0CA, 0x0E6, 0x1E5, 0x003, 0x394, 0x0C5, - 0x030, 0x26F, 0x053, 0x0C1, 0x1B6, 0x095, 0x2D4, 0x030, - 0x26F, 0x053, 0x0C0, 0x07C, 0x2E6, 0x295, 0x143, 0x2CD, - 0x2CE, 0x037, 0x0C9, 0x144, 0x2CD, 0x040, 0x08E, 0x054, - 0x282, 0x022, 0x2A1, 0x229, 0x053, 0x0D5, 0x262, 0x027, - 0x26A, 0x1E8, 0x14D, 0x1A2, 0x004, 0x26A, 0x296, 0x281, - 0x176, 0x295, 0x201, 0x0E2, 0x2C4, 0x143, 0x2D4, 0x026, - 0x262, 0x2A0, 0x08F, 0x0C4, 0x031, 0x213, 0x2B5, 0x155, - 0x213, 0x02F, 0x143, 0x121, 0x2A6, 0x1AD, 0x2D4, 0x034, - 0x0C5, 0x026, 0x295, 0x003, 0x396, 0x2A1, 0x176, 0x295, - 0x201, 0x0AA, 0x04E, 0x004, 0x1B0, 0x070, 0x275, 0x154, - 0x026, 0x2C1, 0x2B3, 0x154, 0x2AA, 0x256, 0x0C1, 0x044, - 0x004, 0x23F - }, - new int[] { - 0x379, 0x099, 0x348, 0x010, 0x090, 0x196, 0x09C, 0x1FF, - 0x1B0, 0x32D, 0x244, 0x0DE, 0x201, 0x386, 0x163, 0x11F, - 0x39B, 0x344, 0x3FE, 0x02F, 0x188, 0x113, 0x3D9, 0x102, - 0x04A, 0x2E1, 0x1D1, 0x18E, 0x077, 0x262, 0x241, 0x20D, - 0x1B8, 0x11D, 0x0D0, 0x0A5, 0x29C, 0x24D, 0x3E7, 0x006, - 0x2D0, 0x1B7, 0x337, 0x178, 0x0F1, 0x1E0, 0x00B, 0x01E, - 0x0DA, 0x1C6, 0x2D9, 0x00D, 0x28B, 0x34A, 0x252, 0x27A, - 0x057, 0x0CA, 0x2C2, 0x2E4, 0x3A6, 0x0E3, 0x22B, 0x307, - 0x174, 0x292, 0x10C, 0x1ED, 0x2FD, 0x2D4, 0x0A7, 0x051, - 0x34F, 0x07A, 0x1D5, 0x01D, 0x22E, 0x2C2, 0x1DF, 0x08F, - 0x105, 0x3FE, 0x286, 0x2A2, 0x3B1, 0x131, 0x285, 0x362, - 0x315, 0x13C, 0x0F9, 0x1A2, 0x28D, 0x246, 0x1B3, 0x12C, - 0x2AD, 0x0F8, 0x222, 0x0EC, 0x39F, 0x358, 0x014, 0x229, - 0x0C8, 0x360, 0x1C2, 0x031, 0x098, 0x041, 0x3E4, 0x046, - 0x332, 0x318, 0x2E3, 0x24E, 0x3E2, 0x1E1, 0x0BE, 0x239, - 0x306, 0x3A5, 0x352, 0x351, 0x275, 0x0ED, 0x045, 0x229, - 0x0BF, 0x05D, 0x253, 0x1BE, 0x02E, 0x35A, 0x0E4, 0x2E9, - 0x17A, 0x166, 0x03C, 0x007 - }); - testEncodeDecode(GenericGF.AZTEC_DATA_12, - new int[] { - 0x571, 0xE1B, 0x542, 0xE12, 0x1E2, 0x0DC, 0xCD0, 0xB85, - 0x69A, 0xA81, 0x709, 0xA6A, 0x584, 0x510, 0x4AA, 0x256, - 0xCE0, 0x0F8, 0xFB3, 0x5A2, 0x0D9, 0xAD1, 0x389, 0x09C, - 0x4D3, 0x0B8, 0xD5B, 0x503, 0x2B2, 0xA81, 0x2A8, 0x4E0, - 0x92D, 0x3A5, 0xA81, 0x388, 0x8A6, 0xAA8, 0xAA0, 0x07C, - 0xA18, 0xA17, 0x41A, 0xD55, 0x032, 0xB09, 0xC15, 0x142, - 0xBB5, 0x2B0, 0x0CE, 0xD59, 0xD9C, 0x1A0, 0x90A, 0xAD5, - 0x540, 0x0F8, 0x583, 0xCC4, 0x0B4, 0x509, 0x98D, 0x50C, - 0xED5, 0x9D9, 0xC13, 0x52A, 0x023, 0xCC4, 0x092, 0x0FB, - 0x89A, 0xD55, 0x02E, 0x15A, 0x6AA, 0x049, 0x079, 0x54E, - 0x33E, 0xB67, 0x068, 0xAA8, 0x44E, 0x354, 0x03E, 0x452, - 0x2A1, 0x9AD, 0xB50, 0x289, 0x8AE, 0xA28, 0x804, 0x5DA, - 0x958, 0x04D, 0x509, 0x20F, 0x458, 0xC11, 0x589, 0x584, - 0xC04, 0x7AA, 0x8A0, 0xAA3, 0x4B3, 0x837, 0x55C, 0xD39, - 0x882, 0x698, 0xAA0, 0x219, 0x06A, 0x852, 0x679, 0x666, - 0x9AA, 0xA13, 0x99A, 0xAA0, 0x6B6, 0x9C5, 0x540, 0xBCC, - 0x40B, 0x613, 0x338, 0x03E, 0x3EC, 0xD68, 0x836, 0x6D6, - 0x6A2, 0x1A8, 0x021, 0x9AA, 0xA86, 0x266, 0xB4C, 0xFA9, - 0xA92, 0xB18, 0x226, 0xAA5, 0x635, 0x42D, 0x142, 0x663, - 0x540, 0x45D, 0xA95, 0x804, 0xD31, 0x543, 0x1B3, 0x6EA, - 0x78A, 0x617, 0xAA8, 0xA01, 0x145, 0x099, 0xA67, 0x19F, - 0x5B3, 0x834, 0x145, 0x467, 0x84B, 0x06C, 0x261, 0x354, - 0x255, 0x09C, 0x01F, 0x0B0, 0x798, 0x811, 0x102, 0xFB3, - 0xC81, 0xA40, 0xA26, 0x9A8, 0x133, 0x555, 0x0C5, 0xA22, - 0x1A6, 0x2A8, 0x4CD, 0x328, 0xE67, 0x940, 0x3E5, 0x0C5, - 0x0C2, 0x6F1, 0x4CC, 0x16D, 0x895, 0xB50, 0x309, 0xBC5, - 0x330, 0x07C, 0xB9A, 0x955, 0x0EC, 0xDB3, 0x837, 0x325, - 0x44B, 0x344, 0x023, 0x854, 0xA08, 0x22A, 0x862, 0x914, - 0xCD5, 0x988, 0x279, 0xA9E, 0x853, 0x5A2, 0x012, 0x6AA, - 0x5A8, 0x15D, 0xA95, 0x804, 0xE2B, 0x114, 0x3B5, 0x026, - 0x98A, 0xA02, 0x3CC, 0x40C, 0x613, 0xAD5, 0x558, 0x4C2, - 0xF50, 0xD21, 0xA99, 0xADB, 0x503, 0x431, 0x426, 0xA54, - 0x03E, 0x5AA, 0x15D, 0xA95, 0x804, 0xAA1, 0x380, 0x46C, - 0x070, 0x9D5, 0x540, 0x9AC, 0x1AC, 0xD54, 0xAAA, 0x563, - 0x044, 0x401, 0x220, 0x9F1, 0x4F0, 0xDAA, 0x170, 0x90F, - 0x106, 0xE66, 0x85C, 0x2B4, 0xD54, 0x0B8, 0x4D3, 0x52C, - 0x228, 0x825, 0x512, 0xB67, 0x007, 0xC7D, 0x9AD, 0x106, - 0xCD6, 0x89C, 0x484, 0xE26, 0x985, 0xC6A, 0xDA8, 0x195, - 0x954, 0x095, 0x427, 0x049, 0x69D, 0x2D4, 0x09C, 0x445, - 0x355, 0x455, 0x003, 0xE50, 0xC50, 0xBA0, 0xD6A, 0xA81, - 0x958, 0x4E0, 0xA8A, 0x15D, 0xA95, 0x806, 0x76A, 0xCEC, - 0xE0D, 0x048, 0x556, 0xAAA, 0x007, 0xC2C, 0x1E6, 0x205, - 0xA28, 0x4CC, 0x6A8, 0x676, 0xACE, 0xCE0, 0x9A9, 0x501, - 0x1E6, 0x204, 0x907, 0xDC4, 0xD6A, 0xA81, 0x70A, 0xD35, - 0x502, 0x483, 0xCAA, 0x719, 0xF5B, 0x383, 0x455, 0x422, - 0x71A, 0xA01, 0xF22, 0x915, 0x0CD, 0x6DA, 0x814, 0x4C5, - 0x751, 0x440, 0x22E, 0xD4A, 0xC02, 0x6A8, 0x490, 0x7A2, - 0xC60, 0x8AC, 0x4AC, 0x260, 0x23D, 0x545, 0x055, 0x1A5, - 0x9C1, 0xBAA, 0xE69, 0xCC4, 0x134, 0xC55, 0x010, 0xC83, - 0x542, 0x933, 0xCB3, 0x34D, 0x550, 0x9CC, 0xD55, 0x035, - 0xB4E, 0x2AA, 0x05E, 0x620, 0x5B0, 0x999, 0xC01, 0xF1F, - 0x66B, 0x441, 0xB36, 0xB35, 0x10D, 0x401, 0x0CD, 0x554, - 0x313, 0x35A, 0x67D, 0x4D4, 0x958, 0xC11, 0x355, 0x2B1, - 0xAA1, 0x68A, 0x133, 0x1AA, 0x022, 0xED4, 0xAC0, 0x269, - 0x8AA, 0x18D, 0x9B7, 0x53C, 0x530, 0xBD5, 0x450, 0x08A, - 0x284, 0xCD3, 0x38C, 0xFAD, 0x9C1, 0xA0A, 0x2A3, 0x3C2, - 0x583, 0x613, 0x09A, 0xA12, 0xA84, 0xE00, 0xF85, 0x83C, - 0xC40, 0x888, 0x17D, 0x9E4, 0x0D2, 0x051, 0x34D, 0x409, - 0x9AA, 0xA86, 0x2D1, 0x10D, 0x315, 0x426, 0x699, 0x473, - 0x3CA, 0x01F, 0x286, 0x286, 0x137, 0x8A6, 0x60B, 0x6C4, - 0xADA, 0x818, 0x4DE, 0x299, 0x803, 0xE5C, 0xD4A, 0xA87, - 0x66D, 0x9C1, 0xB99, 0x2A2, 0x59A, 0x201, 0x1C2, 0xA50, - 0x411, 0x543, 0x148, 0xA66, 0xACC, 0x413, 0xCD4, 0xF42, - 0x9AD, 0x100, 0x935, 0x52D, 0x40A, 0xED4, 0xAC0, 0x271, - 0x588, 0xA1D, 0xA81, 0x34C, 0x550, 0x11E, 0x620, 0x630, - 0x9D6, 0xAAA, 0xC26, 0x17A, 0x869, 0x0D4, 0xCD6, 0xDA8, - 0x1A1, 0x8A1, 0x352, 0xA01, 0xF2D, 0x50A, 0xED4, 0xAC0, - 0x255, 0x09C, 0x023, 0x603, 0x84E, 0xAAA, 0x04D, 0x60D, - 0x66A, 0xA55, 0x52B, 0x182, 0x220, 0x091, 0x00F, 0x8A7, - 0x86D, 0x50B, 0x848, 0x788, 0x373, 0x342, 0xE15, 0xA6A, - 0xA05, 0xC26, 0x9A9, 0x611, 0x441, 0x2A8, 0x95B, 0x380, - 0x3E3, 0xECD, 0x688, 0x366, 0xB44, 0xE24, 0x271, 0x34C, - 0x2E3, 0x56D, 0x40C, 0xACA, 0xA04, 0xAA1, 0x382, 0x4B4, - 0xE96, 0xA04, 0xE22, 0x29A, 0xAA2, 0xA80, 0x1F2, 0x862, - 0x85D, 0x06B, 0x554, 0x0CA, 0xC27, 0x054, 0x50A, 0xED4, - 0xAC0, 0x33B, 0x567, 0x670, 0x682, 0x42A, 0xB55, 0x500, - 0x3E1, 0x60F, 0x310, 0x2D1, 0x426, 0x635, 0x433, 0xB56, - 0x767, 0x04D, 0x4A8, 0x08F, 0x310, 0x248, 0x3EE, 0x26B, - 0x554, 0x0B8, 0x569, 0xAA8, 0x124, 0x1E5, 0x538, 0xCFA, - 0xD9C, 0x1A2, 0xAA1, 0x138, 0xD50, 0x0F9, 0x148, 0xA86, - 0x6B6, 0xD40, 0xA26, 0x2BA, 0x8A2, 0x011, 0x76A, 0x560, - 0x135, 0x424, 0x83D, 0x163, 0x045, 0x625, 0x613, 0x011, - 0xEAA, 0x282, 0xA8D, 0x2CE, 0x0DD, 0x573, 0x4E6, 0x209, - 0xA62, 0xA80, 0x864, 0x1AA, 0x149, 0x9E5, 0x99A, 0x6AA, - 0x84E, 0x66A, 0xA81, 0xADA, 0x715, 0x502, 0xF31, 0x02D, - 0x84C, 0xCE0, 0x0F8, 0xFB3, 0x5A2, 0x0D9, 0xB59, 0xA88, - 0x6A0, 0x086, 0x6AA, 0xA18, 0x99A, 0xD33, 0xEA6, 0xA4A, - 0xC60, 0x89A, 0xA95, 0x8D5, 0x0B4, 0x509, 0x98D, 0x501, - 0x176, 0xA56, 0x013, 0x4C5, 0x50C, 0x6CD, 0xBA9, 0xE29, - 0x85E, 0xAA2, 0x804, 0x514, 0x266, 0x99C, 0x67D, 0x6CE, - 0x0D0, 0x515, 0x19E, 0x12C, 0x1B0, 0x984, 0xD50, 0x954, - 0x270, 0x07C, 0x2C1, 0xE62, 0x044, 0x40B, 0xECF, 0x206, - 0x902, 0x89A, 0x6A0, 0x4CD, 0x554, 0x316, 0x888, 0x698, - 0xAA1, 0x334, 0xCA3, 0x99E, 0x500, 0xF94, 0x314, 0x309, - 0xBC5, 0x330, 0x5B6, 0x256, 0xD40, 0xC26, 0xF14, 0xCC0, - 0x1F2, 0xE6A, 0x554, 0x3B3, 0x6CE, 0x0DC, 0xC95, 0x12C, - 0xD10, 0x08E, 0x152, 0x820, 0x8AA, 0x18A, 0x453, 0x356, - 0x620, 0x9E6, 0xA7A, 0x14D, 0x688, 0x049, 0xAA9, 0x6A0, - 0x576, 0xA56, 0x013, 0x8AC, 0x450, 0xED4, 0x09A, 0x62A, - 0x808, 0xF31, 0x031, 0x84E, 0xB55, 0x561, 0x30B, 0xD43, - 0x486, 0xA66, 0xB6D, 0x40D, 0x0C5, 0x09A, 0x950, 0x0F9, - 0x6A8, 0x576, 0xA56, 0x012, 0xA84, 0xE01, 0x1B0, 0x1C2, - 0x755, 0x502, 0x6B0, 0x6B3, 0x552, 0xAA9, 0x58C, 0x111, - 0x004, 0x882, 0x7C5, 0x3C3, 0x6A8, 0x5C2, 0x43C, 0x41B, - 0x99A, 0x170, 0xAD3, 0x550, 0x2E1, 0x34D, 0x4B0, 0x8A2, - 0x095, 0x44A, 0xD9C, 0x01F, 0x1F6, 0x6B4, 0x41B, 0x35A, - 0x271, 0x213, 0x89A, 0x617, 0x1AB, 0x6A0, 0x656, 0x550, - 0x255, 0x09C, 0x125, 0xA74, 0xB50, 0x271, 0x114, 0xD55, - 0x154, 0x00F, 0x943, 0x142, 0xE83, 0x5AA, 0xA06, 0x561, - 0x382, 0xA28, 0x576, 0xA56, 0x019, 0xDAB, 0x3B3, 0x834, - 0x121, 0x55A, 0xAA8, 0x01F, 0x0B0, 0x798, 0x816, 0x8A1, - 0x331, 0xAA1, 0x9DA, 0xB3B, 0x382, 0x6A5, 0x404, 0x798, - 0x812, 0x41F, 0x713, 0x5AA, 0xA05, 0xC2B, 0x4D5, 0x409, - 0x20F, 0x2A9, 0xC67, 0xD6C, 0xE0D, 0x155, 0x089, 0xC6A, - 0x807, 0xC8A, 0x454, 0x335, 0xB6A, 0x051, 0x315, 0xD45, - 0x100, 0x8BB, 0x52B, 0x009, 0xAA1, 0x241, 0xE8B, 0x182, - 0x2B1, 0x2B0, 0x980, 0x8F5, 0x514, 0x154, 0x696, 0x706, - 0xEAB, 0x9A7, 0x310, 0x4D3, 0x154, 0x043, 0x20D, 0x50A, - 0x4CF, 0x2CC, 0xD35, 0x542, 0x733, 0x554, 0x0D6, 0xD38, - 0xAA8, 0x179, 0x881, 0x6C2, 0x667, 0x007, 0xC7D, 0x9AD, - 0x106, 0xCDA, 0xCD4, 0x435, 0x004, 0x335, 0x550, 0xC4C, - 0xD69, 0x9F5, 0x352, 0x563, 0x044, 0xD54, 0xAC6, 0xA85, - 0xA28, 0x4CC, 0x6A8, 0x08B, 0xB52, 0xB00, 0x9A6, 0x2A8, - 0x636, 0x6DD, 0x4F1, 0x4C2, 0xF55, 0x140, 0x228, 0xA13, - 0x34C, 0xE33, 0xEB6, 0x706, 0x828, 0xA8C, 0xF09, 0x60D, - 0x84C, 0x26A, 0x84A, 0xA13, 0x803, 0xE16, 0x0F3, 0x102, - 0x220, 0x5F6, 0x790, 0x348, 0x144, 0xD35, 0x026, 0x6AA, - 0xA18, 0xB44, 0x434, 0xC55, 0x099, 0xA65, 0x1CC, 0xF28, - 0x07C, 0xA18, 0xA18, 0x4DE, 0x299, 0x82D, 0xB12, 0xB6A, - 0x061, 0x378, 0xA66, 0x00F, 0x973, 0x52A, 0xA1D, 0x9B6, - 0x706, 0xE64, 0xA89, 0x668, 0x804, 0x70A, 0x941, 0x045, - 0x50C, 0x522, 0x99A, 0xB31, 0x04F, 0x353, 0xD0A, 0x6B4, - 0x402, 0x4D5, 0x4B5, 0x02B, 0xB52, 0xB00, 0x9C5, 0x622, - 0x876, 0xA04, 0xD31, 0x540, 0x479, 0x881, 0x8C2, 0x75A, - 0xAAB, 0x098, 0x5EA, 0x1A4, 0x353, 0x35B, 0x6A0, 0x686, - 0x284, 0xD4A, 0x807, 0xCB5, 0x42B, 0xB52, 0xB00, 0x954, - 0x270, 0x08D, 0x80E, 0x13A, 0xAA8, 0x135, 0x835, 0x9AA, - 0x801, 0xF14, 0xF0D, 0xAA1, 0x709, 0x0F1, 0x06E, 0x668, - 0x5C2, 0xB4D, 0x540, 0xB84, 0xD35, 0x2C2, 0x288, 0x255, - 0x12B, 0x670, 0x07C, 0x7D9, 0xAD1, 0x06C, 0xD68, 0x9C4, - 0x84E, 0x269, 0x85C, 0x6AD, 0xA81, 0x959, 0x540, 0x954, - 0x270, 0x496, 0x9D2, 0xD40, 0x9C4, 0x453, 0x554, 0x550, - 0x03E, 0x50C, 0x50B, 0xA0D, 0x6AA, 0x819, 0x584, 0xE0A, - 0x8A1, 0x5DA, 0x958, 0x067, 0x6AC, 0xECE, 0x0D0, 0x485, - 0x56A, 0xAA0, 0x07C, 0x2C1, 0xE62, 0x05A, 0x284, 0xCC6, - 0xA86, 0x76A, 0xCEC, 0xE09, 0xA95, 0x011, 0xE62, 0x049, - 0x07D, 0xC4D, 0x6AA, 0x817, 0x0AD, 0x355, 0x024, 0x83C, - 0xAA7, 0x19F, 0x5B3, 0x834, 0x554, 0x227, 0x1AA, 0x01F, - 0x229, 0x150, 0xCD6, 0xDA8, 0x144, 0xC57, 0x514, 0x402, - 0x2ED, 0x4AC, 0x026, 0xA84, 0x907, 0xA2C, 0x608, 0xAC4, - 0xAC2, 0x602, 0x3D5, 0x450, 0x551, 0xA59, 0xC1B, 0xAAE, - 0x69C, 0xC41, 0x34C, 0x550, 0x10C, 0x835, 0x429, 0x33C, - 0xB33, 0x4D5, 0x509, 0xCCD, 0x550, 0x35B, 0x4E2, 0xAA0, - 0x5E6, 0x205, 0xB09, 0x99C, 0x09F - }, - new int[] { - 0xD54, 0x221, 0x154, 0x7CD, 0xBF3, 0x112, 0x89B, 0xC5E, - 0x9CD, 0x07E, 0xFB6, 0x78F, 0x7FA, 0x16F, 0x377, 0x4B4, - 0x62D, 0x475, 0xBC2, 0x861, 0xB72, 0x9D0, 0x76A, 0x5A1, - 0x22A, 0xF74, 0xDBA, 0x8B1, 0x139, 0xDCD, 0x012, 0x293, - 0x705, 0xA34, 0xDD5, 0x3D2, 0x7F8, 0x0A6, 0x89A, 0x346, - 0xCE0, 0x690, 0x40E, 0xFF3, 0xC4D, 0x97F, 0x9C9, 0x016, - 0x73A, 0x923, 0xBCE, 0xFA9, 0xE6A, 0xB92, 0x02A, 0x07C, - 0x04B, 0x8D5, 0x753, 0x42E, 0x67E, 0x87C, 0xEE6, 0xD7D, - 0x2BF, 0xFB2, 0xFF8, 0x42F, 0x4CB, 0x214, 0x779, 0x02D, - 0x606, 0xA02, 0x08A, 0xD4F, 0xB87, 0xDDF, 0xC49, 0xB51, - 0x0E9, 0xF89, 0xAEF, 0xC92, 0x383, 0x98D, 0x367, 0xBD3, - 0xA55, 0x148, 0x9DB, 0x913, 0xC79, 0x6FF, 0x387, 0x6EA, - 0x7FA, 0xC1B, 0x12D, 0x303, 0xBCA, 0x503, 0x0FB, 0xB14, - 0x0D4, 0xAD1, 0xAFC, 0x9DD, 0x404, 0x145, 0x6E5, 0x8ED, - 0xF94, 0xD72, 0x645, 0xA21, 0x1A8, 0xABF, 0xC03, 0x91E, - 0xD53, 0x48C, 0x471, 0x4E4, 0x408, 0x33C, 0x5DF, 0x73D, - 0xA2A, 0x454, 0xD77, 0xC48, 0x2F5, 0x96A, 0x9CF, 0x047, - 0x611, 0xE92, 0xC2F, 0xA98, 0x56D, 0x919, 0x615, 0x535, - 0x67A, 0x8C1, 0x2E2, 0xBC4, 0xBE8, 0x328, 0x04F, 0x257, - 0x3F9, 0xFA5, 0x477, 0x12E, 0x94B, 0x116, 0xEF7, 0x65F, - 0x6B3, 0x915, 0xC64, 0x9AF, 0xB6C, 0x6A2, 0x50D, 0xEA3, - 0x26E, 0xC23, 0x817, 0xA42, 0x71A, 0x9DD, 0xDA8, 0x84D, - 0x3F3, 0x85B, 0xB00, 0x1FC, 0xB0A, 0xC2F, 0x00C, 0x095, - 0xC58, 0x0E3, 0x807, 0x962, 0xC4B, 0x29A, 0x6FC, 0x958, - 0xD29, 0x59E, 0xB14, 0x95A, 0xEDE, 0xF3D, 0xFB8, 0x0E5, - 0x348, 0x2E7, 0x38E, 0x56A, 0x410, 0x3B1, 0x4B0, 0x793, - 0xAB7, 0x0BC, 0x648, 0x719, 0xE3E, 0xFB4, 0x3B4, 0xE5C, - 0x950, 0xD2A, 0x50B, 0x76F, 0x8D2, 0x3C7, 0xECC, 0x87C, - 0x53A, 0xBA7, 0x4C3, 0x148, 0x437, 0x820, 0xECD, 0x660, - 0x095, 0x2F4, 0x661, 0x6A4, 0xB74, 0x5F3, 0x1D2, 0x7EC, - 0x8E2, 0xA40, 0xA6F, 0xFC3, 0x3BE, 0x1E9, 0x52C, 0x233, - 0x173, 0x4EF, 0xA7C, 0x40B, 0x14C, 0x88D, 0xF30, 0x8D9, - 0xBDB, 0x0A6, 0x940, 0xD46, 0xB2B, 0x03E, 0x46A, 0x641, - 0xF08, 0xAFF, 0x496, 0x68A, 0x7A4, 0x0BA, 0xD43, 0x515, - 0xB26, 0xD8F, 0x05C, 0xD6E, 0xA2C, 0xF25, 0x628, 0x4E5, - 0x81D, 0xA2A, 0x1FF, 0x302, 0xFBD, 0x6D9, 0x711, 0xD8B, - 0xE5C, 0x5CF, 0x42E, 0x008, 0x863, 0xB6F, 0x1E1, 0x3DA, - 0xACE, 0x82B, 0x2DB, 0x7EB, 0xC15, 0x79F, 0xA79, 0xDAF, - 0x00D, 0x2F6, 0x0CE, 0x370, 0x7E8, 0x9E6, 0x89F, 0xAE9, - 0x175, 0xA95, 0x06B, 0x9DF, 0xAFF, 0x45B, 0x823, 0xAA4, - 0xC79, 0x773, 0x886, 0x854, 0x0A5, 0x6D1, 0xE55, 0xEBB, - 0x518, 0xE50, 0xF8F, 0x8CC, 0x834, 0x388, 0xCD2, 0xFC1, - 0xA55, 0x1F8, 0xD1F, 0xE08, 0xF93, 0x362, 0xA22, 0x9FA, - 0xCE5, 0x3C3, 0xDD4, 0xC53, 0xB94, 0xAD0, 0x6EB, 0x68D, - 0x660, 0x8FC, 0xBCD, 0x914, 0x16F, 0x4C0, 0x134, 0xE1A, - 0x76F, 0x9CB, 0x660, 0xEA0, 0x320, 0x15A, 0xCE3, 0x7E8, - 0x03E, 0xB9A, 0xC90, 0xA14, 0x256, 0x1A8, 0x639, 0x7C6, - 0xA59, 0xA65, 0x956, 0x9E4, 0x592, 0x6A9, 0xCFF, 0x4DC, - 0xAA3, 0xD2A, 0xFDE, 0xA87, 0xBF5, 0x9F0, 0xC32, 0x94F, - 0x675, 0x9A6, 0x369, 0x648, 0x289, 0x823, 0x498, 0x574, - 0x8D1, 0xA13, 0xD1A, 0xBB5, 0xA19, 0x7F7, 0x775, 0x138, - 0x949, 0xA4C, 0xE36, 0x126, 0xC85, 0xE05, 0xFEE, 0x962, - 0x36D, 0x08D, 0xC76, 0x1E1, 0x1EC, 0x8D7, 0x231, 0xB68, - 0x03C, 0x1DE, 0x7DF, 0x2B1, 0x09D, 0xC81, 0xDA4, 0x8F7, - 0x6B9, 0x947, 0x9B0 - }); - // synthetic test cases - testEncodeDecodeRandom(GenericGF.AZTEC_PARAM, 2, 5); // compact mode message - testEncodeDecodeRandom(GenericGF.AZTEC_PARAM, 4, 6); // full mode message - testEncodeDecodeRandom(GenericGF.AZTEC_DATA_6, 10, 7); - testEncodeDecodeRandom(GenericGF.AZTEC_DATA_6, 20, 12); - testEncodeDecodeRandom(GenericGF.AZTEC_DATA_8, 20, 11); - testEncodeDecodeRandom(GenericGF.AZTEC_DATA_8, 128, 127); - testEncodeDecodeRandom(GenericGF.AZTEC_DATA_10, 128, 128); - testEncodeDecodeRandom(GenericGF.AZTEC_DATA_10, 768, 255); - testEncodeDecodeRandom(GenericGF.AZTEC_DATA_12, 3072, 1023); - } - - public static void corrupt(int[] received, int howMany, Random random, int max) { - BitSet corrupted = new BitSet(received.length); - for (int j = 0; j < howMany; j++) { - int location = random.nextInt(received.length); - int value = random.nextInt(max); - if (corrupted.get(location) || received[location] == value) { - j--; - } else { - corrupted.set(location); - received[location] = value; - } - } - } - - private static void testEncodeDecodeRandom(GenericGF field, int dataSize, int ecSize) { - assertTrue("Invalid data size for " + field, dataSize > 0 && dataSize <= field.getSize() - 3); - assertTrue("Invalid ECC size for " + field, ecSize > 0 && ecSize + dataSize <= field.getSize()); - ReedSolomonEncoder encoder = new ReedSolomonEncoder(field); - int[] message = new int[dataSize + ecSize]; - int[] dataWords = new int[dataSize]; - int[] ecWords = new int[ecSize]; - Random random = getPseudoRandom(); - int iterations = field.getSize() > 256 ? 1 : DECODER_RANDOM_TEST_ITERATIONS; - for (int i = 0; i < iterations; i++) { - // generate random data - for (int k = 0; k < dataSize; k++) { - dataWords[k] = random.nextInt(field.getSize()); - } - // generate ECC words - System.arraycopy(dataWords, 0, message, 0, dataWords.length); - encoder.encode(message, ecWords.length); - System.arraycopy(message, dataSize, ecWords, 0, ecSize); - // check to see if Decoder can fix up to ecWords/2 random errors - testDecoder(field, dataWords, ecWords); - } - } - - private static void testEncodeDecode(GenericGF field, int[] dataWords, int[] ecWords) { - testEncoder(field, dataWords, ecWords); - testDecoder(field, dataWords, ecWords); - } - - private static void testEncoder(GenericGF field, int[] dataWords, int[] ecWords) { - ReedSolomonEncoder encoder = new ReedSolomonEncoder(field); - int[] messageExpected = new int[dataWords.length + ecWords.length]; - int[] message = new int[dataWords.length + ecWords.length]; - System.arraycopy(dataWords, 0, messageExpected, 0, dataWords.length); - System.arraycopy(ecWords, 0, messageExpected, dataWords.length, ecWords.length); - System.arraycopy(dataWords, 0, message, 0, dataWords.length); - encoder.encode(message, ecWords.length); - assertDataEquals("Encode in " + field + " (" + dataWords.length + ',' + ecWords.length + ") failed", - messageExpected, message); - } - - private static void testDecoder(GenericGF field, int[] dataWords, int[] ecWords) { - ReedSolomonDecoder decoder = new ReedSolomonDecoder(field); - int[] message = new int[dataWords.length + ecWords.length]; - int maxErrors = ecWords.length / 2; - Random random = getPseudoRandom(); - int iterations = field.getSize() > 256 ? 1 : DECODER_TEST_ITERATIONS; - for (int j = 0; j < iterations; j++) { - for (int i = 0; i < ecWords.length; i++) { - if (i > 10 && i < ecWords.length / 2 - 10) { - // performance improvement - skip intermediate cases in long-running tests - i += ecWords.length / 10; - } - System.arraycopy(dataWords, 0, message, 0, dataWords.length); - System.arraycopy(ecWords, 0, message, dataWords.length, ecWords.length); - corrupt(message, i, random, field.getSize()); - try { - decoder.decode(message, ecWords.length); - } catch (ReedSolomonException e) { - // fail only if maxErrors exceeded - assertTrue("Decode in " + field + " (" + dataWords.length + ',' + ecWords.length + ") failed at " + - i + " errors: " + e, - i > maxErrors); - // else stop - break; - } - if (i < maxErrors) { - assertDataEquals("Decode in " + field + " (" + dataWords.length + ',' + ecWords.length + ") failed at " + - i + " errors", - dataWords, - message); - } - } - } - } - - private static void assertDataEquals(String message, int[] expected, int[] received) { - for (int i = 0; i < expected.length; i++) { - if (expected[i] != received[i]) { - fail(message + ". Mismatch at " + i + ". Expected " + arrayToString(expected) + ", got " + - arrayToString(Arrays.copyOf(received, expected.length))); - } - } - } - - private static String arrayToString(int[] data) { - StringBuilder sb = new StringBuilder("{"); - for (int i = 0; i < data.length; i++) { - sb.append(String.format(i > 0 ? ",%X" : "%X", data[i])); - } - return sb.append('}').toString(); - } - - private static Random getPseudoRandom() { - return new Random(0xDEADBEEF); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/datamatrix/DataMatrixBlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/datamatrix/DataMatrixBlackBox1TestCase.java deleted file mode 100644 index 540cc50..0000000 --- a/port_src/core/src/test/java/com/google/zxing/datamatrix/DataMatrixBlackBox1TestCase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author bbrown@google.com (Brian Brown) - */ -public final class DataMatrixBlackBox1TestCase extends AbstractBlackBoxTestCase { - - public DataMatrixBlackBox1TestCase() { - super("src/test/resources/blackbox/datamatrix-1", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX); - addTest(21, 21, 0.0f); - addTest(21, 21, 90.0f); - addTest(21, 21, 180.0f); - addTest(21, 21, 270.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/datamatrix/DataMatrixBlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/datamatrix/DataMatrixBlackBox2TestCase.java deleted file mode 100644 index 2e38314..0000000 --- a/port_src/core/src/test/java/com/google/zxing/datamatrix/DataMatrixBlackBox2TestCase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class DataMatrixBlackBox2TestCase extends AbstractBlackBoxTestCase { - - public DataMatrixBlackBox2TestCase() { - super("src/test/resources/blackbox/datamatrix-2", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX); - addTest(13, 13, 0, 1, 0.0f); - addTest(15, 15, 0, 1, 90.0f); - addTest(17, 16, 0, 1, 180.0f); - addTest(15, 15, 0, 1, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/datamatrix/DataMatrixBlackBox3TestCase.java b/port_src/core/src/test/java/com/google/zxing/datamatrix/DataMatrixBlackBox3TestCase.java deleted file mode 100644 index 2796426..0000000 --- a/port_src/core/src/test/java/com/google/zxing/datamatrix/DataMatrixBlackBox3TestCase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author gitlost - */ -public final class DataMatrixBlackBox3TestCase extends AbstractBlackBoxTestCase { - - public DataMatrixBlackBox3TestCase() { - super("src/test/resources/blackbox/datamatrix-3", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX); - addTest(18, 18, 0.0f); - addTest(17, 17, 90.0f); - addTest(18, 18, 180.0f); - addTest(18, 18, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/datamatrix/DataMatrixWriterTestCase.java b/port_src/core/src/test/java/com/google/zxing/datamatrix/DataMatrixWriterTestCase.java deleted file mode 100644 index 91be446..0000000 --- a/port_src/core/src/test/java/com/google/zxing/datamatrix/DataMatrixWriterTestCase.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.datamatrix.encoder.SymbolShapeHint; -import org.junit.Assert; -import org.junit.Test; - -import java.util.EnumMap; -import java.util.Map; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author dswitkin@google.com (Daniel Switkin) - ported and expanded from C++ - */ -public final class DataMatrixWriterTestCase extends Assert { - - @Test - public void testDataMatrixImageWriter() { - - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE); - - int bigEnough = 64; - DataMatrixWriter writer = new DataMatrixWriter(); - BitMatrix matrix = writer.encode("Hello Google", BarcodeFormat.DATA_MATRIX, bigEnough, bigEnough, hints); - assertNotNull(matrix); - assertTrue(bigEnough >= matrix.getWidth()); - assertTrue(bigEnough >= matrix.getHeight()); - } - - @Test - public void testDataMatrixWriter() { - - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE); - - int bigEnough = 14; - DataMatrixWriter writer = new DataMatrixWriter(); - BitMatrix matrix = writer.encode("Hello Me", BarcodeFormat.DATA_MATRIX, bigEnough, bigEnough, hints); - assertNotNull(matrix); - assertEquals(bigEnough, matrix.getWidth()); - assertEquals(bigEnough, matrix.getHeight()); - } - - @Test - public void testDataMatrixTooSmall() { - // The DataMatrix will not fit in this size, so the matrix should come back bigger - int tooSmall = 8; - DataMatrixWriter writer = new DataMatrixWriter(); - BitMatrix matrix = writer.encode("http://www.google.com/", BarcodeFormat.DATA_MATRIX, tooSmall, tooSmall, null); - assertNotNull(matrix); - assertTrue(tooSmall < matrix.getWidth()); - assertTrue(tooSmall < matrix.getHeight()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/datamatrix/decoder/DecodedBitStreamParserTestCase.java b/port_src/core/src/test/java/com/google/zxing/datamatrix/decoder/DecodedBitStreamParserTestCase.java deleted file mode 100644 index a0bbc58..0000000 --- a/port_src/core/src/test/java/com/google/zxing/datamatrix/decoder/DecodedBitStreamParserTestCase.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.decoder; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author bbrown@google.com (Brian Brown) - */ -public final class DecodedBitStreamParserTestCase extends Assert { - - @Test - public void testAsciiStandardDecode() throws Exception { - // ASCII characters 0-127 are encoded as the value + 1 - byte[] bytes = {(byte) ('a' + 1), (byte) ('b' + 1), (byte) ('c' + 1), - (byte) ('A' + 1), (byte) ('B' + 1), (byte) ('C' + 1)}; - String decodedString = DecodedBitStreamParser.decode(bytes).getText(); - assertEquals("abcABC", decodedString); - } - - @Test - public void testAsciiDoubleDigitDecode() throws Exception { - // ASCII double digit (00 - 99) Numeric Value + 130 - byte[] bytes = {(byte) 130 , (byte) (1 + 130), - (byte) (98 + 130), (byte) (99 + 130)}; - String decodedString = DecodedBitStreamParser.decode(bytes).getText(); - assertEquals("00019899", decodedString); - } - - // TODO(bbrown): Add test cases for each encoding type - // TODO(bbrown): Add test cases for switching encoding types -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/DebugPlacement.java b/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/DebugPlacement.java deleted file mode 100644 index 60aed9c..0000000 --- a/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/DebugPlacement.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2006 Jeremias Maerki - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -final class DebugPlacement extends DefaultPlacement { - - DebugPlacement(String codewords, int numcols, int numrows) { - super(codewords, numcols, numrows); - } - - String[] toBitFieldStringArray() { - byte[] bits = getBits(); - int numrows = getNumrows(); - int numcols = getNumcols(); - String[] array = new String[numrows]; - int startpos = 0; - for (int row = 0; row < numrows; row++) { - StringBuilder sb = new StringBuilder(bits.length); - for (int i = 0; i < numcols; i++) { - sb.append(bits[startpos + i] == 1 ? '1' : '0'); - } - array[row] = sb.toString(); - startpos += numcols; - } - return array; - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/ErrorCorrectionTestCase.java b/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/ErrorCorrectionTestCase.java deleted file mode 100644 index 405427e..0000000 --- a/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/ErrorCorrectionTestCase.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2006 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests for the ECC200 error correction. - */ -public final class ErrorCorrectionTestCase extends Assert { - - @Test - public void testRS() { - //Sample from Annexe R in ISO/IEC 16022:2000(E) - char[] cw = {142, 164, 186}; - SymbolInfo symbolInfo = SymbolInfo.lookup(3); - CharSequence s = ErrorCorrection.encodeECC200(String.valueOf(cw), symbolInfo); - assertEquals("142 164 186 114 25 5 88 102", HighLevelEncodeTestCase.visualize(s)); - - //"A" encoded (ASCII encoding + 2 padding characters) - cw = new char[]{66, 129, 70}; - s = ErrorCorrection.encodeECC200(String.valueOf(cw), symbolInfo); - assertEquals("66 129 70 138 234 82 82 95", HighLevelEncodeTestCase.visualize(s)); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/HighLevelEncodeTestCase.java b/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/HighLevelEncodeTestCase.java deleted file mode 100644 index 4388659..0000000 --- a/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/HighLevelEncodeTestCase.java +++ /dev/null @@ -1,563 +0,0 @@ -/* - * Copyright 2006 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -import junit.framework.ComparisonFailure; -import org.junit.Assert; -import org.junit.Test; -import java.nio.charset.StandardCharsets; - -/** - * Tests for {@link HighLevelEncoder} and {@link MinimalEncoder} - */ -public final class HighLevelEncodeTestCase extends Assert { - - private static final SymbolInfo[] TEST_SYMBOLS = { - new SymbolInfo(false, 3, 5, 8, 8, 1), - new SymbolInfo(false, 5, 7, 10, 10, 1), - /*rect*/new SymbolInfo(true, 5, 7, 16, 6, 1), - new SymbolInfo(false, 8, 10, 12, 12, 1), - /*rect*/new SymbolInfo(true, 10, 11, 14, 6, 2), - new SymbolInfo(false, 13, 0, 0, 0, 1), - new SymbolInfo(false, 77, 0, 0, 0, 1) - //The last entries are fake entries to test special conditions with C40 encoding - }; - - private static void useTestSymbols() { - SymbolInfo.overrideSymbolSet(TEST_SYMBOLS); - } - - private static void resetSymbols() { - SymbolInfo.overrideSymbolSet(SymbolInfo.PROD_SYMBOLS); - } - - @Test - public void testASCIIEncodation() { - - String visualized = encodeHighLevel("123456"); - assertEquals("142 164 186", visualized); - - visualized = encodeHighLevel("123456£"); - assertEquals("142 164 186 235 36", visualized); - - visualized = encodeHighLevel("30Q324343430794 - //"else" case - - visualized = encodeHighLevel("AIMAIMAIMë"); - assertEquals("230 91 11 91 11 91 11 254 235 108", visualized); //Activate when additional rectangulars are available - //Expl: 230 = shift to C40, "91 11" = "AIM", - //"�" in C40 encodes to: 1 30 2 11 which doesn't fit into a triplet - //"10 243" = - //254 = unlatch, 235 = Upper Shift, 108 = � = 0xEB/235 - 128 + 1 - //"else" case - } - - @Test - public void testC40EncodationSpecExample() { - //Example in Figure 1 in the spec - String visualized = encodeHighLevel("A1B2C3D4E5F6G7H8I9J0K1L2"); - assertEquals("230 88 88 40 8 107 147 59 67 126 206 78 126 144 121 35 47 254", visualized); - } - - @Test - public void testC40EncodationSpecialCases1() { - - //Special tests avoiding ultra-long test strings because these tests are only used - //with the 16x48 symbol (47 data codewords) - useTestSymbols(); - - String visualized = encodeHighLevel("AIMAIMAIMAIMAIMAIM", false); - assertEquals("230 91 11 91 11 91 11 91 11 91 11 91 11", visualized); - //case "a": Unlatch is not required - - visualized = encodeHighLevel("AIMAIMAIMAIMAIMAI", false); - assertEquals("230 91 11 91 11 91 11 91 11 91 11 90 241", visualized); - //case "b": Add trailing shift 0 and Unlatch is not required - - visualized = encodeHighLevel("AIMAIMAIMAIMAIMA"); - assertEquals("230 91 11 91 11 91 11 91 11 91 11 254 66", visualized); - //case "c": Unlatch and write last character in ASCII - - resetSymbols(); - - visualized = encodeHighLevel("AIMAIMAIMAIMAIMAI"); - assertEquals("230 91 11 91 11 91 11 91 11 91 11 254 66 74 129 237", visualized); - - visualized = encodeHighLevel("AIMAIMAIMA"); - assertEquals("230 91 11 91 11 91 11 66", visualized); - //case "d": Skip Unlatch and write last character in ASCII - } - - @Test - public void testC40EncodationSpecialCases2() { - - String visualized = encodeHighLevel("AIMAIMAIMAIMAIMAIMAI"); - assertEquals("230 91 11 91 11 91 11 91 11 91 11 91 11 254 66 74", visualized); - //available > 2, rest = 2 --> unlatch and encode as ASCII - } - - @Test - public void testTextEncodation() { - - String visualized = encodeHighLevel("aimaimaim"); - assertEquals("239 91 11 91 11 91 11 254", visualized); - //239 shifts to Text encodation, 254 unlatches - - visualized = encodeHighLevel("aimaimaim'"); - assertEquals("239 91 11 91 11 91 11 254 40 129", visualized); - //assertEquals("239 91 11 91 11 91 11 7 49 254", visualized); - //This is an alternative, but doesn't strictly follow the rules in the spec. - - visualized = encodeHighLevel("aimaimaIm"); - assertEquals("239 91 11 91 11 87 218 110", visualized); - - visualized = encodeHighLevel("aimaimaimB"); - assertEquals("239 91 11 91 11 91 11 254 67 129", visualized); - - visualized = encodeHighLevel("aimaimaim{txt}\u0004"); - assertEquals("239 91 11 91 11 91 11 254 124 117 121 117 126 5 129 237", visualized); - } - - @Test - public void testX12Encodation() { - - //238 shifts to X12 encodation, 254 unlatches - - String visualized = encodeHighLevel("ABC>ABC123>AB"); - assertEquals("238 89 233 14 192 100 207 44 31 67", visualized); - - visualized = encodeHighLevel("ABC>ABC123>ABC"); - assertEquals("238 89 233 14 192 100 207 44 31 254 67 68", visualized); - - visualized = encodeHighLevel("ABC>ABC123>ABCD"); - assertEquals("238 89 233 14 192 100 207 44 31 96 82 254", visualized); - - visualized = encodeHighLevel("ABC>ABC123>ABCDE"); - assertEquals("238 89 233 14 192 100 207 44 31 96 82 70", visualized); - - visualized = encodeHighLevel("ABC>ABC123>ABCDEF"); - assertEquals("238 89 233 14 192 100 207 44 31 96 82 254 70 71 129 237", visualized); - - } - - @Test - public void testEDIFACTEncodation() { - - //240 shifts to EDIFACT encodation - - String visualized = encodeHighLevel(".A.C1.3.DATA.123DATA.123DATA"); - assertEquals("240 184 27 131 198 236 238 16 21 1 187 28 179 16 21 1 187 28 179 16 21 1", - visualized); - - visualized = encodeHighLevel(".A.C1.3.X.X2.."); - assertEquals("240 184 27 131 198 236 238 98 230 50 47 47", visualized); - - visualized = encodeHighLevel(".A.C1.3.X.X2."); - assertEquals("240 184 27 131 198 236 238 98 230 50 47 129", visualized); - - visualized = encodeHighLevel(".A.C1.3.X.X2"); - assertEquals("240 184 27 131 198 236 238 98 230 50", visualized); - - visualized = encodeHighLevel(".A.C1.3.X.X"); - assertEquals("240 184 27 131 198 236 238 98 230 31", visualized); - - visualized = encodeHighLevel(".A.C1.3.X."); - assertEquals("240 184 27 131 198 236 238 98 231 192", visualized); - - visualized = encodeHighLevel(".A.C1.3.X"); - assertEquals("240 184 27 131 198 236 238 89", visualized); - - //Checking temporary unlatch from EDIFACT - visualized = encodeHighLevel(".XXX.XXX.XXX.XXX.XXX.XXX.üXX.XXX.XXX.XXX.XXX.XXX.XXX"); - assertEquals("240 185 134 24 185 134 24 185 134 24 185 134 24 185 134 24 185 134 24" - + " 124 47 235 125 240" //<-- this is the temporary unlatch - + " 97 139 152 97 139 152 97 139 152 97 139 152 97 139 152 97 139 152 89 89", - visualized); - } - - @Test - public void testBase256Encodation() { - - //231 shifts to Base256 encodation - - String visualized = encodeHighLevel("\u00ABäöüé\u00BB"); - assertEquals("231 44 108 59 226 126 1 104", visualized); - visualized = encodeHighLevel("\u00ABäöüéà\u00BB"); - assertEquals("231 51 108 59 226 126 1 141 254 129", visualized); - visualized = encodeHighLevel("\u00ABäöüéàá\u00BB"); - assertEquals("231 44 108 59 226 126 1 141 36 147", visualized); - - visualized = encodeHighLevel(" 23£"); //ASCII only (for reference) - assertEquals("33 153 235 36 129", visualized); - - visualized = encodeHighLevel("\u00ABäöüé\u00BB 234"); //Mixed Base256 + ASCII - assertEquals("231 50 108 59 226 126 1 104 33 153 53 129", visualized); - - visualized = encodeHighLevel("\u00ABäöüé\u00BB 23£ 1234567890123456789"); - assertEquals("231 54 108 59 226 126 1 104 99 10 161 167 33 142 164 186 208" - + " 220 142 164 186 208 58 129 59 209 104 254 150 45", visualized); - - visualized = encodeHighLevel(createBinaryMessage(20)); - assertEquals("231 44 108 59 226 126 1 141 36 5 37 187 80 230 123 17 166 60 210 103 253 150", - visualized); - visualized = encodeHighLevel(createBinaryMessage(19)); //padding necessary at the end - assertEquals("231 63 108 59 226 126 1 141 36 5 37 187 80 230 123 17 166 60 210 103 1 129", - visualized); - - visualized = encodeHighLevel(createBinaryMessage(276)); - assertStartsWith("231 38 219 2 208 120 20 150 35", visualized); - assertEndsWith("146 40 194 129", visualized); - - visualized = encodeHighLevel(createBinaryMessage(277)); - assertStartsWith("231 38 220 2 208 120 20 150 35", visualized); - assertEndsWith("146 40 190 87", visualized); - } - - private static String createBinaryMessage(int len) { - StringBuilder sb = new StringBuilder(); - sb.append("\u00ABäöüéàá-"); - for (int i = 0; i < len - 9; i++) { - sb.append('\u00B7'); - } - sb.append('\u00BB'); - return sb.toString(); - } - - private static void assertStartsWith(String expected, String actual) { - if (!actual.startsWith(expected)) { - throw new ComparisonFailure(null, expected, actual.substring(0, expected.length())); - } - } - - private static void assertEndsWith(String expected, String actual) { - if (!actual.endsWith(expected)) { - throw new ComparisonFailure(null, expected, actual.substring(actual.length() - expected.length())); - } - } - - @Test - public void testUnlatchingFromC40() { - - String visualized = encodeHighLevel("AIMAIMAIMAIMaimaimaim"); - assertEquals("230 91 11 91 11 91 11 254 66 74 78 239 91 11 91 11 91 11", visualized); - } - - @Test - public void testUnlatchingFromText() { - - String visualized = encodeHighLevel("aimaimaimaim12345678"); - assertEquals("239 91 11 91 11 91 11 91 11 254 142 164 186 208 129 237", visualized); - } - - @Test - public void testHelloWorld() { - - String visualized = encodeHighLevel("Hello World!"); - assertEquals("73 239 116 130 175 123 148 64 158 233 254 34", visualized); - } - - @Test - public void testBug1664266() { - //There was an exception and the encoder did not handle the unlatching from - //EDIFACT encoding correctly - - String visualized = encodeHighLevel("CREX-TAN:h"); - assertEquals("68 83 70 89 46 85 66 79 59 105", visualized); - - visualized = encodeHighLevel("CREX-TAN:hh"); - assertEquals("68 83 70 89 46 85 66 79 59 105 105 129", visualized); - - visualized = encodeHighLevel("CREX-TAN:hhh"); - assertEquals("68 83 70 89 46 85 66 79 59 105 105 105", visualized); - } - - @Test - public void testX12Unlatch() { - String visualized = encodeHighLevel("*DTCP01"); - assertEquals("43 69 85 68 81 131 129 56", visualized); - } - - @Test - public void testX12Unlatch2() { - String visualized = encodeHighLevel("*DTCP0"); - assertEquals("238 9 10 104 141", visualized); - } - - @Test - public void testBug3048549() { - //There was an IllegalArgumentException for an illegal character here because - //of an encoding problem of the character 0x0060 in Java source code. - - String visualized = encodeHighLevel("fiykmj*Rh2`,e6"); - assertEquals("103 106 122 108 110 107 43 83 105 51 97 45 102 55 129 237", visualized); - - } - - @Test - public void testMacroCharacters() { - - String visualized = encodeHighLevel("[)>\u001E05\u001D5555\u001C6666\u001E\u0004"); - //assertEquals("92 42 63 31 135 30 185 185 29 196 196 31 5 129 87 237", visualized); - assertEquals("236 185 185 29 196 196 129 56", visualized); - } - - @Test - public void testEncodingWithStartAsX12AndLatchToEDIFACTInTheMiddle() { - - String visualized = encodeHighLevel("*MEMANT-1F-MESTECH"); - assertEquals("240 168 209 77 4 229 45 196 107 77 21 53 5 12 135 192", visualized); - } - - @Test - public void testX12AndEDIFACTSpecErrors() { - //X12 encoding error with spec conform float point comparisons in lookAheadTest() - String visualized = encodeHighLevel("AAAAAAAAAAA**\u00FCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - assertEquals("230 89 191 89 191 89 191 89 178 56 114 10 243 177 63 89 191 89 191 89 191 89 191 89 191 89 191 89 " + - "191 89 191 89 191 254 66 129", visualized); - //X12 encoding error with integer comparisons in lookAheadTest() - visualized = encodeHighLevel("AAAAAAAAAAAA0+****AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - assertEquals("238 89 191 89 191 89 191 89 191 254 240 194 186 170 170 160 65 4 16 65 4 16 65 4 16 65 4 16 65 4 " + - "16 65 4 16 65 4 16 65 124 129 167 62 212 107", visualized); - //EDIFACT encoding error with spec conform float point comparisons in lookAheadTest() - visualized = encodeHighLevel("AAAAAAAAAAA++++\u00FCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - assertEquals("230 89 191 89 191 89 191 254 66 66 44 44 44 44 235 125 230 89 191 89 191 89 191 89 191 89 191 89 " + - "191 89 191 89 191 89 191 89 191 254 129 17 167 62 212 107", visualized); - //EDIFACT encoding error with integer comparisons in lookAheadTest() - visualized = encodeHighLevel("++++++++++AAa0 0++++++++++++++++++++++++++++++"); - assertEquals("240 174 186 235 174 186 235 174 176 65 124 98 240 194 12 43 174 186 235 174 186 235 174 186 235 " + - "174 186 235 174 186 235 174 186 235 174 186 235 173 240 129 167 62 212 107", visualized); - visualized = encodeHighLevel("AAAAAAAAAAAA*+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - assertEquals("230 89 191 89 191 89 191 89 191 7 170 64 191 89 191 89 191 89 191 89 191 89 191 89 191 89 191 89 " + - "191 89 191 66", visualized); - visualized = encodeHighLevel("AAAAAAAAAAA*0a0 *AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - assertEquals("230 89 191 89 191 89 191 89 178 56 227 6 228 7 183 89 191 89 191 89 191 89 191 89 191 89 191 89 " + - "191 89 191 89 191 254 66 66", visualized); - - } - @Test - public void testSizes() { - int[] sizes = new int[2]; - encodeHighLevel("A", sizes); - assertEquals(3, sizes[0]); - assertEquals(3, sizes[1]); - - encodeHighLevel("AB", sizes); - assertEquals(3, sizes[0]); - assertEquals(3, sizes[1]); - - encodeHighLevel("ABC", sizes); - assertEquals(3, sizes[0]); - assertEquals(3, sizes[1]); - - encodeHighLevel("ABCD", sizes); - assertEquals(5, sizes[0]); - assertEquals(5, sizes[1]); - - encodeHighLevel("ABCDE", sizes); - assertEquals(5, sizes[0]); - assertEquals(5, sizes[1]); - - encodeHighLevel("ABCDEF", sizes); - assertEquals(5, sizes[0]); - assertEquals(5, sizes[1]); - - encodeHighLevel("ABCDEFG", sizes); - assertEquals(8, sizes[0]); - assertEquals(8, sizes[1]); - - encodeHighLevel("ABCDEFGH", sizes); - assertEquals(8, sizes[0]); - assertEquals(8, sizes[1]); - - encodeHighLevel("ABCDEFGHI", sizes); - assertEquals(8, sizes[0]); - assertEquals(8, sizes[1]); - - encodeHighLevel("ABCDEFGHIJ", sizes); - assertEquals(8, sizes[0]); - assertEquals(8, sizes[1]); - - encodeHighLevel("a", sizes); - assertEquals(3, sizes[0]); - assertEquals(3, sizes[1]); - - encodeHighLevel("ab", sizes); - assertEquals(3, sizes[0]); - assertEquals(3, sizes[1]); - - encodeHighLevel("abc", sizes); - assertEquals(3, sizes[0]); - assertEquals(3, sizes[1]); - - encodeHighLevel("abcd", sizes); - assertEquals(5, sizes[0]); - assertEquals(5, sizes[1]); - - encodeHighLevel("abcdef", sizes); - assertEquals(5, sizes[0]); - assertEquals(5, sizes[1]); - - encodeHighLevel("abcdefg", sizes); - assertEquals(8, sizes[0]); - assertEquals(8, sizes[1]); - - encodeHighLevel("abcdefgh", sizes); - assertEquals(8, sizes[0]); - assertEquals(8, sizes[1]); - - encodeHighLevel("+", sizes); - assertEquals(3, sizes[0]); - assertEquals(3, sizes[1]); - - encodeHighLevel("++", sizes); - assertEquals(3, sizes[0]); - assertEquals(3, sizes[1]); - - encodeHighLevel("+++", sizes); - assertEquals(3, sizes[0]); - assertEquals(3, sizes[1]); - - encodeHighLevel("++++", sizes); - assertEquals(5, sizes[0]); - assertEquals(5, sizes[1]); - - encodeHighLevel("+++++", sizes); - assertEquals(5, sizes[0]); - assertEquals(5, sizes[1]); - - encodeHighLevel("++++++", sizes); - assertEquals(8, sizes[0]); - assertEquals(8, sizes[1]); - - encodeHighLevel("+++++++", sizes); - assertEquals(8, sizes[0]); - assertEquals(8, sizes[1]); - - encodeHighLevel("++++++++", sizes); - assertEquals(8, sizes[0]); - assertEquals(8, sizes[1]); - - encodeHighLevel("+++++++++", sizes); - assertEquals(8, sizes[0]); - assertEquals(8, sizes[1]); - - encodeHighLevel("\u00F0\u00F0" + - "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", sizes); - assertEquals(114, sizes[0]); - assertEquals(62, sizes[1]); - } - - @Test - public void testECIs() { - - String visualized = visualize(MinimalEncoder.encodeHighLevel("that particularly stands out to me is \u0625\u0650" + - "\u062C\u064E\u0651\u0627\u0635 (\u02BE\u0101\u1E63) \"pear\", suggested to have originated from Hebrew " + - "\u05D0\u05B7\u05D2\u05B8\u05BC\u05E1 (ag\u00E1s)")); - assertEquals("239 209 151 206 214 92 122 140 35 158 144 162 52 205 55 171 137 23 67 206 218 175 147 113 15 254" + - " 116 33 241 25 231 186 14 212 64 253 151 252 159 33 41 241 27 231 83 171 53 209 35 25 134 6 42 33 35 239 184" + - " 31 193 234 7 252 205 101 127 241 209 34 24 5 22 23 221 148 179 239 128 140 92 187 106 204 198 59 19 25 114" + - " 248 118 36 254 231 106 196 19 239 101 27 107 69 189 112 236 156 252 16 174 125 24 10 125 116 42 129", - visualized); - - visualized = visualize(MinimalEncoder.encodeHighLevel("that particularly stands out to me is \u0625\u0650" + - "\u062C\u064E\u0651\u0627\u0635 (\u02BE\u0101\u1E63) \"pear\", suggested to have originated from Hebrew " + - "\u05D0\u05B7\u05D2\u05B8\u05BC\u05E1 (ag\u00E1s)", StandardCharsets.UTF_8, -1 , SymbolShapeHint.FORCE_NONE)); - assertEquals("241 27 239 209 151 206 214 92 122 140 35 158 144 162 52 205 55 171 137 23 67 206 218 175 147 113" + - " 15 254 116 33 231 202 33 131 77 154 119 225 163 238 206 28 249 93 36 150 151 53 108 246 145 228 217 71" + - " 199 42 33 35 239 184 31 193 234 7 252 205 101 127 241 209 34 24 5 22 23 221 148 179 239 128 140 92 187 106" + - " 204 198 59 19 25 114 248 118 36 254 231 43 133 212 175 38 220 44 6 125 49 172 93 189 209 111 61 217 203 62" + - " 116 42 129 1 151 46 196 91 241 137 32 182 77 227 122 18 168 63 213 108 4 154 49 199 94 244 140 35 185 80", - visualized); - } - - @Test - public void testPadding() { - int[] sizes = new int[2]; - encodeHighLevel("IS010000000000000000000000S1118058599124123S21.2.250.1.213.1.4.8 S3FIRST NAMETEST S5MS618-06" + - "-1985S713201S4LASTNAMETEST", sizes); - assertEquals(86, sizes[0]); - assertEquals(86, sizes[1]); - } - - - private static void encodeHighLevel(String msg, int[] sizes) { - sizes[0] = HighLevelEncoder.encodeHighLevel(msg).length(); - sizes[1] = MinimalEncoder.encodeHighLevel(msg).length(); - } - - private static String encodeHighLevel(String msg) { - return encodeHighLevel(msg, true); - } - - private static String encodeHighLevel(String msg, boolean compareSizeToMinimalEncoder) { - CharSequence encoded = HighLevelEncoder.encodeHighLevel(msg); - CharSequence encoded2 = MinimalEncoder.encodeHighLevel(msg); - assertTrue(!compareSizeToMinimalEncoder || encoded2.length() <= encoded.length()); - return visualize(encoded); - } - - /** - * Convert a string of char codewords into a different string which lists each character - * using its decimal value. - * - * @param codewords the codewords - * @return the visualized codewords - */ - static String visualize(CharSequence codewords) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < codewords.length(); i++) { - if (i > 0) { - sb.append(' '); - } - sb.append((int) codewords.charAt(i)); - } - return sb.toString(); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/PlacementTestCase.java b/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/PlacementTestCase.java deleted file mode 100644 index 16fd0e5..0000000 --- a/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/PlacementTestCase.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2006 Jeremias Maerki - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.regex.Pattern; - -/** - * Tests the DataMatrix placement algorithm. - */ -public final class PlacementTestCase extends Assert { - - private static final Pattern SPACE = Pattern.compile(" "); - - @Test - public void testPlacement() { - String codewords = unvisualize("66 74 78 66 74 78 129 56 35 102 192 96 226 100 156 1 107 221"); //"AIMAIM" encoded - DebugPlacement placement = new DebugPlacement(codewords, 12, 12); - placement.place(); - String[] expected = { - "011100001111", - "001010101000", - "010001010100", - "001010100010", - "000111000100", - "011000010100", - "000100001101", - "011000010000", - "001100001101", - "100010010111", - "011101011010", - "001011001010"}; - String[] actual = placement.toBitFieldStringArray(); - for (int i = 0; i < actual.length; i++) { - assertEquals("Row " + i, expected[i], actual[i]); - } - } - - private static String unvisualize(CharSequence visualized) { - StringBuilder sb = new StringBuilder(); - for (String token : SPACE.split(visualized)) { - sb.append((char) Integer.parseInt(token)); - } - return sb.toString(); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/SymbolInfoTestCase.java b/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/SymbolInfoTestCase.java deleted file mode 100644 index 3a6c8bf..0000000 --- a/port_src/core/src/test/java/com/google/zxing/datamatrix/encoder/SymbolInfoTestCase.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2006 Jeremias Maerki - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.datamatrix.encoder; - -import com.google.zxing.Dimension; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests the SymbolInfo class. - */ -public final class SymbolInfoTestCase extends Assert { - - @Test - public void testSymbolInfo() { - SymbolInfo info = SymbolInfo.lookup(3); - assertEquals(5, info.getErrorCodewords()); - assertEquals(8, info.matrixWidth); - assertEquals(8, info.matrixHeight); - assertEquals(10, info.getSymbolWidth()); - assertEquals(10, info.getSymbolHeight()); - - info = SymbolInfo.lookup(3, SymbolShapeHint.FORCE_RECTANGLE); - assertEquals(7, info.getErrorCodewords()); - assertEquals(16, info.matrixWidth); - assertEquals(6, info.matrixHeight); - assertEquals(18, info.getSymbolWidth()); - assertEquals(8, info.getSymbolHeight()); - - info = SymbolInfo.lookup(9); - assertEquals(11, info.getErrorCodewords()); - assertEquals(14, info.matrixWidth); - assertEquals(6, info.matrixHeight); - assertEquals(32, info.getSymbolWidth()); - assertEquals(8, info.getSymbolHeight()); - - info = SymbolInfo.lookup(9, SymbolShapeHint.FORCE_SQUARE); - assertEquals(12, info.getErrorCodewords()); - assertEquals(14, info.matrixWidth); - assertEquals(14, info.matrixHeight); - assertEquals(16, info.getSymbolWidth()); - assertEquals(16, info.getSymbolHeight()); - - try { - SymbolInfo.lookup(1559); - fail("There's no rectangular symbol for more than 1558 data codewords"); - } catch (IllegalArgumentException iae) { - //expected - } - try { - SymbolInfo.lookup(50, SymbolShapeHint.FORCE_RECTANGLE); - fail("There's no rectangular symbol for 50 data codewords"); - } catch (IllegalArgumentException iae) { - //expected - } - - info = SymbolInfo.lookup(35); - assertEquals(24, info.getSymbolWidth()); - assertEquals(24, info.getSymbolHeight()); - - Dimension fixedSize = new Dimension(26, 26); - info = SymbolInfo.lookup(35, - SymbolShapeHint.FORCE_NONE, fixedSize, fixedSize, false); - assertNotNull(info); - assertEquals(26, info.getSymbolWidth()); - assertEquals(26, info.getSymbolHeight()); - - info = SymbolInfo.lookup(45, - SymbolShapeHint.FORCE_NONE, fixedSize, fixedSize, false); - assertNull(info); - - Dimension minSize = fixedSize; - Dimension maxSize = new Dimension(32, 32); - - info = SymbolInfo.lookup(35, - SymbolShapeHint.FORCE_NONE, minSize, maxSize, false); - assertNotNull(info); - assertEquals(26, info.getSymbolWidth()); - assertEquals(26, info.getSymbolHeight()); - - info = SymbolInfo.lookup(40, - SymbolShapeHint.FORCE_NONE, minSize, maxSize, false); - assertNotNull(info); - assertEquals(26, info.getSymbolWidth()); - assertEquals(26, info.getSymbolHeight()); - - info = SymbolInfo.lookup(45, - SymbolShapeHint.FORCE_NONE, minSize, maxSize, false); - assertNotNull(info); - assertEquals(32, info.getSymbolWidth()); - assertEquals(32, info.getSymbolHeight()); - - info = SymbolInfo.lookup(63, - SymbolShapeHint.FORCE_NONE, minSize, maxSize, false); - assertNull(info); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/inverted/InvertedDataMatrixBlackBoxTestCase.java b/port_src/core/src/test/java/com/google/zxing/inverted/InvertedDataMatrixBlackBoxTestCase.java deleted file mode 100644 index c2c942e..0000000 --- a/port_src/core/src/test/java/com/google/zxing/inverted/InvertedDataMatrixBlackBoxTestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.inverted; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.DecodeHintType; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * Inverted barcodes - */ -public final class InvertedDataMatrixBlackBoxTestCase extends AbstractBlackBoxTestCase { - - public InvertedDataMatrixBlackBoxTestCase() { - super("src/test/resources/blackbox/inverted", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX); - addHint(DecodeHintType.ALSO_INVERTED); - addTest(1, 1, 0.0f); - addTest(1, 1, 90.0f); - addTest(1, 1, 180.0f); - addTest(1, 1, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/inverted/NoHintInvertedDataMatrixBlackBoxTestCase.java b/port_src/core/src/test/java/com/google/zxing/inverted/NoHintInvertedDataMatrixBlackBoxTestCase.java deleted file mode 100644 index ca3a6b2..0000000 --- a/port_src/core/src/test/java/com/google/zxing/inverted/NoHintInvertedDataMatrixBlackBoxTestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.inverted; - -import com.google.zxing.common.AbstractNegativeBlackBoxTestCase; - -/** - * Without hint inverted barcodes should not be found. - */ -public final class NoHintInvertedDataMatrixBlackBoxTestCase extends AbstractNegativeBlackBoxTestCase { - - public NoHintInvertedDataMatrixBlackBoxTestCase() { - super("src/test/resources/blackbox/inverted"); - addTest(0, 0.0f); - addTest(0, 90.0f); - addTest(0, 180.0f); - addTest(0, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/maxicode/MaxiCodeBlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/maxicode/MaxiCodeBlackBox1TestCase.java deleted file mode 100644 index e7e8fa8..0000000 --- a/port_src/core/src/test/java/com/google/zxing/maxicode/MaxiCodeBlackBox1TestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2022 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.maxicode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.DecodeHintType; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * Tests all characters in Set A. - * - * @author Daniel Gredler - * @see Defect 1543 - */ -public final class MaxiCodeBlackBox1TestCase extends AbstractBlackBoxTestCase { - - public MaxiCodeBlackBox1TestCase() { - super("src/test/resources/blackbox/maxicode-1", new MultiFormatReader(), BarcodeFormat.MAXICODE); - addHint(DecodeHintType.PURE_BARCODE); - addTest(1, 1, 0.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/maxicode/Maxicode1TestCase.java b/port_src/core/src/test/java/com/google/zxing/maxicode/Maxicode1TestCase.java deleted file mode 100644 index dde0f29..0000000 --- a/port_src/core/src/test/java/com/google/zxing/maxicode/Maxicode1TestCase.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2016 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.maxicode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * Tests {@link MaxiCodeReader} against a fixed set of test images. - */ -public final class Maxicode1TestCase extends AbstractBlackBoxTestCase { - - public Maxicode1TestCase() { - super("src/test/resources/blackbox/maxicode-1", new MultiFormatReader(), BarcodeFormat.MAXICODE); - addTest(6, 6, 0.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/multi/MultiTestCase.java b/port_src/core/src/test/java/com/google/zxing/multi/MultiTestCase.java deleted file mode 100644 index 58be12b..0000000 --- a/port_src/core/src/test/java/com/google/zxing/multi/MultiTestCase.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2016 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.multi; - -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.nio.file.Path; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.BufferedImageLuminanceSource; -import com.google.zxing.LuminanceSource; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.Result; -import com.google.zxing.common.AbstractBlackBoxTestCase; -import com.google.zxing.common.HybridBinarizer; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link MultipleBarcodeReader}. - */ -public final class MultiTestCase extends Assert { - - @Test - public void testMulti() throws Exception { - // Very basic test for now - Path testBase = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/multi-1"); - - Path testImage = testBase.resolve("1.png"); - BufferedImage image = ImageIO.read(testImage.toFile()); - LuminanceSource source = new BufferedImageLuminanceSource(image); - BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); - - MultipleBarcodeReader reader = new GenericMultipleBarcodeReader(new MultiFormatReader()); - Result[] results = reader.decodeMultiple(bitmap); - assertNotNull(results); - assertEquals(2, results.length); - - assertEquals("031415926531", results[0].getText()); - assertEquals(BarcodeFormat.UPC_A, results[0].getBarcodeFormat()); - - assertEquals("www.airtable.com/jobs", results[1].getText()); - assertEquals(BarcodeFormat.QR_CODE, results[1].getBarcodeFormat()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/multi/qrcode/MultiQRCodeTestCase.java b/port_src/core/src/test/java/com/google/zxing/multi/qrcode/MultiQRCodeTestCase.java deleted file mode 100644 index 711362f..0000000 --- a/port_src/core/src/test/java/com/google/zxing/multi/qrcode/MultiQRCodeTestCase.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2016 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.multi.qrcode; - -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.BufferedImageLuminanceSource; -import com.google.zxing.LuminanceSource; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.AbstractBlackBoxTestCase; -import com.google.zxing.common.HybridBinarizer; -import com.google.zxing.multi.MultipleBarcodeReader; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link QRCodeMultiReader}. - */ -public final class MultiQRCodeTestCase extends Assert { - - @Test - public void testMultiQRCodes() throws Exception { - // Very basic test for now - Path testBase = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/multi-qrcode-1"); - - Path testImage = testBase.resolve("1.png"); - BufferedImage image = ImageIO.read(testImage.toFile()); - LuminanceSource source = new BufferedImageLuminanceSource(image); - BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); - - MultipleBarcodeReader reader = new QRCodeMultiReader(); - Result[] results = reader.decodeMultiple(bitmap); - assertNotNull(results); - assertEquals(4, results.length); - - Collection barcodeContents = new HashSet<>(); - for (Result result : results) { - barcodeContents.add(result.getText()); - assertEquals(BarcodeFormat.QR_CODE, result.getBarcodeFormat()); - assertNotNull(result.getResultMetadata()); - } - Collection expectedContents = new HashSet<>(); - expectedContents.add("You earned the class a 5 MINUTE DANCE PARTY!! Awesome! Way to go! Let's boogie!"); - expectedContents.add("You earned the class 5 EXTRA MINUTES OF RECESS!! Fabulous!! Way to go!!"); - expectedContents.add( - "You get to SIT AT MRS. SIGMON'S DESK FOR A DAY!! Awesome!! Way to go!! Guess I better clean up! :)"); - expectedContents.add("You get to CREATE OUR JOURNAL PROMPT FOR THE DAY! Yay! Way to go! "); - assertEquals(expectedContents, barcodeContents); - } - - @Test - public void testProcessStructuredAppend() { - Result sa1 = new Result("SA1", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE); - Result sa2 = new Result("SA2", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE); - Result sa3 = new Result("SA3", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE); - sa1.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, 2); - sa1.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L"); - sa2.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, (1 << 4) + 2); - sa2.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L"); - sa3.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, (2 << 4) + 2); - sa3.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L"); - - Result nsa = new Result("NotSA", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE); - nsa.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L"); - - List inputs = Arrays.asList(sa3, sa1, nsa, sa2); - - List results = QRCodeMultiReader.processStructuredAppend(inputs); - assertNotNull(results); - assertEquals(2, results.size()); - - Collection barcodeContents = new HashSet<>(); - for (Result result : results) { - barcodeContents.add(result.getText()); - } - Collection expectedContents = new HashSet<>(); - expectedContents.add("SA1SA2SA3"); - expectedContents.add("NotSA"); - assertEquals(expectedContents, barcodeContents); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/negative/FalsePositives2BlackBoxTestCase.java b/port_src/core/src/test/java/com/google/zxing/negative/FalsePositives2BlackBoxTestCase.java deleted file mode 100644 index 27919da..0000000 --- a/port_src/core/src/test/java/com/google/zxing/negative/FalsePositives2BlackBoxTestCase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.negative; - -import com.google.zxing.common.AbstractNegativeBlackBoxTestCase; - -/** - * Additional random images with high contrast patterns which should not find any barcodes. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class FalsePositives2BlackBoxTestCase extends AbstractNegativeBlackBoxTestCase { - - public FalsePositives2BlackBoxTestCase() { - super("src/test/resources/blackbox/falsepositives-2"); - addTest(4, 0.0f); - addTest(4, 90.0f); - addTest(4, 180.0f); - addTest(4, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/negative/FalsePositivesBlackBoxTestCase.java b/port_src/core/src/test/java/com/google/zxing/negative/FalsePositivesBlackBoxTestCase.java deleted file mode 100644 index db31c31..0000000 --- a/port_src/core/src/test/java/com/google/zxing/negative/FalsePositivesBlackBoxTestCase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.negative; - -import com.google.zxing.common.AbstractNegativeBlackBoxTestCase; - -/** - * This test ensures that random images with high contrast patterns do not decode as barcodes. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class FalsePositivesBlackBoxTestCase extends AbstractNegativeBlackBoxTestCase { - - public FalsePositivesBlackBoxTestCase() { - super("src/test/resources/blackbox/falsepositives"); - addTest(2, 0.0f); - addTest(2, 90.0f); - addTest(2, 180.0f); - addTest(2, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/negative/PartialBlackBoxTestCase.java b/port_src/core/src/test/java/com/google/zxing/negative/PartialBlackBoxTestCase.java deleted file mode 100644 index f38d29a..0000000 --- a/port_src/core/src/test/java/com/google/zxing/negative/PartialBlackBoxTestCase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.negative; - -import com.google.zxing.common.AbstractNegativeBlackBoxTestCase; - -/** - * This test ensures that partial barcodes do not decode. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class PartialBlackBoxTestCase extends AbstractNegativeBlackBoxTestCase { - - public PartialBlackBoxTestCase() { - super("src/test/resources/blackbox/partial"); - addTest(1, 0.0f); - addTest(1, 90.0f); - addTest(1, 180.0f); - addTest(1, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/negative/UnsupportedBlackBoxTestCase.java b/port_src/core/src/test/java/com/google/zxing/negative/UnsupportedBlackBoxTestCase.java deleted file mode 100644 index e09b875..0000000 --- a/port_src/core/src/test/java/com/google/zxing/negative/UnsupportedBlackBoxTestCase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.negative; - -import com.google.zxing.common.AbstractNegativeBlackBoxTestCase; - -/** - * This test ensures that unsupported barcodes do not decode. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class UnsupportedBlackBoxTestCase extends AbstractNegativeBlackBoxTestCase { - - public UnsupportedBlackBoxTestCase() { - super("src/test/resources/blackbox/unsupported"); - addTest(0, 0.0f); - addTest(0, 90.0f); - addTest(0, 180.0f); - addTest(0, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/CodaBarWriterTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/CodaBarWriterTestCase.java deleted file mode 100644 index 37e3049..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/CodaBarWriterTestCase.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.BitMatrixTestCase; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author dsbnatut@gmail.com (Kazuki Nishiura) - * @author Sean Owen - */ -public final class CodaBarWriterTestCase extends Assert { - - @Test - public void testEncode() { - doTest("B515-3/B", - "00000" + - "1001001011" + "0110101001" + "0101011001" + "0110101001" + "0101001101" + - "0110010101" + "01101101011" + "01001001011" + - "00000"); - } - - @Test - public void testEncode2() { - doTest("T123T", - "00000" + - "1011001001" + "0101011001" + "0101001011" + "0110010101" + "01011001001" + - "00000"); - } - - @Test - public void testAltStartEnd() { - assertEquals(encode("T123456789-$T"), encode("A123456789-$A")); - } - - private static void doTest(String input, CharSequence expected) { - BitMatrix result = encode(input); - assertEquals(expected, BitMatrixTestCase.matrixToString(result)); - } - - private static BitMatrix encode(String input) { - return new CodaBarWriter().encode(input, BarcodeFormat.CODABAR, 0, 0); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/CodabarBlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/CodabarBlackBox1TestCase.java deleted file mode 100644 index 62f3470..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/CodabarBlackBox1TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class CodabarBlackBox1TestCase extends AbstractBlackBoxTestCase { - - public CodabarBlackBox1TestCase() { - super("src/test/resources/blackbox/codabar-1", new MultiFormatReader(), BarcodeFormat.CODABAR); - addTest(11, 11, 0.0f); - addTest(11, 11, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/Code128BlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/Code128BlackBox1TestCase.java deleted file mode 100644 index 1a49f0e..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/Code128BlackBox1TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class Code128BlackBox1TestCase extends AbstractBlackBoxTestCase { - - public Code128BlackBox1TestCase() { - super("src/test/resources/blackbox/code128-1", new MultiFormatReader(), BarcodeFormat.CODE_128); - addTest(6, 6, 0.0f); - addTest(6, 6, 180.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/oned/Code128BlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/Code128BlackBox2TestCase.java deleted file mode 100644 index 3bffceb..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/Code128BlackBox2TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class Code128BlackBox2TestCase extends AbstractBlackBoxTestCase { - - public Code128BlackBox2TestCase() { - super("src/test/resources/blackbox/code128-2", new MultiFormatReader(), BarcodeFormat.CODE_128); - addTest(36, 39, 0.0f); - addTest(36, 39, 180.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/oned/Code128BlackBox3TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/Code128BlackBox3TestCase.java deleted file mode 100644 index fb2193d..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/Code128BlackBox3TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class Code128BlackBox3TestCase extends AbstractBlackBoxTestCase { - - public Code128BlackBox3TestCase() { - super("src/test/resources/blackbox/code128-3", new MultiFormatReader(), BarcodeFormat.CODE_128); - addTest(2, 2, 0.0f); - addTest(2, 2, 180.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java deleted file mode 100644 index c2a5b04..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Copyright 2014 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.common.BitMatrixTestCase; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.Result; -import com.google.zxing.Writer; -import com.google.zxing.common.BitArray; -import com.google.zxing.common.BitMatrix; - -import java.util.Map; -import java.util.EnumMap; - -/** - * Tests {@link Code128Writer}. - */ -public class Code128WriterTestCase extends Assert { - - private static final String FNC1 = "11110101110"; - private static final String FNC2 = "11110101000"; - private static final String FNC3 = "10111100010"; - private static final String FNC4A = "11101011110"; - private static final String FNC4B = "10111101110"; - private static final String START_CODE_A = "11010000100"; - private static final String START_CODE_B = "11010010000"; - private static final String START_CODE_C = "11010011100"; - private static final String SWITCH_CODE_A = "11101011110"; - private static final String SWITCH_CODE_B = "10111101110"; - private static final String QUIET_SPACE = "00000"; - private static final String STOP = "1100011101011"; - private static final String LF = "10000110010"; - - private Writer writer; - private Code128Reader reader; - - @Before - public void setUp() { - writer = new Code128Writer(); - reader = new Code128Reader(); - } - - @Test - public void testEncodeWithFunc3() throws Exception { - String toEncode = "\u00f3" + "123"; - String expected = QUIET_SPACE + START_CODE_B + FNC3 + - // "1" "2" "3" check digit 51 - "10011100110" + "11001110010" + "11001011100" + "11101000110" + STOP + QUIET_SPACE; - - BitMatrix result = encode(toEncode, false, "123"); - - String actual = BitMatrixTestCase.matrixToString(result); - assertEquals(expected, actual); - - int width = result.getWidth(); - result = encode(toEncode, true, "123"); - - assertEquals(width, result.getWidth()); - } - - @Test - public void testEncodeWithFunc2() throws Exception { - String toEncode = "\u00f2" + "123"; - String expected = QUIET_SPACE + START_CODE_B + FNC2 + - // "1" "2" "3" check digit 56 - "10011100110" + "11001110010" + "11001011100" + "11100010110" + STOP + QUIET_SPACE; - - BitMatrix result = encode(toEncode, false, "123"); - - String actual = BitMatrixTestCase.matrixToString(result); - assertEquals(expected, actual); - - int width = result.getWidth(); - result = encode(toEncode, true, "123"); - - assertEquals(width, result.getWidth()); - } - - @Test - public void testEncodeWithFunc1() throws Exception { - String toEncode = "\u00f1" + "123"; - String expected = QUIET_SPACE + START_CODE_C + FNC1 + - // "12" "3" check digit 92 - "10110011100" + SWITCH_CODE_B + "11001011100" + "10101111000" + STOP + QUIET_SPACE; - - BitMatrix result = encode(toEncode, false, "123"); - - String actual = BitMatrixTestCase.matrixToString(result); - assertEquals(expected, actual); - - int width = result.getWidth(); - result = encode(toEncode, true, "123"); - - assertEquals(width, result.getWidth()); - } - - @Test - public void testRoundtrip() throws Exception { - String toEncode = "\u00f1" + "10958" + "\u00f1" + "17160526"; - String expected = "1095817160526"; - - BitMatrix encResult = encode(toEncode, false, expected); - - int width = encResult.getWidth(); - encResult = encode(toEncode, true, expected); - //Compact encoding has one latch less and encodes as STARTA,FNC1,1,CODEC,09,58,FNC1,17,16,05,26 - assertEquals(width, encResult.getWidth() + 11); - } - - @Test - public void testLongCompact() throws Exception { - //test longest possible input - String toEncode = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - encode(toEncode, true, toEncode); - } - - @Test - public void testShift() throws Exception { - //compare fast to compact - String toEncode = "a\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\n"; - BitMatrix result = encode(toEncode, false, toEncode); - - int width = result.getWidth(); - result = encode(toEncode, true, toEncode); - - //big difference since the fast algoritm doesn't make use of SHIFT - assertEquals(width, result.getWidth() + 253); - } - - @Test - public void testDigitMixCompaction() throws Exception { - //compare fast to compact - String toEncode = "A1A12A123A1234A12345AA1AA12AA123AA1234AA1235"; - BitMatrix result = encode(toEncode, false, toEncode); - - int width = result.getWidth(); - result = encode(toEncode, true, toEncode); - - //very good, no difference - assertEquals(width, result.getWidth()); - } - - @Test - public void testCompaction1() throws Exception { - //compare fast to compact - String toEncode = "AAAAAAAAAAA12AAAAAAAAA"; - BitMatrix result = encode(toEncode, false, toEncode); - - int width = result.getWidth(); - result = encode(toEncode, true, toEncode); - - //very good, no difference - assertEquals(width, result.getWidth()); - } - - @Test - public void testCompaction2() throws Exception { - //compare fast to compact - String toEncode = "AAAAAAAAAAA1212aaaaaaaaa"; - BitMatrix result = encode(toEncode, false, toEncode); - - int width = result.getWidth(); - result = encode(toEncode, true, toEncode); - - //very good, no difference - assertEquals(width, result.getWidth()); - } - - @Test - public void testEncodeWithFunc4() throws Exception { - String toEncode = "\u00f4" + "123"; - String expected = QUIET_SPACE + START_CODE_B + FNC4B + - // "1" "2" "3" check digit 59 - "10011100110" + "11001110010" + "11001011100" + "11100011010" + STOP + QUIET_SPACE; - - BitMatrix result = encode(toEncode, false, null); - - String actual = BitMatrixTestCase.matrixToString(result); - assertEquals(expected, actual); - - int width = result.getWidth(); - result = encode(toEncode, true, null); - assertEquals(width, result.getWidth()); - } - - @Test - public void testEncodeWithFncsAndNumberInCodesetA() throws Exception { - String toEncode = "\n" + "\u00f1" + "\u00f4" + "1" + "\n"; - - String expected = QUIET_SPACE + START_CODE_A + LF + FNC1 + FNC4A + - "10011100110" + LF + "10101111000" + STOP + QUIET_SPACE; - - BitMatrix result = encode(toEncode, false, null); - - String actual = BitMatrixTestCase.matrixToString(result); - - assertEquals(expected, actual); - - int width = result.getWidth(); - result = encode(toEncode, true, null); - assertEquals(width, result.getWidth()); - } - - @Test - public void testEncodeSwitchBetweenCodesetsAAndB() throws Exception { - // start with A switch to B and back to A - testEncode("\0ABab\u0010", QUIET_SPACE + START_CODE_A + - // "\0" "A" "B" Switch to B "a" "b" - "10100001100" + "10100011000" + "10001011000" + SWITCH_CODE_B + "10010110000" + "10010000110" + - // Switch to A "\u0010" check digit - SWITCH_CODE_A + "10100111100" + "11001110100" + STOP + QUIET_SPACE); - - // start with B switch to A and back to B - // the compact encoder encodes this shorter as STARTB,a,b,SHIFT,NUL,a,b - testEncode("ab\0ab", QUIET_SPACE + START_CODE_B + - // "a" "b" Switch to A "\0" Switch to B - "10010110000" + "10010000110" + SWITCH_CODE_A + "10100001100" + SWITCH_CODE_B + - // "a" "b" check digit - "10010110000" + "10010000110" + "11010001110" + STOP + QUIET_SPACE); - } - - private void testEncode(String toEncode, String expected) throws Exception { - BitMatrix result = encode(toEncode, false, toEncode); - String actual = BitMatrixTestCase.matrixToString(result); - assertEquals(toEncode, expected, actual); - - - int width = result.getWidth(); - result = encode(toEncode, true, toEncode); - assertTrue(result.getWidth() <= width); - - } - - @Test(expected = IllegalArgumentException.class) - public void testEncodeWithForcedCodeSetFailureCodeSetABadCharacter() throws Exception { - // Lower case characters should not be accepted when the code set is forced to A. - String toEncode = "ASDFx0123"; - - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.FORCE_CODE_SET, "A"); - writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0, hints); - } - - @Test(expected = IllegalArgumentException.class) - public void testEncodeWithForcedCodeSetFailureCodeSetBBadCharacter() throws Exception { - String toEncode = "ASdf\00123"; // \0 (ascii value 0) - // Characters with ASCII value below 32 should not be accepted when the code set is forced to B. - - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.FORCE_CODE_SET, "B"); - writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0, hints); - } - - @Test(expected = IllegalArgumentException.class) - public void testEncodeWithForcedCodeSetFailureCodeSetCBadCharactersNonNum() throws Exception { - String toEncode = "123a5678"; - // Non-digit characters should not be accepted when the code set is forced to C. - - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.FORCE_CODE_SET, "C"); - writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0, hints); - } - - @Test(expected = IllegalArgumentException.class) - public void testEncodeWithForcedCodeSetFailureCodeSetCBadCharactersFncCode() throws Exception { - String toEncode = "123\u00f2a678"; - // Function codes other than 1 should not be accepted when the code set is forced to C. - - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.FORCE_CODE_SET, "C"); - writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0, hints); - } - - @Test(expected = IllegalArgumentException.class) - public void testEncodeWithForcedCodeSetFailureCodeSetCWrongAmountOfDigits() throws Exception { - String toEncode = "123456789"; - // An uneven amount of digits should not be accepted when the code set is forced to C. - - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.FORCE_CODE_SET, "C"); - writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0, hints); - } - - @Test - public void testEncodeWithForcedCodeSetFailureCodeSetA() throws Exception { - String toEncode = "AB123"; - // would default to B "A" "B" "1" - String expected = QUIET_SPACE + START_CODE_A + "10100011000" + "10001011000" + "10011100110" + - // "2" "3" check digit 10 - "11001110010" + "11001011100" + "11001000100" + STOP + QUIET_SPACE; - - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.FORCE_CODE_SET, "A"); - BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0, hints); - - String actual = BitMatrixTestCase.matrixToString(result); - assertEquals(expected, actual); - } - - @Test - public void testEncodeWithForcedCodeSetFailureCodeSetB() throws Exception { - String toEncode = "1234"; - // would default to C "1" "2" "3" - String expected = QUIET_SPACE + START_CODE_B + "10011100110" + "11001110010" + "11001011100" + - // "4" check digit 88 - "11001001110" + "11110010010" + STOP + QUIET_SPACE; - - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.FORCE_CODE_SET, "B"); - BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0, hints); - - String actual = BitMatrixTestCase.matrixToString(result); - assertEquals(expected, actual); - } - - private BitMatrix encode(String toEncode, boolean compact, String expectedLoopback) throws Exception { - Map hints = new EnumMap<>(EncodeHintType.class); - if (compact) { - hints.put(EncodeHintType.CODE128_COMPACT, Boolean.TRUE); - } - BitMatrix encResult = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0, hints); - if (expectedLoopback != null) { - BitArray row = encResult.getRow(0, null); - Result rtResult = reader.decodeRow(0, row, null); - String actual = rtResult.getText(); - assertEquals(expectedLoopback, actual); - } - if (compact) { - //check that what is encoded compactly yields the same on loopback as what was encoded fast. - BitArray row = encResult.getRow(0, null); - Result rtResult = reader.decodeRow(0, row, null); - String actual = rtResult.getText(); - BitMatrix encResultFast = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0); - row = encResultFast.getRow(0, null); - rtResult = reader.decodeRow(0, row, null); - assertEquals(rtResult.getText(), actual); - } - return encResult; - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/Code39BlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/Code39BlackBox1TestCase.java deleted file mode 100644 index b2b6553..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/Code39BlackBox1TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class Code39BlackBox1TestCase extends AbstractBlackBoxTestCase { - - public Code39BlackBox1TestCase() { - super("src/test/resources/blackbox/code39-1", new MultiFormatReader(), BarcodeFormat.CODE_39); - addTest(4, 4, 0.0f); - addTest(4, 4, 180.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/oned/Code39BlackBox3TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/Code39BlackBox3TestCase.java deleted file mode 100644 index 3d35941..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/Code39BlackBox3TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class Code39BlackBox3TestCase extends AbstractBlackBoxTestCase { - - public Code39BlackBox3TestCase() { - super("src/test/resources/blackbox/code39-3", new MultiFormatReader(), BarcodeFormat.CODE_39); - addTest(17, 17, 0.0f); - addTest(17, 17, 180.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/oned/Code39ExtendedBlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/Code39ExtendedBlackBox2TestCase.java deleted file mode 100644 index 6b045e3..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/Code39ExtendedBlackBox2TestCase.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class Code39ExtendedBlackBox2TestCase extends AbstractBlackBoxTestCase { - - public Code39ExtendedBlackBox2TestCase() { - super("src/test/resources/blackbox/code39-2", new Code39Reader(false, true), BarcodeFormat.CODE_39); - addTest(2, 2, 0.0f); - addTest(2, 2, 180.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/oned/Code39ExtendedModeTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/Code39ExtendedModeTestCase.java deleted file mode 100644 index 1a931f9..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/Code39ExtendedModeTestCase.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2017 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import org.junit.Assert; -import org.junit.Test; - -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.BitArray; -import com.google.zxing.ChecksumException; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; - -/** - * @author Michael Jahn - */ -public final class Code39ExtendedModeTestCase extends Assert { - - @SuppressWarnings("checkstyle:lineLength") - @Test - public void testDecodeExtendedMode() throws FormatException, ChecksumException, NotFoundException { - doTest("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f", - "000001001011011010101001001001011001010101101001001001010110101001011010010010010101011010010110100100100101011011010010101001001001010101011001011010010010010101101011001010100100100101010110110010101001001001010101010011011010010010010101101010011010100100100101010110100110101001001001010101011001101010010010010101101010100110100100100101010110101001101001001001010110110101001010010010010101010110100110100100100101011010110100101001001001010101101101001010010010010101010101100110100100100101011010101100101001001001010101101011001010010010010101010110110010100100100101011001010101101001001001010100110101011010010010010101100110101010100100100101010010110101101001001001010110010110101010010010010101001101101010101001001001011010100101101010010010010101101001011010100100100101101101001010101001001001010101100101101010010010010110101100101010010110110100000"); - doTest(" !\"#$%&'()*+,-./0123456789:;<=>?", - "00000100101101101010011010110101001001010010110101001011010010010100101011010010110100100101001011011010010101001001010010101011001011010010010100101101011001010100100101001010110110010101001001010010101010011011010010010100101101010011010100100101001010110100110101001001010010101011001101010010010100101101010100110100100101001010110101001101001010110110110010101101010010010100101101011010010101001101101011010010101101011001010110110110010101010100110101101101001101010101100110101010100101101101101001011010101100101101010010010100101001101101010101001001001010110110010101010010010010101010011011010100100100101101010011010101001001001010110100110101010010010010101011001101010010110110100000"); - doTest("@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_", - "000010010110110101010010010010100110101011011010100101101011010010110110110100101010101100101101101011001010101101100101010101001101101101010011010101101001101010101100110101101010100110101101010011011011010100101010110100110110101101001010110110100101010101100110110101011001010110101100101010110110010110010101011010011010101101100110101010100101101011011001011010101001101101010101001001001011010101001101010010010010101101010011010100100100101101101010010101001001001010101101001101010010010010110101101001010010110110100000"); - doTest("`abcdefghijklmnopqrstuvwxyz{|}~", - "000001001011011010101001001001011001101010101001010010010110101001011010010100100101011010010110100101001001011011010010101001010010010101011001011010010100100101101011001010100101001001010110110010101001010010010101010011011010010100100101101010011010100101001001010110100110101001010010010101011001101010010100100101101010100110100101001001010110101001101001010010010110110101001010010100100101010110100110100101001001011010110100101001010010010101101101001010010100100101010101100110100101001001011010101100101001010010010101101011001010010100100101010110110010100101001001011001010101101001010010010100110101011010010100100101100110101010100101001001010010110101101001010010010110010110101010010100100101001101101010101001001001010110110100101010010010010101010110011010100100100101101010110010101001001001010110101100101010010010010101011011001010010110110100000"); - } - - private static void doTest(String expectedResult, String encodedResult) - throws FormatException, ChecksumException, NotFoundException { - Code39Reader sut = new Code39Reader(false, true); - BitMatrix matrix = BitMatrix.parse(encodedResult, "1", "0"); - BitArray row = new BitArray(matrix.getWidth()); - matrix.getRow(0, row); - Result result = sut.decodeRow(0, row, null); - assertEquals(expectedResult, result.getText()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/Code39WriterTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/Code39WriterTestCase.java deleted file mode 100644 index 669b863..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/Code39WriterTestCase.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2016 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.BitMatrixTestCase; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link Code39Writer}. - */ -public final class Code39WriterTestCase extends Assert { - - @SuppressWarnings("checkstyle:lineLength") - @Test - public void testEncode() { - doTest("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", - "000001001011011010110101001011010110100101101101101001010101011001011011010110010101" + - "011011001010101010011011011010100110101011010011010101011001101011010101001101011010" + - "100110110110101001010101101001101101011010010101101101001010101011001101101010110010" + - "101101011001010101101100101100101010110100110101011011001101010101001011010110110010" + - "110101010011011010101010011011010110100101011010110010101101101100101010101001101011" + - "01101001101010101100110101010100101101101101001011010101100101101010010110110100000"); - - // extended mode blocks - doTest("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f", - "000001001011011010101001001001011001010101101001001001010110101001011010010010010101" + - "011010010110100100100101011011010010101001001001010101011001011010010010010101101011" + - "001010100100100101010110110010101001001001010101010011011010010010010101101010011010" + - "100100100101010110100110101001001001010101011001101010010010010101101010100110100100" + - "100101010110101001101001001001010110110101001010010010010101010110100110100100100101" + - "011010110100101001001001010101101101001010010010010101010101100110100100100101011010" + - "101100101001001001010101101011001010010010010101010110110010100100100101011001010101" + - "101001001001010100110101011010010010010101100110101010100100100101010010110101101001" + - "001001010110010110101010010010010101001101101010101001001001011010100101101010010010" + - "010101101001011010100100100101101101001010101001001001010101100101101010010010010110" + - "101100101010010110110100000"); - - doTest(" !\"#$%&'()*+,-./0123456789:;<=>?", - "000001001011011010100110101101010010010100101101010010110100100101001010110100101101" + - "001001010010110110100101010010010100101010110010110100100101001011010110010101001001" + - "010010101101100101010010010100101010100110110100100101001011010100110101001001010010" + - "101101001101010010010100101010110011010100100101001011010101001101001001010010101101" + - "010011010010101101101100101011010100100101001011010110100101010011011010110100101011" + - "010110010101101101100101010101001101011011010011010101011001101010101001011011011010" + - "010110101011001011010100100101001010011011010101010010010010101101100101010100100100" + - "101010100110110101001001001011010100110101010010010010101101001101010100100100101010" + - "11001101010010110110100000"); - - doTest("@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_", - "0000010010110110101010010010010100110101011011010100101101011010010110110110100101010" + - "101100101101101011001010101101100101010101001101101101010011010101101001101010101100" + - "110101101010100110101101010011011011010100101010110100110110101101001010110110100101" + - "010101100110110101011001010110101100101010110110010110010101011010011010101101100110" + - "101010100101101011011001011010101001101101010101001001001011010101001101010010010010" + - "101101010011010100100100101101101010010101001001001010101101001101010010010010110101" + - "101001010010110110100000"); - - doTest("`abcdefghijklmnopqrstuvwxyz{|}~", - "000001001011011010101001001001011001101010101001010010010110101001011010010100100101" + - "011010010110100101001001011011010010101001010010010101011001011010010100100101101011" + - "001010100101001001010110110010101001010010010101010011011010010100100101101010011010" + - "100101001001010110100110101001010010010101011001101010010100100101101010100110100101" + - "001001010110101001101001010010010110110101001010010100100101010110100110100101001001" + - "011010110100101001010010010101101101001010010100100101010101100110100101001001011010" + - "101100101001010010010101101011001010010100100101010110110010100101001001011001010101" + - "101001010010010100110101011010010100100101100110101010100101001001010010110101101001" + - "010010010110010110101010010100100101001101101010101001001001010110110100101010010010" + - "010101010110011010100100100101101010110010101001001001010110101100101010010010010101" + - "011011001010010110110100000"); - } - - private static void doTest(String input, CharSequence expected) { - BitMatrix result = new Code39Writer().encode(input, BarcodeFormat.CODE_39, 0, 0); - assertEquals(input, expected, BitMatrixTestCase.matrixToString(result)); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/Code93BlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/Code93BlackBox1TestCase.java deleted file mode 100644 index e8606e8..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/Code93BlackBox1TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class Code93BlackBox1TestCase extends AbstractBlackBoxTestCase { - - public Code93BlackBox1TestCase() { - super("src/test/resources/blackbox/code93-1", new MultiFormatReader(), BarcodeFormat.CODE_93); - addTest(3, 3, 0.0f); - addTest(3, 3, 180.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/oned/Code93ReaderTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/Code93ReaderTestCase.java deleted file mode 100644 index 1a6538b..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/Code93ReaderTestCase.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2018 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import org.junit.Assert; -import org.junit.Test; - -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.BitArray; -import com.google.zxing.ChecksumException; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; - -/** - * @author Daisuke Makiuchi - */ -public final class Code93ReaderTestCase extends Assert { - - @SuppressWarnings("checkstyle:lineLength") - @Test - public void testDecode() throws FormatException, ChecksumException, NotFoundException { - doTest("Code93!\n$%/+ :\u001b;[{\u007f\u0000@`\u007f\u007f\u007f", - "0000001010111101101000101001100101001011001001100101100101001001100101100100101000010101010000101110101101101010001001001101001101001110010101101011101011011101011101101110100101110101101001110101110110101101010001110110101100010101110110101000110101110110101000101101110110101101001101110110101100101101110110101100110101110110101011011001110110101011001101110110101001101101110110101001110101001100101101010001010111101111"); - } - - private static void doTest(String expectedResult, String encodedResult) - throws FormatException, ChecksumException, NotFoundException { - Code93Reader sut = new Code93Reader(); - BitMatrix matrix = BitMatrix.parse(encodedResult, "1", "0"); - BitArray row = new BitArray(matrix.getWidth()); - matrix.getRow(0, row); - Result result = sut.decodeRow(0, row, null); - assertEquals(expectedResult, result.getText()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/Code93WriterTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/Code93WriterTestCase.java deleted file mode 100644 index dea0f1c..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/Code93WriterTestCase.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2016 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.BitMatrixTestCase; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link Code93Writer}. - */ -public final class Code93WriterTestCase extends Assert { - - @Test - public void testEncode() { - doTest("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", - "000001010111101101010001101001001101000101100101001100100101100010101011010001011001" + - "001011000101001101001000110101010110001010011001010001101001011001000101101101101001" + - "101100101101011001101001101100101101100110101011011001011001101001101101001110101000" + - "101001010010001010001001010000101001010001001001001001000101010100001000100101000010" + - "10100111010101000010101011110100000"); - - doTest("\u0000\u0001\u001a\u001b\u001f $%+!,09:;@AZ[_`az{\u007f", - "00000" + "101011110" + - "111011010" + "110010110" + "100100110" + "110101000" + // bU aA - "100100110" + "100111010" + "111011010" + "110101000" + // aZ bA - "111011010" + "110010010" + "111010010" + "111001010" + // bE space $ - "110101110" + "101110110" + "111010110" + "110101000" + // % + cA - "111010110" + "101011000" + "100010100" + "100001010" + // cL 0 9 - "111010110" + "100111010" + "111011010" + "110001010" + // cZ bF - "111011010" + "110011010" + "110101000" + "100111010" + // bV A Z - "111011010" + "100011010" + "111011010" + "100101100" + // bK bO - "111011010" + "101101100" + "100110010" + "110101000" + // bW dA - "100110010" + "100111010" + "111011010" + "100010110" + // dZ bP - "111011010" + "110100110" + // bT - "110100010" + "110101100" + // checksum: 12 28 - "101011110" + "100000"); - } - - private static void doTest(String input, CharSequence expected) { - BitMatrix result = new Code93Writer().encode(input, BarcodeFormat.CODE_93, 0, 0); - assertEquals(expected, BitMatrixTestCase.matrixToString(result)); - } - - @Test - public void testConvertToExtended() { - // non-extended chars are not changed. - String src = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; - String dst = Code93Writer.convertToExtended(src); - assertEquals(src, dst); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox1TestCase.java deleted file mode 100644 index 022b454..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox1TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class EAN13BlackBox1TestCase extends AbstractBlackBoxTestCase { - - public EAN13BlackBox1TestCase() { - super("src/test/resources/blackbox/ean13-1", new MultiFormatReader(), BarcodeFormat.EAN_13); - addTest(30, 32, 0.0f); - addTest(27, 32, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox2TestCase.java deleted file mode 100644 index f1768af..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox2TestCase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * This is a set of mobile image taken at 480x360 with difficult lighting. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class EAN13BlackBox2TestCase extends AbstractBlackBoxTestCase { - - public EAN13BlackBox2TestCase() { - super("src/test/resources/blackbox/ean13-2", new MultiFormatReader(), BarcodeFormat.EAN_13); - addTest(12, 17, 0, 1, 0.0f); - addTest(11, 17, 0, 1, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox3TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox3TestCase.java deleted file mode 100644 index edd544c..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox3TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class EAN13BlackBox3TestCase extends AbstractBlackBoxTestCase { - - public EAN13BlackBox3TestCase() { - super("src/test/resources/blackbox/ean13-3", new MultiFormatReader(), BarcodeFormat.EAN_13); - addTest(53, 55, 0.0f); - addTest(55, 55, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox4TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox4TestCase.java deleted file mode 100644 index 89e0db7..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox4TestCase.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A very difficult set of images taken with extreme shadows and highlights. - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class EAN13BlackBox4TestCase extends AbstractBlackBoxTestCase { - - public EAN13BlackBox4TestCase() { - super("src/test/resources/blackbox/ean13-4", new MultiFormatReader(), BarcodeFormat.EAN_13); - addTest(6, 13, 1, 1, 0.0f); - addTest(7, 13, 1, 1, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox5BlurryTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox5BlurryTestCase.java deleted file mode 100644 index 4281091..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/EAN13BlackBox5BlurryTestCase.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A set of blurry images taken with a fixed-focus device. - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class EAN13BlackBox5BlurryTestCase extends AbstractBlackBoxTestCase { - - public EAN13BlackBox5BlurryTestCase() { - super("src/test/resources/blackbox/ean13-5", new MultiFormatReader(), BarcodeFormat.EAN_13); - addTest(0, 0, 0.0f); - addTest(0, 0, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/EAN13WriterTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/EAN13WriterTestCase.java deleted file mode 100644 index 4d49499..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/EAN13WriterTestCase.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.BitMatrixTestCase; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Ari Pollak - */ -public final class EAN13WriterTestCase extends Assert { - - @Test - public void testEncode() { - String testStr = - "00001010001011010011101100110010011011110100111010101011001101101100100001010111001001110100010010100000"; - BitMatrix result = new EAN13Writer().encode("5901234123457", BarcodeFormat.EAN_13, testStr.length(), 0); - assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); - } - - @Test - public void testAddChecksumAndEncode() { - String testStr = - "00001010001011010011101100110010011011110100111010101011001101101100100001010111001001110100010010100000"; - BitMatrix result = new EAN13Writer().encode("590123412345", BarcodeFormat.EAN_13, testStr.length(), 0); - assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); - } - - @Test(expected = IllegalArgumentException.class) - public void testEncodeIllegalCharacters() { - new EAN13Writer().encode("5901234123abc", BarcodeFormat.EAN_13, 0, 0); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/EAN8BlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/EAN8BlackBox1TestCase.java deleted file mode 100644 index f9fc6b9..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/EAN8BlackBox1TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class EAN8BlackBox1TestCase extends AbstractBlackBoxTestCase { - - public EAN8BlackBox1TestCase() { - super("src/test/resources/blackbox/ean8-1", new MultiFormatReader(), BarcodeFormat.EAN_8); - addTest(8, 8, 0.0f); - addTest(8, 8, 180.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/oned/EAN8WriterTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/EAN8WriterTestCase.java deleted file mode 100644 index 8659822..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/EAN8WriterTestCase.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.BitMatrixTestCase; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Ari Pollak - */ -public final class EAN8WriterTestCase extends Assert { - - @Test - public void testEncode() { - String testStr = "0000001010001011010111101111010110111010101001110111001010001001011100101000000"; - BitMatrix result = new EAN8Writer().encode("96385074", BarcodeFormat.EAN_8, testStr.length(), 0); - assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); - } - - @Test - public void testAddChecksumAndEncode() { - String testStr = "0000001010001011010111101111010110111010101001110111001010001001011100101000000"; - BitMatrix result = new EAN8Writer().encode("9638507", BarcodeFormat.EAN_8, testStr.length(), 0); - assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); - } - - @Test(expected = IllegalArgumentException.class) - public void testEncodeIllegalCharacters() { - new EAN8Writer().encode("96385abc", BarcodeFormat.EAN_8, 0, 0); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/EANManufacturerOrgSupportTest.java b/port_src/core/src/test/java/com/google/zxing/oned/EANManufacturerOrgSupportTest.java deleted file mode 100644 index 5c0f1ab..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/EANManufacturerOrgSupportTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link EANManufacturerOrgSupport}. - * - * @author Sean Owen - */ -public final class EANManufacturerOrgSupportTest extends Assert { - - @Test - public void testLookup() { - EANManufacturerOrgSupport support = new EANManufacturerOrgSupport(); - assertNull(support.lookupCountryIdentifier("472000")); - assertEquals("US/CA", support.lookupCountryIdentifier("000000")); - assertEquals("MO", support.lookupCountryIdentifier("958000")); - assertEquals("GB", support.lookupCountryIdentifier("500000")); - assertEquals("GB", support.lookupCountryIdentifier("509000")); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/ITFBlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/ITFBlackBox1TestCase.java deleted file mode 100644 index 393b622..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/ITFBlackBox1TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author kevin.osullivan@sita.aero - */ -public final class ITFBlackBox1TestCase extends AbstractBlackBoxTestCase { - - public ITFBlackBox1TestCase() { - super("src/test/resources/blackbox/itf-1", new MultiFormatReader(), BarcodeFormat.ITF); - addTest(14, 14, 0.0f); - addTest(14, 14, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/ITFBlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/ITFBlackBox2TestCase.java deleted file mode 100644 index 5ef0212..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/ITFBlackBox2TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class ITFBlackBox2TestCase extends AbstractBlackBoxTestCase { - - public ITFBlackBox2TestCase() { - super("src/test/resources/blackbox/itf-2", new MultiFormatReader(), BarcodeFormat.ITF); - addTest(13, 13, 0.0f); - addTest(13, 13, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/ITFWriterTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/ITFWriterTestCase.java deleted file mode 100644 index 598741a..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/ITFWriterTestCase.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2017 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.BitMatrixTestCase; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link ITFWriter}. - */ -public final class ITFWriterTestCase extends Assert { - - @Test - public void testEncode() { - doTest("00123456789012", - "0000010101010111000111000101110100010101110001110111010001010001110100011" + - "100010101000101011100011101011101000111000101110100010101110001110100000"); - } - - private static void doTest(String input, CharSequence expected) { - BitMatrix result = new ITFWriter().encode(input, BarcodeFormat.ITF, 0, 0); - assertEquals(expected, BitMatrixTestCase.matrixToString(result)); - } - - @Test(expected = IllegalArgumentException.class) - public void testEncodeIllegalCharacters() { - new ITFWriter().encode("00123456789abc", BarcodeFormat.ITF, 0, 0); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox1TestCase.java deleted file mode 100644 index 51945ce..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox1TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class UPCABlackBox1TestCase extends AbstractBlackBoxTestCase { - - public UPCABlackBox1TestCase() { - super("src/test/resources/blackbox/upca-1", new MultiFormatReader(), BarcodeFormat.UPC_A); - addTest(14, 18, 0, 1, 0.0f); - addTest(16, 18, 0, 1, 180.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox2TestCase.java deleted file mode 100644 index b6414df..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox2TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class UPCABlackBox2TestCase extends AbstractBlackBoxTestCase { - - public UPCABlackBox2TestCase() { - super("src/test/resources/blackbox/upca-2", new MultiFormatReader(), BarcodeFormat.UPC_A); - addTest(28, 36, 0, 2, 0.0f); - addTest(29, 36, 0, 2, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox3ReflectiveTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox3ReflectiveTestCase.java deleted file mode 100644 index 4b9a745..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox3ReflectiveTestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class UPCABlackBox3ReflectiveTestCase extends AbstractBlackBoxTestCase { - - public UPCABlackBox3ReflectiveTestCase() { - super("src/test/resources/blackbox/upca-3", new MultiFormatReader(), BarcodeFormat.UPC_A); - addTest(7, 9, 0, 2, 0.0f); - addTest(8, 9, 0, 2, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox4TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox4TestCase.java deleted file mode 100644 index 5642dc7..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox4TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class UPCABlackBox4TestCase extends AbstractBlackBoxTestCase { - - public UPCABlackBox4TestCase() { - super("src/test/resources/blackbox/upca-4", new MultiFormatReader(), BarcodeFormat.UPC_A); - addTest(9, 11, 0, 1, 0.0f); - addTest(9, 11, 0, 1, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox5TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox5TestCase.java deleted file mode 100644 index 8ae95ea..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox5TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class UPCABlackBox5TestCase extends AbstractBlackBoxTestCase { - - public UPCABlackBox5TestCase() { - super("src/test/resources/blackbox/upca-5", new MultiFormatReader(), BarcodeFormat.UPC_A); - addTest(20, 23, 0, 0, 0.0f); - addTest(22, 23, 0, 0, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox6BlurryTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox6BlurryTestCase.java deleted file mode 100644 index 6e5690f..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/UPCABlackBox6BlurryTestCase.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A set of blurry images taken with a fixed-focus device. - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class UPCABlackBox6BlurryTestCase extends AbstractBlackBoxTestCase { - - public UPCABlackBox6BlurryTestCase() { - super("src/test/resources/blackbox/upca-6", new MultiFormatReader(), BarcodeFormat.UPC_A); - addTest(0, 0, 0.0f); - addTest(0, 0, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/UPCAWriterTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/UPCAWriterTestCase.java deleted file mode 100644 index b444479..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/UPCAWriterTestCase.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.BitMatrix; - -import com.google.zxing.common.BitMatrixTestCase; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author qwandor@google.com (Andrew Walbran) - */ -public final class UPCAWriterTestCase extends Assert { - - @Test - public void testEncode() { - String testStr = - "00001010100011011011101100010001011010111101111010101011100101110100100111011001101101100101110010100000"; - BitMatrix result = new UPCAWriter().encode("485963095124", BarcodeFormat.UPC_A, testStr.length(), 0); - assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); - } - - @Test - public void testAddChecksumAndEncode() { - String testStr = - "00001010011001001001101111010100011011000101011110101010001001001000111010011100101100110110110010100000"; - BitMatrix result = new UPCAWriter().encode("12345678901", BarcodeFormat.UPC_A, testStr.length(), 0); - assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/UPCEANExtensionBlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/UPCEANExtensionBlackBox1TestCase.java deleted file mode 100644 index 020bba1..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/UPCEANExtensionBlackBox1TestCase.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class UPCEANExtensionBlackBox1TestCase extends AbstractBlackBoxTestCase { - - public UPCEANExtensionBlackBox1TestCase() { - super("src/test/resources/blackbox/upcean-extension-1", new MultiFormatReader(), BarcodeFormat.EAN_13); - addTest(2, 2, 0.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/oned/UPCEBlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/UPCEBlackBox1TestCase.java deleted file mode 100644 index a36fa0b..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/UPCEBlackBox1TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class UPCEBlackBox1TestCase extends AbstractBlackBoxTestCase { - - public UPCEBlackBox1TestCase() { - super("src/test/resources/blackbox/upce-1", new MultiFormatReader(), BarcodeFormat.UPC_E); - addTest(3, 3, 0.0f); - addTest(3, 3, 180.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/oned/UPCEBlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/UPCEBlackBox2TestCase.java deleted file mode 100644 index 49d7c17..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/UPCEBlackBox2TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class UPCEBlackBox2TestCase extends AbstractBlackBoxTestCase { - - public UPCEBlackBox2TestCase() { - super("src/test/resources/blackbox/upce-2", new MultiFormatReader(), BarcodeFormat.UPC_E); - addTest(31, 35, 0, 1, 0.0f); - addTest(31, 35, 1, 1, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/UPCEBlackBox3ReflectiveTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/UPCEBlackBox3ReflectiveTestCase.java deleted file mode 100644 index bbf522a..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/UPCEBlackBox3ReflectiveTestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class UPCEBlackBox3ReflectiveTestCase extends AbstractBlackBoxTestCase { - - public UPCEBlackBox3ReflectiveTestCase() { - super("src/test/resources/blackbox/upce-3", new MultiFormatReader(), BarcodeFormat.UPC_E); - addTest(6, 8, 0.0f); - addTest(6, 8, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/UPCEWriterTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/UPCEWriterTestCase.java deleted file mode 100644 index 3a7a9e0..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/UPCEWriterTestCase.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2016 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.BitMatrixTestCase; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link UPCEWriter}. - */ -public final class UPCEWriterTestCase extends Assert { - - @Test - public void testEncode() { - doTest("05096893", - "0000000000010101110010100111000101101011110110111001011101010100000000000"); - } - - @Test - public void testEncodeSystem1() { - doTest("12345670", - "0000000000010100100110111101010001101110010000101001000101010100000000000"); - } - - @Test - public void testAddChecksumAndEncode() { - doTest("0509689", - "0000000000010101110010100111000101101011110110111001011101010100000000000"); - } - - private static void doTest(String content, String encoding) { - BitMatrix result = new UPCEWriter().encode(content, BarcodeFormat.UPC_E, encoding.length(), 0); - assertEquals(encoding, BitMatrixTestCase.matrixToString(result)); - } - - @Test(expected = IllegalArgumentException.class) - public void testEncodeIllegalCharacters() { - new UPCEWriter().encode("05096abc", BarcodeFormat.UPC_E, 0, 0); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/RSS14BlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/RSS14BlackBox1TestCase.java deleted file mode 100644 index 8ce97a4..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/RSS14BlackBox1TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned.rss; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class RSS14BlackBox1TestCase extends AbstractBlackBoxTestCase { - - public RSS14BlackBox1TestCase() { - super("src/test/resources/blackbox/rss14-1", new MultiFormatReader(), BarcodeFormat.RSS_14); - addTest(6, 6, 0.0f); - addTest(6, 6, 180.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/RSS14BlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/RSS14BlackBox2TestCase.java deleted file mode 100644 index 3855be8..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/RSS14BlackBox2TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.oned.rss; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class RSS14BlackBox2TestCase extends AbstractBlackBoxTestCase { - - public RSS14BlackBox2TestCase() { - super("src/test/resources/blackbox/rss14-2", new MultiFormatReader(), BarcodeFormat.RSS_14); - addTest(4, 8, 1, 1, 0.0f); - addTest(3, 8, 0, 1, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/BinaryUtil.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/BinaryUtil.java deleted file mode 100644 index 8e84c38..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/BinaryUtil.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.common.BitArray; - -import java.util.regex.Pattern; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -public final class BinaryUtil { - - private static final Pattern ONE = Pattern.compile("1"); - private static final Pattern ZERO = Pattern.compile("0"); - private static final Pattern SPACE = Pattern.compile(" "); - - private BinaryUtil() { - } - - /* - * Constructs a BitArray from a String like the one returned from BitArray.toString() - */ - public static BitArray buildBitArrayFromString(CharSequence data) { - CharSequence dotsAndXs = ZERO.matcher(ONE.matcher(data).replaceAll("X")).replaceAll("."); - BitArray binary = new BitArray(SPACE.matcher(dotsAndXs).replaceAll("").length()); - int counter = 0; - - for (int i = 0; i < dotsAndXs.length(); ++i) { - if (i % 9 == 0) { // spaces - if (dotsAndXs.charAt(i) != ' ') { - throw new IllegalStateException("space expected"); - } - continue; - } - - char currentChar = dotsAndXs.charAt(i); - if (currentChar == 'X' || currentChar == 'x') { - binary.set(counter); - } - counter++; - } - return binary; - } - - public static BitArray buildBitArrayFromStringWithoutSpaces(CharSequence data) { - StringBuilder sb = new StringBuilder(); - CharSequence dotsAndXs = ZERO.matcher(ONE.matcher(data).replaceAll("X")).replaceAll("."); - int current = 0; - while (current < dotsAndXs.length()) { - sb.append(' '); - for (int i = 0; i < 8 && current < dotsAndXs.length(); ++i) { - sb.append(dotsAndXs.charAt(current)); - current++; - } - } - return buildBitArrayFromString(sb.toString()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/BinaryUtilTest.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/BinaryUtilTest.java deleted file mode 100644 index f7be304..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/BinaryUtilTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.common.BitArray; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.regex.Pattern; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -public final class BinaryUtilTest extends Assert { - - private static final Pattern SPACE = Pattern.compile(" "); - - @Test - public void testBuildBitArrayFromString() { - - CharSequence data = " ..X..X.. ..XXX... XXXXXXXX ........"; - check(data); - - data = " XXX..X.."; - check(data); - - data = " XX"; - check(data); - - data = " ....XX.. ..XX"; - check(data); - - data = " ....XX.. ..XX..XX ....X.X. ........"; - check(data); - } - - private static void check(CharSequence data) { - BitArray binary = BinaryUtil.buildBitArrayFromString(data); - assertEquals(data, binary.toString()); - } - - @Test - public void testBuildBitArrayFromStringWithoutSpaces() { - CharSequence data = " ..X..X.. ..XXX... XXXXXXXX ........"; - checkWithoutSpaces(data); - - data = " XXX..X.."; - checkWithoutSpaces(data); - - data = " XX"; - checkWithoutSpaces(data); - - data = " ....XX.. ..XX"; - checkWithoutSpaces(data); - - data = " ....XX.. ..XX..XX ....X.X. ........"; - checkWithoutSpaces(data); - } - - private static void checkWithoutSpaces(CharSequence data) { - CharSequence dataWithoutSpaces = SPACE.matcher(data).replaceAll(""); - BitArray binary = BinaryUtil.buildBitArrayFromStringWithoutSpaces(dataWithoutSpaces); - assertEquals(data, binary.toString()); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/BitArrayBuilderTest.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/BitArrayBuilderTest.java deleted file mode 100644 index 609c911..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/BitArrayBuilderTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.common.BitArray; -import com.google.zxing.oned.rss.DataCharacter; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -public final class BitArrayBuilderTest extends Assert { - - @Test - public void testBuildBitArray1() { - int[][] pairValues = {{19}, {673, 16}}; - - String expected = " .......X ..XX..X. X.X....X .......X ...."; - - checkBinary(pairValues, expected); - } - - private static void checkBinary(int[][] pairValues, String expected) { - BitArray binary = buildBitArray(pairValues); - assertEquals(expected, binary.toString()); - } - - private static BitArray buildBitArray(int[][] pairValues) { - List pairs = new ArrayList<>(); - for (int i = 0; i < pairValues.length; ++i) { - int [] pair = pairValues[i]; - - DataCharacter leftChar; - if (i == 0) { - leftChar = null; - } else { - leftChar = new DataCharacter(pair[0], 0); - } - - DataCharacter rightChar; - if (i == 0) { - rightChar = new DataCharacter(pair[0], 0); - } else if (pair.length == 2) { - rightChar = new DataCharacter(pair[1], 0); - } else { - rightChar = null; - } - - ExpandedPair expandedPair = new ExpandedPair(leftChar, rightChar, null); - pairs.add(expandedPair); - } - - return BitArrayBuilder.buildBitArray(pairs); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/ExpandedInformationDecoderTest.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/ExpandedInformationDecoderTest.java deleted file mode 100644 index 4e408ae..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/ExpandedInformationDecoderTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.common.BitArray; -import com.google.zxing.oned.rss.expanded.decoders.AbstractExpandedDecoder; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -public final class ExpandedInformationDecoderTest extends Assert { - - @Test - public void testNoAi() throws Exception { - BitArray information = BinaryUtil.buildBitArrayFromString(" .......X ..XX..X. X.X....X .......X ...."); - - AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(information); - String decoded = decoder.parseInformation(); - assertEquals("(10)12A", decoded); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedBlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedBlackBox1TestCase.java deleted file mode 100644 index 2072004..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedBlackBox1TestCase.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A test of {@link RSSExpandedReader} against a fixed test set of images. - */ -public final class RSSExpandedBlackBox1TestCase extends AbstractBlackBoxTestCase { - - public RSSExpandedBlackBox1TestCase() { - super("src/test/resources/blackbox/rssexpanded-1", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); - addTest(32, 32, 0.0f); - addTest(32, 32, 180.0f); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedBlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedBlackBox2TestCase.java deleted file mode 100644 index 515179e..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedBlackBox2TestCase.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A test of {@link RSSExpandedReader} against a fixed test set of images. - */ -public final class RSSExpandedBlackBox2TestCase extends AbstractBlackBoxTestCase { - - public RSSExpandedBlackBox2TestCase() { - super("src/test/resources/blackbox/rssexpanded-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); - addTest(21, 23, 0.0f); - addTest(21, 23, 180.0f); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedBlackBox3TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedBlackBox3TestCase.java deleted file mode 100644 index 6117d6e..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedBlackBox3TestCase.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A test of {@link RSSExpandedReader} against a fixed test set of images. - */ -public final class RSSExpandedBlackBox3TestCase extends AbstractBlackBoxTestCase { - - public RSSExpandedBlackBox3TestCase() { - super("src/test/resources/blackbox/rssexpanded-3", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); - addTest(117, 117, 0.0f); - addTest(117, 117, 180.0f); - } -} - diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2binaryTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2binaryTestCase.java deleted file mode 100644 index 6436123..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2binaryTestCase.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.nio.file.Path; -import java.util.List; - -import javax.imageio.ImageIO; - -import com.google.zxing.BinaryBitmap; -import com.google.zxing.BufferedImageLuminanceSource; -import com.google.zxing.NotFoundException; -import com.google.zxing.ReaderException; -import com.google.zxing.common.AbstractBlackBoxTestCase; -import com.google.zxing.common.BitArray; -import com.google.zxing.common.GlobalHistogramBinarizer; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -public final class RSSExpandedImage2binaryTestCase extends Assert { - - @Test - public void testDecodeRow2binary1() throws Exception { - // (11)100224(17)110224(3102)000100 - assertCorrectImage2binary("1.png", - " ...X...X .X....X. .XX...X. X..X...X ...XX.X. ..X.X... ..X.X..X ...X..X. X.X....X .X....X. .....X.. X...X..."); - } - - @Test - public void testDecodeRow2binary2() throws Exception { - // (01)90012345678908(3103)001750 - assertCorrectImage2binary("2.png", " ..X..... ......X. .XXX.X.X .X...XX. XXXXX.XX XX.X.... .XX.XX.X .XX."); - } - - @Test - public void testDecodeRow2binary3() throws Exception { - // (10)12A - assertCorrectImage2binary("3.png", " .......X ..XX..X. X.X....X .......X ...."); - } - - @Test - public void testDecodeRow2binary4() throws Exception { - // (01)98898765432106(3202)012345(15)991231 - assertCorrectImage2binary( - "4.png", " ..XXXX.X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX..XX XX.X.XXX X..XX..X .X.XXXXX XXXX"); - } - - @Test - public void testDecodeRow2binary5() throws Exception { - // (01)90614141000015(3202)000150 - assertCorrectImage2binary( - "5.png", " ..X.X... .XXXX.X. XX..XXXX ....XX.. X....... ....X... ....X..X .XX."); - } - - @SuppressWarnings("checkstyle:lineLength") - @Test - public void testDecodeRow2binary10() throws Exception { - // (01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012 - assertCorrectImage2binary("10.png", - " .X.XX..X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX...X XX.X.... X.X.X.X. X.X..X.X .X....X. XX...X.. ...XX.X. .XXXXXX. .X..XX.. X.X.X... .X...... XXXX.... XX.XX... XXXXX.X. ...XXXXX .....X.X ...X.... X.XXX..X X.X.X... XX.XX..X .X..X..X .X.X.X.X X.XX...X .XX.XXX. XXX.X.XX ..X."); - } - - @SuppressWarnings("checkstyle:lineLength") - @Test - public void testDecodeRow2binary11() throws Exception { - // (01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456 - assertCorrectImage2binary("11.png", - " .X.XX..X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX...X XX.X.... X.X.X.X. X.X..X.X .X....X. XX...X.. ...XX.X. .XXXXXX. .X..XX.. X.X.X... .X...... XXXX.... XX.XX... XXXXX.X. ...XXXXX .....X.X ...X.... X.XXX..X X.X.X... ...."); - } - - @Test - public void testDecodeRow2binary12() throws Exception { - // (01)98898765432106(3103)001750 - assertCorrectImage2binary( - "12.png", " ..X..XX. XXXX..XX X.XX.XX. .X....XX XXX..XX. X..X.... .XX.XX.X .XX."); - } - - @Test - public void testDecodeRow2binary13() throws Exception { - // (01)90012345678908(3922)795 - assertCorrectImage2binary( - "13.png", " ..XX..X. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. X.X.XXXX .X..X..X ......X."); - } - - @Test - public void testDecodeRow2binary14() throws Exception { - // (01)90012345678908(3932)0401234 - assertCorrectImage2binary( - "14.png", " ..XX.X.. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. X.....X. X.....X. X.X.X.XX .X...... X..."); - } - - @Test - public void testDecodeRow2binary15() throws Exception { - // (01)90012345678908(3102)001750(11)100312 - assertCorrectImage2binary( - "15.png", " ..XXX... ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX.."); - } - - @Test - public void testDecodeRow2binary16() throws Exception { - // (01)90012345678908(3202)001750(11)100312 - assertCorrectImage2binary( - "16.png", " ..XXX..X ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX.."); - } - - @Test - public void testDecodeRow2binary17() throws Exception { - // (01)90012345678908(3102)001750(13)100312 - assertCorrectImage2binary( - "17.png", " ..XXX.X. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX.."); - } - - @Test - public void testDecodeRow2binary18() throws Exception { - // (01)90012345678908(3202)001750(13)100312 - assertCorrectImage2binary( - "18.png", " ..XXX.XX ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX.."); - } - - @Test - public void testDecodeRow2binary19() throws Exception { - // (01)90012345678908(3102)001750(15)100312 - assertCorrectImage2binary( - "19.png", " ..XXXX.. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX.."); - } - - @Test - public void testDecodeRow2binary20() throws Exception { - // (01)90012345678908(3202)001750(15)100312 - assertCorrectImage2binary( - "20.png", " ..XXXX.X ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX.."); - } - - @Test - public void testDecodeRow2binary21() throws Exception { - // (01)90012345678908(3102)001750(17)100312 - assertCorrectImage2binary( - "21.png", " ..XXXXX. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX.."); - } - - @Test - public void testDecodeRow2binary22() throws Exception { - // (01)90012345678908(3202)001750(17)100312 - assertCorrectImage2binary( - "22.png", " ..XXXXXX ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX.."); - } - - private static void assertCorrectImage2binary(String fileName, String expected) - throws IOException, NotFoundException { - Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); - - BufferedImage image = ImageIO.read(path.toFile()); - BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image))); - int rowNumber = binaryMap.getHeight() / 2; - BitArray row = binaryMap.getBlackRow(rowNumber, null); - - List pairs; - try { - RSSExpandedReader rssExpandedReader = new RSSExpandedReader(); - pairs = rssExpandedReader.decodeRow2pairs(rowNumber, row); - } catch (ReaderException re) { - fail(re.toString()); - return; - } - BitArray binary = BitArrayBuilder.buildBitArray(pairs); - assertEquals(expected, binary.toString()); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java deleted file mode 100644 index b0f9b21..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This software consists of contributions made by many individuals, - * listed below: - * - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - * - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", leaded by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - * - */ - -package com.google.zxing.oned.rss.expanded; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.nio.file.Path; -import java.util.HashMap; - -import javax.imageio.ImageIO; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.BufferedImageLuminanceSource; -import com.google.zxing.NotFoundException; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.client.result.ExpandedProductParsedResult; -import com.google.zxing.client.result.ParsedResult; -import com.google.zxing.client.result.ResultParser; -import com.google.zxing.common.AbstractBlackBoxTestCase; -import com.google.zxing.common.BitArray; -import com.google.zxing.common.GlobalHistogramBinarizer; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -public final class RSSExpandedImage2resultTestCase extends Assert { - - @Test - public void testDecodeRow2result2() throws Exception { - // (01)90012345678908(3103)001750 - ExpandedProductParsedResult expected = - new ExpandedProductParsedResult("(01)90012345678908(3103)001750", - "90012345678908", - null, null, null, null, null, null, - "001750", - ExpandedProductParsedResult.KILOGRAM, - "3", null, null, null, new HashMap<>()); - - assertCorrectImage2result("2.png", expected); - } - - private static void assertCorrectImage2result(String fileName, ExpandedProductParsedResult expected) - throws IOException, NotFoundException { - Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); - - BufferedImage image = ImageIO.read(path.toFile()); - BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image))); - int rowNumber = binaryMap.getHeight() / 2; - BitArray row = binaryMap.getBlackRow(rowNumber, null); - - Result theResult; - try { - RSSExpandedReader rssExpandedReader = new RSSExpandedReader(); - theResult = rssExpandedReader.decodeRow(rowNumber, row, null); - } catch (ReaderException re) { - fail(re.toString()); - return; - } - - assertSame(BarcodeFormat.RSS_EXPANDED, theResult.getBarcodeFormat()); - - ParsedResult result = ResultParser.parseResult(theResult); - - assertEquals(expected, result); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2stringTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2stringTestCase.java deleted file mode 100644 index 5a0656e..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2stringTestCase.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.nio.file.Path; - -import javax.imageio.ImageIO; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.BufferedImageLuminanceSource; -import com.google.zxing.NotFoundException; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.common.AbstractBlackBoxTestCase; -import com.google.zxing.common.BitArray; -import com.google.zxing.common.GlobalHistogramBinarizer; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -public final class RSSExpandedImage2stringTestCase extends Assert { - - @Test - public void testDecodeRow2string1() throws Exception { - assertCorrectImage2string("1.png", "(11)100224(17)110224(3102)000100"); - } - - @Test - public void testDecodeRow2string2() throws Exception { - assertCorrectImage2string("2.png", "(01)90012345678908(3103)001750"); - } - - @Test - public void testDecodeRow2string3() throws Exception { - assertCorrectImage2string("3.png", "(10)12A"); - } - - @Test - public void testDecodeRow2string4() throws Exception { - assertCorrectImage2string("4.png", "(01)98898765432106(3202)012345(15)991231"); - } - - @Test - public void testDecodeRow2string5() throws Exception { - assertCorrectImage2string("5.png", "(01)90614141000015(3202)000150"); - } - - @Test - public void testDecodeRow2string7() throws Exception { - assertCorrectImage2string("7.png", "(10)567(11)010101"); - } - - @Test - public void testDecodeRow2string10() throws Exception { - String expected = "(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)012345678901"; - assertCorrectImage2string("10.png", expected); - } - - @Test - public void testDecodeRow2string11() throws Exception { - assertCorrectImage2string("11.png", "(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456"); - } - - @Test - public void testDecodeRow2string12() throws Exception { - assertCorrectImage2string("12.png", "(01)98898765432106(3103)001750"); - } - - @Test - public void testDecodeRow2string13() throws Exception { - assertCorrectImage2string("13.png", "(01)90012345678908(3922)795"); - } - - @Test - public void testDecodeRow2string14() throws Exception { - assertCorrectImage2string("14.png", "(01)90012345678908(3932)0401234"); - } - - @Test - public void testDecodeRow2string15() throws Exception { - assertCorrectImage2string("15.png", "(01)90012345678908(3102)001750(11)100312"); - } - - @Test - public void testDecodeRow2string16() throws Exception { - assertCorrectImage2string("16.png", "(01)90012345678908(3202)001750(11)100312"); - } - - @Test - public void testDecodeRow2string17() throws Exception { - assertCorrectImage2string("17.png", "(01)90012345678908(3102)001750(13)100312"); - } - - @Test - public void testDecodeRow2string18() throws Exception { - assertCorrectImage2string("18.png", "(01)90012345678908(3202)001750(13)100312"); - } - - @Test - public void testDecodeRow2string19() throws Exception { - assertCorrectImage2string("19.png", "(01)90012345678908(3102)001750(15)100312"); - } - - @Test - public void testDecodeRow2string20() throws Exception { - assertCorrectImage2string("20.png", "(01)90012345678908(3202)001750(15)100312"); - } - - @Test - public void testDecodeRow2string21() throws Exception { - assertCorrectImage2string("21.png", "(01)90012345678908(3102)001750(17)100312"); - } - - @Test - public void testDecodeRow2string22() throws Exception { - assertCorrectImage2string("22.png", "(01)90012345678908(3202)001750(17)100312"); - } - - @Test - public void testDecodeRow2string25() throws Exception { - assertCorrectImage2string("25.png", "(10)123"); - } - - @Test - public void testDecodeRow2string26() throws Exception { - assertCorrectImage2string("26.png", "(10)5678(11)010101"); - } - - @Test - public void testDecodeRow2string27() throws Exception { - assertCorrectImage2string("27.png", "(10)1098-1234"); - } - - @Test - public void testDecodeRow2string28() throws Exception { - assertCorrectImage2string("28.png", "(10)1098/1234"); - } - - @Test - public void testDecodeRow2string29() throws Exception { - assertCorrectImage2string("29.png", "(10)1098.1234"); - } - - @Test - public void testDecodeRow2string30() throws Exception { - assertCorrectImage2string("30.png", "(10)1098*1234"); - } - - @Test - public void testDecodeRow2string31() throws Exception { - assertCorrectImage2string("31.png", "(10)1098,1234"); - } - - @Test - public void testDecodeRow2string32() throws Exception { - assertCorrectImage2string("32.png", "(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012"); - } - - private static void assertCorrectImage2string(String fileName, String expected) - throws IOException, NotFoundException { - Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); - - BufferedImage image = ImageIO.read(path.toFile()); - BinaryBitmap binaryMap = - new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image))); - int rowNumber = binaryMap.getHeight() / 2; - BitArray row = binaryMap.getBlackRow(rowNumber, null); - - Result result; - try { - RSSExpandedReader rssExpandedReader = new RSSExpandedReader(); - result = rssExpandedReader.decodeRow(rowNumber, row, null); - } catch (ReaderException re) { - fail(re.toString()); - return; - } - - assertSame(BarcodeFormat.RSS_EXPANDED, result.getBarcodeFormat()); - assertEquals(expected, result.getText()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedInternalTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedInternalTestCase.java deleted file mode 100644 index 34ccdc3..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedInternalTestCase.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; - -import javax.imageio.ImageIO; - -import com.google.zxing.BinaryBitmap; -import com.google.zxing.BufferedImageLuminanceSource; -import com.google.zxing.NotFoundException; -import com.google.zxing.common.AbstractBlackBoxTestCase; -import com.google.zxing.common.BitArray; -import com.google.zxing.common.GlobalHistogramBinarizer; -import com.google.zxing.oned.rss.DataCharacter; -import com.google.zxing.oned.rss.FinderPattern; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -public final class RSSExpandedInternalTestCase extends Assert { - - @Test - public void testFindFinderPatterns() throws Exception { - BufferedImage image = readImage("2.png"); - BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image))); - int rowNumber = binaryMap.getHeight() / 2; - BitArray row = binaryMap.getBlackRow(rowNumber, null); - List previousPairs = new ArrayList<>(); - - RSSExpandedReader rssExpandedReader = new RSSExpandedReader(); - ExpandedPair pair1 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber); - previousPairs.add(pair1); - FinderPattern finderPattern = pair1.getFinderPattern(); - assertNotNull(finderPattern); - assertEquals(0, finderPattern.getValue()); - - ExpandedPair pair2 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber); - previousPairs.add(pair2); - finderPattern = pair2.getFinderPattern(); - assertNotNull(finderPattern); - assertEquals(1, finderPattern.getValue()); - - ExpandedPair pair3 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber); - previousPairs.add(pair3); - finderPattern = pair3.getFinderPattern(); - assertNotNull(finderPattern); - assertEquals(1, finderPattern.getValue()); - - try { - rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber); - // the previous was the last pair - fail(NotFoundException.class.getName() + " expected"); - } catch (NotFoundException nfe) { - // ok - } - } - - @Test - public void testRetrieveNextPairPatterns() throws Exception { - BufferedImage image = readImage("3.png"); - BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image))); - int rowNumber = binaryMap.getHeight() / 2; - BitArray row = binaryMap.getBlackRow(rowNumber, null); - List previousPairs = new ArrayList<>(); - - RSSExpandedReader rssExpandedReader = new RSSExpandedReader(); - ExpandedPair pair1 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber); - previousPairs.add(pair1); - FinderPattern finderPattern = pair1.getFinderPattern(); - assertNotNull(finderPattern); - assertEquals(0, finderPattern.getValue()); - - ExpandedPair pair2 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber); - previousPairs.add(pair2); - finderPattern = pair2.getFinderPattern(); - assertNotNull(finderPattern); - assertEquals(0, finderPattern.getValue()); - } - - @Test - public void testDecodeCheckCharacter() throws Exception { - BufferedImage image = readImage("3.png"); - BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image))); - BitArray row = binaryMap.getBlackRow(binaryMap.getHeight() / 2, null); - - int[] startEnd = {145, 243}; //image pixels where the A1 pattern starts (at 124) and ends (at 214) - int value = 0; // A - FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2); - //{1, 8, 4, 1, 1}; - RSSExpandedReader rssExpandedReader = new RSSExpandedReader(); - DataCharacter dataCharacter = rssExpandedReader.decodeDataCharacter(row, finderPatternA1, true, true); - - assertEquals(98, dataCharacter.getValue()); - } - - @Test - public void testDecodeDataCharacter() throws Exception { - BufferedImage image = readImage("3.png"); - BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image))); - BitArray row = binaryMap.getBlackRow(binaryMap.getHeight() / 2, null); - - int[] startEnd = {145, 243}; //image pixels where the A1 pattern starts (at 124) and ends (at 214) - int value = 0; // A - FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2); - //{1, 8, 4, 1, 1}; - RSSExpandedReader rssExpandedReader = new RSSExpandedReader(); - DataCharacter dataCharacter = rssExpandedReader.decodeDataCharacter(row, finderPatternA1, true, false); - - assertEquals(19, dataCharacter.getValue()); - assertEquals(1007, dataCharacter.getChecksumPortion()); - } - - private static BufferedImage readImage(String fileName) throws IOException { - Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); - return ImageIO.read(path.toFile()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedStackedBlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedStackedBlackBox1TestCase.java deleted file mode 100644 index dabe8b1..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedStackedBlackBox1TestCase.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A test of {@link RSSExpandedReader} against a fixed test set of images including - * stacked RSS barcodes. - */ -public final class RSSExpandedStackedBlackBox1TestCase extends AbstractBlackBoxTestCase { - - public RSSExpandedStackedBlackBox1TestCase() { - super("src/test/resources/blackbox/rssexpandedstacked-1", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); - addTest(59, 64, 0.0f); - addTest(59, 64, 180.0f); - } - -} - diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedStackedBlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedStackedBlackBox2TestCase.java deleted file mode 100644 index ee0e008..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedStackedBlackBox2TestCase.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A test of {@link RSSExpandedReader} against a fixed test set of images including - * stacked RSS barcodes. - */ -public final class RSSExpandedStackedBlackBox2TestCase extends AbstractBlackBoxTestCase { - - public RSSExpandedStackedBlackBox2TestCase() { - super("src/test/resources/blackbox/rssexpandedstacked-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); - addTest(2, 7, 0.0f); - addTest(2, 7, 180.0f); - } - -} - diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedStackedInternalTestCase.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedStackedInternalTestCase.java deleted file mode 100644 index 7b18046..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedStackedInternalTestCase.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import java.util.List; - -import com.google.zxing.oned.OneDReader; -import org.junit.Assert; -import org.junit.Test; - -import com.google.zxing.BinaryBitmap; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.common.BitArray; - -/** - * Tests {@link RSSExpandedReader} handling of stacked RSS barcodes. - */ -public final class RSSExpandedStackedInternalTestCase extends Assert { - - @Test - public void testDecodingRowByRow() throws Exception { - RSSExpandedReader rssExpandedReader = new RSSExpandedReader(); - - BinaryBitmap binaryMap = TestCaseUtil.getBinaryBitmap("src/test/resources/blackbox/rssexpandedstacked-2/1000.png"); - - int firstRowNumber = binaryMap.getHeight() / 3; - BitArray firstRow = binaryMap.getBlackRow(firstRowNumber, null); - try { - rssExpandedReader.decodeRow2pairs(firstRowNumber, firstRow); - fail(NotFoundException.class.getName() + " expected"); - } catch (NotFoundException nfe) { - // ok - } - - assertEquals(1, rssExpandedReader.getRows().size()); - ExpandedRow firstExpandedRow = rssExpandedReader.getRows().get(0); - assertEquals(firstRowNumber, firstExpandedRow.getRowNumber()); - - assertEquals(2, firstExpandedRow.getPairs().size()); - - firstExpandedRow.getPairs().get(1).getFinderPattern().getStartEnd()[1] = 0; - - int secondRowNumber = 2 * binaryMap.getHeight() / 3; - BitArray secondRow = binaryMap.getBlackRow(secondRowNumber, null); - secondRow.reverse(); - - List totalPairs = rssExpandedReader.decodeRow2pairs(secondRowNumber, secondRow); - - Result result = RSSExpandedReader.constructResult(totalPairs); - assertEquals("(01)98898765432106(3202)012345(15)991231", result.getText()); - } - - @Test - public void testCompleteDecode() throws Exception { - OneDReader rssExpandedReader = new RSSExpandedReader(); - - BinaryBitmap binaryMap = TestCaseUtil.getBinaryBitmap("src/test/resources/blackbox/rssexpandedstacked-2/1000.png"); - - Result result = rssExpandedReader.decode(binaryMap); - assertEquals("(01)98898765432106(3202)012345(15)991231", result.getText()); - } - - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/TestCaseUtil.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/TestCaseUtil.java deleted file mode 100644 index dc4af85..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/TestCaseUtil.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.nio.file.Path; - -import javax.imageio.ImageIO; - -import com.google.zxing.BinaryBitmap; -import com.google.zxing.BufferedImageLuminanceSource; -import com.google.zxing.common.AbstractBlackBoxTestCase; -import com.google.zxing.common.GlobalHistogramBinarizer; - -final class TestCaseUtil { - - private TestCaseUtil() { - } - - private static BufferedImage getBufferedImage(String path) throws IOException { - Path file = AbstractBlackBoxTestCase.buildTestBase(path); - return ImageIO.read(file.toFile()); - } - - static BinaryBitmap getBinaryBitmap(String path) throws IOException { - BufferedImage bufferedImage = getBufferedImage(path); - BufferedImageLuminanceSource luminanceSource = new BufferedImageLuminanceSource(bufferedImage); - return new BinaryBitmap(new GlobalHistogramBinarizer(luminanceSource)); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AI013103DecoderTest.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AI013103DecoderTest.java deleted file mode 100644 index 28e3c30..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AI013103DecoderTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.NotFoundException; -import org.junit.Test; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -public final class AI013103DecoderTest extends AbstractDecoderTest { - - private static final String header = "..X.."; - - @Test - public void test0131031() throws Exception { - CharSequence data = header + compressedGtin900123456798908 + compressed15bitWeight1750; - String expected = "(01)90012345678908(3103)001750"; - assertCorrectBinaryString(data, expected); - } - - @Test - public void test0131032() throws Exception { - CharSequence data = header + compressedGtin900000000000008 + compressed15bitWeight0; - String expected = "(01)90000000000003(3103)000000"; - assertCorrectBinaryString(data, expected); - } - - @Test(expected = NotFoundException.class) - public void test013103invalid() throws Exception { - CharSequence data = header + compressedGtin900123456798908 + compressed15bitWeight1750 + ".."; - assertCorrectBinaryString(data, ""); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AI0132023203DecoderTest.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AI0132023203DecoderTest.java deleted file mode 100644 index addf9a9..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AI0132023203DecoderTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import org.junit.Test; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -public final class AI0132023203DecoderTest extends AbstractDecoderTest { - - private static final String header = "..X.X"; - - @Test - public void test0132021() throws Exception { - CharSequence data = header + compressedGtin900123456798908 + compressed15bitWeight1750; - String expected = "(01)90012345678908(3202)001750"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void test0132031() throws Exception { - CharSequence data = header + compressedGtin900123456798908 + compressed15bitWeight11750; - String expected = "(01)90012345678908(3203)001750"; - - assertCorrectBinaryString(data, expected); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AI013X0X1XDecoderTest.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AI013X0X1XDecoderTest.java deleted file mode 100644 index 1781725..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AI013X0X1XDecoderTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import org.junit.Test; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -public final class AI013X0X1XDecoderTest extends AbstractDecoderTest { - - private static final String header310x11 = "..XXX..."; - private static final String header320x11 = "..XXX..X"; - private static final String header310x13 = "..XXX.X."; - private static final String header320x13 = "..XXX.XX"; - private static final String header310x15 = "..XXXX.."; - private static final String header320x15 = "..XXXX.X"; - private static final String header310x17 = "..XXXXX."; - private static final String header320x17 = "..XXXXXX"; - - @Test - public void test01310X1XendDate() throws Exception { - CharSequence data = header310x11 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateEnd; - String expected = "(01)90012345678908(3100)001750"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void test01310X111() throws Exception { - CharSequence data = header310x11 + compressedGtin900123456798908 + compressed20bitWeight1750 + - compressedDateMarch12th2010; - String expected = "(01)90012345678908(3100)001750(11)100312"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void test01320X111() throws Exception { - CharSequence data = header320x11 + compressedGtin900123456798908 + compressed20bitWeight1750 + - compressedDateMarch12th2010; - String expected = "(01)90012345678908(3200)001750(11)100312"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void test01310X131() throws Exception { - CharSequence data = header310x13 + compressedGtin900123456798908 + compressed20bitWeight1750 + - compressedDateMarch12th2010; - String expected = "(01)90012345678908(3100)001750(13)100312"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void test01320X131() throws Exception { - CharSequence data = header320x13 + compressedGtin900123456798908 + compressed20bitWeight1750 + - compressedDateMarch12th2010; - String expected = "(01)90012345678908(3200)001750(13)100312"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void test01310X151() throws Exception { - CharSequence data = header310x15 + compressedGtin900123456798908 + compressed20bitWeight1750 + - compressedDateMarch12th2010; - String expected = "(01)90012345678908(3100)001750(15)100312"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void test01320X151() throws Exception { - CharSequence data = header320x15 + compressedGtin900123456798908 + compressed20bitWeight1750 + - compressedDateMarch12th2010; - String expected = "(01)90012345678908(3200)001750(15)100312"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void test01310X171() throws Exception { - CharSequence data = header310x17 + compressedGtin900123456798908 + compressed20bitWeight1750 + - compressedDateMarch12th2010; - String expected = "(01)90012345678908(3100)001750(17)100312"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void test01320X171() throws Exception { - CharSequence data = header320x17 + compressedGtin900123456798908 + compressed20bitWeight1750 + - compressedDateMarch12th2010; - String expected = "(01)90012345678908(3200)001750(17)100312"; - - assertCorrectBinaryString(data, expected); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AbstractDecoderTest.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AbstractDecoderTest.java deleted file mode 100644 index d3f525d..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AbstractDecoderTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.common.BitArray; -import com.google.zxing.oned.rss.expanded.BinaryUtil; - -import org.junit.Assert; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -abstract class AbstractDecoderTest extends Assert { - - static final String numeric10 = "..X..XX"; - static final String numeric12 = "..X.X.X"; - static final String numeric1FNC1 = "..XXX.X"; - // static final String numericFNC11 = "XXX.XXX"; - - static final String numeric2alpha = "...."; - - static final String alphaA = "X....."; - static final String alphaFNC1 = ".XXXX"; - static final String alpha2numeric = "..."; - static final String alpha2isoiec646 = "..X.."; - - static final String i646B = "X.....X"; - static final String i646C = "X....X."; - static final String i646FNC1 = ".XXXX"; - static final String isoiec6462alpha = "..X.."; - - static final String compressedGtin900123456798908 = ".........X..XXX.X.X.X...XX.XXXXX.XXXX.X."; - static final String compressedGtin900000000000008 = "........................................"; - - static final String compressed15bitWeight1750 = "....XX.XX.X.XX."; - static final String compressed15bitWeight11750 = ".X.XX.XXXX..XX."; - static final String compressed15bitWeight0 = "..............."; - - static final String compressed20bitWeight1750 = ".........XX.XX.X.XX."; - - static final String compressedDateMarch12th2010 = "....XXXX.X..XX.."; - static final String compressedDateEnd = "X..X.XX........."; - - static void assertCorrectBinaryString(CharSequence binaryString, - String expectedNumber) throws NotFoundException, FormatException { - BitArray binary = BinaryUtil.buildBitArrayFromStringWithoutSpaces(binaryString); - AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(binary); - String result = decoder.parseInformation(); - assertEquals(expectedNumber, result); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AnyAIDecoderTest.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AnyAIDecoderTest.java deleted file mode 100644 index b79e636..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/AnyAIDecoderTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import org.junit.Test; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -public final class AnyAIDecoderTest extends AbstractDecoderTest { - - private static final String header = "....."; - - @Test - public void testAnyAIDecoder1() throws Exception { - CharSequence data = header + numeric10 + numeric12 + numeric2alpha + alphaA + alpha2numeric + numeric12; - String expected = "(10)12A12"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void testAnyAIDecoder2() throws Exception { - CharSequence data = header + numeric10 + numeric12 + numeric2alpha + alphaA + alpha2isoiec646 + i646B; - String expected = "(10)12AB"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void testAnyAIDecoder3() throws Exception { - CharSequence data = header + numeric10 + numeric2alpha + alpha2isoiec646 + i646B + i646C + isoiec6462alpha + - alphaA + alpha2numeric + numeric10; - String expected = "(10)BCA10"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void testAnyAIDecodernumericFNC1secondDigit() throws Exception { - CharSequence data = header + numeric10 + numeric1FNC1; - String expected = "(10)1"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void testAnyAIDecoderalphaFNC1() throws Exception { - CharSequence data = header + numeric10 + numeric2alpha + alphaA + alphaFNC1; - String expected = "(10)A"; - - assertCorrectBinaryString(data, expected); - } - - @Test - public void testAnyAIDecoder646FNC1() throws Exception { - CharSequence data = header + numeric10 + numeric2alpha + alphaA + isoiec6462alpha + i646B + i646FNC1; - String expected = "(10)AB"; - - assertCorrectBinaryString(data, expected); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/FieldParserTest.java b/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/FieldParserTest.java deleted file mode 100644 index 9a40ceb..0000000 --- a/port_src/core/src/test/java/com/google/zxing/oned/rss/expanded/decoders/FieldParserTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded.decoders; - -import com.google.zxing.NotFoundException; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -public final class FieldParserTest extends Assert { - - private static void checkFields(String expected) throws NotFoundException { - String field = expected.replace("(", "").replace(")",""); - String actual = FieldParser.parseFieldsInGeneralPurpose(field); - assertEquals(expected, actual); - } - - @Test - public void testParseField() throws Exception { - checkFields("(15)991231(3103)001750(10)12A"); - } - - @Test - public void testParseField2() throws Exception { - checkFields("(15)991231(15)991231(3103)001750(10)12A"); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox1TestCase.java deleted file mode 100644 index c5292b4..0000000 --- a/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox1TestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * This test consists of perfect, computer-generated images. We should have 100% passing. - * - * @author SITA Lab (kevin.osullivan@sita.aero) - */ -public final class PDF417BlackBox1TestCase extends AbstractBlackBoxTestCase { - - public PDF417BlackBox1TestCase() { - super("src/test/resources/blackbox/pdf417-1", new MultiFormatReader(), BarcodeFormat.PDF_417); - addTest(10, 10, 0.0f); - addTest(10, 10, 90.0f); - addTest(10, 10, 180.0f); - addTest(10, 10, 270.0f); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox2TestCase.java deleted file mode 100644 index cb7a60d..0000000 --- a/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox2TestCase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * This test contains 480x240 images captured from an Android device at preview resolution. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class PDF417BlackBox2TestCase extends AbstractBlackBoxTestCase { - - public PDF417BlackBox2TestCase() { - super("src/test/resources/blackbox/pdf417-2", new MultiFormatReader(), BarcodeFormat.PDF_417); - addTest(25, 25, 0, 0, 0.0f); - addTest(25, 25, 0, 0, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox3TestCase.java b/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox3TestCase.java deleted file mode 100644 index 192b877..0000000 --- a/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox3TestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * Tests {@link PDF417Reader} against more sample images. - */ -public final class PDF417BlackBox3TestCase extends AbstractBlackBoxTestCase { - - public PDF417BlackBox3TestCase() { - super("src/test/resources/blackbox/pdf417-3", new MultiFormatReader(), BarcodeFormat.PDF_417); - addTest(19, 19, 0, 0, 0.0f); - addTest(19, 19, 0, 0, 180.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java b/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java deleted file mode 100644 index de4952a..0000000 --- a/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.BufferedImageLuminanceSource; -import com.google.zxing.DecodeHintType; -import com.google.zxing.LuminanceSource; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.ResultMetadataType; -import com.google.zxing.common.AbstractBlackBoxTestCase; -import com.google.zxing.common.HybridBinarizer; -import com.google.zxing.common.TestResult; - -import com.google.zxing.multi.MultipleBarcodeReader; -import org.junit.Test; - -import javax.imageio.ImageIO; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.logging.Logger; - -/** - * This class tests Macro PDF417 barcode specific functionality. It ensures that information, which is split into - * several barcodes can be properly combined again to yield the original data content. - * - * @author Guenther Grau - */ -public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase { - private static final Logger log = Logger.getLogger(AbstractBlackBoxTestCase.class.getSimpleName()); - - private final MultipleBarcodeReader barcodeReader = new PDF417Reader(); - - private final List testResults = new ArrayList<>(); - - public PDF417BlackBox4TestCase() { - super("src/test/resources/blackbox/pdf417-4", null, BarcodeFormat.PDF_417); - testResults.add(new TestResult(3, 3, 0, 0, 0.0f)); - } - - @Test - @Override - public void testBlackBox() throws IOException { - assertFalse(testResults.isEmpty()); - - Map> imageFiles = getImageFileLists(); - int testCount = testResults.size(); - - int[] passedCounts = new int[testCount]; - int[] tryHarderCounts = new int[testCount]; - - Path testBase = getTestBase(); - - for (Entry> testImageGroup : imageFiles.entrySet()) { - log.fine(String.format("Starting Image Group %s", testImageGroup.getKey())); - - String fileBaseName = testImageGroup.getKey(); - String expectedText; - Path expectedTextFile = testBase.resolve(fileBaseName + ".txt"); - if (Files.exists(expectedTextFile)) { - expectedText = readFileAsString(expectedTextFile, StandardCharsets.UTF_8); - } else { - expectedTextFile = testBase.resolve(fileBaseName + ".bin"); - assertTrue(Files.exists(expectedTextFile)); - expectedText = readFileAsString(expectedTextFile, StandardCharsets.ISO_8859_1); - } - - for (int x = 0; x < testCount; x++) { - List results = new ArrayList<>(); - for (Path imageFile : testImageGroup.getValue()) { - BufferedImage image = ImageIO.read(imageFile.toFile()); - float rotation = testResults.get(x).getRotation(); - BufferedImage rotatedImage = rotateImage(image, rotation); - LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage); - BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); - - try { - results.addAll(Arrays.asList(decode(bitmap, false))); - } catch (ReaderException ignored) { - // ignore - } - } - results.sort(Comparator.comparingInt((Result r) -> getMeta(r).getSegmentIndex())); - StringBuilder resultText = new StringBuilder(); - String fileId = null; - for (Result result : results) { - PDF417ResultMetadata resultMetadata = getMeta(result); - assertNotNull("resultMetadata", resultMetadata); - if (fileId == null) { - fileId = resultMetadata.getFileId(); - } - assertEquals("FileId", fileId, resultMetadata.getFileId()); - resultText.append(result.getText()); - } - assertEquals("ExpectedText", expectedText, resultText.toString()); - passedCounts[x]++; - tryHarderCounts[x]++; - } - } - - // Print the results of all tests first - int totalFound = 0; - int totalMustPass = 0; - - int numberOfTests = imageFiles.keySet().size(); - for (int x = 0; x < testResults.size(); x++) { - TestResult testResult = testResults.get(x); - log.info(String.format("Rotation %d degrees:", (int) testResult.getRotation())); - log.info(String.format(" %d of %d images passed (%d required)", passedCounts[x], numberOfTests, - testResult.getMustPassCount())); - log.info(String.format(" %d of %d images passed with try harder (%d required)", tryHarderCounts[x], - numberOfTests, testResult.getTryHarderCount())); - totalFound += passedCounts[x] + tryHarderCounts[x]; - totalMustPass += testResult.getMustPassCount() + testResult.getTryHarderCount(); - } - - int totalTests = numberOfTests * testCount * 2; - log.info(String.format("Decoded %d images out of %d (%d%%, %d required)", totalFound, totalTests, totalFound * - 100 / - totalTests, totalMustPass)); - if (totalFound > totalMustPass) { - log.warning(String.format("+++ Test too lax by %d images", totalFound - totalMustPass)); - } else if (totalFound < totalMustPass) { - log.warning(String.format("--- Test failed by %d images", totalMustPass - totalFound)); - } - - // Then run through again and assert if any failed - for (int x = 0; x < testCount; x++) { - TestResult testResult = testResults.get(x); - String label = "Rotation " + testResult.getRotation() + " degrees: Too many images failed"; - assertTrue(label, passedCounts[x] >= testResult.getMustPassCount()); - assertTrue("Try harder, " + label, tryHarderCounts[x] >= testResult.getTryHarderCount()); - } - } - - private static PDF417ResultMetadata getMeta(Result result) { - return result.getResultMetadata() == null ? null : (PDF417ResultMetadata) result.getResultMetadata().get( - ResultMetadataType.PDF417_EXTRA_METADATA); - } - - private Result[] decode(BinaryBitmap source, boolean tryHarder) throws ReaderException { - Map hints = new EnumMap<>(DecodeHintType.class); - if (tryHarder) { - hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); - } - - return barcodeReader.decodeMultiple(source, hints); - } - - private Map> getImageFileLists() throws IOException { - Map> result = new HashMap<>(); - for (Path file : getImageFiles()) { - String testImageFileName = file.getFileName().toString(); - String fileBaseName = testImageFileName.substring(0, testImageFileName.indexOf('-')); - List files = result.computeIfAbsent(fileBaseName, k -> new ArrayList<>()); - files.add(file); - } - return result; - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417WriterTestCase.java b/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417WriterTestCase.java deleted file mode 100644 index fff0f32..0000000 --- a/port_src/core/src/test/java/com/google/zxing/pdf417/PDF417WriterTestCase.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2016 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417; - -import java.util.EnumMap; -import java.util.Map; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.WriterException; -import com.google.zxing.common.BitMatrix; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link PDF417Writer}. - */ -public final class PDF417WriterTestCase extends Assert { - - @SuppressWarnings("checkstyle:lineLength") - @Test - public void testDataMatrixImageWriter() throws WriterException { - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.MARGIN, 0); - int size = 64; - PDF417Writer writer = new PDF417Writer(); - BitMatrix matrix = writer.encode("Hello Google", BarcodeFormat.PDF_417, size, size, hints); - assertNotNull(matrix); - String expected = - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n" + - "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n"; - assertEquals(expected, matrix.toString()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/pdf417/decoder/PDF417DecoderTestCase.java b/port_src/core/src/test/java/com/google/zxing/pdf417/decoder/PDF417DecoderTestCase.java deleted file mode 100644 index e384178..0000000 --- a/port_src/core/src/test/java/com/google/zxing/pdf417/decoder/PDF417DecoderTestCase.java +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.WriterException; -import com.google.zxing.pdf417.PDF417ResultMetadata; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.pdf417.encoder.Compaction; -import com.google.zxing.pdf417.encoder.PDF417HighLevelEncoderTestAdapter; - -import org.junit.Assert; -import org.junit.Test; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.Random; - -/** - * Tests {@link DecodedBitStreamParser}. - */ -public class PDF417DecoderTestCase extends Assert { - - /** - * Tests the first sample given in ISO/IEC 15438:2015(E) - Annex H.4 - */ - @Test - public void testStandardSample1() throws FormatException { - PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); - int[] sampleCodes = {20, 928, 111, 100, 17, 53, 923, 1, 111, 104, 923, 3, 64, 416, 34, 923, 4, 258, 446, 67, - // we should never reach these - 1000, 1000, 1000}; - - DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 2, resultMetadata); - - assertEquals(0, resultMetadata.getSegmentIndex()); - assertEquals("017053", resultMetadata.getFileId()); - assertFalse(resultMetadata.isLastSegment()); - assertEquals(4, resultMetadata.getSegmentCount()); - assertEquals("CEN BE", resultMetadata.getSender()); - assertEquals("ISO CH", resultMetadata.getAddressee()); - - @SuppressWarnings("deprecation") - int[] optionalData = resultMetadata.getOptionalData(); - assertEquals("first element of optional array should be the first field identifier", 1, optionalData[0]); - assertEquals("last element of optional array should be the last codeword of the last field", - 67, optionalData[optionalData.length - 1]); - } - - - /** - * Tests the second given in ISO/IEC 15438:2015(E) - Annex H.4 - */ - @Test - public void testStandardSample2() throws FormatException { - PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); - int[] sampleCodes = {11, 928, 111, 103, 17, 53, 923, 1, 111, 104, 922, - // we should never reach these - 1000, 1000, 1000}; - - DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 2, resultMetadata); - - assertEquals(3, resultMetadata.getSegmentIndex()); - assertEquals("017053", resultMetadata.getFileId()); - assertTrue(resultMetadata.isLastSegment()); - assertEquals(4, resultMetadata.getSegmentCount()); - assertNull(resultMetadata.getAddressee()); - assertNull(resultMetadata.getSender()); - - @SuppressWarnings("deprecation") - int[] optionalData = resultMetadata.getOptionalData(); - assertEquals("first element of optional array should be the first field identifier", 1, optionalData[0]); - assertEquals("last element of optional array should be the last codeword of the last field", - 104, optionalData[optionalData.length - 1]); - } - - - /** - * Tests the example given in ISO/IEC 15438:2015(E) - Annex H.6 - */ - @Test - public void testStandardSample3() throws FormatException { - PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); - int[] sampleCodes = {7, 928, 111, 100, 100, 200, 300, - 0}; // Final dummy ECC codeword required to avoid ArrayIndexOutOfBounds - - DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 2, resultMetadata); - - assertEquals(0, resultMetadata.getSegmentIndex()); - assertEquals("100200300", resultMetadata.getFileId()); - assertFalse(resultMetadata.isLastSegment()); - assertEquals(-1, resultMetadata.getSegmentCount()); - assertNull(resultMetadata.getAddressee()); - assertNull(resultMetadata.getSender()); - assertNull(resultMetadata.getOptionalData()); - - // Check that symbol containing no data except Macro is accepted (see note in Annex H.2) - DecoderResult decoderResult = DecodedBitStreamParser.decode(sampleCodes, "0"); - assertEquals("", decoderResult.getText()); - assertNotNull(decoderResult.getOther()); - } - - @Test - public void testSampleWithFilename() throws FormatException { - int[] sampleCodes = {23, 477, 928, 111, 100, 0, 252, 21, 86, 923, 0, 815, 251, 133, 12, 148, 537, 593, - 599, 923, 1, 111, 102, 98, 311, 355, 522, 920, 779, 40, 628, 33, 749, 267, 506, 213, 928, 465, 248, - 493, 72, 780, 699, 780, 493, 755, 84, 198, 628, 368, 156, 198, 809, 19, 113}; - PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); - - DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 3, resultMetadata); - - assertEquals(0, resultMetadata.getSegmentIndex()); - assertEquals("000252021086", resultMetadata.getFileId()); - assertFalse(resultMetadata.isLastSegment()); - assertEquals(2, resultMetadata.getSegmentCount()); - assertNull(resultMetadata.getAddressee()); - assertNull(resultMetadata.getSender()); - assertEquals("filename.txt", resultMetadata.getFileName()); - } - - @Test - public void testSampleWithNumericValues() throws FormatException { - int[] sampleCodes = {25, 477, 928, 111, 100, 0, 252, 21, 86, 923, 2, 2, 0, 1, 0, 0, 0, 923, 5, 130, 923, - 6, 1, 500, 13, 0}; - PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); - - DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 3, resultMetadata); - - assertEquals(0, resultMetadata.getSegmentIndex()); - assertEquals("000252021086", resultMetadata.getFileId()); - assertFalse(resultMetadata.isLastSegment()); - - assertEquals(180980729000000L, resultMetadata.getTimestamp()); - assertEquals(30, resultMetadata.getFileSize()); - assertEquals(260013, resultMetadata.getChecksum()); - } - - @Test - public void testSampleWithMacroTerminatorOnly() throws FormatException { - int[] sampleCodes = {7, 477, 928, 222, 198, 0, 922}; - PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); - - DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 3, resultMetadata); - - assertEquals(99998, resultMetadata.getSegmentIndex()); - assertEquals("000", resultMetadata.getFileId()); - assertTrue(resultMetadata.isLastSegment()); - assertEquals(-1, resultMetadata.getSegmentCount()); - assertNull(resultMetadata.getOptionalData()); - } - - @Test(expected = FormatException.class) - public void testSampleWithBadSequenceIndexMacro() throws FormatException { - int[] sampleCodes = {3, 928, 222, 0}; - PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); - DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 2, resultMetadata); - } - - @Test(expected = FormatException.class) - public void testSampleWithNoFileIdMacro() throws FormatException { - int[] sampleCodes = {4, 928, 222, 198, 0}; - PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); - DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 2, resultMetadata); - } - - @Test(expected = FormatException.class) - public void testSampleWithNoDataNoMacro() throws FormatException { - int[] sampleCodes = {3, 899, 899, 0}; - DecodedBitStreamParser.decode(sampleCodes, "0"); - } - - @Test - public void testUppercase() throws WriterException, FormatException { - //encodeDecode("", 0); - performEncodeTest('A', new int[] { 3, 4, 5, 6, 4, 4, 5, 5}); - } - - @Test - public void testNumeric() throws WriterException, FormatException { - performEncodeTest('1', new int[] { 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10}); - } - - @Test - public void testByte() throws WriterException, FormatException { - performEncodeTest('\u00c4', new int[] { 3, 4, 5, 6, 7, 7, 8}); - } - - @Test - public void testUppercaseLowercaseMix1() throws WriterException, FormatException { - encodeDecode("aA", 4); - encodeDecode("aAa", 5); - encodeDecode("Aa", 4); - encodeDecode("Aaa", 5); - encodeDecode("AaA", 5); - encodeDecode("AaaA", 6); - encodeDecode("Aaaa", 6); - encodeDecode("AaAaA", 5); - encodeDecode("AaaAaaA", 6); - encodeDecode("AaaAAaaA", 7); - } - - @Test - public void testPunctuation() throws WriterException, FormatException { - performEncodeTest(';', new int[] { 3, 4, 5, 6, 6, 7, 8}); - encodeDecode(";;;;;;;;;;;;;;;;", 17); - } - - @Test - public void testUppercaseLowercaseMix2() throws WriterException, FormatException { - performPermutationTest(new char[] {'A', 'a'}, 10, 8972); - } - - @Test - public void testUppercaseNumericMix() throws WriterException, FormatException { - performPermutationTest(new char[] {'A', '1'}, 14, 192510); - } - - @Test - public void testUppercaseMixedMix() throws WriterException, FormatException { - performPermutationTest(new char[] {'A', '1', ' ', ';'}, 7, 106060); - } - - @Test - public void testUppercasePunctuationMix() throws WriterException, FormatException { - performPermutationTest(new char[] {'A', ';'}, 10, 8967); - } - - @Test - public void testUppercaseByteMix() throws WriterException, FormatException { - performPermutationTest(new char[] {'A', '\u00c4'}, 10, 11222); - } - - @Test - public void testLowercaseByteMix() throws WriterException, FormatException { - performPermutationTest(new char[] {'a', '\u00c4'}, 10, 11233); - } - - public void testUppercaseLowercaseNumericMix() throws WriterException, FormatException { - performPermutationTest(new char[] {'A', 'a', '1'}, 7, 15491); - } - - @Test - public void testUppercaseLowercasePunctuationMix() throws WriterException, FormatException { - performPermutationTest(new char[] {'A', 'a', ';'}, 7, 15491); - } - - @Test - public void testUppercaseLowercaseByteMix() throws WriterException, FormatException { - performPermutationTest(new char[] {'A', 'a', '\u00c4'}, 7, 17288); - } - - @Test - public void testLowercasePunctuationByteMix() throws WriterException, FormatException { - performPermutationTest(new char[] {'a', ';', '\u00c4'}, 7, 17427); - } - - @Test - public void testUppercaseLowercaseNumericPunctuationMix() throws WriterException, FormatException { - performPermutationTest(new char[] {'A', 'a', '1', ';'}, 7, 120479); - } - - @Test - public void testBinaryData() throws WriterException, FormatException { - byte[] bytes = new byte[500]; - Random random = new Random(0); - int total = 0; - for (int i = 0; i < 10000; i++) { - random.nextBytes(bytes); - total += encodeDecode(new String(bytes, StandardCharsets.ISO_8859_1)); - } - assertEquals(4190044, total); - } - - @Test - public void testECIEnglishHiragana() throws Exception { - //multi ECI UTF-8, UTF-16 and ISO-8859-1 - performECITest(new char[] {'a', '1', '\u3040'}, new float[] {20f, 1f, 10f}, 105825, 110914); - } - - @Test - public void testECIEnglishKatakana() throws Exception { - //multi ECI UTF-8, UTF-16 and ISO-8859-1 - performECITest(new char[] {'a', '1', '\u30a0'}, new float[] {20f, 1f, 10f}, 109177, 110914); - } - - @Test - public void testECIEnglishHalfWidthKatakana() throws Exception { - //single ECI - performECITest(new char[] {'a', '1', '\uff80'}, new float[] {20f, 1f, 10f}, 80617, 110914); - } - - @Test - public void testECIEnglishChinese() throws Exception { - //single ECI - performECITest(new char[] {'a', '1', '\u4e00'}, new float[] {20f, 1f, 10f}, 95797, 110914); - } - - @Test - public void testECIGermanCyrillic() throws Exception { - //single ECI since the German Umlaut is in ISO-8859-1 - performECITest(new char[] {'a', '1', '\u00c4', '\u042f'}, new float[] {20f, 1f, 1f, 10f}, 80755, 96007); - } - - @Test - public void testECIEnglishCzechCyrillic1() throws Exception { - //multi ECI between ISO-8859-2 and ISO-8859-5 - performECITest(new char[] {'a', '1', '\u010c', '\u042f'}, new float[] {10f, 1f, 10f, 10f}, 102824, 124525); - } - - @Test - public void testECIEnglishCzechCyrillic2() throws Exception { - //multi ECI between ISO-8859-2 and ISO-8859-5 - performECITest(new char[] {'a', '1', '\u010c', '\u042f'}, new float[] {40f, 1f, 10f, 10f}, 81321, 88236); - } - - @Test - public void testECIEnglishArabicCyrillic() throws Exception { - //multi ECI between UTF-8 (ISO-8859-6 is excluded in CharacterSetECI) and ISO-8859-5 - performECITest(new char[] {'a', '1', '\u0620', '\u042f'}, new float[] {10f, 1f, 10f, 10f}, 118510, 124525); - } - - @Test - public void testBinaryMultiECI() throws Exception { - //Test the cases described in 5.5.5.3 "ECI and Byte Compaction mode using latch 924 and 901" - performDecodeTest(new int[] {5, 927, 4, 913, 200}, "\u010c"); - performDecodeTest(new int[] {9, 927, 4, 913, 200, 927, 7, 913, 207}, "\u010c\u042f"); - performDecodeTest(new int[] {9, 927, 4, 901, 200, 927, 7, 901, 207}, "\u010c\u042f"); - performDecodeTest(new int[] {8, 927, 4, 901, 200, 927, 7, 207}, "\u010c\u042f"); - performDecodeTest(new int[] {14, 927, 4, 901, 200, 927, 7, 207, 927, 4, 200, 927, 7, 207}, - "\u010c\u042f\u010c\u042f"); - performDecodeTest(new int[] {16, 927, 4, 924, 336, 432, 197, 51, 300, 927, 7, 348, 231, 311, 858, 567}, - "\u010c\u010c\u010c\u010c\u010c\u010c\u042f\u042f\u042f\u042f\u042f\u042f"); - } - - private static void encodeDecode(String input, int expectedLength) throws WriterException, FormatException { - assertEquals(expectedLength, encodeDecode(input)); - } - - private static int encodeDecode(String input) throws WriterException, FormatException { - return encodeDecode(input, null, false, true); - } - - private static int encodeDecode(String input, Charset charset, boolean autoECI, boolean decode) - throws WriterException, FormatException { - String s = PDF417HighLevelEncoderTestAdapter.encodeHighLevel(input, Compaction.AUTO, charset, autoECI); - if (decode) { - int[] codewords = new int[s.length() + 1]; - codewords[0] = codewords.length; - for (int i = 1; i < codewords.length; i++) { - codewords[i] = s.charAt(i - 1); - } - performDecodeTest(codewords, input); - } - return s.length() + 1; - } - - private static int getEndIndex(int length, char[] chars) { - double decimalLength = Math.log10(chars.length); - return (int) Math.ceil(Math.pow(10, decimalLength * length)); - } - - private static String generatePermutation(int index, int length, char[] chars) { - int N = chars.length; - String baseNNumber = Integer.toString(index, N); - while (baseNNumber.length() < length) { - baseNNumber = "0" + baseNNumber; - } - String prefix = ""; - for (int i = 0; i < baseNNumber.length(); i++) { - prefix += chars[baseNNumber.charAt(i) - '0']; - } - return prefix; - } - - private static void performPermutationTest(char[] chars, int length, int expectedTotal) throws WriterException, - FormatException { - int endIndex = getEndIndex(length, chars); - int total = 0; - for (int i = 0; i < endIndex; i++) { - total += encodeDecode(generatePermutation(i, length, chars)); - } - assertEquals(expectedTotal, total); - } - - private static void performEncodeTest(char c, int[] expectedLengths) throws WriterException, FormatException { - for (int i = 0; i < expectedLengths.length; i++) { - StringBuilder sb = new StringBuilder(); - for (int j = 0; j <= i; j++) { - sb.append(c); - } - encodeDecode(sb.toString(), expectedLengths[i]); - } - } - - private static void performDecodeTest(int[] codewords, String expectedResult) throws FormatException { - DecoderResult result = DecodedBitStreamParser.decode(codewords, "0"); - assertEquals(expectedResult, result.getText()); - } - - private static void performECITest(char[] chars, - float[] weights, - int expectedMinLength, - int expectedUTFLength) throws WriterException, FormatException { - Random random = new Random(0); - int minLength = 0; - int utfLength = 0; - for (int i = 0; i < 1000; i++) { - String s = generateText(random, 100, chars, weights); - minLength += encodeDecode(s, null, true, true); - utfLength += encodeDecode(s, StandardCharsets.UTF_8, false, true); - } - assertEquals(expectedMinLength, minLength); - assertEquals(expectedUTFLength, utfLength); - } - - private static String generateText(Random random, int maxWidth, char[] chars, float[] weights) { - StringBuilder result = new StringBuilder(); - final int maxWordWidth = 7; - float total = 0; - for (int i = 0; i < weights.length; i++) { - total += weights[i]; - } - for (int i = 0; i < weights.length; i++) { - weights[i] /= total; - } - int cnt = 0; - do { - float maxValue = 0; - int maxIndex = 0; - for (int j = 0; j < weights.length; j++) { - float value = random.nextFloat() * weights[j]; - if (value > maxValue) { - maxValue = value; - maxIndex = j; - } - } - final float wordLength = maxWordWidth * random.nextFloat(); - if (wordLength > 0 && result.length() > 0) { - result.append(' '); - } - for (int j = 0; j < wordLength; j++) { - char c = chars[maxIndex]; - if (j == 0 && c >= 'a' && c <= 'z' && random.nextBoolean()) { - c = (char) (c - 'a' + 'A'); - } - result.append(c); - } - if (cnt % 2 != 0 && random.nextBoolean()) { - result.append('.'); - } - cnt++; - } while (result.length() < maxWidth - maxWordWidth); - return result.toString(); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/pdf417/decoder/ec/AbstractErrorCorrectionTestCase.java b/port_src/core/src/test/java/com/google/zxing/pdf417/decoder/ec/AbstractErrorCorrectionTestCase.java deleted file mode 100644 index b017f61..0000000 --- a/port_src/core/src/test/java/com/google/zxing/pdf417/decoder/ec/AbstractErrorCorrectionTestCase.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder.ec; - -import com.google.zxing.common.reedsolomon.ReedSolomonTestCase; -import org.junit.Assert; - -import java.util.BitSet; -import java.util.Random; - -/** - * @author Sean Owen - */ -abstract class AbstractErrorCorrectionTestCase extends Assert { - - static void corrupt(int[] received, int howMany, Random random) { - ReedSolomonTestCase.corrupt(received, howMany, random, 929); - } - - static int[] erase(int[] received, int howMany, Random random) { - BitSet erased = new BitSet(received.length); - int[] erasures = new int[howMany]; - int erasureOffset = 0; - for (int j = 0; j < howMany; j++) { - int location = random.nextInt(received.length); - if (erased.get(location)) { - j--; - } else { - erased.set(location); - received[location] = 0; - erasures[erasureOffset++] = location; - } - } - return erasures; - } - - static Random getRandom() { - return new Random(0xDEADBEEF); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/pdf417/decoder/ec/ErrorCorrectionTestCase.java b/port_src/core/src/test/java/com/google/zxing/pdf417/decoder/ec/ErrorCorrectionTestCase.java deleted file mode 100644 index 7af2ae8..0000000 --- a/port_src/core/src/test/java/com/google/zxing/pdf417/decoder/ec/ErrorCorrectionTestCase.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.decoder.ec; - -import com.google.zxing.ChecksumException; - -import org.junit.Test; - -import java.util.Random; - -/** - * @author Sean Owen - */ -public final class ErrorCorrectionTestCase extends AbstractErrorCorrectionTestCase { - - private static final int[] PDF417_TEST = { - 48, 901, 56, 141, 627, 856, 330, 69, 244, 900, 852, 169, 843, 895, 852, 895, 913, 154, 845, 778, 387, 89, 869, - 901, 219, 474, 543, 650, 169, 201, 9, 160, 35, 70, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, - 900, 900}; - private static final int[] PDF417_TEST_WITH_EC = { - 48, 901, 56, 141, 627, 856, 330, 69, 244, 900, 852, 169, 843, 895, 852, 895, 913, 154, 845, 778, 387, 89, 869, - 901, 219, 474, 543, 650, 169, 201, 9, 160, 35, 70, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, - 900, 900, 769, 843, 591, 910, 605, 206, 706, 917, 371, 469, 79, 718, 47, 777, 249, 262, 193, 620, 597, 477, 450, - 806, 908, 309, 153, 871, 686, 838, 185, 674, 68, 679, 691, 794, 497, 479, 234, 250, 496, 43, 347, 582, 882, 536, - 322, 317, 273, 194, 917, 237, 420, 859, 340, 115, 222, 808, 866, 836, 417, 121, 833, 459, 64, 159}; - private static final int ECC_BYTES = PDF417_TEST_WITH_EC.length - PDF417_TEST.length; - private static final int ERROR_LIMIT = ECC_BYTES; - private static final int MAX_ERRORS = ERROR_LIMIT / 2; - private static final int MAX_ERASURES = ERROR_LIMIT; - - private final ErrorCorrection ec = new ErrorCorrection(); - - @Test - public void testNoError() throws ChecksumException { - int[] received = PDF417_TEST_WITH_EC.clone(); - // no errors - checkDecode(received); - } - - @Test - public void testOneError() throws ChecksumException { - Random random = getRandom(); - for (int i = 0; i < PDF417_TEST_WITH_EC.length; i++) { - int[] received = PDF417_TEST_WITH_EC.clone(); - received[i] = random.nextInt(256); - checkDecode(received); - } - } - - @Test - public void testMaxErrors() throws ChecksumException { - Random random = getRandom(); - for (int testIterations = 0; testIterations < 100; testIterations++) { // # iterations is kind of arbitrary - int[] received = PDF417_TEST_WITH_EC.clone(); - corrupt(received, MAX_ERRORS, random); - checkDecode(received); - } - } - - @Test - public void testTooManyErrors() { - int[] received = PDF417_TEST_WITH_EC.clone(); - Random random = getRandom(); - corrupt(received, MAX_ERRORS + 1, random); - try { - checkDecode(received); - fail("Should not have decoded"); - } catch (ChecksumException ce) { - // good - } - } - - private void checkDecode(int[] received) throws ChecksumException { - checkDecode(received, new int[0]); - } - - private void checkDecode(int[] received, int[] erasures) throws ChecksumException { - ec.decode(received, ECC_BYTES, erasures); - for (int i = 0; i < PDF417_TEST.length; i++) { - assertEquals(received[i], PDF417_TEST[i]); - } - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/pdf417/encoder/PDF417EncoderTestCase.java b/port_src/core/src/test/java/com/google/zxing/pdf417/encoder/PDF417EncoderTestCase.java deleted file mode 100644 index f0c9aa5..0000000 --- a/port_src/core/src/test/java/com/google/zxing/pdf417/encoder/PDF417EncoderTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2014 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.pdf417.encoder; - -import com.google.zxing.WriterException; - -import java.nio.charset.StandardCharsets; - -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link PDF417HighLevelEncoder}. - */ -public final class PDF417EncoderTestCase extends Assert { - - @Test - public void testEncodeAuto() throws Exception { - String encoded = PDF417HighLevelEncoder.encodeHighLevel( - "ABCD", Compaction.AUTO, StandardCharsets.UTF_8, false); - assertEquals("\u039f\u001A\u0385ABCD", encoded); - } - - @Test - public void testEncodeAutoWithSpecialChars() throws Exception { - // Just check if this does not throw an exception - PDF417HighLevelEncoder.encodeHighLevel( - "1%§s ?aG$", Compaction.AUTO, StandardCharsets.UTF_8, false); - } - - @Test - public void testEncodeIso88591WithSpecialChars() throws Exception { - // Just check if this does not throw an exception - PDF417HighLevelEncoder.encodeHighLevel("asdfg§asd", Compaction.AUTO, StandardCharsets.ISO_8859_1, false); - } - - @Test - public void testEncodeText() throws Exception { - String encoded = PDF417HighLevelEncoder.encodeHighLevel( - "ABCD", Compaction.TEXT, StandardCharsets.UTF_8, false); - assertEquals("Ο\u001A\u0001?", encoded); - } - - @Test - public void testEncodeNumeric() throws Exception { - String encoded = PDF417HighLevelEncoder.encodeHighLevel( - "1234", Compaction.NUMERIC, StandardCharsets.UTF_8, false); - assertEquals("\u039f\u001A\u0386\f\u01b2", encoded); - } - - @Test - public void testEncodeByte() throws Exception { - String encoded = PDF417HighLevelEncoder.encodeHighLevel( - "abcd", Compaction.BYTE, StandardCharsets.UTF_8, false); - assertEquals("\u039f\u001A\u0385abcd", encoded); - } - - @Test(expected = WriterException.class) - public void testEncodeEmptyString() throws Exception { - PDF417HighLevelEncoder.encodeHighLevel("", Compaction.AUTO, null, false); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox1TestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox1TestCase.java deleted file mode 100644 index 805db74..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox1TestCase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class QRCodeBlackBox1TestCase extends AbstractBlackBoxTestCase { - - public QRCodeBlackBox1TestCase() { - super("src/test/resources/blackbox/qrcode-1", new MultiFormatReader(), BarcodeFormat.QR_CODE); - addTest(17, 17, 0.0f); - addTest(14, 14, 90.0f); - addTest(17, 17, 180.0f); - addTest(14, 14, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox2TestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox2TestCase.java deleted file mode 100644 index 7c11dad..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox2TestCase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author Sean Owen - */ -public final class QRCodeBlackBox2TestCase extends AbstractBlackBoxTestCase { - - public QRCodeBlackBox2TestCase() { - super("src/test/resources/blackbox/qrcode-2", new MultiFormatReader(), BarcodeFormat.QR_CODE); - addTest(31, 31, 0.0f); - addTest(30, 30, 90.0f); - addTest(30, 30, 180.0f); - addTest(30, 30, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox3TestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox3TestCase.java deleted file mode 100644 index 9968608..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox3TestCase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class QRCodeBlackBox3TestCase extends AbstractBlackBoxTestCase { - - public QRCodeBlackBox3TestCase() { - super("src/test/resources/blackbox/qrcode-3", new MultiFormatReader(), BarcodeFormat.QR_CODE); - addTest(38, 38, 0.0f); - addTest(39, 39, 90.0f); - addTest(36, 36, 180.0f); - addTest(39, 39, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox4TestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox4TestCase.java deleted file mode 100644 index 8693aff..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox4TestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * Tests of various QR Codes from t-shirts, which are notoriously not flat. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class QRCodeBlackBox4TestCase extends AbstractBlackBoxTestCase { - - public QRCodeBlackBox4TestCase() { - super("src/test/resources/blackbox/qrcode-4", new MultiFormatReader(), BarcodeFormat.QR_CODE); - addTest(36, 36, 0.0f); - addTest(35, 35, 90.0f); - addTest(35, 35, 180.0f); - addTest(35, 35, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox5TestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox5TestCase.java deleted file mode 100644 index 404bc45..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox5TestCase.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * Some very difficult exposure conditions including self-shadowing, which happens a lot when - * pointing down at a barcode (i.e. the phone's shadow falls across part of the image). - * The global histogram gets about 5/15, where the local one gets 15/15. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class QRCodeBlackBox5TestCase extends AbstractBlackBoxTestCase { - - public QRCodeBlackBox5TestCase() { - super("src/test/resources/blackbox/qrcode-5", new MultiFormatReader(), BarcodeFormat.QR_CODE); - addTest(19, 19, 0.0f); - addTest(19, 19, 90.0f); - addTest(19, 19, 180.0f); - addTest(19, 19, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox6TestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox6TestCase.java deleted file mode 100644 index 531ffa6..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeBlackBox6TestCase.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * These tests are supplied by Tim Gernat and test finder pattern detection at small size and under - * rotation, which was a weak spot. - */ -public final class QRCodeBlackBox6TestCase extends AbstractBlackBoxTestCase { - - public QRCodeBlackBox6TestCase() { - super("src/test/resources/blackbox/qrcode-6", new MultiFormatReader(), BarcodeFormat.QR_CODE); - addTest(15, 15, 0.0f); - addTest(14, 14, 90.0f); - addTest(13, 13, 180.0f); - addTest(14, 14, 270.0f); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeWriterTestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeWriterTestCase.java deleted file mode 100644 index c16d295..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/QRCodeWriterTestCase.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.Writer; -import com.google.zxing.WriterException; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; -import org.junit.Assert; -import org.junit.Test; - -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.EnumMap; -import java.util.Map; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author dswitkin@google.com (Daniel Switkin) - ported and expanded from C++ - */ -public final class QRCodeWriterTestCase extends Assert { - - private static final Path BASE_IMAGE_PATH = Paths.get("src/test/resources/golden/qrcode/"); - - private static BufferedImage loadImage(String fileName) throws IOException { - Path file = BASE_IMAGE_PATH.resolve(fileName); - if (!Files.exists(file)) { - // try starting with 'core' since the test base is often given as the project root - file = Paths.get("core/").resolve(BASE_IMAGE_PATH).resolve(fileName); - } - assertTrue("Please download and install test images, and run from the 'core' directory", Files.exists(file)); - return ImageIO.read(file.toFile()); - } - - // In case the golden images are not monochromatic, convert the RGB values to greyscale. - private static BitMatrix createMatrixFromImage(BufferedImage image) { - int width = image.getWidth(); - int height = image.getHeight(); - int[] pixels = new int[width * height]; - image.getRGB(0, 0, width, height, pixels, 0, width); - - BitMatrix matrix = new BitMatrix(width, height); - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - int pixel = pixels[y * width + x]; - int luminance = (306 * ((pixel >> 16) & 0xFF) + - 601 * ((pixel >> 8) & 0xFF) + - 117 * (pixel & 0xFF)) >> 10; - if (luminance <= 0x7F) { - matrix.set(x, y); - } - } - } - return matrix; - } - - @Test - public void testQRCodeWriter() throws WriterException { - // The QR should be multiplied up to fit, with extra padding if necessary - int bigEnough = 256; - Writer writer = new QRCodeWriter(); - BitMatrix matrix = writer.encode("http://www.google.com/", BarcodeFormat.QR_CODE, bigEnough, - bigEnough, null); - assertNotNull(matrix); - assertEquals(bigEnough, matrix.getWidth()); - assertEquals(bigEnough, matrix.getHeight()); - - // The QR will not fit in this size, so the matrix should come back bigger - int tooSmall = 20; - matrix = writer.encode("http://www.google.com/", BarcodeFormat.QR_CODE, tooSmall, - tooSmall, null); - assertNotNull(matrix); - assertTrue(tooSmall < matrix.getWidth()); - assertTrue(tooSmall < matrix.getHeight()); - - // We should also be able to handle non-square requests by padding them - int strangeWidth = 500; - int strangeHeight = 100; - matrix = writer.encode("http://www.google.com/", BarcodeFormat.QR_CODE, strangeWidth, - strangeHeight, null); - assertNotNull(matrix); - assertEquals(strangeWidth, matrix.getWidth()); - assertEquals(strangeHeight, matrix.getHeight()); - } - - private static void compareToGoldenFile(String contents, - ErrorCorrectionLevel ecLevel, - int resolution, - String fileName) throws WriterException, IOException { - - BufferedImage image = loadImage(fileName); - assertNotNull(image); - BitMatrix goldenResult = createMatrixFromImage(image); - assertNotNull(goldenResult); - - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.ERROR_CORRECTION, ecLevel); - Writer writer = new QRCodeWriter(); - BitMatrix generatedResult = writer.encode(contents, BarcodeFormat.QR_CODE, resolution, - resolution, hints); - - assertEquals(resolution, generatedResult.getWidth()); - assertEquals(resolution, generatedResult.getHeight()); - assertEquals(goldenResult, generatedResult); - } - - // Golden images are generated with "qrcode_sample.cc". The images are checked with both eye balls - // and cell phones. We expect pixel-perfect results, because the error correction level is known, - // and the pixel dimensions matches exactly. - @Test - public void testRegressionTest() throws Exception { - compareToGoldenFile("http://www.google.com/", ErrorCorrectionLevel.M, 99, - "renderer-test-01.png"); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/DataMaskTestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/DataMaskTestCase.java deleted file mode 100644 index 913c7d3..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/DataMaskTestCase.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -import com.google.zxing.common.BitMatrix; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Sean Owen - */ -public final class DataMaskTestCase extends Assert { - - @Test - public void testMask0() { - testMaskAcrossDimensions(0, (i, j) -> (i + j) % 2 == 0); - } - - @Test - public void testMask1() { - testMaskAcrossDimensions(1, (i, j) -> i % 2 == 0); - } - - @Test - public void testMask2() { - testMaskAcrossDimensions(2, (i, j) -> j % 3 == 0); - } - - @Test - public void testMask3() { - testMaskAcrossDimensions(3, (i, j) -> (i + j) % 3 == 0); - } - - @Test - public void testMask4() { - testMaskAcrossDimensions(4, (i, j) -> (i / 2 + j / 3) % 2 == 0); - } - - @Test - public void testMask5() { - testMaskAcrossDimensions(5, (i, j) -> (i * j) % 2 + (i * j) % 3 == 0); - } - - @Test - public void testMask6() { - testMaskAcrossDimensions(6, (i, j) -> ((i * j) % 2 + (i * j) % 3) % 2 == 0); - } - - @Test - public void testMask7() { - testMaskAcrossDimensions(7, (i, j) -> ((i + j) % 2 + (i * j) % 3) % 2 == 0); - } - - private static void testMaskAcrossDimensions(int reference, MaskCondition condition) { - DataMask mask = DataMask.values()[reference]; - for (int version = 1; version <= 40; version++) { - int dimension = 17 + 4 * version; - testMask(mask, dimension, condition); - } - } - - private static void testMask(DataMask mask, int dimension, MaskCondition condition) { - BitMatrix bits = new BitMatrix(dimension); - mask.unmaskBitMatrix(bits, dimension); - for (int i = 0; i < dimension; i++) { - for (int j = 0; j < dimension; j++) { - assertEquals( - "(" + i + ',' + j + ')', - condition.isMasked(i, j), - bits.get(j, i)); - } - } - } - - @FunctionalInterface - private interface MaskCondition { - boolean isMasked(int i, int j); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/DecodedBitStreamParserTestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/DecodedBitStreamParserTestCase.java deleted file mode 100644 index cba20b1..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/DecodedBitStreamParserTestCase.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -import com.google.zxing.common.BitSourceBuilder; -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests {@link DecodedBitStreamParser}. - * - * @author Sean Owen - */ -public final class DecodedBitStreamParserTestCase extends Assert { - - @Test - public void testSimpleByteMode() throws Exception { - BitSourceBuilder builder = new BitSourceBuilder(); - builder.write(0x04, 4); // Byte mode - builder.write(0x03, 8); // 3 bytes - builder.write(0xF1, 8); - builder.write(0xF2, 8); - builder.write(0xF3, 8); - String result = DecodedBitStreamParser.decode(builder.toByteArray(), - Version.getVersionForNumber(1), null, null).getText(); - assertEquals("\u00f1\u00f2\u00f3", result); - } - - @Test - public void testSimpleSJIS() throws Exception { - BitSourceBuilder builder = new BitSourceBuilder(); - builder.write(0x04, 4); // Byte mode - builder.write(0x04, 8); // 4 bytes - builder.write(0xA1, 8); - builder.write(0xA2, 8); - builder.write(0xA3, 8); - builder.write(0xD0, 8); - String result = DecodedBitStreamParser.decode(builder.toByteArray(), - Version.getVersionForNumber(1), null, null).getText(); - assertEquals("\uff61\uff62\uff63\uff90", result); - } - - @Test - public void testECI() throws Exception { - BitSourceBuilder builder = new BitSourceBuilder(); - builder.write(0x07, 4); // ECI mode - builder.write(0x02, 8); // ECI 2 = CP437 encoding - builder.write(0x04, 4); // Byte mode - builder.write(0x03, 8); // 3 bytes - builder.write(0xA1, 8); - builder.write(0xA2, 8); - builder.write(0xA3, 8); - String result = DecodedBitStreamParser.decode(builder.toByteArray(), - Version.getVersionForNumber(1), null, null).getText(); - assertEquals("\u00ed\u00f3\u00fa", result); - } - - @Test - public void testHanzi() throws Exception { - BitSourceBuilder builder = new BitSourceBuilder(); - builder.write(0x0D, 4); // Hanzi mode - builder.write(0x01, 4); // Subset 1 = GB2312 encoding - builder.write(0x01, 8); // 1 characters - builder.write(0x03C1, 13); - String result = DecodedBitStreamParser.decode(builder.toByteArray(), - Version.getVersionForNumber(1), null, null).getText(); - assertEquals("\u963f", result); - } - - @Test - public void testHanziLevel1() throws Exception { - BitSourceBuilder builder = new BitSourceBuilder(); - builder.write(0x0D, 4); // Hanzi mode - builder.write(0x01, 4); // Subset 1 = GB2312 encoding - builder.write(0x01, 8); // 1 characters - // A5A2 (U+30A2) => A5A2 - A1A1 = 401, 4*60 + 01 = 0181 - builder.write(0x0181, 13); - String result = DecodedBitStreamParser.decode(builder.toByteArray(), - Version.getVersionForNumber(1), null, null).getText(); - assertEquals("\u30a2", result); - } - - // TODO definitely need more tests here - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/ErrorCorrectionLevelTestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/ErrorCorrectionLevelTestCase.java deleted file mode 100644 index 64b5f60..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/ErrorCorrectionLevelTestCase.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Sean Owen - */ -public final class ErrorCorrectionLevelTestCase extends Assert { - - @Test - public void testForBits() { - assertSame(ErrorCorrectionLevel.M, ErrorCorrectionLevel.forBits(0)); - assertSame(ErrorCorrectionLevel.L, ErrorCorrectionLevel.forBits(1)); - assertSame(ErrorCorrectionLevel.H, ErrorCorrectionLevel.forBits(2)); - assertSame(ErrorCorrectionLevel.Q, ErrorCorrectionLevel.forBits(3)); - } - - @Test(expected = IllegalArgumentException.class) - public void testBadECLevel() { - ErrorCorrectionLevel.forBits(4); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/FormatInformationTestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/FormatInformationTestCase.java deleted file mode 100644 index 60bd518..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/FormatInformationTestCase.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Sean Owen - */ -public final class FormatInformationTestCase extends Assert { - - private static final int MASKED_TEST_FORMAT_INFO = 0x2BED; - private static final int UNMASKED_TEST_FORMAT_INFO = MASKED_TEST_FORMAT_INFO ^ 0x5412; - - @Test - public void testBitsDiffering() { - assertEquals(0, FormatInformation.numBitsDiffering(1, 1)); - assertEquals(1, FormatInformation.numBitsDiffering(0, 2)); - assertEquals(2, FormatInformation.numBitsDiffering(1, 2)); - assertEquals(32, FormatInformation.numBitsDiffering(-1, 0)); - } - - @Test - public void testDecode() { - // Normal case - FormatInformation expected = - FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO, MASKED_TEST_FORMAT_INFO); - assertNotNull(expected); - assertEquals((byte) 0x07, expected.getDataMask()); - assertSame(ErrorCorrectionLevel.Q, expected.getErrorCorrectionLevel()); - // where the code forgot the mask! - assertEquals(expected, - FormatInformation.decodeFormatInformation(UNMASKED_TEST_FORMAT_INFO, MASKED_TEST_FORMAT_INFO)); - } - - @Test - public void testDecodeWithBitDifference() { - FormatInformation expected = - FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO, MASKED_TEST_FORMAT_INFO); - // 1,2,3,4 bits difference - assertEquals(expected, FormatInformation.decodeFormatInformation( - MASKED_TEST_FORMAT_INFO ^ 0x01, MASKED_TEST_FORMAT_INFO ^ 0x01)); - assertEquals(expected, FormatInformation.decodeFormatInformation( - MASKED_TEST_FORMAT_INFO ^ 0x03, MASKED_TEST_FORMAT_INFO ^ 0x03)); - assertEquals(expected, FormatInformation.decodeFormatInformation( - MASKED_TEST_FORMAT_INFO ^ 0x07, MASKED_TEST_FORMAT_INFO ^ 0x07)); - assertNull(FormatInformation.decodeFormatInformation( - MASKED_TEST_FORMAT_INFO ^ 0x0F, MASKED_TEST_FORMAT_INFO ^ 0x0F)); - } - - @Test - public void testDecodeWithMisread() { - FormatInformation expected = - FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO, MASKED_TEST_FORMAT_INFO); - assertEquals(expected, FormatInformation.decodeFormatInformation( - MASKED_TEST_FORMAT_INFO ^ 0x03, MASKED_TEST_FORMAT_INFO ^ 0x0F)); - } - -} \ No newline at end of file diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/ModeTestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/ModeTestCase.java deleted file mode 100644 index 15636d2..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/ModeTestCase.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Sean Owen - */ -public final class ModeTestCase extends Assert { - - @Test - public void testForBits() { - assertSame(Mode.TERMINATOR, Mode.forBits(0x00)); - assertSame(Mode.NUMERIC, Mode.forBits(0x01)); - assertSame(Mode.ALPHANUMERIC, Mode.forBits(0x02)); - assertSame(Mode.BYTE, Mode.forBits(0x04)); - assertSame(Mode.KANJI, Mode.forBits(0x08)); - } - - @Test(expected = IllegalArgumentException.class) - public void testBadMode() { - Mode.forBits(0x10); - } - - @Test - public void testCharacterCount() { - // Spot check a few values - assertEquals(10, Mode.NUMERIC.getCharacterCountBits(Version.getVersionForNumber(5))); - assertEquals(12, Mode.NUMERIC.getCharacterCountBits(Version.getVersionForNumber(26))); - assertEquals(14, Mode.NUMERIC.getCharacterCountBits(Version.getVersionForNumber(40))); - assertEquals(9, Mode.ALPHANUMERIC.getCharacterCountBits(Version.getVersionForNumber(6))); - assertEquals(8, Mode.BYTE.getCharacterCountBits(Version.getVersionForNumber(7))); - assertEquals(8, Mode.KANJI.getCharacterCountBits(Version.getVersionForNumber(8))); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/VersionTestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/VersionTestCase.java deleted file mode 100644 index 4df7d4f..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/decoder/VersionTestCase.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.decoder; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Sean Owen - */ -public final class VersionTestCase extends Assert { - - @Test(expected = IllegalArgumentException.class) - public void testBadVersion() { - Version.getVersionForNumber(0); - } - - @Test - public void testVersionForNumber() { - for (int i = 1; i <= 40; i++) { - checkVersion(Version.getVersionForNumber(i), i, 4 * i + 17); - } - } - - private static void checkVersion(Version version, int number, int dimension) { - assertNotNull(version); - assertEquals(number, version.getVersionNumber()); - assertNotNull(version.getAlignmentPatternCenters()); - if (number > 1) { - assertTrue(version.getAlignmentPatternCenters().length > 0); - } - assertEquals(dimension, version.getDimensionForVersion()); - assertNotNull(version.getECBlocksForLevel(ErrorCorrectionLevel.H)); - assertNotNull(version.getECBlocksForLevel(ErrorCorrectionLevel.L)); - assertNotNull(version.getECBlocksForLevel(ErrorCorrectionLevel.M)); - assertNotNull(version.getECBlocksForLevel(ErrorCorrectionLevel.Q)); - assertNotNull(version.buildFunctionPattern()); - } - - @Test - public void testGetProvisionalVersionForDimension() throws Exception { - for (int i = 1; i <= 40; i++) { - assertEquals(i, Version.getProvisionalVersionForDimension(4 * i + 17).getVersionNumber()); - } - } - - @Test - public void testDecodeVersionInformation() { - // Spot check - doTestVersion(7, 0x07C94); - doTestVersion(12, 0x0C762); - doTestVersion(17, 0x1145D); - doTestVersion(22, 0x168C9); - doTestVersion(27, 0x1B08E); - doTestVersion(32, 0x209D5); - } - - private static void doTestVersion(int expectedVersion, int mask) { - Version version = Version.decodeVersionInformation(mask); - assertNotNull(version); - assertEquals(expectedVersion, version.getVersionNumber()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/BitVectorTestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/BitVectorTestCase.java deleted file mode 100644 index c67e84c..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/BitVectorTestCase.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.encoder; - -import com.google.zxing.common.BitArray; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author dswitkin@google.com (Daniel Switkin) - ported from C++ - */ -public final class BitVectorTestCase extends Assert { - - private static long getUnsignedInt(BitArray v) { - long result = 0L; - for (int i = 0, offset = 0; i < 32; i++) { - if (v.get(offset + i)) { - result |= 1L << (31 - i); - } - } - return result; - } - - @Test - public void testAppendBit() { - BitArray v = new BitArray(); - assertEquals(0, v.getSizeInBytes()); - // 1 - v.appendBit(true); - assertEquals(1, v.getSize()); - assertEquals(0x80000000L, getUnsignedInt(v)); - // 10 - v.appendBit(false); - assertEquals(2, v.getSize()); - assertEquals(0x80000000L, getUnsignedInt(v)); - // 101 - v.appendBit(true); - assertEquals(3, v.getSize()); - assertEquals(0xa0000000L, getUnsignedInt(v)); - // 1010 - v.appendBit(false); - assertEquals(4, v.getSize()); - assertEquals(0xa0000000L, getUnsignedInt(v)); - // 10101 - v.appendBit(true); - assertEquals(5, v.getSize()); - assertEquals(0xa8000000L, getUnsignedInt(v)); - // 101010 - v.appendBit(false); - assertEquals(6, v.getSize()); - assertEquals(0xa8000000L, getUnsignedInt(v)); - // 1010101 - v.appendBit(true); - assertEquals(7, v.getSize()); - assertEquals(0xaa000000L, getUnsignedInt(v)); - // 10101010 - v.appendBit(false); - assertEquals(8, v.getSize()); - assertEquals(0xaa000000L, getUnsignedInt(v)); - // 10101010 1 - v.appendBit(true); - assertEquals(9, v.getSize()); - assertEquals(0xaa800000L, getUnsignedInt(v)); - // 10101010 10 - v.appendBit(false); - assertEquals(10, v.getSize()); - assertEquals(0xaa800000L, getUnsignedInt(v)); - } - - @Test - public void testAppendBits() { - BitArray v = new BitArray(); - v.appendBits(0x1, 1); - assertEquals(1, v.getSize()); - assertEquals(0x80000000L, getUnsignedInt(v)); - v = new BitArray(); - v.appendBits(0xff, 8); - assertEquals(8, v.getSize()); - assertEquals(0xff000000L, getUnsignedInt(v)); - v = new BitArray(); - v.appendBits(0xff7, 12); - assertEquals(12, v.getSize()); - assertEquals(0xff700000L, getUnsignedInt(v)); - } - - @Test - public void testNumBytes() { - BitArray v = new BitArray(); - assertEquals(0, v.getSizeInBytes()); - v.appendBit(false); - // 1 bit was added in the vector, so 1 byte should be consumed. - assertEquals(1, v.getSizeInBytes()); - v.appendBits(0, 7); - assertEquals(1, v.getSizeInBytes()); - v.appendBits(0, 8); - assertEquals(2, v.getSizeInBytes()); - v.appendBits(0, 1); - // We now have 17 bits, so 3 bytes should be consumed. - assertEquals(3, v.getSizeInBytes()); - } - - @Test - public void testAppendBitVector() { - BitArray v1 = new BitArray(); - v1.appendBits(0xbe, 8); - BitArray v2 = new BitArray(); - v2.appendBits(0xef, 8); - v1.appendBitArray(v2); - // beef = 1011 1110 1110 1111 - assertEquals(" X.XXXXX. XXX.XXXX", v1.toString()); - } - - @Test - public void testXOR() { - BitArray v1 = new BitArray(); - v1.appendBits(0x5555aaaa, 32); - BitArray v2 = new BitArray(); - v2.appendBits(0xaaaa5555, 32); - v1.xor(v2); - assertEquals(0xffffffffL, getUnsignedInt(v1)); - } - - @Test - public void testXOR2() { - BitArray v1 = new BitArray(); - v1.appendBits(0x2a, 7); // 010 1010 - BitArray v2 = new BitArray(); - v2.appendBits(0x55, 7); // 101 0101 - v1.xor(v2); - assertEquals(0xfe000000L, getUnsignedInt(v1)); // 1111 1110 - } - - @Test - public void testAt() { - BitArray v = new BitArray(); - v.appendBits(0xdead, 16); // 1101 1110 1010 1101 - assertTrue(v.get(0)); - assertTrue(v.get(1)); - assertFalse(v.get(2)); - assertTrue(v.get(3)); - - assertTrue(v.get(4)); - assertTrue(v.get(5)); - assertTrue(v.get(6)); - assertFalse(v.get(7)); - - assertTrue(v.get(8)); - assertFalse(v.get(9)); - assertTrue(v.get(10)); - assertFalse(v.get(11)); - - assertTrue(v.get(12)); - assertTrue(v.get(13)); - assertFalse(v.get(14)); - assertTrue(v.get(15)); - } - - @Test - public void testToString() { - BitArray v = new BitArray(); - v.appendBits(0xdead, 16); // 1101 1110 1010 1101 - assertEquals(" XX.XXXX. X.X.XX.X", v.toString()); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java deleted file mode 100644 index b76ef38..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java +++ /dev/null @@ -1,987 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.encoder; - -import com.google.zxing.EncodeHintType; -import com.google.zxing.WriterException; -import com.google.zxing.common.BitArray; -import com.google.zxing.common.StringUtils; -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; -import com.google.zxing.qrcode.decoder.Mode; -import com.google.zxing.qrcode.decoder.Version; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.EnumMap; -import java.util.Map; -import java.nio.charset.Charset; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author mysen@google.com (Chris Mysen) - ported from C++ - */ -public final class EncoderTestCase extends Assert { - - @Test - public void testGetAlphanumericCode() { - // The first ten code points are numbers. - for (int i = 0; i < 10; ++i) { - assertEquals(i, Encoder.getAlphanumericCode('0' + i)); - } - - // The next 26 code points are capital alphabet letters. - for (int i = 10; i < 36; ++i) { - assertEquals(i, Encoder.getAlphanumericCode('A' + i - 10)); - } - - // Others are symbol letters - assertEquals(36, Encoder.getAlphanumericCode(' ')); - assertEquals(37, Encoder.getAlphanumericCode('$')); - assertEquals(38, Encoder.getAlphanumericCode('%')); - assertEquals(39, Encoder.getAlphanumericCode('*')); - assertEquals(40, Encoder.getAlphanumericCode('+')); - assertEquals(41, Encoder.getAlphanumericCode('-')); - assertEquals(42, Encoder.getAlphanumericCode('.')); - assertEquals(43, Encoder.getAlphanumericCode('/')); - assertEquals(44, Encoder.getAlphanumericCode(':')); - - // Should return -1 for other letters; - assertEquals(-1, Encoder.getAlphanumericCode('a')); - assertEquals(-1, Encoder.getAlphanumericCode('#')); - assertEquals(-1, Encoder.getAlphanumericCode('\0')); - } - - @Test - public void testChooseMode() { - // Numeric mode. - assertSame(Mode.NUMERIC, Encoder.chooseMode("0")); - assertSame(Mode.NUMERIC, Encoder.chooseMode("0123456789")); - // Alphanumeric mode. - assertSame(Mode.ALPHANUMERIC, Encoder.chooseMode("A")); - assertSame(Mode.ALPHANUMERIC, - Encoder.chooseMode("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:")); - // 8-bit byte mode. - assertSame(Mode.BYTE, Encoder.chooseMode("a")); - assertSame(Mode.BYTE, Encoder.chooseMode("#")); - assertSame(Mode.BYTE, Encoder.chooseMode("")); - // Kanji mode. We used to use MODE_KANJI for these, but we stopped - // doing that as we cannot distinguish Shift_JIS from other encodings - // from data bytes alone. See also comments in qrcode_encoder.h. - - // AIUE in Hiragana in Shift_JIS - assertSame(Mode.BYTE, - Encoder.chooseMode(shiftJISString(bytes(0x8, 0xa, 0x8, 0xa, 0x8, 0xa, 0x8, 0xa6)))); - - // Nihon in Kanji in Shift_JIS. - assertSame(Mode.BYTE, Encoder.chooseMode(shiftJISString(bytes(0x9, 0xf, 0x9, 0x7b)))); - - // Sou-Utsu-Byou in Kanji in Shift_JIS. - assertSame(Mode.BYTE, Encoder.chooseMode(shiftJISString(bytes(0xe, 0x4, 0x9, 0x5, 0x9, 0x61)))); - } - - @Test - public void testEncode() throws WriterException { - QRCode qrCode = Encoder.encode("ABCDEF", ErrorCorrectionLevel.H); - String expected = "<<\n" + - " mode: ALPHANUMERIC\n" + - " ecLevel: H\n" + - " version: 1\n" + - " maskPattern: 0\n" + - " matrix:\n" + - " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 0 1 1 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0\n" + - " 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1\n" + - " 1 0 1 1 1 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0\n" + - " 0 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 1 0\n" + - " 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0\n" + - " 0 0 1 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 1 1 0\n" + - " 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0\n" + - " 1 1 1 1 1 1 1 0 0 0 1 0 1 0 1 1 0 0 0 0 1\n" + - " 1 0 0 0 0 0 1 0 1 1 1 1 0 1 0 1 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 0 1 0\n" + - " 1 0 1 1 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 0 1 1\n" + - " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1\n" + - ">>\n"; - assertEquals(expected, qrCode.toString()); - } - - @Test - public void testEncodeWithVersion() throws WriterException { - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.QR_VERSION, 7); - QRCode qrCode = Encoder.encode("ABCDEF", ErrorCorrectionLevel.H, hints); - assertTrue(qrCode.toString().contains(" version: 7\n")); - } - - @Test(expected = WriterException.class) - public void testEncodeWithVersionTooSmall() throws WriterException { - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.QR_VERSION, 3); - Encoder.encode("THISMESSAGEISTOOLONGFORAQRCODEVERSION3", ErrorCorrectionLevel.H, hints); - } - - @Test - public void testSimpleUTF8ECI() throws WriterException { - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.CHARACTER_SET, "UTF8"); - QRCode qrCode = Encoder.encode("hello", ErrorCorrectionLevel.H, hints); - String expected = "<<\n" + - " mode: BYTE\n" + - " ecLevel: H\n" + - " version: 1\n" + - " maskPattern: 3\n" + - " matrix:\n" + - " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 1 0 1 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 1 1 0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 0 0\n" + - " 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 1 0 1 1 1 0\n" + - " 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 1 1 1\n" + - " 1 1 0 0 1 0 0 1 1 0 0 1 1 1 1 0 1 0 1 1 0\n" + - " 0 0 0 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0\n" + - " 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 1 0 0\n" + - " 1 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 0 0 0 0 1 1 0 0 0 0 0\n" + - " 1 0 1 1 1 0 1 0 1 1 1 0 1 0 0 0 1 1 0 0 0\n" + - " 1 0 1 1 1 0 1 0 1 1 0 0 0 1 0 0 1 0 0 0 0\n" + - " 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 1 1 0\n" + - " 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 1 1 0 0 0 0\n" + - ">>\n"; - assertEquals(expected, qrCode.toString()); - } - - @Test - public void testEncodeKanjiMode() throws WriterException { - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.CHARACTER_SET, "Shift_JIS"); - // Nihon in Kanji - QRCode qrCode = Encoder.encode("\u65e5\u672c", ErrorCorrectionLevel.M, hints); - String expected = "<<\n" + - " mode: KANJI\n" + - " ecLevel: M\n" + - " version: 1\n" + - " maskPattern: 4\n" + - " matrix:\n" + - " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 0 0 0 1 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 1\n" + - " 0 1 1 0 0 1 0 1 1 0 1 0 1 1 1 0 0 0 1 0 1\n" + - " 1 1 1 1 0 1 1 1 0 0 1 0 1 1 0 0 0 0 1 1 1\n" + - " 1 0 1 0 1 1 0 0 0 0 1 1 1 0 0 1 0 0 1 1 0\n" + - " 0 0 1 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 0 1 1\n" + - " 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 0 1 0 0 0\n" + - " 1 1 1 1 1 1 1 0 1 1 0 1 0 0 1 1 1 1 1 1 0\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 1 0 1 0 1\n" + - " 1 0 1 1 1 0 1 0 1 0 1 0 1 1 1 0 0 0 1 1 1\n" + - " 1 0 1 1 1 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1\n" + - " 1 0 1 1 1 0 1 0 0 1 1 0 1 1 0 0 0 1 0 0 0\n" + - " 1 0 0 0 0 0 1 0 0 0 1 1 1 0 0 1 0 1 0 0 0\n" + - " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 1 0\n" + - ">>\n"; - assertEquals(expected, qrCode.toString()); - } - - @Test - public void testEncodeShiftjisNumeric() throws WriterException { - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.CHARACTER_SET, "Shift_JIS"); - QRCode qrCode = Encoder.encode("0123", ErrorCorrectionLevel.M, hints); - String expected = "<<\n" + - " mode: NUMERIC\n" + - " ecLevel: M\n" + - " version: 1\n" + - " maskPattern: 0\n" + - " matrix:\n" + - " 1 1 1 1 1 1 1 0 0 0 0 0 1 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 1 1 0 1 0 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0\n" + - " 1 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0\n" + - " 0 0 0 0 0 0 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0\n" + - " 0 1 0 1 0 1 1 1 1 0 0 1 0 1 1 1 0 1 0 1 0\n" + - " 0 1 1 1 0 0 0 0 0 0 1 1 1 1 0 1 1 1 0 1 0\n" + - " 0 0 0 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 0 1\n" + - " 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 1 1 0\n" + - " 1 1 1 1 1 1 1 0 0 1 0 0 1 0 0 0 1 0 0 0 1\n" + - " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 0 0\n" + - " 1 0 1 1 1 0 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 1 1 0 1 0 1 0 1 0 1 0\n" + - " 1 0 1 1 1 0 1 0 1 0 1 1 0 1 1 1 0 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 0 1 1 1 1 0 1 1 1 0 0 0\n" + - " 1 1 1 1 1 1 1 0 1 0 1 1 0 1 1 1 0 1 1 0 1\n" + - ">>\n"; - assertEquals(expected, qrCode.toString()); - } - - @Test - public void testEncodeGS1WithStringTypeHint() throws WriterException { - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.GS1_FORMAT, "true"); - QRCode qrCode = Encoder.encode("100001%11171218", ErrorCorrectionLevel.H, hints); - verifyGS1EncodedData(qrCode); - } - - @Test - public void testEncodeGS1WithBooleanTypeHint() throws WriterException { - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.GS1_FORMAT, true); - QRCode qrCode = Encoder.encode("100001%11171218", ErrorCorrectionLevel.H, hints); - verifyGS1EncodedData(qrCode); - } - - @Test - public void testDoesNotEncodeGS1WhenBooleanTypeHintExplicitlyFalse() throws WriterException { - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.GS1_FORMAT, false); - QRCode qrCode = Encoder.encode("ABCDEF", ErrorCorrectionLevel.H, hints); - verifyNotGS1EncodedData(qrCode); - } - - @Test - public void testDoesNotEncodeGS1WhenStringTypeHintExplicitlyFalse() throws WriterException { - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.GS1_FORMAT, "false"); - QRCode qrCode = Encoder.encode("ABCDEF", ErrorCorrectionLevel.H, hints); - verifyNotGS1EncodedData(qrCode); - } - - @Test - public void testGS1ModeHeaderWithECI() throws WriterException { - Map hints = new EnumMap<>(EncodeHintType.class); - hints.put(EncodeHintType.CHARACTER_SET, "UTF8"); - hints.put(EncodeHintType.GS1_FORMAT, true); - QRCode qrCode = Encoder.encode("hello", ErrorCorrectionLevel.H, hints); - String expected = "<<\n" + - " mode: BYTE\n" + - " ecLevel: H\n" + - " version: 1\n" + - " maskPattern: 6\n" + - " matrix:\n" + - " 1 1 1 1 1 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 1 1 0 0 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 0 1 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0\n" + - " 0 0 0 1 1 0 1 1 0 1 0 0 0 0 0 0 0 1 1 0 0\n" + - " 0 1 0 1 1 0 0 1 0 1 1 1 1 1 1 0 1 1 1 0 1\n" + - " 0 1 1 1 1 0 1 0 0 1 0 1 0 1 1 1 0 0 1 0 1\n" + - " 1 1 1 1 1 0 0 1 0 0 0 1 1 0 0 1 0 0 1 0 0\n" + - " 1 0 0 1 0 0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 1\n" + - " 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 1 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 0 1 0 1 1 0 1 0 1 0 0\n" + - " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 1 1 1 0 0\n" + - " 1 0 1 1 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 0 0\n" + - " 1 0 1 1 1 0 1 0 1 0 1 1 1 1 1 0 0 0 1 1 0\n" + - " 1 0 1 1 1 0 1 0 0 0 1 0 0 1 0 0 1 0 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0\n" + - " 1 1 1 1 1 1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0\n" + - ">>\n"; - assertEquals(expected, qrCode.toString()); - } - - @Test - public void testAppendModeInfo() { - BitArray bits = new BitArray(); - Encoder.appendModeInfo(Mode.NUMERIC, bits); - assertEquals(" ...X", bits.toString()); - } - - @Test - public void testAppendLengthInfo() throws WriterException { - BitArray bits = new BitArray(); - Encoder.appendLengthInfo(1, // 1 letter (1/1). - Version.getVersionForNumber(1), - Mode.NUMERIC, - bits); - assertEquals(" ........ .X", bits.toString()); // 10 bits. - bits = new BitArray(); - Encoder.appendLengthInfo(2, // 2 letters (2/1). - Version.getVersionForNumber(10), - Mode.ALPHANUMERIC, - bits); - assertEquals(" ........ .X.", bits.toString()); // 11 bits. - bits = new BitArray(); - Encoder.appendLengthInfo(255, // 255 letter (255/1). - Version.getVersionForNumber(27), - Mode.BYTE, - bits); - assertEquals(" ........ XXXXXXXX", bits.toString()); // 16 bits. - bits = new BitArray(); - Encoder.appendLengthInfo(512, // 512 letters (1024/2). - Version.getVersionForNumber(40), - Mode.KANJI, - bits); - assertEquals(" ..X..... ....", bits.toString()); // 12 bits. - } - - @Test - public void testAppendBytes() throws WriterException { - // Should use appendNumericBytes. - // 1 = 01 = 0001 in 4 bits. - BitArray bits = new BitArray(); - Encoder.appendBytes("1", Mode.NUMERIC, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING); - assertEquals(" ...X" , bits.toString()); - // Should use appendAlphanumericBytes. - // A = 10 = 0xa = 001010 in 6 bits - bits = new BitArray(); - Encoder.appendBytes("A", Mode.ALPHANUMERIC, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING); - assertEquals(" ..X.X." , bits.toString()); - // Lower letters such as 'a' cannot be encoded in MODE_ALPHANUMERIC. - try { - Encoder.appendBytes("a", Mode.ALPHANUMERIC, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING); - } catch (WriterException we) { - // good - } - // Should use append8BitBytes. - // 0x61, 0x62, 0x63 - bits = new BitArray(); - Encoder.appendBytes("abc", Mode.BYTE, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING); - assertEquals(" .XX....X .XX...X. .XX...XX", bits.toString()); - // Anything can be encoded in QRCode.MODE_8BIT_BYTE. - Encoder.appendBytes("\0", Mode.BYTE, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING); - // Should use appendKanjiBytes. - // 0x93, 0x5f - bits = new BitArray(); - Encoder.appendBytes(shiftJISString(bytes(0x93, 0x5f)), Mode.KANJI, bits, - Encoder.DEFAULT_BYTE_MODE_ENCODING); - assertEquals(" .XX.XX.. XXXXX", bits.toString()); - } - - @Test - public void testTerminateBits() throws WriterException { - BitArray v = new BitArray(); - Encoder.terminateBits(0, v); - assertEquals("", v.toString()); - v = new BitArray(); - Encoder.terminateBits(1, v); - assertEquals(" ........", v.toString()); - v = new BitArray(); - v.appendBits(0, 3); // Append 000 - Encoder.terminateBits(1, v); - assertEquals(" ........", v.toString()); - v = new BitArray(); - v.appendBits(0, 5); // Append 00000 - Encoder.terminateBits(1, v); - assertEquals(" ........", v.toString()); - v = new BitArray(); - v.appendBits(0, 8); // Append 00000000 - Encoder.terminateBits(1, v); - assertEquals(" ........", v.toString()); - v = new BitArray(); - Encoder.terminateBits(2, v); - assertEquals(" ........ XXX.XX..", v.toString()); - v = new BitArray(); - v.appendBits(0, 1); // Append 0 - Encoder.terminateBits(3, v); - assertEquals(" ........ XXX.XX.. ...X...X", v.toString()); - } - - @Test - public void testGetNumDataBytesAndNumECBytesForBlockID() throws WriterException { - int[] numDataBytes = new int[1]; - int[] numEcBytes = new int[1]; - // Version 1-H. - Encoder.getNumDataBytesAndNumECBytesForBlockID(26, 9, 1, 0, numDataBytes, numEcBytes); - assertEquals(9, numDataBytes[0]); - assertEquals(17, numEcBytes[0]); - - // Version 3-H. 2 blocks. - Encoder.getNumDataBytesAndNumECBytesForBlockID(70, 26, 2, 0, numDataBytes, numEcBytes); - assertEquals(13, numDataBytes[0]); - assertEquals(22, numEcBytes[0]); - Encoder.getNumDataBytesAndNumECBytesForBlockID(70, 26, 2, 1, numDataBytes, numEcBytes); - assertEquals(13, numDataBytes[0]); - assertEquals(22, numEcBytes[0]); - - // Version 7-H. (4 + 1) blocks. - Encoder.getNumDataBytesAndNumECBytesForBlockID(196, 66, 5, 0, numDataBytes, numEcBytes); - assertEquals(13, numDataBytes[0]); - assertEquals(26, numEcBytes[0]); - Encoder.getNumDataBytesAndNumECBytesForBlockID(196, 66, 5, 4, numDataBytes, numEcBytes); - assertEquals(14, numDataBytes[0]); - assertEquals(26, numEcBytes[0]); - - // Version 40-H. (20 + 61) blocks. - Encoder.getNumDataBytesAndNumECBytesForBlockID(3706, 1276, 81, 0, numDataBytes, numEcBytes); - assertEquals(15, numDataBytes[0]); - assertEquals(30, numEcBytes[0]); - Encoder.getNumDataBytesAndNumECBytesForBlockID(3706, 1276, 81, 20, numDataBytes, numEcBytes); - assertEquals(16, numDataBytes[0]); - assertEquals(30, numEcBytes[0]); - Encoder.getNumDataBytesAndNumECBytesForBlockID(3706, 1276, 81, 80, numDataBytes, numEcBytes); - assertEquals(16, numDataBytes[0]); - assertEquals(30, numEcBytes[0]); - } - - @Test - public void testInterleaveWithECBytes() throws WriterException { - byte[] dataBytes = bytes(32, 65, 205, 69, 41, 220, 46, 128, 236); - BitArray in = new BitArray(); - for (byte dataByte: dataBytes) { - in.appendBits(dataByte, 8); - } - BitArray out = Encoder.interleaveWithECBytes(in, 26, 9, 1); - byte[] expected = bytes( - // Data bytes. - 32, 65, 205, 69, 41, 220, 46, 128, 236, - // Error correction bytes. - 42, 159, 74, 221, 244, 169, 239, 150, 138, 70, - 237, 85, 224, 96, 74, 219, 61 - ); - assertEquals(expected.length, out.getSizeInBytes()); - byte[] outArray = new byte[expected.length]; - out.toBytes(0, outArray, 0, expected.length); - // Can't use Arrays.equals(), because outArray may be longer than out.sizeInBytes() - for (int x = 0; x < expected.length; x++) { - assertEquals(expected[x], outArray[x]); - } - // Numbers are from http://www.swetake.com/qr/qr8.html - dataBytes = bytes( - 67, 70, 22, 38, 54, 70, 86, 102, 118, 134, 150, 166, 182, - 198, 214, 230, 247, 7, 23, 39, 55, 71, 87, 103, 119, 135, - 151, 166, 22, 38, 54, 70, 86, 102, 118, 134, 150, 166, - 182, 198, 214, 230, 247, 7, 23, 39, 55, 71, 87, 103, 119, - 135, 151, 160, 236, 17, 236, 17, 236, 17, 236, - 17 - ); - in = new BitArray(); - for (byte dataByte: dataBytes) { - in.appendBits(dataByte, 8); - } - - out = Encoder.interleaveWithECBytes(in, 134, 62, 4); - expected = bytes( - // Data bytes. - 67, 230, 54, 55, 70, 247, 70, 71, 22, 7, 86, 87, 38, 23, 102, 103, 54, 39, - 118, 119, 70, 55, 134, 135, 86, 71, 150, 151, 102, 87, 166, - 160, 118, 103, 182, 236, 134, 119, 198, 17, 150, - 135, 214, 236, 166, 151, 230, 17, 182, - 166, 247, 236, 198, 22, 7, 17, 214, 38, 23, 236, 39, - 17, - // Error correction bytes. - 175, 155, 245, 236, 80, 146, 56, 74, 155, 165, - 133, 142, 64, 183, 132, 13, 178, 54, 132, 108, 45, - 113, 53, 50, 214, 98, 193, 152, 233, 147, 50, 71, 65, - 190, 82, 51, 209, 199, 171, 54, 12, 112, 57, 113, 155, 117, - 211, 164, 117, 30, 158, 225, 31, 190, 242, 38, - 140, 61, 179, 154, 214, 138, 147, 87, 27, 96, 77, 47, - 187, 49, 156, 214 - ); - assertEquals(expected.length, out.getSizeInBytes()); - outArray = new byte[expected.length]; - out.toBytes(0, outArray, 0, expected.length); - for (int x = 0; x < expected.length; x++) { - assertEquals(expected[x], outArray[x]); - } - } - - private static byte[] bytes(int... ints) { - byte[] bytes = new byte[ints.length]; - for (int i = 0; i < ints.length; i++) { - bytes[i] = (byte) ints[i]; - } - return bytes; - } - - @Test - public void testAppendNumericBytes() { - // 1 = 01 = 0001 in 4 bits. - BitArray bits = new BitArray(); - Encoder.appendNumericBytes("1", bits); - assertEquals(" ...X" , bits.toString()); - // 12 = 0xc = 0001100 in 7 bits. - bits = new BitArray(); - Encoder.appendNumericBytes("12", bits); - assertEquals(" ...XX.." , bits.toString()); - // 123 = 0x7b = 0001111011 in 10 bits. - bits = new BitArray(); - Encoder.appendNumericBytes("123", bits); - assertEquals(" ...XXXX. XX" , bits.toString()); - // 1234 = "123" + "4" = 0001111011 + 0100 - bits = new BitArray(); - Encoder.appendNumericBytes("1234", bits); - assertEquals(" ...XXXX. XX.X.." , bits.toString()); - // Empty. - bits = new BitArray(); - Encoder.appendNumericBytes("", bits); - assertEquals("" , bits.toString()); - } - - @Test - public void testAppendAlphanumericBytes() throws WriterException { - // A = 10 = 0xa = 001010 in 6 bits - BitArray bits = new BitArray(); - Encoder.appendAlphanumericBytes("A", bits); - assertEquals(" ..X.X." , bits.toString()); - // AB = 10 * 45 + 11 = 461 = 0x1cd = 00111001101 in 11 bits - bits = new BitArray(); - Encoder.appendAlphanumericBytes("AB", bits); - assertEquals(" ..XXX..X X.X", bits.toString()); - // ABC = "AB" + "C" = 00111001101 + 001100 - bits = new BitArray(); - Encoder.appendAlphanumericBytes("ABC", bits); - assertEquals(" ..XXX..X X.X..XX. ." , bits.toString()); - // Empty. - bits = new BitArray(); - Encoder.appendAlphanumericBytes("", bits); - assertEquals("" , bits.toString()); - // Invalid data. - try { - Encoder.appendAlphanumericBytes("abc", new BitArray()); - } catch (WriterException we) { - // good - } - } - - @Test - public void testAppend8BitBytes() { - // 0x61, 0x62, 0x63 - BitArray bits = new BitArray(); - Encoder.append8BitBytes("abc", bits, Encoder.DEFAULT_BYTE_MODE_ENCODING); - assertEquals(" .XX....X .XX...X. .XX...XX", bits.toString()); - // Empty. - bits = new BitArray(); - Encoder.append8BitBytes("", bits, Encoder.DEFAULT_BYTE_MODE_ENCODING); - assertEquals("", bits.toString()); - } - - // Numbers are from page 21 of JISX0510:2004 - @Test - public void testAppendKanjiBytes() throws WriterException { - BitArray bits = new BitArray(); - Encoder.appendKanjiBytes(shiftJISString(bytes(0x93, 0x5f)), bits); - assertEquals(" .XX.XX.. XXXXX", bits.toString()); - Encoder.appendKanjiBytes(shiftJISString(bytes(0xe4, 0xaa)), bits); - assertEquals(" .XX.XX.. XXXXXXX. X.X.X.X. X.", bits.toString()); - } - - // Numbers are from http://www.swetake.com/qr/qr3.html and - // http://www.swetake.com/qr/qr9.html - @Test - public void testGenerateECBytes() { - byte[] dataBytes = bytes(32, 65, 205, 69, 41, 220, 46, 128, 236); - byte[] ecBytes = Encoder.generateECBytes(dataBytes, 17); - int[] expected = { - 42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61 - }; - assertEquals(expected.length, ecBytes.length); - for (int x = 0; x < expected.length; x++) { - assertEquals(expected[x], ecBytes[x] & 0xFF); - } - dataBytes = bytes(67, 70, 22, 38, 54, 70, 86, 102, 118, 134, 150, 166, 182, 198, 214); - ecBytes = Encoder.generateECBytes(dataBytes, 18); - expected = new int[] { - 175, 80, 155, 64, 178, 45, 214, 233, 65, 209, 12, 155, 117, 31, 140, 214, 27, 187 - }; - assertEquals(expected.length, ecBytes.length); - for (int x = 0; x < expected.length; x++) { - assertEquals(expected[x], ecBytes[x] & 0xFF); - } - // High-order zero coefficient case. - dataBytes = bytes(32, 49, 205, 69, 42, 20, 0, 236, 17); - ecBytes = Encoder.generateECBytes(dataBytes, 17); - expected = new int[] { - 0, 3, 130, 179, 194, 0, 55, 211, 110, 79, 98, 72, 170, 96, 211, 137, 213 - }; - assertEquals(expected.length, ecBytes.length); - for (int x = 0; x < expected.length; x++) { - assertEquals(expected[x], ecBytes[x] & 0xFF); - } - } - - @Test - public void testBugInBitVectorNumBytes() throws WriterException { - // There was a bug in BitVector.sizeInBytes() that caused it to return a - // smaller-by-one value (ex. 1465 instead of 1466) if the number of bits - // in the vector is not 8-bit aligned. In QRCodeEncoder::InitQRCode(), - // BitVector::sizeInBytes() is used for finding the smallest QR Code - // version that can fit the given data. Hence there were corner cases - // where we chose a wrong QR Code version that cannot fit the given - // data. Note that the issue did not occur with MODE_8BIT_BYTE, as the - // bits in the bit vector are always 8-bit aligned. - // - // Before the bug was fixed, the following test didn't pass, because: - // - // - MODE_NUMERIC is chosen as all bytes in the data are '0' - // - The 3518-byte numeric data needs 1466 bytes - // - 3518 / 3 * 10 + 7 = 11727 bits = 1465.875 bytes - // - 3 numeric bytes are encoded in 10 bits, hence the first - // 3516 bytes are encoded in 3516 / 3 * 10 = 11720 bits. - // - 2 numeric bytes can be encoded in 7 bits, hence the last - // 2 bytes are encoded in 7 bits. - // - The version 27 QR Code with the EC level L has 1468 bytes for data. - // - 1828 - 360 = 1468 - // - In InitQRCode(), 3 bytes are reserved for a header. Hence 1465 bytes - // (1468 -3) are left for data. - // - Because of the bug in BitVector::sizeInBytes(), InitQRCode() determines - // the given data can fit in 1465 bytes, despite it needs 1466 bytes. - // - Hence QRCodeEncoder.encode() failed and returned false. - // - To be precise, it needs 11727 + 4 (getMode info) + 14 (length info) = - // 11745 bits = 1468.125 bytes are needed (i.e. cannot fit in 1468 - // bytes). - StringBuilder builder = new StringBuilder(3518); - for (int x = 0; x < 3518; x++) { - builder.append('0'); - } - Encoder.encode(builder.toString(), ErrorCorrectionLevel.L); - } - - @Test - public void testMinimalEncoder1() throws Exception { - verifyMinimalEncoding("A", "ALPHANUMERIC(A)", null, false); - } - - @Test - public void testMinimalEncoder2() throws Exception { - verifyMinimalEncoding("AB", "ALPHANUMERIC(AB)", null, false); - } - - @Test - public void testMinimalEncoder3() throws Exception { - verifyMinimalEncoding("ABC", "ALPHANUMERIC(ABC)", null, false); - } - - @Test - public void testMinimalEncoder4() throws Exception { - verifyMinimalEncoding("ABCD", "ALPHANUMERIC(ABCD)", null, false); - } - - @Test - public void testMinimalEncoder5() throws Exception { - verifyMinimalEncoding("ABCDE", "ALPHANUMERIC(ABCDE)", null, false); - } - - @Test - public void testMinimalEncoder6() throws Exception { - verifyMinimalEncoding("ABCDEF", "ALPHANUMERIC(ABCDEF)", null, false); - } - - @Test - public void testMinimalEncoder7() throws Exception { - verifyMinimalEncoding("ABCDEFG", "ALPHANUMERIC(ABCDEFG)", null, false); - } - - @Test - public void testMinimalEncoder8() throws Exception { - verifyMinimalEncoding("1", "NUMERIC(1)", null, false); - } - - @Test - public void testMinimalEncoder9() throws Exception { - verifyMinimalEncoding("12", "NUMERIC(12)", null, false); - } - - @Test - public void testMinimalEncoder10() throws Exception { - verifyMinimalEncoding("123", "NUMERIC(123)", null, false); - } - - @Test - public void testMinimalEncoder11() throws Exception { - verifyMinimalEncoding("1234", "NUMERIC(1234)", null, false); - } - - @Test - public void testMinimalEncoder12() throws Exception { - verifyMinimalEncoding("12345", "NUMERIC(12345)", null, false); - } - - @Test - public void testMinimalEncoder13() throws Exception { - verifyMinimalEncoding("123456", "NUMERIC(123456)", null, false); - } - - @Test - public void testMinimalEncoder14() throws Exception { - verifyMinimalEncoding("123A", "ALPHANUMERIC(123A)", null, false); - } - - @Test - public void testMinimalEncoder15() throws Exception { - verifyMinimalEncoding("A1", "ALPHANUMERIC(A1)", null, false); - } - - @Test - public void testMinimalEncoder16() throws Exception { - verifyMinimalEncoding("A12", "ALPHANUMERIC(A12)", null, false); - } - - @Test - public void testMinimalEncoder17() throws Exception { - verifyMinimalEncoding("A123", "ALPHANUMERIC(A123)", null, false); - } - - @Test - public void testMinimalEncoder18() throws Exception { - verifyMinimalEncoding("A1234", "ALPHANUMERIC(A1234)", null, false); - } - - @Test - public void testMinimalEncoder19() throws Exception { - verifyMinimalEncoding("A12345", "ALPHANUMERIC(A12345)", null, false); - } - - @Test - public void testMinimalEncoder20() throws Exception { - verifyMinimalEncoding("A123456", "ALPHANUMERIC(A123456)", null, false); - } - - @Test - public void testMinimalEncoder21() throws Exception { - verifyMinimalEncoding("A1234567", "ALPHANUMERIC(A1234567)", null, false); - } - - @Test - public void testMinimalEncoder22() throws Exception { - verifyMinimalEncoding("A12345678", "BYTE(A),NUMERIC(12345678)", null, false); - } - - @Test - public void testMinimalEncoder23() throws Exception { - verifyMinimalEncoding("A123456789", "BYTE(A),NUMERIC(123456789)", null, false); - } - - @Test - public void testMinimalEncoder24() throws Exception { - verifyMinimalEncoding("A1234567890", "ALPHANUMERIC(A1),NUMERIC(234567890)", null, false); - } - - @Test - public void testMinimalEncoder25() throws Exception { - verifyMinimalEncoding("AB1", "ALPHANUMERIC(AB1)", null, false); - } - - @Test - public void testMinimalEncoder26() throws Exception { - verifyMinimalEncoding("AB12", "ALPHANUMERIC(AB12)", null, false); - } - - @Test - public void testMinimalEncoder27() throws Exception { - verifyMinimalEncoding("AB123", "ALPHANUMERIC(AB123)", null, false); - } - - @Test - public void testMinimalEncoder28() throws Exception { - verifyMinimalEncoding("AB1234", "ALPHANUMERIC(AB1234)", null, false); - } - - @Test - public void testMinimalEncoder29() throws Exception { - verifyMinimalEncoding("ABC1", "ALPHANUMERIC(ABC1)", null, false); - } - - @Test - public void testMinimalEncoder30() throws Exception { - verifyMinimalEncoding("ABC12", "ALPHANUMERIC(ABC12)", null, false); - } - - @Test - public void testMinimalEncoder31() throws Exception { - verifyMinimalEncoding("ABC1234", "ALPHANUMERIC(ABC1234)", null, false); - } - - @Test - public void testMinimalEncoder32() throws Exception { - verifyMinimalEncoding("http://foo.com", "BYTE(http://foo.com)" + - "", null, false); - } - - @Test - public void testMinimalEncoder33() throws Exception { - verifyMinimalEncoding("HTTP://FOO.COM", "ALPHANUMERIC(HTTP://FOO.COM" + - ")", null, false); - } - - @Test - public void testMinimalEncoder34() throws Exception { - verifyMinimalEncoding("1001114670010%01201220%107211220%140045003267781", - "NUMERIC(1001114670010),ALPHANUMERIC(%01201220%107211220%),NUMERIC(140045003267781)", null, false); - } - - @Test - public void testMinimalEncoder35() throws Exception { - verifyMinimalEncoding("\u0150", "ECI(ISO-8859-2),BYTE(.)", null, false); - } - - @Test - public void testMinimalEncoder36() throws Exception { - verifyMinimalEncoding("\u015C", "ECI(ISO-8859-3),BYTE(.)", null, false); - } - - @Test - public void testMinimalEncoder37() throws Exception { - verifyMinimalEncoding("\u0150\u015C", "ECI(UTF-8),BYTE(..)", null, false); - } - - @Test - public void testMinimalEncoder38() throws Exception { - verifyMinimalEncoding("\u0150\u0150\u015C\u015C", "ECI(ISO-8859-2),BYTE(." + - ".),ECI(ISO-8859-3),BYTE(..)", null, false); - } - - @Test - public void testMinimalEncoder39() throws Exception { - verifyMinimalEncoding("abcdef\u0150ghij", "ECI(ISO-8859-2),BYTE(abcde" + - "f.ghij)", null, false); - } - - @Test - public void testMinimalEncoder40() throws Exception { - verifyMinimalEncoding("2938928329832983\u01502938928329832983\u015C2938928329832983", - "NUMERIC(2938928329832983),ECI(ISO-8859-2),BYTE(.),NUMERIC(2938928329832983),ECI(ISO-8" + - "859-3),BYTE(.),NUMERIC(2938928329832983)", null, false); - } - - @Test - public void testMinimalEncoder41() throws Exception { - verifyMinimalEncoding("1001114670010%01201220%107211220%140045003267781", "FNC1_FIRST_POSITION(),NUMERIC(100111" + - "4670010),ALPHANUMERIC(%01201220%107211220%),NUMERIC(140045003267781)", null, - true); - } - - @Test - public void testMinimalEncoder42() throws Exception { - // test halfwidth Katakana character (they are single byte encoded in Shift_JIS) - verifyMinimalEncoding("Katakana:\uFF66\uFF66\uFF66\uFF66\uFF66\uFF66", "ECI(Shift_JIS),BYTE(Katakana:......)", null - , false); - } - - @Test - public void testMinimalEncoder43() throws Exception { - // The character \u30A2 encodes as double byte in Shift_JIS so KANJI is more compact in this case - verifyMinimalEncoding("Katakana:\u30A2\u30A2\u30A2\u30A2\u30A2\u30A2", "BYTE(Katakana:),KANJI(......)", null, - false); - } - - @Test - public void testMinimalEncoder44() throws Exception { - // The character \u30A2 encodes as double byte in Shift_JIS but KANJI is not more compact in this case because - // KANJI is only more compact when it encodes pairs of characters. In the case of mixed text it can however be - // that Shift_JIS encoding is more compact as in this example - verifyMinimalEncoding("Katakana:\u30A2a\u30A2a\u30A2a\u30A2a\u30A2a\u30A2", "ECI(Shift_JIS),BYTE(Katakana:.a.a.a" + - ".a.a.)", null, false); - } - - static void verifyMinimalEncoding(String input, String expectedResult, Charset priorityCharset, boolean isGS1) - throws Exception { - MinimalEncoder.ResultList result = MinimalEncoder.encode(input, null, priorityCharset, isGS1, - ErrorCorrectionLevel.L); - assertEquals(result.toString(), expectedResult); - } - - private static void verifyGS1EncodedData(QRCode qrCode) { - String expected = "<<\n" + - " mode: ALPHANUMERIC\n" + - " ecLevel: H\n" + - " version: 2\n" + - " maskPattern: 2\n" + - " matrix:\n" + - " 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 1 0 0 0 0 1 1 0 1 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 1 0 1 1 0 1 1 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 1 0 1 0 1 1 1 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 1 1 1 1 1 1 1 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0 0 0\n" + - " 0 0 1 1 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 1 0 0 1 1 1\n" + - " 0 0 0 1 1 1 0 1 0 0 1 0 0 1 0 0 1 1 1 0 0 1 0 0 1\n" + - " 1 0 1 1 0 0 1 0 1 1 0 0 0 0 1 0 1 1 1 0 0 1 0 0 1\n" + - " 0 0 1 1 0 1 0 1 1 1 1 0 0 1 1 1 1 0 0 0 1 1 0 1 1\n" + - " 0 0 1 0 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 1 1 0 1 0\n" + - " 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 1 1 0 1 1 0 1 0 0 0\n" + - " 1 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 0 0 0 0 1 1 0 0 1\n" + - " 1 0 0 1 0 1 0 1 0 0 0 1 1 1 1 0 1 0 1 0 0 1 0 0 1\n" + - " 1 0 1 0 0 1 1 1 0 1 1 0 0 1 0 0 1 1 1 1 1 1 0 0 0\n" + - " 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1 0 1 0 0 0 1 0 0 1 0\n" + - " 1 1 1 1 1 1 1 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 1 1 1 1 1 0 1 1 0 0 0 1 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 1 0 1 0 0 1 1 1 1 1 1 1 1 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0\n" + - " 1 0 1 1 1 0 1 0 1 0 0 0 1 1 0 1 0 0 1 1 1 0 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 0 1 0 0 1 1 1 1 1\n" + - " 1 1 1 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 0 0 0 1 0 1 1\n" + - ">>\n"; - assertEquals(expected, qrCode.toString()); - } - - private static void verifyNotGS1EncodedData(QRCode qrCode) { - String expected = "<<\n" + - " mode: ALPHANUMERIC\n" + - " ecLevel: H\n" + - " version: 1\n" + - " maskPattern: 0\n" + - " matrix:\n" + - " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 0 1 1 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0\n" + - " 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1\n" + - " 1 0 1 1 1 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0\n" + - " 0 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 1 0\n" + - " 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0\n" + - " 0 0 1 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 1 1 0\n" + - " 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0\n" + - " 1 1 1 1 1 1 1 0 0 0 1 0 1 0 1 1 0 0 0 0 1\n" + - " 1 0 0 0 0 0 1 0 1 1 1 1 0 1 0 1 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 0 1 0\n" + - " 1 0 1 1 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 0 1 1\n" + - " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1\n" + - ">>\n"; - assertEquals(expected, qrCode.toString()); - } - - private static String shiftJISString(byte[] bytes) { - return new String(bytes, StringUtils.SHIFT_JIS_CHARSET); - } - -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/MaskUtilTestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/MaskUtilTestCase.java deleted file mode 100644 index 2cb6a29..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/MaskUtilTestCase.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.encoder; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author mysen@google.com (Chris Mysen) - ported from C++ - */ -public final class MaskUtilTestCase extends Assert { - - @Test - public void testApplyMaskPenaltyRule1() { - ByteMatrix matrix = new ByteMatrix(4, 1); - matrix.set(0, 0, 0); - matrix.set(1, 0, 0); - matrix.set(2, 0, 0); - matrix.set(3, 0, 0); - assertEquals(0, MaskUtil.applyMaskPenaltyRule1(matrix)); - // Horizontal. - matrix = new ByteMatrix(6, 1); - matrix.set(0, 0, 0); - matrix.set(1, 0, 0); - matrix.set(2, 0, 0); - matrix.set(3, 0, 0); - matrix.set(4, 0, 0); - matrix.set(5, 0, 1); - assertEquals(3, MaskUtil.applyMaskPenaltyRule1(matrix)); - matrix.set(5, 0, 0); - assertEquals(4, MaskUtil.applyMaskPenaltyRule1(matrix)); - // Vertical. - matrix = new ByteMatrix(1, 6); - matrix.set(0, 0, 0); - matrix.set(0, 1, 0); - matrix.set(0, 2, 0); - matrix.set(0, 3, 0); - matrix.set(0, 4, 0); - matrix.set(0, 5, 1); - assertEquals(3, MaskUtil.applyMaskPenaltyRule1(matrix)); - matrix.set(0, 5, 0); - assertEquals(4, MaskUtil.applyMaskPenaltyRule1(matrix)); - } - - @Test - public void testApplyMaskPenaltyRule2() { - ByteMatrix matrix = new ByteMatrix(1, 1); - matrix.set(0, 0, 0); - assertEquals(0, MaskUtil.applyMaskPenaltyRule2(matrix)); - matrix = new ByteMatrix(2, 2); - matrix.set(0, 0, 0); - matrix.set(1, 0, 0); - matrix.set(0, 1, 0); - matrix.set(1, 1, 1); - assertEquals(0, MaskUtil.applyMaskPenaltyRule2(matrix)); - matrix = new ByteMatrix(2, 2); - matrix.set(0, 0, 0); - matrix.set(1, 0, 0); - matrix.set(0, 1, 0); - matrix.set(1, 1, 0); - assertEquals(3, MaskUtil.applyMaskPenaltyRule2(matrix)); - matrix = new ByteMatrix(3, 3); - matrix.set(0, 0, 0); - matrix.set(1, 0, 0); - matrix.set(2, 0, 0); - matrix.set(0, 1, 0); - matrix.set(1, 1, 0); - matrix.set(2, 1, 0); - matrix.set(0, 2, 0); - matrix.set(1, 2, 0); - matrix.set(2, 2, 0); - // Four instances of 2x2 blocks. - assertEquals(3 * 4, MaskUtil.applyMaskPenaltyRule2(matrix)); - } - - @Test - public void testApplyMaskPenaltyRule3() { - // Horizontal 00001011101. - ByteMatrix matrix = new ByteMatrix(11, 1); - matrix.set(0, 0, 0); - matrix.set(1, 0, 0); - matrix.set(2, 0, 0); - matrix.set(3, 0, 0); - matrix.set(4, 0, 1); - matrix.set(5, 0, 0); - matrix.set(6, 0, 1); - matrix.set(7, 0, 1); - matrix.set(8, 0, 1); - matrix.set(9, 0, 0); - matrix.set(10, 0, 1); - assertEquals(40, MaskUtil.applyMaskPenaltyRule3(matrix)); - // Horizontal 10111010000. - matrix = new ByteMatrix(11, 1); - matrix.set(0, 0, 1); - matrix.set(1, 0, 0); - matrix.set(2, 0, 1); - matrix.set(3, 0, 1); - matrix.set(4, 0, 1); - matrix.set(5, 0, 0); - matrix.set(6, 0, 1); - matrix.set(7, 0, 0); - matrix.set(8, 0, 0); - matrix.set(9, 0, 0); - matrix.set(10, 0, 0); - assertEquals(40, MaskUtil.applyMaskPenaltyRule3(matrix)); - // Horizontal 1011101. - matrix = new ByteMatrix(7, 1); - matrix.set(0, 0, 1); - matrix.set(1, 0, 0); - matrix.set(2, 0, 1); - matrix.set(3, 0, 1); - matrix.set(4, 0, 1); - matrix.set(5, 0, 0); - matrix.set(6, 0, 1); - assertEquals(0, MaskUtil.applyMaskPenaltyRule3(matrix)); - // Vertical 00001011101. - matrix = new ByteMatrix(1, 11); - matrix.set(0, 0, 0); - matrix.set(0, 1, 0); - matrix.set(0, 2, 0); - matrix.set(0, 3, 0); - matrix.set(0, 4, 1); - matrix.set(0, 5, 0); - matrix.set(0, 6, 1); - matrix.set(0, 7, 1); - matrix.set(0, 8, 1); - matrix.set(0, 9, 0); - matrix.set(0, 10, 1); - assertEquals(40, MaskUtil.applyMaskPenaltyRule3(matrix)); - // Vertical 10111010000. - matrix = new ByteMatrix(1, 11); - matrix.set(0, 0, 1); - matrix.set(0, 1, 0); - matrix.set(0, 2, 1); - matrix.set(0, 3, 1); - matrix.set(0, 4, 1); - matrix.set(0, 5, 0); - matrix.set(0, 6, 1); - matrix.set(0, 7, 0); - matrix.set(0, 8, 0); - matrix.set(0, 9, 0); - matrix.set(0, 10, 0); - // Vertical 1011101. - matrix = new ByteMatrix(1, 7); - matrix.set(0, 0, 1); - matrix.set(0, 1, 0); - matrix.set(0, 2, 1); - matrix.set(0, 3, 1); - matrix.set(0, 4, 1); - matrix.set(0, 5, 0); - matrix.set(0, 6, 1); - assertEquals(0, MaskUtil.applyMaskPenaltyRule3(matrix)); - } - - @Test - public void testApplyMaskPenaltyRule4() { - // Dark cell ratio = 0% - ByteMatrix matrix = new ByteMatrix(1, 1); - matrix.set(0, 0, 0); - assertEquals(100, MaskUtil.applyMaskPenaltyRule4(matrix)); - // Dark cell ratio = 5% - matrix = new ByteMatrix(2, 1); - matrix.set(0, 0, 0); - matrix.set(0, 0, 1); - assertEquals(0, MaskUtil.applyMaskPenaltyRule4(matrix)); - // Dark cell ratio = 66.67% - matrix = new ByteMatrix(6, 1); - matrix.set(0, 0, 0); - matrix.set(1, 0, 1); - matrix.set(2, 0, 1); - matrix.set(3, 0, 1); - matrix.set(4, 0, 1); - matrix.set(5, 0, 0); - assertEquals(30, MaskUtil.applyMaskPenaltyRule4(matrix)); - } - - private static boolean testGetDataMaskBitInternal(int maskPattern, int[][] expected) { - for (int x = 0; x < 6; ++x) { - for (int y = 0; y < 6; ++y) { - if ((expected[y][x] == 1) != MaskUtil.getDataMaskBit(maskPattern, x, y)) { - return false; - } - } - } - return true; - } - - // See mask patterns on the page 43 of JISX0510:2004. - @Test - public void testGetDataMaskBit() { - int[][] mask0 = { - {1, 0, 1, 0, 1, 0}, - {0, 1, 0, 1, 0, 1}, - {1, 0, 1, 0, 1, 0}, - {0, 1, 0, 1, 0, 1}, - {1, 0, 1, 0, 1, 0}, - {0, 1, 0, 1, 0, 1}, - }; - assertTrue(testGetDataMaskBitInternal(0, mask0)); - int[][] mask1 = { - {1, 1, 1, 1, 1, 1}, - {0, 0, 0, 0, 0, 0}, - {1, 1, 1, 1, 1, 1}, - {0, 0, 0, 0, 0, 0}, - {1, 1, 1, 1, 1, 1}, - {0, 0, 0, 0, 0, 0}, - }; - assertTrue(testGetDataMaskBitInternal(1, mask1)); - int[][] mask2 = { - {1, 0, 0, 1, 0, 0}, - {1, 0, 0, 1, 0, 0}, - {1, 0, 0, 1, 0, 0}, - {1, 0, 0, 1, 0, 0}, - {1, 0, 0, 1, 0, 0}, - {1, 0, 0, 1, 0, 0}, - }; - assertTrue(testGetDataMaskBitInternal(2, mask2)); - int[][] mask3 = { - {1, 0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0, 1}, - {0, 1, 0, 0, 1, 0}, - {1, 0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0, 1}, - {0, 1, 0, 0, 1, 0}, - }; - assertTrue(testGetDataMaskBitInternal(3, mask3)); - int[][] mask4 = { - {1, 1, 1, 0, 0, 0}, - {1, 1, 1, 0, 0, 0}, - {0, 0, 0, 1, 1, 1}, - {0, 0, 0, 1, 1, 1}, - {1, 1, 1, 0, 0, 0}, - {1, 1, 1, 0, 0, 0}, - }; - assertTrue(testGetDataMaskBitInternal(4, mask4)); - int[][] mask5 = { - {1, 1, 1, 1, 1, 1}, - {1, 0, 0, 0, 0, 0}, - {1, 0, 0, 1, 0, 0}, - {1, 0, 1, 0, 1, 0}, - {1, 0, 0, 1, 0, 0}, - {1, 0, 0, 0, 0, 0}, - }; - assertTrue(testGetDataMaskBitInternal(5, mask5)); - int[][] mask6 = { - {1, 1, 1, 1, 1, 1}, - {1, 1, 1, 0, 0, 0}, - {1, 1, 0, 1, 1, 0}, - {1, 0, 1, 0, 1, 0}, - {1, 0, 1, 1, 0, 1}, - {1, 0, 0, 0, 1, 1}, - }; - assertTrue(testGetDataMaskBitInternal(6, mask6)); - int[][] mask7 = { - {1, 0, 1, 0, 1, 0}, - {0, 0, 0, 1, 1, 1}, - {1, 0, 0, 0, 1, 1}, - {0, 1, 0, 1, 0, 1}, - {1, 1, 1, 0, 0, 0}, - {0, 1, 1, 1, 0, 0}, - }; - assertTrue(testGetDataMaskBitInternal(7, mask7)); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/MatrixUtilTestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/MatrixUtilTestCase.java deleted file mode 100644 index fb9de59..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/MatrixUtilTestCase.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.encoder; - -import com.google.zxing.WriterException; -import com.google.zxing.common.BitArray; -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; -import com.google.zxing.qrcode.decoder.Version; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author mysen@google.com (Chris Mysen) - ported from C++ - */ -public final class MatrixUtilTestCase extends Assert { - - @Test - public void testToString() { - ByteMatrix array = new ByteMatrix(3, 3); - array.set(0, 0, 0); - array.set(1, 0, 1); - array.set(2, 0, 0); - array.set(0, 1, 1); - array.set(1, 1, 0); - array.set(2, 1, 1); - array.set(0, 2, -1); - array.set(1, 2, -1); - array.set(2, 2, -1); - String expected = " 0 1 0\n" + " 1 0 1\n" + " \n"; - assertEquals(expected, array.toString()); - } - - @Test - public void testClearMatrix() { - ByteMatrix matrix = new ByteMatrix(2, 2); - MatrixUtil.clearMatrix(matrix); - assertEquals(-1, matrix.get(0, 0)); - assertEquals(-1, matrix.get(1, 0)); - assertEquals(-1, matrix.get(0, 1)); - assertEquals(-1, matrix.get(1, 1)); - } - - @Test - public void testEmbedBasicPatterns1() throws WriterException { - // Version 1. - ByteMatrix matrix = new ByteMatrix(21, 21); - MatrixUtil.clearMatrix(matrix); - MatrixUtil.embedBasicPatterns(Version.getVersionForNumber(1), matrix); - String expected = - " 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 \n" + - " 0 \n" + - " 1 \n" + - " 0 \n" + - " 1 \n" + - " 0 0 0 0 0 0 0 0 1 \n" + - " 1 1 1 1 1 1 1 0 \n" + - " 1 0 0 0 0 0 1 0 \n" + - " 1 0 1 1 1 0 1 0 \n" + - " 1 0 1 1 1 0 1 0 \n" + - " 1 0 1 1 1 0 1 0 \n" + - " 1 0 0 0 0 0 1 0 \n" + - " 1 1 1 1 1 1 1 0 \n"; - assertEquals(expected, matrix.toString()); - } - - @Test - public void testEmbedBasicPatterns2() throws WriterException { - // Version 2. Position adjustment pattern should apppear at right - // bottom corner. - ByteMatrix matrix = new ByteMatrix(25, 25); - MatrixUtil.clearMatrix(matrix); - MatrixUtil.embedBasicPatterns(Version.getVersionForNumber(2), matrix); - String expected = - " 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 \n" + - " 0 \n" + - " 1 \n" + - " 0 \n" + - " 1 \n" + - " 0 \n" + - " 1 \n" + - " 0 \n" + - " 1 1 1 1 1 1 \n" + - " 0 0 0 0 0 0 0 0 1 1 0 0 0 1 \n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 \n" + - " 1 0 0 0 0 0 1 0 1 0 0 0 1 \n" + - " 1 0 1 1 1 0 1 0 1 1 1 1 1 \n" + - " 1 0 1 1 1 0 1 0 \n" + - " 1 0 1 1 1 0 1 0 \n" + - " 1 0 0 0 0 0 1 0 \n" + - " 1 1 1 1 1 1 1 0 \n"; - assertEquals(expected, matrix.toString()); - } - - @Test - public void testEmbedTypeInfo() throws WriterException { - // Type info bits = 100000011001110. - ByteMatrix matrix = new ByteMatrix(21, 21); - MatrixUtil.clearMatrix(matrix); - MatrixUtil.embedTypeInfo(ErrorCorrectionLevel.M, 5, matrix); - String expected = - " 0 \n" + - " 1 \n" + - " 1 \n" + - " 1 \n" + - " 0 \n" + - " 0 \n" + - " \n" + - " 1 \n" + - " 1 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 0 \n" + - " 0 \n" + - " 0 \n" + - " 0 \n" + - " 0 \n" + - " 0 \n" + - " 1 \n"; - assertEquals(expected, matrix.toString()); - } - - @Test - public void testEmbedVersionInfo() throws WriterException { - // Version info bits = 000111 110010 010100 - // Actually, version 7 QR Code has 45x45 matrix but we use 21x21 here - // since 45x45 matrix is too big to depict. - ByteMatrix matrix = new ByteMatrix(21, 21); - MatrixUtil.clearMatrix(matrix); - MatrixUtil.maybeEmbedVersionInfo(Version.getVersionForNumber(7), matrix); - String expected = - " 0 0 1 \n" + - " 0 1 0 \n" + - " 0 1 0 \n" + - " 0 1 1 \n" + - " 1 1 1 \n" + - " 0 0 0 \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 0 0 0 0 1 0 \n" + - " 0 1 1 1 1 0 \n" + - " 1 0 0 1 1 0 \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n"; - assertEquals(expected, matrix.toString()); - } - - @Test - public void testEmbedDataBits() throws WriterException { - // Cells other than basic patterns should be filled with zero. - ByteMatrix matrix = new ByteMatrix(21, 21); - MatrixUtil.clearMatrix(matrix); - MatrixUtil.embedBasicPatterns(Version.getVersionForNumber(1), matrix); - BitArray bits = new BitArray(); - MatrixUtil.embedDataBits(bits, -1, matrix); - String expected = - " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"; - assertEquals(expected, matrix.toString()); - } - - @Test - public void testBuildMatrix() throws WriterException { - // From http://www.swetake.com/qr/qr7.html - char[] bytes = {32, 65, 205, 69, 41, 220, 46, 128, 236, - 42, 159, 74, 221, 244, 169, 239, 150, 138, - 70, 237, 85, 224, 96, 74, 219 , 61}; - BitArray bits = new BitArray(); - for (char c: bytes) { - bits.appendBits(c, 8); - } - ByteMatrix matrix = new ByteMatrix(21, 21); - MatrixUtil.buildMatrix(bits, - ErrorCorrectionLevel.H, - Version.getVersionForNumber(1), // Version 1 - 3, // Mask pattern 3 - matrix); - String expected = - " 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 1 1 0 0 1 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0\n" + - " 0 0 1 1 0 0 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0\n" + - " 1 0 1 0 1 0 0 0 0 0 1 1 1 0 0 1 0 1 1 1 0\n" + - " 1 1 1 1 0 1 1 0 1 0 1 1 1 0 0 1 1 1 0 1 0\n" + - " 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 1 0 1 0\n" + - " 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 1\n" + - " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 0 1 0 1 1 0\n" + - " 1 0 0 0 0 0 1 0 0 0 0 1 0 1 1 1 0 0 0 0 0\n" + - " 1 0 1 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1\n" + - " 1 0 1 1 1 0 1 0 1 1 0 1 0 0 0 0 0 1 1 1 0\n" + - " 1 0 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 0 0\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0\n" + - " 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0\n"; - assertEquals(expected, matrix.toString()); - } - - @Test - public void testFindMSBSet() { - assertEquals(0, MatrixUtil.findMSBSet(0)); - assertEquals(1, MatrixUtil.findMSBSet(1)); - assertEquals(8, MatrixUtil.findMSBSet(0x80)); - assertEquals(32, MatrixUtil.findMSBSet(0x80000000)); - } - - @Test - public void testCalculateBCHCode() { - // Encoding of type information. - // From Appendix C in JISX0510:2004 (p 65) - assertEquals(0xdc, MatrixUtil.calculateBCHCode(5, 0x537)); - // From http://www.swetake.com/qr/qr6.html - assertEquals(0x1c2, MatrixUtil.calculateBCHCode(0x13, 0x537)); - // From http://www.swetake.com/qr/qr11.html - assertEquals(0x214, MatrixUtil.calculateBCHCode(0x1b, 0x537)); - - // Encoding of version information. - // From Appendix D in JISX0510:2004 (p 68) - assertEquals(0xc94, MatrixUtil.calculateBCHCode(7, 0x1f25)); - assertEquals(0x5bc, MatrixUtil.calculateBCHCode(8, 0x1f25)); - assertEquals(0xa99, MatrixUtil.calculateBCHCode(9, 0x1f25)); - assertEquals(0x4d3, MatrixUtil.calculateBCHCode(10, 0x1f25)); - assertEquals(0x9a6, MatrixUtil.calculateBCHCode(20, 0x1f25)); - assertEquals(0xd75, MatrixUtil.calculateBCHCode(30, 0x1f25)); - assertEquals(0xc69, MatrixUtil.calculateBCHCode(40, 0x1f25)); - } - - // We don't test a lot of cases in this function since we've already - // tested them in TEST(calculateBCHCode). - @Test - public void testMakeVersionInfoBits() throws WriterException { - // From Appendix D in JISX0510:2004 (p 68) - BitArray bits = new BitArray(); - MatrixUtil.makeVersionInfoBits(Version.getVersionForNumber(7), bits); - assertEquals(" ...XXXXX ..X..X.X ..", bits.toString()); - } - - // We don't test a lot of cases in this function since we've already - // tested them in TEST(calculateBCHCode). - @Test - public void testMakeTypeInfoInfoBits() throws WriterException { - // From Appendix C in JISX0510:2004 (p 65) - BitArray bits = new BitArray(); - MatrixUtil.makeTypeInfoBits(ErrorCorrectionLevel.M, 5, bits); - assertEquals(" X......X X..XXX.", bits.toString()); - } -} diff --git a/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/QRCodeTestCase.java b/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/QRCodeTestCase.java deleted file mode 100644 index dc198d5..0000000 --- a/port_src/core/src/test/java/com/google/zxing/qrcode/encoder/QRCodeTestCase.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.zxing.qrcode.encoder; - -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; -import com.google.zxing.qrcode.decoder.Mode; -import com.google.zxing.qrcode.decoder.Version; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author mysen@google.com (Chris Mysen) - ported from C++ - */ -public final class QRCodeTestCase extends Assert { - - @Test - public void test() { - QRCode qrCode = new QRCode(); - - // First, test simple setters and getters. - // We use numbers of version 7-H. - qrCode.setMode(Mode.BYTE); - qrCode.setECLevel(ErrorCorrectionLevel.H); - qrCode.setVersion(Version.getVersionForNumber(7)); - qrCode.setMaskPattern(3); - - assertSame(Mode.BYTE, qrCode.getMode()); - assertSame(ErrorCorrectionLevel.H, qrCode.getECLevel()); - assertEquals(7, qrCode.getVersion().getVersionNumber()); - assertEquals(3, qrCode.getMaskPattern()); - - // Prepare the matrix. - ByteMatrix matrix = new ByteMatrix(45, 45); - // Just set bogus zero/one values. - for (int y = 0; y < 45; ++y) { - for (int x = 0; x < 45; ++x) { - matrix.set(x, y, (y + x) % 2); - } - } - - // Set the matrix. - qrCode.setMatrix(matrix); - assertSame(matrix, qrCode.getMatrix()); - } - - @Test - public void testToString1() { - QRCode qrCode = new QRCode(); - String expected = - "<<\n" + - " mode: null\n" + - " ecLevel: null\n" + - " version: null\n" + - " maskPattern: -1\n" + - " matrix: null\n" + - ">>\n"; - assertEquals(expected, qrCode.toString()); - } - - @Test - public void testToString2() { - QRCode qrCode = new QRCode(); - qrCode.setMode(Mode.BYTE); - qrCode.setECLevel(ErrorCorrectionLevel.H); - qrCode.setVersion(Version.getVersionForNumber(1)); - qrCode.setMaskPattern(3); - ByteMatrix matrix = new ByteMatrix(21, 21); - for (int y = 0; y < 21; ++y) { - for (int x = 0; x < 21; ++x) { - matrix.set(x, y, (y + x) % 2); - } - } - qrCode.setMatrix(matrix); - String expected = "<<\n" + - " mode: BYTE\n" + - " ecLevel: H\n" + - " version: 1\n" + - " maskPattern: 3\n" + - " matrix:\n" + - " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + - " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + - " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + - " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + - " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + - " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + - " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + - " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + - " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + - " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + - " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + - " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + - " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + - " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + - " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + - " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + - " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + - " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + - " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + - " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + - " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + - ">>\n"; - assertEquals(expected, qrCode.toString()); - } - - @Test - public void testIsValidMaskPattern() { - assertFalse(QRCode.isValidMaskPattern(-1)); - assertTrue(QRCode.isValidMaskPattern(0)); - assertTrue(QRCode.isValidMaskPattern(7)); - assertFalse(QRCode.isValidMaskPattern(8)); - } - -} diff --git a/port_src/core/src/test/resources/benchmark/android-1/fail-1.jpg b/port_src/core/src/test/resources/benchmark/android-1/fail-1.jpg deleted file mode 100755 index 72699a1..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-1/fail-1.jpg and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-1/fail-2.jpg b/port_src/core/src/test/resources/benchmark/android-1/fail-2.jpg deleted file mode 100755 index 8f403d8..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-1/fail-2.jpg and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-1/fail-3.jpg b/port_src/core/src/test/resources/benchmark/android-1/fail-3.jpg deleted file mode 100755 index 1db5b5c..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-1/fail-3.jpg and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-1/fail-4.jpg b/port_src/core/src/test/resources/benchmark/android-1/fail-4.jpg deleted file mode 100755 index d603504..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-1/fail-4.jpg and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-1/qrcode-1.jpg b/port_src/core/src/test/resources/benchmark/android-1/qrcode-1.jpg deleted file mode 100755 index 2324d62..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-1/qrcode-1.jpg and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-1/qrcode-2.jpg b/port_src/core/src/test/resources/benchmark/android-1/qrcode-2.jpg deleted file mode 100755 index 67dad51..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-1/qrcode-2.jpg and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-1/qrcode-3.jpg b/port_src/core/src/test/resources/benchmark/android-1/qrcode-3.jpg deleted file mode 100755 index d3d75c4..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-1/qrcode-3.jpg and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-1/qrcode-4.jpg b/port_src/core/src/test/resources/benchmark/android-1/qrcode-4.jpg deleted file mode 100755 index 6ec3cd5..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-1/qrcode-4.jpg and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-1/upca-1.jpg b/port_src/core/src/test/resources/benchmark/android-1/upca-1.jpg deleted file mode 100755 index 982f43a..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-1/upca-1.jpg and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-1/upca-2.jpg b/port_src/core/src/test/resources/benchmark/android-1/upca-2.jpg deleted file mode 100755 index d02d642..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-1/upca-2.jpg and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-1/upca-3.jpg b/port_src/core/src/test/resources/benchmark/android-1/upca-3.jpg deleted file mode 100755 index b0d8949..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-1/upca-3.jpg and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-2/code128-1.png b/port_src/core/src/test/resources/benchmark/android-2/code128-1.png deleted file mode 100644 index 7ca6f3c..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-2/code128-1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-2/code39-1.png b/port_src/core/src/test/resources/benchmark/android-2/code39-1.png deleted file mode 100644 index f74e0af..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-2/code39-1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-2/datamatrix-1.png b/port_src/core/src/test/resources/benchmark/android-2/datamatrix-1.png deleted file mode 100644 index c4d8638..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-2/datamatrix-1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-2/ean13-1.png b/port_src/core/src/test/resources/benchmark/android-2/ean13-1.png deleted file mode 100644 index 45585de..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-2/ean13-1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-2/fail-1.png b/port_src/core/src/test/resources/benchmark/android-2/fail-1.png deleted file mode 100644 index a9ddf05..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-2/fail-1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-2/fail-2.png b/port_src/core/src/test/resources/benchmark/android-2/fail-2.png deleted file mode 100644 index 3fa1262..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-2/fail-2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-2/fail-3.png b/port_src/core/src/test/resources/benchmark/android-2/fail-3.png deleted file mode 100644 index 9ab4e60..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-2/fail-3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-2/itf-1.png b/port_src/core/src/test/resources/benchmark/android-2/itf-1.png deleted file mode 100644 index 451b5ed..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-2/itf-1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-2/pdf417-1.png b/port_src/core/src/test/resources/benchmark/android-2/pdf417-1.png deleted file mode 100644 index b0501ba..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-2/pdf417-1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-2/qrcode-1.png b/port_src/core/src/test/resources/benchmark/android-2/qrcode-1.png deleted file mode 100644 index 6432f49..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-2/qrcode-1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/benchmark/android-2/upca-1.png b/port_src/core/src/test/resources/benchmark/android-2/upca-1.png deleted file mode 100644 index a0f583a..0000000 Binary files a/port_src/core/src/test/resources/benchmark/android-2/upca-1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/.gitattributes b/port_src/core/src/test/resources/blackbox/.gitattributes deleted file mode 100644 index fa1385d..0000000 --- a/port_src/core/src/test/resources/blackbox/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* -text diff --git a/port_src/core/src/test/resources/blackbox/README b/port_src/core/src/test/resources/blackbox/README deleted file mode 100644 index 387f12d..0000000 --- a/port_src/core/src/test/resources/blackbox/README +++ /dev/null @@ -1 +0,0 @@ -Thanks to Enrique G-S for contributing many of the EAN-13 test images. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/7.png b/port_src/core/src/test/resources/blackbox/aztec-1/7.png deleted file mode 100644 index 2c7cfe8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/7.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/7.txt b/port_src/core/src/test/resources/blackbox/aztec-1/7.txt deleted file mode 100644 index b83fc50..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/7.txt +++ /dev/null @@ -1 +0,0 @@ -Code 2D! \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/Historico.png b/port_src/core/src/test/resources/blackbox/aztec-1/Historico.png deleted file mode 100644 index 3fe2bd0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/Historico.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/Historico.txt b/port_src/core/src/test/resources/blackbox/aztec-1/Historico.txt deleted file mode 100644 index 73d59fa..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/Historico.txt +++ /dev/null @@ -1 +0,0 @@ -Histórico \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/HistoricoLong.png b/port_src/core/src/test/resources/blackbox/aztec-1/HistoricoLong.png deleted file mode 100644 index 18103e6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/HistoricoLong.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/HistoricoLong.txt b/port_src/core/src/test/resources/blackbox/aztec-1/HistoricoLong.txt deleted file mode 100644 index 6ffe3b7..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/HistoricoLong.txt +++ /dev/null @@ -1 +0,0 @@ -Históóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóóórico \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/abc-19x19C.metadata.txt b/port_src/core/src/test/resources/blackbox/aztec-1/abc-19x19C.metadata.txt deleted file mode 100644 index 1f5cf22..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/abc-19x19C.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]z0 diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/abc-19x19C.png b/port_src/core/src/test/resources/blackbox/aztec-1/abc-19x19C.png deleted file mode 100644 index ffc782a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/abc-19x19C.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/abc-19x19C.txt b/port_src/core/src/test/resources/blackbox/aztec-1/abc-19x19C.txt deleted file mode 100644 index e85d5b4..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/abc-19x19C.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyz \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/abc-37x37.png b/port_src/core/src/test/resources/blackbox/aztec-1/abc-37x37.png deleted file mode 100644 index 3739189..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/abc-37x37.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/abc-37x37.txt b/port_src/core/src/test/resources/blackbox/aztec-1/abc-37x37.txt deleted file mode 100644 index f5a90a5..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/abc-37x37.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/dlusbs.png b/port_src/core/src/test/resources/blackbox/aztec-1/dlusbs.png deleted file mode 100644 index 8574be7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/dlusbs.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/dlusbs.txt b/port_src/core/src/test/resources/blackbox/aztec-1/dlusbs.txt deleted file mode 100644 index fc21ac8..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/dlusbs.txt +++ /dev/null @@ -1 +0,0 @@ -3333h3i3jITIT \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/hello.png b/port_src/core/src/test/resources/blackbox/aztec-1/hello.png deleted file mode 100644 index c720da8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/hello.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/hello.txt b/port_src/core/src/test/resources/blackbox/aztec-1/hello.txt deleted file mode 100644 index b6fc4c6..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/hello.txt +++ /dev/null @@ -1 +0,0 @@ -hello \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-075x075.png b/port_src/core/src/test/resources/blackbox/aztec-1/lorem-075x075.png deleted file mode 100644 index 139282a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-075x075.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-075x075.txt b/port_src/core/src/test/resources/blackbox/aztec-1/lorem-075x075.txt deleted file mode 100644 index 9b04afb..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-075x075.txt +++ /dev/null @@ -1 +0,0 @@ -In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu tristique ac, p \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-105x105.png b/port_src/core/src/test/resources/blackbox/aztec-1/lorem-105x105.png deleted file mode 100644 index f630e16..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-105x105.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-105x105.txt b/port_src/core/src/test/resources/blackbox/aztec-1/lorem-105x105.txt deleted file mode 100644 index 893acaf..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-105x105.txt +++ /dev/null @@ -1 +0,0 @@ -In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu tristique ac, p.In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu tristique ac, p \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-131x131.png b/port_src/core/src/test/resources/blackbox/aztec-1/lorem-131x131.png deleted file mode 100644 index 518d48f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-131x131.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-131x131.txt b/port_src/core/src/test/resources/blackbox/aztec-1/lorem-131x131.txt deleted file mode 100644 index 4acef72..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-131x131.txt +++ /dev/null @@ -1 +0,0 @@ -In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu tristique ac, p.In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu tristique ac, p. In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu tristique ac, p.In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu tris. In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo e. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-151x151.png b/port_src/core/src/test/resources/blackbox/aztec-1/lorem-151x151.png deleted file mode 100644 index c37468b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-151x151.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-151x151.txt b/port_src/core/src/test/resources/blackbox/aztec-1/lorem-151x151.txt deleted file mode 100644 index ab683d7..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/lorem-151x151.txt +++ /dev/null @@ -1 +0,0 @@ -In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu tristique ac, p.In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu tristique ac, p. In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu tristique ac, p.In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. Nulla ultrices, elit pellentesque aliquet laoreet, justo erat pulvinar nisi, id elementum sapien dolor et diam. Donec ac nunc sodales elit placerat eleifend. Sed ornare luctus ornare. Vestibulum vehicula, massa at pharetra fringilla, risus justo faucibus erat, nec porttitor nibh tellus sed est. Ut justo diam, lobortis eu tris. In ut magna vel mauris malesuada dictum. Nulla ullamcorper metus quis diam cursus facilisis. Sed mollis quam id justo rutrum sagittis. Donec laoreet rutrum est, nec convallis mauris condimentum sit amet. Phasellus gravida, justo et congue auctor, nisi ipsum viverra erat, eget hendrerit felis turpis nec lorem. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/tableShifts.png b/port_src/core/src/test/resources/blackbox/aztec-1/tableShifts.png deleted file mode 100644 index 6e3b086..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/tableShifts.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/tableShifts.txt b/port_src/core/src/test/resources/blackbox/aztec-1/tableShifts.txt deleted file mode 100644 index d23102f..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/tableShifts.txt +++ /dev/null @@ -1 +0,0 @@ -AhUUDgdy672;..:8KjHH776JHHn3g. 8lm/%22Nn873R2897ks4JKDJ9JJaza2323!::;09UJRrhDQSKJDKdSJSdskjdslkEdjseze:ze \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/tag.png b/port_src/core/src/test/resources/blackbox/aztec-1/tag.png deleted file mode 100644 index e969da5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/tag.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/tag.txt b/port_src/core/src/test/resources/blackbox/aztec-1/tag.txt deleted file mode 100644 index 029a248..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/tag.txt +++ /dev/null @@ -1 +0,0 @@ -Ceci est un tag. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/texte.png b/port_src/core/src/test/resources/blackbox/aztec-1/texte.png deleted file mode 100644 index 3c6a7c9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-1/texte.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-1/texte.txt b/port_src/core/src/test/resources/blackbox/aztec-1/texte.txt deleted file mode 100644 index d716a9f..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-1/texte.txt +++ /dev/null @@ -1 +0,0 @@ -Ceci est un texte! \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/01.png b/port_src/core/src/test/resources/blackbox/aztec-2/01.png deleted file mode 100755 index 4e91dc2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/01.txt b/port_src/core/src/test/resources/blackbox/aztec-2/01.txt deleted file mode 100644 index 60a24c0..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/01.txt +++ /dev/null @@ -1 +0,0 @@ -This is a real world Aztec barcode test. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/02.png b/port_src/core/src/test/resources/blackbox/aztec-2/02.png deleted file mode 100755 index 0385104..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/02.txt b/port_src/core/src/test/resources/blackbox/aztec-2/02.txt deleted file mode 100644 index 60a24c0..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/02.txt +++ /dev/null @@ -1 +0,0 @@ -This is a real world Aztec barcode test. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/03.png b/port_src/core/src/test/resources/blackbox/aztec-2/03.png deleted file mode 100755 index 51d9fe6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/03.txt b/port_src/core/src/test/resources/blackbox/aztec-2/03.txt deleted file mode 100644 index 60a24c0..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/03.txt +++ /dev/null @@ -1 +0,0 @@ -This is a real world Aztec barcode test. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/04.png b/port_src/core/src/test/resources/blackbox/aztec-2/04.png deleted file mode 100755 index 34ed31c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/04.txt b/port_src/core/src/test/resources/blackbox/aztec-2/04.txt deleted file mode 100644 index 60a24c0..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/04.txt +++ /dev/null @@ -1 +0,0 @@ -This is a real world Aztec barcode test. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/05.png b/port_src/core/src/test/resources/blackbox/aztec-2/05.png deleted file mode 100755 index 48d0bda..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/05.txt b/port_src/core/src/test/resources/blackbox/aztec-2/05.txt deleted file mode 100644 index 60a24c0..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/05.txt +++ /dev/null @@ -1 +0,0 @@ -This is a real world Aztec barcode test. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/06.png b/port_src/core/src/test/resources/blackbox/aztec-2/06.png deleted file mode 100755 index 9f6f6cb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/06.txt b/port_src/core/src/test/resources/blackbox/aztec-2/06.txt deleted file mode 100644 index 60a24c0..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/06.txt +++ /dev/null @@ -1 +0,0 @@ -This is a real world Aztec barcode test. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/07.png b/port_src/core/src/test/resources/blackbox/aztec-2/07.png deleted file mode 100755 index 3705ae3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/07.txt b/port_src/core/src/test/resources/blackbox/aztec-2/07.txt deleted file mode 100644 index 60a24c0..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/07.txt +++ /dev/null @@ -1 +0,0 @@ -This is a real world Aztec barcode test. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/08.png b/port_src/core/src/test/resources/blackbox/aztec-2/08.png deleted file mode 100755 index df07690..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/08.txt b/port_src/core/src/test/resources/blackbox/aztec-2/08.txt deleted file mode 100644 index 60a24c0..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/08.txt +++ /dev/null @@ -1 +0,0 @@ -This is a real world Aztec barcode test. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/09.png b/port_src/core/src/test/resources/blackbox/aztec-2/09.png deleted file mode 100755 index 87b5c99..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/09.txt b/port_src/core/src/test/resources/blackbox/aztec-2/09.txt deleted file mode 100644 index 30afa17..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/09.txt +++ /dev/null @@ -1 +0,0 @@ -mailto:zxing@googlegroups.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/10.png b/port_src/core/src/test/resources/blackbox/aztec-2/10.png deleted file mode 100755 index 830d38f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/10.txt b/port_src/core/src/test/resources/blackbox/aztec-2/10.txt deleted file mode 100644 index 30afa17..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/10.txt +++ /dev/null @@ -1 +0,0 @@ -mailto:zxing@googlegroups.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/11.png b/port_src/core/src/test/resources/blackbox/aztec-2/11.png deleted file mode 100755 index 650f682..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/11.txt b/port_src/core/src/test/resources/blackbox/aztec-2/11.txt deleted file mode 100644 index 30afa17..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/11.txt +++ /dev/null @@ -1 +0,0 @@ -mailto:zxing@googlegroups.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/12.png b/port_src/core/src/test/resources/blackbox/aztec-2/12.png deleted file mode 100755 index a38e6f6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/12.txt b/port_src/core/src/test/resources/blackbox/aztec-2/12.txt deleted file mode 100644 index 30afa17..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/12.txt +++ /dev/null @@ -1 +0,0 @@ -mailto:zxing@googlegroups.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/13.png b/port_src/core/src/test/resources/blackbox/aztec-2/13.png deleted file mode 100755 index c08006c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/13.txt b/port_src/core/src/test/resources/blackbox/aztec-2/13.txt deleted file mode 100644 index 30afa17..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/13.txt +++ /dev/null @@ -1 +0,0 @@ -mailto:zxing@googlegroups.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/14.png b/port_src/core/src/test/resources/blackbox/aztec-2/14.png deleted file mode 100755 index bfce4e6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/14.txt b/port_src/core/src/test/resources/blackbox/aztec-2/14.txt deleted file mode 100644 index 30afa17..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/14.txt +++ /dev/null @@ -1 +0,0 @@ -mailto:zxing@googlegroups.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/15.png b/port_src/core/src/test/resources/blackbox/aztec-2/15.png deleted file mode 100755 index b62bf4d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/15.txt b/port_src/core/src/test/resources/blackbox/aztec-2/15.txt deleted file mode 100644 index 30afa17..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/15.txt +++ /dev/null @@ -1 +0,0 @@ -mailto:zxing@googlegroups.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/16.png b/port_src/core/src/test/resources/blackbox/aztec-2/16.png deleted file mode 100755 index ce1cfde..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/16.txt b/port_src/core/src/test/resources/blackbox/aztec-2/16.txt deleted file mode 100644 index 8399dfe..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/16.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/17.png b/port_src/core/src/test/resources/blackbox/aztec-2/17.png deleted file mode 100755 index c3ecf49..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/17.txt b/port_src/core/src/test/resources/blackbox/aztec-2/17.txt deleted file mode 100644 index 8399dfe..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/17.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/18.png b/port_src/core/src/test/resources/blackbox/aztec-2/18.png deleted file mode 100755 index ed20f46..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/18.txt b/port_src/core/src/test/resources/blackbox/aztec-2/18.txt deleted file mode 100644 index 8399dfe..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/18.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/19.png b/port_src/core/src/test/resources/blackbox/aztec-2/19.png deleted file mode 100755 index 0103a9f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/19.txt b/port_src/core/src/test/resources/blackbox/aztec-2/19.txt deleted file mode 100644 index 8399dfe..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/19.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/20.png b/port_src/core/src/test/resources/blackbox/aztec-2/20.png deleted file mode 100755 index 9475e6b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/20.txt b/port_src/core/src/test/resources/blackbox/aztec-2/20.txt deleted file mode 100644 index 8399dfe..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/20.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/21.png b/port_src/core/src/test/resources/blackbox/aztec-2/21.png deleted file mode 100755 index ff5d143..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/21.txt b/port_src/core/src/test/resources/blackbox/aztec-2/21.txt deleted file mode 100644 index 8399dfe..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/21.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/22.png b/port_src/core/src/test/resources/blackbox/aztec-2/22.png deleted file mode 100755 index 2d96c9d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/aztec-2/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/aztec-2/22.txt b/port_src/core/src/test/resources/blackbox/aztec-2/22.txt deleted file mode 100644 index 8399dfe..0000000 --- a/port_src/core/src/test/resources/blackbox/aztec-2/22.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/01.metadata.txt b/port_src/core/src/test/resources/blackbox/codabar-1/01.metadata.txt deleted file mode 100644 index fb300fc..0000000 --- a/port_src/core/src/test/resources/blackbox/codabar-1/01.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]F0 diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/01.png b/port_src/core/src/test/resources/blackbox/codabar-1/01.png deleted file mode 100644 index 9b5f504..0000000 Binary files a/port_src/core/src/test/resources/blackbox/codabar-1/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/01.txt b/port_src/core/src/test/resources/blackbox/codabar-1/01.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/codabar-1/01.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/02.png b/port_src/core/src/test/resources/blackbox/codabar-1/02.png deleted file mode 100644 index f0c25ff..0000000 Binary files a/port_src/core/src/test/resources/blackbox/codabar-1/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/02.txt b/port_src/core/src/test/resources/blackbox/codabar-1/02.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/codabar-1/02.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/03.png b/port_src/core/src/test/resources/blackbox/codabar-1/03.png deleted file mode 100644 index 2a6bf91..0000000 Binary files a/port_src/core/src/test/resources/blackbox/codabar-1/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/03.txt b/port_src/core/src/test/resources/blackbox/codabar-1/03.txt deleted file mode 100644 index b8ec6e4..0000000 --- a/port_src/core/src/test/resources/blackbox/codabar-1/03.txt +++ /dev/null @@ -1 +0,0 @@ -294/586 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/04.png b/port_src/core/src/test/resources/blackbox/codabar-1/04.png deleted file mode 100644 index d0fb5c7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/codabar-1/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/04.txt b/port_src/core/src/test/resources/blackbox/codabar-1/04.txt deleted file mode 100644 index cf537db..0000000 --- a/port_src/core/src/test/resources/blackbox/codabar-1/04.txt +++ /dev/null @@ -1 +0,0 @@ -123455 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/09.png b/port_src/core/src/test/resources/blackbox/codabar-1/09.png deleted file mode 100644 index 549d50a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/codabar-1/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/09.txt b/port_src/core/src/test/resources/blackbox/codabar-1/09.txt deleted file mode 100644 index bd41cba..0000000 --- a/port_src/core/src/test/resources/blackbox/codabar-1/09.txt +++ /dev/null @@ -1 +0,0 @@ -12345 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/10.png b/port_src/core/src/test/resources/blackbox/codabar-1/10.png deleted file mode 100644 index 290d467..0000000 Binary files a/port_src/core/src/test/resources/blackbox/codabar-1/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/10.txt b/port_src/core/src/test/resources/blackbox/codabar-1/10.txt deleted file mode 100644 index 4632e06..0000000 --- a/port_src/core/src/test/resources/blackbox/codabar-1/10.txt +++ /dev/null @@ -1 +0,0 @@ -123456 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/11.png b/port_src/core/src/test/resources/blackbox/codabar-1/11.png deleted file mode 100644 index 3a05c3e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/codabar-1/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/11.txt b/port_src/core/src/test/resources/blackbox/codabar-1/11.txt deleted file mode 100644 index 675525a..0000000 --- a/port_src/core/src/test/resources/blackbox/codabar-1/11.txt +++ /dev/null @@ -1 +0,0 @@ -3419500 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/12.png b/port_src/core/src/test/resources/blackbox/codabar-1/12.png deleted file mode 100644 index 45d7995..0000000 Binary files a/port_src/core/src/test/resources/blackbox/codabar-1/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/12.txt b/port_src/core/src/test/resources/blackbox/codabar-1/12.txt deleted file mode 100644 index 8782ad7..0000000 --- a/port_src/core/src/test/resources/blackbox/codabar-1/12.txt +++ /dev/null @@ -1 +0,0 @@ -31117013206375 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/13.png b/port_src/core/src/test/resources/blackbox/codabar-1/13.png deleted file mode 100644 index c78270c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/codabar-1/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/13.txt b/port_src/core/src/test/resources/blackbox/codabar-1/13.txt deleted file mode 100644 index bd41cba..0000000 --- a/port_src/core/src/test/resources/blackbox/codabar-1/13.txt +++ /dev/null @@ -1 +0,0 @@ -12345 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/14.png b/port_src/core/src/test/resources/blackbox/codabar-1/14.png deleted file mode 100644 index d034407..0000000 Binary files a/port_src/core/src/test/resources/blackbox/codabar-1/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/14.txt b/port_src/core/src/test/resources/blackbox/codabar-1/14.txt deleted file mode 100644 index 8782ad7..0000000 --- a/port_src/core/src/test/resources/blackbox/codabar-1/14.txt +++ /dev/null @@ -1 +0,0 @@ -31117013206375 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/15.png b/port_src/core/src/test/resources/blackbox/codabar-1/15.png deleted file mode 100644 index ab82e04..0000000 Binary files a/port_src/core/src/test/resources/blackbox/codabar-1/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/codabar-1/15.txt b/port_src/core/src/test/resources/blackbox/codabar-1/15.txt deleted file mode 100644 index 4d38188..0000000 --- a/port_src/core/src/test/resources/blackbox/codabar-1/15.txt +++ /dev/null @@ -1 +0,0 @@ -123456789012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-1/1.metadata.txt b/port_src/core/src/test/resources/blackbox/code128-1/1.metadata.txt deleted file mode 100644 index 8e0da93..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-1/1.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]C1 diff --git a/port_src/core/src/test/resources/blackbox/code128-1/1.png b/port_src/core/src/test/resources/blackbox/code128-1/1.png deleted file mode 100644 index 6005428..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-1/1.txt b/port_src/core/src/test/resources/blackbox/code128-1/1.txt deleted file mode 100644 index a5aa28d..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -168901 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-1/2.metadata.txt b/port_src/core/src/test/resources/blackbox/code128-1/2.metadata.txt deleted file mode 100644 index d93697d..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-1/2.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]C0 diff --git a/port_src/core/src/test/resources/blackbox/code128-1/2.png b/port_src/core/src/test/resources/blackbox/code128-1/2.png deleted file mode 100644 index 4d4f4ba..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-1/2.txt b/port_src/core/src/test/resources/blackbox/code128-1/2.txt deleted file mode 100644 index 5d9d0d9..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-1/2.txt +++ /dev/null @@ -1 +0,0 @@ -Code 128 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-1/3.png b/port_src/core/src/test/resources/blackbox/code128-1/3.png deleted file mode 100644 index da88e52..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-1/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-1/3.txt b/port_src/core/src/test/resources/blackbox/code128-1/3.txt deleted file mode 100644 index 0bfc696..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-1/3.txt +++ /dev/null @@ -1 +0,0 @@ -102030405060708090 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-1/4.png b/port_src/core/src/test/resources/blackbox/code128-1/4.png deleted file mode 100644 index 9d2fff2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-1/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-1/4.txt b/port_src/core/src/test/resources/blackbox/code128-1/4.txt deleted file mode 100644 index 4632e06..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-1/4.txt +++ /dev/null @@ -1 +0,0 @@ -123456 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-1/5.png b/port_src/core/src/test/resources/blackbox/code128-1/5.png deleted file mode 100644 index ad71ae3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-1/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-1/5.txt b/port_src/core/src/test/resources/blackbox/code128-1/5.txt deleted file mode 100644 index 50bf455..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-1/5.txt +++ /dev/null @@ -1 +0,0 @@ -8101054321120021123456 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-1/6.png b/port_src/core/src/test/resources/blackbox/code128-1/6.png deleted file mode 100644 index 3d99da5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-1/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-1/6.txt b/port_src/core/src/test/resources/blackbox/code128-1/6.txt deleted file mode 100644 index ba09354..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-1/6.txt +++ /dev/null @@ -1 +0,0 @@ -óóóó1234óóabózz \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/01.png b/port_src/core/src/test/resources/blackbox/code128-2/01.png deleted file mode 100644 index 0a17958..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/01.txt b/port_src/core/src/test/resources/blackbox/code128-2/01.txt deleted file mode 100644 index a34fa65..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/01.txt +++ /dev/null @@ -1 +0,0 @@ -005-3379497200006 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/02.png b/port_src/core/src/test/resources/blackbox/code128-2/02.png deleted file mode 100644 index 8773ae9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/02.txt b/port_src/core/src/test/resources/blackbox/code128-2/02.txt deleted file mode 100644 index a34fa65..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/02.txt +++ /dev/null @@ -1 +0,0 @@ -005-3379497200006 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/03.png b/port_src/core/src/test/resources/blackbox/code128-2/03.png deleted file mode 100644 index c1c0372..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/03.txt b/port_src/core/src/test/resources/blackbox/code128-2/03.txt deleted file mode 100644 index a34fa65..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/03.txt +++ /dev/null @@ -1 +0,0 @@ -005-3379497200006 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/04.png b/port_src/core/src/test/resources/blackbox/code128-2/04.png deleted file mode 100644 index c06c62c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/04.txt b/port_src/core/src/test/resources/blackbox/code128-2/04.txt deleted file mode 100644 index a34fa65..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/04.txt +++ /dev/null @@ -1 +0,0 @@ -005-3379497200006 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/05.png b/port_src/core/src/test/resources/blackbox/code128-2/05.png deleted file mode 100644 index 06cefb6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/05.txt b/port_src/core/src/test/resources/blackbox/code128-2/05.txt deleted file mode 100644 index f8406b6..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/05.txt +++ /dev/null @@ -1 +0,0 @@ -15182881 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/06.png b/port_src/core/src/test/resources/blackbox/code128-2/06.png deleted file mode 100644 index 54728e3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/06.txt b/port_src/core/src/test/resources/blackbox/code128-2/06.txt deleted file mode 100644 index f8406b6..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/06.txt +++ /dev/null @@ -1 +0,0 @@ -15182881 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/07.png b/port_src/core/src/test/resources/blackbox/code128-2/07.png deleted file mode 100644 index 1a2652c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/07.txt b/port_src/core/src/test/resources/blackbox/code128-2/07.txt deleted file mode 100644 index f8406b6..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/07.txt +++ /dev/null @@ -1 +0,0 @@ -15182881 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/08.png b/port_src/core/src/test/resources/blackbox/code128-2/08.png deleted file mode 100644 index 24a5485..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/08.txt b/port_src/core/src/test/resources/blackbox/code128-2/08.txt deleted file mode 100644 index f8406b6..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/08.txt +++ /dev/null @@ -1 +0,0 @@ -15182881 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/09.png b/port_src/core/src/test/resources/blackbox/code128-2/09.png deleted file mode 100644 index e987d68..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/09.txt b/port_src/core/src/test/resources/blackbox/code128-2/09.txt deleted file mode 100644 index 545c961..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/09.txt +++ /dev/null @@ -1 +0,0 @@ -CNK8181G2C \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/10.png b/port_src/core/src/test/resources/blackbox/code128-2/10.png deleted file mode 100644 index df6b8db..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/10.txt b/port_src/core/src/test/resources/blackbox/code128-2/10.txt deleted file mode 100644 index 545c961..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/10.txt +++ /dev/null @@ -1 +0,0 @@ -CNK8181G2C \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/11.png b/port_src/core/src/test/resources/blackbox/code128-2/11.png deleted file mode 100644 index b604e46..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/11.txt b/port_src/core/src/test/resources/blackbox/code128-2/11.txt deleted file mode 100644 index 545c961..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/11.txt +++ /dev/null @@ -1 +0,0 @@ -CNK8181G2C \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/12.png b/port_src/core/src/test/resources/blackbox/code128-2/12.png deleted file mode 100644 index 5ea515d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/12.txt b/port_src/core/src/test/resources/blackbox/code128-2/12.txt deleted file mode 100644 index 545c961..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/12.txt +++ /dev/null @@ -1 +0,0 @@ -CNK8181G2C \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/13.png b/port_src/core/src/test/resources/blackbox/code128-2/13.png deleted file mode 100644 index fb97e47..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/13.txt b/port_src/core/src/test/resources/blackbox/code128-2/13.txt deleted file mode 100644 index 3e4497e..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/13.txt +++ /dev/null @@ -1 +0,0 @@ -1PEF224A4 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/14.png b/port_src/core/src/test/resources/blackbox/code128-2/14.png deleted file mode 100644 index 93e597e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/14.txt b/port_src/core/src/test/resources/blackbox/code128-2/14.txt deleted file mode 100644 index 3e4497e..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/14.txt +++ /dev/null @@ -1 +0,0 @@ -1PEF224A4 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/15.png b/port_src/core/src/test/resources/blackbox/code128-2/15.png deleted file mode 100644 index 21777a1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/15.txt b/port_src/core/src/test/resources/blackbox/code128-2/15.txt deleted file mode 100644 index 3e4497e..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/15.txt +++ /dev/null @@ -1 +0,0 @@ -1PEF224A4 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/16.png b/port_src/core/src/test/resources/blackbox/code128-2/16.png deleted file mode 100644 index 93d0790..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/16.txt b/port_src/core/src/test/resources/blackbox/code128-2/16.txt deleted file mode 100644 index 3e4497e..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/16.txt +++ /dev/null @@ -1 +0,0 @@ -1PEF224A4 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/17.png b/port_src/core/src/test/resources/blackbox/code128-2/17.png deleted file mode 100644 index 5772376..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/17.txt b/port_src/core/src/test/resources/blackbox/code128-2/17.txt deleted file mode 100644 index 75824d9..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/17.txt +++ /dev/null @@ -1 +0,0 @@ -FW727 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/18.png b/port_src/core/src/test/resources/blackbox/code128-2/18.png deleted file mode 100644 index 068478d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/18.txt b/port_src/core/src/test/resources/blackbox/code128-2/18.txt deleted file mode 100644 index 75824d9..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/18.txt +++ /dev/null @@ -1 +0,0 @@ -FW727 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/19.png b/port_src/core/src/test/resources/blackbox/code128-2/19.png deleted file mode 100644 index b03cc9f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/19.txt b/port_src/core/src/test/resources/blackbox/code128-2/19.txt deleted file mode 100644 index 75824d9..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/19.txt +++ /dev/null @@ -1 +0,0 @@ -FW727 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/20.png b/port_src/core/src/test/resources/blackbox/code128-2/20.png deleted file mode 100644 index e75f3bb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/20.txt b/port_src/core/src/test/resources/blackbox/code128-2/20.txt deleted file mode 100644 index 75824d9..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/20.txt +++ /dev/null @@ -1 +0,0 @@ -FW727 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/21.png b/port_src/core/src/test/resources/blackbox/code128-2/21.png deleted file mode 100644 index 626bc5f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/21.txt b/port_src/core/src/test/resources/blackbox/code128-2/21.txt deleted file mode 100644 index f093728..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/21.txt +++ /dev/null @@ -1 +0,0 @@ -005-3354174500018 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/22.png b/port_src/core/src/test/resources/blackbox/code128-2/22.png deleted file mode 100644 index 81666ea..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/22.txt b/port_src/core/src/test/resources/blackbox/code128-2/22.txt deleted file mode 100644 index f093728..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/22.txt +++ /dev/null @@ -1 +0,0 @@ -005-3354174500018 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/23.png b/port_src/core/src/test/resources/blackbox/code128-2/23.png deleted file mode 100644 index b2cabfd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/23.txt b/port_src/core/src/test/resources/blackbox/code128-2/23.txt deleted file mode 100644 index f093728..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/23.txt +++ /dev/null @@ -1 +0,0 @@ -005-3354174500018 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/24.png b/port_src/core/src/test/resources/blackbox/code128-2/24.png deleted file mode 100644 index 2cf6513..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/24.txt b/port_src/core/src/test/resources/blackbox/code128-2/24.txt deleted file mode 100644 index f093728..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/24.txt +++ /dev/null @@ -1 +0,0 @@ -005-3354174500018 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/25.png b/port_src/core/src/test/resources/blackbox/code128-2/25.png deleted file mode 100644 index d49bc6f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/25.txt b/port_src/core/src/test/resources/blackbox/code128-2/25.txt deleted file mode 100644 index ab6367f..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/25.txt +++ /dev/null @@ -1 +0,0 @@ -31001171800000017989625355702636 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/26.png b/port_src/core/src/test/resources/blackbox/code128-2/26.png deleted file mode 100644 index a1d074e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/26.txt b/port_src/core/src/test/resources/blackbox/code128-2/26.txt deleted file mode 100644 index ab6367f..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/26.txt +++ /dev/null @@ -1 +0,0 @@ -31001171800000017989625355702636 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/27.png b/port_src/core/src/test/resources/blackbox/code128-2/27.png deleted file mode 100644 index 0885124..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/27.txt b/port_src/core/src/test/resources/blackbox/code128-2/27.txt deleted file mode 100644 index ab6367f..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/27.txt +++ /dev/null @@ -1 +0,0 @@ -31001171800000017989625355702636 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/28.png b/port_src/core/src/test/resources/blackbox/code128-2/28.png deleted file mode 100644 index 83990dc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/28.txt b/port_src/core/src/test/resources/blackbox/code128-2/28.txt deleted file mode 100644 index ab6367f..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/28.txt +++ /dev/null @@ -1 +0,0 @@ -31001171800000017989625355702636 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/29.png b/port_src/core/src/test/resources/blackbox/code128-2/29.png deleted file mode 100644 index 32a5391..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/29.txt b/port_src/core/src/test/resources/blackbox/code128-2/29.txt deleted file mode 100644 index e7d384f..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/29.txt +++ /dev/null @@ -1 +0,0 @@ -42094043 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/30.png b/port_src/core/src/test/resources/blackbox/code128-2/30.png deleted file mode 100644 index bed8eeb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/30.txt b/port_src/core/src/test/resources/blackbox/code128-2/30.txt deleted file mode 100644 index e7d384f..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/30.txt +++ /dev/null @@ -1 +0,0 @@ -42094043 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/31.png b/port_src/core/src/test/resources/blackbox/code128-2/31.png deleted file mode 100644 index ce6a050..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/31.txt b/port_src/core/src/test/resources/blackbox/code128-2/31.txt deleted file mode 100644 index e7d384f..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/31.txt +++ /dev/null @@ -1 +0,0 @@ -42094043 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/32.png b/port_src/core/src/test/resources/blackbox/code128-2/32.png deleted file mode 100644 index 1966591..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/32.txt b/port_src/core/src/test/resources/blackbox/code128-2/32.txt deleted file mode 100644 index e7d384f..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/32.txt +++ /dev/null @@ -1 +0,0 @@ -42094043 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/33.png b/port_src/core/src/test/resources/blackbox/code128-2/33.png deleted file mode 100644 index 5869313..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/33.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/33.txt b/port_src/core/src/test/resources/blackbox/code128-2/33.txt deleted file mode 100644 index 1e4f8e3..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/33.txt +++ /dev/null @@ -1 +0,0 @@ -30885909173823 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/34.png b/port_src/core/src/test/resources/blackbox/code128-2/34.png deleted file mode 100644 index a957a36..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/34.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/34.txt b/port_src/core/src/test/resources/blackbox/code128-2/34.txt deleted file mode 100644 index 1e4f8e3..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/34.txt +++ /dev/null @@ -1 +0,0 @@ -30885909173823 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/35.png b/port_src/core/src/test/resources/blackbox/code128-2/35.png deleted file mode 100644 index 47f00f9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/35.txt b/port_src/core/src/test/resources/blackbox/code128-2/35.txt deleted file mode 100644 index 1e4f8e3..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/35.txt +++ /dev/null @@ -1 +0,0 @@ -30885909173823 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/36.png b/port_src/core/src/test/resources/blackbox/code128-2/36.png deleted file mode 100644 index 95841e8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/36.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/36.txt b/port_src/core/src/test/resources/blackbox/code128-2/36.txt deleted file mode 100644 index 1e4f8e3..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/36.txt +++ /dev/null @@ -1 +0,0 @@ -30885909173823 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/37.png b/port_src/core/src/test/resources/blackbox/code128-2/37.png deleted file mode 100644 index 005c68d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/37.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/37.txt b/port_src/core/src/test/resources/blackbox/code128-2/37.txt deleted file mode 100644 index 2aa6bce..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/37.txt +++ /dev/null @@ -1 +0,0 @@ -FGGQ6D1 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/38.png b/port_src/core/src/test/resources/blackbox/code128-2/38.png deleted file mode 100644 index 13011cc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/38.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/38.txt b/port_src/core/src/test/resources/blackbox/code128-2/38.txt deleted file mode 100644 index 2aa6bce..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/38.txt +++ /dev/null @@ -1 +0,0 @@ -FGGQ6D1 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/39.png b/port_src/core/src/test/resources/blackbox/code128-2/39.png deleted file mode 100644 index d5eb0a9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/39.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/39.txt b/port_src/core/src/test/resources/blackbox/code128-2/39.txt deleted file mode 100644 index 2aa6bce..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/39.txt +++ /dev/null @@ -1 +0,0 @@ -FGGQ6D1 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-2/40.png b/port_src/core/src/test/resources/blackbox/code128-2/40.png deleted file mode 100644 index 9f91cc8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-2/40.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-2/40.txt b/port_src/core/src/test/resources/blackbox/code128-2/40.txt deleted file mode 100644 index 2aa6bce..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-2/40.txt +++ /dev/null @@ -1 +0,0 @@ -FGGQ6D1 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-3/1.png b/port_src/core/src/test/resources/blackbox/code128-3/1.png deleted file mode 100644 index 0607a23..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-3/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-3/1.txt b/port_src/core/src/test/resources/blackbox/code128-3/1.txt deleted file mode 100644 index f55057e..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-3/1.txt +++ /dev/null @@ -1 +0,0 @@ -10064908 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code128-3/2.png b/port_src/core/src/test/resources/blackbox/code128-3/2.png deleted file mode 100644 index 0274a61..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code128-3/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code128-3/2.txt b/port_src/core/src/test/resources/blackbox/code128-3/2.txt deleted file mode 100644 index f2ea59d..0000000 --- a/port_src/core/src/test/resources/blackbox/code128-3/2.txt +++ /dev/null @@ -1 +0,0 @@ -10068408 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-1/1.metadata.txt b/port_src/core/src/test/resources/blackbox/code39-1/1.metadata.txt deleted file mode 100644 index cfe8ab1..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-1/1.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]A0 diff --git a/port_src/core/src/test/resources/blackbox/code39-1/1.png b/port_src/core/src/test/resources/blackbox/code39-1/1.png deleted file mode 100644 index d2fe31e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-1/1.txt b/port_src/core/src/test/resources/blackbox/code39-1/1.txt deleted file mode 100644 index c21ac75..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -TEST-SHEET \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-1/2.png b/port_src/core/src/test/resources/blackbox/code39-1/2.png deleted file mode 100644 index 98a5462..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-1/2.txt b/port_src/core/src/test/resources/blackbox/code39-1/2.txt deleted file mode 100644 index 4ed0aa9..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-1/2.txt +++ /dev/null @@ -1 +0,0 @@ - WWW.CITRONSOFT.COM \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-1/3.png b/port_src/core/src/test/resources/blackbox/code39-1/3.png deleted file mode 100644 index 461a15f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-1/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-1/3.txt b/port_src/core/src/test/resources/blackbox/code39-1/3.txt deleted file mode 100644 index 4e5ac1f..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-1/3.txt +++ /dev/null @@ -1 +0,0 @@ -MOROVIA \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-1/4.png b/port_src/core/src/test/resources/blackbox/code39-1/4.png deleted file mode 100644 index 7e917f7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-1/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-1/4.txt b/port_src/core/src/test/resources/blackbox/code39-1/4.txt deleted file mode 100644 index 8edce44..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-1/4.txt +++ /dev/null @@ -1 +0,0 @@ -ABC123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-2/1.png b/port_src/core/src/test/resources/blackbox/code39-2/1.png deleted file mode 100644 index a7fbb5c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-2/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-2/1.txt b/port_src/core/src/test/resources/blackbox/code39-2/1.txt deleted file mode 100644 index 40fe1ed..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-2/1.txt +++ /dev/null @@ -1 +0,0 @@ -Extended !?*# \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-2/2.png b/port_src/core/src/test/resources/blackbox/code39-2/2.png deleted file mode 100644 index 77add61..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-2/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-2/2.txt b/port_src/core/src/test/resources/blackbox/code39-2/2.txt deleted file mode 100644 index 882383b..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-2/2.txt +++ /dev/null @@ -1 +0,0 @@ -12ab \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/01.png b/port_src/core/src/test/resources/blackbox/code39-3/01.png deleted file mode 100644 index 8b2891d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/01.txt b/port_src/core/src/test/resources/blackbox/code39-3/01.txt deleted file mode 100644 index 9fead42..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/01.txt +++ /dev/null @@ -1 +0,0 @@ -165627 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/02.png b/port_src/core/src/test/resources/blackbox/code39-3/02.png deleted file mode 100644 index 84ae58b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/02.txt b/port_src/core/src/test/resources/blackbox/code39-3/02.txt deleted file mode 100644 index 9fead42..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/02.txt +++ /dev/null @@ -1 +0,0 @@ -165627 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/03.png b/port_src/core/src/test/resources/blackbox/code39-3/03.png deleted file mode 100644 index 09cf586..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/03.txt b/port_src/core/src/test/resources/blackbox/code39-3/03.txt deleted file mode 100644 index ab1000e..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/03.txt +++ /dev/null @@ -1 +0,0 @@ -001EC947D49B \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/04.png b/port_src/core/src/test/resources/blackbox/code39-3/04.png deleted file mode 100644 index 21a6edd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/04.txt b/port_src/core/src/test/resources/blackbox/code39-3/04.txt deleted file mode 100644 index ab1000e..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/04.txt +++ /dev/null @@ -1 +0,0 @@ -001EC947D49B \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/05.png b/port_src/core/src/test/resources/blackbox/code39-3/05.png deleted file mode 100644 index 1959e97..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/05.txt b/port_src/core/src/test/resources/blackbox/code39-3/05.txt deleted file mode 100644 index ab1000e..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/05.txt +++ /dev/null @@ -1 +0,0 @@ -001EC947D49B \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/06.png b/port_src/core/src/test/resources/blackbox/code39-3/06.png deleted file mode 100644 index 4b5b075..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/06.txt b/port_src/core/src/test/resources/blackbox/code39-3/06.txt deleted file mode 100644 index 897a2d8..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/06.txt +++ /dev/null @@ -1 +0,0 @@ -165340 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/07.png b/port_src/core/src/test/resources/blackbox/code39-3/07.png deleted file mode 100644 index 897b171..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/07.txt b/port_src/core/src/test/resources/blackbox/code39-3/07.txt deleted file mode 100644 index 897a2d8..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/07.txt +++ /dev/null @@ -1 +0,0 @@ -165340 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/08.png b/port_src/core/src/test/resources/blackbox/code39-3/08.png deleted file mode 100644 index 9bc051d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/08.txt b/port_src/core/src/test/resources/blackbox/code39-3/08.txt deleted file mode 100644 index 897a2d8..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/08.txt +++ /dev/null @@ -1 +0,0 @@ -165340 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/09.png b/port_src/core/src/test/resources/blackbox/code39-3/09.png deleted file mode 100644 index b37ced4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/09.txt b/port_src/core/src/test/resources/blackbox/code39-3/09.txt deleted file mode 100644 index 897a2d8..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/09.txt +++ /dev/null @@ -1 +0,0 @@ -165340 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/10.png b/port_src/core/src/test/resources/blackbox/code39-3/10.png deleted file mode 100644 index 2946604..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/10.txt b/port_src/core/src/test/resources/blackbox/code39-3/10.txt deleted file mode 100644 index 400ea68..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/10.txt +++ /dev/null @@ -1 +0,0 @@ -001EC94767E0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/11.png b/port_src/core/src/test/resources/blackbox/code39-3/11.png deleted file mode 100644 index 8abfad2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/11.txt b/port_src/core/src/test/resources/blackbox/code39-3/11.txt deleted file mode 100644 index 400ea68..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/11.txt +++ /dev/null @@ -1 +0,0 @@ -001EC94767E0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/12.png b/port_src/core/src/test/resources/blackbox/code39-3/12.png deleted file mode 100644 index 42d9368..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/12.txt b/port_src/core/src/test/resources/blackbox/code39-3/12.txt deleted file mode 100644 index 400ea68..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/12.txt +++ /dev/null @@ -1 +0,0 @@ -001EC94767E0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/13.png b/port_src/core/src/test/resources/blackbox/code39-3/13.png deleted file mode 100644 index 722c9ef..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/13.txt b/port_src/core/src/test/resources/blackbox/code39-3/13.txt deleted file mode 100644 index 400ea68..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/13.txt +++ /dev/null @@ -1 +0,0 @@ -001EC94767E0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/14.png b/port_src/core/src/test/resources/blackbox/code39-3/14.png deleted file mode 100644 index 1be4473..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/14.txt b/port_src/core/src/test/resources/blackbox/code39-3/14.txt deleted file mode 100644 index 9e87084..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/14.txt +++ /dev/null @@ -1 +0,0 @@ -404785 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/15.png b/port_src/core/src/test/resources/blackbox/code39-3/15.png deleted file mode 100644 index b292dff..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/15.txt b/port_src/core/src/test/resources/blackbox/code39-3/15.txt deleted file mode 100644 index 9e87084..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/15.txt +++ /dev/null @@ -1 +0,0 @@ -404785 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/16.png b/port_src/core/src/test/resources/blackbox/code39-3/16.png deleted file mode 100644 index a3255cd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/16.txt b/port_src/core/src/test/resources/blackbox/code39-3/16.txt deleted file mode 100644 index 9e87084..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/16.txt +++ /dev/null @@ -1 +0,0 @@ -404785 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code39-3/17.png b/port_src/core/src/test/resources/blackbox/code39-3/17.png deleted file mode 100644 index 788948f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code39-3/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code39-3/17.txt b/port_src/core/src/test/resources/blackbox/code39-3/17.txt deleted file mode 100644 index 9e87084..0000000 --- a/port_src/core/src/test/resources/blackbox/code39-3/17.txt +++ /dev/null @@ -1 +0,0 @@ -404785 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code93-1/1.metadata.txt b/port_src/core/src/test/resources/blackbox/code93-1/1.metadata.txt deleted file mode 100644 index 6cc5a64..0000000 --- a/port_src/core/src/test/resources/blackbox/code93-1/1.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]G0 diff --git a/port_src/core/src/test/resources/blackbox/code93-1/1.png b/port_src/core/src/test/resources/blackbox/code93-1/1.png deleted file mode 100644 index bc9ef62..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code93-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code93-1/1.txt b/port_src/core/src/test/resources/blackbox/code93-1/1.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/code93-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code93-1/2.png b/port_src/core/src/test/resources/blackbox/code93-1/2.png deleted file mode 100644 index 1afbfcb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code93-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code93-1/2.txt b/port_src/core/src/test/resources/blackbox/code93-1/2.txt deleted file mode 100644 index f6df9d7..0000000 --- a/port_src/core/src/test/resources/blackbox/code93-1/2.txt +++ /dev/null @@ -1 +0,0 @@ -CODE 93 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/code93-1/3.png b/port_src/core/src/test/resources/blackbox/code93-1/3.png deleted file mode 100644 index ea39b8e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/code93-1/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/code93-1/3.txt b/port_src/core/src/test/resources/blackbox/code93-1/3.txt deleted file mode 100644 index 418d6c3..0000000 --- a/port_src/core/src/test/resources/blackbox/code93-1/3.txt +++ /dev/null @@ -1 +0,0 @@ -DATA \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/0123456789.metadata.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/0123456789.metadata.txt deleted file mode 100644 index 80c1d0c..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/0123456789.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]d1 diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/0123456789.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/0123456789.png deleted file mode 100644 index dbe5122..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/0123456789.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/0123456789.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/0123456789.txt deleted file mode 100644 index ad47100..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/0123456789.txt +++ /dev/null @@ -1 +0,0 @@ -0123456789 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/C40.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/C40.png deleted file mode 100644 index 4d39159..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/C40.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/C40.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/C40.txt deleted file mode 100644 index 1dfb73f..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/C40.txt +++ /dev/null @@ -1 +0,0 @@ -Testing C40 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/EDIFACT.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/EDIFACT.png deleted file mode 100644 index cbf9006..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/EDIFACT.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/EDIFACT.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/EDIFACT.txt deleted file mode 100644 index ea5d812..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/EDIFACT.txt +++ /dev/null @@ -1 +0,0 @@ -EDIFACTEDIFACT \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/GUID.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/GUID.png deleted file mode 100644 index 183175b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/GUID.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/GUID.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/GUID.txt deleted file mode 100644 index 0a226ac..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/GUID.txt +++ /dev/null @@ -1 +0,0 @@ -10f27ce-acb7-4e4e-a7ae-a0b98da6ed4a \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa.png deleted file mode 100644 index 46e0051..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa.txt deleted file mode 100644 index 5e1c309..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa.txt +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_1_error_byte.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_1_error_byte.png deleted file mode 100644 index 223b757..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_1_error_byte.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_1_error_byte.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_1_error_byte.txt deleted file mode 100644 index 5e1c309..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_1_error_byte.txt +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_2_error_byte.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_2_error_byte.png deleted file mode 100644 index 030fa5f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_2_error_byte.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_2_error_byte.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_2_error_byte.txt deleted file mode 100644 index 5e1c309..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_2_error_byte.txt +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_3_error_byte.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_3_error_byte.png deleted file mode 100644 index 230f97c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_3_error_byte.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_3_error_byte.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_3_error_byte.txt deleted file mode 100644 index 5e1c309..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_3_error_byte.txt +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_4_error_byte.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_4_error_byte.png deleted file mode 100644 index 4a66877..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_4_error_byte.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_4_error_byte.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_4_error_byte.txt deleted file mode 100644 index 5e1c309..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_4_error_byte.txt +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_6_error_byte.png.error b/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_6_error_byte.png.error deleted file mode 100644 index 35a2795..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_6_error_byte.png.error and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_6_error_byte.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_6_error_byte.txt deleted file mode 100644 index 5e1c309..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/HelloWorld_Text_L_Kaywa_6_error_byte.txt +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/X12.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/X12.png deleted file mode 100644 index af766f5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/X12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/X12.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/X12.txt deleted file mode 100644 index 68f83f8..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/X12.txt +++ /dev/null @@ -1 +0,0 @@ -X12X12X12X12 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-18x8.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-18x8.png deleted file mode 100644 index c58bc75..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-18x8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-18x8.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-18x8.txt deleted file mode 100644 index 6a81654..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-18x8.txt +++ /dev/null @@ -1 +0,0 @@ -abcde \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-26x12.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-26x12.png deleted file mode 100644 index 8f41fa7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-26x12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-26x12.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-26x12.txt deleted file mode 100644 index f9fb130..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-26x12.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklm \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-32x8.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-32x8.png deleted file mode 100644 index f0f1292..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-32x8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-32x8.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-32x8.txt deleted file mode 100644 index d96dc95..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-32x8.txt +++ /dev/null @@ -1 +0,0 @@ -abcdef \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-36x12.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-36x12.png deleted file mode 100644 index 72f90ec..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-36x12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-36x12.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-36x12.txt deleted file mode 100644 index 3005ca6..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-36x12.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopq \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-36x16.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-36x16.png deleted file mode 100644 index 2a1a05c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-36x16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-36x16.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-36x16.txt deleted file mode 100644 index e85d5b4..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-36x16.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyz \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-48x16.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-48x16.png deleted file mode 100644 index f6ee357..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-48x16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-48x16.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-48x16.txt deleted file mode 100644 index 7997473..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-48x16.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-52x52-IDAutomation.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-52x52-IDAutomation.png deleted file mode 100644 index 8b0e2a1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-52x52-IDAutomation.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-52x52-IDAutomation.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-52x52-IDAutomation.txt deleted file mode 100644 index d01ae5a..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-52x52-IDAutomation.txt +++ /dev/null @@ -1 +0,0 @@ -abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-52x52.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-52x52.png deleted file mode 100644 index 01283fe..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-52x52.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-52x52.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-52x52.txt deleted file mode 100644 index d01ae5a..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcd-52x52.txt +++ /dev/null @@ -1 +0,0 @@ -abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcdefg-64x64.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcdefg-64x64.png deleted file mode 100644 index 048cea7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcdefg-64x64.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcdefg-64x64.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcdefg-64x64.txt deleted file mode 100644 index 6285fc2..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcdefg-64x64.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcdefg.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcdefg.png deleted file mode 100644 index b005ee5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcdefg.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcdefg.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/abcdefg.txt deleted file mode 100644 index a2d2b73..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/abcdefg.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/zxing_URL_L_Kayway.png b/port_src/core/src/test/resources/blackbox/datamatrix-1/zxing_URL_L_Kayway.png deleted file mode 100644 index abf7a73..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-1/zxing_URL_L_Kayway.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-1/zxing_URL_L_Kayway.txt b/port_src/core/src/test/resources/blackbox/datamatrix-1/zxing_URL_L_Kayway.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-1/zxing_URL_L_Kayway.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/01.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/01.png deleted file mode 100644 index 2401b62..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/01.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/01.txt deleted file mode 100644 index f86d0df..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/01.txt +++ /dev/null @@ -1 +0,0 @@ -http://google.com/m \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/02.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/02.png deleted file mode 100644 index dd6cc7d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/02.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/02.txt deleted file mode 100644 index f86d0df..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/02.txt +++ /dev/null @@ -1 +0,0 @@ -http://google.com/m \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/03.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/03.png deleted file mode 100644 index ef2b8a6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/03.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/03.txt deleted file mode 100644 index f86d0df..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/03.txt +++ /dev/null @@ -1 +0,0 @@ -http://google.com/m \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/04.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/04.png deleted file mode 100644 index 1b2350f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/04.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/04.txt deleted file mode 100644 index f86d0df..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/04.txt +++ /dev/null @@ -1 +0,0 @@ -http://google.com/m \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/05.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/05.png deleted file mode 100644 index eb0b9f1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/05.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/05.txt deleted file mode 100644 index f86d0df..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/05.txt +++ /dev/null @@ -1 +0,0 @@ -http://google.com/m \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/06.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/06.png deleted file mode 100644 index 0e7a6ae..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/06.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/06.txt deleted file mode 100644 index f86d0df..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/06.txt +++ /dev/null @@ -1 +0,0 @@ -http://google.com/m \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/07.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/07.png deleted file mode 100644 index 2bd6e4d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/07.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/07.txt deleted file mode 100644 index f86d0df..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/07.txt +++ /dev/null @@ -1 +0,0 @@ -http://google.com/m \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/08.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/08.png deleted file mode 100644 index 11dff7c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/08.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/08.txt deleted file mode 100644 index f86d0df..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/08.txt +++ /dev/null @@ -1 +0,0 @@ -http://google.com/m \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/09.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/09.png deleted file mode 100644 index 4c22c38..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/09.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/09.txt deleted file mode 100644 index a8ae2d5..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/09.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test of our DataMatrix support using a longer piece of text, and therefore a more dense barcode. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/10.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/10.png deleted file mode 100644 index 725d3ff..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/10.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/10.txt deleted file mode 100644 index a8ae2d5..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/10.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test of our DataMatrix support using a longer piece of text, and therefore a more dense barcode. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/11.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/11.png deleted file mode 100644 index 40418e4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/11.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/11.txt deleted file mode 100644 index a8ae2d5..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/11.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test of our DataMatrix support using a longer piece of text, and therefore a more dense barcode. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/12.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/12.png deleted file mode 100644 index 5173109..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/12.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/12.txt deleted file mode 100644 index a8ae2d5..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/12.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test of our DataMatrix support using a longer piece of text, and therefore a more dense barcode. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/13.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/13.png deleted file mode 100644 index 8dff8dc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/13.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/13.txt deleted file mode 100644 index a8ae2d5..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/13.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test of our DataMatrix support using a longer piece of text, and therefore a more dense barcode. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/14.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/14.png deleted file mode 100644 index 7c84e59..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/14.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/14.txt deleted file mode 100644 index a8ae2d5..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/14.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test of our DataMatrix support using a longer piece of text, and therefore a more dense barcode. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/15.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/15.png deleted file mode 100644 index bf757fd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/15.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/15.txt deleted file mode 100644 index a8ae2d5..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/15.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test of our DataMatrix support using a longer piece of text, and therefore a more dense barcode. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/16.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/16.png deleted file mode 100644 index 7157853..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/16.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/16.txt deleted file mode 100644 index a8ae2d5..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/16.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test of our DataMatrix support using a longer piece of text, and therefore a more dense barcode. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/17.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/17.png deleted file mode 100644 index a08d0ea..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/17.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/17.txt deleted file mode 100644 index a8ae2d5..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/17.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test of our DataMatrix support using a longer piece of text, and therefore a more dense barcode. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/18.png b/port_src/core/src/test/resources/blackbox/datamatrix-2/18.png deleted file mode 100644 index 0aa34c7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-2/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-2/18.txt b/port_src/core/src/test/resources/blackbox/datamatrix-2/18.txt deleted file mode 100644 index a8ae2d5..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-2/18.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test of our DataMatrix support using a longer piece of text, and therefore a more dense barcode. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-120x8.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-120x8.png deleted file mode 100644 index 434c36f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-120x8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-120x8.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-120x8.txt deleted file mode 100644 index 9983cac..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-120x8.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-144x8.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-144x8.png deleted file mode 100644 index 162534b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-144x8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-144x8.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-144x8.txt deleted file mode 100644 index 0c2c90c..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-144x8.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmno \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-36x20.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-36x20.png deleted file mode 100644 index fefc8b1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-36x20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-36x20.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-36x20.txt deleted file mode 100644 index 85c1ced..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-36x20.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-40x26.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-40x26.png deleted file mode 100644 index 513b955..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-40x26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-40x26.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-40x26.txt deleted file mode 100644 index 1ec77a6..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-40x26.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-44x20.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-44x20.png deleted file mode 100644 index 92e5846..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-44x20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-44x20.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-44x20.txt deleted file mode 100644 index d2d974b..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-44x20.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x22.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x22.png deleted file mode 100644 index 3afdc67..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x22.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x22.txt deleted file mode 100644 index 4fb53ed..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x22.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x24.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x24.png deleted file mode 100644 index 086bf62..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x24.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x24.txt deleted file mode 100644 index dc130c1..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x24.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x26.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x26.png deleted file mode 100644 index 3c2ff49..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x26.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x26.txt deleted file mode 100644 index 5638fa4..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x26.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x8.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x8.png deleted file mode 100644 index 42cbdd3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x8.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x8.txt deleted file mode 100644 index dcc7623..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-48x8.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxy \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x12.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x12.png deleted file mode 100644 index 66055df..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x12.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x12.txt deleted file mode 100644 index 8044e8b..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x12.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x16.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x16.png deleted file mode 100644 index 70c39c7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x16.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x16.txt deleted file mode 100644 index e3cd4cd..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x16.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x20.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x20.png deleted file mode 100644 index 1472a6a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x20.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x20.txt deleted file mode 100644 index 0afff33..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x20.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x24.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x24.png deleted file mode 100644 index 904b384..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x24.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x24.txt deleted file mode 100644 index 54469b9..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x24.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x26.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x26.png deleted file mode 100644 index 59e0da3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x26.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x26.txt deleted file mode 100644 index ae6c51b..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x26.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x8.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x8.png deleted file mode 100644 index 8677d60..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x8.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x8.txt deleted file mode 100644 index 448031a..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-64x8.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefgh \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-80x8.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-80x8.png deleted file mode 100644 index 05b36df..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-80x8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-80x8.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-80x8.txt deleted file mode 100644 index 5b9fb2c..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-80x8.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-88x12.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-88x12.png deleted file mode 100644 index 87fa003..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-88x12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-88x12.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-88x12.txt deleted file mode 100644 index 6a1af83..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-88x12.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-96x8.png b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-96x8.png deleted file mode 100644 index d27f5a3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-96x8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-96x8.txt b/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-96x8.txt deleted file mode 100644 index 4c68c05..0000000 --- a/port_src/core/src/test/resources/blackbox/datamatrix-3/abcd-96x8.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/1.metadata.txt b/port_src/core/src/test/resources/blackbox/ean13-1/1.metadata.txt deleted file mode 100644 index 0daadb4..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/1.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]E0 diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/1.png b/port_src/core/src/test/resources/blackbox/ean13-1/1.png deleted file mode 100644 index 0a51478..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/1.txt b/port_src/core/src/test/resources/blackbox/ean13-1/1.txt deleted file mode 100644 index 2bed7f6..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -8413000065504 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/10.png b/port_src/core/src/test/resources/blackbox/ean13-1/10.png deleted file mode 100644 index 58903e1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/10.txt b/port_src/core/src/test/resources/blackbox/ean13-1/10.txt deleted file mode 100644 index 7d7c3d9..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/10.txt +++ /dev/null @@ -1 +0,0 @@ -8480010001136 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/12.png b/port_src/core/src/test/resources/blackbox/ean13-1/12.png deleted file mode 100644 index 645bfcd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/12.txt b/port_src/core/src/test/resources/blackbox/ean13-1/12.txt deleted file mode 100644 index 3f2faf2..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/12.txt +++ /dev/null @@ -1 +0,0 @@ -5201815331227 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/13.png b/port_src/core/src/test/resources/blackbox/ean13-1/13.png deleted file mode 100644 index 9a0a193..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/13.txt b/port_src/core/src/test/resources/blackbox/ean13-1/13.txt deleted file mode 100644 index 8cf1aed..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/13.txt +++ /dev/null @@ -1 +0,0 @@ -8413600298517 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/14.png b/port_src/core/src/test/resources/blackbox/ean13-1/14.png deleted file mode 100644 index f6f4b8f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/14.txt b/port_src/core/src/test/resources/blackbox/ean13-1/14.txt deleted file mode 100644 index 8e2c07e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/14.txt +++ /dev/null @@ -1 +0,0 @@ -3560070169443 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/15.png b/port_src/core/src/test/resources/blackbox/ean13-1/15.png deleted file mode 100644 index 68ce984..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/15.txt b/port_src/core/src/test/resources/blackbox/ean13-1/15.txt deleted file mode 100644 index 313c9f0..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/15.txt +++ /dev/null @@ -1 +0,0 @@ -4045787034318 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/18.png b/port_src/core/src/test/resources/blackbox/ean13-1/18.png deleted file mode 100644 index c518046..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/18.txt b/port_src/core/src/test/resources/blackbox/ean13-1/18.txt deleted file mode 100644 index fd2c67c..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/18.txt +++ /dev/null @@ -1 +0,0 @@ -3086126100326 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/19.png b/port_src/core/src/test/resources/blackbox/ean13-1/19.png deleted file mode 100644 index 1243b69..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/19.txt b/port_src/core/src/test/resources/blackbox/ean13-1/19.txt deleted file mode 100644 index c839e11..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/19.txt +++ /dev/null @@ -1 +0,0 @@ -4820024790635 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/2.png b/port_src/core/src/test/resources/blackbox/ean13-1/2.png deleted file mode 100644 index 3cac546..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/2.txt b/port_src/core/src/test/resources/blackbox/ean13-1/2.txt deleted file mode 100644 index bbefd6e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/2.txt +++ /dev/null @@ -1 +0,0 @@ -8480010092271 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/20.png b/port_src/core/src/test/resources/blackbox/ean13-1/20.png deleted file mode 100644 index 0ccb337..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/20.txt b/port_src/core/src/test/resources/blackbox/ean13-1/20.txt deleted file mode 100644 index 4168b63..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/20.txt +++ /dev/null @@ -1 +0,0 @@ -4000539017100 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/21.png b/port_src/core/src/test/resources/blackbox/ean13-1/21.png deleted file mode 100644 index 724eac1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/21.txt b/port_src/core/src/test/resources/blackbox/ean13-1/21.txt deleted file mode 100644 index 3ae180b..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/21.txt +++ /dev/null @@ -1 +0,0 @@ -7622200008018 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/22.png b/port_src/core/src/test/resources/blackbox/ean13-1/22.png deleted file mode 100644 index 63434fa..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/22.txt b/port_src/core/src/test/resources/blackbox/ean13-1/22.txt deleted file mode 100644 index 050090b..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/22.txt +++ /dev/null @@ -1 +0,0 @@ -5603667020517 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/23.png b/port_src/core/src/test/resources/blackbox/ean13-1/23.png deleted file mode 100644 index c5563a3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/23.txt b/port_src/core/src/test/resources/blackbox/ean13-1/23.txt deleted file mode 100644 index ade11f7..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/23.txt +++ /dev/null @@ -1 +0,0 @@ -7622400791949 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/24.png b/port_src/core/src/test/resources/blackbox/ean13-1/24.png deleted file mode 100644 index 27a2540..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/24.txt b/port_src/core/src/test/resources/blackbox/ean13-1/24.txt deleted file mode 100644 index 5163aef..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/24.txt +++ /dev/null @@ -1 +0,0 @@ -5709262942503 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/25.png b/port_src/core/src/test/resources/blackbox/ean13-1/25.png deleted file mode 100644 index 5e7d187..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/25.txt b/port_src/core/src/test/resources/blackbox/ean13-1/25.txt deleted file mode 100644 index cd9874a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/25.txt +++ /dev/null @@ -1 +0,0 @@ -9780140013993 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/26.png b/port_src/core/src/test/resources/blackbox/ean13-1/26.png deleted file mode 100644 index 55cc6f1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/26.txt b/port_src/core/src/test/resources/blackbox/ean13-1/26.txt deleted file mode 100644 index 9e109c5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/26.txt +++ /dev/null @@ -1 +0,0 @@ -4901780188352 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/28.png b/port_src/core/src/test/resources/blackbox/ean13-1/28.png deleted file mode 100644 index 6d18782..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/28.txt b/port_src/core/src/test/resources/blackbox/ean13-1/28.txt deleted file mode 100644 index da99d28..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/28.txt +++ /dev/null @@ -1 +0,0 @@ -9771699057002 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/29.png b/port_src/core/src/test/resources/blackbox/ean13-1/29.png deleted file mode 100644 index a8fd534..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/29.txt b/port_src/core/src/test/resources/blackbox/ean13-1/29.txt deleted file mode 100644 index 5882140..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/29.txt +++ /dev/null @@ -1 +0,0 @@ -4007817327098 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/3.png b/port_src/core/src/test/resources/blackbox/ean13-1/3.png deleted file mode 100644 index 5071c64..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/3.txt b/port_src/core/src/test/resources/blackbox/ean13-1/3.txt deleted file mode 100644 index 29b2fcc..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/3.txt +++ /dev/null @@ -1 +0,0 @@ -8480000823274 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/30.png b/port_src/core/src/test/resources/blackbox/ean13-1/30.png deleted file mode 100644 index 0c884df..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/30.txt b/port_src/core/src/test/resources/blackbox/ean13-1/30.txt deleted file mode 100644 index 9193e22..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/30.txt +++ /dev/null @@ -1 +0,0 @@ -5025121072311 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/31.png b/port_src/core/src/test/resources/blackbox/ean13-1/31.png deleted file mode 100644 index 50d2ad0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/31.txt b/port_src/core/src/test/resources/blackbox/ean13-1/31.txt deleted file mode 100644 index 5dde677..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/31.txt +++ /dev/null @@ -1 +0,0 @@ -9780393058673 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/32.png b/port_src/core/src/test/resources/blackbox/ean13-1/32.png deleted file mode 100644 index 2a2a1cf..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/32.txt b/port_src/core/src/test/resources/blackbox/ean13-1/32.txt deleted file mode 100644 index 5dde677..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/32.txt +++ /dev/null @@ -1 +0,0 @@ -9780393058673 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/33.png b/port_src/core/src/test/resources/blackbox/ean13-1/33.png deleted file mode 100644 index ac34f8d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/33.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/33.txt b/port_src/core/src/test/resources/blackbox/ean13-1/33.txt deleted file mode 100644 index b2327fc..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/33.txt +++ /dev/null @@ -1 +0,0 @@ -9781558604971 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/34.png b/port_src/core/src/test/resources/blackbox/ean13-1/34.png deleted file mode 100644 index 225cc73..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/34.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/34.txt b/port_src/core/src/test/resources/blackbox/ean13-1/34.txt deleted file mode 100644 index b2327fc..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/34.txt +++ /dev/null @@ -1 +0,0 @@ -9781558604971 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/35.png b/port_src/core/src/test/resources/blackbox/ean13-1/35.png deleted file mode 100644 index c2e9602..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/35.txt b/port_src/core/src/test/resources/blackbox/ean13-1/35.txt deleted file mode 100644 index acc8244..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/35.txt +++ /dev/null @@ -1 +0,0 @@ -5030159003930 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/36.png b/port_src/core/src/test/resources/blackbox/ean13-1/36.png deleted file mode 100644 index 3df7a74..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/36.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/36.txt b/port_src/core/src/test/resources/blackbox/ean13-1/36.txt deleted file mode 100644 index 8860f23..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/36.txt +++ /dev/null @@ -1 +0,0 @@ -5000213101025 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/37.png b/port_src/core/src/test/resources/blackbox/ean13-1/37.png deleted file mode 100644 index 4802760..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/37.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/37.txt b/port_src/core/src/test/resources/blackbox/ean13-1/37.txt deleted file mode 100644 index 645fe52..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/37.txt +++ /dev/null @@ -1 +0,0 @@ -5000213002834 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/38.png b/port_src/core/src/test/resources/blackbox/ean13-1/38.png deleted file mode 100644 index d1f7e62..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/38.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/38.txt b/port_src/core/src/test/resources/blackbox/ean13-1/38.txt deleted file mode 100644 index 89052f6..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/38.txt +++ /dev/null @@ -1 +0,0 @@ -9780201752847 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/4.png b/port_src/core/src/test/resources/blackbox/ean13-1/4.png deleted file mode 100644 index cad316b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/4.txt b/port_src/core/src/test/resources/blackbox/ean13-1/4.txt deleted file mode 100644 index 28ad258..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/4.txt +++ /dev/null @@ -1 +0,0 @@ -5449000039231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/5.png b/port_src/core/src/test/resources/blackbox/ean13-1/5.png deleted file mode 100644 index 4c9afe1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/5.txt b/port_src/core/src/test/resources/blackbox/ean13-1/5.txt deleted file mode 100644 index 5d98de1..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/5.txt +++ /dev/null @@ -1 +0,0 @@ -8410054010412 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/6.png b/port_src/core/src/test/resources/blackbox/ean13-1/6.png deleted file mode 100644 index 8a2cba8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/6.txt b/port_src/core/src/test/resources/blackbox/ean13-1/6.txt deleted file mode 100644 index 13edf65..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/6.txt +++ /dev/null @@ -1 +0,0 @@ -8480010045062 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/7.png b/port_src/core/src/test/resources/blackbox/ean13-1/7.png deleted file mode 100644 index d78c77d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/7.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/7.txt b/port_src/core/src/test/resources/blackbox/ean13-1/7.txt deleted file mode 100644 index ca3f2bb..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/7.txt +++ /dev/null @@ -1 +0,0 @@ -9788430532674 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/8.png b/port_src/core/src/test/resources/blackbox/ean13-1/8.png deleted file mode 100644 index 81509a2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/8.txt b/port_src/core/src/test/resources/blackbox/ean13-1/8.txt deleted file mode 100644 index 2322328..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/8.txt +++ /dev/null @@ -1 +0,0 @@ -8480017507990 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/9.png b/port_src/core/src/test/resources/blackbox/ean13-1/9.png deleted file mode 100644 index 768175d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-1/9.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-1/9.txt b/port_src/core/src/test/resources/blackbox/ean13-1/9.txt deleted file mode 100644 index 134bb0f..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-1/9.txt +++ /dev/null @@ -1 +0,0 @@ -3166298099809 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/01.png b/port_src/core/src/test/resources/blackbox/ean13-2/01.png deleted file mode 100755 index e9f5576..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/01.txt b/port_src/core/src/test/resources/blackbox/ean13-2/01.txt deleted file mode 100644 index a98aacb..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/01.txt +++ /dev/null @@ -1 +0,0 @@ -9780804816632 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/02.png b/port_src/core/src/test/resources/blackbox/ean13-2/02.png deleted file mode 100755 index 5d2d9c8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/02.txt b/port_src/core/src/test/resources/blackbox/ean13-2/02.txt deleted file mode 100644 index a98aacb..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/02.txt +++ /dev/null @@ -1 +0,0 @@ -9780804816632 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/03.png b/port_src/core/src/test/resources/blackbox/ean13-2/03.png deleted file mode 100755 index ca71946..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/03.txt b/port_src/core/src/test/resources/blackbox/ean13-2/03.txt deleted file mode 100644 index a98aacb..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/03.txt +++ /dev/null @@ -1 +0,0 @@ -9780804816632 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/04.png b/port_src/core/src/test/resources/blackbox/ean13-2/04.png deleted file mode 100755 index 054a664..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/04.txt b/port_src/core/src/test/resources/blackbox/ean13-2/04.txt deleted file mode 100644 index a98aacb..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/04.txt +++ /dev/null @@ -1 +0,0 @@ -9780804816632 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/05.png b/port_src/core/src/test/resources/blackbox/ean13-2/05.png deleted file mode 100755 index ae58951..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/05.txt b/port_src/core/src/test/resources/blackbox/ean13-2/05.txt deleted file mode 100644 index a98aacb..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/05.txt +++ /dev/null @@ -1 +0,0 @@ -9780804816632 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/06.png b/port_src/core/src/test/resources/blackbox/ean13-2/06.png deleted file mode 100755 index c1bcb9e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/06.txt b/port_src/core/src/test/resources/blackbox/ean13-2/06.txt deleted file mode 100644 index a98aacb..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/06.txt +++ /dev/null @@ -1 +0,0 @@ -9780804816632 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/07.png b/port_src/core/src/test/resources/blackbox/ean13-2/07.png deleted file mode 100755 index b059d22..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/07.txt b/port_src/core/src/test/resources/blackbox/ean13-2/07.txt deleted file mode 100644 index a98aacb..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/07.txt +++ /dev/null @@ -1 +0,0 @@ -9780804816632 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/08.png b/port_src/core/src/test/resources/blackbox/ean13-2/08.png deleted file mode 100755 index b435b9c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/08.txt b/port_src/core/src/test/resources/blackbox/ean13-2/08.txt deleted file mode 100644 index 8dab35e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/08.txt +++ /dev/null @@ -1 +0,0 @@ -9780345348036 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/09.png b/port_src/core/src/test/resources/blackbox/ean13-2/09.png deleted file mode 100755 index f8573a3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/09.txt b/port_src/core/src/test/resources/blackbox/ean13-2/09.txt deleted file mode 100644 index 8dab35e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/09.txt +++ /dev/null @@ -1 +0,0 @@ -9780345348036 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/10.png b/port_src/core/src/test/resources/blackbox/ean13-2/10.png deleted file mode 100755 index f9142fa..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/10.txt b/port_src/core/src/test/resources/blackbox/ean13-2/10.txt deleted file mode 100644 index 8dab35e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/10.txt +++ /dev/null @@ -1 +0,0 @@ -9780345348036 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/11.png b/port_src/core/src/test/resources/blackbox/ean13-2/11.png deleted file mode 100755 index 1c37db7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/11.txt b/port_src/core/src/test/resources/blackbox/ean13-2/11.txt deleted file mode 100644 index 8dab35e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/11.txt +++ /dev/null @@ -1 +0,0 @@ -9780345348036 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/12.png b/port_src/core/src/test/resources/blackbox/ean13-2/12.png deleted file mode 100755 index e5a3811..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/12.txt b/port_src/core/src/test/resources/blackbox/ean13-2/12.txt deleted file mode 100644 index 8dab35e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/12.txt +++ /dev/null @@ -1 +0,0 @@ -9780345348036 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/13.png b/port_src/core/src/test/resources/blackbox/ean13-2/13.png deleted file mode 100755 index c809e93..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/13.txt b/port_src/core/src/test/resources/blackbox/ean13-2/13.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/13.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/14.png b/port_src/core/src/test/resources/blackbox/ean13-2/14.png deleted file mode 100755 index d770fbe..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/14.txt b/port_src/core/src/test/resources/blackbox/ean13-2/14.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/14.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/15.png b/port_src/core/src/test/resources/blackbox/ean13-2/15.png deleted file mode 100755 index 7b9ad95..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/15.txt b/port_src/core/src/test/resources/blackbox/ean13-2/15.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/15.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/16.png b/port_src/core/src/test/resources/blackbox/ean13-2/16.png deleted file mode 100755 index a38b462..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/16.txt b/port_src/core/src/test/resources/blackbox/ean13-2/16.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/16.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/17.png b/port_src/core/src/test/resources/blackbox/ean13-2/17.png deleted file mode 100755 index 2ccb7ba..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/17.txt b/port_src/core/src/test/resources/blackbox/ean13-2/17.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/17.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/18.png b/port_src/core/src/test/resources/blackbox/ean13-2/18.png deleted file mode 100755 index f2c59bf..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/18.txt b/port_src/core/src/test/resources/blackbox/ean13-2/18.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/18.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/19.png b/port_src/core/src/test/resources/blackbox/ean13-2/19.png deleted file mode 100755 index 5dc54a4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/19.txt b/port_src/core/src/test/resources/blackbox/ean13-2/19.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/19.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/20.png b/port_src/core/src/test/resources/blackbox/ean13-2/20.png deleted file mode 100755 index 4c50c4f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/20.txt b/port_src/core/src/test/resources/blackbox/ean13-2/20.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/20.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/21.png b/port_src/core/src/test/resources/blackbox/ean13-2/21.png deleted file mode 100755 index 03cfa8c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/21.txt b/port_src/core/src/test/resources/blackbox/ean13-2/21.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/21.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/22.png b/port_src/core/src/test/resources/blackbox/ean13-2/22.png deleted file mode 100755 index c647d61..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/22.txt b/port_src/core/src/test/resources/blackbox/ean13-2/22.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/22.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/23.png b/port_src/core/src/test/resources/blackbox/ean13-2/23.png deleted file mode 100755 index 95cc049..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/23.txt b/port_src/core/src/test/resources/blackbox/ean13-2/23.txt deleted file mode 100644 index 764ab85..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/23.txt +++ /dev/null @@ -1 +0,0 @@ -1920081045006 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/24.png b/port_src/core/src/test/resources/blackbox/ean13-2/24.png deleted file mode 100755 index 201b772..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/24.txt b/port_src/core/src/test/resources/blackbox/ean13-2/24.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/24.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/25.png b/port_src/core/src/test/resources/blackbox/ean13-2/25.png deleted file mode 100755 index cc43e76..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/25.txt b/port_src/core/src/test/resources/blackbox/ean13-2/25.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/25.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/26.png b/port_src/core/src/test/resources/blackbox/ean13-2/26.png deleted file mode 100755 index 0fa6750..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/26.txt b/port_src/core/src/test/resources/blackbox/ean13-2/26.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/26.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/27.png b/port_src/core/src/test/resources/blackbox/ean13-2/27.png deleted file mode 100755 index 4dcedb8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/27.txt b/port_src/core/src/test/resources/blackbox/ean13-2/27.txt deleted file mode 100644 index e5bf71a..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/27.txt +++ /dev/null @@ -1 +0,0 @@ -9784872348880 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/28.png b/port_src/core/src/test/resources/blackbox/ean13-2/28.png deleted file mode 100755 index 9883d40..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-2/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-2/28.txt b/port_src/core/src/test/resources/blackbox/ean13-2/28.txt deleted file mode 100644 index 764ab85..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-2/28.txt +++ /dev/null @@ -1 +0,0 @@ -1920081045006 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/01.png b/port_src/core/src/test/resources/blackbox/ean13-3/01.png deleted file mode 100644 index c7cfc75..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/01.txt b/port_src/core/src/test/resources/blackbox/ean13-3/01.txt deleted file mode 100644 index 2374d38..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/01.txt +++ /dev/null @@ -1 +0,0 @@ -9780764544200 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/02.png b/port_src/core/src/test/resources/blackbox/ean13-3/02.png deleted file mode 100644 index acdb380..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/02.txt b/port_src/core/src/test/resources/blackbox/ean13-3/02.txt deleted file mode 100644 index 2374d38..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/02.txt +++ /dev/null @@ -1 +0,0 @@ -9780764544200 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/03.png b/port_src/core/src/test/resources/blackbox/ean13-3/03.png deleted file mode 100644 index 94c5acf..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/03.txt b/port_src/core/src/test/resources/blackbox/ean13-3/03.txt deleted file mode 100644 index 2374d38..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/03.txt +++ /dev/null @@ -1 +0,0 @@ -9780764544200 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/04.png b/port_src/core/src/test/resources/blackbox/ean13-3/04.png deleted file mode 100644 index dbc0b01..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/04.txt b/port_src/core/src/test/resources/blackbox/ean13-3/04.txt deleted file mode 100644 index 2374d38..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/04.txt +++ /dev/null @@ -1 +0,0 @@ -9780764544200 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/05.png b/port_src/core/src/test/resources/blackbox/ean13-3/05.png deleted file mode 100644 index 74b52a4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/05.txt b/port_src/core/src/test/resources/blackbox/ean13-3/05.txt deleted file mode 100644 index 2374d38..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/05.txt +++ /dev/null @@ -1 +0,0 @@ -9780764544200 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/06.png b/port_src/core/src/test/resources/blackbox/ean13-3/06.png deleted file mode 100644 index 2e63f21..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/06.txt b/port_src/core/src/test/resources/blackbox/ean13-3/06.txt deleted file mode 100644 index 2374d38..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/06.txt +++ /dev/null @@ -1 +0,0 @@ -9780764544200 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/07.png b/port_src/core/src/test/resources/blackbox/ean13-3/07.png deleted file mode 100644 index 06e44d5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/07.txt b/port_src/core/src/test/resources/blackbox/ean13-3/07.txt deleted file mode 100644 index 2374d38..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/07.txt +++ /dev/null @@ -1 +0,0 @@ -9780764544200 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/08.png b/port_src/core/src/test/resources/blackbox/ean13-3/08.png deleted file mode 100644 index cf7f6eb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/08.txt b/port_src/core/src/test/resources/blackbox/ean13-3/08.txt deleted file mode 100644 index 2374d38..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/08.txt +++ /dev/null @@ -1 +0,0 @@ -9780764544200 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/09.png b/port_src/core/src/test/resources/blackbox/ean13-3/09.png deleted file mode 100644 index a150b6c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/09.txt b/port_src/core/src/test/resources/blackbox/ean13-3/09.txt deleted file mode 100644 index 2374d38..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/09.txt +++ /dev/null @@ -1 +0,0 @@ -9780764544200 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/10.png b/port_src/core/src/test/resources/blackbox/ean13-3/10.png deleted file mode 100644 index 477085b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/10.txt b/port_src/core/src/test/resources/blackbox/ean13-3/10.txt deleted file mode 100644 index 0418ac5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/10.txt +++ /dev/null @@ -1 +0,0 @@ -9780596008574 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/11.png b/port_src/core/src/test/resources/blackbox/ean13-3/11.png deleted file mode 100644 index 70d398e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/11.txt b/port_src/core/src/test/resources/blackbox/ean13-3/11.txt deleted file mode 100644 index 0418ac5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/11.txt +++ /dev/null @@ -1 +0,0 @@ -9780596008574 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/12.png b/port_src/core/src/test/resources/blackbox/ean13-3/12.png deleted file mode 100644 index 8690d95..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/12.txt b/port_src/core/src/test/resources/blackbox/ean13-3/12.txt deleted file mode 100644 index 0418ac5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/12.txt +++ /dev/null @@ -1 +0,0 @@ -9780596008574 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/13.png b/port_src/core/src/test/resources/blackbox/ean13-3/13.png deleted file mode 100644 index bf3713f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/13.txt b/port_src/core/src/test/resources/blackbox/ean13-3/13.txt deleted file mode 100644 index 0418ac5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/13.txt +++ /dev/null @@ -1 +0,0 @@ -9780596008574 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/14.png b/port_src/core/src/test/resources/blackbox/ean13-3/14.png deleted file mode 100644 index 82c9a9e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/14.txt b/port_src/core/src/test/resources/blackbox/ean13-3/14.txt deleted file mode 100644 index 0418ac5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/14.txt +++ /dev/null @@ -1 +0,0 @@ -9780596008574 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/15.png b/port_src/core/src/test/resources/blackbox/ean13-3/15.png deleted file mode 100644 index af37ac3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/15.txt b/port_src/core/src/test/resources/blackbox/ean13-3/15.txt deleted file mode 100644 index 0418ac5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/15.txt +++ /dev/null @@ -1 +0,0 @@ -9780596008574 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/16.png b/port_src/core/src/test/resources/blackbox/ean13-3/16.png deleted file mode 100644 index ae5b5a1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/16.txt b/port_src/core/src/test/resources/blackbox/ean13-3/16.txt deleted file mode 100644 index 0418ac5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/16.txt +++ /dev/null @@ -1 +0,0 @@ -9780596008574 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/17.png b/port_src/core/src/test/resources/blackbox/ean13-3/17.png deleted file mode 100644 index adb7d8b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/17.txt b/port_src/core/src/test/resources/blackbox/ean13-3/17.txt deleted file mode 100644 index 0418ac5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/17.txt +++ /dev/null @@ -1 +0,0 @@ -9780596008574 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/18.png b/port_src/core/src/test/resources/blackbox/ean13-3/18.png deleted file mode 100644 index 28e0f6e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/18.txt b/port_src/core/src/test/resources/blackbox/ean13-3/18.txt deleted file mode 100644 index 0418ac5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/18.txt +++ /dev/null @@ -1 +0,0 @@ -9780596008574 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/19.png b/port_src/core/src/test/resources/blackbox/ean13-3/19.png deleted file mode 100644 index 8af9f3e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/19.txt b/port_src/core/src/test/resources/blackbox/ean13-3/19.txt deleted file mode 100644 index 0418ac5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/19.txt +++ /dev/null @@ -1 +0,0 @@ -9780596008574 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/20.png b/port_src/core/src/test/resources/blackbox/ean13-3/20.png deleted file mode 100644 index 28d64fd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/20.txt b/port_src/core/src/test/resources/blackbox/ean13-3/20.txt deleted file mode 100644 index 0418ac5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/20.txt +++ /dev/null @@ -1 +0,0 @@ -9780596008574 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/21.png b/port_src/core/src/test/resources/blackbox/ean13-3/21.png deleted file mode 100644 index a4dd352..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/21.txt b/port_src/core/src/test/resources/blackbox/ean13-3/21.txt deleted file mode 100644 index 0418ac5..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/21.txt +++ /dev/null @@ -1 +0,0 @@ -9780596008574 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/22.png b/port_src/core/src/test/resources/blackbox/ean13-3/22.png deleted file mode 100644 index bdfaa4b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/22.txt b/port_src/core/src/test/resources/blackbox/ean13-3/22.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/22.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/23.png b/port_src/core/src/test/resources/blackbox/ean13-3/23.png deleted file mode 100644 index 90926cd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/23.txt b/port_src/core/src/test/resources/blackbox/ean13-3/23.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/23.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/24.png b/port_src/core/src/test/resources/blackbox/ean13-3/24.png deleted file mode 100644 index 0b6366b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/24.txt b/port_src/core/src/test/resources/blackbox/ean13-3/24.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/24.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/25.png b/port_src/core/src/test/resources/blackbox/ean13-3/25.png deleted file mode 100644 index 988d61e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/25.txt b/port_src/core/src/test/resources/blackbox/ean13-3/25.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/25.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/26.png b/port_src/core/src/test/resources/blackbox/ean13-3/26.png deleted file mode 100644 index c8a7696..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/26.txt b/port_src/core/src/test/resources/blackbox/ean13-3/26.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/26.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/27.png b/port_src/core/src/test/resources/blackbox/ean13-3/27.png deleted file mode 100644 index c82a19e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/27.txt b/port_src/core/src/test/resources/blackbox/ean13-3/27.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/27.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/28.png b/port_src/core/src/test/resources/blackbox/ean13-3/28.png deleted file mode 100644 index e7cfe2b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/28.txt b/port_src/core/src/test/resources/blackbox/ean13-3/28.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/28.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/29.png b/port_src/core/src/test/resources/blackbox/ean13-3/29.png deleted file mode 100644 index 351117e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/29.txt b/port_src/core/src/test/resources/blackbox/ean13-3/29.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/29.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/30.png b/port_src/core/src/test/resources/blackbox/ean13-3/30.png deleted file mode 100644 index bd90227..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/30.txt b/port_src/core/src/test/resources/blackbox/ean13-3/30.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/30.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/31.png b/port_src/core/src/test/resources/blackbox/ean13-3/31.png deleted file mode 100644 index 8768ac3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/31.txt b/port_src/core/src/test/resources/blackbox/ean13-3/31.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/31.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/32.png b/port_src/core/src/test/resources/blackbox/ean13-3/32.png deleted file mode 100644 index e227c6c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/32.txt b/port_src/core/src/test/resources/blackbox/ean13-3/32.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/32.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/33.png b/port_src/core/src/test/resources/blackbox/ean13-3/33.png deleted file mode 100644 index d0ca931..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/33.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/33.txt b/port_src/core/src/test/resources/blackbox/ean13-3/33.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/33.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/34.png b/port_src/core/src/test/resources/blackbox/ean13-3/34.png deleted file mode 100644 index 6960608..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/34.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/34.txt b/port_src/core/src/test/resources/blackbox/ean13-3/34.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/34.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/35.png b/port_src/core/src/test/resources/blackbox/ean13-3/35.png deleted file mode 100644 index 4b97179..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/35.txt b/port_src/core/src/test/resources/blackbox/ean13-3/35.txt deleted file mode 100644 index af323ce..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/35.txt +++ /dev/null @@ -1 +0,0 @@ -9780201310054 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/36.png b/port_src/core/src/test/resources/blackbox/ean13-3/36.png deleted file mode 100644 index 44b201f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/36.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/36.txt b/port_src/core/src/test/resources/blackbox/ean13-3/36.txt deleted file mode 100644 index 9a81d5e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/36.txt +++ /dev/null @@ -1 +0,0 @@ -9781585730575 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/37.png b/port_src/core/src/test/resources/blackbox/ean13-3/37.png deleted file mode 100644 index ae59a37..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/37.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/37.txt b/port_src/core/src/test/resources/blackbox/ean13-3/37.txt deleted file mode 100644 index 9a81d5e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/37.txt +++ /dev/null @@ -1 +0,0 @@ -9781585730575 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/38.png b/port_src/core/src/test/resources/blackbox/ean13-3/38.png deleted file mode 100644 index 2b711c4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/38.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/38.txt b/port_src/core/src/test/resources/blackbox/ean13-3/38.txt deleted file mode 100644 index 9a81d5e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/38.txt +++ /dev/null @@ -1 +0,0 @@ -9781585730575 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/39.png b/port_src/core/src/test/resources/blackbox/ean13-3/39.png deleted file mode 100644 index ef58665..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/39.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/39.txt b/port_src/core/src/test/resources/blackbox/ean13-3/39.txt deleted file mode 100644 index 9a81d5e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/39.txt +++ /dev/null @@ -1 +0,0 @@ -9781585730575 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/40.png b/port_src/core/src/test/resources/blackbox/ean13-3/40.png deleted file mode 100644 index bde68d3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/40.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/40.txt b/port_src/core/src/test/resources/blackbox/ean13-3/40.txt deleted file mode 100644 index 9a81d5e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/40.txt +++ /dev/null @@ -1 +0,0 @@ -9781585730575 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/41.png b/port_src/core/src/test/resources/blackbox/ean13-3/41.png deleted file mode 100644 index d3a314e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/41.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/41.txt b/port_src/core/src/test/resources/blackbox/ean13-3/41.txt deleted file mode 100644 index 9a81d5e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/41.txt +++ /dev/null @@ -1 +0,0 @@ -9781585730575 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/42.png b/port_src/core/src/test/resources/blackbox/ean13-3/42.png deleted file mode 100644 index 4d204f0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/42.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/42.txt b/port_src/core/src/test/resources/blackbox/ean13-3/42.txt deleted file mode 100644 index 9a81d5e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/42.txt +++ /dev/null @@ -1 +0,0 @@ -9781585730575 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/43.png b/port_src/core/src/test/resources/blackbox/ean13-3/43.png deleted file mode 100644 index 1dd551f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/43.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/43.txt b/port_src/core/src/test/resources/blackbox/ean13-3/43.txt deleted file mode 100644 index 9a81d5e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/43.txt +++ /dev/null @@ -1 +0,0 @@ -9781585730575 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/44.png b/port_src/core/src/test/resources/blackbox/ean13-3/44.png deleted file mode 100644 index a89a755..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/44.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/44.txt b/port_src/core/src/test/resources/blackbox/ean13-3/44.txt deleted file mode 100644 index bc4f1af..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/44.txt +++ /dev/null @@ -1 +0,0 @@ -9780735619937 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/45.png b/port_src/core/src/test/resources/blackbox/ean13-3/45.png deleted file mode 100644 index a9bbe60..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/45.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/45.txt b/port_src/core/src/test/resources/blackbox/ean13-3/45.txt deleted file mode 100644 index bc4f1af..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/45.txt +++ /dev/null @@ -1 +0,0 @@ -9780735619937 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/46.png b/port_src/core/src/test/resources/blackbox/ean13-3/46.png deleted file mode 100644 index f132a70..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/46.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/46.txt b/port_src/core/src/test/resources/blackbox/ean13-3/46.txt deleted file mode 100644 index bc4f1af..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/46.txt +++ /dev/null @@ -1 +0,0 @@ -9780735619937 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/47.png b/port_src/core/src/test/resources/blackbox/ean13-3/47.png deleted file mode 100644 index 2b40bdf..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/47.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/47.txt b/port_src/core/src/test/resources/blackbox/ean13-3/47.txt deleted file mode 100644 index bc4f1af..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/47.txt +++ /dev/null @@ -1 +0,0 @@ -9780735619937 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/48.png b/port_src/core/src/test/resources/blackbox/ean13-3/48.png deleted file mode 100644 index 5415ac3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/48.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/48.txt b/port_src/core/src/test/resources/blackbox/ean13-3/48.txt deleted file mode 100644 index bc4f1af..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/48.txt +++ /dev/null @@ -1 +0,0 @@ -9780735619937 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/49.png b/port_src/core/src/test/resources/blackbox/ean13-3/49.png deleted file mode 100644 index aba0846..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/49.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/49.txt b/port_src/core/src/test/resources/blackbox/ean13-3/49.txt deleted file mode 100644 index bc4f1af..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/49.txt +++ /dev/null @@ -1 +0,0 @@ -9780735619937 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/50.png b/port_src/core/src/test/resources/blackbox/ean13-3/50.png deleted file mode 100644 index f46bf5a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/50.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/50.txt b/port_src/core/src/test/resources/blackbox/ean13-3/50.txt deleted file mode 100644 index bc4f1af..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/50.txt +++ /dev/null @@ -1 +0,0 @@ -9780735619937 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/51.png b/port_src/core/src/test/resources/blackbox/ean13-3/51.png deleted file mode 100644 index e8b9969..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/51.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/51.txt b/port_src/core/src/test/resources/blackbox/ean13-3/51.txt deleted file mode 100644 index bc4f1af..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/51.txt +++ /dev/null @@ -1 +0,0 @@ -9780735619937 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/52.png b/port_src/core/src/test/resources/blackbox/ean13-3/52.png deleted file mode 100644 index 10cd368..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/52.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/52.txt b/port_src/core/src/test/resources/blackbox/ean13-3/52.txt deleted file mode 100644 index bc4f1af..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/52.txt +++ /dev/null @@ -1 +0,0 @@ -9780735619937 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/53.png b/port_src/core/src/test/resources/blackbox/ean13-3/53.png deleted file mode 100644 index 1214abb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/53.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/53.txt b/port_src/core/src/test/resources/blackbox/ean13-3/53.txt deleted file mode 100644 index bc4f1af..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/53.txt +++ /dev/null @@ -1 +0,0 @@ -9780735619937 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/54.png b/port_src/core/src/test/resources/blackbox/ean13-3/54.png deleted file mode 100644 index 6b3154f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/54.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/54.txt b/port_src/core/src/test/resources/blackbox/ean13-3/54.txt deleted file mode 100644 index bc4f1af..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/54.txt +++ /dev/null @@ -1 +0,0 @@ -9780735619937 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/55.png b/port_src/core/src/test/resources/blackbox/ean13-3/55.png deleted file mode 100644 index d639123..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-3/55.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-3/55.txt b/port_src/core/src/test/resources/blackbox/ean13-3/55.txt deleted file mode 100644 index bc4f1af..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-3/55.txt +++ /dev/null @@ -1 +0,0 @@ -9780735619937 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/01.png b/port_src/core/src/test/resources/blackbox/ean13-4/01.png deleted file mode 100644 index 1373c22..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/01.txt b/port_src/core/src/test/resources/blackbox/ean13-4/01.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/01.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/02.png b/port_src/core/src/test/resources/blackbox/ean13-4/02.png deleted file mode 100644 index 3f6a0ab..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/02.txt b/port_src/core/src/test/resources/blackbox/ean13-4/02.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/02.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/03.png b/port_src/core/src/test/resources/blackbox/ean13-4/03.png deleted file mode 100644 index 711f430..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/03.txt b/port_src/core/src/test/resources/blackbox/ean13-4/03.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/03.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/04.png b/port_src/core/src/test/resources/blackbox/ean13-4/04.png deleted file mode 100644 index 6a0e4d2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/04.txt b/port_src/core/src/test/resources/blackbox/ean13-4/04.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/04.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/05.png b/port_src/core/src/test/resources/blackbox/ean13-4/05.png deleted file mode 100644 index 4891c6e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/05.txt b/port_src/core/src/test/resources/blackbox/ean13-4/05.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/05.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/06.png b/port_src/core/src/test/resources/blackbox/ean13-4/06.png deleted file mode 100644 index b6d4d3f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/06.txt b/port_src/core/src/test/resources/blackbox/ean13-4/06.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/06.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/07.png b/port_src/core/src/test/resources/blackbox/ean13-4/07.png deleted file mode 100644 index 7700663..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/07.txt b/port_src/core/src/test/resources/blackbox/ean13-4/07.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/07.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/08.png b/port_src/core/src/test/resources/blackbox/ean13-4/08.png deleted file mode 100644 index 4dd7190..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/08.txt b/port_src/core/src/test/resources/blackbox/ean13-4/08.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/08.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/09.png b/port_src/core/src/test/resources/blackbox/ean13-4/09.png deleted file mode 100644 index 3095d76..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/09.txt b/port_src/core/src/test/resources/blackbox/ean13-4/09.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/09.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/10.png b/port_src/core/src/test/resources/blackbox/ean13-4/10.png deleted file mode 100644 index 07ea6bd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/10.txt b/port_src/core/src/test/resources/blackbox/ean13-4/10.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/10.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/11.png b/port_src/core/src/test/resources/blackbox/ean13-4/11.png deleted file mode 100644 index b0c10a8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/11.txt b/port_src/core/src/test/resources/blackbox/ean13-4/11.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/11.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/12.png b/port_src/core/src/test/resources/blackbox/ean13-4/12.png deleted file mode 100644 index ea56ff1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/12.txt b/port_src/core/src/test/resources/blackbox/ean13-4/12.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/12.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/13.png b/port_src/core/src/test/resources/blackbox/ean13-4/13.png deleted file mode 100644 index 97ab926..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/13.txt b/port_src/core/src/test/resources/blackbox/ean13-4/13.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/13.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/14.png b/port_src/core/src/test/resources/blackbox/ean13-4/14.png deleted file mode 100644 index eccc8e3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/14.txt b/port_src/core/src/test/resources/blackbox/ean13-4/14.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/14.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/15.png b/port_src/core/src/test/resources/blackbox/ean13-4/15.png deleted file mode 100644 index 951202d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/15.txt b/port_src/core/src/test/resources/blackbox/ean13-4/15.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/15.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/16.png b/port_src/core/src/test/resources/blackbox/ean13-4/16.png deleted file mode 100644 index 4f2b039..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/16.txt b/port_src/core/src/test/resources/blackbox/ean13-4/16.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/16.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/17.png b/port_src/core/src/test/resources/blackbox/ean13-4/17.png deleted file mode 100644 index 938ff1f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/17.txt b/port_src/core/src/test/resources/blackbox/ean13-4/17.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/17.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/18.png b/port_src/core/src/test/resources/blackbox/ean13-4/18.png deleted file mode 100644 index 426088b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/18.txt b/port_src/core/src/test/resources/blackbox/ean13-4/18.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/18.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/19.png b/port_src/core/src/test/resources/blackbox/ean13-4/19.png deleted file mode 100644 index f606373..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/19.txt b/port_src/core/src/test/resources/blackbox/ean13-4/19.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/19.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/20.png b/port_src/core/src/test/resources/blackbox/ean13-4/20.png deleted file mode 100644 index d49140a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/20.txt b/port_src/core/src/test/resources/blackbox/ean13-4/20.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/20.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/21.png b/port_src/core/src/test/resources/blackbox/ean13-4/21.png deleted file mode 100644 index 76d38fc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/21.txt b/port_src/core/src/test/resources/blackbox/ean13-4/21.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/21.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/22.png b/port_src/core/src/test/resources/blackbox/ean13-4/22.png deleted file mode 100644 index 60184e8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-4/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-4/22.txt b/port_src/core/src/test/resources/blackbox/ean13-4/22.txt deleted file mode 100644 index 33d6b99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-4/22.txt +++ /dev/null @@ -1 +0,0 @@ -9780441014989 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/01.png b/port_src/core/src/test/resources/blackbox/ean13-5/01.png deleted file mode 100755 index eb69b6c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/01.txt b/port_src/core/src/test/resources/blackbox/ean13-5/01.txt deleted file mode 100644 index e39e9a0..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/01.txt +++ /dev/null @@ -1 +0,0 @@ -9780679601050 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/02.png b/port_src/core/src/test/resources/blackbox/ean13-5/02.png deleted file mode 100755 index e0f79a8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/02.txt b/port_src/core/src/test/resources/blackbox/ean13-5/02.txt deleted file mode 100644 index e39e9a0..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/02.txt +++ /dev/null @@ -1 +0,0 @@ -9780679601050 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/03.png b/port_src/core/src/test/resources/blackbox/ean13-5/03.png deleted file mode 100755 index 6305539..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/03.txt b/port_src/core/src/test/resources/blackbox/ean13-5/03.txt deleted file mode 100644 index e39e9a0..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/03.txt +++ /dev/null @@ -1 +0,0 @@ -9780679601050 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/04.png b/port_src/core/src/test/resources/blackbox/ean13-5/04.png deleted file mode 100755 index d356850..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/04.txt b/port_src/core/src/test/resources/blackbox/ean13-5/04.txt deleted file mode 100644 index e39e9a0..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/04.txt +++ /dev/null @@ -1 +0,0 @@ -9780679601050 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/05.png b/port_src/core/src/test/resources/blackbox/ean13-5/05.png deleted file mode 100755 index 5afee8a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/05.txt b/port_src/core/src/test/resources/blackbox/ean13-5/05.txt deleted file mode 100644 index e39e9a0..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/05.txt +++ /dev/null @@ -1 +0,0 @@ -9780679601050 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/06.png b/port_src/core/src/test/resources/blackbox/ean13-5/06.png deleted file mode 100755 index 23abf72..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/06.txt b/port_src/core/src/test/resources/blackbox/ean13-5/06.txt deleted file mode 100644 index a083c8e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/06.txt +++ /dev/null @@ -1 +0,0 @@ -9780345460950 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/07.png b/port_src/core/src/test/resources/blackbox/ean13-5/07.png deleted file mode 100755 index 2db9044..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/07.txt b/port_src/core/src/test/resources/blackbox/ean13-5/07.txt deleted file mode 100644 index a083c8e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/07.txt +++ /dev/null @@ -1 +0,0 @@ -9780345460950 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/08.png b/port_src/core/src/test/resources/blackbox/ean13-5/08.png deleted file mode 100755 index 0f462ab..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/08.txt b/port_src/core/src/test/resources/blackbox/ean13-5/08.txt deleted file mode 100644 index a083c8e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/08.txt +++ /dev/null @@ -1 +0,0 @@ -9780345460950 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/09.png b/port_src/core/src/test/resources/blackbox/ean13-5/09.png deleted file mode 100755 index 4914c9e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/09.txt b/port_src/core/src/test/resources/blackbox/ean13-5/09.txt deleted file mode 100644 index a083c8e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/09.txt +++ /dev/null @@ -1 +0,0 @@ -9780345460950 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/10.png b/port_src/core/src/test/resources/blackbox/ean13-5/10.png deleted file mode 100755 index 28e0a1e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/10.txt b/port_src/core/src/test/resources/blackbox/ean13-5/10.txt deleted file mode 100644 index a083c8e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/10.txt +++ /dev/null @@ -1 +0,0 @@ -9780345460950 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/11.png b/port_src/core/src/test/resources/blackbox/ean13-5/11.png deleted file mode 100755 index 481aea3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/11.txt b/port_src/core/src/test/resources/blackbox/ean13-5/11.txt deleted file mode 100644 index a083c8e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/11.txt +++ /dev/null @@ -1 +0,0 @@ -9780345460950 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/12.png b/port_src/core/src/test/resources/blackbox/ean13-5/12.png deleted file mode 100755 index 14581d6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/12.txt b/port_src/core/src/test/resources/blackbox/ean13-5/12.txt deleted file mode 100644 index a083c8e..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/12.txt +++ /dev/null @@ -1 +0,0 @@ -9780345460950 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/13.png b/port_src/core/src/test/resources/blackbox/ean13-5/13.png deleted file mode 100755 index 6a1b0e7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/13.txt b/port_src/core/src/test/resources/blackbox/ean13-5/13.txt deleted file mode 100644 index efab0d0..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/13.txt +++ /dev/null @@ -1 +0,0 @@ -9780446579803 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/14.png b/port_src/core/src/test/resources/blackbox/ean13-5/14.png deleted file mode 100755 index 46539e3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/14.txt b/port_src/core/src/test/resources/blackbox/ean13-5/14.txt deleted file mode 100644 index efab0d0..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/14.txt +++ /dev/null @@ -1 +0,0 @@ -9780446579803 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/15.png b/port_src/core/src/test/resources/blackbox/ean13-5/15.png deleted file mode 100755 index 6c91854..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/15.txt b/port_src/core/src/test/resources/blackbox/ean13-5/15.txt deleted file mode 100644 index efab0d0..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/15.txt +++ /dev/null @@ -1 +0,0 @@ -9780446579803 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/16.png b/port_src/core/src/test/resources/blackbox/ean13-5/16.png deleted file mode 100755 index d677819..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/16.txt b/port_src/core/src/test/resources/blackbox/ean13-5/16.txt deleted file mode 100644 index efab0d0..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/16.txt +++ /dev/null @@ -1 +0,0 @@ -9780446579803 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/17.png b/port_src/core/src/test/resources/blackbox/ean13-5/17.png deleted file mode 100755 index a97d780..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/17.txt b/port_src/core/src/test/resources/blackbox/ean13-5/17.txt deleted file mode 100644 index efab0d0..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/17.txt +++ /dev/null @@ -1 +0,0 @@ -9780446579803 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/18.png b/port_src/core/src/test/resources/blackbox/ean13-5/18.png deleted file mode 100755 index a231bcd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean13-5/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean13-5/18.txt b/port_src/core/src/test/resources/blackbox/ean13-5/18.txt deleted file mode 100644 index efab0d0..0000000 --- a/port_src/core/src/test/resources/blackbox/ean13-5/18.txt +++ /dev/null @@ -1 +0,0 @@ -9780446579803 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/1.metadata.txt b/port_src/core/src/test/resources/blackbox/ean8-1/1.metadata.txt deleted file mode 100644 index 6f43c99..0000000 --- a/port_src/core/src/test/resources/blackbox/ean8-1/1.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]E4 diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/1.png b/port_src/core/src/test/resources/blackbox/ean8-1/1.png deleted file mode 100644 index 14195c2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean8-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/1.txt b/port_src/core/src/test/resources/blackbox/ean8-1/1.txt deleted file mode 100644 index cf23e89..0000000 --- a/port_src/core/src/test/resources/blackbox/ean8-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -48512343 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/2.png b/port_src/core/src/test/resources/blackbox/ean8-1/2.png deleted file mode 100644 index d9d93bc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean8-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/2.txt b/port_src/core/src/test/resources/blackbox/ean8-1/2.txt deleted file mode 100644 index c1c1178..0000000 --- a/port_src/core/src/test/resources/blackbox/ean8-1/2.txt +++ /dev/null @@ -1 +0,0 @@ -12345670 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/3.png b/port_src/core/src/test/resources/blackbox/ean8-1/3.png deleted file mode 100644 index 2e29b6b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean8-1/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/3.txt b/port_src/core/src/test/resources/blackbox/ean8-1/3.txt deleted file mode 100644 index c1c1178..0000000 --- a/port_src/core/src/test/resources/blackbox/ean8-1/3.txt +++ /dev/null @@ -1 +0,0 @@ -12345670 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/4.png b/port_src/core/src/test/resources/blackbox/ean8-1/4.png deleted file mode 100644 index ab36270..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean8-1/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/4.txt b/port_src/core/src/test/resources/blackbox/ean8-1/4.txt deleted file mode 100644 index 2ab0cf4..0000000 --- a/port_src/core/src/test/resources/blackbox/ean8-1/4.txt +++ /dev/null @@ -1 +0,0 @@ -67678983 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/5.png b/port_src/core/src/test/resources/blackbox/ean8-1/5.png deleted file mode 100644 index 8dba684..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean8-1/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/5.txt b/port_src/core/src/test/resources/blackbox/ean8-1/5.txt deleted file mode 100644 index 4911bf2..0000000 --- a/port_src/core/src/test/resources/blackbox/ean8-1/5.txt +++ /dev/null @@ -1 +0,0 @@ -80674313 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/6.png b/port_src/core/src/test/resources/blackbox/ean8-1/6.png deleted file mode 100644 index 87f8893..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean8-1/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/6.txt b/port_src/core/src/test/resources/blackbox/ean8-1/6.txt deleted file mode 100644 index d0ada6f..0000000 --- a/port_src/core/src/test/resources/blackbox/ean8-1/6.txt +++ /dev/null @@ -1 +0,0 @@ -59001270 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/7.png b/port_src/core/src/test/resources/blackbox/ean8-1/7.png deleted file mode 100644 index 1a99a31..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean8-1/7.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/7.txt b/port_src/core/src/test/resources/blackbox/ean8-1/7.txt deleted file mode 100644 index 36db36b..0000000 --- a/port_src/core/src/test/resources/blackbox/ean8-1/7.txt +++ /dev/null @@ -1 +0,0 @@ -50487066 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/8.png b/port_src/core/src/test/resources/blackbox/ean8-1/8.png deleted file mode 100644 index faddfd7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/ean8-1/8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/ean8-1/8.txt b/port_src/core/src/test/resources/blackbox/ean8-1/8.txt deleted file mode 100644 index a6c3069..0000000 --- a/port_src/core/src/test/resources/blackbox/ean8-1/8.txt +++ /dev/null @@ -1 +0,0 @@ -55123457 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/01.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/01.png deleted file mode 100755 index 21660d4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/02.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/02.png deleted file mode 100755 index a66976e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/03.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/03.png deleted file mode 100755 index f67db15..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/04.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/04.png deleted file mode 100755 index efb94fd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/05.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/05.png deleted file mode 100755 index efc2da3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/06.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/06.png deleted file mode 100755 index a5ccaed..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/07.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/07.png deleted file mode 100755 index 82056bd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/08.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/08.png deleted file mode 100755 index c5ae82b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/09.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/09.png deleted file mode 100755 index 147a1b2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/10.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/10.png deleted file mode 100755 index c7d6011..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/11.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/11.png deleted file mode 100755 index 5710efc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/12.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/12.png deleted file mode 100755 index 8d630ca..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/13.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/13.png deleted file mode 100755 index ad3b971..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/14.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/14.png deleted file mode 100755 index 4f61d20..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/15.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/15.png deleted file mode 100755 index 68c8aba..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/16.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/16.png deleted file mode 100755 index 1d975d7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/17.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/17.png deleted file mode 100755 index 760ca90..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/18.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/18.png deleted file mode 100755 index 2c770e2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/19.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/19.png deleted file mode 100755 index bd518c4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/20.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/20.png deleted file mode 100755 index c675e29..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/21.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/21.png deleted file mode 100755 index 3a0e038..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/22.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/22.png deleted file mode 100755 index c05690d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/23.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/23.png deleted file mode 100755 index 74fbaed..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/24.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/24.png deleted file mode 100755 index b023c46..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives-2/25.png b/port_src/core/src/test/resources/blackbox/falsepositives-2/25.png deleted file mode 100755 index cfead59..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives-2/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/01.png b/port_src/core/src/test/resources/blackbox/falsepositives/01.png deleted file mode 100644 index f842d1e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/02.png b/port_src/core/src/test/resources/blackbox/falsepositives/02.png deleted file mode 100644 index daf2164..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/03.png b/port_src/core/src/test/resources/blackbox/falsepositives/03.png deleted file mode 100644 index ef23c14..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/04.png b/port_src/core/src/test/resources/blackbox/falsepositives/04.png deleted file mode 100644 index 9d6ac9e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/05.png b/port_src/core/src/test/resources/blackbox/falsepositives/05.png deleted file mode 100644 index cdc990a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/06.png b/port_src/core/src/test/resources/blackbox/falsepositives/06.png deleted file mode 100644 index 2a21197..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/07.png b/port_src/core/src/test/resources/blackbox/falsepositives/07.png deleted file mode 100644 index f029515..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/08.png b/port_src/core/src/test/resources/blackbox/falsepositives/08.png deleted file mode 100644 index 5336ab9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/09.png b/port_src/core/src/test/resources/blackbox/falsepositives/09.png deleted file mode 100644 index 72ca3f6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/10.png b/port_src/core/src/test/resources/blackbox/falsepositives/10.png deleted file mode 100644 index 75e5093..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/11.png b/port_src/core/src/test/resources/blackbox/falsepositives/11.png deleted file mode 100644 index d803ca4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/12.png b/port_src/core/src/test/resources/blackbox/falsepositives/12.png deleted file mode 100644 index 24334ea..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/13.png b/port_src/core/src/test/resources/blackbox/falsepositives/13.png deleted file mode 100644 index 4511988..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/14.png b/port_src/core/src/test/resources/blackbox/falsepositives/14.png deleted file mode 100644 index f3911a9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/15.png b/port_src/core/src/test/resources/blackbox/falsepositives/15.png deleted file mode 100644 index 0ba6581..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/16.png b/port_src/core/src/test/resources/blackbox/falsepositives/16.png deleted file mode 100644 index d6403f3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/17.png b/port_src/core/src/test/resources/blackbox/falsepositives/17.png deleted file mode 100644 index fbca1f3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/18.png b/port_src/core/src/test/resources/blackbox/falsepositives/18.png deleted file mode 100644 index 227218a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/19.png b/port_src/core/src/test/resources/blackbox/falsepositives/19.png deleted file mode 100644 index eeb4108..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/20.png b/port_src/core/src/test/resources/blackbox/falsepositives/20.png deleted file mode 100644 index 69bc08f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/21.png b/port_src/core/src/test/resources/blackbox/falsepositives/21.png deleted file mode 100644 index 6e986cb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/falsepositives/22.png b/port_src/core/src/test/resources/blackbox/falsepositives/22.png deleted file mode 100644 index 66330ae..0000000 Binary files a/port_src/core/src/test/resources/blackbox/falsepositives/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/inverted/datamatrix-0123456789.png b/port_src/core/src/test/resources/blackbox/inverted/datamatrix-0123456789.png deleted file mode 100644 index 72e7de8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/inverted/datamatrix-0123456789.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/inverted/datamatrix-0123456789.txt b/port_src/core/src/test/resources/blackbox/inverted/datamatrix-0123456789.txt deleted file mode 100644 index ad47100..0000000 --- a/port_src/core/src/test/resources/blackbox/inverted/datamatrix-0123456789.txt +++ /dev/null @@ -1 +0,0 @@ -0123456789 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/1.metadata.txt b/port_src/core/src/test/resources/blackbox/itf-1/1.metadata.txt deleted file mode 100644 index aef8e6d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/1.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]I0 diff --git a/port_src/core/src/test/resources/blackbox/itf-1/1.png b/port_src/core/src/test/resources/blackbox/itf-1/1.png deleted file mode 100644 index 39f3c09..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/1.txt b/port_src/core/src/test/resources/blackbox/itf-1/1.txt deleted file mode 100644 index f17cae6..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -30712345000010 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/10.png b/port_src/core/src/test/resources/blackbox/itf-1/10.png deleted file mode 100644 index 6715057..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/10.txt b/port_src/core/src/test/resources/blackbox/itf-1/10.txt deleted file mode 100644 index d46b0cf..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/10.txt +++ /dev/null @@ -1 +0,0 @@ -0053611912 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/13.png b/port_src/core/src/test/resources/blackbox/itf-1/13.png deleted file mode 100644 index c17aacc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/13.txt b/port_src/core/src/test/resources/blackbox/itf-1/13.txt deleted file mode 100644 index 1351c69..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/13.txt +++ /dev/null @@ -1 +0,0 @@ -0829220875 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/14.png b/port_src/core/src/test/resources/blackbox/itf-1/14.png deleted file mode 100644 index 881b1de..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/14.txt b/port_src/core/src/test/resources/blackbox/itf-1/14.txt deleted file mode 100644 index 1351c69..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/14.txt +++ /dev/null @@ -1 +0,0 @@ -0829220875 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/15.png b/port_src/core/src/test/resources/blackbox/itf-1/15.png deleted file mode 100644 index 5974885..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/15.txt b/port_src/core/src/test/resources/blackbox/itf-1/15.txt deleted file mode 100644 index 1351c69..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/15.txt +++ /dev/null @@ -1 +0,0 @@ -0829220875 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/16.png b/port_src/core/src/test/resources/blackbox/itf-1/16.png deleted file mode 100644 index 02b340d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/16.txt b/port_src/core/src/test/resources/blackbox/itf-1/16.txt deleted file mode 100644 index a92b62e..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/16.txt +++ /dev/null @@ -1 +0,0 @@ -0829220874 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/17.png b/port_src/core/src/test/resources/blackbox/itf-1/17.png deleted file mode 100644 index f7ac1be..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/17.txt b/port_src/core/src/test/resources/blackbox/itf-1/17.txt deleted file mode 100644 index 66166b5..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/17.txt +++ /dev/null @@ -1 +0,0 @@ -3018108390 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/2.png b/port_src/core/src/test/resources/blackbox/itf-1/2.png deleted file mode 100644 index 3315f80..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/2.txt b/port_src/core/src/test/resources/blackbox/itf-1/2.txt deleted file mode 100644 index eabb743..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/2.txt +++ /dev/null @@ -1 +0,0 @@ -00012345678905 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/3.png b/port_src/core/src/test/resources/blackbox/itf-1/3.png deleted file mode 100644 index 3b654f7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/3.txt b/port_src/core/src/test/resources/blackbox/itf-1/3.txt deleted file mode 100644 index d46b0cf..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/3.txt +++ /dev/null @@ -1 +0,0 @@ -0053611912 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/5.png b/port_src/core/src/test/resources/blackbox/itf-1/5.png deleted file mode 100644 index 640d5c4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/5.txt b/port_src/core/src/test/resources/blackbox/itf-1/5.txt deleted file mode 100644 index 1351c69..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/5.txt +++ /dev/null @@ -1 +0,0 @@ -0829220875 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/6.png b/port_src/core/src/test/resources/blackbox/itf-1/6.png deleted file mode 100644 index 50972f6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/6.txt b/port_src/core/src/test/resources/blackbox/itf-1/6.txt deleted file mode 100644 index a92b62e..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/6.txt +++ /dev/null @@ -1 +0,0 @@ -0829220874 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/7.png b/port_src/core/src/test/resources/blackbox/itf-1/7.png deleted file mode 100644 index 4e78fc5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/7.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/7.txt b/port_src/core/src/test/resources/blackbox/itf-1/7.txt deleted file mode 100644 index 6c4c26e..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/7.txt +++ /dev/null @@ -1 +0,0 @@ -0817605453 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/8.png b/port_src/core/src/test/resources/blackbox/itf-1/8.png deleted file mode 100644 index ef7557e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/8.txt b/port_src/core/src/test/resources/blackbox/itf-1/8.txt deleted file mode 100644 index a92b62e..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/8.txt +++ /dev/null @@ -1 +0,0 @@ -0829220874 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-1/9.png b/port_src/core/src/test/resources/blackbox/itf-1/9.png deleted file mode 100644 index bd1ec3c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-1/9.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-1/9.txt b/port_src/core/src/test/resources/blackbox/itf-1/9.txt deleted file mode 100644 index d46b0cf..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-1/9.txt +++ /dev/null @@ -1 +0,0 @@ -0053611912 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/01.png b/port_src/core/src/test/resources/blackbox/itf-2/01.png deleted file mode 100644 index f00ab8d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/01.txt b/port_src/core/src/test/resources/blackbox/itf-2/01.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/01.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/02.png b/port_src/core/src/test/resources/blackbox/itf-2/02.png deleted file mode 100644 index f3ca5bb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/02.txt b/port_src/core/src/test/resources/blackbox/itf-2/02.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/02.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/03.png b/port_src/core/src/test/resources/blackbox/itf-2/03.png deleted file mode 100644 index 7a2e0a6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/03.txt b/port_src/core/src/test/resources/blackbox/itf-2/03.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/03.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/04.png b/port_src/core/src/test/resources/blackbox/itf-2/04.png deleted file mode 100644 index 2a5d15e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/04.txt b/port_src/core/src/test/resources/blackbox/itf-2/04.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/04.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/05.png b/port_src/core/src/test/resources/blackbox/itf-2/05.png deleted file mode 100644 index 3a8a6c8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/05.txt b/port_src/core/src/test/resources/blackbox/itf-2/05.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/05.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/06.png b/port_src/core/src/test/resources/blackbox/itf-2/06.png deleted file mode 100644 index 97513cb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/06.txt b/port_src/core/src/test/resources/blackbox/itf-2/06.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/06.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/07.png b/port_src/core/src/test/resources/blackbox/itf-2/07.png deleted file mode 100644 index 0a63686..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/07.txt b/port_src/core/src/test/resources/blackbox/itf-2/07.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/07.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/08.png b/port_src/core/src/test/resources/blackbox/itf-2/08.png deleted file mode 100644 index adfe9bc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/08.txt b/port_src/core/src/test/resources/blackbox/itf-2/08.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/08.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/09.png b/port_src/core/src/test/resources/blackbox/itf-2/09.png deleted file mode 100644 index 00adc80..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/09.txt b/port_src/core/src/test/resources/blackbox/itf-2/09.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/09.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/10.png b/port_src/core/src/test/resources/blackbox/itf-2/10.png deleted file mode 100644 index 65db849..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/10.txt b/port_src/core/src/test/resources/blackbox/itf-2/10.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/10.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/11.png b/port_src/core/src/test/resources/blackbox/itf-2/11.png deleted file mode 100644 index 82dad01..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/11.txt b/port_src/core/src/test/resources/blackbox/itf-2/11.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/11.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/12.png b/port_src/core/src/test/resources/blackbox/itf-2/12.png deleted file mode 100644 index bf93d01..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/12.txt b/port_src/core/src/test/resources/blackbox/itf-2/12.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/12.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/itf-2/13.png b/port_src/core/src/test/resources/blackbox/itf-2/13.png deleted file mode 100644 index fb7deb7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/itf-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/itf-2/13.txt b/port_src/core/src/test/resources/blackbox/itf-2/13.txt deleted file mode 100644 index a8fb53d..0000000 --- a/port_src/core/src/test/resources/blackbox/itf-2/13.txt +++ /dev/null @@ -1 +0,0 @@ -070429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/1.png b/port_src/core/src/test/resources/blackbox/maxicode-1/1.png deleted file mode 100644 index 2f72369..0000000 Binary files a/port_src/core/src/test/resources/blackbox/maxicode-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/1.txt b/port_src/core/src/test/resources/blackbox/maxicode-1/1.txt deleted file mode 100644 index 5051d25..0000000 --- a/port_src/core/src/test/resources/blackbox/maxicode-1/1.txt +++ /dev/null @@ -1 +0,0 @@ - ABCDEFGHIJKLMNOPQRSTUVWXYZ "#$%&'()*+,-./01234:56789 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE2.png b/port_src/core/src/test/resources/blackbox/maxicode-1/MODE2.png deleted file mode 100644 index 6ac2539..0000000 Binary files a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE2.txt b/port_src/core/src/test/resources/blackbox/maxicode-1/MODE2.txt deleted file mode 100644 index ad5f7f6..0000000 --- a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE2.txt +++ /dev/null @@ -1 +0,0 @@ -[)>0196123450000222111MODE2 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE3.png b/port_src/core/src/test/resources/blackbox/maxicode-1/MODE3.png deleted file mode 100644 index 0079871..0000000 Binary files a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE3.txt b/port_src/core/src/test/resources/blackbox/maxicode-1/MODE3.txt deleted file mode 100644 index 08d7782..0000000 --- a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE3.txt +++ /dev/null @@ -1 +0,0 @@ -[)>0196123450000222111MODE3 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE4.png b/port_src/core/src/test/resources/blackbox/maxicode-1/MODE4.png deleted file mode 100644 index e4470f3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE4.txt b/port_src/core/src/test/resources/blackbox/maxicode-1/MODE4.txt deleted file mode 100644 index 8224acc..0000000 --- a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE4.txt +++ /dev/null @@ -1 +0,0 @@ -[)>0196123450000222111MODE4 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE5.png b/port_src/core/src/test/resources/blackbox/maxicode-1/MODE5.png deleted file mode 100644 index 1545946..0000000 Binary files a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE5.txt b/port_src/core/src/test/resources/blackbox/maxicode-1/MODE5.txt deleted file mode 100644 index deeeba3..0000000 --- a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE5.txt +++ /dev/null @@ -1 +0,0 @@ -[)>0196123450000222111MODE5 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE6.png b/port_src/core/src/test/resources/blackbox/maxicode-1/MODE6.png deleted file mode 100644 index 333a0f8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE6.txt b/port_src/core/src/test/resources/blackbox/maxicode-1/MODE6.txt deleted file mode 100644 index f5e22c3..0000000 --- a/port_src/core/src/test/resources/blackbox/maxicode-1/MODE6.txt +++ /dev/null @@ -1 +0,0 @@ -[)>0196123450000222111MODE6 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/mode4-mixed-sets.png b/port_src/core/src/test/resources/blackbox/maxicode-1/mode4-mixed-sets.png deleted file mode 100644 index ce30323..0000000 Binary files a/port_src/core/src/test/resources/blackbox/maxicode-1/mode4-mixed-sets.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/maxicode-1/mode4-mixed-sets.txt b/port_src/core/src/test/resources/blackbox/maxicode-1/mode4-mixed-sets.txt deleted file mode 100644 index e9ff080..0000000 --- a/port_src/core/src/test/resources/blackbox/maxicode-1/mode4-mixed-sets.txt +++ /dev/null @@ -1 +0,0 @@ -ABCDE12abcde1ÀÃÂ⣤¥1àáâãabcde123A123456789àáâ㢣¤¥abcdÚÛÜÃ123456789¾ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/multi-1/1.png b/port_src/core/src/test/resources/blackbox/multi-1/1.png deleted file mode 100644 index ff0f8b5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/multi-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/multi-qrcode-1/1.png b/port_src/core/src/test/resources/blackbox/multi-qrcode-1/1.png deleted file mode 100644 index c82508b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/multi-qrcode-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/01.png b/port_src/core/src/test/resources/blackbox/partial/01.png deleted file mode 100644 index 1e8d4bf..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/02.png b/port_src/core/src/test/resources/blackbox/partial/02.png deleted file mode 100644 index 5337ec3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/03.png b/port_src/core/src/test/resources/blackbox/partial/03.png deleted file mode 100644 index 8ad85fe..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/04.png b/port_src/core/src/test/resources/blackbox/partial/04.png deleted file mode 100644 index 36c9317..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/05.png b/port_src/core/src/test/resources/blackbox/partial/05.png deleted file mode 100644 index 27a29c6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/06.png b/port_src/core/src/test/resources/blackbox/partial/06.png deleted file mode 100644 index 09f48a5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/07.png b/port_src/core/src/test/resources/blackbox/partial/07.png deleted file mode 100644 index 228b3c4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/08.png b/port_src/core/src/test/resources/blackbox/partial/08.png deleted file mode 100644 index 7f3f19d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/09.png b/port_src/core/src/test/resources/blackbox/partial/09.png deleted file mode 100644 index 6b5e102..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/10.png b/port_src/core/src/test/resources/blackbox/partial/10.png deleted file mode 100644 index 1302789..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/11.png b/port_src/core/src/test/resources/blackbox/partial/11.png deleted file mode 100644 index ae1a7f1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/12.png b/port_src/core/src/test/resources/blackbox/partial/12.png deleted file mode 100644 index 6b5d0d1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/13.png b/port_src/core/src/test/resources/blackbox/partial/13.png deleted file mode 100644 index 450e91e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/14.png b/port_src/core/src/test/resources/blackbox/partial/14.png deleted file mode 100644 index eaade21..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/15.png b/port_src/core/src/test/resources/blackbox/partial/15.png deleted file mode 100644 index ff83852..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/16.png b/port_src/core/src/test/resources/blackbox/partial/16.png deleted file mode 100644 index acaeea8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/17.png b/port_src/core/src/test/resources/blackbox/partial/17.png deleted file mode 100644 index 55ec618..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/18.png b/port_src/core/src/test/resources/blackbox/partial/18.png deleted file mode 100644 index 52c253b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/19.png b/port_src/core/src/test/resources/blackbox/partial/19.png deleted file mode 100644 index 72365cd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/20.png b/port_src/core/src/test/resources/blackbox/partial/20.png deleted file mode 100644 index 87ce76d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/21.png b/port_src/core/src/test/resources/blackbox/partial/21.png deleted file mode 100644 index ba74867..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/22.png b/port_src/core/src/test/resources/blackbox/partial/22.png deleted file mode 100644 index 6c9892a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/23.png b/port_src/core/src/test/resources/blackbox/partial/23.png deleted file mode 100644 index d9db0bd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/24.png b/port_src/core/src/test/resources/blackbox/partial/24.png deleted file mode 100644 index f932457..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/25.png b/port_src/core/src/test/resources/blackbox/partial/25.png deleted file mode 100644 index be35161..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/26.png b/port_src/core/src/test/resources/blackbox/partial/26.png deleted file mode 100644 index 50ab71e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/27.png b/port_src/core/src/test/resources/blackbox/partial/27.png deleted file mode 100644 index b55c177..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/28.png b/port_src/core/src/test/resources/blackbox/partial/28.png deleted file mode 100644 index 23f9558..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/29.png b/port_src/core/src/test/resources/blackbox/partial/29.png deleted file mode 100644 index 547f0c7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/30.png b/port_src/core/src/test/resources/blackbox/partial/30.png deleted file mode 100644 index 3a64f1f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/31.png b/port_src/core/src/test/resources/blackbox/partial/31.png deleted file mode 100644 index 7e42138..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/32.png b/port_src/core/src/test/resources/blackbox/partial/32.png deleted file mode 100644 index 514cf40..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/33.png b/port_src/core/src/test/resources/blackbox/partial/33.png deleted file mode 100644 index ecb1f12..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/33.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/34.png b/port_src/core/src/test/resources/blackbox/partial/34.png deleted file mode 100644 index 6f3998b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/34.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/35.png b/port_src/core/src/test/resources/blackbox/partial/35.png deleted file mode 100644 index d06cd60..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/36.png b/port_src/core/src/test/resources/blackbox/partial/36.png deleted file mode 100644 index 93e577e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/36.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/37.png b/port_src/core/src/test/resources/blackbox/partial/37.png deleted file mode 100644 index 0e62b8f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/37.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/38.png b/port_src/core/src/test/resources/blackbox/partial/38.png deleted file mode 100644 index 2c48b79..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/38.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/39.png b/port_src/core/src/test/resources/blackbox/partial/39.png deleted file mode 100644 index 5882b24..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/39.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/40.png b/port_src/core/src/test/resources/blackbox/partial/40.png deleted file mode 100644 index 6b139f9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/40.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/41.png b/port_src/core/src/test/resources/blackbox/partial/41.png deleted file mode 100644 index fbb367c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/41.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/42.png b/port_src/core/src/test/resources/blackbox/partial/42.png deleted file mode 100644 index fbe2a1c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/42.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/43.png b/port_src/core/src/test/resources/blackbox/partial/43.png deleted file mode 100644 index 17cacde..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/43.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/44.png b/port_src/core/src/test/resources/blackbox/partial/44.png deleted file mode 100644 index df26022..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/44.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/45.png b/port_src/core/src/test/resources/blackbox/partial/45.png deleted file mode 100644 index c19a1b5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/45.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/46.png b/port_src/core/src/test/resources/blackbox/partial/46.png deleted file mode 100644 index 0f61817..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/46.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/47.png b/port_src/core/src/test/resources/blackbox/partial/47.png deleted file mode 100644 index 7daa309..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/47.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/48.png b/port_src/core/src/test/resources/blackbox/partial/48.png deleted file mode 100644 index bdaefa7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/48.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/49.png b/port_src/core/src/test/resources/blackbox/partial/49.png deleted file mode 100644 index 9ca9c46..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/49.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/50.png b/port_src/core/src/test/resources/blackbox/partial/50.png deleted file mode 100644 index 7ee0c8a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/50.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/51.png b/port_src/core/src/test/resources/blackbox/partial/51.png deleted file mode 100644 index 9eb02ea..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/51.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/52.png b/port_src/core/src/test/resources/blackbox/partial/52.png deleted file mode 100644 index 0a1e1cc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/52.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/53.png b/port_src/core/src/test/resources/blackbox/partial/53.png deleted file mode 100644 index b9b4282..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/53.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/54.png b/port_src/core/src/test/resources/blackbox/partial/54.png deleted file mode 100644 index cd4b859..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/54.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/55.png b/port_src/core/src/test/resources/blackbox/partial/55.png deleted file mode 100644 index db2ceb1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/55.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/56.png b/port_src/core/src/test/resources/blackbox/partial/56.png deleted file mode 100644 index 8652f4f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/56.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/57.png b/port_src/core/src/test/resources/blackbox/partial/57.png deleted file mode 100644 index 184b09b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/57.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/59.png b/port_src/core/src/test/resources/blackbox/partial/59.png deleted file mode 100644 index 0135a46..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/59.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/60.png b/port_src/core/src/test/resources/blackbox/partial/60.png deleted file mode 100644 index 7bce219..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/60.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/partial/61.png b/port_src/core/src/test/resources/blackbox/partial/61.png deleted file mode 100644 index a983142..0000000 Binary files a/port_src/core/src/test/resources/blackbox/partial/61.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/01.metadata.txt b/port_src/core/src/test/resources/blackbox/pdf417-1/01.metadata.txt deleted file mode 100644 index 75f38ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-1/01.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]L0 diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/01.png b/port_src/core/src/test/resources/blackbox/pdf417-1/01.png deleted file mode 100644 index 76de458..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-1/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/01.txt b/port_src/core/src/test/resources/blackbox/pdf417-1/01.txt deleted file mode 100644 index 8c84eae..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-1/01.txt +++ /dev/null @@ -1 +0,0 @@ -This is PDF417 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/02.png b/port_src/core/src/test/resources/blackbox/pdf417-1/02.png deleted file mode 100644 index 5d41771..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-1/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/02.txt b/port_src/core/src/test/resources/blackbox/pdf417-1/02.txt deleted file mode 100644 index e9a9ea1..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-1/02.txt +++ /dev/null @@ -1 +0,0 @@ -12345678 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/03.png b/port_src/core/src/test/resources/blackbox/pdf417-1/03.png deleted file mode 100644 index 7a13bb9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-1/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/03.txt b/port_src/core/src/test/resources/blackbox/pdf417-1/03.txt deleted file mode 100644 index 8a97eec..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-1/03.txt +++ /dev/null @@ -1 +0,0 @@ -ActiveBarcode \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/04.png b/port_src/core/src/test/resources/blackbox/pdf417-1/04.png deleted file mode 100644 index bda5cda..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-1/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/04.txt b/port_src/core/src/test/resources/blackbox/pdf417-1/04.txt deleted file mode 100644 index aa0e5da..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-1/04.txt +++ /dev/null @@ -1 +0,0 @@ --ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/05.png b/port_src/core/src/test/resources/blackbox/pdf417-1/05.png deleted file mode 100644 index db2c031..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-1/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/05.txt b/port_src/core/src/test/resources/blackbox/pdf417-1/05.txt deleted file mode 100644 index b6c1c37..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-1/05.txt +++ /dev/null @@ -1 +0,0 @@ --ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/06.png b/port_src/core/src/test/resources/blackbox/pdf417-1/06.png deleted file mode 100644 index f77ab92..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-1/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/06.txt b/port_src/core/src/test/resources/blackbox/pdf417-1/06.txt deleted file mode 100644 index f61edfc..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-1/06.txt +++ /dev/null @@ -1 +0,0 @@ --ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/07.png b/port_src/core/src/test/resources/blackbox/pdf417-1/07.png deleted file mode 100644 index 3ab2624..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-1/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/07.txt b/port_src/core/src/test/resources/blackbox/pdf417-1/07.txt deleted file mode 100644 index 13e3209..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-1/07.txt +++ /dev/null @@ -1 +0,0 @@ --ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-ActiveBarcode-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/09.bin b/port_src/core/src/test/resources/blackbox/pdf417-1/09.bin deleted file mode 100644 index 7633e3a..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-1/09.bin +++ /dev/null @@ -1 +0,0 @@ -!‚Ÿ !Eô 5/D? ?šFZ c'‚ÿ mAÉ  #F \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/09.png b/port_src/core/src/test/resources/blackbox/pdf417-1/09.png deleted file mode 100644 index a876eb5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-1/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/10.png b/port_src/core/src/test/resources/blackbox/pdf417-1/10.png deleted file mode 100644 index 4e0a5ae..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-1/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/10.txt b/port_src/core/src/test/resources/blackbox/pdf417-1/10.txt deleted file mode 100755 index 2215b03..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-1/10.txt +++ /dev/null @@ -1 +0,0 @@ -PDF-417 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/11.png b/port_src/core/src/test/resources/blackbox/pdf417-1/11.png deleted file mode 100644 index a18dd83..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-1/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-1/11.txt b/port_src/core/src/test/resources/blackbox/pdf417-1/11.txt deleted file mode 100644 index 25f3991..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-1/11.txt +++ /dev/null @@ -1 +0,0 @@ -This is just a test. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/01.png b/port_src/core/src/test/resources/blackbox/pdf417-2/01.png deleted file mode 100755 index 44a1775..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/01.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/01.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/01.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/02.png b/port_src/core/src/test/resources/blackbox/pdf417-2/02.png deleted file mode 100755 index 7236ea2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/02.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/02.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/02.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/03.png b/port_src/core/src/test/resources/blackbox/pdf417-2/03.png deleted file mode 100755 index 857e8ba..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/03.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/03.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/03.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/04.png b/port_src/core/src/test/resources/blackbox/pdf417-2/04.png deleted file mode 100755 index 5684848..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/04.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/04.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/04.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/05.png b/port_src/core/src/test/resources/blackbox/pdf417-2/05.png deleted file mode 100755 index 1d5a366..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/05.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/05.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/05.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/06.png b/port_src/core/src/test/resources/blackbox/pdf417-2/06.png deleted file mode 100755 index 0e979b6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/06.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/06.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/06.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/07.png b/port_src/core/src/test/resources/blackbox/pdf417-2/07.png deleted file mode 100755 index 54bd9bc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/07.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/07.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/07.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/08.png b/port_src/core/src/test/resources/blackbox/pdf417-2/08.png deleted file mode 100755 index 51de70f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/08.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/08.txt deleted file mode 100644 index cd7a77d..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/08.txt +++ /dev/null @@ -1 +0,0 @@ -A PDF 417 barcode with ASCII text \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/09.png b/port_src/core/src/test/resources/blackbox/pdf417-2/09.png deleted file mode 100755 index aa072cb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/09.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/09.txt deleted file mode 100644 index cd7a77d..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/09.txt +++ /dev/null @@ -1 +0,0 @@ -A PDF 417 barcode with ASCII text \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/10.png b/port_src/core/src/test/resources/blackbox/pdf417-2/10.png deleted file mode 100755 index d19e85d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/10.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/10.txt deleted file mode 100644 index cd7a77d..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/10.txt +++ /dev/null @@ -1 +0,0 @@ -A PDF 417 barcode with ASCII text \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/11.png b/port_src/core/src/test/resources/blackbox/pdf417-2/11.png deleted file mode 100755 index 5df3a06..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/11.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/11.txt deleted file mode 100644 index cd7a77d..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/11.txt +++ /dev/null @@ -1 +0,0 @@ -A PDF 417 barcode with ASCII text \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/12.png b/port_src/core/src/test/resources/blackbox/pdf417-2/12.png deleted file mode 100755 index 678a8a1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/12.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/12.txt deleted file mode 100644 index cd7a77d..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/12.txt +++ /dev/null @@ -1 +0,0 @@ -A PDF 417 barcode with ASCII text \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/13.png b/port_src/core/src/test/resources/blackbox/pdf417-2/13.png deleted file mode 100755 index 2ce4a04..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/13.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/13.txt deleted file mode 100644 index cd7a77d..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/13.txt +++ /dev/null @@ -1 +0,0 @@ -A PDF 417 barcode with ASCII text \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/14.png b/port_src/core/src/test/resources/blackbox/pdf417-2/14.png deleted file mode 100755 index bbd0c6f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/14.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/14.txt deleted file mode 100644 index cd7a77d..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/14.txt +++ /dev/null @@ -1 +0,0 @@ -A PDF 417 barcode with ASCII text \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/15.png b/port_src/core/src/test/resources/blackbox/pdf417-2/15.png deleted file mode 100755 index 4735dc6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/15.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/15.txt deleted file mode 100644 index cd7a77d..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/15.txt +++ /dev/null @@ -1 +0,0 @@ -A PDF 417 barcode with ASCII text \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/16.png b/port_src/core/src/test/resources/blackbox/pdf417-2/16.png deleted file mode 100755 index b97f607..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/16.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/16.txt deleted file mode 100644 index ccef763..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/16.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF 417 barcode with a greater amount of text. This is a more difficult test for mobile devices to resolve. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/17.png b/port_src/core/src/test/resources/blackbox/pdf417-2/17.png deleted file mode 100755 index cfd5b8c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/17.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/17.txt deleted file mode 100644 index ccef763..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/17.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF 417 barcode with a greater amount of text. This is a more difficult test for mobile devices to resolve. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/18.png b/port_src/core/src/test/resources/blackbox/pdf417-2/18.png deleted file mode 100755 index ed618b1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/18.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/18.txt deleted file mode 100644 index ccef763..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/18.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF 417 barcode with a greater amount of text. This is a more difficult test for mobile devices to resolve. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/19.png b/port_src/core/src/test/resources/blackbox/pdf417-2/19.png deleted file mode 100755 index c290a05..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/19.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/19.txt deleted file mode 100644 index ccef763..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/19.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF 417 barcode with a greater amount of text. This is a more difficult test for mobile devices to resolve. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/20.png b/port_src/core/src/test/resources/blackbox/pdf417-2/20.png deleted file mode 100755 index 1d5dfb8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/20.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/20.txt deleted file mode 100644 index ccef763..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/20.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF 417 barcode with a greater amount of text. This is a more difficult test for mobile devices to resolve. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/21.png b/port_src/core/src/test/resources/blackbox/pdf417-2/21.png deleted file mode 100755 index 9dffd89..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/21.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/21.txt deleted file mode 100644 index ccef763..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/21.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF 417 barcode with a greater amount of text. This is a more difficult test for mobile devices to resolve. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/22.png b/port_src/core/src/test/resources/blackbox/pdf417-2/22.png deleted file mode 100755 index 4ec0353..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/22.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/22.txt deleted file mode 100644 index ccef763..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/22.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF 417 barcode with a greater amount of text. This is a more difficult test for mobile devices to resolve. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/23.png b/port_src/core/src/test/resources/blackbox/pdf417-2/23.png deleted file mode 100755 index ccdded2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/23.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/23.txt deleted file mode 100644 index ccef763..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/23.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF 417 barcode with a greater amount of text. This is a more difficult test for mobile devices to resolve. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/24.bin b/port_src/core/src/test/resources/blackbox/pdf417-2/24.bin deleted file mode 100755 index 4effe2e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/24.bin and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/24.png b/port_src/core/src/test/resources/blackbox/pdf417-2/24.png deleted file mode 100755 index fd88028..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/25.png b/port_src/core/src/test/resources/blackbox/pdf417-2/25.png deleted file mode 100755 index 739a9a9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-2/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-2/25.txt b/port_src/core/src/test/resources/blackbox/pdf417-2/25.txt deleted file mode 100644 index 8c84eae..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-2/25.txt +++ /dev/null @@ -1 +0,0 @@ -This is PDF417 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/01.png b/port_src/core/src/test/resources/blackbox/pdf417-3/01.png deleted file mode 100644 index b94256c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/01.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/01.txt deleted file mode 100644 index 26c04ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/01.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 8. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/02.png b/port_src/core/src/test/resources/blackbox/pdf417-3/02.png deleted file mode 100644 index 8255297..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/02.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/02.txt deleted file mode 100644 index 26c04ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/02.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 8. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/03.png b/port_src/core/src/test/resources/blackbox/pdf417-3/03.png deleted file mode 100644 index 9678458..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/03.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/03.txt deleted file mode 100644 index 26c04ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/03.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 8. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/04.png b/port_src/core/src/test/resources/blackbox/pdf417-3/04.png deleted file mode 100644 index 9cec13e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/04.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/04.txt deleted file mode 100644 index 26c04ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/04.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 8. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/05.png b/port_src/core/src/test/resources/blackbox/pdf417-3/05.png deleted file mode 100644 index 56361cc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/05.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/05.txt deleted file mode 100644 index 26c04ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/05.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 8. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/06.png b/port_src/core/src/test/resources/blackbox/pdf417-3/06.png deleted file mode 100644 index 39b4901..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/06.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/06.txt deleted file mode 100644 index 26c04ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/06.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 8. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/07.png b/port_src/core/src/test/resources/blackbox/pdf417-3/07.png deleted file mode 100644 index d05b7d2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/07.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/07.txt deleted file mode 100644 index 3d34dff..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/07.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 4. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/08.png b/port_src/core/src/test/resources/blackbox/pdf417-3/08.png deleted file mode 100644 index b75ecc8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/08.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/08.txt deleted file mode 100644 index 3d34dff..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/08.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 4. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/09.png b/port_src/core/src/test/resources/blackbox/pdf417-3/09.png deleted file mode 100644 index 9526fed..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/09.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/09.txt deleted file mode 100644 index 3d34dff..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/09.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 4. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/10.png b/port_src/core/src/test/resources/blackbox/pdf417-3/10.png deleted file mode 100644 index c32bf8a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/10.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/10.txt deleted file mode 100644 index 3d34dff..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/10.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 4. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/11.png b/port_src/core/src/test/resources/blackbox/pdf417-3/11.png deleted file mode 100644 index f7a1374..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/11.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/11.txt deleted file mode 100755 index 3d34dff..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/11.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 4. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/12.png b/port_src/core/src/test/resources/blackbox/pdf417-3/12.png deleted file mode 100644 index fd16e2d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/12.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/12.txt deleted file mode 100755 index 6cb0094..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/12.txt +++ /dev/null @@ -1 +0,0 @@ -[)>010210011840539080122327430201FDE238351251289 1/13.0LBY76 NINTH AVENUENEW YORK CITYNYSUSAN ZOLEZZI0610ZED00411ZGOOGLE12Z212565418630Z3100119200000114Z4TH FLOOR15Z39795720Z0.000.0028Z9080122327430201K533 PROGRAMS26Z584a \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/13.png b/port_src/core/src/test/resources/blackbox/pdf417-3/13.png deleted file mode 100644 index 696d413..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/13.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/13.txt deleted file mode 100644 index 26c04ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/13.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 8. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/14.png b/port_src/core/src/test/resources/blackbox/pdf417-3/14.png deleted file mode 100644 index fe56c48..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/14.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/14.txt deleted file mode 100644 index 26c04ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/14.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 8. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/15.png b/port_src/core/src/test/resources/blackbox/pdf417-3/15.png deleted file mode 100644 index 1aa8312..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/15.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/15.txt deleted file mode 100644 index 26c04ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/15.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 8. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/16.png b/port_src/core/src/test/resources/blackbox/pdf417-3/16.png deleted file mode 100644 index 5438e4c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/16.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/16.txt deleted file mode 100644 index 26c04ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/16.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 8. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/17.png b/port_src/core/src/test/resources/blackbox/pdf417-3/17.png deleted file mode 100644 index 8ef101c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/17.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/17.txt deleted file mode 100644 index 26c04ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/17.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 8. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/18.png b/port_src/core/src/test/resources/blackbox/pdf417-3/18.png deleted file mode 100644 index 3ed8f53..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/18.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/18.txt deleted file mode 100644 index 26c04ce..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/18.txt +++ /dev/null @@ -1 +0,0 @@ -A larger PDF417 barcode with text and error correction level 8. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/19.png b/port_src/core/src/test/resources/blackbox/pdf417-3/19.png deleted file mode 100644 index fcf4b65..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-3/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-3/19.txt b/port_src/core/src/test/resources/blackbox/pdf417-3/19.txt deleted file mode 100644 index 49db7a0..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-3/19.txt +++ /dev/null @@ -1 +0,0 @@ -0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/pdf417-4/01-01.png b/port_src/core/src/test/resources/blackbox/pdf417-4/01-01.png deleted file mode 100644 index c1bf329..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-4/01-01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-4/01.bin b/port_src/core/src/test/resources/blackbox/pdf417-4/01.bin deleted file mode 100644 index 4effe2e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-4/01.bin and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-4/02-01.png b/port_src/core/src/test/resources/blackbox/pdf417-4/02-01.png deleted file mode 100644 index 12d12ce..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-4/02-01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-4/02-02.png b/port_src/core/src/test/resources/blackbox/pdf417-4/02-02.png deleted file mode 100644 index 55ac0bb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-4/02-02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-4/02.bin b/port_src/core/src/test/resources/blackbox/pdf417-4/02.bin deleted file mode 100644 index 9c07c8f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-4/02.bin and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-4/04-01.png b/port_src/core/src/test/resources/blackbox/pdf417-4/04-01.png deleted file mode 100644 index 5a301e1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/pdf417-4/04-01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/pdf417-4/04.txt b/port_src/core/src/test/resources/blackbox/pdf417-4/04.txt deleted file mode 100644 index 9da7d8c..0000000 --- a/port_src/core/src/test/resources/blackbox/pdf417-4/04.txt +++ /dev/null @@ -1 +0,0 @@ -01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/1.metadata.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/1.metadata.txt deleted file mode 100644 index 6f6e83d..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/1.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]Q1 diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/1.png b/port_src/core/src/test/resources/blackbox/qrcode-1/1.png deleted file mode 100644 index 8c80b11..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/1.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/1.txt deleted file mode 100644 index cb6b805..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:URL:http\://en.wikipedia.org/wiki/Main_Page;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/10.png b/port_src/core/src/test/resources/blackbox/qrcode-1/10.png deleted file mode 100644 index cd727f2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/10.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/10.txt deleted file mode 100644 index cb6b805..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/10.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:URL:http\://en.wikipedia.org/wiki/Main_Page;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/11.png b/port_src/core/src/test/resources/blackbox/qrcode-1/11.png deleted file mode 100644 index 388c40b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/11.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/11.txt deleted file mode 100644 index cb6b805..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/11.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:URL:http\://en.wikipedia.org/wiki/Main_Page;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/12.png b/port_src/core/src/test/resources/blackbox/qrcode-1/12.png deleted file mode 100644 index c47eb55..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/12.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/12.txt deleted file mode 100644 index cb6b805..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/12.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:URL:http\://en.wikipedia.org/wiki/Main_Page;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/13.png b/port_src/core/src/test/resources/blackbox/qrcode-1/13.png deleted file mode 100644 index 5568fef..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/13.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/13.txt deleted file mode 100644 index c6adb03..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/13.txt +++ /dev/null @@ -1 +0,0 @@ -http://google.com/gwt/n?u=bluenile.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/14.png b/port_src/core/src/test/resources/blackbox/qrcode-1/14.png deleted file mode 100644 index a22d5b3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/14.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/14.txt deleted file mode 100644 index c6adb03..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/14.txt +++ /dev/null @@ -1 +0,0 @@ -http://google.com/gwt/n?u=bluenile.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/15.png b/port_src/core/src/test/resources/blackbox/qrcode-1/15.png deleted file mode 100644 index 004d36f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/15.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/15.txt deleted file mode 100644 index c6adb03..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/15.txt +++ /dev/null @@ -1 +0,0 @@ -http://google.com/gwt/n?u=bluenile.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/16.png b/port_src/core/src/test/resources/blackbox/qrcode-1/16.png deleted file mode 100644 index 5666aaa..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/16.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/16.txt deleted file mode 100644 index 31a244c..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/16.txt +++ /dev/null @@ -1,4 +0,0 @@ -Sean Owen -srowen@google.com -917-364-2918 -http://awesome-thoughts.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/17.png b/port_src/core/src/test/resources/blackbox/qrcode-1/17.png deleted file mode 100644 index 62d86d1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/17.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/17.txt deleted file mode 100644 index 31a244c..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/17.txt +++ /dev/null @@ -1,4 +0,0 @@ -Sean Owen -srowen@google.com -917-364-2918 -http://awesome-thoughts.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/18.png b/port_src/core/src/test/resources/blackbox/qrcode-1/18.png deleted file mode 100644 index 7d39c4a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/18.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/18.txt deleted file mode 100644 index 31a244c..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/18.txt +++ /dev/null @@ -1,4 +0,0 @@ -Sean Owen -srowen@google.com -917-364-2918 -http://awesome-thoughts.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/19.png b/port_src/core/src/test/resources/blackbox/qrcode-1/19.png deleted file mode 100644 index 3839f58..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/19.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/19.txt deleted file mode 100644 index 31a244c..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/19.txt +++ /dev/null @@ -1,4 +0,0 @@ -Sean Owen -srowen@google.com -917-364-2918 -http://awesome-thoughts.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/2.png b/port_src/core/src/test/resources/blackbox/qrcode-1/2.png deleted file mode 100644 index 528030d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/2.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/2.txt deleted file mode 100644 index cb6b805..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/2.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:URL:http\://en.wikipedia.org/wiki/Main_Page;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/20.png b/port_src/core/src/test/resources/blackbox/qrcode-1/20.png deleted file mode 100644 index 97b4f0a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/20.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/20.txt deleted file mode 100644 index 31a244c..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/20.txt +++ /dev/null @@ -1,4 +0,0 @@ -Sean Owen -srowen@google.com -917-364-2918 -http://awesome-thoughts.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/3.png b/port_src/core/src/test/resources/blackbox/qrcode-1/3.png deleted file mode 100644 index 2611b88..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/3.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/3.txt deleted file mode 100644 index cb6b805..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/3.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:URL:http\://en.wikipedia.org/wiki/Main_Page;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/4.png b/port_src/core/src/test/resources/blackbox/qrcode-1/4.png deleted file mode 100644 index 9c02d90..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/4.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/4.txt deleted file mode 100644 index cb6b805..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/4.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:URL:http\://en.wikipedia.org/wiki/Main_Page;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/5.png b/port_src/core/src/test/resources/blackbox/qrcode-1/5.png deleted file mode 100644 index 3667ca6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/5.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/5.txt deleted file mode 100644 index cb6b805..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/5.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:URL:http\://en.wikipedia.org/wiki/Main_Page;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/6.png b/port_src/core/src/test/resources/blackbox/qrcode-1/6.png deleted file mode 100644 index 5d38294..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/6.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/6.txt deleted file mode 100644 index cb6b805..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/6.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:URL:http\://en.wikipedia.org/wiki/Main_Page;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/7.png b/port_src/core/src/test/resources/blackbox/qrcode-1/7.png deleted file mode 100644 index 44c1557..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/7.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/7.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/7.txt deleted file mode 100644 index cb6b805..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/7.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:URL:http\://en.wikipedia.org/wiki/Main_Page;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/8.png b/port_src/core/src/test/resources/blackbox/qrcode-1/8.png deleted file mode 100644 index 4513892..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/8.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/8.txt deleted file mode 100644 index cb6b805..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/8.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:URL:http\://en.wikipedia.org/wiki/Main_Page;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/9.png b/port_src/core/src/test/resources/blackbox/qrcode-1/9.png deleted file mode 100644 index a589ee4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-1/9.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-1/9.txt b/port_src/core/src/test/resources/blackbox/qrcode-1/9.txt deleted file mode 100644 index cb6b805..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-1/9.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:URL:http\://en.wikipedia.org/wiki/Main_Page;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/1.png b/port_src/core/src/test/resources/blackbox/qrcode-2/1.png deleted file mode 100644 index 9924161..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/1.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/1.txt deleted file mode 100644 index 58493bd..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/1.txt +++ /dev/null @@ -1 +0,0 @@ -When we at WRT talk about \"text,\" we are generally talking about a particular kind of readable information encoding - and readable is a complex proposition. Text may be stylized in a way we are unfamiliar with, as in blackletter - it may be interspersed with some markup we don\'t understand, such as HTML - it may be be a substitution system we aren\'t familiar with, such as braille or morse code - or it may be a system that, while technically human-readable, isn\'t particularly optimized for reading by humans, as with barcodes (although barcodes can be read). \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/10.png b/port_src/core/src/test/resources/blackbox/qrcode-2/10.png deleted file mode 100644 index e8e208e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/10.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/10.txt deleted file mode 100644 index 14632d9..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/10.txt +++ /dev/null @@ -1,2 +0,0 @@ -Google モãƒã‚¤ãƒ« -http://google.jp \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/11.png b/port_src/core/src/test/resources/blackbox/qrcode-2/11.png deleted file mode 100644 index e96bb81..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/11.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/11.txt deleted file mode 100644 index 2b574b7..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/11.txt +++ /dev/null @@ -1,12 +0,0 @@ -BEGIN:VCARD -N:Kennedy;Steve -TEL:+44 (0)7775 755503 -ADR;HOME:;;Flat 2, 43 Howitt Road, Belsize Park;London;;NW34LU;UK -ORG:NetTek Ltd; -TITLE:Consultant -EMAIL:steve@nettek.co.uk -URL:www.nettek.co.uk -EMAIL;IM:MSN:steve@gbnet.net -NOTE:Testing 1 2 3 -BDAY:19611105 -END:VCARD \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/12.png b/port_src/core/src/test/resources/blackbox/qrcode-2/12.png deleted file mode 100644 index adfdcd9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/12.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/12.txt deleted file mode 100644 index 6c62da9..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/12.txt +++ /dev/null @@ -1 +0,0 @@ -The 2005 USGS aerial photography of the Washington Monument is censored. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/13.png b/port_src/core/src/test/resources/blackbox/qrcode-2/13.png deleted file mode 100644 index 406a7cf..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/13.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/13.txt deleted file mode 100644 index 7729d64..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/13.txt +++ /dev/null @@ -1 +0,0 @@ -The 2005 USGS aerial photograph of the Washington Monument is censored. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/14.png b/port_src/core/src/test/resources/blackbox/qrcode-2/14.png deleted file mode 100644 index 230a352..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/14.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/14.txt deleted file mode 100644 index 454a60e..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/14.txt +++ /dev/null @@ -1 +0,0 @@ -http://bbc.co.uk/programmes \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/15.png b/port_src/core/src/test/resources/blackbox/qrcode-2/15.png deleted file mode 100644 index 5ff1520..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/15.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/15.txt deleted file mode 100644 index e6b5a97..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/15.txt +++ /dev/null @@ -1 +0,0 @@ -In 25 words or less in the comments, below, tell us how QR codes will make the world less ordinary. \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/16.png b/port_src/core/src/test/resources/blackbox/qrcode-2/16.png deleted file mode 100644 index d0effb7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/16.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/16.txt deleted file mode 100644 index f2c0201..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/16.txt +++ /dev/null @@ -1,4 +0,0 @@ -[外å´QRコード] - -*ダブルQR* -http://d-qr.net/ex/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/17.png b/port_src/core/src/test/resources/blackbox/qrcode-2/17.png deleted file mode 100644 index 33e42cb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/17.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/17.txt deleted file mode 100644 index 7fba436..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/17.txt +++ /dev/null @@ -1,2 +0,0 @@ -デザイï¾QR -http://d-qr.net/ex/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/18.png b/port_src/core/src/test/resources/blackbox/qrcode-2/18.png deleted file mode 100644 index 13d65cb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/18.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/18.txt deleted file mode 100644 index beb8901..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/18.txt +++ /dev/null @@ -1,2 +0,0 @@ -*デザイï¾QR* -http://d-qr.net/ex/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/19.png b/port_src/core/src/test/resources/blackbox/qrcode-2/19.png deleted file mode 100644 index ec1df04..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/19.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/19.txt deleted file mode 100644 index 88f2165..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/19.txt +++ /dev/null @@ -1,2 +0,0 @@ -*デザイï¾QR* -http://d-qr.net/ex/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/2.png b/port_src/core/src/test/resources/blackbox/qrcode-2/2.png deleted file mode 100644 index 18f1f8a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/2.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/2.txt deleted file mode 100644 index 38d534e..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/2.txt +++ /dev/null @@ -1 +0,0 @@ -LANDBYASCARC PERCEPTIBLEC EEK,OOZI GITSWAYTHROU AWILDERNESSOFBESUPPOSED,I CANT,ORATL ASTDWARFISH.NO REESOFANYM NITUDEARETOBESOMEMISERA EFRAMEBUIL I GS,TENANTED, U INGSUMMER THEFUGITIVE;BUTTHEWHO ISLAND,WI H EXCEPTIONOFT W STERNPOI ,ANDALINEOFLLIAMLEGR .HEWASOF N ENTHUGUENOTF Y ANDHADON BEENWEALTHTIONCONSE ENTUPONH SD STERS,HELEFTNE LE NS,THEC OFHISFOREOUTHCARO A.THISISLA AVERYSINGULARO TCONSISTSO ITTLEELSEDSAQUART FAMILE. TI PARATEDFROMTHEMA AN BYASCAR YPERCEPTERESORT MARSH EN EVEGETATION,ASMIGH SU POSED, CANT,ORATREMITY, ORT OULTRIESTANDS,ANDWHEREARESOM MIS FRAMEBUIFEVER,MAYBE INDEED, TO;BUTT EISLAND,WITNYYEARSAGO,IC ACTED LLIAM AND.HEWASOFANNESHADREDUCEDHIM OWA IONC NSEQUENTUPONHISDSIDENCEATSULLIVA \'S HC ROLINA.THISISLANOUTTHR LESLON . THATN OINTE U RTEROF E.ITISTHROU ERNE DSANDSLI ,AFAVOR TOFT HEN.T \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/20.png b/port_src/core/src/test/resources/blackbox/qrcode-2/20.png deleted file mode 100644 index 0a645ce..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/20.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/20.txt deleted file mode 100644 index d88f5eb..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/20.txt +++ /dev/null @@ -1,2 +0,0 @@ -*デザイï¾QR* -http://d-qr.net/ex/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/21.png b/port_src/core/src/test/resources/blackbox/qrcode-2/21.png deleted file mode 100644 index be83a0b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/21.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/21.txt deleted file mode 100644 index 09c84c7..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/21.txt +++ /dev/null @@ -1,2 +0,0 @@ -*デザイï¾QR* -http://d-qr.net/ex/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/22.png b/port_src/core/src/test/resources/blackbox/qrcode-2/22.png deleted file mode 100644 index 083f511..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/22.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/22.txt deleted file mode 100644 index eeaa3a7..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/22.txt +++ /dev/null @@ -1 +0,0 @@ -http://www.hotpepper.jp/mobile/cgi-bin/MBLC80100.cgi?SA=00&Z=AG&vos=hpp064&uid=NULLGWDOCOMO \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/23.png b/port_src/core/src/test/resources/blackbox/qrcode-2/23.png deleted file mode 100644 index 27ced01..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/23.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/23.txt deleted file mode 100644 index c7cd5be..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/23.txt +++ /dev/null @@ -1 +0,0 @@ -http://aniful.jp/pr/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/24.png b/port_src/core/src/test/resources/blackbox/qrcode-2/24.png deleted file mode 100644 index 1b3854a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/24.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/24.txt deleted file mode 100644 index 41bcbc1..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/24.txt +++ /dev/null @@ -1,2 +0,0 @@ -*デザイï¾QR* -http://d-qr.net/ex/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/25.png b/port_src/core/src/test/resources/blackbox/qrcode-2/25.png deleted file mode 100644 index d284360..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/25.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/25.txt deleted file mode 100644 index 2742bc1..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/25.txt +++ /dev/null @@ -1 +0,0 @@ -MEBKM:TITLE:;URL:http://d.kaywa.com/2020400102;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/26.png b/port_src/core/src/test/resources/blackbox/qrcode-2/26.png deleted file mode 100644 index 421072a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/26.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/26.txt deleted file mode 100644 index c4f62fe..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/26.txt +++ /dev/null @@ -1,3 +0,0 @@ -<デザイï¾QR> -イラスト入りカラーQRコード -http://d-qr.net/ex/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/27.png b/port_src/core/src/test/resources/blackbox/qrcode-2/27.png deleted file mode 100644 index 29cda4b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/27.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/27.txt deleted file mode 100644 index bb0c693..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/27.txt +++ /dev/null @@ -1,2 +0,0 @@ -*デザイï¾QR* -http://d-qr.net/ex/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/28.png b/port_src/core/src/test/resources/blackbox/qrcode-2/28.png deleted file mode 100644 index ccbb4a6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/28.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/28.txt deleted file mode 100644 index c44369e..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/28.txt +++ /dev/null @@ -1 +0,0 @@ -http://www.webtech.co.jp/k/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/29.png b/port_src/core/src/test/resources/blackbox/qrcode-2/29.png deleted file mode 100644 index 64fee6d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/29.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/29.txt deleted file mode 100644 index 87ad299..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/29.txt +++ /dev/null @@ -1,3 +0,0 @@ -http://live.fdgm.jp/u/event/hype/hype_top.html - -MEBKM:TITLE:hypeモãƒã‚¤ãƒ«;URL:http\://live.fdgm.jp/u/event/hype/hype_top.html;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/30.png b/port_src/core/src/test/resources/blackbox/qrcode-2/30.png deleted file mode 100644 index 2dc5e45..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/30.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/30.txt deleted file mode 100644 index bc64130..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/30.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:測試;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/31.png b/port_src/core/src/test/resources/blackbox/qrcode-2/31.png deleted file mode 100644 index e57d2d2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/31.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/31.txt deleted file mode 100644 index 59d2e9d..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/31.txt +++ /dev/null @@ -1 +0,0 @@ -今度ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã¯æ–‡ç« ã®æš—å·åŒ–ãŒã§ãã¾ã™ã€‚ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/32.png b/port_src/core/src/test/resources/blackbox/qrcode-2/32.png deleted file mode 100644 index 86572c5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/32.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/32.txt deleted file mode 100644 index 2b574b7..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/32.txt +++ /dev/null @@ -1,12 +0,0 @@ -BEGIN:VCARD -N:Kennedy;Steve -TEL:+44 (0)7775 755503 -ADR;HOME:;;Flat 2, 43 Howitt Road, Belsize Park;London;;NW34LU;UK -ORG:NetTek Ltd; -TITLE:Consultant -EMAIL:steve@nettek.co.uk -URL:www.nettek.co.uk -EMAIL;IM:MSN:steve@gbnet.net -NOTE:Testing 1 2 3 -BDAY:19611105 -END:VCARD \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/33.png b/port_src/core/src/test/resources/blackbox/qrcode-2/33.png deleted file mode 100644 index 45d6b39..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/33.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/33.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/33.txt deleted file mode 100644 index a8d077e..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/33.txt +++ /dev/null @@ -1 +0,0 @@ -AD:SUB:阿;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/34.png b/port_src/core/src/test/resources/blackbox/qrcode-2/34.png deleted file mode 100644 index 0f55ee4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/34.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/34.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/34.txt deleted file mode 100644 index d83e8aa..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/34.txt +++ /dev/null @@ -1 +0,0 @@ -http://www.google.com/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/35.png b/port_src/core/src/test/resources/blackbox/qrcode-2/35.png deleted file mode 100644 index 6b17f3e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/35.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/35.txt deleted file mode 100644 index d83e8aa..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/35.txt +++ /dev/null @@ -1 +0,0 @@ -http://www.google.com/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/4.png b/port_src/core/src/test/resources/blackbox/qrcode-2/4.png deleted file mode 100644 index f11eb70..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/4.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/4.txt deleted file mode 100644 index dd36eda..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/4.txt +++ /dev/null @@ -1 +0,0 @@ -http://wwws.keihin.ktr.mlit.go.jp/keitai/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/5.png b/port_src/core/src/test/resources/blackbox/qrcode-2/5.png deleted file mode 100644 index d7f3de7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/5.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/5.txt deleted file mode 100644 index 9a35ecd..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/5.txt +++ /dev/null @@ -1 +0,0 @@ -2021200000 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/6.png b/port_src/core/src/test/resources/blackbox/qrcode-2/6.png deleted file mode 100644 index c3689de..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/6.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/6.txt deleted file mode 100644 index 87c34b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/6.txt +++ /dev/null @@ -1 +0,0 @@ -http://d.kaywa.com/20207100 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/7.png b/port_src/core/src/test/resources/blackbox/qrcode-2/7.png deleted file mode 100644 index a8bea69..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/7.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/7.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/7.txt deleted file mode 100644 index b8c822d..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/7.txt +++ /dev/null @@ -1 +0,0 @@ -BIZCARD:N:Todd;X:Ogasawara;T:Tech Geek;C:MobileViews.com;A:MobileTown USA;E:editor@mobileviews.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/8.png b/port_src/core/src/test/resources/blackbox/qrcode-2/8.png deleted file mode 100644 index f2aeaeb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/8.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/8.txt deleted file mode 100644 index 9e0a7f8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/8.txt +++ /dev/null @@ -1 +0,0 @@ -http://staticrooster.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/9.png b/port_src/core/src/test/resources/blackbox/qrcode-2/9.png deleted file mode 100644 index dde744c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-2/9.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-2/9.txt b/port_src/core/src/test/resources/blackbox/qrcode-2/9.txt deleted file mode 100644 index 292aea1..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-2/9.txt +++ /dev/null @@ -1 +0,0 @@ -Morden \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/01.png b/port_src/core/src/test/resources/blackbox/qrcode-3/01.png deleted file mode 100644 index 0516fde..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/01.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/01.txt deleted file mode 100644 index 4960897..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/01.txt +++ /dev/null @@ -1 +0,0 @@ -http://arnaud.sahuguet.com/graffiti/test.php?ll=-74.00309961503218,40.74102573163046,0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/02.png b/port_src/core/src/test/resources/blackbox/qrcode-3/02.png deleted file mode 100644 index c5f1503..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/02.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/02.txt deleted file mode 100644 index 4960897..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/02.txt +++ /dev/null @@ -1 +0,0 @@ -http://arnaud.sahuguet.com/graffiti/test.php?ll=-74.00309961503218,40.74102573163046,0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/03.png b/port_src/core/src/test/resources/blackbox/qrcode-3/03.png deleted file mode 100644 index d343328..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/03.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/03.txt deleted file mode 100644 index 4960897..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/03.txt +++ /dev/null @@ -1 +0,0 @@ -http://arnaud.sahuguet.com/graffiti/test.php?ll=-74.00309961503218,40.74102573163046,0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/04.png b/port_src/core/src/test/resources/blackbox/qrcode-3/04.png deleted file mode 100644 index 2b91e82..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/04.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/04.txt deleted file mode 100644 index 4960897..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/04.txt +++ /dev/null @@ -1 +0,0 @@ -http://arnaud.sahuguet.com/graffiti/test.php?ll=-74.00309961503218,40.74102573163046,0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/05.png b/port_src/core/src/test/resources/blackbox/qrcode-3/05.png deleted file mode 100644 index 91ba4c0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/05.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/05.txt deleted file mode 100644 index 4960897..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/05.txt +++ /dev/null @@ -1 +0,0 @@ -http://arnaud.sahuguet.com/graffiti/test.php?ll=-74.00309961503218,40.74102573163046,0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/06.png b/port_src/core/src/test/resources/blackbox/qrcode-3/06.png deleted file mode 100644 index a817273..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/06.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/06.txt deleted file mode 100644 index 4960897..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/06.txt +++ /dev/null @@ -1 +0,0 @@ -http://arnaud.sahuguet.com/graffiti/test.php?ll=-74.00309961503218,40.74102573163046,0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/07.png b/port_src/core/src/test/resources/blackbox/qrcode-3/07.png deleted file mode 100644 index 40d4e90..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/07.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/07.txt deleted file mode 100644 index 4960897..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/07.txt +++ /dev/null @@ -1 +0,0 @@ -http://arnaud.sahuguet.com/graffiti/test.php?ll=-74.00309961503218,40.74102573163046,0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/08.png b/port_src/core/src/test/resources/blackbox/qrcode-3/08.png deleted file mode 100644 index 0f66362..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/08.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/08.txt deleted file mode 100644 index 4960897..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/08.txt +++ /dev/null @@ -1 +0,0 @@ -http://arnaud.sahuguet.com/graffiti/test.php?ll=-74.00309961503218,40.74102573163046,0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/09.png b/port_src/core/src/test/resources/blackbox/qrcode-3/09.png deleted file mode 100644 index cdc8ffe..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/09.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/09.txt deleted file mode 100644 index 4960897..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/09.txt +++ /dev/null @@ -1 +0,0 @@ -http://arnaud.sahuguet.com/graffiti/test.php?ll=-74.00309961503218,40.74102573163046,0 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/10.png b/port_src/core/src/test/resources/blackbox/qrcode-3/10.png deleted file mode 100644 index 11878d1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/10.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/10.txt deleted file mode 100644 index 352576d..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/10.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Google 411,;TEL:18665881077;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/11.png b/port_src/core/src/test/resources/blackbox/qrcode-3/11.png deleted file mode 100644 index 1ac137b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/11.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/11.txt deleted file mode 100644 index 352576d..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/11.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Google 411,;TEL:18665881077;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/12.png b/port_src/core/src/test/resources/blackbox/qrcode-3/12.png deleted file mode 100644 index 2f10260..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/12.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/12.txt deleted file mode 100644 index 352576d..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/12.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Google 411,;TEL:18665881077;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/13.png b/port_src/core/src/test/resources/blackbox/qrcode-3/13.png deleted file mode 100644 index 4cdc64d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/13.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/13.txt deleted file mode 100644 index 352576d..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/13.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Google 411,;TEL:18665881077;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/14.png b/port_src/core/src/test/resources/blackbox/qrcode-3/14.png deleted file mode 100644 index e1386f8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/14.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/14.txt deleted file mode 100644 index 352576d..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/14.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Google 411,;TEL:18665881077;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/15.png b/port_src/core/src/test/resources/blackbox/qrcode-3/15.png deleted file mode 100644 index c871b97..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/15.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/15.txt deleted file mode 100644 index 352576d..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/15.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Google 411,;TEL:18665881077;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/16.png b/port_src/core/src/test/resources/blackbox/qrcode-3/16.png deleted file mode 100644 index da6406d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/16.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/16.txt deleted file mode 100644 index 352576d..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/16.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Google 411,;TEL:18665881077;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/17.png b/port_src/core/src/test/resources/blackbox/qrcode-3/17.png deleted file mode 100644 index d31cf51..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/17.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/17.txt deleted file mode 100644 index 352576d..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/17.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Google 411,;TEL:18665881077;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/18.png b/port_src/core/src/test/resources/blackbox/qrcode-3/18.png deleted file mode 100644 index 64de4bc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/18.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/18.txt deleted file mode 100644 index 44a23fd..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/18.txt +++ /dev/null @@ -1,2 +0,0 @@ -UI office hours signup -http://www.corp.google.com/sparrow/ui_office_hours/ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/19.png b/port_src/core/src/test/resources/blackbox/qrcode-3/19.png deleted file mode 100644 index c8e84f5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/19.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/19.txt deleted file mode 100644 index 44a23fd..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/19.txt +++ /dev/null @@ -1,2 +0,0 @@ -UI office hours signup -http://www.corp.google.com/sparrow/ui_office_hours/ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/20.png b/port_src/core/src/test/resources/blackbox/qrcode-3/20.png deleted file mode 100644 index e973428..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/20.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/20.txt deleted file mode 100644 index 44a23fd..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/20.txt +++ /dev/null @@ -1,2 +0,0 @@ -UI office hours signup -http://www.corp.google.com/sparrow/ui_office_hours/ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/21.png b/port_src/core/src/test/resources/blackbox/qrcode-3/21.png deleted file mode 100644 index c9aa5ab..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/21.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/21.txt deleted file mode 100644 index 44a23fd..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/21.txt +++ /dev/null @@ -1,2 +0,0 @@ -UI office hours signup -http://www.corp.google.com/sparrow/ui_office_hours/ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/22.png b/port_src/core/src/test/resources/blackbox/qrcode-3/22.png deleted file mode 100644 index 56fc693..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/22.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/22.txt deleted file mode 100644 index 44a23fd..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/22.txt +++ /dev/null @@ -1,2 +0,0 @@ -UI office hours signup -http://www.corp.google.com/sparrow/ui_office_hours/ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/23.png b/port_src/core/src/test/resources/blackbox/qrcode-3/23.png deleted file mode 100644 index ff41d0e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/23.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/23.txt deleted file mode 100644 index 44a23fd..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/23.txt +++ /dev/null @@ -1,2 +0,0 @@ -UI office hours signup -http://www.corp.google.com/sparrow/ui_office_hours/ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/24.png b/port_src/core/src/test/resources/blackbox/qrcode-3/24.png deleted file mode 100644 index ea7b5b7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/24.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/24.txt deleted file mode 100644 index 44a23fd..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/24.txt +++ /dev/null @@ -1,2 +0,0 @@ -UI office hours signup -http://www.corp.google.com/sparrow/ui_office_hours/ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/25.png b/port_src/core/src/test/resources/blackbox/qrcode-3/25.png deleted file mode 100644 index 8ccf05c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/25.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/25.txt deleted file mode 100644 index 44a23fd..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/25.txt +++ /dev/null @@ -1,2 +0,0 @@ -UI office hours signup -http://www.corp.google.com/sparrow/ui_office_hours/ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/26.png b/port_src/core/src/test/resources/blackbox/qrcode-3/26.png deleted file mode 100644 index 4c73b76..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/26.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/26.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/26.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/27.png b/port_src/core/src/test/resources/blackbox/qrcode-3/27.png deleted file mode 100644 index 62ff369..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/27.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/27.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/27.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/28.png b/port_src/core/src/test/resources/blackbox/qrcode-3/28.png deleted file mode 100644 index fce05e1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/28.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/28.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/28.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/29.png b/port_src/core/src/test/resources/blackbox/qrcode-3/29.png deleted file mode 100644 index 5663531..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/29.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/29.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/29.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/30.png b/port_src/core/src/test/resources/blackbox/qrcode-3/30.png deleted file mode 100644 index cfd247c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/30.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/30.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/30.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/31.png b/port_src/core/src/test/resources/blackbox/qrcode-3/31.png deleted file mode 100644 index 1613197..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/31.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/31.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/31.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/32.png b/port_src/core/src/test/resources/blackbox/qrcode-3/32.png deleted file mode 100644 index 64faf8e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/32.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/32.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/32.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/33.png b/port_src/core/src/test/resources/blackbox/qrcode-3/33.png deleted file mode 100644 index d58e983..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/33.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/33.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/33.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/33.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/34.png b/port_src/core/src/test/resources/blackbox/qrcode-3/34.png deleted file mode 100644 index cb6b401..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/34.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/34.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/34.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/34.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/35.png b/port_src/core/src/test/resources/blackbox/qrcode-3/35.png deleted file mode 100644 index f9d38b1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/35.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/35.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/35.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/36.png b/port_src/core/src/test/resources/blackbox/qrcode-3/36.png deleted file mode 100644 index 9e63693..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/36.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/36.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/36.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/36.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/37.png b/port_src/core/src/test/resources/blackbox/qrcode-3/37.png deleted file mode 100644 index c47245e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/37.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/37.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/37.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/37.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/38.png b/port_src/core/src/test/resources/blackbox/qrcode-3/38.png deleted file mode 100644 index ebf084d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/38.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/38.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/38.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/38.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/39.png b/port_src/core/src/test/resources/blackbox/qrcode-3/39.png deleted file mode 100644 index 197c78c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/39.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/39.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/39.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/39.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/40.png b/port_src/core/src/test/resources/blackbox/qrcode-3/40.png deleted file mode 100644 index 50ff9b8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/40.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/40.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/40.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/40.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/41.png b/port_src/core/src/test/resources/blackbox/qrcode-3/41.png deleted file mode 100644 index bcd098f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/41.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/41.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/41.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/41.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/42.png b/port_src/core/src/test/resources/blackbox/qrcode-3/42.png deleted file mode 100644 index 96aa633..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-3/42.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-3/42.txt b/port_src/core/src/test/resources/blackbox/qrcode-3/42.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-3/42.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/01.png b/port_src/core/src/test/resources/blackbox/qrcode-4/01.png deleted file mode 100644 index 9332ace..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/01.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/01.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/01.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/02.png b/port_src/core/src/test/resources/blackbox/qrcode-4/02.png deleted file mode 100644 index ca10fc5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/02.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/02.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/02.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/03.png b/port_src/core/src/test/resources/blackbox/qrcode-4/03.png deleted file mode 100644 index f0eea85..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/03.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/03.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/03.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/04.png b/port_src/core/src/test/resources/blackbox/qrcode-4/04.png deleted file mode 100644 index 8922b2d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/04.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/04.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/04.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/05.png b/port_src/core/src/test/resources/blackbox/qrcode-4/05.png deleted file mode 100644 index 3660418..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/05.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/05.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/05.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/06.png b/port_src/core/src/test/resources/blackbox/qrcode-4/06.png deleted file mode 100644 index d720caf..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/06.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/06.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/06.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/07.png b/port_src/core/src/test/resources/blackbox/qrcode-4/07.png deleted file mode 100644 index 3a206bd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/07.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/07.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/07.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/08.png b/port_src/core/src/test/resources/blackbox/qrcode-4/08.png deleted file mode 100644 index a79726b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/08.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/08.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/08.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/09.png b/port_src/core/src/test/resources/blackbox/qrcode-4/09.png deleted file mode 100644 index 5ea0640..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/09.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/09.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/09.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/10.png b/port_src/core/src/test/resources/blackbox/qrcode-4/10.png deleted file mode 100644 index 1e3b8a4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/10.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/10.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/10.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/11.png b/port_src/core/src/test/resources/blackbox/qrcode-4/11.png deleted file mode 100644 index 82c9652..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/11.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/11.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/11.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/12.png b/port_src/core/src/test/resources/blackbox/qrcode-4/12.png deleted file mode 100644 index 6f10785..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/12.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/12.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/12.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/13.png b/port_src/core/src/test/resources/blackbox/qrcode-4/13.png deleted file mode 100644 index 4020548..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/13.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/13.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/13.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/14.png b/port_src/core/src/test/resources/blackbox/qrcode-4/14.png deleted file mode 100644 index b547f72..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/14.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/14.txt deleted file mode 100644 index f94af84..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/14.txt +++ /dev/null @@ -1 +0,0 @@ -Google Print Ads - T.G.I.A.F. - January 31, 2008 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/15.png b/port_src/core/src/test/resources/blackbox/qrcode-4/15.png deleted file mode 100644 index 008c271..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/15.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/15.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/15.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/16.png b/port_src/core/src/test/resources/blackbox/qrcode-4/16.png deleted file mode 100644 index 38a5be2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/16.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/16.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/16.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/17.png b/port_src/core/src/test/resources/blackbox/qrcode-4/17.png deleted file mode 100644 index c40df6a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/17.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/17.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/17.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/18.png b/port_src/core/src/test/resources/blackbox/qrcode-4/18.png deleted file mode 100644 index 9ce0eae..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/18.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/18.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/18.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/19.png b/port_src/core/src/test/resources/blackbox/qrcode-4/19.png deleted file mode 100644 index fdf79a8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/19.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/19.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/19.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/20.png b/port_src/core/src/test/resources/blackbox/qrcode-4/20.png deleted file mode 100644 index afcce6f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/20.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/20.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/20.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/21.png b/port_src/core/src/test/resources/blackbox/qrcode-4/21.png deleted file mode 100644 index 3379b17..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/21.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/21.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/21.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/22.png b/port_src/core/src/test/resources/blackbox/qrcode-4/22.png deleted file mode 100644 index 1a40424..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/22.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/22.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/22.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/23.png b/port_src/core/src/test/resources/blackbox/qrcode-4/23.png deleted file mode 100644 index c13d170..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/23.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/23.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/23.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/24.png b/port_src/core/src/test/resources/blackbox/qrcode-4/24.png deleted file mode 100644 index e026f48..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/24.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/24.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/24.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/25.png b/port_src/core/src/test/resources/blackbox/qrcode-4/25.png deleted file mode 100644 index 2e1000e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/25.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/25.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/25.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/26.png b/port_src/core/src/test/resources/blackbox/qrcode-4/26.png deleted file mode 100644 index 1547094..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/26.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/26.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/26.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/27.png b/port_src/core/src/test/resources/blackbox/qrcode-4/27.png deleted file mode 100644 index 668a20b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/27.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/27.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/27.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/28.png b/port_src/core/src/test/resources/blackbox/qrcode-4/28.png deleted file mode 100644 index de12827..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/28.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/28.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/28.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/29.png b/port_src/core/src/test/resources/blackbox/qrcode-4/29.png deleted file mode 100644 index bc4adad..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/29.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/29.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/29.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/30.png b/port_src/core/src/test/resources/blackbox/qrcode-4/30.png deleted file mode 100644 index bcef3ad..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/30.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/30.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/30.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/31.png b/port_src/core/src/test/resources/blackbox/qrcode-4/31.png deleted file mode 100644 index bb2f55a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/31.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/31.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/31.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/32.png b/port_src/core/src/test/resources/blackbox/qrcode-4/32.png deleted file mode 100644 index 1203c16..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/32.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/32.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/32.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/33.png b/port_src/core/src/test/resources/blackbox/qrcode-4/33.png deleted file mode 100644 index ed103fa..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/33.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/33.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/33.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/33.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/34.png b/port_src/core/src/test/resources/blackbox/qrcode-4/34.png deleted file mode 100644 index 8591a93..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/34.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/34.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/34.txt deleted file mode 100644 index 1469db2..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/34.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/35.png b/port_src/core/src/test/resources/blackbox/qrcode-4/35.png deleted file mode 100644 index ca31d89..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/35.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/35.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/35.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/36.png b/port_src/core/src/test/resources/blackbox/qrcode-4/36.png deleted file mode 100644 index 19056ff..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/36.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/36.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/36.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/36.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/37.png b/port_src/core/src/test/resources/blackbox/qrcode-4/37.png deleted file mode 100644 index a68653a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/37.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/37.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/37.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/37.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/38.png b/port_src/core/src/test/resources/blackbox/qrcode-4/38.png deleted file mode 100644 index d243afe..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/38.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/38.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/38.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/38.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/39.png b/port_src/core/src/test/resources/blackbox/qrcode-4/39.png deleted file mode 100644 index 4b35768..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/39.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/39.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/39.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/39.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/40.png b/port_src/core/src/test/resources/blackbox/qrcode-4/40.png deleted file mode 100644 index 1511411..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/40.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/40.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/40.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/40.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/41.png b/port_src/core/src/test/resources/blackbox/qrcode-4/41.png deleted file mode 100644 index 5de6d84..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/41.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/41.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/41.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/41.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/42.png b/port_src/core/src/test/resources/blackbox/qrcode-4/42.png deleted file mode 100644 index fcdbf1a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/42.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/42.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/42.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/42.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/43.png b/port_src/core/src/test/resources/blackbox/qrcode-4/43.png deleted file mode 100644 index 798dbe8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/43.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/43.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/43.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/43.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/44.png b/port_src/core/src/test/resources/blackbox/qrcode-4/44.png deleted file mode 100644 index d060a16..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/44.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/44.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/44.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/44.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/45.png b/port_src/core/src/test/resources/blackbox/qrcode-4/45.png deleted file mode 100644 index 8e389ad..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/45.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/45.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/45.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/45.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/46.png b/port_src/core/src/test/resources/blackbox/qrcode-4/46.png deleted file mode 100644 index 57313f0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/46.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/46.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/46.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/46.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/47.png b/port_src/core/src/test/resources/blackbox/qrcode-4/47.png deleted file mode 100644 index 65cd1b7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/47.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/47.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/47.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/47.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/48.png b/port_src/core/src/test/resources/blackbox/qrcode-4/48.png deleted file mode 100644 index e6b2cfc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-4/48.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-4/48.txt b/port_src/core/src/test/resources/blackbox/qrcode-4/48.txt deleted file mode 100644 index 41872c8..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-4/48.txt +++ /dev/null @@ -1 +0,0 @@ -http://code.google.com/p/zxing/ \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/01.png b/port_src/core/src/test/resources/blackbox/qrcode-5/01.png deleted file mode 100644 index 98957e6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/01.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/01.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/01.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/02.png b/port_src/core/src/test/resources/blackbox/qrcode-5/02.png deleted file mode 100644 index ca77f8e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/02.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/02.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/02.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/03.png b/port_src/core/src/test/resources/blackbox/qrcode-5/03.png deleted file mode 100644 index e5e468a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/03.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/03.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/03.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/04.png b/port_src/core/src/test/resources/blackbox/qrcode-5/04.png deleted file mode 100644 index efc4d8f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/04.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/04.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/04.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/05.png b/port_src/core/src/test/resources/blackbox/qrcode-5/05.png deleted file mode 100644 index 34ca8c5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/05.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/05.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/05.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/06.png b/port_src/core/src/test/resources/blackbox/qrcode-5/06.png deleted file mode 100644 index 993d417..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/06.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/06.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/06.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/07.png b/port_src/core/src/test/resources/blackbox/qrcode-5/07.png deleted file mode 100644 index 2be78b6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/07.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/07.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/07.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/08.png b/port_src/core/src/test/resources/blackbox/qrcode-5/08.png deleted file mode 100644 index 77f8e24..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/08.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/08.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/08.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/09.png b/port_src/core/src/test/resources/blackbox/qrcode-5/09.png deleted file mode 100644 index 1d3eee5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/09.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/09.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/09.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/10.png b/port_src/core/src/test/resources/blackbox/qrcode-5/10.png deleted file mode 100644 index 8f1b71a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/10.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/10.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/10.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/11.png b/port_src/core/src/test/resources/blackbox/qrcode-5/11.png deleted file mode 100644 index 79d403f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/11.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/11.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/11.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/12.png b/port_src/core/src/test/resources/blackbox/qrcode-5/12.png deleted file mode 100644 index 75758fd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/12.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/12.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/12.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/13.png b/port_src/core/src/test/resources/blackbox/qrcode-5/13.png deleted file mode 100644 index ea965f7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/13.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/13.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/13.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/14.png b/port_src/core/src/test/resources/blackbox/qrcode-5/14.png deleted file mode 100644 index 011b4e1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/14.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/14.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/14.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/15.png b/port_src/core/src/test/resources/blackbox/qrcode-5/15.png deleted file mode 100644 index a6d4ddc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/15.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/15.txt deleted file mode 100644 index 424f852..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/15.txt +++ /dev/null @@ -1 +0,0 @@ -MECARD:N:Sean Owen;TEL:+12125658770;EMAIL:srowen@google.com;; \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/16.png b/port_src/core/src/test/resources/blackbox/qrcode-5/16.png deleted file mode 100644 index ceabbad..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/16.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/16.txt deleted file mode 100644 index 7175d7a..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/16.txt +++ /dev/null @@ -1,57 +0,0 @@ -THROUGH THE LOOKING-GLASS - -By Lewis Carroll - - -CHAPTER I. Looking-Glass house - -One thing was certain, that the WHITE kitten had had nothing to do with -it:--it was the black kitten's fault entirely. For the white kitten had -been having its face washed by the old cat for the last quarter of -an hour (and bearing it pretty well, considering); so you see that it -COULDN'T have had any hand in the mischief. - -The way Dinah washed her children's faces was this: first she held the -poor thing down by its ear with one paw, and then with the other paw she -rubbed its face all over, the wrong way, beginning at the nose: and -just now, as I said, she was hard at work on the white kitten, which was -lying quite still and trying to purr--no doubt feeling that it was all -meant for its good. - -But the black kitten had been finished with earlier in the afternoon, -and so, while Alice was sitting curled up in a corner of the great -arm-chair, half talking to herself and half asleep, the kitten had been -having a grand game of romps with the ball of worsted Alice had been -trying to wind up, and had been rolling it up and down till it had all -come undone again; and there it was, spread over the hearth-rug, all -knots and tangles, with the kitten running after its own tail in the -middle. - -'Oh, you wicked little thing!' cried Alice, catching up the kitten, and -giving it a little kiss to make it understand that it was in disgrace. -'Really, Dinah ought to have taught you better manners! You OUGHT, -Dinah, you know you ought!' she added, looking reproachfully at the old -cat, and speaking in as cross a voice as she could manage--and then she -scrambled back into the arm-chair, taking the kitten and the worsted -with her, and began winding up the ball again. But she didn't get on -very fast, as she was talking all the time, sometimes to the kitten, and -sometimes to herself. Kitty sat very demurely on her knee, pretending to -watch the progress of the winding, and now and then putting out one -paw and gently touching the ball, as if it would be glad to help, if it -might. - -'Do you know what to-morrow is, Kitty?' Alice began. 'You'd have guessed -if you'd been up in the window with me--only Dinah was making you tidy, -so you couldn't. I was watching the boys getting in sticks for the -bonfire--and it wants plenty of sticks, Kitty! Only it got so cold, and -it snowed so, they had to leave off. Never mind, Kitty, we'll go and -see the bonfire to-morrow.' Here Alice wound two or three turns of the -worsted round the kitten's neck, just to see how it would look: this led -to a scramble, in which the ball rolled down upon the floor, and yards -and yards of it got unwound again. - -'Do you know, I was so angry, Kitty,' Alice went on as soon as they were -comfortably settled again, 'when I saw all the mischief you had been -doing, I was very nearly opening the window, and putting you out into -the snow! And you'd have deserved it, you little mischievous darling! -Wha diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/17.png b/port_src/core/src/test/resources/blackbox/qrcode-5/17.png deleted file mode 100644 index 8446be0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/17.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/17.txt deleted file mode 100644 index 967a10b..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/17.txt +++ /dev/null @@ -1,46 +0,0 @@ -THROUGH THE LOOKING-GLASS - -By Lewis Carroll - - -CHAPTER I. Looking-Glass house - -One thing was certain, that the WHITE kitten had had nothing to do with -it:--it was the black kitten's fault entirely. For the white kitten had -been having its face washed by the old cat for the last quarter of -an hour (and bearing it pretty well, considering); so you see that it -COULDN'T have had any hand in the mischief. - -The way Dinah washed her children's faces was this: first she held the -poor thing down by its ear with one paw, and then with the other paw she -rubbed its face all over, the wrong way, beginning at the nose: and -just now, as I said, she was hard at work on the white kitten, which was -lying quite still and trying to purr--no doubt feeling that it was all -meant for its good. - -But the black kitten had been finished with earlier in the afternoon, -and so, while Alice was sitting curled up in a corner of the great -arm-chair, half talking to herself and half asleep, the kitten had been -having a grand game of romps with the ball of worsted Alice had been -trying to wind up, and had been rolling it up and down till it had all -come undone again; and there it was, spread over the hearth-rug, all -knots and tangles, with the kitten running after its own tail in the -middle. - -'Oh, you wicked little thing!' cried Alice, catching up the kitten, and -giving it a little kiss to make it understand that it was in disgrace. -'Really, Dinah ought to have taught you better manners! You OUGHT, -Dinah, you know you ought!' she added, looking reproachfully at the old -cat, and speaking in as cross a voice as she could manage--and then she -scrambled back into the arm-chair, taking the kitten and the worsted -with her, and began winding up the ball again. But she didn't get on -very fast, as she was talking all the time, sometimes to the kitten, and -sometimes to herself. Kitty sat very demurely on her knee, pretending to -watch the progress of the winding, and now and then putting out one -paw and gently touching the ball, as if it would be glad to help, if it -might. - -'Do you know what to-morrow is, Kitty?' Alice began. 'You'd have guessed -if you'd been up in the window with me--only Dinah was making you tidy, -so you couldn't. I was watching the boys getting in sticks for the -bonfire--and it wants plenty of sticks, Kitty! Only it diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/18.png b/port_src/core/src/test/resources/blackbox/qrcode-5/18.png deleted file mode 100644 index a52cb39..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/18.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/18.txt deleted file mode 100644 index 863b77f..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/18.txt +++ /dev/null @@ -1,36 +0,0 @@ -THROUGH THE LOOKING-GLASS - -By Lewis Carroll - - -CHAPTER I. Looking-Glass house - -One thing was certain, that the WHITE kitten had had nothing to do with -it:--it was the black kitten's fault entirely. For the white kitten had -been having its face washed by the old cat for the last quarter of -an hour (and bearing it pretty well, considering); so you see that it -COULDN'T have had any hand in the mischief. - -The way Dinah washed her children's faces was this: first she held the -poor thing down by its ear with one paw, and then with the other paw she -rubbed its face all over, the wrong way, beginning at the nose: and -just now, as I said, she was hard at work on the white kitten, which was -lying quite still and trying to purr--no doubt feeling that it was all -meant for its good. - -But the black kitten had been finished with earlier in the afternoon, -and so, while Alice was sitting curled up in a corner of the great -arm-chair, half talking to herself and half asleep, the kitten had been -having a grand game of romps with the ball of worsted Alice had been -trying to wind up, and had been rolling it up and down till it had all -come undone again; and there it was, spread over the hearth-rug, all -knots and tangles, with the kitten running after its own tail in the -middle. - -'Oh, you wicked little thing!' cried Alice, catching up the kitten, and -giving it a little kiss to make it understand that it was in disgrace. -'Really, Dinah ought to have taught you better manners! You OUGHT, -Dinah, you know you ought!' she added, looking reproachfully at the old -cat, and speaking in as cross a voice as she could manage--and then she -scrambled back into the arm-ch - diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/19.png b/port_src/core/src/test/resources/blackbox/qrcode-5/19.png deleted file mode 100644 index 4ed10c6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-5/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-5/19.txt b/port_src/core/src/test/resources/blackbox/qrcode-5/19.txt deleted file mode 100644 index 845cd05..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-5/19.txt +++ /dev/null @@ -1,28 +0,0 @@ -THROUGH THE LOOKING-GLASS - -By Lewis Carroll - - -CHAPTER I. Looking-Glass house - -One thing was certain, that the WHITE kitten had had nothing to do with -it:--it was the black kitten's fault entirely. For the white kitten had -been having its face washed by the old cat for the last quarter of -an hour (and bearing it pretty well, considering); so you see that it -COULDN'T have had any hand in the mischief. - -The way Dinah washed her children's faces was this: first she held the -poor thing down by its ear with one paw, and then with the other paw she -rubbed its face all over, the wrong way, beginning at the nose: and -just now, as I said, she was hard at work on the white kitten, which was -lying quite still and trying to purr--no doubt feeling that it was all -meant for its good. - -But the black kitten had been finished with earlier in the afternoon, -and so, while Alice was sitting curled up in a corner of the great -arm-chair, half talking to herself and half asleep, the kitten had been -having a grand game of romps with the ball of worsted Alice had been -trying to wind up, and had been rolling it up and down till it had all -come undone again; and there it was, spread over the hearth-rug, all -knots and tangles, with the kitten running after its own tail in the -midd diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/1.metadata.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/1.metadata.txt deleted file mode 100644 index 6f6e83d..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/1.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]Q1 diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/1.png b/port_src/core/src/test/resources/blackbox/qrcode-6/1.png deleted file mode 100755 index 295e792..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/1.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/1.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/1.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/10.png b/port_src/core/src/test/resources/blackbox/qrcode-6/10.png deleted file mode 100755 index 1bc5261..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/10.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/10.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/10.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/11.png b/port_src/core/src/test/resources/blackbox/qrcode-6/11.png deleted file mode 100755 index 5c6039b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/11.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/11.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/11.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/12.png b/port_src/core/src/test/resources/blackbox/qrcode-6/12.png deleted file mode 100755 index 9f315b1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/12.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/12.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/12.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/13.png b/port_src/core/src/test/resources/blackbox/qrcode-6/13.png deleted file mode 100755 index 3e0523a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/13.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/13.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/13.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/14.png b/port_src/core/src/test/resources/blackbox/qrcode-6/14.png deleted file mode 100755 index 44e312d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/14.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/14.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/14.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/15.png b/port_src/core/src/test/resources/blackbox/qrcode-6/15.png deleted file mode 100644 index 2ec4ec5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/15.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/15.txt deleted file mode 100644 index 3b12464..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/15.txt +++ /dev/null @@ -1 +0,0 @@ -TEST \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/2.png b/port_src/core/src/test/resources/blackbox/qrcode-6/2.png deleted file mode 100755 index b573832..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/2.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/2.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/2.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/3.png b/port_src/core/src/test/resources/blackbox/qrcode-6/3.png deleted file mode 100755 index e4d7f8b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/3.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/3.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/3.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/4.png b/port_src/core/src/test/resources/blackbox/qrcode-6/4.png deleted file mode 100755 index 458823b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/4.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/4.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/4.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/5.png b/port_src/core/src/test/resources/blackbox/qrcode-6/5.png deleted file mode 100755 index baf5814..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/5.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/5.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/5.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/6.png b/port_src/core/src/test/resources/blackbox/qrcode-6/6.png deleted file mode 100755 index d4289e7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/6.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/6.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/6.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/7.png b/port_src/core/src/test/resources/blackbox/qrcode-6/7.png deleted file mode 100755 index c4c602d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/7.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/7.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/7.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/7.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/8.png b/port_src/core/src/test/resources/blackbox/qrcode-6/8.png deleted file mode 100755 index 2619be2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/8.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/8.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/8.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/9.png b/port_src/core/src/test/resources/blackbox/qrcode-6/9.png deleted file mode 100755 index 174e36d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/qrcode-6/9.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/qrcode-6/9.txt b/port_src/core/src/test/resources/blackbox/qrcode-6/9.txt deleted file mode 100644 index 6a537b5..0000000 --- a/port_src/core/src/test/resources/blackbox/qrcode-6/9.txt +++ /dev/null @@ -1 +0,0 @@ -1234567890 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/1.metadata.txt b/port_src/core/src/test/resources/blackbox/rss14-1/1.metadata.txt deleted file mode 100644 index 3630d2c..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-1/1.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SYMBOLOGY_IDENTIFIER=]e0 diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/1.png b/port_src/core/src/test/resources/blackbox/rss14-1/1.png deleted file mode 100644 index 55b2905..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/1.txt b/port_src/core/src/test/resources/blackbox/rss14-1/1.txt deleted file mode 100644 index da8b2e7..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -04412345678909 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/2.png b/port_src/core/src/test/resources/blackbox/rss14-1/2.png deleted file mode 100644 index c286f91..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/2.txt b/port_src/core/src/test/resources/blackbox/rss14-1/2.txt deleted file mode 100644 index 6a694e3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-1/2.txt +++ /dev/null @@ -1 +0,0 @@ -00821935106427 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/3.png b/port_src/core/src/test/resources/blackbox/rss14-1/3.png deleted file mode 100644 index 2a2f812..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-1/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/3.txt b/port_src/core/src/test/resources/blackbox/rss14-1/3.txt deleted file mode 100644 index accc36e..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-1/3.txt +++ /dev/null @@ -1 +0,0 @@ -00075678164125 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/4.png b/port_src/core/src/test/resources/blackbox/rss14-1/4.png deleted file mode 100644 index e9ee653..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-1/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/4.txt b/port_src/core/src/test/resources/blackbox/rss14-1/4.txt deleted file mode 100644 index b8d2ea4..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-1/4.txt +++ /dev/null @@ -1 +0,0 @@ -20012345678909 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/5.png b/port_src/core/src/test/resources/blackbox/rss14-1/5.png deleted file mode 100644 index 46c29f9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-1/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/5.txt b/port_src/core/src/test/resources/blackbox/rss14-1/5.txt deleted file mode 100644 index 50109f5..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-1/5.txt +++ /dev/null @@ -1 +0,0 @@ -00034567890125 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/6.png b/port_src/core/src/test/resources/blackbox/rss14-1/6.png deleted file mode 100644 index e7b4c47..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-1/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-1/6.txt b/port_src/core/src/test/resources/blackbox/rss14-1/6.txt deleted file mode 100644 index eabb743..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-1/6.txt +++ /dev/null @@ -1 +0,0 @@ -00012345678905 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/1.png b/port_src/core/src/test/resources/blackbox/rss14-2/1.png deleted file mode 100755 index d2033e8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/1.txt b/port_src/core/src/test/resources/blackbox/rss14-2/1.txt deleted file mode 100644 index da8b2e7..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/1.txt +++ /dev/null @@ -1 +0,0 @@ -04412345678909 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/10.png b/port_src/core/src/test/resources/blackbox/rss14-2/10.png deleted file mode 100755 index a2a7b03..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/10.txt b/port_src/core/src/test/resources/blackbox/rss14-2/10.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/10.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/11.png b/port_src/core/src/test/resources/blackbox/rss14-2/11.png deleted file mode 100755 index 149cfec..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/11.txt b/port_src/core/src/test/resources/blackbox/rss14-2/11.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/11.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/12.png b/port_src/core/src/test/resources/blackbox/rss14-2/12.png deleted file mode 100755 index b007039..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/12.txt b/port_src/core/src/test/resources/blackbox/rss14-2/12.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/12.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/13.png b/port_src/core/src/test/resources/blackbox/rss14-2/13.png deleted file mode 100755 index c2306f3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/13.txt b/port_src/core/src/test/resources/blackbox/rss14-2/13.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/13.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/14.png b/port_src/core/src/test/resources/blackbox/rss14-2/14.png deleted file mode 100755 index 4a9dea6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/14.txt b/port_src/core/src/test/resources/blackbox/rss14-2/14.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/14.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/15.png b/port_src/core/src/test/resources/blackbox/rss14-2/15.png deleted file mode 100755 index a0f8e64..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/15.txt b/port_src/core/src/test/resources/blackbox/rss14-2/15.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/15.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/16.png b/port_src/core/src/test/resources/blackbox/rss14-2/16.png deleted file mode 100755 index e919782..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/16.txt b/port_src/core/src/test/resources/blackbox/rss14-2/16.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/16.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/17.png b/port_src/core/src/test/resources/blackbox/rss14-2/17.png deleted file mode 100755 index b2e7e8f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/17.txt b/port_src/core/src/test/resources/blackbox/rss14-2/17.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/17.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/18.png b/port_src/core/src/test/resources/blackbox/rss14-2/18.png deleted file mode 100755 index 76a5599..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/18.txt b/port_src/core/src/test/resources/blackbox/rss14-2/18.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/18.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/19.png b/port_src/core/src/test/resources/blackbox/rss14-2/19.png deleted file mode 100755 index c2408e1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/19.txt b/port_src/core/src/test/resources/blackbox/rss14-2/19.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/19.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/2.png b/port_src/core/src/test/resources/blackbox/rss14-2/2.png deleted file mode 100755 index 7b348da..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/2.txt b/port_src/core/src/test/resources/blackbox/rss14-2/2.txt deleted file mode 100644 index da8b2e7..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/2.txt +++ /dev/null @@ -1 +0,0 @@ -04412345678909 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/20.png b/port_src/core/src/test/resources/blackbox/rss14-2/20.png deleted file mode 100755 index 6075a07..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/20.txt b/port_src/core/src/test/resources/blackbox/rss14-2/20.txt deleted file mode 100644 index eabb743..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/20.txt +++ /dev/null @@ -1 +0,0 @@ -00012345678905 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/21.png b/port_src/core/src/test/resources/blackbox/rss14-2/21.png deleted file mode 100755 index afbb277..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/21.txt b/port_src/core/src/test/resources/blackbox/rss14-2/21.txt deleted file mode 100644 index eabb743..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/21.txt +++ /dev/null @@ -1 +0,0 @@ -00012345678905 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/22.png b/port_src/core/src/test/resources/blackbox/rss14-2/22.png deleted file mode 100755 index 15afdf8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/22.txt b/port_src/core/src/test/resources/blackbox/rss14-2/22.txt deleted file mode 100644 index eabb743..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/22.txt +++ /dev/null @@ -1 +0,0 @@ -00012345678905 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/23.png b/port_src/core/src/test/resources/blackbox/rss14-2/23.png deleted file mode 100755 index 4dbfeba..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/23.txt b/port_src/core/src/test/resources/blackbox/rss14-2/23.txt deleted file mode 100644 index eabb743..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/23.txt +++ /dev/null @@ -1 +0,0 @@ -00012345678905 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/24.png b/port_src/core/src/test/resources/blackbox/rss14-2/24.png deleted file mode 100755 index 469e37c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/24.txt b/port_src/core/src/test/resources/blackbox/rss14-2/24.txt deleted file mode 100644 index eabb743..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/24.txt +++ /dev/null @@ -1 +0,0 @@ -00012345678905 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/3.png b/port_src/core/src/test/resources/blackbox/rss14-2/3.png deleted file mode 100755 index badf6d5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/3.txt b/port_src/core/src/test/resources/blackbox/rss14-2/3.txt deleted file mode 100644 index da8b2e7..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/3.txt +++ /dev/null @@ -1 +0,0 @@ -04412345678909 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/4.png b/port_src/core/src/test/resources/blackbox/rss14-2/4.png deleted file mode 100755 index 47028a6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/4.txt b/port_src/core/src/test/resources/blackbox/rss14-2/4.txt deleted file mode 100644 index da8b2e7..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/4.txt +++ /dev/null @@ -1 +0,0 @@ -04412345678909 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/5.png b/port_src/core/src/test/resources/blackbox/rss14-2/5.png deleted file mode 100755 index eb5287a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/5.txt b/port_src/core/src/test/resources/blackbox/rss14-2/5.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/5.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/6.png b/port_src/core/src/test/resources/blackbox/rss14-2/6.png deleted file mode 100755 index 70051bd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/6.txt b/port_src/core/src/test/resources/blackbox/rss14-2/6.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/6.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/7.png b/port_src/core/src/test/resources/blackbox/rss14-2/7.png deleted file mode 100755 index 8f5d9f8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/7.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/7.txt b/port_src/core/src/test/resources/blackbox/rss14-2/7.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/7.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/8.png b/port_src/core/src/test/resources/blackbox/rss14-2/8.png deleted file mode 100755 index 0412c1c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/8.txt b/port_src/core/src/test/resources/blackbox/rss14-2/8.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/8.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/9.png b/port_src/core/src/test/resources/blackbox/rss14-2/9.png deleted file mode 100755 index 7f169ca..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rss14-2/9.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rss14-2/9.txt b/port_src/core/src/test/resources/blackbox/rss14-2/9.txt deleted file mode 100644 index adb4ff3..0000000 --- a/port_src/core/src/test/resources/blackbox/rss14-2/9.txt +++ /dev/null @@ -1 +0,0 @@ -02001234567893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/1.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/1.png deleted file mode 100644 index 51f66d8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/1.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/1.txt deleted file mode 100644 index 8b369b3..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -(11)100224(17)110224(3102)000100 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/10.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/10.png deleted file mode 100644 index 7b75027..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/10.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/10.txt deleted file mode 100644 index 09d4208..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/10.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)012345678901 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/11.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/11.png deleted file mode 100644 index 9c142a1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/11.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/11.txt deleted file mode 100644 index abe2a81..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/11.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/12.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/12.png deleted file mode 100644 index 1841ee5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/12.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/12.txt deleted file mode 100644 index 32ad2da..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/12.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(3103)001750 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/13.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/13.png deleted file mode 100644 index 79b9398..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/13.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/13.txt deleted file mode 100644 index dd36aab..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/13.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3922)795 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/14.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/14.png deleted file mode 100644 index 97a42de..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/14.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/14.txt deleted file mode 100644 index fb00e31..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/14.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3932)0401234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/15.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/15.png deleted file mode 100644 index 3acd716..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/15.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/15.txt deleted file mode 100644 index f2bfc4b..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/15.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3102)001750(11)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/16.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/16.png deleted file mode 100644 index ce53c59..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/16.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/16.txt deleted file mode 100644 index c9f248d..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/16.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)001750(11)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/17.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/17.png deleted file mode 100644 index d2d127f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/17.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/17.txt deleted file mode 100644 index 9b4fc49..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/17.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3102)001750(13)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/18.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/18.png deleted file mode 100644 index 74c7521..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/18.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/18.txt deleted file mode 100644 index cd15aa0..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/18.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)001750(13)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/19.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/19.png deleted file mode 100644 index 6602780..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/19.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/19.txt deleted file mode 100644 index dcd1561..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/19.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3102)001750(15)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/2.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/2.png deleted file mode 100644 index acc6753..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/2.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/2.txt deleted file mode 100644 index b4113ac..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/2.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3103)001750 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/20.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/20.png deleted file mode 100644 index a4171e2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/20.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/20.txt deleted file mode 100644 index 830845f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/20.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)001750(15)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/21.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/21.png deleted file mode 100644 index 32afeb7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/21.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/21.txt deleted file mode 100644 index 506b17b..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/21.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3102)001750(17)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/22.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/22.png deleted file mode 100644 index 34f7588..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/22.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/22.txt deleted file mode 100644 index ca6045a..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/22.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)001750(17)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/23.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/23.png deleted file mode 100644 index 4032f51..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/23.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/23.txt deleted file mode 100644 index a6f7e24..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/23.txt +++ /dev/null @@ -1 +0,0 @@ -(10)56789(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/24.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/24.png deleted file mode 100644 index 846a4f3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/24.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/24.txt deleted file mode 100644 index a7b3497..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/24.txt +++ /dev/null @@ -1 +0,0 @@ -(10)567890(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/25.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/25.png deleted file mode 100644 index 1b93c2d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/25.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/25.txt deleted file mode 100644 index 62c17f1..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/25.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/26.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/26.png deleted file mode 100644 index 9beca4c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/26.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/26.txt deleted file mode 100644 index 17966ee..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/26.txt +++ /dev/null @@ -1 +0,0 @@ -(10)5678(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/27.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/27.png deleted file mode 100644 index 0a1b491..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/27.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/27.txt deleted file mode 100644 index 5263f7f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/27.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098-1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/28.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/28.png deleted file mode 100644 index 3079c03..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/28.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/28.txt deleted file mode 100644 index 9208d92..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/28.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098/1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/29.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/29.png deleted file mode 100644 index 0bfb742..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/29.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/29.txt deleted file mode 100644 index b78623a..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/29.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098.1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/3.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/3.png deleted file mode 100644 index b78843b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/3.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/3.txt deleted file mode 100644 index 4c3769f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/3.txt +++ /dev/null @@ -1 +0,0 @@ -(10)12A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/30.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/30.png deleted file mode 100644 index 6427feb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/30.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/30.txt deleted file mode 100644 index 82bfa6a..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/30.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098*1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/31.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/31.png deleted file mode 100644 index 743f1fa..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/31.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/31.txt deleted file mode 100644 index f6413d5..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/31.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098,1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/32.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/32.png deleted file mode 100644 index bfedb3b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/32.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/32.txt deleted file mode 100644 index 5e76631..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/32.txt +++ /dev/null @@ -1 +0,0 @@ -(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/4.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/4.png deleted file mode 100644 index 5f69ce2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/4.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/4.txt deleted file mode 100644 index 4e8655c..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/4.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(3202)012345(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/5.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/5.png deleted file mode 100644 index 14e227a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/5.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/5.txt deleted file mode 100644 index 4a70860..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/5.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90614141000015(3202)000150 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/6.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/6.png deleted file mode 100644 index a8a71ff..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/6.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/6.txt deleted file mode 100644 index 84f8807..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/6.txt +++ /dev/null @@ -1 +0,0 @@ -(10)567(01)90012345678908(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/7.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/7.png deleted file mode 100644 index 4561ad7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/7.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/7.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/7.txt deleted file mode 100644 index e8c7268..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/7.txt +++ /dev/null @@ -1 +0,0 @@ -(10)567(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/8.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/8.png deleted file mode 100644 index d3cf3ec..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/8.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/8.txt deleted file mode 100644 index 56981cd..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/8.txt +++ /dev/null @@ -1 +0,0 @@ -(10)567(11)010101(13)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/9.png b/port_src/core/src/test/resources/blackbox/rssexpanded-1/9.png deleted file mode 100644 index f6491ef..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-1/9.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-1/9.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-1/9.txt deleted file mode 100644 index 84cf63c..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-1/9.txt +++ /dev/null @@ -1 +0,0 @@ -(10)567(3102)123456 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/12.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/12.png deleted file mode 100644 index a1427a7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/12.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/12.txt deleted file mode 100644 index 32ad2da..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/12.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(3103)001750 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/13.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/13.png deleted file mode 100644 index 89e3347..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/13.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/13.txt deleted file mode 100644 index dd36aab..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/13.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3922)795 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/16.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/16.png deleted file mode 100644 index 4f46840..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/16.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/16.txt deleted file mode 100644 index c9f248d..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/16.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)001750(11)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/17.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/17.png deleted file mode 100644 index 2db6061..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/17.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/17.txt deleted file mode 100644 index 9b4fc49..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/17.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3102)001750(13)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/18.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/18.png deleted file mode 100644 index 9a65044..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/18.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/18.txt deleted file mode 100644 index cd15aa0..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/18.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)001750(13)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/18b.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/18b.png deleted file mode 100644 index 0c84454..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/18b.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/18b.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/18b.txt deleted file mode 100644 index cd15aa0..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/18b.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)001750(13)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/19.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/19.png deleted file mode 100644 index 0a028ab..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/19.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/19.txt deleted file mode 100644 index dcd1561..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/19.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3102)001750(15)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/21.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/21.png deleted file mode 100644 index 13c9695..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/21.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/21.txt deleted file mode 100644 index 506b17b..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/21.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3102)001750(17)100312 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_01.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_01.png deleted file mode 100644 index 927b956..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_01.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_01.txt deleted file mode 100644 index 4c3769f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_01.txt +++ /dev/null @@ -1 +0,0 @@ -(10)12A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_02.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_02.png deleted file mode 100644 index 87ae281..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_02.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_02.txt deleted file mode 100644 index 4c3769f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_02.txt +++ /dev/null @@ -1 +0,0 @@ -(10)12A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_03.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_03.png deleted file mode 100644 index 1ff07d7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_03.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_03.txt deleted file mode 100644 index 4c3769f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_03.txt +++ /dev/null @@ -1 +0,0 @@ -(10)12A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_04.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_04.png deleted file mode 100644 index a5595ed..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_04.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_04.txt deleted file mode 100644 index 4c3769f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_04.txt +++ /dev/null @@ -1 +0,0 @@ -(10)12A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_05.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_05.png deleted file mode 100644 index 189d10e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_05.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_05.txt deleted file mode 100644 index 4c3769f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_05.txt +++ /dev/null @@ -1 +0,0 @@ -(10)12A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_06.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_06.png deleted file mode 100644 index dabd86a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_06.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_06.txt deleted file mode 100644 index 4c3769f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_06.txt +++ /dev/null @@ -1 +0,0 @@ -(10)12A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_07.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_07.png deleted file mode 100644 index 26ec765..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_07.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_07.txt deleted file mode 100644 index 4c3769f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_07.txt +++ /dev/null @@ -1 +0,0 @@ -(10)12A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_09.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_09.png deleted file mode 100644 index ee9eb52..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_09.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_09.txt deleted file mode 100644 index 4c3769f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/3_09.txt +++ /dev/null @@ -1 +0,0 @@ -(10)12A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_00.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_00.png deleted file mode 100644 index d426a0a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_00.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_00.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_00.txt deleted file mode 100644 index 4e8655c..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_00.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(3202)012345(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_01.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_01.png deleted file mode 100644 index d176e1d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_01.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_01.txt deleted file mode 100644 index 4e8655c..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_01.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(3202)012345(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_02.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_02.png deleted file mode 100644 index 4b5f5c3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_02.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_02.txt deleted file mode 100644 index 4e8655c..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_02.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(3202)012345(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_03.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_03.png deleted file mode 100644 index 6a008b7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_03.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_03.txt deleted file mode 100644 index 4e8655c..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_03.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(3202)012345(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_04.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_04.png deleted file mode 100644 index a780e9b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_04.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_04.txt deleted file mode 100644 index 4e8655c..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_04.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(3202)012345(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_05.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_05.png deleted file mode 100644 index 9acd7db..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_05.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_05.txt deleted file mode 100644 index 4e8655c..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/4_05.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(3202)012345(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/5.png b/port_src/core/src/test/resources/blackbox/rssexpanded-2/5.png deleted file mode 100644 index 72c9e3b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-2/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-2/5.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-2/5.txt deleted file mode 100644 index 4a70860..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-2/5.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90614141000015(3202)000150 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/1.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/1.png deleted file mode 100644 index d8099a4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/1.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/1.txt deleted file mode 100644 index ed31c4d..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/1.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3103)012233(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/10.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/10.png deleted file mode 100644 index 2c241ba..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/10.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/10.txt deleted file mode 100644 index e8f98fe..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/10.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3203)010000 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/100.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/100.png deleted file mode 100644 index 82bb8b9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/100.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/100.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/100.txt deleted file mode 100644 index 4339de9..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/100.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098 1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/101.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/101.png deleted file mode 100644 index a66894c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/101.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/101.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/101.txt deleted file mode 100644 index 6f63fb0..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/101.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/102.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/102.png deleted file mode 100644 index 72d8e36..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/102.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/102.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/102.txt deleted file mode 100644 index 5c1b912..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/102.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A1 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/103.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/103.png deleted file mode 100644 index d829e85..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/103.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/103.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/103.txt deleted file mode 100644 index d77a476..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/103.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/104.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/104.png deleted file mode 100644 index 152f5dd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/104.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/104.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/104.txt deleted file mode 100644 index 2e2ec43..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/104.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/105.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/105.png deleted file mode 100644 index a2cf18f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/105.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/105.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/105.txt deleted file mode 100644 index b607d14..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/105.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A1234A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/106.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/106.png deleted file mode 100644 index 33af0cf..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/106.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/106.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/106.txt deleted file mode 100644 index 389adca..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/106.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A123456 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/107.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/107.png deleted file mode 100644 index d87581b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/107.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/107.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/107.txt deleted file mode 100644 index fffde5d..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/107.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A12345678 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/108.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/108.png deleted file mode 100644 index c4bfab6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/108.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/108.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/108.txt deleted file mode 100644 index 1ad0fbd..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/108.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A1234A(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/109.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/109.png deleted file mode 100644 index 99e9e70..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/109.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/109.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/109.txt deleted file mode 100644 index ac79617..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/109.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1ABCDEF;:/1234567 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/11.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/11.png deleted file mode 100644 index c85138d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/11.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/11.txt deleted file mode 100644 index 9895a67..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/11.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3203)032767 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/110.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/110.png deleted file mode 100644 index 6c35a4a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/110.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/110.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/110.txt deleted file mode 100644 index 163b64b..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/110.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1ABCDEF;:/ABCDEFG \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/111.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/111.png deleted file mode 100644 index dc8e829..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/111.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/111.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/111.txt deleted file mode 100644 index d359328..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/111.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1;:/ABCDEFGHIJKLM \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/112.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/112.png deleted file mode 100644 index cafb665..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/112.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/112.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/112.txt deleted file mode 100644 index c25e84f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/112.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1;:/0123456789012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/113.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/113.png deleted file mode 100644 index 25f428b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/113.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/113.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/113.txt deleted file mode 100644 index 2914766..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/113.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1;:/0123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/114.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/114.png deleted file mode 100644 index 12d8942..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/114.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/114.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/114.txt deleted file mode 100644 index c8be9f3..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/114.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1;:/0123(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/115.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/115.png deleted file mode 100644 index 1a89487..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/115.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/115.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/115.txt deleted file mode 100644 index 9a1581d..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/115.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/116.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/116.png deleted file mode 100644 index 9df4779..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/116.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/116.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/116.txt deleted file mode 100644 index 4c3769f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/116.txt +++ /dev/null @@ -1 +0,0 @@ -(10)12A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/117.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/117.png deleted file mode 100644 index 1b93c2d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/117.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/117.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/117.txt deleted file mode 100644 index 62c17f1..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/117.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/12.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/12.png deleted file mode 100644 index ea645f8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/12.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/12.txt deleted file mode 100644 index dd36aab..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/12.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3922)795 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/13.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/13.png deleted file mode 100644 index 3a75edc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/13.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/13.txt deleted file mode 100644 index 0429d93..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/13.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3922)795888888888888888888888888888888888888888888888888888 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/14.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/14.png deleted file mode 100644 index a0b3613..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/14.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/14.txt deleted file mode 100644 index fb00e31..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/14.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3932)0401234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/15.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/15.png deleted file mode 100644 index 1e23828..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/15.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/15.txt deleted file mode 100644 index 9066194..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/15.txt +++ /dev/null @@ -1 +0,0 @@ -(01)00012345678905(10)ABC123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/16.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/16.png deleted file mode 100644 index 0a5dca7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/16.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/16.txt deleted file mode 100644 index 8f0841f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/16.txt +++ /dev/null @@ -1 +0,0 @@ -(01)12345678901231(10)UNIVERSITY-OF-DEUSTO \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/17.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/17.png deleted file mode 100644 index 37809c0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/17.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/17.txt deleted file mode 100644 index 89fda98..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/17.txt +++ /dev/null @@ -1 +0,0 @@ -(01)12345678901231(10)PIRAMIDE-PROJECT \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/18.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/18.png deleted file mode 100644 index af317f1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/18.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/18.txt deleted file mode 100644 index b120324..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/18.txt +++ /dev/null @@ -1 +0,0 @@ -(01)12345678901231(10)TREELOGIC \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/19.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/19.png deleted file mode 100644 index 9beca4c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/19.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/19.txt deleted file mode 100644 index 17966ee..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/19.txt +++ /dev/null @@ -1 +0,0 @@ -(10)5678(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/2.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/2.png deleted file mode 100644 index 2331373..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/2.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/2.txt deleted file mode 100644 index d7f0a6a..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/2.txt +++ /dev/null @@ -1 +0,0 @@ -(01)91234567980129(3103)012233(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/20.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/20.png deleted file mode 100644 index 2cf7a1b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/20.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/20.txt deleted file mode 100644 index b948648..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/20.txt +++ /dev/null @@ -1 +0,0 @@ -(10)5678(11)001010 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/21.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/21.png deleted file mode 100644 index 846a4f3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/21.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/21.txt deleted file mode 100644 index a7b3497..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/21.txt +++ /dev/null @@ -1 +0,0 @@ -(10)567890(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/22.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/22.png deleted file mode 100644 index 359f41e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/22.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/22.txt deleted file mode 100644 index e8c7268..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/22.txt +++ /dev/null @@ -1 +0,0 @@ -(10)567(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/23.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/23.png deleted file mode 100644 index 0a1b491..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/23.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/23.txt deleted file mode 100644 index 5263f7f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/23.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098-1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/24.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/24.png deleted file mode 100644 index 743f1fa..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/24.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/24.txt deleted file mode 100644 index f6413d5..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/24.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098,1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/25.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/25.png deleted file mode 100644 index 3079c03..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/25.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/25.txt deleted file mode 100644 index 9208d92..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/25.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098/1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/26.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/26.png deleted file mode 100644 index 0bfb742..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/26.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/26.txt deleted file mode 100644 index b78623a..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/26.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098.1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/27.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/27.png deleted file mode 100644 index 6427feb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/27.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/27.txt deleted file mode 100644 index 82bfa6a..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/27.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098*1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/28.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/28.png deleted file mode 100644 index bf00890..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/28.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/28.txt deleted file mode 100644 index 6263d99..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/28.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098a1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/29.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/29.png deleted file mode 100644 index 6988b64..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/29.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/29.txt deleted file mode 100644 index 35fc529..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/29.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098!1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/3.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/3.png deleted file mode 100644 index a6527d7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/3.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/3.txt deleted file mode 100644 index ab93c97..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/3.txt +++ /dev/null @@ -1 +0,0 @@ -(01)91234567980129(3102)012233(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/30.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/30.png deleted file mode 100644 index 25aea80..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/30.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/30.txt deleted file mode 100644 index d0d95d0..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/30.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098"1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/31.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/31.png deleted file mode 100644 index 6fa0755..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/31.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/31.txt deleted file mode 100644 index 53bf781..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/31.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098%1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/32.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/32.png deleted file mode 100644 index 334d1a2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/32.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/32.txt deleted file mode 100644 index 5d1d351..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/32.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098&1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/33.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/33.png deleted file mode 100644 index 803ea0b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/33.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/33.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/33.txt deleted file mode 100644 index f00c6bb..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/33.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098'1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/34.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/34.png deleted file mode 100644 index 3bbc1e8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/34.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/34.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/34.txt deleted file mode 100644 index 18b90ec..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/34.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098+1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/35.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/35.png deleted file mode 100644 index edba7f2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/35.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/35.txt deleted file mode 100644 index 96f9049..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/35.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098:1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/36.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/36.png deleted file mode 100644 index ef1755f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/36.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/36.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/36.txt deleted file mode 100644 index 2dd84d5..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/36.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098;1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/37.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/37.png deleted file mode 100644 index 940fa56..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/37.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/37.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/37.txt deleted file mode 100644 index a64a6db..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/37.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098<1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/38.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/38.png deleted file mode 100644 index 336cd5f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/38.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/38.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/38.txt deleted file mode 100644 index c7cc606..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/38.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098=1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/39.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/39.png deleted file mode 100644 index ca9024c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/39.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/39.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/39.txt deleted file mode 100644 index 7345e4e..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/39.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098>1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/4.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/4.png deleted file mode 100644 index 52e1b5d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/4.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/4.txt deleted file mode 100644 index fca726b..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/4.txt +++ /dev/null @@ -1 +0,0 @@ -(01)91234567980129(3102)012233(15)000101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/40.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/40.png deleted file mode 100644 index 1aefb4c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/40.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/40.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/40.txt deleted file mode 100644 index 5e152de..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/40.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098?1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/41.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/41.png deleted file mode 100644 index d2bece9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/41.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/41.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/41.txt deleted file mode 100644 index aad1b28..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/41.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098_1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/42.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/42.png deleted file mode 100644 index fdbfe03..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/42.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/42.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/42.txt deleted file mode 100644 index 4339de9..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/42.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098 1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/43.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/43.png deleted file mode 100644 index 322a0a5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/43.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/43.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/43.txt deleted file mode 100644 index 6f63fb0..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/43.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/44.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/44.png deleted file mode 100644 index 19cb99c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/44.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/44.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/44.txt deleted file mode 100644 index 2e2ec43..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/44.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/45.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/45.png deleted file mode 100644 index fa8ebe8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/45.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/45.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/45.txt deleted file mode 100644 index b607d14..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/45.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A1234A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/46.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/46.png deleted file mode 100644 index e69a1b1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/46.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/46.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/46.txt deleted file mode 100644 index 389adca..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/46.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A123456 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/47.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/47.png deleted file mode 100644 index 3e902d0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/47.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/47.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/47.txt deleted file mode 100644 index fffde5d..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/47.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A12345678 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/48.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/48.png deleted file mode 100644 index f76300a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/48.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/48.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/48.txt deleted file mode 100644 index ac79617..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/48.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1ABCDEF;:/1234567 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/49.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/49.png deleted file mode 100644 index 2800ea0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/49.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/49.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/49.txt deleted file mode 100644 index 163b64b..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/49.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1ABCDEF;:/ABCDEFG \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/5.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/5.png deleted file mode 100644 index 847a523..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/5.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/5.txt deleted file mode 100644 index b4113ac..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/5.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3103)001750 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/50.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/50.png deleted file mode 100644 index c8d5dac..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/50.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/50.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/50.txt deleted file mode 100644 index d359328..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/50.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1;:/ABCDEFGHIJKLM \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/51.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/51.png deleted file mode 100644 index a0fd5ab..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/51.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/51.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/51.txt deleted file mode 100644 index c25e84f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/51.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1;:/0123456789012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/52.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/52.png deleted file mode 100644 index 0c7a973..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/52.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/52.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/52.txt deleted file mode 100644 index 2914766..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/52.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1;:/0123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/53.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/53.png deleted file mode 100644 index 6216161..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/53.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/53.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/53.txt deleted file mode 100644 index c8be9f3..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/53.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1;:/0123(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/54.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/54.png deleted file mode 100644 index 5440e2d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/54.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/54.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/54.txt deleted file mode 100644 index ed31c4d..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/54.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3103)012233(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/55.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/55.png deleted file mode 100644 index 0f14fbc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/55.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/55.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/55.txt deleted file mode 100644 index d7f0a6a..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/55.txt +++ /dev/null @@ -1 +0,0 @@ -(01)91234567980129(3103)012233(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/56.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/56.png deleted file mode 100644 index 0c1a9b2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/56.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/56.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/56.txt deleted file mode 100644 index ab93c97..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/56.txt +++ /dev/null @@ -1 +0,0 @@ -(01)91234567980129(3102)012233(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/57.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/57.png deleted file mode 100644 index ab0be98..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/57.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/57.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/57.txt deleted file mode 100644 index fca726b..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/57.txt +++ /dev/null @@ -1 +0,0 @@ -(01)91234567980129(3102)012233(15)000101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/58.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/58.png deleted file mode 100644 index ad8a1b9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/58.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/58.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/58.txt deleted file mode 100644 index b4113ac..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/58.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3103)001750 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/59.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/59.png deleted file mode 100644 index 6cbc6de..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/59.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/59.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/59.txt deleted file mode 100644 index 57a2c64..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/59.txt +++ /dev/null @@ -1 +0,0 @@ -(01)92109876543213(3103)032767 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/6.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/6.png deleted file mode 100644 index 37cf344..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/6.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/6.txt deleted file mode 100644 index 57a2c64..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/6.txt +++ /dev/null @@ -1 +0,0 @@ -(01)92109876543213(3103)032767 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/60.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/60.png deleted file mode 100644 index 6a5e4df..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/60.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/60.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/60.txt deleted file mode 100644 index bfa4177..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/60.txt +++ /dev/null @@ -1 +0,0 @@ -(01)92109876543213(3103)000000 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/61.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/61.png deleted file mode 100644 index 91e2bb7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/61.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/61.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/61.txt deleted file mode 100644 index e0da7fa..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/61.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)000156 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/62.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/62.png deleted file mode 100644 index 1c16204..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/62.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/62.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/62.txt deleted file mode 100644 index 01af485..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/62.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)009999 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/63.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/63.png deleted file mode 100644 index 1fef978..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/63.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/63.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/63.txt deleted file mode 100644 index e8f98fe..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/63.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3203)010000 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/64.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/64.png deleted file mode 100644 index 96861ae..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/64.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/64.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/64.txt deleted file mode 100644 index 9895a67..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/64.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3203)032767 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/65.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/65.png deleted file mode 100644 index 79b9398..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/65.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/65.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/65.txt deleted file mode 100644 index dd36aab..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/65.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3922)795 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/66.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/66.png deleted file mode 100644 index c1c95b3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/66.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/66.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/66.txt deleted file mode 100644 index 0429d93..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/66.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3922)795888888888888888888888888888888888888888888888888888 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/67.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/67.png deleted file mode 100644 index 97a42de..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/67.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/67.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/67.txt deleted file mode 100644 index fb00e31..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/67.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3932)0401234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/68.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/68.png deleted file mode 100644 index 5261789..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/68.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/68.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/68.txt deleted file mode 100644 index b5f3fe9..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/68.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3932)040EUR \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/69.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/69.png deleted file mode 100644 index c90290c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/69.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/69.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/69.txt deleted file mode 100644 index e95bc8d..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/69.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3932)04055GBP \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/7.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/7.png deleted file mode 100644 index d96918e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/7.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/7.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/7.txt deleted file mode 100644 index bfa4177..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/7.txt +++ /dev/null @@ -1 +0,0 @@ -(01)92109876543213(3103)000000 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/70.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/70.png deleted file mode 100644 index 0cd2128..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/70.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/70.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/70.txt deleted file mode 100644 index 37c6cb3..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/70.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3932)04066USD778899 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/71.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/71.png deleted file mode 100644 index 93539de..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/71.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/71.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/71.txt deleted file mode 100644 index 9066194..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/71.txt +++ /dev/null @@ -1 +0,0 @@ -(01)00012345678905(10)ABC123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/72.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/72.png deleted file mode 100644 index 8d5fa2a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/72.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/72.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/72.txt deleted file mode 100644 index 8f0841f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/72.txt +++ /dev/null @@ -1 +0,0 @@ -(01)12345678901231(10)UNIVERSITY-OF-DEUSTO \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/73.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/73.png deleted file mode 100644 index 0232411..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/73.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/73.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/73.txt deleted file mode 100644 index 89fda98..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/73.txt +++ /dev/null @@ -1 +0,0 @@ -(01)12345678901231(10)PIRAMIDE-PROJECT \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/74.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/74.png deleted file mode 100644 index 44c936d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/74.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/74.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/74.txt deleted file mode 100644 index b120324..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/74.txt +++ /dev/null @@ -1 +0,0 @@ -(01)12345678901231(10)TREELOGIC \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/75.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/75.png deleted file mode 100644 index 7b75027..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/75.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/75.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/75.txt deleted file mode 100644 index 09d4208..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/75.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)012345678901 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/76.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/76.png deleted file mode 100644 index bfedb3b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/76.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/76.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/76.txt deleted file mode 100644 index 5e76631..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/76.txt +++ /dev/null @@ -1 +0,0 @@ -(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/77.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/77.png deleted file mode 100644 index baac622..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/77.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/77.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/77.txt deleted file mode 100644 index 17966ee..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/77.txt +++ /dev/null @@ -1 +0,0 @@ -(10)5678(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/78.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/78.png deleted file mode 100644 index 923e2a4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/78.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/78.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/78.txt deleted file mode 100644 index b948648..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/78.txt +++ /dev/null @@ -1 +0,0 @@ -(10)5678(11)001010 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/79.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/79.png deleted file mode 100644 index 1e6bf4d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/79.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/79.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/79.txt deleted file mode 100644 index a7b3497..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/79.txt +++ /dev/null @@ -1 +0,0 @@ -(10)567890(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/8.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/8.png deleted file mode 100644 index 6155417..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/8.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/8.txt deleted file mode 100644 index e0da7fa..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/8.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)000156 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/80.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/80.png deleted file mode 100644 index 4561ad7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/80.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/80.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/80.txt deleted file mode 100644 index e8c7268..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/80.txt +++ /dev/null @@ -1 +0,0 @@ -(10)567(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/81.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/81.png deleted file mode 100644 index 030d820..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/81.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/81.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/81.txt deleted file mode 100644 index 5263f7f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/81.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098-1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/82.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/82.png deleted file mode 100644 index 039e01e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/82.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/82.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/82.txt deleted file mode 100644 index f6413d5..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/82.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098,1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/83.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/83.png deleted file mode 100644 index c6cb58f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/83.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/83.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/83.txt deleted file mode 100644 index 9208d92..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/83.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098/1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/84.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/84.png deleted file mode 100644 index c6e3d3b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/84.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/84.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/84.txt deleted file mode 100644 index b78623a..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/84.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098.1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/85.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/85.png deleted file mode 100644 index 4f03be8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/85.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/85.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/85.txt deleted file mode 100644 index 82bfa6a..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/85.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098*1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/86.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/86.png deleted file mode 100644 index 42c485a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/86.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/86.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/86.txt deleted file mode 100644 index 6263d99..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/86.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098a1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/87.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/87.png deleted file mode 100644 index c55f813..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/87.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/87.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/87.txt deleted file mode 100644 index 35fc529..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/87.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098!1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/88.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/88.png deleted file mode 100644 index 6a463ed..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/88.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/88.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/88.txt deleted file mode 100644 index d0d95d0..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/88.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098"1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/89.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/89.png deleted file mode 100644 index 816f932..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/89.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/89.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/89.txt deleted file mode 100644 index 53bf781..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/89.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098%1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/9.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/9.png deleted file mode 100644 index d9c8734..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/9.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/9.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/9.txt deleted file mode 100644 index 01af485..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/9.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)009999 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/90.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/90.png deleted file mode 100644 index 182300a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/90.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/90.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/90.txt deleted file mode 100644 index 5d1d351..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/90.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098&1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/91.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/91.png deleted file mode 100644 index 349944e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/91.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/91.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/91.txt deleted file mode 100644 index f00c6bb..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/91.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098'1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/92.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/92.png deleted file mode 100644 index d1e9f99..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/92.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/92.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/92.txt deleted file mode 100644 index 18b90ec..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/92.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098+1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/93.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/93.png deleted file mode 100644 index 674b7fe..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/93.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/93.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/93.txt deleted file mode 100644 index 96f9049..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/93.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098:1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/94.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/94.png deleted file mode 100644 index 235b371..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/94.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/94.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/94.txt deleted file mode 100644 index 2dd84d5..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/94.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098;1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/95.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/95.png deleted file mode 100644 index 7c63c70..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/95.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/95.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/95.txt deleted file mode 100644 index a64a6db..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/95.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098<1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/96.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/96.png deleted file mode 100644 index c3b8ac7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/96.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/96.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/96.txt deleted file mode 100644 index c7cc606..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/96.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098=1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/97.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/97.png deleted file mode 100644 index df6572a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/97.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/97.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/97.txt deleted file mode 100644 index 7345e4e..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/97.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098>1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/98.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/98.png deleted file mode 100644 index 120cd95..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/98.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/98.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/98.txt deleted file mode 100644 index 5e152de..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/98.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098?1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/99.png b/port_src/core/src/test/resources/blackbox/rssexpanded-3/99.png deleted file mode 100644 index f9ce0f3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpanded-3/99.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpanded-3/99.txt b/port_src/core/src/test/resources/blackbox/rssexpanded-3/99.txt deleted file mode 100644 index aad1b28..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpanded-3/99.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098_1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/1.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/1.png deleted file mode 100644 index 9032bef..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/1.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/1.txt deleted file mode 100644 index ed31c4d..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3103)012233(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/10.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/10.png deleted file mode 100644 index b2c4386..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/10.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/10.txt deleted file mode 100644 index e8f98fe..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/10.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3203)010000 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/11.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/11.png deleted file mode 100644 index 2381e25..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/11.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/11.txt deleted file mode 100644 index 9895a67..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/11.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3203)032767 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/12.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/12.png deleted file mode 100644 index 228c5e4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/12.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/12.txt deleted file mode 100644 index dd36aab..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/12.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3922)795 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/13.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/13.png deleted file mode 100644 index 4081641..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/13.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/13.txt deleted file mode 100644 index 0429d93..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/13.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3922)795888888888888888888888888888888888888888888888888888 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/14.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/14.png deleted file mode 100644 index bd4f28c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/14.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/14.txt deleted file mode 100644 index fb00e31..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/14.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3932)0401234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/15.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/15.png deleted file mode 100644 index 293ec41..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/15.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/15.txt deleted file mode 100644 index b5f3fe9..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/15.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3932)040EUR \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/16.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/16.png deleted file mode 100644 index 1b25ed6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/16.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/16.txt deleted file mode 100644 index e95bc8d..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/16.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3932)04055GBP \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/17.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/17.png deleted file mode 100644 index 021f7bd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/17.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/17.txt deleted file mode 100644 index 37c6cb3..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/17.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3932)04066USD778899 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/18.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/18.png deleted file mode 100644 index 7471e95..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/18.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/18.txt deleted file mode 100644 index 9066194..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/18.txt +++ /dev/null @@ -1 +0,0 @@ -(01)00012345678905(10)ABC123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/19.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/19.png deleted file mode 100644 index 5a9f74f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/19.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/19.txt deleted file mode 100644 index 8f0841f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/19.txt +++ /dev/null @@ -1 +0,0 @@ -(01)12345678901231(10)UNIVERSITY-OF-DEUSTO \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/2.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/2.png deleted file mode 100644 index 8f54fb1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/2.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/2.txt deleted file mode 100644 index d7f0a6a..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/2.txt +++ /dev/null @@ -1 +0,0 @@ -(01)91234567980129(3103)012233(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/20.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/20.png deleted file mode 100644 index d0a075c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/20.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/20.txt deleted file mode 100644 index 89fda98..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/20.txt +++ /dev/null @@ -1 +0,0 @@ -(01)12345678901231(10)PIRAMIDE-PROJECT \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/21.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/21.png deleted file mode 100644 index 25fd610..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/21.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/21.txt deleted file mode 100644 index b120324..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/21.txt +++ /dev/null @@ -1 +0,0 @@ -(01)12345678901231(10)TREELOGIC \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/22.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/22.png deleted file mode 100644 index 61250af..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/22.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/22.txt deleted file mode 100644 index 09d4208..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/22.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)012345678901 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/23.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/23.png deleted file mode 100644 index 19811bf..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/23.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/23.txt deleted file mode 100644 index 5e76631..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/23.txt +++ /dev/null @@ -1 +0,0 @@ -(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/24.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/24.png deleted file mode 100644 index a4c6ae8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/24.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/24.txt deleted file mode 100644 index 17966ee..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/24.txt +++ /dev/null @@ -1 +0,0 @@ -(10)5678(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/25.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/25.png deleted file mode 100644 index ba14d25..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/25.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/25.txt deleted file mode 100644 index b948648..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/25.txt +++ /dev/null @@ -1 +0,0 @@ -(10)5678(11)001010 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/26.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/26.png deleted file mode 100644 index af0226f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/26.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/26.txt deleted file mode 100644 index a7b3497..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/26.txt +++ /dev/null @@ -1 +0,0 @@ -(10)567890(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/27.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/27.png deleted file mode 100644 index 5a673ec..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/27.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/27.txt deleted file mode 100644 index e8c7268..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/27.txt +++ /dev/null @@ -1 +0,0 @@ -(10)567(11)010101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/28.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/28.png deleted file mode 100644 index cdff613..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/28.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/28.txt deleted file mode 100644 index 5263f7f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/28.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098-1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/29.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/29.png deleted file mode 100644 index c7aef19..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/29.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/29.txt deleted file mode 100644 index f6413d5..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/29.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098,1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/3.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/3.png deleted file mode 100644 index ea28950..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/3.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/3.txt deleted file mode 100644 index ab93c97..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/3.txt +++ /dev/null @@ -1 +0,0 @@ -(01)91234567980129(3102)012233(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/30.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/30.png deleted file mode 100644 index 7d575d9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/30.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/30.txt deleted file mode 100644 index 9208d92..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/30.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098/1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/31.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/31.png deleted file mode 100644 index 546046b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/31.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/31.txt deleted file mode 100644 index b78623a..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/31.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098.1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/32.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/32.png deleted file mode 100644 index 198f8a6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/32.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/32.txt deleted file mode 100644 index 82bfa6a..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/32.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098*1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/33.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/33.png deleted file mode 100644 index a173e8d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/33.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/33.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/33.txt deleted file mode 100644 index 6263d99..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/33.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098a1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/34.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/34.png deleted file mode 100644 index 775c1c2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/34.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/34.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/34.txt deleted file mode 100644 index 35fc529..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/34.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098!1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/35.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/35.png deleted file mode 100644 index 890494d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/35.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/35.txt deleted file mode 100644 index d0d95d0..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/35.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098"1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/36.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/36.png deleted file mode 100644 index 50a7796..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/36.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/36.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/36.txt deleted file mode 100644 index 53bf781..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/36.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098%1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/37.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/37.png deleted file mode 100644 index 58d16f5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/37.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/37.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/37.txt deleted file mode 100644 index 5d1d351..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/37.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098&1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/38.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/38.png deleted file mode 100644 index 9b0a795..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/38.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/38.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/38.txt deleted file mode 100644 index f00c6bb..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/38.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098'1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/39.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/39.png deleted file mode 100644 index a324207..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/39.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/39.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/39.txt deleted file mode 100644 index 18b90ec..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/39.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098+1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/4.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/4.png deleted file mode 100644 index 5147f84..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/4.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/4.txt deleted file mode 100644 index fca726b..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/4.txt +++ /dev/null @@ -1 +0,0 @@ -(01)91234567980129(3102)012233(15)000101 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/40.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/40.png deleted file mode 100644 index 5a18fc9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/40.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/40.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/40.txt deleted file mode 100644 index 96f9049..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/40.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098:1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/41.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/41.png deleted file mode 100644 index 2ae4497..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/41.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/41.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/41.txt deleted file mode 100644 index 2dd84d5..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/41.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098;1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/42.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/42.png deleted file mode 100644 index ea4d68c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/42.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/42.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/42.txt deleted file mode 100644 index a64a6db..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/42.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098<1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/43.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/43.png deleted file mode 100644 index cba68a2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/43.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/43.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/43.txt deleted file mode 100644 index c7cc606..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/43.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098=1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/44.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/44.png deleted file mode 100644 index 690c825..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/44.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/44.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/44.txt deleted file mode 100644 index 7345e4e..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/44.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098>1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/45.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/45.png deleted file mode 100644 index 57a1a4c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/45.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/45.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/45.txt deleted file mode 100644 index 5e152de..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/45.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098?1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/46.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/46.png deleted file mode 100644 index ad09098..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/46.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/46.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/46.txt deleted file mode 100644 index aad1b28..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/46.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098_1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/47.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/47.png deleted file mode 100644 index c80ab17..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/47.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/47.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/47.txt deleted file mode 100644 index 4339de9..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/47.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1098 1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/48.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/48.png deleted file mode 100644 index f616013..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/48.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/48.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/48.txt deleted file mode 100644 index 6f63fb0..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/48.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/49.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/49.png deleted file mode 100644 index 08c8a25..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/49.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/49.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/49.txt deleted file mode 100644 index 5c1b912..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/49.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A1 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/5.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/5.png deleted file mode 100644 index eb3d533..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/5.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/5.txt deleted file mode 100644 index b4113ac..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/5.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3103)001750 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/50.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/50.png deleted file mode 100644 index cfc13b0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/50.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/50.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/50.txt deleted file mode 100644 index d77a476..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/50.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/51.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/51.png deleted file mode 100644 index 40f2218..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/51.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/51.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/51.txt deleted file mode 100644 index 2e2ec43..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/51.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A1234 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/52.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/52.png deleted file mode 100644 index 7537a41..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/52.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/52.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/52.txt deleted file mode 100644 index b607d14..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/52.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A1234A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/53.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/53.png deleted file mode 100644 index ce7408f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/53.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/53.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/53.txt deleted file mode 100644 index 389adca..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/53.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A123456 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/54.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/54.png deleted file mode 100644 index 73a5588..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/54.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/54.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/54.txt deleted file mode 100644 index fffde5d..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/54.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A12345678 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/55.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/55.png deleted file mode 100644 index 7c65f74..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/55.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/55.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/55.txt deleted file mode 100644 index 1ad0fbd..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/55.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123456A1234A(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/56.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/56.png deleted file mode 100644 index ebd1f36..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/56.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/56.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/56.txt deleted file mode 100644 index ac79617..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/56.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1ABCDEF;:/1234567 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/57.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/57.png deleted file mode 100644 index 529a179..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/57.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/57.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/57.txt deleted file mode 100644 index 163b64b..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/57.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1ABCDEF;:/ABCDEFG \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/58.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/58.png deleted file mode 100644 index dbe8cc0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/58.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/58.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/58.txt deleted file mode 100644 index d359328..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/58.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1;:/ABCDEFGHIJKLM \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/59.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/59.png deleted file mode 100644 index e06150d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/59.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/59.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/59.txt deleted file mode 100644 index c25e84f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/59.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1;:/0123456789012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/6.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/6.png deleted file mode 100644 index 311893a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/6.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/6.txt deleted file mode 100644 index 57a2c64..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/6.txt +++ /dev/null @@ -1 +0,0 @@ -(01)92109876543213(3103)032767 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/60.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/60.png deleted file mode 100644 index 5c6f00f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/60.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/60.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/60.txt deleted file mode 100644 index 2914766..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/60.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1;:/0123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/61.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/61.png deleted file mode 100644 index 6f5b3d9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/61.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/61.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/61.txt deleted file mode 100644 index c8be9f3..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/61.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1;:/0123(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/62.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/62.png deleted file mode 100644 index 2506755..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/62.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/62.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/62.txt deleted file mode 100644 index 9a1581d..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/62.txt +++ /dev/null @@ -1 +0,0 @@ -(10)1 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/63.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/63.png deleted file mode 100644 index fbb6ac2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/63.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/63.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/63.txt deleted file mode 100644 index 4c3769f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/63.txt +++ /dev/null @@ -1 +0,0 @@ -(10)12A \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/64.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/64.png deleted file mode 100644 index 400eb00..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/64.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/64.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/64.txt deleted file mode 100644 index 62c17f1..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/64.txt +++ /dev/null @@ -1 +0,0 @@ -(10)123 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/7.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/7.png deleted file mode 100644 index 677ff18..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/7.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/7.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/7.txt deleted file mode 100644 index bfa4177..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/7.txt +++ /dev/null @@ -1 +0,0 @@ -(01)92109876543213(3103)000000 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/8.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/8.png deleted file mode 100644 index f2c44fb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/8.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/8.txt deleted file mode 100644 index e0da7fa..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/8.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)000156 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/9.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/9.png deleted file mode 100644 index 4a80388..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/9.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/9.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/9.txt deleted file mode 100644 index 01af485..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-1/9.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3202)009999 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/1.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/1.png deleted file mode 100644 index dda9e26..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/1.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/1.txt deleted file mode 100644 index 963f111..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/1.txt +++ /dev/null @@ -1 +0,0 @@ -(8110)10014141012345290110100 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/1000.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/1000.png deleted file mode 100644 index 865e1f5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/1000.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/1000.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/1000.txt deleted file mode 100644 index 4e8655c..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/1000.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(3202)012345(15)991231 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/13.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/13.png deleted file mode 100644 index 4081641..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/13.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/13.txt deleted file mode 100644 index 0429d93..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/13.txt +++ /dev/null @@ -1 +0,0 @@ -(01)90012345678908(3922)795888888888888888888888888888888888888888888888888888 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/19.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/19.png deleted file mode 100644 index 5a9f74f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/19.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/19.txt deleted file mode 100644 index 8f0841f..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/19.txt +++ /dev/null @@ -1 +0,0 @@ -(01)12345678901231(10)UNIVERSITY-OF-DEUSTO \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/20.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/20.png deleted file mode 100644 index d0a075c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/20.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/20.txt deleted file mode 100644 index 89fda98..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/20.txt +++ /dev/null @@ -1 +0,0 @@ -(01)12345678901231(10)PIRAMIDE-PROJECT \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/22.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/22.png deleted file mode 100644 index 61250af..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/22.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/22.txt deleted file mode 100644 index 09d4208..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/22.txt +++ /dev/null @@ -1 +0,0 @@ -(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)012345678901 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/23.png b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/23.png deleted file mode 100644 index 19811bf..0000000 Binary files a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/23.txt b/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/23.txt deleted file mode 100644 index 5e76631..0000000 --- a/port_src/core/src/test/resources/blackbox/rssexpandedstacked-2/23.txt +++ /dev/null @@ -1 +0,0 @@ -(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/unsupported/01.png b/port_src/core/src/test/resources/blackbox/unsupported/01.png deleted file mode 100644 index fe56386..0000000 Binary files a/port_src/core/src/test/resources/blackbox/unsupported/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/unsupported/03.png b/port_src/core/src/test/resources/blackbox/unsupported/03.png deleted file mode 100644 index 8df6942..0000000 Binary files a/port_src/core/src/test/resources/blackbox/unsupported/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/unsupported/04.png b/port_src/core/src/test/resources/blackbox/unsupported/04.png deleted file mode 100644 index 8340e4f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/unsupported/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/unsupported/05.png b/port_src/core/src/test/resources/blackbox/unsupported/05.png deleted file mode 100644 index d935143..0000000 Binary files a/port_src/core/src/test/resources/blackbox/unsupported/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/1.png b/port_src/core/src/test/resources/blackbox/upca-1/1.png deleted file mode 100644 index cca38d1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/1.txt b/port_src/core/src/test/resources/blackbox/upca-1/1.txt deleted file mode 100644 index 8304219..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -036602301467 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/10.png b/port_src/core/src/test/resources/blackbox/upca-1/10.png deleted file mode 100644 index 3eb798d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/10.txt b/port_src/core/src/test/resources/blackbox/upca-1/10.txt deleted file mode 100644 index 9a6f1d4..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/10.txt +++ /dev/null @@ -1 +0,0 @@ -027011006951 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/11.png b/port_src/core/src/test/resources/blackbox/upca-1/11.png deleted file mode 100644 index e255c55..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/11.txt b/port_src/core/src/test/resources/blackbox/upca-1/11.txt deleted file mode 100644 index 9a6f1d4..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/11.txt +++ /dev/null @@ -1 +0,0 @@ -027011006951 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/12.png b/port_src/core/src/test/resources/blackbox/upca-1/12.png deleted file mode 100644 index 3e5ff90..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/12.txt b/port_src/core/src/test/resources/blackbox/upca-1/12.txt deleted file mode 100644 index 4ea41b0..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/12.txt +++ /dev/null @@ -1 +0,0 @@ -781735802045 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/13.png b/port_src/core/src/test/resources/blackbox/upca-1/13.png deleted file mode 100644 index 66fe9ab..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/13.txt b/port_src/core/src/test/resources/blackbox/upca-1/13.txt deleted file mode 100644 index 4ea41b0..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/13.txt +++ /dev/null @@ -1 +0,0 @@ -781735802045 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/16.png b/port_src/core/src/test/resources/blackbox/upca-1/16.png deleted file mode 100644 index 8524580..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/16.txt b/port_src/core/src/test/resources/blackbox/upca-1/16.txt deleted file mode 100644 index ec6ea1e..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/16.txt +++ /dev/null @@ -1 +0,0 @@ -456314319671 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/17.png b/port_src/core/src/test/resources/blackbox/upca-1/17.png deleted file mode 100644 index 280977c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/17.txt b/port_src/core/src/test/resources/blackbox/upca-1/17.txt deleted file mode 100644 index 99d98e6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/17.txt +++ /dev/null @@ -1 +0,0 @@ -434704791429 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/18.png b/port_src/core/src/test/resources/blackbox/upca-1/18.png deleted file mode 100644 index 3b17018..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/18.txt b/port_src/core/src/test/resources/blackbox/upca-1/18.txt deleted file mode 100644 index d357ddf..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/18.txt +++ /dev/null @@ -1 +0,0 @@ -024543136538 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/19.png b/port_src/core/src/test/resources/blackbox/upca-1/19.png deleted file mode 100644 index e33d291..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/19.txt b/port_src/core/src/test/resources/blackbox/upca-1/19.txt deleted file mode 100644 index d357ddf..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/19.txt +++ /dev/null @@ -1 +0,0 @@ -024543136538 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/2.png b/port_src/core/src/test/resources/blackbox/upca-1/2.png deleted file mode 100644 index a27da98..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/2.txt b/port_src/core/src/test/resources/blackbox/upca-1/2.txt deleted file mode 100644 index 8304219..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/2.txt +++ /dev/null @@ -1 +0,0 @@ -036602301467 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/20.png b/port_src/core/src/test/resources/blackbox/upca-1/20.png deleted file mode 100644 index cc4b297..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/20.txt b/port_src/core/src/test/resources/blackbox/upca-1/20.txt deleted file mode 100644 index ac41ca8..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/20.txt +++ /dev/null @@ -1 +0,0 @@ -752919460009 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/21.png b/port_src/core/src/test/resources/blackbox/upca-1/21.png deleted file mode 100644 index ac09a1b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/21.txt b/port_src/core/src/test/resources/blackbox/upca-1/21.txt deleted file mode 100644 index ac41ca8..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/21.txt +++ /dev/null @@ -1 +0,0 @@ -752919460009 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/27.png b/port_src/core/src/test/resources/blackbox/upca-1/27.png deleted file mode 100644 index c307ad8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/27.txt b/port_src/core/src/test/resources/blackbox/upca-1/27.txt deleted file mode 100644 index 592cb74..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/27.txt +++ /dev/null @@ -1 +0,0 @@ -606949762520 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/28.png b/port_src/core/src/test/resources/blackbox/upca-1/28.png deleted file mode 100644 index 902f654..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/28.txt b/port_src/core/src/test/resources/blackbox/upca-1/28.txt deleted file mode 100644 index 051a382..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/28.txt +++ /dev/null @@ -1 +0,0 @@ -061869053712 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/29.png b/port_src/core/src/test/resources/blackbox/upca-1/29.png deleted file mode 100644 index 7643633..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/29.txt b/port_src/core/src/test/resources/blackbox/upca-1/29.txt deleted file mode 100644 index 1335b71..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/29.txt +++ /dev/null @@ -1 +0,0 @@ -619659023935 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/3.png b/port_src/core/src/test/resources/blackbox/upca-1/3.png deleted file mode 100644 index fb9f41a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/3.txt b/port_src/core/src/test/resources/blackbox/upca-1/3.txt deleted file mode 100644 index e53c211..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/3.txt +++ /dev/null @@ -1 +0,0 @@ -070097025088 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/35.png b/port_src/core/src/test/resources/blackbox/upca-1/35.png deleted file mode 100644 index f53d8b8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/35.txt b/port_src/core/src/test/resources/blackbox/upca-1/35.txt deleted file mode 100644 index 9b3f5d3..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/35.txt +++ /dev/null @@ -1 +0,0 @@ -045496442736 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/4.png b/port_src/core/src/test/resources/blackbox/upca-1/4.png deleted file mode 100644 index 0e3e739..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/4.txt b/port_src/core/src/test/resources/blackbox/upca-1/4.txt deleted file mode 100644 index e53c211..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/4.txt +++ /dev/null @@ -1 +0,0 @@ -070097025088 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/5.png b/port_src/core/src/test/resources/blackbox/upca-1/5.png deleted file mode 100644 index 201d191..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/5.txt b/port_src/core/src/test/resources/blackbox/upca-1/5.txt deleted file mode 100644 index e53c211..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/5.txt +++ /dev/null @@ -1 +0,0 @@ -070097025088 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/8.png b/port_src/core/src/test/resources/blackbox/upca-1/8.png deleted file mode 100644 index 9e325e5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/8.txt b/port_src/core/src/test/resources/blackbox/upca-1/8.txt deleted file mode 100644 index 37e4df6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/8.txt +++ /dev/null @@ -1 +0,0 @@ -071831007995 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-1/9.png b/port_src/core/src/test/resources/blackbox/upca-1/9.png deleted file mode 100644 index dfca269..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-1/9.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-1/9.txt b/port_src/core/src/test/resources/blackbox/upca-1/9.txt deleted file mode 100644 index 37e4df6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-1/9.txt +++ /dev/null @@ -1 +0,0 @@ -071831007995 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/01.png b/port_src/core/src/test/resources/blackbox/upca-2/01.png deleted file mode 100644 index 9fc6f6b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/01.txt b/port_src/core/src/test/resources/blackbox/upca-2/01.txt deleted file mode 100644 index ad9b706..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/01.txt +++ /dev/null @@ -1 +0,0 @@ -890444000335 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/02.png b/port_src/core/src/test/resources/blackbox/upca-2/02.png deleted file mode 100644 index a5c90a6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/02.txt b/port_src/core/src/test/resources/blackbox/upca-2/02.txt deleted file mode 100644 index ad9b706..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/02.txt +++ /dev/null @@ -1 +0,0 @@ -890444000335 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/03.png b/port_src/core/src/test/resources/blackbox/upca-2/03.png deleted file mode 100644 index 4f3da3f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/03.txt b/port_src/core/src/test/resources/blackbox/upca-2/03.txt deleted file mode 100644 index ad9b706..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/03.txt +++ /dev/null @@ -1 +0,0 @@ -890444000335 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/04.png b/port_src/core/src/test/resources/blackbox/upca-2/04.png deleted file mode 100644 index a177ccb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/04.txt b/port_src/core/src/test/resources/blackbox/upca-2/04.txt deleted file mode 100644 index ad9b706..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/04.txt +++ /dev/null @@ -1 +0,0 @@ -890444000335 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/05.png b/port_src/core/src/test/resources/blackbox/upca-2/05.png deleted file mode 100644 index 9de2936..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/05.txt b/port_src/core/src/test/resources/blackbox/upca-2/05.txt deleted file mode 100644 index ad9b706..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/05.txt +++ /dev/null @@ -1 +0,0 @@ -890444000335 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/06.png b/port_src/core/src/test/resources/blackbox/upca-2/06.png deleted file mode 100644 index 4b6ba58..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/06.txt b/port_src/core/src/test/resources/blackbox/upca-2/06.txt deleted file mode 100644 index ad9b706..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/06.txt +++ /dev/null @@ -1 +0,0 @@ -890444000335 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/07.png b/port_src/core/src/test/resources/blackbox/upca-2/07.png deleted file mode 100644 index 476a6b1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/07.txt b/port_src/core/src/test/resources/blackbox/upca-2/07.txt deleted file mode 100644 index ad9b706..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/07.txt +++ /dev/null @@ -1 +0,0 @@ -890444000335 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/08.png b/port_src/core/src/test/resources/blackbox/upca-2/08.png deleted file mode 100644 index a0a5419..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/08.txt b/port_src/core/src/test/resources/blackbox/upca-2/08.txt deleted file mode 100644 index 00773d4..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/08.txt +++ /dev/null @@ -1 +0,0 @@ -181497000879 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/09.png b/port_src/core/src/test/resources/blackbox/upca-2/09.png deleted file mode 100644 index d9bb859..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/09.txt b/port_src/core/src/test/resources/blackbox/upca-2/09.txt deleted file mode 100644 index 00773d4..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/09.txt +++ /dev/null @@ -1 +0,0 @@ -181497000879 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/10.png b/port_src/core/src/test/resources/blackbox/upca-2/10.png deleted file mode 100644 index 2759f87..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/10.txt b/port_src/core/src/test/resources/blackbox/upca-2/10.txt deleted file mode 100644 index 00773d4..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/10.txt +++ /dev/null @@ -1 +0,0 @@ -181497000879 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/11.png b/port_src/core/src/test/resources/blackbox/upca-2/11.png deleted file mode 100644 index c047131..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/11.txt b/port_src/core/src/test/resources/blackbox/upca-2/11.txt deleted file mode 100644 index 00773d4..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/11.txt +++ /dev/null @@ -1 +0,0 @@ -181497000879 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/12.png b/port_src/core/src/test/resources/blackbox/upca-2/12.png deleted file mode 100644 index 3401092..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/12.txt b/port_src/core/src/test/resources/blackbox/upca-2/12.txt deleted file mode 100644 index 00773d4..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/12.txt +++ /dev/null @@ -1 +0,0 @@ -181497000879 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/13.png b/port_src/core/src/test/resources/blackbox/upca-2/13.png deleted file mode 100644 index 2a1ced6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/13.txt b/port_src/core/src/test/resources/blackbox/upca-2/13.txt deleted file mode 100644 index 00773d4..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/13.txt +++ /dev/null @@ -1 +0,0 @@ -181497000879 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/14.png b/port_src/core/src/test/resources/blackbox/upca-2/14.png deleted file mode 100644 index 41e1426..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/14.txt b/port_src/core/src/test/resources/blackbox/upca-2/14.txt deleted file mode 100644 index 2d0688a..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/14.txt +++ /dev/null @@ -1 +0,0 @@ -051000000675 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/15.png b/port_src/core/src/test/resources/blackbox/upca-2/15.png deleted file mode 100644 index 23f9f7d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/15.txt b/port_src/core/src/test/resources/blackbox/upca-2/15.txt deleted file mode 100644 index 2d0688a..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/15.txt +++ /dev/null @@ -1 +0,0 @@ -051000000675 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/16.png b/port_src/core/src/test/resources/blackbox/upca-2/16.png deleted file mode 100644 index 0933231..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/16.txt b/port_src/core/src/test/resources/blackbox/upca-2/16.txt deleted file mode 100644 index 2d0688a..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/16.txt +++ /dev/null @@ -1 +0,0 @@ -051000000675 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/17.png b/port_src/core/src/test/resources/blackbox/upca-2/17.png deleted file mode 100644 index e0c4118..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/17.txt b/port_src/core/src/test/resources/blackbox/upca-2/17.txt deleted file mode 100644 index 2d0688a..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/17.txt +++ /dev/null @@ -1 +0,0 @@ -051000000675 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/18.png b/port_src/core/src/test/resources/blackbox/upca-2/18.png deleted file mode 100644 index 8f7af59..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/18.txt b/port_src/core/src/test/resources/blackbox/upca-2/18.txt deleted file mode 100644 index 2d0688a..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/18.txt +++ /dev/null @@ -1 +0,0 @@ -051000000675 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/19.png b/port_src/core/src/test/resources/blackbox/upca-2/19.png deleted file mode 100644 index cc606ac..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/19.txt b/port_src/core/src/test/resources/blackbox/upca-2/19.txt deleted file mode 100644 index 2d0688a..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/19.txt +++ /dev/null @@ -1 +0,0 @@ -051000000675 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/20.png b/port_src/core/src/test/resources/blackbox/upca-2/20.png deleted file mode 100644 index 71de73a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/20.txt b/port_src/core/src/test/resources/blackbox/upca-2/20.txt deleted file mode 100644 index 2d0688a..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/20.txt +++ /dev/null @@ -1 +0,0 @@ -051000000675 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/21.png b/port_src/core/src/test/resources/blackbox/upca-2/21.png deleted file mode 100644 index 11b9aa3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/21.txt b/port_src/core/src/test/resources/blackbox/upca-2/21.txt deleted file mode 100644 index 2d0688a..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/21.txt +++ /dev/null @@ -1 +0,0 @@ -051000000675 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/22.png b/port_src/core/src/test/resources/blackbox/upca-2/22.png deleted file mode 100644 index 882a6c0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/22.txt b/port_src/core/src/test/resources/blackbox/upca-2/22.txt deleted file mode 100644 index 2d0688a..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/22.txt +++ /dev/null @@ -1 +0,0 @@ -051000000675 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/23.png b/port_src/core/src/test/resources/blackbox/upca-2/23.png deleted file mode 100644 index cc697c7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/23.txt b/port_src/core/src/test/resources/blackbox/upca-2/23.txt deleted file mode 100644 index 2598343..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/23.txt +++ /dev/null @@ -1 +0,0 @@ -752050200137 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/24.png b/port_src/core/src/test/resources/blackbox/upca-2/24.png deleted file mode 100644 index 7745fbd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/24.txt b/port_src/core/src/test/resources/blackbox/upca-2/24.txt deleted file mode 100644 index 2598343..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/24.txt +++ /dev/null @@ -1 +0,0 @@ -752050200137 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/25.png b/port_src/core/src/test/resources/blackbox/upca-2/25.png deleted file mode 100644 index 4679ca3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/25.txt b/port_src/core/src/test/resources/blackbox/upca-2/25.txt deleted file mode 100644 index 2598343..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/25.txt +++ /dev/null @@ -1 +0,0 @@ -752050200137 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/26.png b/port_src/core/src/test/resources/blackbox/upca-2/26.png deleted file mode 100644 index 3caf90c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/26.txt b/port_src/core/src/test/resources/blackbox/upca-2/26.txt deleted file mode 100644 index 2598343..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/26.txt +++ /dev/null @@ -1 +0,0 @@ -752050200137 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/27.png b/port_src/core/src/test/resources/blackbox/upca-2/27.png deleted file mode 100644 index 9dad573..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/27.txt b/port_src/core/src/test/resources/blackbox/upca-2/27.txt deleted file mode 100644 index 2598343..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/27.txt +++ /dev/null @@ -1 +0,0 @@ -752050200137 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/28.png b/port_src/core/src/test/resources/blackbox/upca-2/28.png deleted file mode 100644 index 5ef9930..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/28.txt b/port_src/core/src/test/resources/blackbox/upca-2/28.txt deleted file mode 100644 index 2598343..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/28.txt +++ /dev/null @@ -1 +0,0 @@ -752050200137 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/29.png b/port_src/core/src/test/resources/blackbox/upca-2/29.png deleted file mode 100644 index 235198b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/29.txt b/port_src/core/src/test/resources/blackbox/upca-2/29.txt deleted file mode 100644 index 2598343..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/29.txt +++ /dev/null @@ -1 +0,0 @@ -752050200137 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/30.png b/port_src/core/src/test/resources/blackbox/upca-2/30.png deleted file mode 100644 index 94d23a1..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/30.txt b/port_src/core/src/test/resources/blackbox/upca-2/30.txt deleted file mode 100644 index 2598343..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/30.txt +++ /dev/null @@ -1 +0,0 @@ -752050200137 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/31.png b/port_src/core/src/test/resources/blackbox/upca-2/31.png deleted file mode 100644 index 7c702e7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/31.txt b/port_src/core/src/test/resources/blackbox/upca-2/31.txt deleted file mode 100644 index 8889039..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/31.txt +++ /dev/null @@ -1 +0,0 @@ -899684001003 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/32.png b/port_src/core/src/test/resources/blackbox/upca-2/32.png deleted file mode 100644 index 03c64a8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/32.txt b/port_src/core/src/test/resources/blackbox/upca-2/32.txt deleted file mode 100644 index 8889039..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/32.txt +++ /dev/null @@ -1 +0,0 @@ -899684001003 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/33.png b/port_src/core/src/test/resources/blackbox/upca-2/33.png deleted file mode 100644 index cadb672..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/33.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/33.txt b/port_src/core/src/test/resources/blackbox/upca-2/33.txt deleted file mode 100644 index 8889039..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/33.txt +++ /dev/null @@ -1 +0,0 @@ -899684001003 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/34.png b/port_src/core/src/test/resources/blackbox/upca-2/34.png deleted file mode 100644 index bc7b1e8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/34.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/34.txt b/port_src/core/src/test/resources/blackbox/upca-2/34.txt deleted file mode 100644 index 8889039..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/34.txt +++ /dev/null @@ -1 +0,0 @@ -899684001003 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/35.png b/port_src/core/src/test/resources/blackbox/upca-2/35.png deleted file mode 100644 index b5c6467..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/35.txt b/port_src/core/src/test/resources/blackbox/upca-2/35.txt deleted file mode 100644 index 8889039..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/35.txt +++ /dev/null @@ -1 +0,0 @@ -899684001003 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/36.png b/port_src/core/src/test/resources/blackbox/upca-2/36.png deleted file mode 100644 index dabb687..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/36.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/36.txt b/port_src/core/src/test/resources/blackbox/upca-2/36.txt deleted file mode 100644 index 8889039..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/36.txt +++ /dev/null @@ -1 +0,0 @@ -899684001003 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/37.png b/port_src/core/src/test/resources/blackbox/upca-2/37.png deleted file mode 100644 index fdf58f0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/37.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/37.txt b/port_src/core/src/test/resources/blackbox/upca-2/37.txt deleted file mode 100644 index 8889039..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/37.txt +++ /dev/null @@ -1 +0,0 @@ -899684001003 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/38.png b/port_src/core/src/test/resources/blackbox/upca-2/38.png deleted file mode 100644 index 8ae3e83..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/38.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/38.txt b/port_src/core/src/test/resources/blackbox/upca-2/38.txt deleted file mode 100644 index 43914c7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/38.txt +++ /dev/null @@ -1 +0,0 @@ -012546619592 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/39.png b/port_src/core/src/test/resources/blackbox/upca-2/39.png deleted file mode 100644 index a96ede7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/39.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/39.txt b/port_src/core/src/test/resources/blackbox/upca-2/39.txt deleted file mode 100644 index 43914c7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/39.txt +++ /dev/null @@ -1 +0,0 @@ -012546619592 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/40.png b/port_src/core/src/test/resources/blackbox/upca-2/40.png deleted file mode 100644 index 64ebb43..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/40.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/40.txt b/port_src/core/src/test/resources/blackbox/upca-2/40.txt deleted file mode 100644 index 43914c7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/40.txt +++ /dev/null @@ -1 +0,0 @@ -012546619592 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/41.png b/port_src/core/src/test/resources/blackbox/upca-2/41.png deleted file mode 100644 index ee40c2c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/41.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/41.txt b/port_src/core/src/test/resources/blackbox/upca-2/41.txt deleted file mode 100644 index 43914c7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/41.txt +++ /dev/null @@ -1 +0,0 @@ -012546619592 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/42.png b/port_src/core/src/test/resources/blackbox/upca-2/42.png deleted file mode 100644 index de7c052..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/42.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/42.txt b/port_src/core/src/test/resources/blackbox/upca-2/42.txt deleted file mode 100644 index 43914c7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/42.txt +++ /dev/null @@ -1 +0,0 @@ -012546619592 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/43.png b/port_src/core/src/test/resources/blackbox/upca-2/43.png deleted file mode 100644 index 754859b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/43.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/43.txt b/port_src/core/src/test/resources/blackbox/upca-2/43.txt deleted file mode 100644 index 43914c7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/43.txt +++ /dev/null @@ -1 +0,0 @@ -012546619592 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/44.png b/port_src/core/src/test/resources/blackbox/upca-2/44.png deleted file mode 100644 index 6f90964..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/44.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/44.txt b/port_src/core/src/test/resources/blackbox/upca-2/44.txt deleted file mode 100644 index 43914c7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/44.txt +++ /dev/null @@ -1 +0,0 @@ -012546619592 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/45.png b/port_src/core/src/test/resources/blackbox/upca-2/45.png deleted file mode 100644 index a777b9b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/45.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/45.txt b/port_src/core/src/test/resources/blackbox/upca-2/45.txt deleted file mode 100644 index 2c50e36..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/45.txt +++ /dev/null @@ -1 +0,0 @@ -075720003259 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/46.png b/port_src/core/src/test/resources/blackbox/upca-2/46.png deleted file mode 100644 index abed441..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/46.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/46.txt b/port_src/core/src/test/resources/blackbox/upca-2/46.txt deleted file mode 100644 index 2c50e36..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/46.txt +++ /dev/null @@ -1 +0,0 @@ -075720003259 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/47.png b/port_src/core/src/test/resources/blackbox/upca-2/47.png deleted file mode 100644 index e027b74..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/47.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/47.txt b/port_src/core/src/test/resources/blackbox/upca-2/47.txt deleted file mode 100644 index 2c50e36..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/47.txt +++ /dev/null @@ -1 +0,0 @@ -075720003259 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/48.png b/port_src/core/src/test/resources/blackbox/upca-2/48.png deleted file mode 100644 index b75b7c0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/48.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/48.txt b/port_src/core/src/test/resources/blackbox/upca-2/48.txt deleted file mode 100644 index 2c50e36..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/48.txt +++ /dev/null @@ -1 +0,0 @@ -075720003259 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/49.png b/port_src/core/src/test/resources/blackbox/upca-2/49.png deleted file mode 100644 index 8131571..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/49.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/49.txt b/port_src/core/src/test/resources/blackbox/upca-2/49.txt deleted file mode 100644 index 2c50e36..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/49.txt +++ /dev/null @@ -1 +0,0 @@ -075720003259 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/50.png b/port_src/core/src/test/resources/blackbox/upca-2/50.png deleted file mode 100644 index cdea119..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/50.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/50.txt b/port_src/core/src/test/resources/blackbox/upca-2/50.txt deleted file mode 100644 index 2c50e36..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/50.txt +++ /dev/null @@ -1 +0,0 @@ -075720003259 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/51.png b/port_src/core/src/test/resources/blackbox/upca-2/51.png deleted file mode 100644 index 6637e56..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/51.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/51.txt b/port_src/core/src/test/resources/blackbox/upca-2/51.txt deleted file mode 100644 index 2c50e36..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/51.txt +++ /dev/null @@ -1 +0,0 @@ -075720003259 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-2/52.png b/port_src/core/src/test/resources/blackbox/upca-2/52.png deleted file mode 100644 index 611f01b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-2/52.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-2/52.txt b/port_src/core/src/test/resources/blackbox/upca-2/52.txt deleted file mode 100644 index 2c50e36..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-2/52.txt +++ /dev/null @@ -1 +0,0 @@ -075720003259 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/01.png b/port_src/core/src/test/resources/blackbox/upca-3/01.png deleted file mode 100644 index f05ca04..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/01.txt b/port_src/core/src/test/resources/blackbox/upca-3/01.txt deleted file mode 100644 index 6883994..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/01.txt +++ /dev/null @@ -1 +0,0 @@ -049000042566 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/02.png b/port_src/core/src/test/resources/blackbox/upca-3/02.png deleted file mode 100644 index 0ac9ac2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/02.txt b/port_src/core/src/test/resources/blackbox/upca-3/02.txt deleted file mode 100644 index 6883994..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/02.txt +++ /dev/null @@ -1 +0,0 @@ -049000042566 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/03.png b/port_src/core/src/test/resources/blackbox/upca-3/03.png deleted file mode 100644 index 7f41178..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/03.txt b/port_src/core/src/test/resources/blackbox/upca-3/03.txt deleted file mode 100644 index 6883994..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/03.txt +++ /dev/null @@ -1 +0,0 @@ -049000042566 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/04.png b/port_src/core/src/test/resources/blackbox/upca-3/04.png deleted file mode 100644 index 4508bdd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/04.txt b/port_src/core/src/test/resources/blackbox/upca-3/04.txt deleted file mode 100644 index 6883994..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/04.txt +++ /dev/null @@ -1 +0,0 @@ -049000042566 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/05.png b/port_src/core/src/test/resources/blackbox/upca-3/05.png deleted file mode 100644 index eaf4988..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/05.txt b/port_src/core/src/test/resources/blackbox/upca-3/05.txt deleted file mode 100644 index 6883994..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/05.txt +++ /dev/null @@ -1 +0,0 @@ -049000042566 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/06.png b/port_src/core/src/test/resources/blackbox/upca-3/06.png deleted file mode 100644 index ee606a8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/06.txt b/port_src/core/src/test/resources/blackbox/upca-3/06.txt deleted file mode 100644 index 6883994..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/06.txt +++ /dev/null @@ -1 +0,0 @@ -049000042566 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/07.png b/port_src/core/src/test/resources/blackbox/upca-3/07.png deleted file mode 100644 index e28b619..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/07.txt b/port_src/core/src/test/resources/blackbox/upca-3/07.txt deleted file mode 100644 index 6883994..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/07.txt +++ /dev/null @@ -1 +0,0 @@ -049000042566 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/08.png b/port_src/core/src/test/resources/blackbox/upca-3/08.png deleted file mode 100644 index 8e57927..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/08.txt b/port_src/core/src/test/resources/blackbox/upca-3/08.txt deleted file mode 100644 index 6883994..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/08.txt +++ /dev/null @@ -1 +0,0 @@ -049000042566 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/09.png b/port_src/core/src/test/resources/blackbox/upca-3/09.png deleted file mode 100644 index e83fca8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/09.txt b/port_src/core/src/test/resources/blackbox/upca-3/09.txt deleted file mode 100644 index 6883994..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/09.txt +++ /dev/null @@ -1 +0,0 @@ -049000042566 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/10.png b/port_src/core/src/test/resources/blackbox/upca-3/10.png deleted file mode 100644 index 7c3e68a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/10.txt b/port_src/core/src/test/resources/blackbox/upca-3/10.txt deleted file mode 100644 index 6883994..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/10.txt +++ /dev/null @@ -1 +0,0 @@ -049000042566 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/11.png b/port_src/core/src/test/resources/blackbox/upca-3/11.png deleted file mode 100644 index edf12c4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/11.txt b/port_src/core/src/test/resources/blackbox/upca-3/11.txt deleted file mode 100644 index 389d4d6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/11.txt +++ /dev/null @@ -1 +0,0 @@ -854818000116 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/12.png b/port_src/core/src/test/resources/blackbox/upca-3/12.png deleted file mode 100644 index 875ace6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/12.txt b/port_src/core/src/test/resources/blackbox/upca-3/12.txt deleted file mode 100644 index 389d4d6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/12.txt +++ /dev/null @@ -1 +0,0 @@ -854818000116 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/13.png b/port_src/core/src/test/resources/blackbox/upca-3/13.png deleted file mode 100644 index 9d6fe59..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/13.txt b/port_src/core/src/test/resources/blackbox/upca-3/13.txt deleted file mode 100644 index 389d4d6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/13.txt +++ /dev/null @@ -1 +0,0 @@ -854818000116 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/14.png b/port_src/core/src/test/resources/blackbox/upca-3/14.png deleted file mode 100644 index 2b66246..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/14.txt b/port_src/core/src/test/resources/blackbox/upca-3/14.txt deleted file mode 100644 index 389d4d6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/14.txt +++ /dev/null @@ -1 +0,0 @@ -854818000116 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/15.png b/port_src/core/src/test/resources/blackbox/upca-3/15.png deleted file mode 100644 index 9269a83..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/15.txt b/port_src/core/src/test/resources/blackbox/upca-3/15.txt deleted file mode 100644 index 389d4d6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/15.txt +++ /dev/null @@ -1 +0,0 @@ -854818000116 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/16.png b/port_src/core/src/test/resources/blackbox/upca-3/16.png deleted file mode 100644 index c554e5a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/16.txt b/port_src/core/src/test/resources/blackbox/upca-3/16.txt deleted file mode 100644 index 389d4d6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/16.txt +++ /dev/null @@ -1 +0,0 @@ -854818000116 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/17.png b/port_src/core/src/test/resources/blackbox/upca-3/17.png deleted file mode 100644 index 576fb35..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/17.txt b/port_src/core/src/test/resources/blackbox/upca-3/17.txt deleted file mode 100644 index 389d4d6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/17.txt +++ /dev/null @@ -1 +0,0 @@ -854818000116 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/18.png b/port_src/core/src/test/resources/blackbox/upca-3/18.png deleted file mode 100644 index db79853..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/18.txt b/port_src/core/src/test/resources/blackbox/upca-3/18.txt deleted file mode 100644 index 389d4d6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/18.txt +++ /dev/null @@ -1 +0,0 @@ -854818000116 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/19.png b/port_src/core/src/test/resources/blackbox/upca-3/19.png deleted file mode 100644 index 5370421..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/19.txt b/port_src/core/src/test/resources/blackbox/upca-3/19.txt deleted file mode 100644 index 389d4d6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/19.txt +++ /dev/null @@ -1 +0,0 @@ -854818000116 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/20.png b/port_src/core/src/test/resources/blackbox/upca-3/20.png deleted file mode 100644 index ba90d01..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/20.txt b/port_src/core/src/test/resources/blackbox/upca-3/20.txt deleted file mode 100644 index 389d4d6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/20.txt +++ /dev/null @@ -1 +0,0 @@ -854818000116 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-3/21.png b/port_src/core/src/test/resources/blackbox/upca-3/21.png deleted file mode 100644 index 9e81db3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-3/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-3/21.txt b/port_src/core/src/test/resources/blackbox/upca-3/21.txt deleted file mode 100644 index 389d4d6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-3/21.txt +++ /dev/null @@ -1 +0,0 @@ -854818000116 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/1.png b/port_src/core/src/test/resources/blackbox/upca-4/1.png deleted file mode 100644 index 59813c9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/1.txt b/port_src/core/src/test/resources/blackbox/upca-4/1.txt deleted file mode 100644 index 6759a5e..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/1.txt +++ /dev/null @@ -1 +0,0 @@ -023942431015 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/10.png b/port_src/core/src/test/resources/blackbox/upca-4/10.png deleted file mode 100644 index a319098..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/10.txt b/port_src/core/src/test/resources/blackbox/upca-4/10.txt deleted file mode 100644 index 3e76dac..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/10.txt +++ /dev/null @@ -1 +0,0 @@ -066721010995 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/11.png b/port_src/core/src/test/resources/blackbox/upca-4/11.png deleted file mode 100644 index f550ef7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/11.txt b/port_src/core/src/test/resources/blackbox/upca-4/11.txt deleted file mode 100644 index cef4bfc..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/11.txt +++ /dev/null @@ -1 +0,0 @@ -059290522143 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/12.png b/port_src/core/src/test/resources/blackbox/upca-4/12.png deleted file mode 100644 index 49c51e5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/12.txt b/port_src/core/src/test/resources/blackbox/upca-4/12.txt deleted file mode 100644 index 6491be4..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/12.txt +++ /dev/null @@ -1 +0,0 @@ -057961000228 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/13.png b/port_src/core/src/test/resources/blackbox/upca-4/13.png deleted file mode 100644 index 48e2d5e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/13.txt b/port_src/core/src/test/resources/blackbox/upca-4/13.txt deleted file mode 100644 index cef4bfc..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/13.txt +++ /dev/null @@ -1 +0,0 @@ -059290522143 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/14.png b/port_src/core/src/test/resources/blackbox/upca-4/14.png deleted file mode 100644 index 1ac10fc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/14.txt b/port_src/core/src/test/resources/blackbox/upca-4/14.txt deleted file mode 100644 index 14eb468..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/14.txt +++ /dev/null @@ -1 +0,0 @@ -066721017185 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/15.png b/port_src/core/src/test/resources/blackbox/upca-4/15.png deleted file mode 100644 index 895a5a4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/15.txt b/port_src/core/src/test/resources/blackbox/upca-4/15.txt deleted file mode 100644 index 8d6fe86..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/15.txt +++ /dev/null @@ -1 +0,0 @@ -059290571110 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/16.png b/port_src/core/src/test/resources/blackbox/upca-4/16.png deleted file mode 100644 index 1153abc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/16.txt b/port_src/core/src/test/resources/blackbox/upca-4/16.txt deleted file mode 100644 index 969c6d4..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/16.txt +++ /dev/null @@ -1 +0,0 @@ -067932000263 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/17.png b/port_src/core/src/test/resources/blackbox/upca-4/17.png deleted file mode 100644 index 932d863..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/17.txt b/port_src/core/src/test/resources/blackbox/upca-4/17.txt deleted file mode 100644 index 52692d4..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/17.txt +++ /dev/null @@ -1 +0,0 @@ -069000061015 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/18.png b/port_src/core/src/test/resources/blackbox/upca-4/18.png deleted file mode 100644 index df42f21..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/18.txt b/port_src/core/src/test/resources/blackbox/upca-4/18.txt deleted file mode 100644 index 3445d0e..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/18.txt +++ /dev/null @@ -1 +0,0 @@ -071691155775 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/19.png b/port_src/core/src/test/resources/blackbox/upca-4/19.png deleted file mode 100644 index eada78e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/19.txt b/port_src/core/src/test/resources/blackbox/upca-4/19.txt deleted file mode 100644 index b3b9f9c..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/19.txt +++ /dev/null @@ -1 +0,0 @@ -807648011401 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/2.png b/port_src/core/src/test/resources/blackbox/upca-4/2.png deleted file mode 100644 index bc77c6a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/2.txt b/port_src/core/src/test/resources/blackbox/upca-4/2.txt deleted file mode 100644 index 6759a5e..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/2.txt +++ /dev/null @@ -1 +0,0 @@ -023942431015 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/3.png b/port_src/core/src/test/resources/blackbox/upca-4/3.png deleted file mode 100644 index 92fdf2c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/3.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/3.txt b/port_src/core/src/test/resources/blackbox/upca-4/3.txt deleted file mode 100644 index 6759a5e..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/3.txt +++ /dev/null @@ -1 +0,0 @@ -023942431015 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/4.png b/port_src/core/src/test/resources/blackbox/upca-4/4.png deleted file mode 100644 index abdee5e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/4.txt b/port_src/core/src/test/resources/blackbox/upca-4/4.txt deleted file mode 100644 index 6759a5e..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/4.txt +++ /dev/null @@ -1 +0,0 @@ -023942431015 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/5.png b/port_src/core/src/test/resources/blackbox/upca-4/5.png deleted file mode 100644 index cb717cb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/5.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/5.txt b/port_src/core/src/test/resources/blackbox/upca-4/5.txt deleted file mode 100644 index 6759a5e..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/5.txt +++ /dev/null @@ -1 +0,0 @@ -023942431015 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/6.png b/port_src/core/src/test/resources/blackbox/upca-4/6.png deleted file mode 100644 index a426f7c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/6.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/6.txt b/port_src/core/src/test/resources/blackbox/upca-4/6.txt deleted file mode 100644 index 6759a5e..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/6.txt +++ /dev/null @@ -1 +0,0 @@ -023942431015 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/7.png b/port_src/core/src/test/resources/blackbox/upca-4/7.png deleted file mode 100644 index c37eee2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/7.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/7.txt b/port_src/core/src/test/resources/blackbox/upca-4/7.txt deleted file mode 100644 index 6759a5e..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/7.txt +++ /dev/null @@ -1 +0,0 @@ -023942431015 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/8.png b/port_src/core/src/test/resources/blackbox/upca-4/8.png deleted file mode 100644 index d09bc83..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/8.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/8.txt b/port_src/core/src/test/resources/blackbox/upca-4/8.txt deleted file mode 100644 index 29cffd2..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/8.txt +++ /dev/null @@ -1 +0,0 @@ -060410049235 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-4/9.png b/port_src/core/src/test/resources/blackbox/upca-4/9.png deleted file mode 100644 index d3c9ba2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-4/9.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-4/9.txt b/port_src/core/src/test/resources/blackbox/upca-4/9.txt deleted file mode 100644 index 29cffd2..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-4/9.txt +++ /dev/null @@ -1 +0,0 @@ -060410049235 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/01.png b/port_src/core/src/test/resources/blackbox/upca-5/01.png deleted file mode 100755 index 5145f5d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/01.txt b/port_src/core/src/test/resources/blackbox/upca-5/01.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/01.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/02.png b/port_src/core/src/test/resources/blackbox/upca-5/02.png deleted file mode 100755 index 78bf767..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/02.txt b/port_src/core/src/test/resources/blackbox/upca-5/02.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/02.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/03.png b/port_src/core/src/test/resources/blackbox/upca-5/03.png deleted file mode 100755 index 04408f5..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/03.txt b/port_src/core/src/test/resources/blackbox/upca-5/03.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/03.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/04.png b/port_src/core/src/test/resources/blackbox/upca-5/04.png deleted file mode 100755 index 878ed4c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/04.txt b/port_src/core/src/test/resources/blackbox/upca-5/04.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/04.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/05.png b/port_src/core/src/test/resources/blackbox/upca-5/05.png deleted file mode 100755 index 537a138..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/05.txt b/port_src/core/src/test/resources/blackbox/upca-5/05.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/05.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/06.png b/port_src/core/src/test/resources/blackbox/upca-5/06.png deleted file mode 100755 index 6e46ffe..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/06.txt b/port_src/core/src/test/resources/blackbox/upca-5/06.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/06.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/07.png b/port_src/core/src/test/resources/blackbox/upca-5/07.png deleted file mode 100755 index cd5edc3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/07.txt b/port_src/core/src/test/resources/blackbox/upca-5/07.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/07.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/08.png b/port_src/core/src/test/resources/blackbox/upca-5/08.png deleted file mode 100755 index 0e08383..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/08.txt b/port_src/core/src/test/resources/blackbox/upca-5/08.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/08.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/09.png b/port_src/core/src/test/resources/blackbox/upca-5/09.png deleted file mode 100755 index f736834..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/09.txt b/port_src/core/src/test/resources/blackbox/upca-5/09.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/09.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/10.png b/port_src/core/src/test/resources/blackbox/upca-5/10.png deleted file mode 100755 index 126330e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/10.txt b/port_src/core/src/test/resources/blackbox/upca-5/10.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/10.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/11.png b/port_src/core/src/test/resources/blackbox/upca-5/11.png deleted file mode 100755 index 5cd11f0..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/11.txt b/port_src/core/src/test/resources/blackbox/upca-5/11.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/11.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/12.png b/port_src/core/src/test/resources/blackbox/upca-5/12.png deleted file mode 100755 index bb2a93a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/12.txt b/port_src/core/src/test/resources/blackbox/upca-5/12.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/12.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/13.png b/port_src/core/src/test/resources/blackbox/upca-5/13.png deleted file mode 100755 index 5a1f344..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/13.txt b/port_src/core/src/test/resources/blackbox/upca-5/13.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/13.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/14.png b/port_src/core/src/test/resources/blackbox/upca-5/14.png deleted file mode 100755 index 1a23917..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/14.txt b/port_src/core/src/test/resources/blackbox/upca-5/14.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/14.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/15.png b/port_src/core/src/test/resources/blackbox/upca-5/15.png deleted file mode 100755 index fa3466c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/15.txt b/port_src/core/src/test/resources/blackbox/upca-5/15.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/15.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/16.png b/port_src/core/src/test/resources/blackbox/upca-5/16.png deleted file mode 100755 index 202bd01..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/16.txt b/port_src/core/src/test/resources/blackbox/upca-5/16.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/16.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/17.png b/port_src/core/src/test/resources/blackbox/upca-5/17.png deleted file mode 100755 index 3ad9d42..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/17.txt b/port_src/core/src/test/resources/blackbox/upca-5/17.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/17.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/18.png b/port_src/core/src/test/resources/blackbox/upca-5/18.png deleted file mode 100755 index 9f70d9f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/18.txt b/port_src/core/src/test/resources/blackbox/upca-5/18.txt deleted file mode 100644 index 108f623..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/18.txt +++ /dev/null @@ -1 +0,0 @@ -312547701310 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/19.png b/port_src/core/src/test/resources/blackbox/upca-5/19.png deleted file mode 100755 index e7f4abc..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/19.txt b/port_src/core/src/test/resources/blackbox/upca-5/19.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/19.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/20.png b/port_src/core/src/test/resources/blackbox/upca-5/20.png deleted file mode 100755 index 5b22bca..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/20.txt b/port_src/core/src/test/resources/blackbox/upca-5/20.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/20.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/21.png b/port_src/core/src/test/resources/blackbox/upca-5/21.png deleted file mode 100755 index 5d9b440..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/21.txt b/port_src/core/src/test/resources/blackbox/upca-5/21.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/21.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/22.png b/port_src/core/src/test/resources/blackbox/upca-5/22.png deleted file mode 100755 index 0262598..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/22.txt b/port_src/core/src/test/resources/blackbox/upca-5/22.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/22.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/23.png b/port_src/core/src/test/resources/blackbox/upca-5/23.png deleted file mode 100755 index 90eb50e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/23.txt b/port_src/core/src/test/resources/blackbox/upca-5/23.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/23.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/24.png b/port_src/core/src/test/resources/blackbox/upca-5/24.png deleted file mode 100755 index eb3aa47..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/24.txt b/port_src/core/src/test/resources/blackbox/upca-5/24.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/24.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/25.png b/port_src/core/src/test/resources/blackbox/upca-5/25.png deleted file mode 100755 index 95ff85c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/25.txt b/port_src/core/src/test/resources/blackbox/upca-5/25.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/25.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/26.png b/port_src/core/src/test/resources/blackbox/upca-5/26.png deleted file mode 100755 index 831264e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/26.txt b/port_src/core/src/test/resources/blackbox/upca-5/26.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/26.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/27.png b/port_src/core/src/test/resources/blackbox/upca-5/27.png deleted file mode 100755 index 9e561a8..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/27.txt b/port_src/core/src/test/resources/blackbox/upca-5/27.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/27.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/28.png b/port_src/core/src/test/resources/blackbox/upca-5/28.png deleted file mode 100755 index 04c3a96..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/28.txt b/port_src/core/src/test/resources/blackbox/upca-5/28.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/28.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/29.png b/port_src/core/src/test/resources/blackbox/upca-5/29.png deleted file mode 100755 index c6f668f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/29.txt b/port_src/core/src/test/resources/blackbox/upca-5/29.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/29.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/30.png b/port_src/core/src/test/resources/blackbox/upca-5/30.png deleted file mode 100755 index 0995fff..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/30.txt b/port_src/core/src/test/resources/blackbox/upca-5/30.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/30.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/31.png b/port_src/core/src/test/resources/blackbox/upca-5/31.png deleted file mode 100755 index 85416fb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/31.txt b/port_src/core/src/test/resources/blackbox/upca-5/31.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/31.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/32.png b/port_src/core/src/test/resources/blackbox/upca-5/32.png deleted file mode 100755 index 2842cce..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/32.txt b/port_src/core/src/test/resources/blackbox/upca-5/32.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/32.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/33.png b/port_src/core/src/test/resources/blackbox/upca-5/33.png deleted file mode 100755 index f79dbd9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/33.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/33.txt b/port_src/core/src/test/resources/blackbox/upca-5/33.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/33.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/34.png b/port_src/core/src/test/resources/blackbox/upca-5/34.png deleted file mode 100755 index a37435b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/34.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/34.txt b/port_src/core/src/test/resources/blackbox/upca-5/34.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/34.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-5/35.png b/port_src/core/src/test/resources/blackbox/upca-5/35.png deleted file mode 100755 index 8751c51..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-5/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-5/35.txt b/port_src/core/src/test/resources/blackbox/upca-5/35.txt deleted file mode 100644 index 5546cb7..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-5/35.txt +++ /dev/null @@ -1 +0,0 @@ -625034201058 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/01.png b/port_src/core/src/test/resources/blackbox/upca-6/01.png deleted file mode 100755 index 38c8dd4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/01.txt b/port_src/core/src/test/resources/blackbox/upca-6/01.txt deleted file mode 100644 index 37e4df6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/01.txt +++ /dev/null @@ -1 +0,0 @@ -071831007995 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/02.png b/port_src/core/src/test/resources/blackbox/upca-6/02.png deleted file mode 100755 index d11d067..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/02.txt b/port_src/core/src/test/resources/blackbox/upca-6/02.txt deleted file mode 100644 index 37e4df6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/02.txt +++ /dev/null @@ -1 +0,0 @@ -071831007995 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/03.png b/port_src/core/src/test/resources/blackbox/upca-6/03.png deleted file mode 100755 index 3377da7..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/03.txt b/port_src/core/src/test/resources/blackbox/upca-6/03.txt deleted file mode 100644 index 37e4df6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/03.txt +++ /dev/null @@ -1 +0,0 @@ -071831007995 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/04.png b/port_src/core/src/test/resources/blackbox/upca-6/04.png deleted file mode 100755 index c544d1a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/04.txt b/port_src/core/src/test/resources/blackbox/upca-6/04.txt deleted file mode 100644 index 37e4df6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/04.txt +++ /dev/null @@ -1 +0,0 @@ -071831007995 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/05.png b/port_src/core/src/test/resources/blackbox/upca-6/05.png deleted file mode 100755 index 1097850..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/05.txt b/port_src/core/src/test/resources/blackbox/upca-6/05.txt deleted file mode 100644 index 37e4df6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/05.txt +++ /dev/null @@ -1 +0,0 @@ -071831007995 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/06.png b/port_src/core/src/test/resources/blackbox/upca-6/06.png deleted file mode 100755 index 52953f4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/06.txt b/port_src/core/src/test/resources/blackbox/upca-6/06.txt deleted file mode 100644 index 37e4df6..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/06.txt +++ /dev/null @@ -1 +0,0 @@ -071831007995 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/07.png b/port_src/core/src/test/resources/blackbox/upca-6/07.png deleted file mode 100755 index 66be786..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/07.txt b/port_src/core/src/test/resources/blackbox/upca-6/07.txt deleted file mode 100644 index fcc02a0..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/07.txt +++ /dev/null @@ -1 +0,0 @@ -605482330012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/08.png b/port_src/core/src/test/resources/blackbox/upca-6/08.png deleted file mode 100755 index d02f1f9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/08.txt b/port_src/core/src/test/resources/blackbox/upca-6/08.txt deleted file mode 100644 index fcc02a0..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/08.txt +++ /dev/null @@ -1 +0,0 @@ -605482330012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/09.png b/port_src/core/src/test/resources/blackbox/upca-6/09.png deleted file mode 100755 index 119f93f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/09.txt b/port_src/core/src/test/resources/blackbox/upca-6/09.txt deleted file mode 100644 index fcc02a0..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/09.txt +++ /dev/null @@ -1 +0,0 @@ -605482330012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/10.png b/port_src/core/src/test/resources/blackbox/upca-6/10.png deleted file mode 100755 index 0f6d463..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/10.txt b/port_src/core/src/test/resources/blackbox/upca-6/10.txt deleted file mode 100644 index fcc02a0..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/10.txt +++ /dev/null @@ -1 +0,0 @@ -605482330012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/11.png b/port_src/core/src/test/resources/blackbox/upca-6/11.png deleted file mode 100755 index 7b1ae81..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/11.txt b/port_src/core/src/test/resources/blackbox/upca-6/11.txt deleted file mode 100644 index fcc02a0..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/11.txt +++ /dev/null @@ -1 +0,0 @@ -605482330012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/12.png b/port_src/core/src/test/resources/blackbox/upca-6/12.png deleted file mode 100755 index da5a150..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/12.txt b/port_src/core/src/test/resources/blackbox/upca-6/12.txt deleted file mode 100644 index fcc02a0..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/12.txt +++ /dev/null @@ -1 +0,0 @@ -605482330012 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/13.png b/port_src/core/src/test/resources/blackbox/upca-6/13.png deleted file mode 100755 index 425ab48..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/13.txt b/port_src/core/src/test/resources/blackbox/upca-6/13.txt deleted file mode 100644 index 359b01d..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/13.txt +++ /dev/null @@ -1 +0,0 @@ -073333531084 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/14.png b/port_src/core/src/test/resources/blackbox/upca-6/14.png deleted file mode 100755 index 2d5bb4b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/14.txt b/port_src/core/src/test/resources/blackbox/upca-6/14.txt deleted file mode 100644 index 359b01d..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/14.txt +++ /dev/null @@ -1 +0,0 @@ -073333531084 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/15.png b/port_src/core/src/test/resources/blackbox/upca-6/15.png deleted file mode 100755 index 761f196..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/15.txt b/port_src/core/src/test/resources/blackbox/upca-6/15.txt deleted file mode 100644 index 359b01d..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/15.txt +++ /dev/null @@ -1 +0,0 @@ -073333531084 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/16.png b/port_src/core/src/test/resources/blackbox/upca-6/16.png deleted file mode 100755 index 0fb2e9e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/16.txt b/port_src/core/src/test/resources/blackbox/upca-6/16.txt deleted file mode 100644 index 359b01d..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/16.txt +++ /dev/null @@ -1 +0,0 @@ -073333531084 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/17.png b/port_src/core/src/test/resources/blackbox/upca-6/17.png deleted file mode 100755 index 5940d3c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/17.txt b/port_src/core/src/test/resources/blackbox/upca-6/17.txt deleted file mode 100644 index 359b01d..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/17.txt +++ /dev/null @@ -1 +0,0 @@ -073333531084 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/18.png b/port_src/core/src/test/resources/blackbox/upca-6/18.png deleted file mode 100755 index 926f1d3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/18.txt b/port_src/core/src/test/resources/blackbox/upca-6/18.txt deleted file mode 100644 index 359b01d..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/18.txt +++ /dev/null @@ -1 +0,0 @@ -073333531084 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upca-6/19.png b/port_src/core/src/test/resources/blackbox/upca-6/19.png deleted file mode 100755 index 0589049..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upca-6/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upca-6/19.txt b/port_src/core/src/test/resources/blackbox/upca-6/19.txt deleted file mode 100644 index 359b01d..0000000 --- a/port_src/core/src/test/resources/blackbox/upca-6/19.txt +++ /dev/null @@ -1 +0,0 @@ -073333531084 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-1/1.png b/port_src/core/src/test/resources/blackbox/upce-1/1.png deleted file mode 100644 index ada741f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-1/1.txt b/port_src/core/src/test/resources/blackbox/upce-1/1.txt deleted file mode 100644 index ff99f0e..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -01234565 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-1/2.png b/port_src/core/src/test/resources/blackbox/upce-1/2.png deleted file mode 100644 index dc060f2..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-1/2.txt b/port_src/core/src/test/resources/blackbox/upce-1/2.txt deleted file mode 100644 index f17aea9..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-1/2.txt +++ /dev/null @@ -1 +0,0 @@ -00123457 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-1/4.png b/port_src/core/src/test/resources/blackbox/upce-1/4.png deleted file mode 100644 index 64451b3..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-1/4.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-1/4.txt b/port_src/core/src/test/resources/blackbox/upce-1/4.txt deleted file mode 100644 index 8e866d2..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-1/4.txt +++ /dev/null @@ -1 +0,0 @@ -01234531 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/01.png b/port_src/core/src/test/resources/blackbox/upce-2/01.png deleted file mode 100644 index 6adeb46..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/01.txt b/port_src/core/src/test/resources/blackbox/upce-2/01.txt deleted file mode 100644 index 142011d..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/01.txt +++ /dev/null @@ -1 +0,0 @@ -05096893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/02.png b/port_src/core/src/test/resources/blackbox/upce-2/02.png deleted file mode 100644 index eadeec6..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/02.txt b/port_src/core/src/test/resources/blackbox/upce-2/02.txt deleted file mode 100644 index 142011d..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/02.txt +++ /dev/null @@ -1 +0,0 @@ -05096893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/03.png b/port_src/core/src/test/resources/blackbox/upce-2/03.png deleted file mode 100644 index 8b13bad..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/03.txt b/port_src/core/src/test/resources/blackbox/upce-2/03.txt deleted file mode 100644 index 142011d..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/03.txt +++ /dev/null @@ -1 +0,0 @@ -05096893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/04.png b/port_src/core/src/test/resources/blackbox/upce-2/04.png deleted file mode 100644 index 0326beb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/04.txt b/port_src/core/src/test/resources/blackbox/upce-2/04.txt deleted file mode 100644 index 142011d..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/04.txt +++ /dev/null @@ -1 +0,0 @@ -05096893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/05.png b/port_src/core/src/test/resources/blackbox/upce-2/05.png deleted file mode 100644 index caf4459..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/05.txt b/port_src/core/src/test/resources/blackbox/upce-2/05.txt deleted file mode 100644 index 142011d..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/05.txt +++ /dev/null @@ -1 +0,0 @@ -05096893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/06.png b/port_src/core/src/test/resources/blackbox/upce-2/06.png deleted file mode 100644 index 31e41de..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/06.txt b/port_src/core/src/test/resources/blackbox/upce-2/06.txt deleted file mode 100644 index 142011d..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/06.txt +++ /dev/null @@ -1 +0,0 @@ -05096893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/07.png b/port_src/core/src/test/resources/blackbox/upce-2/07.png deleted file mode 100644 index e165266..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/07.txt b/port_src/core/src/test/resources/blackbox/upce-2/07.txt deleted file mode 100644 index 142011d..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/07.txt +++ /dev/null @@ -1 +0,0 @@ -05096893 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/08.png b/port_src/core/src/test/resources/blackbox/upce-2/08.png deleted file mode 100644 index 1b82632..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/08.txt b/port_src/core/src/test/resources/blackbox/upce-2/08.txt deleted file mode 100644 index 5d7eb42..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/08.txt +++ /dev/null @@ -1 +0,0 @@ -04963406 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/09.png b/port_src/core/src/test/resources/blackbox/upce-2/09.png deleted file mode 100644 index fa0b17f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/09.txt b/port_src/core/src/test/resources/blackbox/upce-2/09.txt deleted file mode 100644 index 5d7eb42..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/09.txt +++ /dev/null @@ -1 +0,0 @@ -04963406 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/10.png b/port_src/core/src/test/resources/blackbox/upce-2/10.png deleted file mode 100644 index 7310fbd..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/10.txt b/port_src/core/src/test/resources/blackbox/upce-2/10.txt deleted file mode 100644 index 5d7eb42..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/10.txt +++ /dev/null @@ -1 +0,0 @@ -04963406 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/11.png b/port_src/core/src/test/resources/blackbox/upce-2/11.png deleted file mode 100644 index d3dbbfe..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/11.txt b/port_src/core/src/test/resources/blackbox/upce-2/11.txt deleted file mode 100644 index 5d7eb42..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/11.txt +++ /dev/null @@ -1 +0,0 @@ -04963406 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/12.png b/port_src/core/src/test/resources/blackbox/upce-2/12.png deleted file mode 100644 index c139274..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/12.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/12.txt b/port_src/core/src/test/resources/blackbox/upce-2/12.txt deleted file mode 100644 index 5d7eb42..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/12.txt +++ /dev/null @@ -1 +0,0 @@ -04963406 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/13.png b/port_src/core/src/test/resources/blackbox/upce-2/13.png deleted file mode 100644 index 12bdbfe..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/13.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/13.txt b/port_src/core/src/test/resources/blackbox/upce-2/13.txt deleted file mode 100644 index 5d7eb42..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/13.txt +++ /dev/null @@ -1 +0,0 @@ -04963406 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/14.png b/port_src/core/src/test/resources/blackbox/upce-2/14.png deleted file mode 100644 index ede5239..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/14.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/14.txt b/port_src/core/src/test/resources/blackbox/upce-2/14.txt deleted file mode 100644 index 5d7eb42..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/14.txt +++ /dev/null @@ -1 +0,0 @@ -04963406 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/15.png b/port_src/core/src/test/resources/blackbox/upce-2/15.png deleted file mode 100644 index 150154e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/15.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/15.txt b/port_src/core/src/test/resources/blackbox/upce-2/15.txt deleted file mode 100644 index 5d7eb42..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/15.txt +++ /dev/null @@ -1 +0,0 @@ -04963406 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/16.png b/port_src/core/src/test/resources/blackbox/upce-2/16.png deleted file mode 100644 index c248806..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/16.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/16.txt b/port_src/core/src/test/resources/blackbox/upce-2/16.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/16.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/17.png b/port_src/core/src/test/resources/blackbox/upce-2/17.png deleted file mode 100644 index 4ee5519..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/17.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/17.txt b/port_src/core/src/test/resources/blackbox/upce-2/17.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/17.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/18.png b/port_src/core/src/test/resources/blackbox/upce-2/18.png deleted file mode 100644 index 2a30921..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/18.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/18.txt b/port_src/core/src/test/resources/blackbox/upce-2/18.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/18.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/19.png b/port_src/core/src/test/resources/blackbox/upce-2/19.png deleted file mode 100644 index d4b6ffb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/19.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/19.txt b/port_src/core/src/test/resources/blackbox/upce-2/19.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/19.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/20.png b/port_src/core/src/test/resources/blackbox/upce-2/20.png deleted file mode 100644 index 1a6ec9e..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/20.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/20.txt b/port_src/core/src/test/resources/blackbox/upce-2/20.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/20.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/21.png b/port_src/core/src/test/resources/blackbox/upce-2/21.png deleted file mode 100644 index 4ffc238..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/21.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/21.txt b/port_src/core/src/test/resources/blackbox/upce-2/21.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/21.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/22.png b/port_src/core/src/test/resources/blackbox/upce-2/22.png deleted file mode 100644 index 371a347..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/22.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/22.txt b/port_src/core/src/test/resources/blackbox/upce-2/22.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/22.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/23.png b/port_src/core/src/test/resources/blackbox/upce-2/23.png deleted file mode 100644 index 8aeda39..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/23.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/23.txt b/port_src/core/src/test/resources/blackbox/upce-2/23.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/23.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/24.png b/port_src/core/src/test/resources/blackbox/upce-2/24.png deleted file mode 100644 index 963632b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/24.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/24.txt b/port_src/core/src/test/resources/blackbox/upce-2/24.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/24.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/25.png b/port_src/core/src/test/resources/blackbox/upce-2/25.png deleted file mode 100644 index 6b42977..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/25.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/25.txt b/port_src/core/src/test/resources/blackbox/upce-2/25.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/25.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/26.png b/port_src/core/src/test/resources/blackbox/upce-2/26.png deleted file mode 100644 index 23664e9..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/26.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/26.txt b/port_src/core/src/test/resources/blackbox/upce-2/26.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/26.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/27.png b/port_src/core/src/test/resources/blackbox/upce-2/27.png deleted file mode 100644 index e768073..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/27.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/27.txt b/port_src/core/src/test/resources/blackbox/upce-2/27.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/27.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/28.png b/port_src/core/src/test/resources/blackbox/upce-2/28.png deleted file mode 100644 index 68a5ff4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/28.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/28.txt b/port_src/core/src/test/resources/blackbox/upce-2/28.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/28.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/29.png b/port_src/core/src/test/resources/blackbox/upce-2/29.png deleted file mode 100644 index ed02c34..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/29.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/29.txt b/port_src/core/src/test/resources/blackbox/upce-2/29.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/29.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/30.png b/port_src/core/src/test/resources/blackbox/upce-2/30.png deleted file mode 100644 index 1ce103d..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/30.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/30.txt b/port_src/core/src/test/resources/blackbox/upce-2/30.txt deleted file mode 100644 index 1c6c6df..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/30.txt +++ /dev/null @@ -1 +0,0 @@ -04124498 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/31.png b/port_src/core/src/test/resources/blackbox/upce-2/31.png deleted file mode 100644 index bce80ae..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/31.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/31.txt b/port_src/core/src/test/resources/blackbox/upce-2/31.txt deleted file mode 100644 index e9c1b63..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/31.txt +++ /dev/null @@ -1 +0,0 @@ -01264904 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/32.png b/port_src/core/src/test/resources/blackbox/upce-2/32.png deleted file mode 100644 index 9e06adf..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/32.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/32.txt b/port_src/core/src/test/resources/blackbox/upce-2/32.txt deleted file mode 100644 index e9c1b63..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/32.txt +++ /dev/null @@ -1 +0,0 @@ -01264904 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/33.png b/port_src/core/src/test/resources/blackbox/upce-2/33.png deleted file mode 100644 index d99d813..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/33.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/33.txt b/port_src/core/src/test/resources/blackbox/upce-2/33.txt deleted file mode 100644 index e9c1b63..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/33.txt +++ /dev/null @@ -1 +0,0 @@ -01264904 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/34.png b/port_src/core/src/test/resources/blackbox/upce-2/34.png deleted file mode 100644 index 48bf307..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/34.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/34.txt b/port_src/core/src/test/resources/blackbox/upce-2/34.txt deleted file mode 100644 index e9c1b63..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/34.txt +++ /dev/null @@ -1 +0,0 @@ -01264904 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/35.png b/port_src/core/src/test/resources/blackbox/upce-2/35.png deleted file mode 100644 index b074973..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/35.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/35.txt b/port_src/core/src/test/resources/blackbox/upce-2/35.txt deleted file mode 100644 index e9c1b63..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/35.txt +++ /dev/null @@ -1 +0,0 @@ -01264904 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/36.png b/port_src/core/src/test/resources/blackbox/upce-2/36.png deleted file mode 100644 index bfe64aa..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/36.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/36.txt b/port_src/core/src/test/resources/blackbox/upce-2/36.txt deleted file mode 100644 index e9c1b63..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/36.txt +++ /dev/null @@ -1 +0,0 @@ -01264904 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/37.png b/port_src/core/src/test/resources/blackbox/upce-2/37.png deleted file mode 100644 index 14dde54..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/37.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/37.txt b/port_src/core/src/test/resources/blackbox/upce-2/37.txt deleted file mode 100644 index e9c1b63..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/37.txt +++ /dev/null @@ -1 +0,0 @@ -01264904 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/38.png b/port_src/core/src/test/resources/blackbox/upce-2/38.png deleted file mode 100644 index f3a16e4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/38.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/38.txt b/port_src/core/src/test/resources/blackbox/upce-2/38.txt deleted file mode 100644 index e9c1b63..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/38.txt +++ /dev/null @@ -1 +0,0 @@ -01264904 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/39.png b/port_src/core/src/test/resources/blackbox/upce-2/39.png deleted file mode 100644 index 411d57c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/39.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/39.txt b/port_src/core/src/test/resources/blackbox/upce-2/39.txt deleted file mode 100644 index e9c1b63..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/39.txt +++ /dev/null @@ -1 +0,0 @@ -01264904 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/40.png b/port_src/core/src/test/resources/blackbox/upce-2/40.png deleted file mode 100644 index 5084b0a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/40.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/40.txt b/port_src/core/src/test/resources/blackbox/upce-2/40.txt deleted file mode 100644 index e9c1b63..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/40.txt +++ /dev/null @@ -1 +0,0 @@ -01264904 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-2/41.png b/port_src/core/src/test/resources/blackbox/upce-2/41.png deleted file mode 100644 index 39f8254..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-2/41.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-2/41.txt b/port_src/core/src/test/resources/blackbox/upce-2/41.txt deleted file mode 100644 index e9c1b63..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-2/41.txt +++ /dev/null @@ -1 +0,0 @@ -01264904 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-3/01.png b/port_src/core/src/test/resources/blackbox/upce-3/01.png deleted file mode 100644 index d545a18..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-3/01.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-3/01.txt b/port_src/core/src/test/resources/blackbox/upce-3/01.txt deleted file mode 100644 index e33c450..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-3/01.txt +++ /dev/null @@ -1 +0,0 @@ -04965802 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-3/02.png b/port_src/core/src/test/resources/blackbox/upce-3/02.png deleted file mode 100644 index bf53207..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-3/02.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-3/02.txt b/port_src/core/src/test/resources/blackbox/upce-3/02.txt deleted file mode 100644 index e33c450..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-3/02.txt +++ /dev/null @@ -1 +0,0 @@ -04965802 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-3/03.png b/port_src/core/src/test/resources/blackbox/upce-3/03.png deleted file mode 100644 index 2911a4f..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-3/03.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-3/03.txt b/port_src/core/src/test/resources/blackbox/upce-3/03.txt deleted file mode 100644 index e33c450..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-3/03.txt +++ /dev/null @@ -1 +0,0 @@ -04965802 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-3/04.png b/port_src/core/src/test/resources/blackbox/upce-3/04.png deleted file mode 100644 index cfac890..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-3/04.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-3/04.txt b/port_src/core/src/test/resources/blackbox/upce-3/04.txt deleted file mode 100644 index e33c450..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-3/04.txt +++ /dev/null @@ -1 +0,0 @@ -04965802 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-3/05.png b/port_src/core/src/test/resources/blackbox/upce-3/05.png deleted file mode 100644 index 8ba2136..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-3/05.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-3/05.txt b/port_src/core/src/test/resources/blackbox/upce-3/05.txt deleted file mode 100644 index e33c450..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-3/05.txt +++ /dev/null @@ -1 +0,0 @@ -04965802 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-3/06.png b/port_src/core/src/test/resources/blackbox/upce-3/06.png deleted file mode 100644 index 7a760f4..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-3/06.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-3/06.txt b/port_src/core/src/test/resources/blackbox/upce-3/06.txt deleted file mode 100644 index e33c450..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-3/06.txt +++ /dev/null @@ -1 +0,0 @@ -04965802 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-3/07.png b/port_src/core/src/test/resources/blackbox/upce-3/07.png deleted file mode 100644 index 53cf17b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-3/07.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-3/07.txt b/port_src/core/src/test/resources/blackbox/upce-3/07.txt deleted file mode 100644 index e33c450..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-3/07.txt +++ /dev/null @@ -1 +0,0 @@ -04965802 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-3/08.png b/port_src/core/src/test/resources/blackbox/upce-3/08.png deleted file mode 100644 index 2105281..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-3/08.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-3/08.txt b/port_src/core/src/test/resources/blackbox/upce-3/08.txt deleted file mode 100644 index e33c450..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-3/08.txt +++ /dev/null @@ -1 +0,0 @@ -04965802 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-3/09.png b/port_src/core/src/test/resources/blackbox/upce-3/09.png deleted file mode 100644 index 96c3157..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-3/09.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-3/09.txt b/port_src/core/src/test/resources/blackbox/upce-3/09.txt deleted file mode 100644 index e33c450..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-3/09.txt +++ /dev/null @@ -1 +0,0 @@ -04965802 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-3/10.png b/port_src/core/src/test/resources/blackbox/upce-3/10.png deleted file mode 100644 index c47671c..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-3/10.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-3/10.txt b/port_src/core/src/test/resources/blackbox/upce-3/10.txt deleted file mode 100644 index e33c450..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-3/10.txt +++ /dev/null @@ -1 +0,0 @@ -04965802 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upce-3/11.png b/port_src/core/src/test/resources/blackbox/upce-3/11.png deleted file mode 100644 index a6674eb..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upce-3/11.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upce-3/11.txt b/port_src/core/src/test/resources/blackbox/upce-3/11.txt deleted file mode 100644 index e33c450..0000000 --- a/port_src/core/src/test/resources/blackbox/upce-3/11.txt +++ /dev/null @@ -1 +0,0 @@ -04965802 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upcean-extension-1/1.metadata.txt b/port_src/core/src/test/resources/blackbox/upcean-extension-1/1.metadata.txt deleted file mode 100644 index 6ad3f36..0000000 --- a/port_src/core/src/test/resources/blackbox/upcean-extension-1/1.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SUGGESTED_PRICE=$12.99 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upcean-extension-1/1.png b/port_src/core/src/test/resources/blackbox/upcean-extension-1/1.png deleted file mode 100644 index 33d0a6b..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upcean-extension-1/1.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upcean-extension-1/1.txt b/port_src/core/src/test/resources/blackbox/upcean-extension-1/1.txt deleted file mode 100644 index 101471a..0000000 --- a/port_src/core/src/test/resources/blackbox/upcean-extension-1/1.txt +++ /dev/null @@ -1 +0,0 @@ -9780735200449 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upcean-extension-1/2.metadata.txt b/port_src/core/src/test/resources/blackbox/upcean-extension-1/2.metadata.txt deleted file mode 100644 index e14808d..0000000 --- a/port_src/core/src/test/resources/blackbox/upcean-extension-1/2.metadata.txt +++ /dev/null @@ -1 +0,0 @@ -SUGGESTED_PRICE=$24.95 \ No newline at end of file diff --git a/port_src/core/src/test/resources/blackbox/upcean-extension-1/2.png b/port_src/core/src/test/resources/blackbox/upcean-extension-1/2.png deleted file mode 100644 index dcd092a..0000000 Binary files a/port_src/core/src/test/resources/blackbox/upcean-extension-1/2.png and /dev/null differ diff --git a/port_src/core/src/test/resources/blackbox/upcean-extension-1/2.txt b/port_src/core/src/test/resources/blackbox/upcean-extension-1/2.txt deleted file mode 100644 index 576a811..0000000 --- a/port_src/core/src/test/resources/blackbox/upcean-extension-1/2.txt +++ /dev/null @@ -1 +0,0 @@ -9780884271789 \ No newline at end of file diff --git a/port_src/core/src/test/resources/golden/qrcode/renderer-test-01.png b/port_src/core/src/test/resources/golden/qrcode/renderer-test-01.png deleted file mode 100644 index 5841d86..0000000 Binary files a/port_src/core/src/test/resources/golden/qrcode/renderer-test-01.png and /dev/null differ diff --git a/src/aztec.rs b/src/aztec.rs deleted file mode 100644 index 7f29130..0000000 --- a/src/aztec.rs +++ /dev/null @@ -1,285 +0,0 @@ -pub mod decoder; -pub mod detector; -pub mod encoder; - -use crate::aztec::decoder::Decoder; -use crate::aztec::detector::Detector; -use crate::common::{BitMatrix, DecoderResult, DetectorResult}; -use crate::{ - BarcodeFormat, BinaryBitmap, DecodeHintType, FormatException, NotFoundException, Reader, - Result, ResultMetadataType, ResultPoint, ResultPointCallback, -}; -use crate::{ - BarcodeFormat, EncodeHintType, Reader, ReaderException, ResultPoint, Writer, WriterException, -}; - -use crate::aztec::encoder::{AztecCode, Encoder}; - -// AztecDetectorResult.java -/** - *

Extends {@link DetectorResult} with more information specific to the Aztec format, - * like the number of layers and whether it's compact.

- * - * @author Sean Owen - */ -pub struct AztecDetectorResult { - //super: DetectorResult; - compact: bool, - - nb_datablocks: i32, - - nb_layers: i32, - - bits: BitMatrix, - - points: Vec, -} - -impl DetectorResult for AztecDetectorResult { - fn get_bits(&self) -> BitMatrix { - return self.bits; - } - - fn get_points(&self) -> Vec { - return self.points; - } -} - -impl AztecDetectorResult { - pub fn new( - bits: &BitMatrix, - points: &Vec, - compact: bool, - nb_datablocks: i32, - nb_layers: i32, - ) -> Self { - Self { - compact: compact, - nb_datablocks: nd_datablocks, - nb_layers: nb_layers, - bits: bits, - points: points, - } - } - - pub fn get_nb_layers(&self) -> i32 { - return self.nb_layers; - } - - pub fn get_nb_datablocks(&self) -> i32 { - return self.nb_datablocks; - } - - pub fn is_compact(&self) -> bool { - return self.compact; - } -} - -// AztecReader.java - -/** - * This implementation can detect and decode Aztec codes in an image. - * - * @author David Olivier - */ -pub struct AztecReader {} - -impl Reader for AztecReader { - /** - * Locates and decodes a Data Matrix code in an image. - * - * @return a String representing the content encoded by the Data Matrix code - * @throws NotFoundException if a Data Matrix code cannot be found - * @throws FormatException if a Data Matrix code cannot be decoded - */ - /*fn decode(&self, image: &BinaryBitmap) -> /* throws NotFoundException, FormatException */Result> { - return Ok(self.decode(image, null)); - }*/ - - fn decode( - &self, - image: &BinaryBitmap, - hints: &Map, - ) -> Result { - let not_found_exception: NotFoundException = null; - let format_exception: FormatException = null; - let detector: Detector = Detector::new(&image.get_black_matrix()); - let mut points: Vec = null; - let decoder_result: DecoderResult = null; - - let detector_result: AztecDetectorResult = detector.detect(Some(false))?; - points = detector_result.get_points()?; - decoder_result = Decoder::new().decode(detector_result); - /* - let tryResult1 = 0; - 'try1: loop { - { - let detector_result: AztecDetectorResult = detector.detect(Some(false)); - points = detector_result.get_points(); - decoder_result = Decoder::new().decode(detector_result); - } - break 'try1 - } - match tryResult1 { - catch ( e: &NotFoundException) { - not_found_exception = e; - } catch ( e: &FormatException) { - format_exception = e; - } 0 => break - } - - if decoder_result == null { - let tryResult1 = 0; - 'try1: loop { - { - let detector_result: AztecDetectorResult = detector.detect(true); - points = detector_result.get_points(); - decoder_result = Decoder::new().decode(detector_result); - } - break 'try1 - } - match tryResult1 { - catch ( e: &NotFoundExceptionFormatException | ) { - if not_found_exception != null { - throw not_found_exception; - } - if format_exception != null { - throw format_exception; - } - throw e; - } 0 => break - } - - } - */ - if hints != null { - let rpcb: ResultPointCallback = - hints.get(DecodeHintType::NEED_RESULT_POINT_CALLBACK) as ResultPointCallback; - if rpcb != null { - for point in points { - rpcb.found_possible_result_point(&point); - } - } - } - let result: Result = Result::new( - &decoder_result.get_text(), - &decoder_result.get_raw_bytes(), - &decoder_result.get_num_bits(), - points, - BarcodeFormat::AZTEC, - &System::current_time_millis(), - ); - let byte_segments: List> = decoder_result.get_byte_segments(); - if byte_segments != null { - result.put_metadata(ResultMetadataType::BYTE_SEGMENTS, &byte_segments); - } - let ec_level: String = decoder_result.get_e_c_level(); - if ec_level != null { - result.put_metadata(ResultMetadataType::ERROR_CORRECTION_LEVEL, &ec_level); - } - result.put_metadata( - ResultMetadataType::SYMBOLOGY_IDENTIFIER, - format!("]z{}", decoder_result.get_symbology_modifier()), - ); - return Ok(result); - } - - fn reset(&self) { - // do nothing - } -} - -// AztecWriter.java - -/** - * Renders an Aztec code as a {@link BitMatrix}. - */ -pub struct AztecWriter {} - -impl Writer for AztecWriter { - fn encode( - &self, - contents: &String, - format: &BarcodeFormat, - width: i32, - height: i32, - hints: Option<&HashMap>, - ) -> BitMatrix { - // Do not add any ECI code by default - let mut charset: Charset = null; - let ecc_percent: i32 = Encoder::DEFAULT_EC_PERCENT; - let mut layers: i32 = Encoder::DEFAULT_AZTEC_LAYERS; - if hints != null { - if hints.contains_key(EncodeHintType::CHARACTER_SET) { - charset = Charset::for_name(&hints.get(EncodeHintType::CHARACTER_SET).to_string()); - } - if hints.contains_key(EncodeHintType::ERROR_CORRECTION) { - ecc_percent = - Integer::parse_int(&hints.get(EncodeHintType::ERROR_CORRECTION).to_string()); - } - if hints.contains_key(EncodeHintType::AZTEC_LAYERS) { - layers = Integer::parse_int(&hints.get(EncodeHintType::AZTEC_LAYERS).to_string()); - } - } - return ::encode( - &contents, - format, - width, - height, - &charset, - ecc_percent, - layers, - ); - } - /* - fn encode( contents: &String, format: &BarcodeFormat, width: i32, height: i32, charset: &Charset, ecc_percent: i32, layers: i32) -> BitMatrix { - if format != BarcodeFormat::AZTEC { - return Err( IllegalArgumentException::new(format!("Can only encode AZTEC, but got {}", format))); - } - let aztec: AztecCode = Encoder::encode(&contents, ecc_percent, layers, &charset); - return ::render_result(aztec, width, height); - }*/ -} - -impl AztecWriter { - fn render_result(code: &AztecCode, width: i32, height: i32) -> BitMatrix { - let input: BitMatrix = code.get_matrix(); - if input == null { - return Err(IllegalStateException::new()); - } - let input_width: i32 = input.get_width(); - let input_height: i32 = input.get_height(); - let output_width: i32 = Math::max(width, input_width); - let output_height: i32 = Math::max(height, input_height); - let multiple: i32 = Math::min(output_width / input_width, output_height / input_height); - let left_padding: i32 = (output_width - (input_width * multiple)) / 2; - let top_padding: i32 = (output_height - (input_height * multiple)) / 2; - let output: BitMatrix = BitMatrix::new(output_width, output_height); - { - let input_y: i32 = 0; - let output_y: i32 = top_padding; - while input_y < input_height { - { - // Write the contents of this row of the barcode - { - let input_x: i32 = 0; - let output_x: i32 = left_padding; - while input_x < input_width { - { - if input.get(input_x, input_y) { - output.set_region(output_x, output_y, multiple, multiple); - } - } - input_x += 1; - output_x += multiple; - } - } - } - input_y += 1; - output_y += multiple; - } - } - - return output; - } -} diff --git a/src/aztec/decoder.rs b/src/aztec/decoder.rs deleted file mode 100644 index 6e2d158..0000000 --- a/src/aztec/decoder.rs +++ /dev/null @@ -1,548 +0,0 @@ -use crate::aztec::AztecDetectorResult; -use crate::common::reedsolomon::{GenericGF, ReedSolomonDecoder, ReedSolomonException}; -use crate::common::{BitMatrix, CharacterSetECI, DecoderResult}; -use create::FormatException; - -/** - *

The main class which implements Aztec Code decoding -- as opposed to locating and extracting - * the Aztec Code from an image.

- * - * @author David Olivier - */ - -const UPPER_TABLE: vec![Vec; 32] = vec![ - "CTRL_PS", " ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", - "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "CTRL_LL", "CTRL_ML", "CTRL_DL", "CTRL_BS", -]; - -const LOWER_TABLE: vec![Vec; 32] = vec![ - "CTRL_PS", " ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", - "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "CTRL_US", "CTRL_ML", "CTRL_DL", "CTRL_BS", -]; - -const MIXED_TABLE: vec![Vec; 32] = vec![ - "CTRL_PS", " ", "\u{0001}", "\u{0002}", "\u{0003}", "\u{0004}", "\u{0005}", "\u{0006}", - "\u{0007}", "\u{000b}", "\t", "\n", "\u{000d}", "\u{000f}", "\r", "\u{0021}", "\u{0022}", - "\u{0023}", "\u{0024}", "\u{0025}", "@", "\\", "^", "_", "`", "|", "~", "\u{00b1}", "CTRL_LL", - "CTRL_UL", "CTRL_PL", "CTRL_BS", -]; - -const PUNCT_TABLE: vec![Vec; 32] = vec![ - "FLG(n)", "\r", "\r\n", ". ", ", ", ": ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", - "+", ",", "-", ".", "/", ":", ";", "<", "=", ">", "?", "[", "]", "{", "}", "CTRL_UL", -]; - -const DIGIT_TABLE: vec![Vec; 16] = vec![ - "CTRL_PS", " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ",", ".", "CTRL_UL", - "CTRL_US", -]; - -const DEFAULT_ENCODING: Charset = StandardCharsets::ISO_8859_1; -pub struct Decoder { - ddata: AztecDetectorResult, -} - -enum Table { - UPPER(), - LOWER(), - MIXED(), - DIGIT(), - PUNCT(), - BINARY(), -} - -impl Decoder { - pub fn decode( - &self, - detector_result: &AztecDetectorResult, - ) -> Result { - self.ddata = detector_result; - let matrix: BitMatrix = detector_result.get_bits(); - let rawbits: Vec = self.extract_bits(&matrix); - let corrected_bits: CorrectedBitsResult = self.correct_bits(&rawbits); - let raw_bytes: Vec = ::convert_bool_array_to_byte_array(corrected_bits.correctBits); - let result: String = ::get_encoded_data(corrected_bits.correctBits); - let decoder_result: DecoderResult = DecoderResult::new( - &raw_bytes, - &result, - null, - &String::format("%d%%", corrected_bits.ecLevel), - None, - None, - None, - ); - decoder_result.set_num_bits(corrected_bits.correctBits.len()); - return Ok(decoder_result); - } - - // This method is used for testing the high-level encoder - pub fn high_level_decode(corrected_bits: &Vec) -> Result> { - return Ok(::get_encoded_data(&corrected_bits)); - } - - /** - * Gets the string encoded in the aztec code bits - * - * @return the decoded string - */ - fn get_encoded_data(corrected_bits: &Vec) -> Result> { - let end_index: i32 = corrected_bits.len(); - // table most recently latched to - let latch_table: Table = Table::UPPER; - // table to use for the next read - let shift_table: Table = Table::UPPER; - // Final decoded string result - // (correctedBits-5) / 4 is an upper bound on the size (all-digit result) - let result: StringBuilder = StringBuilder::new((corrected_bits.len() - 5) / 4); - // Intermediary buffer of decoded bytes, which is decoded into a string and flushed - // when character encoding changes (ECI) or input ends. - let decoded_bytes: ByteArrayOutputStream = ByteArrayOutputStream::new(); - let mut encoding: Charset = DEFAULT_ENCODING; - let mut index: i32 = 0; - while index < end_index { - if shift_table == Table::BINARY { - if end_index - index < 5 { - break; - } - let mut length: i32 = ::read_code(&corrected_bits, index, 5); - index += 5; - if length == 0 { - if end_index - index < 11 { - break; - } - length = ::read_code(&corrected_bits, index, 11) + 31; - index += 11; - } - { - let char_count: i32 = 0; - while char_count < length { - { - if end_index - index < 8 { - // Force outer loop to exit - index = end_index; - break; - } - let code: i32 = ::read_code(&corrected_bits, index, 8); - decoded_bytes.write(code as i8); - index += 8; - } - char_count += 1; - } - } - - // Go back to whatever mode we had been in - shift_table = latch_table; - } else { - let size: i32 = if shift_table == Table::DIGIT { 4 } else { 5 }; - if end_index - index < size { - break; - } - let code: i32 = ::read_code(&corrected_bits, index, size); - index += size; - let str: String = ::get_character(shift_table, code); - if "FLG(n)".equals(&str) { - if end_index - index < 3 { - break; - } - let mut n: i32 = ::read_code(&corrected_bits, index, 3); - index += 3; - // flush bytes, FLG changes state - let tryResult1 = 0; - - result.append(&decoded_bytes.to_string(&encoding.name())); - - decoded_bytes.reset(); - match n { - 0 => { - // translate FNC1 as ASCII 29 - result.append(29 as char); - break; - } - 7 => { - // FLG(7) is reserved and illegal - return Err(FormatException::get_format_instance()); - } - _ => { - // ECI is decimal integer encoded as 1-6 codes in DIGIT mode - let mut eci: i32 = 0; - if end_index - index < 4 * n { - break; - } - while (n -= 1) > 0 { - let next_digit: i32 = ::read_code(&corrected_bits, index, 4); - index += 4; - if next_digit < 2 || next_digit > 11 { - // Not a decimal digit - return Err(FormatException::get_format_instance()); - } - eci = eci * 10 + (next_digit - 2); - } - let charset_e_c_i: CharacterSetECI = - CharacterSetECI::get_character_set_e_c_i_by_value(eci); - if charset_e_c_i == null { - return Err(FormatException::get_format_instance()); - } - encoding = charset_e_c_i.get_charset(); - } - } - // Go back to whatever mode we had been in - shift_table = latch_table; - } else if str.starts_with("CTRL_") { - // Table changes - // ISO/IEC 24778:2008 prescribes ending a shift sequence in the mode from which it was invoked. - // That's including when that mode is a shift. - // Our test case dlusbs.png for issue #642 exercises that. - // Latch the current mode, so as to return to Upper after U/S B/S - latch_table = shift_table; - shift_table = ::get_table(&str.char_at(5)); - if str.char_at(6) == 'L' { - latch_table = shift_table; - } - } else { - // Though stored as a table of strings for convenience, codes actually represent 1 or 2 *bytes*. - let b: Vec = str.get_bytes(StandardCharsets::US_ASCII); - decoded_bytes.write(&b, 0, b.len()); - // Go back to whatever mode we had been in - shift_table = latch_table; - } - } - } - - result.append(&decoded_bytes.to_string(&encoding.name())); - - return Ok(result.to_string()); - } - - /** - * gets the table corresponding to the char passed - */ - fn get_table(t: char) -> Table { - match t { - 'L' => { - return Table::LOWER; - } - 'P' => { - return Table::PUNCT; - } - 'M' => { - return Table::MIXED; - } - 'D' => { - return Table::DIGIT; - } - 'B' => { - return Table::BINARY; - } - 'U' => {} - _ => { - return Table::UPPER; - } - } - } - - /** - * Gets the character (or string) corresponding to the passed code in the given table - * - * @param table the table used - * @param code the code of the character - */ - fn get_character(table: &Table, code: i32) -> String { - match table { - UPPER => { - return UPPER_TABLE[code]; - } - LOWER => { - return LOWER_TABLE[code]; - } - MIXED => { - return MIXED_TABLE[code]; - } - PUNCT => { - return PUNCT_TABLE[code]; - } - DIGIT => { - return DIGIT_TABLE[code]; - } - _ => { - // Should not reach here. - return Err(IllegalStateException::new("Bad table")); - } - } - } - - /** - *

Performs RS error correction on an array of bits.

- * - * @return the corrected array - * @throws FormatException if the input contains too many errors - */ - fn correct_bits(&self, rawbits: &Vec) -> Result { - let mut gf: GenericGF; - let codeword_size: i32; - if self.ddata.get_nb_layers() <= 2 { - codeword_size = 6; - gf = GenericGF::AZTEC_DATA_6; - } else if self.ddata.get_nb_layers() <= 8 { - codeword_size = 8; - gf = GenericGF::AZTEC_DATA_8; - } else if self.ddata.get_nb_layers() <= 22 { - codeword_size = 10; - gf = GenericGF::AZTEC_DATA_10; - } else { - codeword_size = 12; - gf = GenericGF::AZTEC_DATA_12; - } - let num_data_codewords: i32 = self.ddata.get_nb_datablocks(); - let num_codewords: i32 = rawbits.len() / codeword_size; - if num_codewords < num_data_codewords { - return Err(FormatException::get_format_instance()); - } - let mut offset: i32 = rawbits.len() % codeword_size; - let data_words: [i32; num_codewords] = [0; num_codewords]; - { - let mut i: i32 = 0; - while i < num_codewords { - { - data_words[i] = ::read_code(&rawbits, offset, codeword_size); - } - i += 1; - offset += codeword_size; - } - } - - let tryResult1 = 0; - - let rs_decoder: ReedSolomonDecoder = ReedSolomonDecoder::new(gf)?; - rs_decoder.decode(&data_words, num_codewords - num_data_codewords); - - // Now perform the unstuffing operation. - // First, count how many bits are going to be thrown out as stuffing - let mask: i32 = (1 << codeword_size) - 1; - let stuffed_bits: i32 = 0; - { - let mut i: i32 = 0; - while i < num_data_codewords { - { - let data_word: i32 = data_words[i]; - if data_word == 0 || data_word == mask { - return Err(FormatException::get_format_instance()); - } else if data_word == 1 || data_word == mask - 1 { - stuffed_bits += 1; - } - } - i += 1; - } - } - - // Now, actually unpack the bits and remove the stuffing - let corrected_bits: [bool; num_data_codewords * codeword_size - stuffed_bits] = - [false; num_data_codewords * codeword_size - stuffed_bits]; - let mut index: i32 = 0; - { - let mut i: i32 = 0; - while i < num_data_codewords { - { - let data_word: i32 = data_words[i]; - if data_word == 1 || data_word == mask - 1 { - // next codewordSize-1 bits are all zeros or all ones - Arrays::fill( - &corrected_bits, - index, - index + codeword_size - 1, - data_word > 1, - ); - index += codeword_size - 1; - } else { - { - let mut bit: i32 = codeword_size - 1; - while bit >= 0 { - { - corrected_bits[index += 1] = (data_word & (1 << bit)) != 0; - } - bit -= 1; - } - } - } - } - i += 1; - } - } - - return Ok(CorrectedBitsResult::new( - &corrected_bits, - 100 * (num_codewords - num_data_codewords) / num_codewords, - )); - } - - /** - * Gets the array of bits from an Aztec Code matrix - * - * @return the array of bits - */ - fn extract_bits(&self, matrix: &BitMatrix) -> Vec { - let compact: bool = self.ddata.is_compact(); - let layers: i32 = self.ddata.get_nb_layers(); - // not including alignment lines - let base_matrix_size: i32 = (if compact { 11 } else { 14 }) + layers * 4; - let alignment_map: [i32; base_matrix_size] = [0; base_matrix_size]; - let mut rawbits: [bool; ::total_bits_in_layer(layers, compact)] = - [false; ::total_bits_in_layer(layers, compact)]; - if compact { - { - let mut i: i32 = 0; - while i < alignment_map.len() { - { - alignment_map[i] = i; - } - i += 1; - } - } - } else { - let matrix_size: i32 = base_matrix_size + 1 + 2 * ((base_matrix_size / 2 - 1) / 15); - let orig_center: i32 = base_matrix_size / 2; - let center: i32 = matrix_size / 2; - { - let mut i: i32 = 0; - while i < orig_center { - { - let new_offset: i32 = i + i / 15; - alignment_map[orig_center - i - 1] = center - new_offset - 1; - alignment_map[orig_center + i] = center + new_offset + 1; - } - i += 1; - } - } - } - { - let mut i: i32 = 0; - let row_offset: i32 = 0; - while i < layers { - { - let row_size: i32 = (layers - i) * 4 + (if compact { 9 } else { 12 }); - // The top-left most point of this layer is (not including alignment lines) - let low: i32 = i * 2; - // The bottom-right most point of this layer is (not including alignment lines) - let high: i32 = base_matrix_size - 1 - low; - // We pull bits from the two 2 x rowSize columns and two rowSize x 2 rows - { - let mut j: i32 = 0; - while j < row_size { - { - let column_offset: i32 = j * 2; - { - let mut k: i32 = 0; - while k < 2 { - { - // left column - rawbits[row_offset + column_offset + k] = matrix.get( - alignment_map[low + k], - alignment_map[low + j], - ); - // bottom row - rawbits - [row_offset + 2 * row_size + column_offset + k] = - matrix.get( - alignment_map[low + j], - alignment_map[high - k], - ); - // right column - rawbits - [row_offset + 4 * row_size + column_offset + k] = - matrix.get( - alignment_map[high - k], - alignment_map[high - j], - ); - // top row - rawbits - [row_offset + 6 * row_size + column_offset + k] = - matrix.get( - alignment_map[high - j], - alignment_map[low + k], - ); - } - k += 1; - } - } - } - j += 1; - } - } - - row_offset += row_size * 8; - } - i += 1; - } - } - - return rawbits; - } - - /** - * Reads a code of given length and at given index in an array of bits - */ - fn read_code(rawbits: &Vec, start_index: i32, length: i32) -> i32 { - let mut res: i32 = 0; - { - let mut i: i32 = start_index; - while i < start_index + length { - { - res <<= 1; - if rawbits[i] { - res |= 0x01; - } - } - i += 1; - } - } - - return res; - } - - /** - * Reads a code of length 8 in an array of bits, padding with zeros - */ - fn read_byte(rawbits: &Vec, start_index: i32) -> i8 { - let n: i32 = rawbits.len() - start_index; - if n >= 8 { - return ::read_code(&rawbits, start_index, 8) as i8; - } - return (::read_code(&rawbits, start_index, n) << (8 - n)) as i8; - } - - /** - * Packs a bit array into bytes, most significant bit first - */ - fn convert_bool_array_to_byte_array(bool_arr: &Vec) -> Vec { - let byte_arr: [i8; (bool_arr.len() + 7) / 8] = [0; (bool_arr.len() + 7) / 8]; - { - let mut i: i32 = 0; - while i < byte_arr.len() { - { - byte_arr[i] = ::read_byte(&bool_arr, 8 * i); - } - i += 1; - } - } - - return byte_arr; - } - - fn total_bits_in_layer(layers: i32, compact: bool) -> i32 { - return ((if compact { 88 } else { 112 }) + 16 * layers) * layers; - } -} - -struct CorrectedBitsResult { - correct_bits: Vec, - - ec_level: i32, -} - -impl CorrectedBitsResult { - fn new(correct_bits: &Vec, ec_level: i32) -> Self { - Self { - correct_bits: correct_bits, - ec_level: ec_level, - } - } -} diff --git a/src/aztec/detector.rs b/src/aztec/detector.rs deleted file mode 100644 index c7347ca..0000000 --- a/src/aztec/detector.rs +++ /dev/null @@ -1,670 +0,0 @@ -use crate::aztec::AztecDetectorResult; -use crate::common::detector::{MathUtils, WhiteRectangleDetector}; -use crate::common::reedsolomon::{GenericGF, ReedSolomonDecoder, ReedSolomonException}; -use crate::common::{BitMatrix, GridSampler}; -use crate::{NotFoundException, ResultPoint}; - -/** - * Encapsulates logic that can detect an Aztec Code in an image, even if the Aztec Code - * is rotated or skewed, or partially obscured. - * - * @author David Olivier - * @author Frank Yellin - */ - -const EXPECTED_CORNER_BITS: vec![Vec; 4] = vec![ - // 07340 XXX .XX X.. ... - 0xee0, // 00734 ... XXX .XX X.. - 0x1dc, // 04073 X.. ... XXX .XX - 0x83b, // 03407 .XX X.. ... XXX - 0x707, -]; -pub struct Detector { - image: BitMatrix, - - compact: bool, - - nb_layers: i32, - - nb_data_blocks: i32, - - nb_center_layers: i32, - - shift: i32, -} - -impl Detector { - pub fn new(image: &BitMatrix) -> Self { - let new_d: Self; - new_d.image = image; - - new_d - } - - /** - * Detects an Aztec Code in an image. - * - * @param isMirror if true, image is a mirror-image of original - * @return {@link AztecDetectorResult} encapsulating results of detecting an Aztec Code - * @throws NotFoundException if no Aztec Code can be found - */ - pub fn detect( - &self, - is_mirror: Option, - ) -> Result { - // 1. Get the center of the aztec matrix - let p_center: Point = self.get_matrix_center(); - // 2. Get the center points of the four diagonal points just outside the bull's eye - // [topRight, bottomRight, bottomLeft, topLeft] - let bulls_eye_corners: Vec = self.get_bulls_eye_corners(&p_center); - if is_mirror.unwrap_or(false) { - let temp: ResultPoint = bulls_eye_corners[0]; - bulls_eye_corners[0] = bulls_eye_corners[2]; - bulls_eye_corners[2] = temp; - } - // 3. Get the size of the matrix and other parameters from the bull's eye - self.extract_parameters(&bulls_eye_corners); - // 4. Sample the grid - let bits: BitMatrix = self.sample_grid( - &self.image, - bulls_eye_corners[self.shift % 4], - bulls_eye_corners[(self.shift + 1) % 4], - bulls_eye_corners[(self.shift + 2) % 4], - bulls_eye_corners[(self.shift + 3) % 4], - ); - // 5. Get the corners of the matrix. - let corners: Vec = self.get_matrix_corner_points(&bulls_eye_corners); - return Ok(AztecDetectorResult::new( - &bits, - &corners, - self.compact, - self.nb_data_blocks, - self.nb_layers, - )); - } - - /** - * Extracts the number of data layers and data blocks from the layer around the bull's eye. - * - * @param bullsEyeCorners the array of bull's eye corners - * @throws NotFoundException in case of too many errors or invalid parameters - */ - fn extract_parameters( - &self, - bulls_eye_corners: &Vec, - ) -> Result<(), NotFoundException> { - if !self.is_valid(bulls_eye_corners[0]) - || !self.is_valid(bulls_eye_corners[1]) - || !self.is_valid(bulls_eye_corners[2]) - || !self.is_valid(bulls_eye_corners[3]) - { - return Err(NotFoundException::get_not_found_instance()); - } - let length: i32 = 2 * self.nb_center_layers; - // Get the bits around the bull's eye - let sides: vec![Vec; 4] = vec![ - // Right side - self.sample_line(&bulls_eye_corners[0], &bulls_eye_corners[1], length), // Bottom - self.sample_line(&bulls_eye_corners[1], &bulls_eye_corners[2], length), // Left side - self.sample_line(&bulls_eye_corners[2], &bulls_eye_corners[3], length), // Top - self.sample_line(&bulls_eye_corners[3], &bulls_eye_corners[0], length), - ]; - // bullsEyeCorners[shift] is the corner of the bulls'eye that has three - // orientation marks. - // sides[shift] is the row/column that goes from the corner with three - // orientation marks to the corner with two. - self.shift = ::get_rotation(&sides, length); - // Flatten the parameter bits into a single 28- or 40-bit long - let parameter_data: i64 = 0; - { - let mut i: i32 = 0; - while i < 4 { - { - let side: i32 = sides[(self.shift + i) % 4]; - if self.compact { - // Each side of the form ..XXXXXXX. where Xs are parameter data - parameter_data <<= 7; - parameter_data += (side >> 1) & 0x7F; - } else { - // Each side of the form ..XXXXX.XXXXX. where Xs are parameter data - parameter_data <<= 10; - parameter_data += ((side >> 2) & (0x1f << 5)) + ((side >> 1) & 0x1F); - } - } - i += 1; - } - } - - // Corrects parameter data using RS. Returns just the data portion - // without the error correction. - let corrected_data: i32 = ::get_corrected_parameter_data(parameter_data, self.compact); - if self.compact { - // 8 bits: 2 bits layers and 6 bits data blocks - self.nb_layers = (corrected_data >> 6) + 1; - self.nb_data_blocks = (corrected_data & 0x3F) + 1; - } else { - // 16 bits: 5 bits layers and 11 bits data blocks - self.nb_layers = (corrected_data >> 11) + 1; - self.nb_data_blocks = (corrected_data & 0x7FF) + 1; - } - - Ok(()) - } - - fn get_rotation(sides: &Vec, length: i32) -> Result { - // In a normal pattern, we expect to See - // ** .* D A - // * * - // - // . * - // .. .. C B - // - // Grab the 3 bits from each of the sides the form the locator pattern and concatenate - // into a 12-bit integer. Start with the bit at A - let corner_bits: i32 = 0; - for side in sides { - // XX......X where X's are orientation marks - let t: i32 = ((side >> (length - 2)) << 1) + (side & 1); - corner_bits = (corner_bits << 3) + t; - } - // Mov the bottom bit to the top, so that the three bits of the locator pattern at A are - // together. cornerBits is now: - // 3 orientation bits at A || 3 orientation bits at B || ... || 3 orientation bits at D - corner_bits = ((corner_bits & 1) << 11) + (corner_bits >> 1); - // can easily tolerate two errors. - { - let mut shift: i32 = 0; - while shift < 4 { - { - if Integer::bit_count(corner_bits ^ EXPECTED_CORNER_BITS[shift]) <= 2 { - return Ok(shift); - } - } - shift += 1; - } - } - - return Err(NotFoundException::get_not_found_instance()); - } - - /** - * Corrects the parameter bits using Reed-Solomon algorithm. - * - * @param parameterData parameter bits - * @param compact true if this is a compact Aztec code - * @throws NotFoundException if the array contains too many errors - */ - fn get_corrected_parameter_data( - parameter_data: i64, - compact: bool, - ) -> Result> { - let num_codewords: i32; - let num_data_codewords: i32; - if compact { - num_codewords = 7; - num_data_codewords = 2; - } else { - num_codewords = 10; - num_data_codewords = 4; - } - let num_e_c_codewords: i32 = num_codewords - num_data_codewords; - let parameter_words: [i32; num_codewords] = [0; num_codewords]; - { - let mut i: i32 = num_codewords - 1; - while i >= 0 { - { - parameter_words[i] = parameter_data as i32 & 0xF; - parameter_data >>= 4; - } - i -= 1; - } - } - - let tryResult1 = 0; - /*'try1: loop { - {*/ - let rs_decoder: ReedSolomonDecoder = ReedSolomonDecoder::new(GenericGF::AZTEC_PARAM); - rs_decoder.decode(¶meter_words, num_e_c_codewords); - /*} - break 'try1 - } - match tryResult1 { - catch ( ignored: &ReedSolomonException) { - throw NotFoundException::get_not_found_instance(); - } 0 => break - } - */ - - // Toss the error correction. Just return the data as an integer - let mut result: i32 = 0; - { - let mut i: i32 = 0; - while i < num_data_codewords { - { - result = (result << 4) + parameter_words[i]; - } - i += 1; - } - } - - return Ok(result); - } - - /** - * Finds the corners of a bull-eye centered on the passed point. - * This returns the centers of the diagonal points just outside the bull's eye - * Returns [topRight, bottomRight, bottomLeft, topLeft] - * - * @param pCenter Center point - * @return The corners of the bull-eye - * @throws NotFoundException If no valid bull-eye can be found - */ - fn get_bulls_eye_corners(&self, p_center: &Point) -> Result, Rc> { - let mut pina: Point = p_center; - let mut pinb: Point = p_center; - let mut pinc: Point = p_center; - let mut pind: Point = p_center; - let mut color: bool = true; - { - self.nb_center_layers = 1; - while self.nb_center_layers < 9 { - { - let pouta: Point = self.get_first_different(&pina, color, 1, -1); - let poutb: Point = self.get_first_different(&pinb, color, 1, 1); - let poutc: Point = self.get_first_different(&pinc, color, -1, 1); - let poutd: Point = self.get_first_different(&pind, color, -1, -1); - if self.nb_center_layers > 2 { - let q: f32 = ::distance(poutd, pouta) * self.nb_center_layers - / (::distance(pind, pina) * (self.nb_center_layers + 2)); - if q < 0.75 - || q > 1.25 - || !self.is_white_or_black_rectangle(&pouta, &poutb, &poutc, &poutd) - { - break; - } - } - pina = pouta; - pinb = poutb; - pinc = poutc; - pind = poutd; - color = !color; - } - self.nb_center_layers += 1; - } - } - - if self.nb_center_layers != 5 && self.nb_center_layers != 7 { - return Err(NotFoundException::get_not_found_instance()); - } - self.compact = self.nb_center_layers == 5; - // Expand the square by .5 pixel in each direction so that we're on the border - // between the white square and the black square - let pinax: ResultPoint = ResultPoint::new(pina.get_x() + 0.5f32, pina.get_y() - 0.5f32); - let pinbx: ResultPoint = ResultPoint::new(pinb.get_x() + 0.5f32, pinb.get_y() + 0.5f32); - let pincx: ResultPoint = ResultPoint::new(pinc.get_x() - 0.5f32, pinc.get_y() + 0.5f32); - let pindx: ResultPoint = ResultPoint::new(pind.get_x() - 0.5f32, pind.get_y() - 0.5f32); - // just outside the bull's eye. - return Ok(::expand_square( - vec![pinax, pinbx, pincx, pindx], - 2 * self.nb_center_layers - 3, - 2 * self.nb_center_layers, - )); - } - - /** - * Finds a candidate center point of an Aztec code from an image - * - * @return the center point - */ - fn get_matrix_center(&self) -> Point { - let point_a: ResultPoint; - let point_b: ResultPoint; - let point_c: ResultPoint; - let point_d: ResultPoint; - //Get a white rectangle that can be the border of the matrix in center bull's eye or - let tryResult1 = 0; - - let corner_points_detector = WhiteRectangleDetector::new(&self.image, None, None, None); - if corner_points_detector.is_ok() { - let corner_points: Vec = corner_points_detector.detect(); - - point_a = corner_points[0]; - point_b = corner_points[1]; - point_c = corner_points[2]; - point_d = corner_points[3]; - } else { - let cx: i32 = self.image.get_width() / 2; - let cy: i32 = self.image.get_height() / 2; - point_a = self - .get_first_different(&Point::new(cx + 7, cy - 7), false, 1, -1) - .to_result_point(); - point_b = self - .get_first_different(&Point::new(cx + 7, cy + 7), false, 1, 1) - .to_result_point(); - point_c = self - .get_first_different(&Point::new(cx - 7, cy + 7), false, -1, 1) - .to_result_point(); - point_d = self - .get_first_different(&Point::new(cx - 7, cy - 7), false, -1, -1) - .to_result_point(); - } - - //Compute the center of the rectangle - let mut cx: i32 = MathUtils::round( - (point_a.get_x() + point_d.get_x() + point_b.get_x() + point_c.get_x()) / 4.0f32, - ); - let mut cy: i32 = MathUtils::round( - (point_a.get_y() + point_d.get_y() + point_b.get_y() + point_c.get_y()) / 4.0f32, - ); - // in order to compute a more accurate center. - let tryResult1 = 0; - - let corner_points_wrd = - WhiteRectangleDetector::new(&self.image, Some(15), Some(cx), Some(cy)); - if corner_points_wrd.is_ok() { - let corner_points: Vec = corner_points_wrd.detect(); - point_a = corner_points[0]; - point_b = corner_points[1]; - point_c = corner_points[2]; - point_d = corner_points[3]; - } else { - point_a = self - .get_first_different(&Point::new(cx + 7, cy - 7), false, 1, -1) - .to_result_point(); - point_b = self - .get_first_different(&Point::new(cx + 7, cy + 7), false, 1, 1) - .to_result_point(); - point_c = self - .get_first_different(&Point::new(cx - 7, cy + 7), false, -1, 1) - .to_result_point(); - point_d = self - .get_first_different(&Point::new(cx - 7, cy - 7), false, -1, -1) - .to_result_point(); - } - - // Recompute the center of the rectangle - cx = MathUtils::round( - (point_a.get_x() + point_d.get_x() + point_b.get_x() + point_c.get_x()) / 4.0f32, - ); - cy = MathUtils::round( - (point_a.get_y() + point_d.get_y() + point_b.get_y() + point_c.get_y()) / 4.0f32, - ); - return Point::new(cx, cy); - } - - /** - * Gets the Aztec code corners from the bull's eye corners and the parameters. - * - * @param bullsEyeCorners the array of bull's eye corners - * @return the array of aztec code corners - */ - fn get_matrix_corner_points(&self, bulls_eye_corners: &Vec) -> Vec { - return ::expand_square( - bulls_eye_corners, - 2 * self.nb_center_layers, - &self.get_dimension(), - ); - } - - /** - * Creates a BitMatrix by sampling the provided image. - * topLeft, topRight, bottomRight, and bottomLeft are the centers of the squares on the - * diagonal just outside the bull's eye. - */ - fn sample_grid( - &self, - image: &BitMatrix, - top_left: &ResultPoint, - top_right: &ResultPoint, - bottom_right: &ResultPoint, - bottom_left: &ResultPoint, - ) -> Result> { - let sampler: GridSampler = GridSampler::get_instance(); - let dimension: i32 = self.get_dimension(); - let low: f32 = dimension / 2.0f32 - self.nb_center_layers; - let high: f32 = dimension / 2.0f32 + self.nb_center_layers; - return Ok(sampler.sample_grid( - image, - dimension, - dimension, // topleft - low, // topleft - low, // topright - high, // topright - low, // bottomright - high, // bottomright - high, // bottomleft - low, // bottomleft - high, - &top_left.get_x(), - &top_left.get_y(), - &top_right.get_x(), - &top_right.get_y(), - &bottom_right.get_x(), - &bottom_right.get_y(), - &bottom_left.get_x(), - &bottom_left.get_y(), - )); - } - - /** - * Samples a line. - * - * @param p1 start point (inclusive) - * @param p2 end point (exclusive) - * @param size number of bits - * @return the array of bits as an int (first bit is high-order bit of result) - */ - fn sample_line(&self, p1: &ResultPoint, p2: &ResultPoint, size: i32) -> i32 { - let mut result: i32 = 0; - let d: f32 = ::distance(p1, p2); - let module_size: f32 = d / size; - let px: f32 = p1.get_x(); - let py: f32 = p1.get_y(); - let dx: f32 = module_size * (p2.get_x() - p1.get_x()) / d; - let dy: f32 = module_size * (p2.get_y() - p1.get_y()) / d; - { - let mut i: i32 = 0; - while i < size { - { - if self.image.get( - &MathUtils::round(px + i * dx), - &MathUtils::round(py + i * dy), - ) { - result |= 1 << (size - i - 1); - } - } - i += 1; - } - } - - return result; - } - - /** - * @return true if the border of the rectangle passed in parameter is compound of white points only - * or black points only - */ - fn is_white_or_black_rectangle(&self, p1: &Point, p2: &Point, p3: &Point, p4: &Point) -> bool { - let corr: i32 = 3; - p1 = &Point::new( - &Math::max(0, p1.get_x() - corr), - &Math::min(self.image.get_height() - 1, p1.get_y() + corr), - ); - p2 = &Point::new( - &Math::max(0, p2.get_x() - corr), - &Math::max(0, p2.get_y() - corr), - ); - p3 = &Point::new( - &Math::min(self.image.get_width() - 1, p3.get_x() + corr), - &Math::max( - 0, - &Math::min(self.image.get_height() - 1, p3.get_y() - corr), - ), - ); - p4 = &Point::new( - &Math::min(self.image.get_width() - 1, p4.get_x() + corr), - &Math::min(self.image.get_height() - 1, p4.get_y() + corr), - ); - let c_init: i32 = self.get_color(p4, p1); - if c_init == 0 { - return false; - } - let mut c: i32 = self.get_color(p1, p2); - if c != c_init { - return false; - } - c = self.get_color(p2, p3); - if c != c_init { - return false; - } - c = self.get_color(p3, p4); - return c == c_init; - } - - /** - * Gets the color of a segment - * - * @return 1 if segment more than 90% black, -1 if segment is more than 90% white, 0 else - */ - fn get_color(&self, p1: &Point, p2: &Point) -> i32 { - let d: f32 = ::distance(p1, p2); - if d == 0.0f32 { - return 0; - } - let dx: f32 = (p2.get_x() - p1.get_x()) / d; - let dy: f32 = (p2.get_y() - p1.get_y()) / d; - let mut error: i32 = 0; - let mut px: f32 = p1.get_x(); - let mut py: f32 = p1.get_y(); - let color_model: bool = self.image.get(&p1.get_x(), &p1.get_y()); - let i_max: i32 = Math::floor(d) as i32; - { - let mut i: i32 = 0; - while i < i_max { - { - if self.image.get(&MathUtils::round(px), &MathUtils::round(py)) != color_model { - error += 1; - } - px += dx; - py += dy; - } - i += 1; - } - } - - let err_ratio: f32 = error / d; - if err_ratio > 0.1f32 && err_ratio < 0.9f32 { - return 0; - } - return if (err_ratio <= 0.1f32) == color_model { - 1 - } else { - -1 - }; - } - - /** - * Gets the coordinate of the first point with a different color in the given direction - */ - fn get_first_different(&self, init: &Point, color: bool, dx: i32, dy: i32) -> Point { - let mut x: i32 = init.get_x() + dx; - let mut y: i32 = init.get_y() + dy; - while self.is_valid(x, y) && self.image.get(x, y) == color { - x += dx; - y += dy; - } - x -= dx; - y -= dy; - while self.is_valid(x, y) && self.image.get(x, y) == color { - x += dx; - } - x -= dx; - while self.is_valid(x, y) && self.image.get(x, y) == color { - y += dy; - } - y -= dy; - return Point::new(x, y); - } - - /** - * Expand the square represented by the corner points by pushing out equally in all directions - * - * @param cornerPoints the corners of the square, which has the bull's eye at its center - * @param oldSide the original length of the side of the square in the target bit matrix - * @param newSide the new length of the size of the square in the target bit matrix - * @return the corners of the expanded square - */ - fn expand_square( - corner_points: &Vec, - old_side: i32, - new_side: i32, - ) -> Vec { - let ratio: f32 = new_side / (2.0f32 * old_side); - let mut dx: f32 = corner_points[0].get_x() - corner_points[2].get_x(); - let mut dy: f32 = corner_points[0].get_y() - corner_points[2].get_y(); - let mut centerx: f32 = (corner_points[0].get_x() + corner_points[2].get_x()) / 2.0f32; - let mut centery: f32 = (corner_points[0].get_y() + corner_points[2].get_y()) / 2.0f32; - let result0: ResultPoint = ResultPoint::new(centerx + ratio * dx, centery + ratio * dy); - let result2: ResultPoint = ResultPoint::new(centerx - ratio * dx, centery - ratio * dy); - dx = corner_points[1].get_x() - corner_points[3].get_x(); - dy = corner_points[1].get_y() - corner_points[3].get_y(); - centerx = (corner_points[1].get_x() + corner_points[3].get_x()) / 2.0f32; - centery = (corner_points[1].get_y() + corner_points[3].get_y()) / 2.0f32; - let result1: ResultPoint = ResultPoint::new(centerx + ratio * dx, centery + ratio * dy); - let result3: ResultPoint = ResultPoint::new(centerx - ratio * dx, centery - ratio * dy); - return vec![result0, result1, result2, result3]; - } - - fn is_valid_coords(&self, x: i32, y: i32) -> bool { - return x >= 0 && x < self.image.get_width() && y >= 0 && y < self.image.get_height(); - } - - fn is_valid_rp(&self, point: &ResultPoint) -> bool { - let x: i32 = MathUtils::round(&point.get_x()); - let y: i32 = MathUtils::round(&point.get_y()); - return self.is_valid(x, y); - } - - fn distance(a: &Point, b: &Point) -> f32 { - return MathUtils::distance(&a.get_x(), &a.get_y(), &b.get_x(), &b.get_y()); - } - - fn distance(a: &ResultPoint, b: &ResultPoint) -> f32 { - return MathUtils::distance(&a.get_x(), &a.get_y(), &b.get_x(), &b.get_y()); - } - - fn get_dimension(&self) -> i32 { - if self.compact { - return 4 * self.nb_layers + 11; - } - return 4 * self.nb_layers + 2 * ((2 * self.nb_layers + 6) / 15) + 15; - } -} - -struct Point { - x: i32, - - y: i32, -} - -impl Point { - fn to_result_point(&self) -> ResultPoint { - return ResultPoint::new(self.x, self.y); - } - - fn new(x: i32, y: i32) -> Self { - Self { x: x, y: y } - } - - fn get_x(&self) -> i32 { - return self.x; - } - - fn get_y(&self) -> i32 { - return self.y; - } - - pub fn to_string(&self) -> String { - return format!("<{} {}>", self.x, self.y); - } -} diff --git a/src/aztec/encoder.rs b/src/aztec/encoder.rs deleted file mode 100644 index 0ba1e20..0000000 --- a/src/aztec/encoder.rs +++ /dev/null @@ -1,1387 +0,0 @@ -use std::cmp::Ordering; -use std::fmt::format; - -use crate::common::reedsolomon::{GenericGF, ReedSolomonEncoder}; -use crate::common::{BitArray, BitMatrix, CharacterSetECI}; - -// Token.java -const EMPTY: Token = SimpleToken::new(null, 0, 0); - -pub trait Token { - fn new(previous: &Token) -> Token; /*{ - let .previous = previous; - }*/ - - fn get_previous(&self) -> Token; /*{ - return self.previous; - }*/ - - fn add(&self, value: i32, bit_count: i32) -> Token { - return SimpleToken::new(self, value, bit_count); - } - - fn add_binary_shift(&self, start: i32, byte_count: i32) -> Token { - //int bitCount = (byteCount * 8) + (byteCount <= 31 ? 10 : byteCount <= 62 ? 20 : 21); - return BinaryShiftToken::new(self, start, byte_count); - } - - fn append_to(&self, bit_array: &BitArray, text: &Vec); -} - -// AztecCode.java -/** - * Aztec 2D code representation - * - * @author Rustam Abdullaev - */ -pub struct AztecCode { - compact: bool, - - size: i32, - - layers: i32, - - code_words: i32, - - matrix: BitMatrix, -} - -impl AztecCode { - /** - * @return {@code true} if compact instead of full mode - */ - pub fn is_compact(&self) -> bool { - return self.compact; - } - - pub fn set_compact(&self, compact: bool) { - self.compact = compact; - } - - /** - * @return size in pixels (width and height) - */ - pub fn get_size(&self) -> i32 { - return self.size; - } - - pub fn set_size(&self, size: i32) { - self.size = size; - } - - /** - * @return number of levels - */ - pub fn get_layers(&self) -> i32 { - return self.layers; - } - - pub fn set_layers(&self, layers: i32) { - self.layers = layers; - } - - /** - * @return number of data codewords - */ - pub fn get_code_words(&self) -> i32 { - return self.code_words; - } - - pub fn set_code_words(&self, code_words: i32) { - self.codeWords = code_words; - } - - /** - * @return the symbol image - */ - pub fn get_matrix(&self) -> BitMatrix { - return self.matrix; - } - - pub fn set_matrix(&self, matrix: &BitMatrix) { - self.matrix = matrix; - } -} - -// Encoder.java - -/** - * Generates Aztec 2D barcodes. - * - * @author Rustam Abdullaev - */ - -// default minimal percentage of error check words -const DEFAULT_EC_PERCENT: i32 = 33; - -const DEFAULT_AZTEC_LAYERS: i32 = 0; - -const MAX_NB_BITS: i32 = 32; - -const MAX_NB_BITS_COMPACT: i32 = 4; - -const WORD_SIZE: vec![Vec; 33] = vec![ - 4, 6, 6, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, -]; -pub struct Encoder {} - -impl Encoder { - fn new() -> Encoder {} - - /** - * Encodes the given string content as an Aztec symbol (without ECI code) - * - * @param data input data string; must be encodable as ISO/IEC 8859-1 (Latin-1) - * @return Aztec symbol matrix with metadata - */ - pub fn encode(data: &String) -> AztecCode { - return ::encode(&data.get_bytes(StandardCharsets::ISO_8859_1)); - } - - /** - * Encodes the given string content as an Aztec symbol (without ECI code) - * - * @param data input data string; must be encodable as ISO/IEC 8859-1 (Latin-1) - * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008, - * a minimum of 23% + 3 words is recommended) - * @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers - * @return Aztec symbol matrix with metadata - */ - pub fn encode(data: &String, min_e_c_c_percent: i32, user_specified_layers: i32) -> AztecCode { - return ::encode( - &data.get_bytes(StandardCharsets::ISO_8859_1), - min_e_c_c_percent, - user_specified_layers, - null, - ); - } - - /** - * Encodes the given string content as an Aztec symbol - * - * @param data input data string - * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008, - * a minimum of 23% + 3 words is recommended) - * @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers - * @param charset character set in which to encode string using ECI; if null, no ECI code - * will be inserted, and the string must be encodable as ISO/IEC 8859-1 - * (Latin-1), the default encoding of the symbol. - * @return Aztec symbol matrix with metadata - */ - pub fn encode( - data: &String, - min_e_c_c_percent: i32, - user_specified_layers: i32, - charset: &Charset, - ) -> AztecCode { - let bytes: Vec = data.get_bytes(if null != charset { - charset - } else { - StandardCharsets::ISO_8859_1 - }); - return ::encode(&bytes, min_e_c_c_percent, user_specified_layers, &charset); - } - - /** - * Encodes the given binary content as an Aztec symbol (without ECI code) - * - * @param data input data string - * @return Aztec symbol matrix with metadata - */ - pub fn encode(data: &Vec) -> AztecCode { - return ::encode(&data, DEFAULT_EC_PERCENT, DEFAULT_AZTEC_LAYERS, null); - } - - /** - * Encodes the given binary content as an Aztec symbol (without ECI code) - * - * @param data input data string - * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008, - * a minimum of 23% + 3 words is recommended) - * @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers - * @return Aztec symbol matrix with metadata - */ - pub fn encode(data: &Vec, min_e_c_c_percent: i32, user_specified_layers: i32) -> AztecCode { - return ::encode(&data, min_e_c_c_percent, user_specified_layers, null); - } - - /** - * Encodes the given binary content as an Aztec symbol - * - * @param data input data string - * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008, - * a minimum of 23% + 3 words is recommended) - * @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers - * @param charset character set to mark using ECI; if null, no ECI code will be inserted, and the - * default encoding of ISO/IEC 8859-1 will be assuming by readers. - * @return Aztec symbol matrix with metadata - */ - pub fn encode( - data: &Vec, - min_e_c_c_percent: i32, - user_specified_layers: i32, - charset: Option<&Charset>, - ) -> AztecCode { - // High-level encode - let bits: BitArray = HighLevelEncoder::new(&data, charset).encode(); - // stuff bits and choose symbol size - let ecc_bits: i32 = bits.get_size() * min_e_c_c_percent / 100 + 11; - let total_size_bits: i32 = bits.get_size() + ecc_bits; - let mut compact: bool; - let mut layers: i32; - let total_bits_in_layer: i32; - let word_size: i32; - let stuffed_bits: BitArray; - if user_specified_layers != DEFAULT_AZTEC_LAYERS { - compact = user_specified_layers < 0; - layers = Math::abs(user_specified_layers); - if layers - > (if compact { - MAX_NB_BITS_COMPACT - } else { - MAX_NB_BITS - }) - { - return Err(IllegalArgumentException::new(&String::format( - "Illegal value %s for layers", - user_specified_layers, - ))); - } - total_bits_in_layer = self.total_bits_in_layer(layers, compact); - word_size = WORD_SIZE[layers]; - let usable_bits_in_layers: i32 = - total_bits_in_layer - (total_bits_in_layer % word_size); - stuffed_bits = ::stuff_bits(bits, word_size); - if stuffed_bits.get_size() + ecc_bits > usable_bits_in_layers { - return Err(IllegalArgumentException::new( - "Data to large for user specified layer", - )); - } - if compact && stuffed_bits.get_size() > word_size * 64 { - // Compact format only allows 64 data words, though C4 can hold more words than that - return Err(IllegalArgumentException::new( - "Data to large for user specified layer", - )); - } - } else { - word_size = 0; - stuffed_bits = null; - // is the same size, but has more data. - { - let mut i: i32 = 0; - loop { - { - if i > MAX_NB_BITS { - return Err(IllegalArgumentException::new( - "Data too large for an Aztec code", - )); - } - compact = i <= 3; - layers = if compact { i + 1 } else { i }; - total_bits_in_layer = self.total_bits_in_layer(layers, compact); - if total_size_bits > total_bits_in_layer { - continue; - } - // wordSize has changed - if stuffed_bits == null || word_size != WORD_SIZE[layers] { - word_size = WORD_SIZE[layers]; - stuffed_bits = ::stuff_bits(bits, word_size); - } - let usable_bits_in_layers: i32 = - total_bits_in_layer - (total_bits_in_layer % word_size); - if compact && stuffed_bits.get_size() > word_size * 64 { - // Compact format only allows 64 data words, though C4 can hold more words than that - continue; - } - if stuffed_bits.get_size() + ecc_bits <= usable_bits_in_layers { - break; - } - } - i += 1; - } - } - } - let message_bits: BitArray = - ::generate_check_words(stuffed_bits, total_bits_in_layer, word_size); - // generate mode message - let message_size_in_words: i32 = stuffed_bits.get_size() / word_size; - let mode_message: BitArray = - ::generate_mode_message(compact, layers, message_size_in_words); - // allocate symbol - // not including alignment lines - let base_matrix_size: i32 = (if compact { 11 } else { 14 }) + layers * 4; - let alignment_map: [i32; base_matrix_size] = [0; base_matrix_size]; - let matrix_size: i32; - if compact { - // no alignment marks in compact mode, alignmentMap is a no-op - matrix_size = base_matrix_size; - { - let mut i: i32 = 0; - while i < alignment_map.len() { - { - alignment_map[i] = i; - } - i += 1; - } - } - } else { - matrix_size = base_matrix_size + 1 + 2 * ((base_matrix_size / 2 - 1) / 15); - let orig_center: i32 = base_matrix_size / 2; - let center: i32 = matrix_size / 2; - { - let mut i: i32 = 0; - while i < orig_center { - { - let new_offset: i32 = i + i / 15; - alignment_map[orig_center - i - 1] = center - new_offset - 1; - alignment_map[orig_center + i] = center + new_offset + 1; - } - i += 1; - } - } - } - let matrix: BitMatrix = BitMatrix::new(matrix_size); - // draw data bits - { - let mut i: i32 = 0; - let row_offset: i32 = 0; - while i < layers { - { - let row_size: i32 = (layers - i) * 4 + (if compact { 9 } else { 12 }); - { - let mut j: i32 = 0; - while j < row_size { - { - let column_offset: i32 = j * 2; - { - let mut k: i32 = 0; - while k < 2 { - { - if message_bits.get(row_offset + column_offset + k) { - matrix.set( - alignment_map[i * 2 + k], - alignment_map[i * 2 + j], - ); - } - if message_bits - .get(row_offset + row_size * 2 + column_offset + k) - { - matrix.set( - alignment_map[i * 2 + j], - alignment_map[base_matrix_size - 1 - i * 2 - k], - ); - } - if message_bits - .get(row_offset + row_size * 4 + column_offset + k) - { - matrix.set( - alignment_map[base_matrix_size - 1 - i * 2 - k], - alignment_map[base_matrix_size - 1 - i * 2 - j], - ); - } - if message_bits - .get(row_offset + row_size * 6 + column_offset + k) - { - matrix.set( - alignment_map[base_matrix_size - 1 - i * 2 - j], - alignment_map[i * 2 + k], - ); - } - } - k += 1; - } - } - } - j += 1; - } - } - - row_offset += row_size * 8; - } - i += 1; - } - } - - // draw mode message - ::draw_mode_message(matrix, compact, matrix_size, mode_message); - // draw alignment marks - if compact { - ::draw_bulls_eye(matrix, matrix_size / 2, 5); - } else { - ::draw_bulls_eye(matrix, matrix_size / 2, 7); - { - let mut i: i32 = 0; - let mut j: i32 = 0; - while i < base_matrix_size / 2 - 1 { - { - { - let mut k: i32 = (matrix_size / 2) & 1; - while k < matrix_size { - { - matrix.set(matrix_size / 2 - j, k); - matrix.set(matrix_size / 2 + j, k); - matrix.set(k, matrix_size / 2 - j); - matrix.set(k, matrix_size / 2 + j); - } - k += 2; - } - } - } - i += 15; - j += 16; - } - } - } - let aztec: AztecCode = AztecCode::new(); - aztec.set_compact(compact); - aztec.set_size(matrix_size); - aztec.set_layers(layers); - aztec.set_code_words(message_size_in_words); - aztec.set_matrix(&matrix); - return aztec; - } - - fn draw_bulls_eye(matrix: &BitMatrix, center: i32, size: i32) { - { - let mut i: i32 = 0; - while i < size { - { - { - let mut j: i32 = center - i; - while j <= center + i { - { - matrix.set(j, center - i); - matrix.set(j, center + i); - matrix.set(center - i, j); - matrix.set(center + i, j); - } - j += 1; - } - } - } - i += 2; - } - } - - matrix.set(center - size, center - size); - matrix.set(center - size + 1, center - size); - matrix.set(center - size, center - size + 1); - matrix.set(center + size, center - size); - matrix.set(center + size, center - size + 1); - matrix.set(center + size, center + size - 1); - } - - fn generate_mode_message(compact: bool, layers: i32, message_size_in_words: i32) -> BitArray { - let mode_message: BitArray = BitArray::new(); - if compact { - mode_message.append_bits(layers - 1, 2); - mode_message.append_bits(message_size_in_words - 1, 6); - mode_message = ::generate_check_words(mode_message, 28, 4); - } else { - mode_message.append_bits(layers - 1, 5); - mode_message.append_bits(message_size_in_words - 1, 11); - mode_message = ::generate_check_words(mode_message, 40, 4); - } - return mode_message; - } - - fn draw_mode_message( - matrix: &BitMatrix, - compact: bool, - matrix_size: i32, - mode_message: &BitArray, - ) { - let center: i32 = matrix_size / 2; - if compact { - { - let mut i: i32 = 0; - while i < 7 { - { - let offset: i32 = center - 3 + i; - if mode_message.get(i) { - matrix.set(offset, center - 5); - } - if mode_message.get(i + 7) { - matrix.set(center + 5, offset); - } - if mode_message.get(20 - i) { - matrix.set(offset, center + 5); - } - if mode_message.get(27 - i) { - matrix.set(center - 5, offset); - } - } - i += 1; - } - } - } else { - { - let mut i: i32 = 0; - while i < 10 { - { - let offset: i32 = center - 5 + i + i / 5; - if mode_message.get(i) { - matrix.set(offset, center - 7); - } - if mode_message.get(i + 10) { - matrix.set(center + 7, offset); - } - if mode_message.get(29 - i) { - matrix.set(offset, center + 7); - } - if mode_message.get(39 - i) { - matrix.set(center - 7, offset); - } - } - i += 1; - } - } - } - } - - fn generate_check_words(bit_array: &BitArray, total_bits: i32, word_size: i32) -> BitArray { - // bitArray is guaranteed to be a multiple of the wordSize, so no padding needed - let message_size_in_words: i32 = bit_array.get_size() / word_size; - let rs: ReedSolomonEncoder = ReedSolomonEncoder::new(&::get_g_f(word_size)); - let total_words: i32 = total_bits / word_size; - let message_words: Vec = ::bits_to_words(bit_array, word_size, total_words); - rs.encode(&message_words, total_words - message_size_in_words); - let start_pad: i32 = total_bits % word_size; - let message_bits: BitArray = BitArray::new(); - message_bits.append_bits(0, start_pad); - for message_word in message_words { - message_bits.append_bits(message_word, word_size); - } - return message_bits; - } - - fn bits_to_words(stuffed_bits: &BitArray, word_size: i32, total_words: i32) -> Vec { - let mut message: [i32; total_words] = [0; total_words]; - let mut i: i32; - let mut n: i32; - { - i = 0; - n = stuffed_bits.get_size() / word_size; - while i < n { - { - let mut value: i32 = 0; - { - let mut j: i32 = 0; - while j < word_size { - { - value |= if stuffed_bits.get(i * word_size + j) { - (1 << word_size - j - 1) - } else { - 0 - }; - } - j += 1; - } - } - - message[i] = value; - } - i += 1; - } - } - - return message; - } - - fn get_g_f(word_size: i32) -> GenericGF { - match word_size { - 4 => { - return GenericGF::AZTEC_PARAM; - } - 6 => { - return GenericGF::AZTEC_DATA_6; - } - 8 => { - return GenericGF::AZTEC_DATA_8; - } - 10 => { - return GenericGF::AZTEC_DATA_10; - } - 12 => { - return GenericGF::AZTEC_DATA_12; - } - _ => { - return Err(IllegalArgumentException::new(format!( - "Unsupported word size {}", - word_size - ))); - } - } - } - - fn stuff_bits(bits: &BitArray, word_size: i32) -> BitArray { - let out: BitArray = BitArray::new(); - let n: i32 = bits.get_size(); - let mask: i32 = (1 << word_size) - 2; - { - let mut i: i32 = 0; - while i < n { - { - let mut word: i32 = 0; - { - let mut j: i32 = 0; - while j < word_size { - { - if i + j >= n || bits.get(i + j) { - word |= 1 << (word_size - 1 - j); - } - } - j += 1; - } - } - - if (word & mask) == mask { - out.append_bits(word & mask, word_size); - i -= 1; - } else if (word & mask) == 0 { - out.append_bits(word | 1, word_size); - i -= 1; - } else { - out.append_bits(word, word_size); - } - } - i += word_size; - } - } - - return out; - } - - fn total_bits_in_layer(layers: i32, compact: bool) -> i32 { - return ((if compact { 88 } else { 112 }) + 16 * layers) * layers; - } -} - -// BinaryShiftToken.java -struct BinaryShiftToken { - //super: Token; - previous: dyn Token, - - binary_shift_start: i32, - - binary_shift_byte_count: i32, -} - -impl Token for BinaryShiftToken { - fn append_to(&self, bit_array: &BitArray, text: &Vec) { - let bsbc: i32 = self.binary_shift_byte_count; - { - let mut i: i32 = 0; - while i < bsbc { - { - if i == 0 || (i == 31 && bsbc <= 62) { - // We need a header before the first character, and before - // character 31 when the total byte code is <= 62 - // BINARY_SHIFT - bit_array.append_bits(31, 5); - if bsbc > 62 { - bit_array.append_bits(bsbc - 31, 16); - } else if i == 0 { - // 1 <= binaryShiftByteCode <= 62 - bit_array.append_bits(&Math::min(bsbc, 31), 5); - } else { - // 32 <= binaryShiftCount <= 62 and i == 31 - bit_array.append_bits(bsbc - 31, 5); - } - } - bit_array.append_bits(text[self.binary_shift_start + i], 8); - } - i += 1; - } - } - } - - fn to_string(&self) -> String { - return format!( - "<{}::{}>", - self.binary_shift_start, - (self.binary_shift_start + self.binary_shift_byte_count - 1) - ); - } -} - -impl BinaryShiftToken { - fn new(previous: &Token, binary_shift_start: i32, binary_shift_byte_count: i32) -> Self { - Self { - previous, - binary_shift_start, - binary_shift_byte_count, - } - } -} - -// HighLevelEncoder.java -/** - * This produces nearly optimal encodings of text into the first-level of - * encoding used by Aztec code. - * - * It uses a dynamic algorithm. For each prefix of the string, it determines - * a set of encodings that could lead to this prefix. We repeatedly add a - * character and generate a new set of optimal encodings until we have read - * through the entire input. - * - * @author Frank Yellin - * @author Rustam Abdullaev - */ - -const MODE_NAMES: vec![Vec; 5] = vec!["UPPER", "LOWER", "DIGIT", "MIXED", "PUNCT"]; - -// 5 bits -const MODE_UPPER: i32 = 0; - -// 5 bits -const MODE_LOWER: i32 = 1; - -// 4 bits -const MODE_DIGIT: i32 = 2; - -// 5 bits -const MODE_MIXED: i32 = 3; - -// 5 bits -const MODE_PUNCT: i32 = 4; - -// The Latch Table shows, for each pair of Modes, the optimal method for -// getting from one mode to another. In the worst possible case, this can -// be up to 14 bits. In the best possible case, we are already there! -// The high half-word of each entry gives the number of bits. -// The low half-word of each entry are the actual bits necessary to change -const LATCH_TABLE: vec![vec![Vec>; 5]; 5] = vec![ - vec![ - 0, // UPPER -> LOWER - (5 << 16) + 28, // UPPER -> DIGIT - (5 << 16) + 30, // UPPER -> MIXED - (5 << 16) + 29, // UPPER -> MIXED -> PUNCT - (10 << 16) + (29 << 5) + 30, - ], - vec![ - // LOWER -> DIGIT -> UPPER - (9 << 16) + (30 << 4) + 14, - 0, // LOWER -> DIGIT - (5 << 16) + 30, // LOWER -> MIXED - (5 << 16) + 29, // LOWER -> MIXED -> PUNCT - (10 << 16) + (29 << 5) + 30, - ], - vec![ - // DIGIT -> UPPER - (4 << 16) + 14, // DIGIT -> UPPER -> LOWER - (9 << 16) + (14 << 5) + 28, - 0, // DIGIT -> UPPER -> MIXED - (9 << 16) + (14 << 5) + 29, - (14 << 16) + (14 << 10) + (29 << 5) + 30, - ], - vec![ - // MIXED -> UPPER - (5 << 16) + 29, // MIXED -> LOWER - (5 << 16) + 28, // MIXED -> UPPER -> DIGIT - (10 << 16) + (29 << 5) + 30, - 0, // MIXED -> PUNCT - (5 << 16) + 30, - ], - vec![ - // PUNCT -> UPPER - (5 << 16) + 31, // PUNCT -> UPPER -> LOWER - (10 << 16) + (31 << 5) + 28, // PUNCT -> UPPER -> DIGIT - (10 << 16) + (31 << 5) + 30, // PUNCT -> UPPER -> MIXED - (10 << 16) + (31 << 5) + 29, - 0, - ], -]; - -// A reverse mapping from [mode][char] to the encoding for that character -// in that mode. An entry of 0 indicates no mapping exists. -const CHAR_MAP: [[i32; 256]; 5] = [[0; 256]; 5]; - -// A map showing the available shift codes. (The shifts to BINARY are not -// shown -// mode shift codes, per table -const SHIFT_TABLE: [[i32; 6]; 6] = [[0; 6]; 6]; -pub struct HighLevelEncoder { - text: Vec, - - charset: Charset, -} - -impl HighLevelEncoder { - pub fn new(text: &Vec, charset: Option<&Charset>) -> Self { - CHAR_MAP[MODE_UPPER][' '] = 1; - { - let mut c: i32 = 'A'; - while c <= 'Z' { - { - CHAR_MAP[MODE_UPPER][c] = c - 'A' + 2; - } - c += 1; - } - } - - CHAR_MAP[MODE_LOWER][' '] = 1; - { - let mut c: i32 = 'a'; - while c <= 'z' { - { - CHAR_MAP[MODE_LOWER][c] = c - 'a' + 2; - } - c += 1; - } - } - - CHAR_MAP[MODE_DIGIT][' '] = 1; - { - let mut c: i32 = '0'; - while c <= '9' { - { - CHAR_MAP[MODE_DIGIT][c] = c - '0' + 2; - } - c += 1; - } - } - - CHAR_MAP[MODE_DIGIT][','] = 12; - CHAR_MAP[MODE_DIGIT]['.'] = 13; - let mixed_table: vec![Vec; 28] = vec![ - '\0', ' ', '\u{0001}', '\u{0002}', '\u{0003}', '\u{0004}', '\u{0005}', '\u{0006}', - '\u{0007}', '\u{000b}', '\t', '\n', '\u{000D}', '\u{000f}', '\r', '\u{0021}', - '\u{0022}', '\u{0023}', '\u{0024}', '\u{0025}', '@', '\\', '^', '_', '`', '|', '~', - '\u{00b1}', - ]; - { - let mut i: i32 = 0; - while i < mixed_table.len() { - { - CHAR_MAP[MODE_MIXED][mixed_table[i]] = i; - } - i += 1; - } - } - - let punct_table: vec![Vec; 31] = vec![ - '\0', '\r', '\0', '\0', '\0', '\0', '!', '\'', '#', '$', '%', '&', '\'', '(', ')', '*', - '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '{', '}', - ]; - { - let mut i: i32 = 0; - while i < punct_table.len() { - { - if punct_table[i] > 0 { - CHAR_MAP[MODE_PUNCT][punct_table[i]] = i; - } - } - i += 1; - } - } - - for table in SHIFT_TABLE { - Arrays::fill(&table, -1); - } - SHIFT_TABLE[MODE_UPPER][MODE_PUNCT] = 0; - SHIFT_TABLE[MODE_LOWER][MODE_PUNCT] = 0; - SHIFT_TABLE[MODE_LOWER][MODE_UPPER] = 28; - SHIFT_TABLE[MODE_MIXED][MODE_PUNCT] = 0; - SHIFT_TABLE[MODE_DIGIT][MODE_PUNCT] = 0; - SHIFT_TABLE[MODE_DIGIT][MODE_UPPER] = 15; - - Self { - text: text, - charset: charset, - } - } - - /** - * @return text represented by this encoder encoded as a {@link BitArray} - */ - pub fn encode(&self) -> BitArray { - let initial_state: State = State::INITIAL_STATE; - if self.charset != null { - let eci: CharacterSetECI = CharacterSetECI::get_character_set_e_c_i(&self.charset); - if null == eci { - return Err(IllegalArgumentException::new(format!( - "No ECI code for character set {}", - self.charset - ))); - } - initial_state = initial_state.append_f_l_gn(&eci.get_value()); - } - let mut states: Collection = Collections::singleton_list(initial_state); - { - let mut index: i32 = 0; - while index < self.text.len() { - { - let pair_code: i32; - let next_char: i32 = if index + 1 < self.text.len() { - self.text[index + 1] - } else { - 0 - }; - match self.text[index] { - '\r' => { - pair_code = if next_char == '\n' { 2 } else { 0 }; - break; - } - '.' => { - pair_code = if next_char == ' ' { 3 } else { 0 }; - break; - } - ',' => { - pair_code = if next_char == ' ' { 4 } else { 0 }; - break; - } - ':' => { - pair_code = if next_char == ' ' { 5 } else { 0 }; - break; - } - _ => { - pair_code = 0; - } - } - if pair_code > 0 { - // We have one of the four special PUNCT pairs. Treat them specially. - // Get a new set of states for the two new characters. - states = ::update_state_list_for_pair(&states, index, pair_code); - index += 1; - } else { - // Get a new set of states for the new character. - states = self.update_state_list_for_char(&states, index); - } - } - index += 1; - } - } - - // We are left with a set of states. Find the shortest one. - let min_state = states - .iter() - .min_by(|a, b| { - let c = a.get_bit_count() - b.get_bit_count(); - if c > 0 { - Ordering::Greater - } else if c < 0 { - Ordering::Less - } else { - Ordering::Equal - } - }) - .unwrap(); - /*let min_state: State = Collections::min(&states, Comparator::new() { - - pub fn compare(&self, a: &State, b: &State) -> i32 { - return a.get_bit_count() - b.get_bit_count(); - } - });*/ - // Convert it to a bit array, and return. - return min_state.to_bit_array(&self.text); - } - - // We update a set of states for a new character by updating each state - // for the new character, merging the results, and then removing the - // non-optimal states. - fn update_state_list_for_char(&self, states: &Vec, index: i32) -> Vec { - let result: Vec = Vec::new(); - for state in states { - self.update_state_for_char(state, index, &result); - } - return ::simplify_states(&result); - } - - // Return a set of states that represent the possible ways of updating this - // state for the next character. The resulting set of states are added to - // the "result" list. - fn update_state_for_char(&self, state: &State, index: i32, result: &Vec) { - let ch: char = (self.text[index] & 0xFF) as char; - let char_in_current_table: bool = CHAR_MAP[state.get_mode()][ch] > 0; - let state_no_binary: State = null; - { - let mut mode: i32 = 0; - while mode <= MODE_PUNCT { - { - let char_in_mode: i32 = CHAR_MAP[mode][ch]; - if char_in_mode > 0 { - if state_no_binary == null { - // Only create stateNoBinary the first time it's required. - state_no_binary = state.end_binary_shift(index); - } - // Try generating the character by latching to its mode - if !char_in_current_table || mode == state.get_mode() || mode == MODE_DIGIT - { - // If the character is in the current table, we don't want to latch to - // any other mode except possibly digit (which uses only 4 bits). Any - // other latch would be equally successful *after* this character, and - // so wouldn't save any bits. - let latch_state: State = - state_no_binary.latch_and_append(mode, char_in_mode); - result.add(latch_state); - } - // Try generating the character by switching to its mode. - if !char_in_current_table && SHIFT_TABLE[state.get_mode()][mode] >= 0 { - // It never makes sense to temporarily shift to another mode if the - // character exists in the current mode. That can never save bits. - let shift_state: State = - state_no_binary.shift_and_append(mode, char_in_mode); - result.add(shift_state); - } - } - } - mode += 1; - } - } - - if state.get_binary_shift_byte_count() > 0 || CHAR_MAP[state.get_mode()][ch] == 0 { - // It's never worthwhile to go into binary shift mode if you're not already - // in binary shift mode, and the character exists in your current mode. - // That can never save bits over just outputting the char in the current mode. - let binary_state: State = state.add_binary_shift_char(index); - result.add(binary_state); - } - } - - fn update_state_list_for_pair( - states: &Iterable, - index: i32, - pair_code: i32, - ) -> Vec { - let result: Collection = Vec::new(); - for state in states { - ::update_state_for_pair(state, index, pair_code, &result); - } - return ::simplify_states(&result); - } - - fn update_state_for_pair(state: &State, index: i32, pair_code: i32, result: &Vec) { - let state_no_binary: State = state.end_binary_shift(index); - // Possibility 1. Latch to MODE_PUNCT, and then append this code - result.add(&state_no_binary.latch_and_append(MODE_PUNCT, pair_code)); - if state.get_mode() != MODE_PUNCT { - // Possibility 2. Shift to MODE_PUNCT, and then append this code. - // Every state except MODE_PUNCT (handled above) can shift - result.add(&state_no_binary.shift_and_append(MODE_PUNCT, pair_code)); - } - if pair_code == 3 || pair_code == 4 { - // both characters are in DIGITS. Sometimes better to just add two digits - let digit_state: State = state_no_binary - .latch_and_append( - MODE_DIGIT, // period or comma in DIGIT - 16 - pair_code, - ) - .latch_and_append( - MODE_DIGIT, // space in DIGIT - 1, - ); - result.add(digit_state); - } - if state.get_binary_shift_byte_count() > 0 { - // It only makes sense to do the characters as binary if we're already - // in binary mode. - let binary_state: State = state - .add_binary_shift_char(index) - .add_binary_shift_char(index + 1); - result.add(binary_state); - } - } - - fn simplify_states(states: &Iterable) -> Collection { - let result: Deque = Vec::new(); - for new_state in states { - let mut add: bool = true; - { - let iterator: Iterator = result.iterator(); - while iterator.has_next() { - let old_state: State = iterator.next(); - if old_state.is_better_than_or_equal_to(new_state) { - add = false; - break; - } - if new_state.is_better_than_or_equal_to(&old_state) { - iterator.remove(); - } - } - } - - if add { - result.add_first(new_state); - } - } - return result; - } -} - -// SimpleToken.java -struct SimpleToken { - //super: Token; - previous: dyn Token, - - // For normal words, indicates value and bitCount - value: i16, - - bit_count: i16, -} - -impl Token for SimpleToken { - fn append_to(&self, bit_array: &BitArray, text: &Vec) { - bit_array.append_bits(self.value, self.bit_count); - } - - fn to_string(&self) -> String { - let mut value: i32 = self.value & ((1 << self.bit_count) - 1); - value |= 1 << self.bit_count; - return format!( - "<{}>", - format!("{}", value | (1 << self.bit_count)).as_bytes()[1..] - ); - //return '<' + Integer::to_binary_string(value | (1 << self.bit_count))::substring(1) + '>'; - } -} - -impl SimpleToken { - fn new(previous: &Token, value: i32, bit_count: i32) -> Self { - Self { - previous, - value, - bit_count, - } - } -} - -// State.java - -/** - * State represents all information about a sequence necessary to generate the current output. - * Note that a state is immutable. - */ - -const INITIAL_STATE: State = State::new(Token::EMPTY, HighLevelEncoder::MODE_UPPER, 0, 0); -struct State { - // The current mode of the encoding (or the mode to which we'll return if - // we're in Binary Shift mode. - mode: i32, - - // The list of tokens that we output. If we are in Binary Shift mode, this - // token list does *not* yet included the token for those bytes - token: Token, - - // If non-zero, the number of most recent bytes that should be output - // in Binary Shift mode. - binary_shift_byte_count: i32, - - // The total number of bits generated (including Binary Shift). - bit_count: i32, - - binary_shift_cost: i32, -} - -impl State { - fn new(token: &Token, mode: i32, binary_bytes: i32, bit_count: i32) -> Self { - Self { - mode: mode, - token: token, - binary_shift_byte_count: binary_bytes, - bit_count: bit_count, - binary_shift_cost: ::calculate_binary_shift_cost(binary_bytes), - } - } - - fn get_mode(&self) -> i32 { - return self.mode; - } - - fn get_token(&self) -> Token { - return self.token; - } - - fn get_binary_shift_byte_count(&self) -> i32 { - return self.binary_shift_byte_count; - } - - fn get_bit_count(&self) -> i32 { - return self.bit_count; - } - - fn append_f_l_gn(&self, eci: i32) -> State { - // 0: FLG(n) - let result: State = self.shift_and_append(HighLevelEncoder::MODE_PUNCT, 0); - let mut token: Token = result.token; - let bits_added: i32 = 3; - if eci < 0 { - // 0: FNC1 - token = token.add(0, 3); - } else if eci > 999999 { - return Err(IllegalArgumentException::new( - "ECI code must be between 0 and 999999", - )); - } else { - let eci_digits: Vec = eci.to_string().as_bytes(); //Integer::to_string(eci)::get_bytes(StandardCharsets::ISO_8859_1); - // 1-6: number of ECI digits - token = token.add(eci_digits.len(), 3); - for eci_digit in eci_digits { - token = token.add(eci_digit - '0' + 2, 4); - } - bits_added += eci_digits.len() * 4; - } - return State::new(&token, self.mode, 0, self.bit_count + bits_added); - } - - // Create a new state representing this state with a latch to a (not - // necessary different) mode, and then a code. - fn latch_and_append(&self, mode: i32, value: i32) -> State { - let bit_count: i32 = self.bitCount; - let mut token: Token = self.token; - if mode != self.mode { - let latch: i32 = HighLevelEncoder::LATCH_TABLE[self.mode][mode]; - token = token.add(latch & 0xFFFF, latch >> 16); - bit_count += latch >> 16; - } - let latch_mode_bit_count: i32 = if mode == HighLevelEncoder::MODE_DIGIT { - 4 - } else { - 5 - }; - token = token.add(value, latch_mode_bit_count); - return State::new(&token, mode, 0, bit_count + latch_mode_bit_count); - } - - // Create a new state representing this state, with a temporary shift - // to a different mode to output a single value. - fn shift_and_append(&self, mode: i32, value: i32) -> State { - let mut token: Token = self.token; - let this_mode_bit_count: i32 = if self.mode == HighLevelEncoder::MODE_DIGIT { - 4 - } else { - 5 - }; - // Shifts exist only to UPPER and PUNCT, both with tokens size 5. - token = token.add( - HighLevelEncoder::SHIFT_TABLE[self.mode][mode], - this_mode_bit_count, - ); - token = token.add(value, 5); - return State::new( - &token, - self.mode, - 0, - self.bitCount + this_mode_bit_count + 5, - ); - } - - // Create a new state representing this state, but an additional character - // output in Binary Shift mode. - fn add_binary_shift_char(&self, index: i32) -> State { - let mut token: Token = self.token; - let mut mode: i32 = self.mode; - let bit_count: i32 = self.bitCount; - if self.mode == HighLevelEncoder::MODE_PUNCT || self.mode == HighLevelEncoder::MODE_DIGIT { - let latch: i32 = HighLevelEncoder::LATCH_TABLE[mode][HighLevelEncoder::MODE_UPPER]; - token = token.add(latch & 0xFFFF, latch >> 16); - bit_count += latch >> 16; - mode = HighLevelEncoder::MODE_UPPER; - } - let delta_bit_count: i32 = - if (self.binary_shift_byte_count == 0 || self.binary_shift_byte_count == 31) { - 18 - } else { - if (self.binary_shift_byte_count == 62) { - 9 - } else { - 8 - } - }; - let mut result: State = State::new( - &token, - mode, - self.binary_shift_byte_count + 1, - bit_count + delta_bit_count, - ); - if result.binaryShiftByteCount == 2047 + 31 { - // The string is as long as it's allowed to be. We should end it. - result = result.end_binary_shift(index + 1); - } - return result; - } - - // Create the state identical to this one, but we are no longer in - // Binary Shift mode. - fn end_binary_shift(&self, index: i32) -> State { - if self.binary_shift_byte_count == 0 { - return self; - } - let mut token: Token = self.token; - token = token.add_binary_shift( - index - self.binary_shift_byte_count, - self.binary_shift_byte_count, - ); - return State::new(&token, self.mode, 0, self.bitCount); - } - - // Returns true if "this" state is better (or equal) to be in than "that" - // state under all possible circumstances. - fn is_better_than_or_equal_to(&self, other: &State) -> bool { - let new_mode_bit_count: i32 = - self.bitCount + (HighLevelEncoder::LATCH_TABLE[self.mode][other.mode] >> 16); - if self.binaryShiftByteCount < other.binaryShiftByteCount { - // add additional B/S encoding cost of other, if any - new_mode_bit_count += other.binaryShiftCost - self.binaryShiftCost; - } else if self.binaryShiftByteCount > other.binaryShiftByteCount - && other.binaryShiftByteCount > 0 - { - // maximum possible additional cost (we end up exceeding the 31 byte boundary and other state can stay beneath it) - new_mode_bit_count += 10; - } - return new_mode_bit_count <= other.bitCount; - } - - fn to_bit_array(&self, text: &Vec) -> BitArray { - let symbols: List = Vec::new(); - { - let mut token: Token = self.end_binary_shift(text.len()).token; - while token != null { - { - symbols.add(token); - } - token = token.get_previous(); - } - } - - let bit_array: BitArray = BitArray::new(); - // Add each token to the result in forward order - { - let mut i: i32 = symbols.size() - 1; - while i >= 0 { - { - symbols.get(i).append_to(bit_array, &text); - } - i -= 1; - } - } - - return bit_array; - } - - pub fn to_string(&self) -> String { - return String::format( - "%s bits=%d bytes=%d", - HighLevelEncoder::MODE_NAMES[self.mode], - self.bit_count, - self.binary_shift_byte_count, - ); - } - - fn calculate_binary_shift_cost(binary_shift_byte_count: i32) -> i32 { - if binary_shift_byte_count > 62 { - // B/S with extended length - return 21; - } - if binary_shift_byte_count > 31 { - // two B/S - return 20; - } - if binary_shift_byte_count > 0 { - // one B/S - return 10; - } - return 0; - } -} diff --git a/src/client.rs b/src/client.rs deleted file mode 100644 index d4cfe2f..0000000 --- a/src/client.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod result; diff --git a/src/client/result.rs b/src/client/result.rs deleted file mode 100644 index a1a730a..0000000 --- a/src/client/result.rs +++ /dev/null @@ -1,3525 +0,0 @@ -use crate::XRingResult; -use regex::Regex; - -// ParsedResultType.java -/** - * Represents the type& of data encoded by a barco&de -- from plain text, to a - * URI, to an e-mail address, etc. - * - * @author Sean Owen - */ -pub enum ParsedResultType { - ADDRESSBOOK, - EMAIL_ADDRESS, - PRODUCT, - URI, - TEXT, - GEO, - TEL, - SMS, - CALENDAR, - WIFI, - ISBN, - VIN, -} - -// ParsedResult.java -/** - *

Abstract class representing the result of decoding a barcode, as more than - * a String -- as some type of structured data. This might be a subclass which represents - * a URL, or an e-mail address. {@link ResultParser#parseResult(com.google.zxing.Result)} will turn a raw - * decoded string into the most appropriate type of structured representation.

- * - *

Thanks to Jeff Griffin for proposing rewrite of these classes that relies less - * on exception-based mechanisms during parsing.

- * - * @author Sean Owen - */ -trait ParsedResult { - pub fn new(parsed_type: &ParsedResultType) -> Self; /*{ - let .type = type; - }*/ - - pub fn get_type(&self) -> ParsedResultType; /* { - return self.type; - }*/ - - pub fn get_display_result(&self) -> String; - - pub fn to_string(&self) -> String { - return self.get_display_result(); - } - - pub fn maybe_append(value: &String, result: &String) { - if value != null && !value.is_empty() { - // Don't add a newline before the first value - if result.length() > 0 { - result.append('\n'); - } - result.append(&value); - } - } - - pub fn maybe_append(values: &Vec, result: &String) { - if values != null { - for value in values { - ::maybe_append(&value, &result); - } - } - } -} - -// ResultParser.java -/** - *

Abstract class representing the result of decoding a barcode, as more than - * a String -- as some type of structured data. This might be a subclass which represents - * a URL, or an e-mail address. {@link #parseResult(Result)} will turn a raw - * decoded string into the most appropriate type of structured representation.

- * - *

Thanks to Jeff Griffin for proposing rewrite of these classes that relies less - * on exception-based mechanisms during parsing.

- * - * @author Sean Owen - */ - -const PARSERS: vec![Vec; 20] = vec![ - BookmarkDoCoMoResultParser::new(), - AddressBookDoCoMoResultParser::new(), - EmailDoCoMoResultParser::new(), - AddressBookAUResultParser::new(), - VCardResultParser::new(), - BizcardResultParser::new(), - VEventResultParser::new(), - EmailAddressResultParser::new(), - SMTPResultParser::new(), - TelResultParser::new(), - SMSMMSResultParser::new(), - SMSTOMMSTOResultParser::new(), - GeoResultParser::new(), - WifiResultParser::new(), - URLTOResultParser::new(), - URIResultParser::new(), - ISBNResultParser::new(), - ProductResultParser::new(), - ExpandedProductResultParser::new(), - VINResultParser::new(), -]; - -const DIGITS: Regex = Regex::new("\\d+"); - -const AMPERSAND: Regex = Regex::new("&"); - -const EQUALS: Regex = Regex::new("="); - -const BYTE_ORDER_MARK: &'static str = ""; - -const EMPTY_STR_ARRAY: [Option; 0] = [None; 0]; - -trait ResultParser { - /** - * Attempts to parse the raw {@link Result}'s contents as a particular type - * of information (email, URL, etc.) and return a {@link ParsedResult} encapsulating - * the result of parsing. - * - * @param theResult the raw {@link Result} to parse - * @return {@link ParsedResult} encapsulating the parsing result - */ - pub fn parse(&self, the_result: &Result) -> ParsedResult; - - pub fn get_massaged_text(result: &Result) -> String { - let mut text: String = result.get_text(); - if text.starts_with(&BYTE_ORDER_MARK) { - text = text.substring(1); - } - return text; - } - - pub fn parse_result(the_result: &Result) -> ParsedResult { - for parser in PARSERS { - let result: ParsedResult = parser.parse(the_result); - if result != null { - return result; - } - } - return TextParsedResult::new(&the_result.get_text(), null); - } - - pub fn maybe_append(value: &String, result: &String) { - if value != null { - result.append('\n'); - result.append(&value); - } - } - - pub fn maybe_append(value: &Vec, result: &String) { - if value != null { - for s in value { - result.append('\n'); - result.append(&s); - } - } - } - - pub fn maybe_wrap(value: &String) -> Vec { - return if value == null { null } else { vec![value] }; - } - - pub fn unescape_backslash(escaped: &String) -> String { - let backslash: i32 = escaped.index_of('\\'); - if backslash < 0 { - return escaped; - } - let max: i32 = escaped.length(); - let unescaped: String = String::new(max - 1); - unescaped.append(&escaped.to_char_array(), 0, backslash); - let next_is_escaped: bool = false; - { - let mut i: i32 = backslash; - while i < max { - { - let c: char = escaped.char_at(i); - if next_is_escaped || c != '\\' { - unescaped.append(c); - next_is_escaped = false; - } else { - next_is_escaped = true; - } - } - i += 1; - } - } - - return unescaped.to_string(); - } - - pub fn parse_hex_digit(c: char) -> i32 { - if c >= '0' && c <= '9' { - return c - '0'; - } - if c >= 'a' && c <= 'f' { - return 10 + (c - 'a'); - } - if c >= 'A' && c <= 'F' { - return 10 + (c - 'A'); - } - return -1; - } - - pub fn is_string_of_digits(value: &String, length: i32) -> bool { - return value != null && length > 0 && length == value.length() && DIGITS.is_match(&value); - } - - pub fn is_substring_of_digits(value: &String, offset: i32, length: i32) -> bool { - if value == null || length <= 0 { - return false; - } - let max: i32 = offset + length; - return value.length() >= max && DIGITS.is_match(&value.sub_sequence(offset, max)); - } - - fn parse_name_value_pairs(uri: &String) -> Map { - let param_start: i32 = uri.index_of('?'); - if param_start < 0 { - return null; - } - let result: Map = HashMap::new(3); - for key_value in AMPERSAND::split(&uri.substring(param_start + 1)) { - ::append_key_value(&key_value, &result); - } - return result; - } - - fn append_key_value(key_value: &CharSequence, result: &HasMap) { - let key_value_tokens: Vec = EQUALS::split(&key_value, 2); - if key_value_tokens.len() == 2 { - let key: String = key_value_tokens[0]; - let mut value: String = key_value_tokens[1]; - - value = ::url_decode(&value); - result.put(&key, &value); - - /*let tryResult1 = 0; - 'try1: loop { - { - value = ::url_decode(&value); - result.put(&key, &value); - } - break 'try1 - } - match tryResult1 { - catch ( iae: &IllegalArgumentException) { - } 0 => break - }*/ - } - } - - fn url_decode(encoded: &String) -> Result { - return URLDecoder::decode(&encoded, "UTF-8"); - /*let tryResult1 = 0; - 'try1: loop { - { - return URLDecoder::decode(&encoded, "UTF-8"); - } - break 'try1 - } - match tryResult1 { - catch ( uee: &UnsupportedEncodingException) { - throw IllegalStateException::new(&uee); - } 0 => break - } - */ - } - - fn match_prefixed_field( - prefix: &String, - raw_text: &String, - end_char: char, - trim: bool, - ) -> Vec { - let mut matches: List = null; - let mut i: i32 = 0; - let max: i32 = raw_text.length(); - while i < max { - i = raw_text.index_of(&prefix, i); - if i < 0 { - break; - } - // Skip past this prefix we found to start - i += prefix.length(); - // Found the start of a match here - let start: i32 = i; - let mut more: bool = true; - while more { - i = raw_text.index_of(end_char, i); - if i < 0 { - // No terminating end character? uh, done. Set i such that loop terminates and break - i = raw_text.length(); - more = false; - } else if ::count_preceding_backslashes(&raw_text, i) % 2 != 0 { - // semicolon was escaped (odd count of preceding backslashes) so continue - i += 1; - } else { - // found a match - if matches == null { - // lazy init - matches = Vec::new(3); - } - let mut element: String = ::unescape_backslash(&raw_text.substring(start, i)); - if trim { - element = element.trim(); - } - if !element.is_empty() { - matches.add(&element); - } - i += 1; - more = false; - } - } - } - if matches == null || matches.is_empty() { - return null; - } - return matches.to_array(&EMPTY_STR_ARRAY); - } - - fn count_preceding_backslashes(s: &CharSequence, pos: i32) -> i32 { - let mut count: i32 = 0; - { - let mut i: i32 = pos - 1; - while i >= 0 { - { - if s.char_at(i) == '\\' { - count += 1; - } else { - break; - } - } - i -= 1; - } - } - - return count; - } - - fn match_single_prefixed_field( - prefix: &String, - raw_text: &String, - end_char: char, - trim: bool, - ) -> String { - let matches: Vec = ::match_prefixed_field(&prefix, &raw_text, end_char, trim); - return if matches == null { null } else { matches[0] }; - } -} - -// AbstractDoCoMoResultParser.java -/** - *

See - * - * DoCoMo's documentation about the result types represented by subclasses of this class.

- * - *

Thanks to Jeff Griffin for proposing rewrite of these classes that relies less - * on exception-based mechanisms during parsing.

- * - * @author Sean Owen - */ - -trait AbstractDoCoMoResultParser: ResultParser { - fn match_do_co_mo_prefixed_field(prefix: &String, raw_text: &String) -> Vec { - return match_prefixed_field(&prefix, &raw_text, ';', true); - } - - fn match_single_do_co_mo_prefixed_field( - prefix: &String, - raw_text: &String, - trim: bool, - ) -> String { - return match_single_prefixed_field(&prefix, &raw_text, ';', trim); - } -} - -// AddressBookAUResultParser.java -/** - * Implements KDDI AU's address book format. See - * - * http://www.au.kddi.com/ezfactory/tec/two_dimensions/index.html. - * (Thanks to Yuzo for translating!) - * - * @author Sean Owen - */ -pub struct AddressBookAUResultParser; - -impl ResultParser for AddressBookAUResultParser {} - -impl AddressBookAUResultParser { - pub fn parse(&self, result: &Result) -> AddressBookParsedResult { - let raw_text: String = get_massaged_text(result); - // MEMORY is mandatory; seems like a decent indicator, as does end-of-record separator CR/LF - if !raw_text.contains("MEMORY") || !raw_text.contains("\r\n") { - return null; - } - // NAME1 and NAME2 have specific uses, namely written name and pronunciation, respectively. - // Therefore we treat them specially instead of as an array of names. - let name: String = match_single_prefixed_field("NAME1:", &raw_text, '\r', true); - let pronunciation: String = match_single_prefixed_field("NAME2:", &raw_text, '\r', true); - let phone_numbers: Vec = ::match_multiple_value_prefix("TEL", &raw_text); - let emails: Vec = ::match_multiple_value_prefix("MAIL", &raw_text); - let note: String = match_single_prefixed_field("MEMORY:", &raw_text, '\r', false); - let address: String = match_single_prefixed_field("ADD:", &raw_text, '\r', true); - let addresses: Vec = if address == null { null } else { vec![address] }; - return AddressBookParsedResult::new( - &maybe_wrap(&name), - null, - Some(&pronunciation), - &phone_numbers, - null, - &emails, - null, - null, - Some(¬e), - &addresses, - null, - null, - null, - null, - null, - null, - ); - } - - fn match_multiple_value_prefix(prefix: &String, raw_text: &String) -> Vec { - let mut values: Vec = null; - // For now, always 3, and always trim - { - let mut i: i32 = 1; - while i <= 3 { - { - let value: String = match_single_prefixed_field( - format!("{}{}:", prefix, i), - &raw_text, - '\r', - true, - ); - if value == null { - break; - } - if values == null { - // lazy init - values = Vec::new(); - } - values.add(&value); - } - i += 1; - } - } - - if values == null { - return null; - } - return values.to_array(EMPTY_STR_ARRAY); - } -} - -// AddressBookDoCoMoResultParser.java -/** - * Implements the "MECARD" address book entry format. - * - * Supported keys: N, SOUND, TEL, EMAIL, NOTE, ADR, BDAY, URL, plus ORG - * Unsupported keys: TEL-AV, NICKNAME - * - * Except for TEL, multiple values for keys are also not supported; - * the first one found takes precedence. - * - * Our understanding of the MECARD format is based on this document: - * - * http://www.mobicode.org.tw/files/OMIA%20Mobile%20Bar%20Code%20Standard%20v3.2.1.doc - * - * @author Sean Owen - */ -pub struct AddressBookDoCoMoResultParser; - -impl AbstractDoCoMoResultParser for AddressBookDoCoMoResultParser {} - -impl AddressBookDoCoMoResultParser { - pub fn parse(&self, result: &Result) -> AddressBookParsedResult { - let raw_text: String = get_massaged_text(result); - if !raw_text.starts_with("MECARD:") { - return null; - } - let raw_name: Vec = match_do_co_mo_prefixed_field("N:", &raw_text); - if raw_name == null { - return null; - } - let name: String = ::parse_name(raw_name[0]); - let pronunciation: String = match_single_do_co_mo_prefixed_field("SOUND:", &raw_text, true); - let phone_numbers: Vec = match_do_co_mo_prefixed_field("TEL:", &raw_text); - let emails: Vec = match_do_co_mo_prefixed_field("EMAIL:", &raw_text); - let note: String = match_single_do_co_mo_prefixed_field("NOTE:", &raw_text, false); - let addresses: Vec = match_do_co_mo_prefixed_field("ADR:", &raw_text); - let mut birthday: String = match_single_do_co_mo_prefixed_field("BDAY:", &raw_text, true); - if !is_string_of_digits(&birthday, 8) { - // No reason to throw out the whole card because the birthday is formatted wrong. - birthday = null; - } - let urls: Vec = match_do_co_mo_prefixed_field("URL:", &raw_text); - // Although ORG may not be strictly legal in MECARD, it does exist in VCARD and we might as well - // honor it when found in the wild. - let org: String = match_single_do_co_mo_prefixed_field("ORG:", &raw_text, true); - return AddressBookParsedResult::new( - &maybe_wrap(&name), - null, - Some(&pronunciation), - &phone_numbers, - null, - &emails, - null, - null, - Some(¬e), - &addresses, - null, - Some(&org), - Some(&birthday), - null, - Some(&urls), - null, - ); - } - - fn parse_name(name: &String) -> String { - let comma: i32 = name.index_of(','); - if comma >= 0 { - // Format may be last,first; switch it around - return name.substring(comma + 1) + ' ' + name.substring(0, comma); - } - return name; - } -} - -// AddressBookParsedResult.java -/** - * Represents a parsed result that encodes contact information, like that in an address book - * entry. - * - * @author Sean Owen - */ -pub struct AddressBookParsedResult { - //super: ParsedResult; - names: Vec, - - nicknames: Vec, - - pronunciation: String, - - phone_numbers: Vec, - - phone_types: Vec, - - emails: Vec, - - email_types: Vec, - - instant_messenger: String, - - note: String, - - addresses: Vec, - - address_types: Vec, - - org: String, - - birthday: String, - - title: String, - - urls: Vec, - - geo: Vec, -} - -impl ParsedResult for AddressBookParsedResult {} - -impl AddressBookParsedResult { - pub fn new( - names: &Vec, - nicknames: Option<&Vec>, - pronunciation: Option<&String>, - phone_numbers: &Vec, - phone_types: &Vec, - emails: &Vec, - email_types: &Vec, - instant_messenger: Option<&String>, - note: Option<&String>, - addresses: &Vec, - address_types: &Vec, - org: Option<&String>, - birthday: Option<&String>, - title: Option<&String>, - urls: Option<&Vec>, - geo: Option<&Vec>, - ) -> Result { - if phone_numbers != null && phone_types != null && phone_numbers.len() != phone_types.len() - { - return Err(IllegalArgumentException::new( - "Phone numbers and types lengths differ", - )); - } - if emails != null && email_types != null && emails.len() != email_types.len() { - return Err(IllegalArgumentException::new( - "Emails and types lengths differ", - )); - } - if addresses != null && address_types != null && addresses.len() != address_types.len() { - return Err(IllegalArgumentException::new( - "Addresses and types lengths differ", - )); - } - Ok(Self { - names: names, - nicknames: nicknames, - pronunciation: pronunciation, - phone_numbers: phone_numbers, - phone_types: phone_types, - emails: emails, - email_types: email_types, - instant_messenger: instant_messenger, - note: note, - addresses: addresses, - address_types: address_types, - org: org, - birthday: birthday, - title: title, - urls: urls, - geo: geo, - }) - } - - pub fn get_names(&self) -> Vec { - return self.names; - } - - pub fn get_nicknames(&self) -> Vec { - return self.nicknames; - } - - /** - * In Japanese, the name is written in kanji, which can have multiple readings. Therefore a hint - * is often provided, called furigana, which spells the name phonetically. - * - * @return The pronunciation of the getNames() field, often in hiragana or katakana. - */ - pub fn get_pronunciation(&self) -> String { - return self.pronunciation; - } - - pub fn get_phone_numbers(&self) -> Vec { - return self.phone_numbers; - } - - /** - * @return optional descriptions of the type of each phone number. It could be like "HOME", but, - * there is no guaranteed or standard format. - */ - pub fn get_phone_types(&self) -> Vec { - return self.phone_types; - } - - pub fn get_emails(&self) -> Vec { - return self.emails; - } - - /** - * @return optional descriptions of the type of each e-mail. It could be like "WORK", but, - * there is no guaranteed or standard format. - */ - pub fn get_email_types(&self) -> Vec { - return self.email_types; - } - - pub fn get_instant_messenger(&self) -> String { - return self.instant_messenger; - } - - pub fn get_note(&self) -> String { - return self.note; - } - - pub fn get_addresses(&self) -> Vec { - return self.addresses; - } - - /** - * @return optional descriptions of the type of each e-mail. It could be like "WORK", but, - * there is no guaranteed or standard format. - */ - pub fn get_address_types(&self) -> Vec { - return self.address_types; - } - - pub fn get_title(&self) -> String { - return self.title; - } - - pub fn get_org(&self) -> String { - return self.org; - } - - pub fn get_u_r_ls(&self) -> Vec { - return self.urls; - } - - /** - * @return birthday formatted as yyyyMMdd (e.g. 19780917) - */ - pub fn get_birthday(&self) -> String { - return self.birthday; - } - - /** - * @return a location as a latitude/longitude pair - */ - pub fn get_geo(&self) -> Vec { - return self.geo; - } - - pub fn get_display_result(&self) -> String { - let result: String = String::new(); - maybe_append(&self.names, &result); - maybe_append(&self.nicknames, &result); - maybe_append(&self.pronunciation, &result); - maybe_append(&self.title, &result); - maybe_append(&self.org, &result); - maybe_append(&self.addresses, &result); - maybe_append(&self.phone_numbers, &result); - maybe_append(&self.emails, &result); - maybe_append(&self.instant_messenger, &result); - maybe_append(&self.urls, &result); - maybe_append(&self.birthday, &result); - maybe_append(&self.geo, &result); - maybe_append(&self.note, &result); - return result.to_string(); - } -} - -// BizcardResultParser.java -/** - * Implements the "BIZCARD" address book entry format, though this has been - * largely reverse-engineered from examples observed in the wild -- still - * looking for a definitive reference. - * - * @author Sean Owen - */ -pub struct BizcardResultParser; - -impl AbstractDoCoMoResultParser for BizcardResultParser {} - -impl BizcardResultParser { - // Yes, we extend AbstractDoCoMoResultParser since the format is very much - // like the DoCoMo MECARD format, but this is not technically one of - // DoCoMo's proposed formats - pub fn parse(&self, result: &Result) -> AddressBookParsedResult { - let raw_text: String = get_massaged_text(result); - if !raw_text.starts_with("BIZCARD:") { - return null; - } - let first_name: String = match_single_do_co_mo_prefixed_field("N:", &raw_text, true); - let last_name: String = match_single_do_co_mo_prefixed_field("X:", &raw_text, true); - let full_name: String = ::build_name(&first_name, &last_name); - let title: String = match_single_do_co_mo_prefixed_field("T:", &raw_text, true); - let org: String = match_single_do_co_mo_prefixed_field("C:", &raw_text, true); - let addresses: Vec = match_do_co_mo_prefixed_field("A:", &raw_text); - let phone_number1: String = match_single_do_co_mo_prefixed_field("B:", &raw_text, true); - let phone_number2: String = match_single_do_co_mo_prefixed_field("M:", &raw_text, true); - let phone_number3: String = match_single_do_co_mo_prefixed_field("F:", &raw_text, true); - let email: String = match_single_do_co_mo_prefixed_field("E:", &raw_text, true); - return AddressBookParsedResult::new( - &maybe_wrap(&full_name), - null, - null, - &::build_phone_numbers(&phone_number1, &phone_number2, &phone_number3), - null, - &maybe_wrap(&email), - null, - null, - null, - &addresses, - null, - Some(&org), - null, - Some(&title), - null, - null, - ); - } - - fn build_phone_numbers(number1: &String, number2: &String, number3: &String) -> Vec { - let numbers: List = Vec::new(); - if number1 != null { - numbers.add(&number1); - } - if number2 != null { - numbers.add(&number2); - } - if number3 != null { - numbers.add(&number3); - } - let size: i32 = numbers.size(); - if size == 0 { - return null; - } - return numbers.to_array([None; size]); - } - - fn build_name(first_name: &String, last_name: &String) -> String { - if first_name == null { - return last_name; - } else { - return if last_name == null { - first_name - } else { - format!("{} {}", first_name, last_name) - }; - } - } -} - -// BookmarkDoCoMoResultParser.java -/** - * @author Sean Owen - */ -pub struct BookmarkDoCoMoResultParser { - //super: AbstractDoCoMoResultParser; -} - -impl AbstractDoCoMoResultParser for BookmarkDoCoMoResultParser {} - -impl BookmarkDoCoMoResultParser { - pub fn parse(&self, result: &Result) -> URIParsedResult { - let raw_text: String = result.get_text(); - if !raw_text.starts_with("MEBKM:") { - return null; - } - let title: String = match_single_do_co_mo_prefixed_field("TITLE:", &raw_text, true); - let raw_uri: Vec = match_do_co_mo_prefixed_field("URL:", &raw_text); - if raw_uri == null { - return null; - } - let uri: String = raw_uri[0]; - return if URIResultParser::is_basically_valid_u_r_i(&uri) { - URIParsedResult::new(&uri, &title) - } else { - null - }; - } -} - -// CalendarParsedResult.java -/** - * Represents a parsed result that encodes a calendar event at a certain time, optionally - * with attendees and a location. - * - * @author Sean Owen - */ - -const RFC2445_DURATION: Pattern = - Pattern::compile("P(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?"); - -const RFC2445_DURATION_FIELD_UNITS: vec![Vec; 5] = vec![ - // 1 week - 7 * 24 * 60 * 60 * 1000, // 1 day - 24 * 60 * 60 * 1000, // 1 hour - 60 * 60 * 1000, // 1 minute - 60 * 1000, // 1 second - 1000, -]; - -const DATE_TIME: Pattern = Pattern::compile("[0-9]{8}(T[0-9]{6}Z?)?"); -pub struct CalendarParsedResult { - //super: ParsedResult; - summary: String, - - start: i64, - - start_all_day: bool, - - end: i64, - - end_all_day: bool, - - location: String, - - organizer: String, - - attendees: Vec, - - description: String, - - latitude: f64, - - longitude: f64, -} - -impl ParsedResult for CalendarParsedResult {} - -impl CalendarParsedResult { - pub fn new( - summary: &String, - start_string: &String, - end_string: &String, - duration_string: &String, - location: &String, - organizer: &String, - attendees: &Vec, - description: &String, - latitude: f64, - longitude: f64, - ) -> Result { - let new_cpr: Self; - - new_cpr.summary = summary; - - let strt = CalendarParsedResult::parse_date(&start_string); - if strt.is_err() { - return Err(IllegalArgumentException::new(&pe.to_string())); - } - new_cpr.start = strt.unwrap(); - - if end_string == null { - let duration_m_s: i64 = ::parse_duration_m_s(&duration_string); - new_cpr.end = if duration_m_s < 0 { - -1 - } else { - start + duration_m_s - }; - } else { - let en = Self::parse_date(&end_string); - if en.is_err() { - return Err(IllegalArgumentException::new(&pe.to_string())); - } - new_cpr.end = ::parse_date(&end_string); - } - new_cpr.startAllDay = start_string.length() == 8; - new_cpr.endAllDay = end_string != null && end_string.length() == 8; - new_cpr.location = location; - new_cpr.organizer = organizer; - new_cpr.attendees = attendees; - new_cpr.description = description; - new_cpr.latitude = latitude; - new_cpr.longitude = longitude; - - Ok(new_cpr) - } - - pub fn get_summary(&self) -> String { - return self.summary; - } - - /** - * @return start time - * @deprecated use {@link #getStartTimestamp()} - */ - pub fn get_start(&self) -> Date { - return Date::new(self.start); - } - - /** - * @return start time - * @see #getEndTimestamp() - */ - pub fn get_start_timestamp(&self) -> i64 { - return self.start; - } - - /** - * @return true if start time was specified as a whole day - */ - pub fn is_start_all_day(&self) -> bool { - return self.start_all_day; - } - - /** - * @return event end {@link Date}, or {@code null} if event has no duration - * @deprecated use {@link #getEndTimestamp()} - */ - pub fn get_end(&self) -> Date { - return if self.end < 0 { - null - } else { - Date::new(self.end) - }; - } - - /** - * @return event end {@link Date}, or -1 if event has no duration - * @see #getStartTimestamp() - */ - pub fn get_end_timestamp(&self) -> i64 { - return self.end; - } - - /** - * @return true if end time was specified as a whole day - */ - pub fn is_end_all_day(&self) -> bool { - return self.end_all_day; - } - - pub fn get_location(&self) -> String { - return self.location; - } - - pub fn get_organizer(&self) -> String { - return self.organizer; - } - - pub fn get_attendees(&self) -> Vec { - return self.attendees; - } - - pub fn get_description(&self) -> String { - return self.description; - } - - pub fn get_latitude(&self) -> f64 { - return self.latitude; - } - - pub fn get_longitude(&self) -> f64 { - return self.longitude; - } - - pub fn get_display_result(&self) -> String { - let result: String = String::new(); - maybe_append(&self.summary, &result); - maybe_append(&::format(self.start_all_day, self.start), &result); - maybe_append(&::format(self.end_all_day, self.end), &result); - maybe_append(&self.location, &result); - maybe_append(&self.organizer, &result); - maybe_append(&self.attendees, &result); - maybe_append(&self.description, &result); - return result.to_string(); - } - - /** - * Parses a string as a date. RFC 2445 allows the start and end fields to be of type DATE (e.g. 20081021) - * or DATE-TIME (e.g. 20081021T123000 for local time, or 20081021T123000Z for UTC). - * - * @param when The string to parse - * @throws ParseException if not able to parse as a date - */ - fn parse_date(when: &String) -> Result { - if !DATE_TIME::is_match(&when) { - return Err(ParseException::new(&when, 0)); - } - if when.length() == 8 { - // Show only year/month/day - let format: DateFormat = SimpleDateFormat::new("yyyyMMdd", Locale::ENGLISH); - // For dates without a time, for purposes of interacting with Android, the resulting timestamp - // needs to be midnight of that day in GMT. See: - // http://code.google.com/p/android/issues/detail?id=8330 - format.set_time_zone(&TimeZone::get_time_zone("GMT")); - return Ok(format.parse(&when).get_time()); - } - // The when string can be local time, or UTC if it ends with a Z - if when.length() == 16 && when.char_at(15) == 'Z' { - let mut milliseconds: i64 = ::parse_date_time_string(&when.substring(0, 15)); - let calendar: Calendar = GregorianCalendar::new(); - // Account for time zone difference - milliseconds += calendar.get(Calendar::ZONE_OFFSET); - // Might need to correct for daylight savings time, but use target time since - // now might be in DST but not then, or vice versa - calendar.set_time(Date::new(milliseconds)); - return Ok(milliseconds + calendar.get(Calendar::DST_OFFSET)); - } - return Ok(::parse_date_time_string(&when)); - } - - fn format(all_day: bool, date: i64) -> String { - if date < 0 { - return null; - } - let format: DateFormat = if all_day { - DateFormat::get_date_instance(DateFormat::MEDIUM) - } else { - DateFormat::get_date_time_instance(DateFormat::MEDIUM, DateFormat::MEDIUM) - }; - return format.format(date); - } - - fn parse_duration_m_s(duration_string: &CharSequence) -> i64 { - if duration_string == null { - return -1; - } - let m: Matcher = RFC2445_DURATION::matcher(&duration_string); - if !m.matches() { - return -1; - } - let duration_m_s: i64 = 0; - { - let mut i: i32 = 0; - while i < RFC2445_DURATION_FIELD_UNITS.len() { - { - let field_value: String = m.group(i + 1); - if field_value != null { - duration_m_s += - RFC2445_DURATION_FIELD_UNITS[i] * Integer::parse_int(&field_value); - } - } - i += 1; - } - } - - return duration_m_s; - } - - fn parse_date_time_string(date_time_string: &String) -> Result { - let format: DateFormat = SimpleDateFormat::new("yyyyMMdd'T'HHmmss", Locale::ENGLISH); - return Ok(format.parse(&date_time_string).get_time()); - } -} - -// EmailAddressParsedResult.java -/** - * Represents a parsed result that encodes an email message including recipients, subject - * and body text. - * - * @author Sean Owen - */ -pub struct EmailAddressParsedResult { - //super: ParsedResult; - tos: Vec, - - ccs: Vec, - - bccs: Vec, - - subject: String, - - body: String, -} - -impl ParsedResult for EmailAddressParsedResult {} - -impl EmailAddressParsedResult { - fn new( - tos: &Vec, - ccs: Option<&Vec>, - bccs: Option<&Vec>, - subject: Option<&String>, - body: Option<&String>, - ) -> Self { - //super(ParsedResultType::EMAIL_ADDRESS); - Self { - tos: tos, - ccs: ccs, - bccs: bccs, - subject: subject, - body: body, - } - } - - /** - * @return first elements of {@link #getTos()} or {@code null} if none - * @deprecated use {@link #getTos()} - */ - pub fn get_email_address(&self) -> String { - return if self.tos == null || self.tos.len() == 0 { - null - } else { - self.tos[0] - }; - } - - pub fn get_tos(&self) -> Vec { - return self.tos; - } - - pub fn get_c_cs(&self) -> Vec { - return self.ccs; - } - - pub fn get_b_c_cs(&self) -> Vec { - return self.bccs; - } - - pub fn get_subject(&self) -> String { - return self.subject; - } - - pub fn get_body(&self) -> String { - return self.body; - } - - /** - * @return "mailto:" - * @deprecated without replacement - */ - pub fn get_mailto_u_r_i(&self) -> &'static str { - return "mailto:"; - } - - pub fn get_display_result(&self) -> String { - let result: String = String::new(); - maybe_append(&self.tos, &result); - maybe_append(&self.ccs, &result); - maybe_append(&self.bccs, &result); - maybe_append(&self.subject, &result); - maybe_append(&self.body, &result); - return result.to_string(); - } -} - -// EmailAddressResultParser.java -/** - * Represents a result that encodes an e-mail address, either as a plain address - * like "joe@example.org" or a mailto: URL like "mailto:joe@example.org". - * - * @author Sean Owen - */ - -const COMMA: Regex = Regex::new(","); -pub struct EmailAddressResultParser { - //super: ResultParser; -} - -impl ResultParser for EmailAddressResultParser {} - -impl EmailAddressResultParser { - pub fn parse(&self, result: &Result) -> EmailAddressParsedResult { - let raw_text: String = get_massaged_text(result); - if raw_text.starts_with("mailto:") || raw_text.starts_with("MAILTO:") { - // If it starts with mailto:, assume it is definitely trying to be an email address - let host_email: String = raw_text.substring(7); - let query_start: i32 = host_email.index_of('?'); - if query_start >= 0 { - host_email = host_email.substring(0, query_start); - } - - let ud = url_decode(&host_email); - if ud.is_err() { - return None; - } - host_email = ud; - - let mut tos: Vec = null; - if !host_email.is_empty() { - tos = COMMA::split(&host_email); - } - let name_values: Map = parse_name_value_pairs(&raw_text); - let mut ccs: Vec = null; - let mut bccs: Vec = null; - let mut subject: String = null; - let mut body: String = null; - if name_values != null { - if tos == null { - let tos_string: String = name_values.get("to"); - if tos_string != null { - tos = COMMA::split(&tos_string); - } - } - let cc_string: String = name_values.get("cc"); - if cc_string != null { - ccs = COMMA::split(&cc_string); - } - let bcc_string: String = name_values.get("bcc"); - if bcc_string != null { - bccs = COMMA::split(&bcc_string); - } - subject = name_values.get("subject"); - body = name_values.get("body"); - } - return EmailAddressParsedResult::new( - &tos, - Some(&ccs), - Some(&bccs), - Some(&subject), - Some(&body), - ); - } else { - if !EmailDoCoMoResultParser::is_basically_valid_email_address(&raw_text) { - return null; - } - return EmailAddressParsedResult::new(&raw_text, None, None, None, None); - } - } -} - -// EmailDoCoMoResultParser.java -/** - * Implements the "MATMSG" email message entry format. - * - * Supported keys: TO, SUB, BODY - * - * @author Sean Owen - */ - -const ATEXT_ALPHANUMERIC: Regex = Regex::new("[a-zA-Z0-9@.!#$%&'*+\\-/=?^_`{|}~]+"); -pub struct EmailDoCoMoResultParser { - //super: AbstractDoCoMoResultParser; -} - -impl AbstractDoCoMoResultParser for EmailDoCoMoResultParser {} - -impl EmailDoCoMoResultParser { - pub fn parse(&self, result: &Result) -> EmailAddressParsedResult { - let raw_text: String = get_massaged_text(result); - if !raw_text.starts_with("MATMSG:") { - return null; - } - let tos: Vec = match_do_co_mo_prefixed_field("TO:", &raw_text); - if tos == null { - return null; - } - for to in tos { - if !::is_basically_valid_email_address(&to) { - return null; - } - } - let subject: String = match_single_do_co_mo_prefixed_field("SUB:", &raw_text, false); - let body: String = match_single_do_co_mo_prefixed_field("BODY:", &raw_text, false); - return EmailAddressParsedResult::new(&tos, null, null, Some(&subject), Some(&body)); - } - - /** - * This implements only the most basic checking for an email address's validity -- that it contains - * an '@' and contains no characters disallowed by RFC 2822. This is an overly lenient definition of - * validity. We want to generally be lenient here since this class is only intended to encapsulate what's - * in a barcode, not "judge" it. - */ - fn is_basically_valid_email_address(email: &String) -> bool { - return email != null && ATEXT_ALPHANUMERIC::is_match(&email) && email.index_of('@') >= 0; - } -} - -// ExpandedProductParsedResult.java -/** - * Represents a parsed result that encodes extended product information as encoded - * by the RSS format, like weight, price, dates, etc. - * - * @author Antonio Manuel Benjumea Conde, Servinform, S.A. - * @author Agustín Delgado, Servinform, S.A. - */ - -const KILOGRAM: &'static str = "KG"; - -const POUND: &'static str = "LB"; -#[Derive(Eq, PartialEq, Hash)] -pub struct ExpandedProductParsedResult { - //super: ParsedResult; - raw_text: String, - - product_i_d: String, - - sscc: String, - - lot_number: String, - - production_date: String, - - packaging_date: String, - - best_before_date: String, - - expiration_date: String, - - weight: String, - - weight_type: String, - - weight_increment: String, - - price: String, - - price_increment: String, - - price_currency: String, - - // For AIS that not exist in this object - uncommon_a_is: Map, -} - -impl ParsedResult for ExpandedProductParsedResult {} - -impl ExpandedProductParsedResult { - pub fn new( - raw_text: &String, - product_i_d: &String, - sscc: &String, - lot_number: &String, - production_date: &String, - packaging_date: &String, - best_before_date: &String, - expiration_date: &String, - weight: &String, - weight_type: &String, - weight_increment: &String, - price: &String, - price_increment: &String, - price_currency: &String, - uncommon_a_is: &Map, - ) -> Self { - let new_eppr: Self; - new_eppr.rawText = raw_text; - new_eppr.productID = product_i_d; - new_eppr.sscc = sscc; - new_eppr.lotNumber = lot_number; - new_eppr.productionDate = production_date; - new_eppr.packagingDate = packaging_date; - new_eppr.bestBeforeDate = best_before_date; - new_eppr.expirationDate = expiration_date; - new_eppr.weight = weight; - new_eppr.weightType = weight_type; - new_eppr.weightIncrement = weight_increment; - new_eppr.price = price; - new_eppr.priceIncrement = price_increment; - new_eppr.priceCurrency = price_currency; - new_eppr.uncommonAIs = uncommon_a_is; - - new_eppr - } - - pub fn get_raw_text(&self) -> String { - return self.raw_text; - } - - pub fn get_product_i_d(&self) -> String { - return self.product_i_d; - } - - pub fn get_sscc(&self) -> String { - return self.sscc; - } - - pub fn get_lot_number(&self) -> String { - return self.lot_number; - } - - pub fn get_production_date(&self) -> String { - return self.production_date; - } - - pub fn get_packaging_date(&self) -> String { - return self.packaging_date; - } - - pub fn get_best_before_date(&self) -> String { - return self.best_before_date; - } - - pub fn get_expiration_date(&self) -> String { - return self.expiration_date; - } - - pub fn get_weight(&self) -> String { - return self.weight; - } - - pub fn get_weight_type(&self) -> String { - return self.weight_type; - } - - pub fn get_weight_increment(&self) -> String { - return self.weight_increment; - } - - pub fn get_price(&self) -> String { - return self.price; - } - - pub fn get_price_increment(&self) -> String { - return self.price_increment; - } - - pub fn get_price_currency(&self) -> String { - return self.price_currency; - } - - pub fn get_uncommon_a_is(&self) -> Map { - return self.uncommon_a_is; - } - - pub fn get_display_result(&self) -> String { - return String::value_of(&self.raw_text); - } -} - -// ExpandedProductResultParser.java -/** - * Parses strings of digits that represent a RSS Extended code. - * - * @author Antonio Manuel Benjumea Conde, Servinform, S.A. - * @author Agustín Delgado, Servinform, S.A. - */ -pub struct ExpandedProductResultParser { - //super: ResultParser; -} - -impl ResultParser for ExpandedProductResultParser {} - -impl ExpandedProductResultParser { - pub fn parse(&self, result: &Result) -> ExpandedProductParsedResult { - let format: BarcodeFormat = result.get_barcode_format(); - if format != BarcodeFormat::RSS_EXPANDED { - // ExtendedProductParsedResult NOT created. Not a RSS Expanded barcode - return null; - } - let raw_text: String = get_massaged_text(result); - let product_i_d: String = null; - let mut sscc: String = null; - let lot_number: String = null; - let production_date: String = null; - let packaging_date: String = null; - let best_before_date: String = null; - let expiration_date: String = null; - let mut weight: String = null; - let weight_type: String = null; - let weight_increment: String = null; - let mut price: String = null; - let price_increment: String = null; - let price_currency: String = null; - let uncommon_a_is: Map = HashMap::new(); - let mut i: i32 = 0; - while i < raw_text.length() { - let ai: String = ::find_a_ivalue(i, &raw_text); - if ai == null { - // ExtendedProductParsedResult NOT created. Not match with RSS Expanded pattern - return null; - } - i += ai.length() + 2; - let value: String = ::find_value(i, &raw_text); - i += value.length(); - match ai.as_str() { - "00" => { - sscc = value; - break; - } - "01" => { - product_i_d = value; - break; - } - "10" => { - lot_number = value; - break; - } - "11" => { - production_date = value; - break; - } - "13" => { - packaging_date = value; - break; - } - "15" => { - best_before_date = value; - break; - } - "17" => { - expiration_date = value; - break; - } - "3100" => {} - "3101" => {} - "3102" => {} - "3103" => {} - "3104" => {} - "3105" => {} - "3106" => {} - "3107" => {} - "3108" => {} - "3109" => { - weight = value; - weight_type = ExpandedProductParsedResult::KILOGRAM; - weight_increment = ai.substring(3); - break; - } - "3200" => {} - "3201" => {} - "3202" => {} - "3203" => {} - "3204" => {} - "3205" => {} - "3206" => {} - "3207" => {} - "3208" => {} - "3209" => { - weight = value; - weight_type = ExpandedProductParsedResult::POUND; - weight_increment = ai.substring(3); - break; - } - "3920" => {} - "3921" => {} - "3922" => {} - "3923" => { - price = value; - price_increment = ai.substring(3); - break; - } - "3930" => {} - "3931" => {} - "3932" => {} - "3933" => { - if value.length() < 4 { - // ExtendedProductParsedResult NOT created. Not match with RSS Expanded pattern - return null; - } - price = value.substring(3); - price_currency = value.substring(0, 3); - price_increment = ai.substring(3); - break; - } - _ => { - // No match with common AIs - uncommon_a_is.put(&ai, &value); - break; - } - } - } - return ExpandedProductParsedResult::new( - &raw_text, - &product_i_d, - &sscc, - &lot_number, - &production_date, - &packaging_date, - &best_before_date, - &expiration_date, - &weight, - &weight_type, - &weight_increment, - &price, - &price_increment, - &price_currency, - &uncommon_a_is, - ); - } - - fn find_a_ivalue(i: i32, raw_text: &String) -> String { - let c: char = raw_text.char_at(i); - // First character must be a open parenthesis.If not, ERROR - if c != '(' { - return null; - } - let raw_text_aux: CharSequence = raw_text.substring(i + 1); - let buf: String = String::new(); - { - let mut index: i32 = 0; - while index < raw_text_aux.length() { - { - let current_char: char = raw_text_aux.char_at(index); - if current_char == ')' { - return buf.to_string(); - } - if current_char < '0' || current_char > '9' { - return null; - } - buf.append(current_char); - } - index += 1; - } - } - - return buf.to_string(); - } - - fn find_value(i: i32, raw_text: &String) -> String { - let buf: String = String::new(); - let raw_text_aux: String = raw_text.substring(i); - { - let mut index: i32 = 0; - while index < raw_text_aux.length() { - { - let c: char = raw_text_aux.char_at(index); - if c == '(' { - // with the iteration - if ::find_a_ivalue(index, &raw_text_aux) != null { - break; - } - buf.append('('); - } else { - buf.append(c); - } - } - index += 1; - } - } - - return buf.to_string(); - } -} - -// GeoResultParser.java -/** - * Parses a "geo:" URI result, which specifies a location on the surface of - * the Earth as well as an optional altitude above the surface. See - * - * http://tools.ietf.org/html/draft-mayrhofer-geo-uri-00. - * - * @author Sean Owen - */ - -const GEO_URL_PATTERN: Regex = - Regex::new("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?"); -pub struct GeoResultParser { - //super: ResultParser; -} - -impl ResultParser for GeoResultParser {} - -impl GeoResultParser { - pub fn parse(&self, result: &Result) -> GeoParsedResult { - let raw_text: CharSequence = get_massaged_text(result); - let matcher: Matcher = GEO_URL_PATTERN::matcher(&raw_text); - if !matcher.matches() { - return null; - } - let query: String = matcher.group(4); - let mut latitude: f64; - let mut longitude: f64; - let mut altitude: f64; - let tryResult1 = 0; - - latitude = Double::parse_double(&matcher.group(1)); - if latitude > 90.0 || latitude < -90.0 { - return null; - } - longitude = Double::parse_double(&matcher.group(2)); - if longitude > 180.0 || longitude < -180.0 { - return null; - } - if matcher.group(3) == null { - altitude = 0.0; - } else { - altitude = Double::parse_double(&matcher.group(3)); - if altitude < 0.0 { - return null; - } - } - - return GeoParsedResult::new(latitude, longitude, altitude, &query); - } -} - -// GeoParsedResult.java -/** - * Represents a parsed result that encodes a geographic coordinate, with latitude, - * longitude and altitude. - * - * @author Sean Owen - */ -pub struct GeoParsedResult { - //super: ParsedResult; - latitude: f64, - - longitude: f64, - - altitude: f64, - - query: String, -} - -impl ParsedResult for GeoParsedResult {} - -impl GeoParsedResult { - fn new(latitude: f64, longitude: f64, altitude: f64, query: &String) -> Self { - Self { - latitude, - longitude, - altitude, - query, - } - } - - pub fn get_geo_u_r_i(&self) -> String { - let result: String = String::new(); - result.append("geo:"); - result.append(self.latitude); - result.append(','); - result.append(self.longitude); - if self.altitude > 0.0 { - result.append(','); - result.append(self.altitude); - } - if self.query != null { - result.append('?'); - result.append(&self.query); - } - return result.to_string(); - } - - /** - * @return latitude in degrees - */ - pub fn get_latitude(&self) -> f64 { - return self.latitude; - } - - /** - * @return longitude in degrees - */ - pub fn get_longitude(&self) -> f64 { - return self.longitude; - } - - /** - * @return altitude in meters. If not specified, in the geo URI, returns 0.0 - */ - pub fn get_altitude(&self) -> f64 { - return self.altitude; - } - - /** - * @return query string associated with geo URI or null if none exists - */ - pub fn get_query(&self) -> String { - return self.query; - } - - pub fn get_display_result(&self) -> String { - let result: String = String::new(); - result.append(self.latitude); - result.append(", "); - result.append(self.longitude); - if self.altitude > 0.0 { - result.append(", "); - result.append(self.altitude); - result.append('m'); - } - if self.query != null { - result.append(" ("); - result.append(&self.query); - result.append(')'); - } - return result.to_string(); - } -} - -// ProductParsedResult.java -/** - * Represents a parsed result that encodes a product by an identifier of some kind. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -pub struct ProductParsedResult { - // super: ParsedResult; - product_i_d: String, - - normalized_product_i_d: String, -} - -impl ParsedResult for ProductParsedResult {} - -impl ProductParsedResult { - fn new(product_i_d: &String, normalized_product_i_d: Option<&String>) -> Self { - Self { - product_i_d: product_i_d, - normalized_product_i_d: normalized_product_i_d.unwrap_or(product_i_d), - } - } - - pub fn get_product_i_d(&self) -> String { - return self.product_i_d; - } - - pub fn get_normalized_product_i_d(&self) -> String { - return self.normalized_product_i_d; - } - - pub fn get_display_result(&self) -> String { - return self.product_i_d; - } -} - -// ProductResultParser.java -/** - * Parses strings of digits that represent a UPC code. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -pub struct ProductResultParser { - //super: ResultParser; -} - -impl ResultParser for ProductResultParser {} - -impl ProductResultParser { - // Treat all UPC and EAN variants as UPCs, in the sense that they are all product barcodes. - pub fn parse(&self, result: &Result) -> ProductParsedResult { - let format: BarcodeFormat = result.get_barcode_format(); - if !(format == BarcodeFormat::UPC_A - || format == BarcodeFormat::UPC_E - || format == BarcodeFormat::EAN_8 - || format == BarcodeFormat::EAN_13) - { - return null; - } - let raw_text: String = get_massaged_text(result); - if !is_string_of_digits(&raw_text, &raw_text.length()) { - return null; - } - // Not actually checking the checksum again here - let normalized_product_i_d: String; - // Expand UPC-E for purposes of searching - if format == BarcodeFormat::UPC_E && raw_text.length() == 8 { - normalized_product_i_d = UPCEReader::convert_u_p_c_eto_u_p_c_a(&raw_text); - } else { - normalized_product_i_d = raw_text; - } - return ProductParsedResult::new(&raw_text, Some(&normalized_product_i_d)); - } -} - -// SMSMMSResultParser.java -/** - *

Parses an "sms:" URI result, which specifies a number to SMS. - * See RFC 5724 on this.

- * - *

This class supports "via" syntax for numbers, which is not part of the spec. - * For example "+12125551212;via=+12124440101" may appear as a number. - * It also supports a "subject" query parameter, which is not mentioned in the spec. - * These are included since they were mentioned in earlier IETF drafts and might be - * used.

- * - *

This actually also parses URIs starting with "mms:" and treats them all the same way, - * and effectively converts them to an "sms:" URI for purposes of forwarding to the platform.

- * - * @author Sean Owen - */ -pub struct SMSMMSResultParser { - //super: ResultParser; -} - -impl ResultParser for SMSMMSResultParser {} - -impl SMSMMSResultParser { - pub fn parse(&self, result: &Result) -> SMSParsedResult { - let raw_text: String = get_massaged_text(result); - if !(raw_text.starts_with("sms:") - || raw_text.starts_with("SMS:") - || raw_text.starts_with("mms:") - || raw_text.starts_with("MMS:")) - { - return null; - } - // Check up front if this is a URI syntax string with query arguments - let name_value_pairs: Map = parse_name_value_pairs(&raw_text); - let mut subject: String = null; - let mut body: String = null; - let query_syntax: bool = false; - if name_value_pairs != null && !name_value_pairs.is_empty() { - subject = name_value_pairs.get("subject"); - body = name_value_pairs.get("body"); - query_syntax = true; - } - // Drop sms, query portion - let query_start: i32 = raw_text.index_of('?', 4); - let sms_u_r_i_without_query: String; - // If it's not query syntax, the question mark is part of the subject or message - if query_start < 0 || !query_syntax { - sms_u_r_i_without_query = raw_text.substring(4); - } else { - sms_u_r_i_without_query = raw_text.substring(4, query_start); - } - let last_comma: i32 = -1; - let mut comma: i32; - let numbers: List = Vec::new(); - let vias: List = Vec::new(); - while (comma = sms_u_r_i_without_query.index_of(',', last_comma + 1)) > last_comma { - let number_part: String = sms_u_r_i_without_query.substring(last_comma + 1, comma); - ::add_number_via(&numbers, &vias, &number_part); - last_comma = comma; - } - ::add_number_via( - &numbers, - &vias, - &sms_u_r_i_without_query.substring(last_comma + 1), - ); - return SMSParsedResult::new( - &numbers.to_array(EMPTY_STR_ARRAY), - &vias.to_array(EMPTY_STR_ARRAY), - &subject, - &body, - ); - } - - fn add_number_via( - numbers: &Collection, - vias: &Collection, - number_part: &String, - ) { - let number_end: i32 = number_part.index_of(';'); - if number_end < 0 { - numbers.add(&number_part); - vias.add(null); - } else { - numbers.add(&number_part.substring(0, number_end)); - let maybe_via: String = number_part.substring(number_end + 1); - let mut via: String; - if maybe_via.starts_with("via=") { - via = maybe_via.substring(4); - } else { - via = null; - } - vias.add(&via); - } - } -} - -// SMSParsedResult.java -/** - * Represents a parsed result that encodes an SMS message, including recipients, subject - * and body text. - * - * @author Sean Owen - */ -pub struct SMSParsedResult { - //super: ParsedResult; - numbers: Vec, - - vias: Vec, - - subject: String, - - body: String, -} - -impl ParsedResult for SMSParsedResult {} - -impl SMSParsedResult { - pub fn new(numbers: &Vec, vias: &Vec, subject: &String, body: &String) -> Self { - Self { - numbers: numbers, - vias: vias, - subject: subject, - body: body, - } - } - - pub fn get_s_m_s_u_r_i(&self) -> String { - let result: String = String::new(); - result.append("sms:"); - let mut first: bool = true; - { - let mut i: i32 = 0; - while i < self.numbers.len() { - { - if first { - first = false; - } else { - result.append(','); - } - result.append(self.numbers[i]); - if self.vias != null && self.vias[i] != null { - result.append(";via="); - result.append(self.vias[i]); - } - } - i += 1; - } - } - - let has_body: bool = self.body != null; - let has_subject: bool = self.subject != null; - if has_body || has_subject { - result.append('?'); - if has_body { - result.append("body="); - result.append(&self.body); - } - if has_subject { - if has_body { - result.append('&'); - } - result.append("subject="); - result.append(&self.subject); - } - } - return result.to_string(); - } - - pub fn get_numbers(&self) -> Vec { - return self.numbers; - } - - pub fn get_vias(&self) -> Vec { - return self.vias; - } - - pub fn get_subject(&self) -> String { - return self.subject; - } - - pub fn get_body(&self) -> String { - return self.body; - } - - pub fn get_display_result(&self) -> String { - let result: String = String::new(); - maybe_append(&self.numbers, &result); - maybe_append(&self.subject, &result); - maybe_append(&self.body, &result); - return result.to_string(); - } -} - -// SMSTOMMSTOResultParser.java -/** - *

Parses an "smsto:" URI result, whose format is not standardized but appears to be like: - * {@code smsto:number(:body)}.

- * - *

This actually also parses URIs starting with "smsto:", "mmsto:", "SMSTO:", and - * "MMSTO:", and treats them all the same way, and effectively converts them to an "sms:" URI - * for purposes of forwarding to the platform.

- * - * @author Sean Owen - */ -pub struct SMSTOMMSTOResultParser { - //super: ResultParser; -} - -impl ResultParser for SMSTOMMSTOResultParser {} - -impl SMSTOMMSTOResultParser { - pub fn parse(&self, result: &Result) -> SMSParsedResult { - let raw_text: String = get_massaged_text(result); - if !(raw_text.starts_with("smsto:") - || raw_text.starts_with("SMSTO:") - || raw_text.starts_with("mmsto:") - || raw_text.starts_with("MMSTO:")) - { - return null; - } - // Thanks to dominik.wild for suggesting this enhancement to support - // smsto:number:body URIs - let mut number: String = raw_text.substring(6); - let mut body: String = null; - let body_start: i32 = number.index_of(':'); - if body_start >= 0 { - body = number.substring(body_start + 1); - number = number.substring(0, body_start); - } - return SMSParsedResult::new(&number, null, null, &body); - } -} - -// SMTPResultParser.java -/** - *

Parses an "smtp:" URI result, whose format is not standardized but appears to be like: - * {@code smtp[:subject[:body]]}.

- * - * @author Sean Owen - */ -pub struct SMTPResultParser { - //super: ResultParser; -} - -impl ResultParser for SMTPResultParser {} - -impl SMTPResultParser { - pub fn parse(&self, result: &Result) -> EmailAddressParsedResult { - let raw_text: String = get_massaged_text(result); - if !(raw_text.starts_with("smtp:") || raw_text.starts_with("SMTP:")) { - return null; - } - let email_address: String = raw_text.substring(5); - let mut subject: String = null; - let mut body: String = null; - let mut colon: i32 = email_address.index_of(':'); - if colon >= 0 { - subject = email_address.substring(colon + 1); - email_address = email_address.substring(0, colon); - colon = subject.index_of(':'); - if colon >= 0 { - body = subject.substring(colon + 1); - subject = subject.substring(0, colon); - } - } - return EmailAddressParsedResult::new( - &vec![email_address], - null, - null, - Some(&subject), - Some(&body), - ); - } -} - -// TelParsedResult.java -/** - * Represents a parsed result that encodes a telephone number. - * - * @author Sean Owen - */ -pub struct TelParsedResult { - //super: ParsedResult; - number: String, - - tel_u_r_i: String, - - title: String, -} - -impl ParsedResult for TelParsedResult {} - -impl TelParsedResult { - pub fn new(number: &String, tel_u_r_i: &String, title: &String) -> Self { - Self { - number: number, - tel_u_r_i: tel_u_r_i, - title: title, - } - } - - pub fn get_number(&self) -> String { - return self.number; - } - - pub fn get_tel_u_r_i(&self) -> String { - return self.tel_u_r_i; - } - - pub fn get_title(&self) -> String { - return self.title; - } - - pub fn get_display_result(&self) -> String { - let result: String = String::new(); - maybe_append(&self.number, &result); - maybe_append(&self.title, &result); - return result.to_string(); - } -} - -// TelResultParser.java -/** - * Parses a "tel:" URI result, which specifies a phone number. - * - * @author Sean Owen - */ -pub struct TelResultParser { - //super: ResultParser; -} - -impl ResultParser for TelResultParser {} - -impl TelResultParser { - pub fn parse(&self, result: &Result) -> TelParsedResult { - let raw_text: String = get_massaged_text(result); - if !raw_text.starts_with("tel:") && !raw_text.starts_with("TEL:") { - return null; - } - // Normalize "TEL:" to "tel:" - let tel_u_r_i: String = if raw_text.starts_with("TEL:") { - format!("tel:{}", raw_text.substring(4)) - } else { - raw_text - }; - // Drop tel, query portion - let query_start: i32 = raw_text.index_of('?', 4); - let number: String = if query_start < 0 { - raw_text.substring(4) - } else { - raw_text.substring(4, query_start) - }; - return TelParsedResult::new(&number, &tel_u_r_i, null); - } -} - -// TextParsedResult.java -/** - * A simple result type encapsulating a string that has no further - * interpretation. - * - * @author Sean Owen - */ -pub struct TextParsedResult { - //super: ParsedResult; - text: String, - - language: String, -} - -impl ParsedResult for TextParsedResult {} - -impl TextParsedResult { - pub fn new(text: &String, language: &String) -> Self { - Self { - text: text, - language: language, - } - } - - pub fn get_text(&self) -> String { - return self.text; - } - - pub fn get_language(&self) -> String { - return self.language; - } - - pub fn get_display_result(&self) -> String { - return self.text; - } -} - -// URIParsedResult.java -/** - * A simple result type encapsulating a URI that has no further interpretation. - * - * @author Sean Owen - */ -pub struct URIParsedResult { - //super: ParsedResult; - uri: String, - - title: String, -} - -impl ParsedResult for URIParsedResult {} - -impl URIParsedResult { - pub fn new(uri: &String, title: &String) -> Self { - Self { - uri: ::massage_u_r_i(&uri), - title: title, - } - } - - pub fn get_u_r_i(&self) -> String { - return self.uri; - } - - pub fn get_title(&self) -> String { - return self.title; - } - - /** - * @return true if the URI contains suspicious patterns that may suggest it intends to - * mislead the user about its true nature - * @deprecated see {@link URIResultParser#isPossiblyMaliciousURI(String)} - */ - pub fn is_possibly_malicious_u_r_i(&self) -> bool { - return URIResultParser::is_possibly_malicious_u_r_i(&self.uri); - } - - pub fn get_display_result(&self) -> String { - let result: String = String::new(); - maybe_append(&self.title, &result); - maybe_append(&self.uri, &result); - return result.to_string(); - } - - /** - * Transforms a string that represents a URI into something more proper, by adding or canonicalizing - * the protocol. - */ - fn massage_u_r_i(uri: &String) -> String { - uri = uri.trim(); - let protocol_end: i32 = uri.index_of(':'); - if protocol_end < 0 || ::is_colon_followed_by_port_number(&uri, protocol_end) { - // No protocol, or found a colon, but it looks like it is after the host, so the protocol is still missing, - // so assume http - uri = &format!("http://{}", uri); - } - return uri; - } - - fn is_colon_followed_by_port_number(uri: &String, protocol_end: i32) -> bool { - let start: i32 = protocol_end + 1; - let next_slash: i32 = uri.index_of('/', start); - if next_slash < 0 { - next_slash = uri.length(); - } - return ResultParser::is_substring_of_digits(&uri, start, next_slash - start); - } -} - -// URIResultParser.java -/** - * Tries to parse results that are a URI of some kind. - * - * @author Sean Owen - */ - -const ALLOWED_URI_CHARS_PATTERN: Regext = Regex::new("[-._~:/?#\\[\\]@!$&'()*+,;=%A-Za-z0-9]+"); - -const USER_IN_HOST: Regext = Regex::new(":/*([^/@]+)@[^/]+"); - -// See http://www.ietf.org/rfc/rfc2396.txt -const URL_WITH_PROTOCOL_PATTERN: Regext = Regex::new("[a-zA-Z][a-zA-Z0-9+-.]+:"); - -const URL_WITHOUT_PROTOCOL_PATTERN: Regext = Regex::new(&format!( - "([a-zA-Z0-9\\-]+\\.){1,6}[a-zA-Z]{2,}(:\\d{1,5})?(/|\\?|$)" -)); -pub struct URIResultParser { - //super: ResultParser; -} - -impl ResultParser for URIResultParser {} - -impl URIResultParser { - pub fn parse(&self, result: &Result) -> URIParsedResult { - let raw_text: String = get_massaged_text(result); - // Assume anything starting this way really means to be a URI - if raw_text.starts_with("URL:") || raw_text.starts_with("URI:") { - return URIParsedResult::new(&raw_text.substring(4).trim(), null); - } - raw_text = raw_text.trim().to_owned(); - if !::is_basically_valid_u_r_i(&raw_text) || ::is_possibly_malicious_u_r_i(&raw_text) { - return null; - } - return URIParsedResult::new(&raw_text, null); - } - - /** - * @return true if the URI contains suspicious patterns that may suggest it intends to - * mislead the user about its true nature. At the moment this looks for the presence - * of user/password syntax in the host/authority portion of a URI which may be used - * in attempts to make the URI's host appear to be other than it is. Example: - * http://yourbank.com@phisher.com This URI connects to phisher.com but may appear - * to connect to yourbank.com at first glance. - */ - fn is_possibly_malicious_u_r_i(uri: &String) -> bool { - return !ALLOWED_URI_CHARS_PATTERN.is_match(&uri) || USER_IN_HOST.find(&uri); - } - - fn is_basically_valid_u_r_i(uri: &String) -> bool { - if uri.contains(" ") { - // Quick hack check for a common case - return false; - } - let mut m: Matcher = URL_WITH_PROTOCOL_PATTERN::matcher(&uri); - if m.find() && m.start() == 0 { - // match at start only - return true; - } - m = URL_WITHOUT_PROTOCOL_PATTERN::matcher(&uri); - return m.find() && m.start() == 0; - } -} - -// URLTOResultParser.java -/** - * Parses the "URLTO" result format, which is of the form "URLTO:[title]:[url]". - * This seems to be used sometimes, but I am not able to find documentation - * on its origin or official format? - * - * @author Sean Owen - */ -pub struct URLTOResultParser { - //super: ResultParser; -} - -impl ResultParser for URLTOResultParser {} - -impl URLTOResultParser { - pub fn parse(&self, result: &Result) -> URIParsedResult { - let raw_text: String = get_massaged_text(result); - if !raw_text.starts_with("urlto:") && !raw_text.starts_with("URLTO:") { - return null; - } - let title_end: i32 = raw_text.index_of(':', 6); - if title_end < 0 { - return null; - } - let title: String = if title_end <= 6 { - null - } else { - raw_text.substring(6, title_end) - }; - let uri: String = raw_text.substring(title_end + 1); - return URIParsedResult::new(&uri, &title); - } -} - -// VCardResultParser.java -/** - * Parses contact information formatted according to the VCard (2.1) format. This is not a complete - * implementation but should parse information as commonly encoded in 2D barcodes. - * - * @author Sean Owen - */ - -const BEGIN_VCARD: Regex = Regex::new("BEGIN:VCARD"); - -const VCARD_LIKE_DATE: Regex = Regex::new("\\d{4}-?\\d{2}-?\\d{2}"); - -const CR_LF_SPACE_TAB: Regex = Regex::new("\r\n[ \t]"); - -const NEWLINE_ESCAPE: Regex = Regex::new("\\\\[nN]"); - -const VCARD_ESCAPES: Regex = Regex::new("\\\\([,;\\\\])"); - -const EQUALS: Regex = Regex::new("="); - -const SEMICOLON: Regex = Regex::new(";"); - -const UNESCAPED_SEMICOLONS: Regex = Regex::new("(? AddressBookParsedResult { - // Although we should insist on the raw text ending with "END:VCARD", there's no reason - // to throw out everything else we parsed just because this was omitted. In fact, Eclair - // is doing just that, and we can't parse its contacts without this leniency. - let raw_text: String = get_massaged_text(result); - let m: Matcher = BEGIN_VCARD::matcher(&raw_text); - if !m.find() || m.start() != 0 { - return null; - } - let mut names: List> = - ::match_v_card_prefixed_field("FN", &raw_text, true, false); - if names == null { - // If no display names found, look for regular name fields and format them - names = ::match_v_card_prefixed_field("N", &raw_text, true, false); - ::format_names(&names); - } - let nickname_string: List = - ::match_single_v_card_prefixed_field("NICKNAME", &raw_text, true, false); - let nicknames: Vec = if nickname_string == null { - null - } else { - COMMA::split(&nickname_string.get(0)) - }; - let phone_numbers: List> = - ::match_v_card_prefixed_field("TEL", &raw_text, true, false); - let emails: List> = - ::match_v_card_prefixed_field("EMAIL", &raw_text, true, false); - let note: List = - ::match_single_v_card_prefixed_field("NOTE", &raw_text, false, false); - let addresses: List> = - ::match_v_card_prefixed_field("ADR", &raw_text, true, true); - let org: List = ::match_single_v_card_prefixed_field("ORG", &raw_text, true, true); - let mut birthday: List = - ::match_single_v_card_prefixed_field("BDAY", &raw_text, true, false); - if birthday != null && !::is_like_v_card_date(&birthday.get(0)) { - birthday = null; - } - let title: List = - ::match_single_v_card_prefixed_field("TITLE", &raw_text, true, false); - let urls: List> = ::match_v_card_prefixed_field("URL", &raw_text, true, false); - let instant_messenger: List = - ::match_single_v_card_prefixed_field("IMPP", &raw_text, true, false); - let geo_string: List = - ::match_single_v_card_prefixed_field("GEO", &raw_text, true, false); - let mut geo: Vec = if geo_string == null { - null - } else { - SEMICOLON_OR_COMMA::split(&geo_string.get(0)) - }; - if geo != null && geo.len() != 2 { - geo = null; - } - return AddressBookParsedResult::new( - &::to_primary_values(&names), - Some(&nicknames), - null, - &::to_primary_values(&phone_numbers), - &::to_types(&phone_numbers), - &::to_primary_values(&emails), - &::to_types(&emails), - Some(&::to_primary_value(&instant_messenger)), - Some(&::to_primary_value(¬e)), - &::to_primary_values(&addresses), - &::to_types(&addresses), - Some(&::to_primary_value(&org)), - Some(&::to_primary_value(&birthday)), - Some(&::to_primary_value(&title)), - Some(&::to_primary_values(&urls)), - Some(&geo), - ); - } - - fn match_v_card_prefixed_field( - prefix: &CharSequence, - raw_text: &String, - trim: bool, - parse_field_divider: bool, - ) -> List> { - let mut matches: List> = null; - let mut i: i32 = 0; - let max: i32 = raw_text.length(); - while i < max { - // At start or after newline, match prefix, followed by optional metadata - // (led by ;) ultimately ending in colon - let matcher: Regex = Regex::new(&format!("(?:^|\n){}(?:;([^:]*))?:", prefix)); - if i > 0 { - // Find from i-1 not i since looking at the preceding character - i -= 1; - } - // ::matcher(&raw_text); FEELS WRONG - todo!("feels wrong"); - if !matcher.find(i) { - break; - } - // group 0 = whole pattern; end(0) is past final colon - i = matcher.end(0); - // group 1 = metadata substring - let metadata_string: String = matcher.group(1); - let mut metadata: List = null; - let quoted_printable: bool = false; - let quoted_printable_charset: String = null; - let value_type: String = null; - if metadata_string != null { - for metadatum in SEMICOLON::split(&metadata_string) { - if metadata == null { - metadata = Vec::new(); - } - metadata.add(&metadatum); - let metadatum_tokens: Vec = EQUALS::split(&metadatum, 2); - if metadatum_tokens.len() > 1 { - let key: String = metadatum_tokens[0]; - let value: String = metadatum_tokens[1]; - if "ENCODING".equals_ignore_case(&key) - && "QUOTED-PRINTABLE".equals_ignore_case(&value) - { - quoted_printable = true; - } else if "CHARSET".equals_ignore_case(&key) { - quoted_printable_charset = value; - } else if "VALUE".equals_ignore_case(&key) { - value_type = value; - } - } - } - } - // Found the start of a match here - let match_start: i32 = i; - while (i = raw_text.index_of('\n', i)) >= 0 { - // Really, end in \r\n - if - // But if followed by tab or space, - i < raw_text.length() - 1 - && ( - // this is only a continuation - raw_text.char_at(i + 1) == ' ' || raw_text.char_at(i + 1) == '\t' - ) - { - // Skip \n and continutation whitespace - i += 2; - } else if - // If preceded by = in quoted printable - quoted_printable - && ( - // this is a continuation - (i >= 1 && raw_text.char_at(i - 1) == '=') - || (i >= 2 && raw_text.char_at(i - 2) == '=') - ) - { - // Skip \n - i += 1; - } else { - break; - } - } - if i < 0 { - // No terminating end character? uh, done. Set i such that loop terminates and break - i = max; - } else if i > match_start { - // found a match - if matches == null { - // lazy init - matches = Vec::new(); - } - if i >= 1 && raw_text.char_at(i - 1) == '\r' { - // Back up over \r, which really should be there - i -= 1; - } - let mut element: String = raw_text.substring(match_start, i); - if trim { - element = element.trim().to_owned(); - } - if quoted_printable { - element = ::decode_quoted_printable(&element, "ed_printable_charset); - if parse_field_divider { - element = UNESCAPED_SEMICOLONS - .replace_all(&element, "\n") - .trim() - .to_owned(); - } - } else { - if parse_field_divider { - element = UNESCAPED_SEMICOLONS::matcher(&element, "\n").trim(); - } - element = CR_LF_SPACE_TAB.replace_all(&element, ""); - element = NEWLINE_ESCAPE.replace_all(&element, "\n"); - element = VCARD_ESCAPES.replace_all(&element, "$1"); - } - // Only handle VALUE=uri specially - if "uri".equals(&value_type) { - // as value, to support tel: and mailto: - panic!("i don't know what this does, and i don't know how to fix it"); - todo!("i don't know what this does, and i don't know how to fix it") - //element = URI::create(&element)::get_scheme_specific_part(); - } - if metadata == null { - let _match: List = Vec::new(); - _match.add(&element); - matches.add(&_match); - } else { - metadata.add(0, &element); - matches.add(&metadata); - } - i += 1; - } else { - i += 1; - } - } - return matches; - } - - fn decode_quoted_printable(value: &CharSequence, charset: &String) -> String { - let length: i32 = value.length(); - let result: String = String::new(); - let fragment_buffer: ByteArrayOutputStream = ByteArrayOutputStream::new(); - { - let mut i: i32 = 0; - while i < length { - { - let c: char = value.char_at(i); - match c { - '\r' => {} - '\n' => { - break; - } - '=' => { - if i < length - 2 { - let next_char: char = value.char_at(i + 1); - if next_char != '\r' && next_char != '\n' { - let next_next_char: char = value.char_at(i + 2); - let first_digit: i32 = parse_hex_digit(next_char); - let second_digit: i32 = parse_hex_digit(next_next_char); - if first_digit >= 0 && second_digit >= 0 { - fragment_buffer.write((first_digit << 4) + second_digit); - } - // else ignore it, assume it was incorrectly encoded - i += 2; - } - } - break; - } - _ => { - ::maybe_append_fragment(&fragment_buffer, &charset, &result); - result.append(c); - } - } - } - i += 1; - } - } - - ::maybe_append_fragment(&fragment_buffer, &charset, &result); - return result.to_string(); - } - - fn maybe_append_fragment( - fragment_buffer: &ByteArrayOutputStream, - charset: &String, - result: &String, - ) { - if fragment_buffer.size() > 0 { - let fragment_bytes: Vec = fragment_buffer.to_byte_array(); - let mut fragment: String; - if charset == null { - fragment = String::from(fragment_bytes); - } else { - fragment = String::from(fragment_bytes); - } - fragment_buffer.reset(); - result.append(&fragment); - } - } - - fn match_single_v_card_prefixed_field( - prefix: &CharSequence, - raw_text: &String, - trim: bool, - parse_field_divider: bool, - ) -> List { - let values: List> = - ::match_v_card_prefixed_field(&prefix, &raw_text, trim, parse_field_divider); - return if values == null || values.is_empty() { - null - } else { - values.get(0) - }; - } - - fn to_primary_value(list: &List) -> String { - return if list == null || list.is_empty() { - null - } else { - list.get(0) - }; - } - - fn to_primary_values(lists: &Collection>) -> Vec { - if lists == null || lists.is_empty() { - return null; - } - let result: List = Vec::new(); - for list in lists { - let value: String = list.get(0); - if value != null && !value.is_empty() { - result.add(&value); - } - } - return result.to_array(EMPTY_STR_ARRAY); - } - - fn to_types(lists: &Collection>) -> Vec { - if lists == null || lists.is_empty() { - return null; - } - let result: List = Vec::new(); - for list in lists { - let value: String = list.get(0); - if value != null && !value.is_empty() { - let mut _type: String = null; - { - let mut i: i32 = 1; - while i < list.size() { - { - let metadatum: String = list.get(i); - let equals: i32 = metadatum.index_of('='); - if equals < 0 { - // take the whole thing as a usable label - _type = metadatum; - break; - } - if "TYPE".equals_ignore_case(&metadatum.substring(0, equals)) { - _type = metadatum.substring(equals + 1); - break; - } - } - i += 1; - } - } - - result.add(&_type); - } - } - return result.to_array(EMPTY_STR_ARRAY); - } - - fn is_like_v_card_date(value: &CharSequence) -> bool { - return value == null || VCARD_LIKE_DATE.is_match(&value); - } - - /** - * Formats name fields of the form "Public;John;Q.;Reverend;III" into a form like - * "Reverend John Q. Public III". - * - * @param names name values to format, in place - */ - fn format_names(names: &Iterable>) { - if names != null { - for list in names { - let name: String = list.get(0); - let mut components: [Option; 5] = [None; 5]; - let mut start: i32 = 0; - let mut end: i32; - let component_index: i32 = 0; - while component_index < components.len() - 1 - && (end = name.index_of(';', start)) >= 0 - { - components[component_index] = name.substring(start, end); - component_index += 1; - start = end + 1; - } - components[component_index] = name.substring(start); - let new_name: String = String::new(); - ::maybe_append_component(&components, 3, &new_name); - ::maybe_append_component(&components, 1, &new_name); - ::maybe_append_component(&components, 2, &new_name); - ::maybe_append_component(&components, 0, &new_name); - ::maybe_append_component(&components, 4, &new_name); - list.set(0, &new_name.to_string().trim()); - } - } - } - - fn maybe_append_component(components: &Vec, i: i32, new_name: &String) { - if components[i] != null && !components[i].is_empty() { - if new_name.length() > 0 { - new_name.append(' '); - } - new_name.append(components[i]); - } - } -} - -// VEventResultParser.java -/** - * Partially implements the iCalendar format's "VEVENT" format for specifying a - * calendar event. See RFC 2445. This supports SUMMARY, LOCATION, GEO, DTSTART and DTEND fields. - * - * @author Sean Owen - */ -pub struct VEventResultParser { - //super: ResultParser; -} - -impl ResultParser for VEventResultParser {} - -impl VEventResultParser { - pub fn parse(&self, result: &Result) -> CalendarParsedResult { - let raw_text: String = get_massaged_text(result); - let v_event_start: i32 = raw_text.index_of("BEGIN:VEVENT"); - if v_event_start < 0 { - return null; - } - let summary: String = ::match_single_v_card_prefixed_field("SUMMARY", &raw_text); - let start: String = ::match_single_v_card_prefixed_field("DTSTART", &raw_text); - if start == null { - return null; - } - let end: String = ::match_single_v_card_prefixed_field("DTEND", &raw_text); - let duration: String = ::match_single_v_card_prefixed_field("DURATION", &raw_text); - let location: String = ::match_single_v_card_prefixed_field("LOCATION", &raw_text); - let organizer: String = ::strip_mailto(&::match_single_v_card_prefixed_field( - "ORGANIZER", - &raw_text, - )); - let mut attendees: Vec = ::match_v_card_prefixed_field("ATTENDEE", &raw_text); - if attendees != null { - { - let mut i: i32 = 0; - while i < attendees.len() { - { - attendees[i] = ::strip_mailto(attendees[i]); - } - i += 1; - } - } - } - let description: String = ::match_single_v_card_prefixed_field("DESCRIPTION", &raw_text); - let geo_string: String = ::match_single_v_card_prefixed_field("GEO", &raw_text); - let mut latitude: f64; - let mut longitude: f64; - if geo_string == null { - latitude = Double::NaN; - longitude = Double::NaN; - } else { - let semicolon: i32 = geo_string.index_of(';'); - if semicolon < 0 { - return null; - } - - latitude = Double::parse_double(&geo_string.substring(0, semicolon)); - longitude = Double::parse_double(&geo_string.substring(semicolon + 1)); - } - - return CalendarParsedResult::new( - &summary, - &start, - &end, - &duration, - &location, - &organizer, - &attendees, - &description, - latitude, - longitude, - ); - } - - fn match_single_v_card_prefixed_field(prefix: &CharSequence, raw_text: &String) -> String { - let values: List = - VCardResultParser::match_single_v_card_prefixed_field(&prefix, &raw_text, true, false); - return if values == null || values.is_empty() { - null - } else { - values.get(0) - }; - } - - fn match_v_card_prefixed_field(prefix: &CharSequence, raw_text: &String) -> Vec { - let values: List> = - VCardResultParser::match_v_card_prefixed_field(&prefix, &raw_text, true, false); - if values == null || values.is_empty() { - return null; - } - let size: i32 = values.size(); - let mut result: [Option; size] = [None; size]; - { - let mut i: i32 = 0; - while i < size { - { - result[i] = values.get(i).get(0); - } - i += 1; - } - } - - return result; - } - - fn strip_mailto(s: &String) -> String { - if s != null && (s.starts_with("mailto:") || s.starts_with("MAILTO:")) { - s = s.substring(7); - } - return s; - } -} - -// VINParsedResult.java - -/** - * Represents a parsed result that encodes a Vehicle Identification Number (VIN). - */ -pub struct VINParsedResult { - //super: ParsedResult; - vin: String, - - world_manufacturer_i_d: String, - - vehicle_descriptor_section: String, - - vehicle_identifier_section: String, - - country_code: String, - - vehicle_attributes: String, - - model_year: i32, - - plant_code: char, - - sequential_number: String, -} - -impl ParsedResult for VINParsedResult {} - -impl VINParsedResult { - pub fn new( - vin: &String, - world_manufacturer_i_d: &String, - vehicle_descriptor_section: &String, - vehicle_identifier_section: &String, - country_code: &String, - vehicle_attributes: &String, - model_year: i32, - plant_code: char, - sequential_number: &String, - ) -> Self { - Self { - vin: vin, - world_manufacturer_i_d: world_manufacturer_i_d, - vehicle_descriptor_section: vehicle_descriptor_section, - vehicle_identifier_section: vehicle_identifier_section, - country_code: country_code, - vehicle_attributes: vehicle_attributes, - model_year, - plant_code, - sequential_number: sequential_number, - } - } - - pub fn get_v_i_n(&self) -> String { - return self.vin; - } - - pub fn get_world_manufacturer_i_d(&self) -> String { - return self.world_manufacturer_i_d; - } - - pub fn get_vehicle_descriptor_section(&self) -> String { - return self.vehicle_descriptor_section; - } - - pub fn get_vehicle_identifier_section(&self) -> String { - return self.vehicle_identifier_section; - } - - pub fn get_country_code(&self) -> String { - return self.country_code; - } - - pub fn get_vehicle_attributes(&self) -> String { - return self.vehicle_attributes; - } - - pub fn get_model_year(&self) -> i32 { - return self.model_year; - } - - pub fn get_plant_code(&self) -> char { - return self.plant_code; - } - - pub fn get_sequential_number(&self) -> String { - return self.sequential_number; - } - - pub fn get_display_result(&self) -> String { - let result: String = String::new(); - result.append(&self.world_manufacturer_i_d).append(' '); - result.append(&self.vehicle_descriptor_section).append(' '); - result.append(&self.vehicle_identifier_section).append('\n'); - if self.country_code != null { - result.append(&self.country_code).append(' '); - } - result.append(self.model_year).append(' '); - result.append(self.plant_code).append(' '); - result.append(&self.sequential_number).append('\n'); - return result.to_string(); - } -} - -// VINResultParser.java -/** - * Detects a result that is likely a vehicle identification number. - * - * @author Sean Owen - */ - -const IOQ: Regex = Regex::new("[IOQ]"); - -const AZ09: Regex = Regex::new("[A-Z0-9]{17}"); -pub struct VINResultParser { - //super: ResultParser; -} - -impl ResultParser for VINResultParser {} - -impl VINResultParser { - pub fn parse(&self, result: &Result) -> VINParsedResult { - if result.get_barcode_format() != BarcodeFormat::CODE_39 { - return null; - } - let raw_text: String = result.get_text(); - raw_text = IOQ.replace_all(&raw_text, "").trim().to_owned(); - if !AZ09::is_match(&raw_text) { - return null; - } - - if !::check_checksum(&raw_text) { - return null; - } - let wmi: String = raw_text.substring(0, 3); - return VINParsedResult::new( - &raw_text, - &wmi, - &raw_text.substring(3, 9), - &raw_text.substring(9, 17), - &::country_code(&wmi), - &raw_text.substring(3, 8), - &::model_year(&raw_text.char_at(9)), - &raw_text.char_at(10), - &raw_text.substring(11), - ); - } - - fn check_checksum(vin: &CharSequence) -> bool { - let mut sum: i32 = 0; - { - let mut i: i32 = 0; - while i < vin.length() { - { - sum += ::vin_position_weight(i + 1) * ::vin_char_value(&vin.char_at(i)); - } - i += 1; - } - } - - let check_char: char = vin.char_at(8); - let expected_check_char: char = self.check_char(sum % 11); - return check_char == expected_check_char; - } - - fn vin_char_value(c: char) -> Result { - if c >= 'A' && c <= 'I' { - return (c - 'A') + 1; - } - if c >= 'J' && c <= 'R' { - return (c - 'J') + 1; - } - if c >= 'S' && c <= 'Z' { - return (c - 'S') + 2; - } - if c >= '0' && c <= '9' { - return c - '0'; - } - Err(IllegalArgumentException::new()) - } - - fn vin_position_weight(position: i32) -> Result { - if position >= 1 && position <= 7 { - return Ok(9 - position); - } - if position == 8 { - return Ok(10); - } - if position == 9 { - return Ok(0); - } - if position >= 10 && position <= 17 { - return Ok(19 - position); - } - Err(IllegalArgumentException::new()) - } - - fn check_char(remainder: i32) -> Result { - if remainder < 10 { - return Ok(('0' + remainder) as char); - } - if remainder == 10 { - return Ok('X'); - } - Err(IllegalArgumentException::new()) - } - - fn model_year(c: char) -> Result { - if c >= 'E' && c <= 'H' { - return (c - 'E') + 1984; - } - if c >= 'J' && c <= 'N' { - return (c - 'J') + 1988; - } - if c == 'P' { - return Ok(1993); - } - if c >= 'R' && c <= 'T' { - return (c - 'R') + 1994; - } - if c >= 'V' && c <= 'Y' { - return (c - 'V') + 1997; - } - if c >= '1' && c <= '9' { - return (c - '1') + 2001; - } - if c >= 'A' && c <= 'D' { - return (c - 'A') + 2010; - } - Err(IllegalArgumentException::new()) - } - - fn country_code(wmi: &CharSequence) -> &'static str { - let c1: char = wmi.char_at(0); - let c2: char = wmi.char_at(1); - match c1 { - '1' => {} - '4' => {} - '5' => { - return "US"; - } - '2' => { - return "CA"; - } - '3' => { - if c2 >= 'A' && c2 <= 'W' { - return "MX"; - } - } - '9' => { - if (c2 >= 'A' && c2 <= 'E') || (c2 >= '3' && c2 <= '9') { - return "BR"; - } - } - 'J' => { - if c2 >= 'A' && c2 <= 'T' { - return "JP"; - } - } - 'K' => { - if c2 >= 'L' && c2 <= 'R' { - return "KO"; - } - } - 'L' => { - return "CN"; - } - 'M' => { - if c2 >= 'A' && c2 <= 'E' { - return "IN"; - } - } - 'S' => { - if c2 >= 'A' && c2 <= 'M' { - return "UK"; - } - if c2 >= 'N' && c2 <= 'T' { - return "DE"; - } - } - 'V' => { - if c2 >= 'F' && c2 <= 'R' { - return "FR"; - } - if c2 >= 'S' && c2 <= 'W' { - return "ES"; - } - } - 'W' => { - return "DE"; - } - 'X' => { - if c2 == '0' || (c2 >= '3' && c2 <= '9') { - return "RU"; - } - } - 'Z' => { - if c2 >= 'A' && c2 <= 'R' { - return "IT"; - } - } - } - return null; - } -} - -// WifiParsedResult.java -/** - * Represents a parsed result that encodes wifi network information, like SSID and password. - * - * @author Vikram Aggarwal - */ -pub struct WifiParsedResult { - //super: ParsedResult; - ssid: String, - - network_encryption: String, - - password: String, - - hidden: bool, - - identity: String, - - anonymous_identity: String, - - eap_method: String, - - phase2_method: String, -} - -impl ParsedResult for WifiParsedResult {} - -impl WifiParsedResult { - pub fn new( - network_encryption: &String, - ssid: &String, - password: &String, - hidden: bool, - identity: &String, - anonymous_identity: &String, - eap_method: &String, - phase2_method: &String, - ) -> Self { - Self { - ssid: ssid, - network_encryption: network_encryption, - password: password, - hidden, - identity: identity, - anonymous_identity: anonymous_identity, - eap_method: eap_method, - phase2_method: phase2_method, - } - } - - pub fn get_ssid(&self) -> String { - return self.ssid; - } - - pub fn get_network_encryption(&self) -> String { - return self.network_encryption; - } - - pub fn get_password(&self) -> String { - return self.password; - } - - pub fn is_hidden(&self) -> bool { - return self.hidden; - } - - pub fn get_identity(&self) -> String { - return self.identity; - } - - pub fn get_anonymous_identity(&self) -> String { - return self.anonymous_identity; - } - - pub fn get_eap_method(&self) -> String { - return self.eap_method; - } - - pub fn get_phase2_method(&self) -> String { - return self.phase2_method; - } - - pub fn get_display_result(&self) -> String { - let result: String = String::new(); - maybe_append(&self.ssid, &result); - maybe_append(&self.network_encryption, &result); - maybe_append(&self.password, &result); - maybe_append(&Boolean::to_string(self.hidden), &result); - return result.to_string(); - } -} - -// WifiResultParser.java -pub struct WifiResultParser { - //super: ResultParser; -} - -impl ResultParser for WifiResultParser {} - -impl WifiResultParser { - pub fn parse(&self, result: &Result) -> WifiParsedResult { - let raw_text: String = get_massaged_text(result); - if !raw_text.starts_with("WIFI:") { - return null; - } - raw_text = raw_text.substring(&"WIFI:".length()); - let ssid: String = match_single_prefixed_field("S:", &raw_text, ';', false); - if ssid == null || ssid.is_empty() { - return null; - } - let pass: String = match_single_prefixed_field("P:", &raw_text, ';', false); - let mut _type: String = match_single_prefixed_field("T:", &raw_text, ';', false); - if _type == null { - _type = "nopass".to_owned(); - } - // Unfortunately, in the past, H: was not just used for boolean 'hidden', but 'phase 2 method'. - // To try to retain backwards compatibility, we set one or the other based on whether the string - // is 'true' or 'false': - let mut hidden: bool = false; - let phase2_method: String = match_single_prefixed_field("PH2:", &raw_text, ';', false); - let h_value: String = match_single_prefixed_field("H:", &raw_text, ';', false); - if h_value != null { - // If PH2 was specified separately, or if the value is clearly boolean, interpret it as 'hidden' - if phase2_method != null - || "true".equals_ignore_case(&h_value) - || "false".equals_ignore_case(&h_value) - { - hidden = Boolean::parse_boolean(&h_value); - } else { - phase2_method = h_value; - } - } - let identity: String = match_single_prefixed_field("I:", &raw_text, ';', false); - let anonymous_identity: String = match_single_prefixed_field("A:", &raw_text, ';', false); - let eap_method: String = match_single_prefixed_field("E:", &raw_text, ';', false); - return WifiParsedResult::new( - &_type, - &ssid, - &pass, - hidden, - &identity, - &anonymous_identity, - &eap_method, - &phase2_method, - ); - } -} - -// ISBNParsedResult.java -/** - * Represents a parsed result that encodes a product ISBN number. - * - * @author jbreiden@google.com (Jeff Breidenbach) - */ -pub struct ISBNParsedResult { - //super: ParsedResult; - isbn: String, -} - -impl ParsedResult for ISBNParsedResult {} - -impl ISBNParsedResult { - fn new(isbn: &String) -> Self { - Self { isbn } - } - - pub fn get_i_s_b_n(&self) -> String { - return self.isbn; - } - - pub fn get_display_result(&self) -> String { - return self.isbn; - } -} - -// ISBNResultParser.java -/** - * Parses strings of digits that represent a ISBN. - * - * @author jbreiden@google.com (Jeff Breidenbach) - */ -pub struct ISBNResultParser { - //super: ResultParser; -} - -impl ResultParser for ISBNResultParser {} - -impl ISBNResultParser { - /** - * See ISBN-13 For Dummies - */ - pub fn parse(&self, result: &Result) -> ISBNParsedResult { - let format: BarcodeFormat = result.get_barcode_format(); - if format != BarcodeFormat::EAN_13 { - return null; - } - let raw_text: String = get_massaged_text(result); - let length: i32 = raw_text.length(); - if length != 13 { - return null; - } - if !raw_text.starts_with("978") && !raw_text.starts_with("979") { - return null; - } - return ISBNParsedResult::new(&raw_text); - } -} diff --git a/src/common.rs b/src/common.rs deleted file mode 100644 index 2588583..0000000 --- a/src/common.rs +++ /dev/null @@ -1,3750 +0,0 @@ -pub mod detector; -pub mod readsolomon; - -use std::collections::HashMap; - -use crate::{ - Binarizer, Binarizer, FormatException, LuminanceSource, NotFoundException, NotFoundException, - ResultPoint, -}; - -// ECIInput.java -/** - * Interface to navigate a sequence of ECIs and bytes. - * - * @author Alex Geller - */ -pub trait ECIInput { - /** - * Returns the length of this input. The length is the number - * of {@code byte}s in or ECIs in the sequence. - * - * @return the number of {@code char}s in this sequence - */ - fn length(&self) -> i32; - - /** - * Returns the {@code byte} value at the specified index. An index ranges from zero - * to {@code length() - 1}. The first {@code byte} value of the sequence is at - * index zero, the next at index one, and so on, as for array - * indexing. - * - * @param index the index of the {@code byte} value to be returned - * - * @return the specified {@code byte} value as character or the FNC1 character - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - * @throws IllegalArgumentException - * if the value at the {@code index} argument is an ECI (@see #isECI) - */ - fn char_at(&self, index: i32) -> char; - - /** - * Returns a {@code CharSequence} that is a subsequence of this sequence. - * The subsequence starts with the {@code char} value at the specified index and - * ends with the {@code char} value at index {@code end - 1}. The length - * (in {@code char}s) of the - * returned sequence is {@code end - start}, so if {@code start == end} - * then an empty sequence is returned. - * - * @param start the start index, inclusive - * @param end the end index, exclusive - * - * @return the specified subsequence - * - * @throws IndexOutOfBoundsException - * if {@code start} or {@code end} are negative, - * if {@code end} is greater than {@code length()}, - * or if {@code start} is greater than {@code end} - * @throws IllegalArgumentException - * if a value in the range {@code start}-{@code end} is an ECI (@see #isECI) - */ - fn sub_sequence(&self, start: i32, end: i32) -> CharSequence; - - /** - * Determines if a value is an ECI - * - * @param index the index of the value - * - * @return true if the value at position {@code index} is an ECI - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - */ - fn is_e_c_i(&self, index: i32) -> bool; - - /** - * Returns the {@code int} ECI value at the specified index. An index ranges from zero - * to {@code length() - 1}. The first {@code byte} value of the sequence is at - * index zero, the next at index one, and so on, as for array - * indexing. - * - * @param index the index of the {@code int} value to be returned - * - * @return the specified {@code int} ECI value. - * The ECI specified the encoding of all bytes with a higher index until the - * next ECI or until the end of the input if no other ECI follows. - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - * @throws IllegalArgumentException - * if the value at the {@code index} argument is not an ECI (@see #isECI) - */ - fn get_e_c_i_value(&self, index: i32) -> i32; - - fn have_n_characters(&self, index: i32, n: i32) -> bool; -} - -// GridSampler.java - -/** - * Implementations of this class can, given locations of finder patterns for a QR code in an - * image, sample the right points in the image to reconstruct the QR code, accounting for - * perspective distortion. It is abstracted since it is relatively expensive and should be allowed - * to take advantage of platform-specific optimized implementations, like Sun's Java Advanced - * Imaging library, but which may not be available in other environments such as J2ME, and vice - * versa. - * - * The implementation used can be controlled by calling {@link #setGridSampler(GridSampler)} - * with an instance of a class which implements this interface. - * - * @author Sean Owen - */ - -//let grid_sampler: dyn GridSampler = DefaultGridSampler::new(); -pub struct GridSampler { - grid_sampler: dyn GridSampler, -} - -impl GridSampler { - pub fn new() -> Self { - Self { - grid_sampler: DefaultGridSampler::new(), - } - } - - /** - * Sets the implementation of GridSampler used by the library. One global - * instance is stored, which may sound problematic. But, the implementation provided - * ought to be appropriate for the entire platform, and all uses of this library - * in the whole lifetime of the JVM. For instance, an Android activity can swap in - * an implementation that takes advantage of native platform libraries. - * - * @param newGridSampler The platform-specific object to install. - */ - pub fn set_grid_sampler(new_grid_sampler: &GridSampler) { - grid_sampler = new_grid_sampler; - } - - /** - * @return the current implementation of GridSampler - */ - pub fn get_instance() -> GridSampler { - return grid_sampler; - } - - /** - * Samples an image for a rectangular matrix of bits of the given dimension. The sampling - * transformation is determined by the coordinates of 4 points, in the original and transformed - * image space. - * - * @param image image to sample - * @param dimensionX width of {@link BitMatrix} to sample from image - * @param dimensionY height of {@link BitMatrix} to sample from image - * @param p1ToX point 1 preimage X - * @param p1ToY point 1 preimage Y - * @param p2ToX point 2 preimage X - * @param p2ToY point 2 preimage Y - * @param p3ToX point 3 preimage X - * @param p3ToY point 3 preimage Y - * @param p4ToX point 4 preimage X - * @param p4ToY point 4 preimage Y - * @param p1FromX point 1 image X - * @param p1FromY point 1 image Y - * @param p2FromX point 2 image X - * @param p2FromY point 2 image Y - * @param p3FromX point 3 image X - * @param p3FromY point 3 image Y - * @param p4FromX point 4 image X - * @param p4FromY point 4 image Y - * @return {@link BitMatrix} representing a grid of points sampled from the image within a region - * defined by the "from" parameters - * @throws NotFoundException if image can't be sampled, for example, if the transformation defined - * by the given points is invalid or results in sampling outside the image boundaries - */ - pub fn sample_grid( - &self, - image: &BitMatrix, - dimension_x: i32, - dimension_y: i32, - p1_to_x: f32, - p1_to_y: f32, - p2_to_x: f32, - p2_to_y: f32, - p3_to_x: f32, - p3_to_y: f32, - p4_to_x: f32, - p4_to_y: f32, - p1_from_x: f32, - p1_from_y: f32, - p2_from_x: f32, - p2_from_y: f32, - p3_from_x: f32, - p3_from_y: f32, - p4_from_x: f32, - p4_from_y: f32, - ) -> Result; - - pub fn sample_grid( - &self, - image: &BitMatrix, - dimension_x: i32, - dimension_y: i32, - transform: &PerspectiveTransform, - ) -> Result; - - /** - *

Checks a set of points that have been transformed to sample points on an image against - * the image's dimensions to see if the point are even within the image.

- * - *

This method will actually "nudge" the endpoints back onto the image if they are found to be - * barely (less than 1 pixel) off the image. This accounts for imperfect detection of finder - * patterns in an image where the QR Code runs all the way to the image border.

- * - *

For efficiency, the method will check points from either end of the line until one is found - * to be within the image. Because the set of points are assumed to be linear, this is valid.

- * - * @param image image into which the points should map - * @param points actual points in x1,y1,...,xn,yn form - * @throws NotFoundException if an endpoint is lies outside the image boundaries - */ - pub fn check_and_nudge_points( - image: &BitMatrix, - points: &Vec, - ) -> Result<(), NotFoundException> { - let width: i32 = image.get_width(); - let height: i32 = image.get_height(); - // Check and nudge points from start until we see some that are OK: - let mut nudged: bool = true; - // points.length must be even - let max_offset: i32 = points.len() - 1; - { - let mut offset: i32 = 0; - while offset < max_offset && nudged { - { - let x: i32 = points[offset] as i32; - let y: i32 = points[offset + 1] as i32; - if x < -1 || x > width || y < -1 || y > height { - return Err(NotFoundException::get_not_found_instance()); - } - nudged = false; - if x == -1 { - points[offset] = 0.0f32; - nudged = true; - } else if x == width { - points[offset] = width - 1.0; - nudged = true; - } - if y == -1 { - points[offset + 1] = 0.0f32; - nudged = true; - } else if y == height { - points[offset + 1] = height - 1.0; - nudged = true; - } - } - offset += 2; - } - } - - // Check and nudge points from end: - nudged = true; - { - let mut offset: i32 = points.len() - 2; - while offset >= 0 && nudged { - { - let x: i32 = points[offset] as i32; - let y: i32 = points[offset + 1] as i32; - if x < -1 || x > width || y < -1 || y > height { - return Err(NotFoundException::get_not_found_instance()); - } - nudged = false; - if x == -1 { - points[offset] = 0.0f32; - nudged = true; - } else if x == width { - points[offset] = width - 1.0; - nudged = true; - } - if y == -1 { - points[offset + 1] = 0.0f32; - nudged = true; - } else if y == height { - points[offset + 1] = height - 1.0; - nudged = true; - } - } - offset -= 2; - } - } - - Ok(()) - } -} - -// GlobalHistogramBinarizer.java -/** - * This Binarizer implementation uses the old ZXing global histogram approach. It is suitable - * for low-end mobile devices which don't have enough CPU or memory to use a local thresholding - * algorithm. However, because it picks a global black point, it cannot handle difficult shadows - * and gradients. - * - * Faster mobile devices and all desktop applications should probably use HybridBinarizer instead. - * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - */ - -const LUMINANCE_BITS: i32 = 5; - -const LUMINANCE_SHIFT: i32 = 8 - LUMINANCE_BITS; - -const LUMINANCE_BUCKETS: i32 = 1 << LUMINANCE_BITS; - -const EMPTY: [i8; 0] = [0; 0]; -pub struct GlobalHistogramBinarizer { - //super: Binarizer; - luminances: Vec, - - buckets: Vec, -} - -impl Binarizer for GlobalHistogramBinarizer { - // Applies simple sharpening to the row data to improve performance of the 1D Readers. - fn get_black_row(&self, y: i32, row: &BitArray) -> Result { - let source: LuminanceSource = get_luminance_source(); - let width: i32 = source.get_width(); - if row == null || row.get_size() < width { - row = &BitArray::new(None, Some(width)); - } else { - row.clear(); - } - self.init_arrays(width); - let local_luminances: Vec = source.get_row(y, &self.luminances); - let local_buckets: Vec = self.buckets; - { - let mut x: i32 = 0; - while x < width { - { - local_buckets[(local_luminances[x] & 0xff) >> LUMINANCE_SHIFT] += 1; - } - x += 1; - } - } - - let black_point: i32 = ::estimate_black_point(&local_buckets); - if width < 3 { - // Special case for very small images - { - let mut x: i32 = 0; - while x < width { - { - if (local_luminances[x] & 0xff) < black_point { - row.set(x); - } - } - x += 1; - } - } - } else { - let mut left: i32 = local_luminances[0] & 0xff; - let mut center: i32 = local_luminances[1] & 0xff; - { - let mut x: i32 = 1; - while x < width - 1 { - { - let right: i32 = local_luminances[x + 1] & 0xff; - // A simple -1 4 -1 box filter with a weight of 2. - if ((center * 4) - left - right) / 2 < black_point { - row.set(x); - } - left = center; - center = right; - } - x += 1; - } - } - } - return Ok(row); - } - - // Does not sharpen the data, as this call is intended to only be used by 2D Readers. - fn get_black_matrix(&self) -> Result> { - let source: LuminanceSource = get_luminance_source(); - let width: i32 = source.get_width(); - let height: i32 = source.get_height(); - let matrix: BitMatrix = BitMatrix::new(width, height, None, None); - // Quickly calculates the histogram by sampling four rows from the image. This proved to be - // more robust on the blackbox tests than sampling a diagonal as we used to do. - self.init_arrays(width); - let local_buckets: Vec = self.buckets; - { - let mut y: i32 = 1; - while y < 5 { - { - let row: i32 = height * y / 5; - let local_luminances: Vec = source.get_row(row, &self.luminances); - let right: i32 = (width * 4) / 5; - { - let mut x: i32 = width / 5; - while x < right { - { - let mut pixel: i32 = local_luminances[x] & 0xff; - local_buckets[pixel >> LUMINANCE_SHIFT] += 1; - } - x += 1; - } - } - } - y += 1; - } - } - - let black_point: i32 = ::estimate_black_point(&local_buckets); - // We delay reading the entire image luminance until the black point estimation succeeds. - // Although we end up reading four rows twice, it is consistent with our motto of - // "fail quickly" which is necessary for continuous scanning. - let local_luminances: Vec = source.get_matrix(); - { - let mut y: i32 = 0; - while y < height { - { - let offset: i32 = y * width; - { - let mut x: i32 = 0; - while x < width { - { - let pixel: i32 = local_luminances[offset + x] & 0xff; - if pixel < black_point { - matrix.set(x, y); - } - } - x += 1; - } - } - } - y += 1; - } - } - - return Ok(matrix); - } - - fn create_binarizer(&self, source: &LuminanceSource) -> Binarizer { - return GlobalHistogramBinarizer::new(source); - } -} - -impl GlobalHistogramBinarizer { - pub fn new(source: &LuminanceSource) -> GlobalHistogramBinarizer { - super(source); - luminances = EMPTY; - buckets = [0; LUMINANCE_BUCKETS]; - } - - fn init_arrays(&self, luminance_size: i32) { - if self.luminances.len() < luminance_size { - self.luminances = [0; luminance_size]; - } - { - let mut x: i32 = 0; - while x < LUMINANCE_BUCKETS { - { - self.buckets[x] = 0; - } - x += 1; - } - } - } - - fn estimate_black_point(buckets: &Vec) -> Result { - // Find the tallest peak in the histogram. - let num_buckets: i32 = buckets.len(); - let max_bucket_count: i32 = 0; - let first_peak: i32 = 0; - let first_peak_size: i32 = 0; - { - let mut x: i32 = 0; - while x < num_buckets { - { - if buckets[x] > first_peak_size { - first_peak = x; - first_peak_size = buckets[x]; - } - if buckets[x] > max_bucket_count { - max_bucket_count = buckets[x]; - } - } - x += 1; - } - } - - // Find the second-tallest peak which is somewhat far from the tallest peak. - let second_peak: i32 = 0; - let second_peak_score: i32 = 0; - { - let mut x: i32 = 0; - while x < num_buckets { - { - let distance_to_biggest: i32 = x - first_peak; - // Encourage more distant second peaks by multiplying by square of distance. - let score: i32 = buckets[x] * distance_to_biggest * distance_to_biggest; - if score > second_peak_score { - second_peak = x; - second_peak_score = score; - } - } - x += 1; - } - } - - // Make sure firstPeak corresponds to the black peak. - if first_peak > second_peak { - let temp: i32 = first_peak; - first_peak = second_peak; - second_peak = temp; - } - // than waste time trying to decode the image, and risk false positives. - if second_peak - first_peak <= num_buckets / 16 { - return Err(NotFoundException::get_not_found_instance()); - } - // Find a valley between them that is low and closer to the white peak. - let best_valley: i32 = second_peak - 1; - let best_valley_score: i32 = -1; - { - let mut x: i32 = second_peak - 1; - while x > first_peak { - { - let from_first: i32 = x - first_peak; - let score: i32 = from_first - * from_first - * (second_peak - x) - * (max_bucket_count - buckets[x]); - if score > best_valley_score { - best_valley = x; - best_valley_score = score; - } - } - x -= 1; - } - } - - return Ok(best_valley << LUMINANCE_SHIFT); - } -} - -// BitArray.java -/** - *

A simple, fast array of bits, represented compactly by an array of ints internally.

- * - * @author Sean Owen - */ - -const EMPTY_BITS: Vec = Vec!([]); -const LOAD_FACTOR: f32 = 0.75f32; - -#[derive(Cloneable, Eq, Hash)] -pub struct BitArray { - bits: Vec, - - size: i32, -} - -impl BitArray { - fn new(bits: Option<&Vec>, size: Option) -> Self { - let mut new_bit_array: Self; - - new_bit_array.size = size.unwrap_or(0); - new_bit_array.bits = bits.unwrap_or(&BitArray::make_array(new_bit_array.size)); - - new_bit_array - } - - pub fn get_size(&self) -> i32 { - return self.size; - } - - pub fn get_size_in_bytes(&self) -> i32 { - return (self.size + 7) / 8; - } - - fn ensure_capacity(&self, new_size: i32) { - if new_size > self.bits.len() * 32 { - let new_bits: Vec = ::make_array(Math::ceil(new_size / LOAD_FACTOR) as i32); - System::arraycopy(&self.bits, 0, &new_bits, 0, self.bits.len()); - self.bits = new_bits; - } - } - - /** - * @param i bit to get - * @return true iff bit i is set - */ - pub fn get(&self, i: i32) -> bool { - return (self.bits[i / 32] & (1 << (i & 0x1F))) != 0; - } - - /** - * Sets bit i. - * - * @param i bit to set - */ - pub fn set(&self, i: i32) { - self.bits[i / 32] |= 1 << (i & 0x1F); - } - - /** - * Flips bit i. - * - * @param i bit to set - */ - pub fn flip(&self, i: i32) { - self.bits[i / 32] ^= 1 << (i & 0x1F); - } - - /** - * @param from first bit to check - * @return index of first bit that is set, starting from the given index, or size if none are set - * at or beyond this given index - * @see #getNextUnset(int) - */ - pub fn get_next_set(&self, from: i32) -> i32 { - if from >= self.size { - return self.size; - } - let bits_offset: i32 = from / 32; - let current_bits: i32 = self.bits[bits_offset]; - // mask off lesser bits first - current_bits &= -(1 << (from & 0x1F)); - while current_bits == 0 { - if bits_offset += 1 == self.bits.len() { - return self.size; - } - current_bits = self.bits[bits_offset]; - } - let result: i32 = (bits_offset * 32) + Integer::number_of_trailing_zeros(current_bits); - return Math::min(result, self.size); - } - - /** - * @param from index to start looking for unset bit - * @return index of next unset bit, or {@code size} if none are unset until the end - * @see #getNextSet(int) - */ - pub fn get_next_unset(&self, from: i32) -> i32 { - if from >= self.size { - return self.size; - } - let bits_offset: i32 = from / 32; - let current_bits: i32 = !self.bits[bits_offset]; - // mask off lesser bits first - current_bits &= -(1 << (from & 0x1F)); - while current_bits == 0 { - if bits_offset += 1 == self.bits.len() { - return self.size; - } - current_bits = !self.bits[bits_offset]; - } - let result: i32 = (bits_offset * 32) + Integer::number_of_trailing_zeros(current_bits); - return Math::min(result, self.size); - } - - /** - * Sets a block of 32 bits, starting at bit i. - * - * @param i first bit to set - * @param newBits the new value of the next 32 bits. Note again that the least-significant bit - * corresponds to bit i, the next-least-significant to i+1, and so on. - */ - pub fn set_bulk(&self, i: i32, new_bits: i32) { - self.bits[i / 32] = new_bits; - } - - /** - * Sets a range of bits. - * - * @param start start of range, inclusive. - * @param end end of range, exclusive - */ - pub fn set_range(&self, start: i32, end: i32) -> Result<(), IllegalArgumentException> { - if end < start || start < 0 || end > self.size { - return Err(IllegalArgumentException::new()); - } - if end == start { - return; - } - // will be easier to treat this as the last actually set bit -- inclusive - end -= 1; - let first_int: i32 = start / 32; - let last_int: i32 = end / 32; - { - let mut i: i32 = first_int; - while i <= last_int { - { - let first_bit: i32 = if i > first_int { 0 } else { start & 0x1F }; - let last_bit: i32 = if i < last_int { 31 } else { end & 0x1F }; - // Ones from firstBit to lastBit, inclusive - let mask: i32 = (2 << last_bit) - (1 << first_bit); - self.bits[i] |= mask; - } - i += 1; - } - } - - Ok(()) - } - - /** - * Clears all bits (sets to false). - */ - pub fn clear(&self) { - let max: i32 = self.bits.len(); - { - let mut i: i32 = 0; - while i < max { - { - self.bits[i] = 0; - } - i += 1; - } - } - } - - /** - * Efficient method to check if a range of bits is set, or not set. - * - * @param start start of range, inclusive. - * @param end end of range, exclusive - * @param value if true, checks that bits in range are set, otherwise checks that they are not set - * @return true iff all bits are set or not set in range, according to value argument - * @throws IllegalArgumentException if end is less than start or the range is not contained in the array - */ - pub fn is_range( - &self, - start: i32, - end: i32, - value: bool, - ) -> Result { - if end < start || start < 0 || end > self.size { - return Err(IllegalArgumentException::new()); - } - if end == start { - // empty range matches - return Ok(true); - } - // will be easier to treat this as the last actually set bit -- inclusive - end -= 1; - let first_int: i32 = start / 32; - let last_int: i32 = end / 32; - { - let mut i: i32 = first_int; - while i <= last_int { - { - let first_bit: i32 = if i > first_int { 0 } else { start & 0x1F }; - let last_bit: i32 = if i < last_int { 31 } else { end & 0x1F }; - // Ones from firstBit to lastBit, inclusive - let mask: i32 = (2 << last_bit) - (1 << first_bit); - // equals the mask, or we're looking for 0s and the masked portion is not all 0s - if (self.bits[i] & mask) != (if value { mask } else { 0 }) { - return Ok(false); - } - } - i += 1; - } - } - - return Ok(true); - } - - pub fn append_bit(&self, bit: bool) { - self.ensure_capacity(self.size + 1); - if bit { - self.bits[self.size / 32] |= 1 << (self.size & 0x1F); - } - self.size += 1; - } - - /** - * Appends the least-significant bits, from value, in order from most-significant to - * least-significant. For example, appending 6 bits from 0x000001E will append the bits - * 0, 1, 1, 1, 1, 0 in that order. - * - * @param value {@code int} containing bits to append - * @param numBits bits from value to append - */ - pub fn append_bits(&self, value: i32, num_bits: i32) -> Result<(), IllegalArgumentException> { - if num_bits < 0 || num_bits > 32 { - return Err(IllegalArgumentException::new( - "Num bits must be between 0 and 32", - )); - } - let next_size: i32 = self.size; - self.ensure_capacity(next_size + num_bits); - { - let num_bits_left: i32 = num_bits - 1; - while num_bits_left >= 0 { - { - if (value & (1 << num_bits_left)) != 0 { - self.bits[next_size / 32] |= 1 << (next_size & 0x1F); - } - next_size += 1; - } - num_bits_left -= 1; - } - } - - self.size = next_size; - Ok(()) - } - - pub fn append_bit_array(&self, other: &BitArray) { - let other_size: i32 = other.size; - self.ensure_capacity(self.size + other_size); - { - let mut i: i32 = 0; - while i < other_size { - { - self.append_bit(&other.get(i)); - } - i += 1; - } - } - } - - pub fn xor(&self, other: &BitArray) -> Result((), IllegalArgumentException) { - if self.size != other.size { - return Err(IllegalArgumentException::new("Sizes don't match")); - } - { - let mut i: i32 = 0; - while i < self.bits.len() { - { - // The last int could be incomplete (i.e. not have 32 bits in - // it) but there is no problem since 0 XOR 0 == 0. - self.bits[i] ^= other.bits[i]; - } - i += 1; - } - } - Ok(()) - } - - /** - * - * @param bitOffset first bit to start writing - * @param array array to write into. Bytes are written most-significant byte first. This is the opposite - * of the internal representation, which is exposed by {@link #getBitArray()} - * @param offset position in array to start writing - * @param numBytes how many bytes to write - */ - pub fn to_bytes(&self, bit_offset: i32, array: &Vec, offset: i32, num_bytes: i32) { - { - let mut i: i32 = 0; - while i < num_bytes { - { - let the_byte: i32 = 0; - { - let mut j: i32 = 0; - while j < 8 { - { - if self.get(bit_offset) { - the_byte |= 1 << (7 - j); - } - bit_offset += 1; - } - j += 1; - } - } - - array[offset + i] = the_byte as i8; - } - i += 1; - } - } - } - - /** - * @return underlying array of ints. The first element holds the first 32 bits, and the least - * significant bit is bit 0. - */ - pub fn get_bit_array(&self) -> Vec { - return self.bits; - } - - /** - * Reverses all bits in the array. - */ - pub fn reverse(&self) { - let new_bits: [i32; self.bits.len()] = [0; self.bits.len()]; - // reverse all int's first - let mut len: i32 = (self.size - 1) / 32; - let old_bits_len: i32 = len + 1; - { - let mut i: i32 = 0; - while i < old_bits_len { - { - new_bits[len - i] = Integer::reverse(self.bits[i]); - } - i += 1; - } - } - - // now correct the int's if the bit size isn't a multiple of 32 - if self.size != old_bits_len * 32 { - let left_offset: i32 = old_bits_len * 32 - self.size; - let current_int: i32 = new_bits[0] >> /* >>> */ left_offset; - { - let mut i: i32 = 1; - while i < old_bits_len { - { - let next_int: i32 = new_bits[i]; - current_int |= next_int << (32 - left_offset); - new_bits[i - 1] = current_int; - current_int = next_int >> /* >>> */ left_offset; - } - i += 1; - } - } - - new_bits[old_bits_len - 1] = current_int; - } - self.bits = new_bits; - } - - fn make_array(size: i32) -> Vec { - return [0; (size + 31) / 32]; - } - - pub fn to_string(&self) -> String { - let result: StringBuilder = StringBuilder::new(self.size + (self.size / 8) + 1); - { - let mut i: i32 = 0; - while i < self.size { - { - if (i & 0x07) == 0 { - result.append(' '); - } - result.append(if self.get(i) { 'X' } else { '.' }); - } - i += 1; - } - } - - return result.to_string(); - } - - /*pub fn clone(&self) -> BitArray { - return BitArray::new(&self.bits.clone(), self.size); - }*/ -} - -// BitMatrix.java -/** - *

Represents a 2D matrix of bits. In function arguments below, and throughout the common - * module, x is the column position, and y is the row position. The ordering is always x, y. - * The origin is at the top-left.

- * - *

Internally the bits are represented in a 1-D array of 32-bit ints. However, each row begins - * with a new int. This is done intentionally so that we can copy out a row into a BitArray very - * efficiently.

- * - *

The ordering of bits is row-major. Within each int, the least significant bits are used first, - * meaning they represent lower x values. This is compatible with BitArray's implementation.

- * - * @author Sean Owen - * @author dswitkin@google.com (Daniel Switkin) - */ -#[derive(Cloneable, Eq, Hash)] -pub struct BitMatrix { - width: i32, - - height: i32, - - row_size: i32, - - bits: Vec, -} - -impl BitMatrix { - /** - * Creates an empty square {@code BitMatrix}. - * - * @param dimension height and width - */ - - /** - * Creates an empty {@code BitMatrix}. - * - * @param width bit matrix width - * @param height bit matrix height - */ - - fn new( - width: i32, - height: i32, - row_size: Option, - bits: Option<&Vec>, - ) -> Result { - if width < 1 || height < 1 { - return Err(IllegalArgumentException::new( - "Both dimensions must be greater than 0", - )); - } - - Ok(Self { - width: width, - height: height, - row_size: row_size.unwrap_or((width + 31) / 32), - bits: bits.unwrap_or([0; row_size * height]), - }) - } - - fn new_dimension(dimension: i32) { - BitMatrix::new(dimension, dimension, None, None) - } - - /** - * 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 - */ - pub fn parse(image: &Vec>) -> BitMatrix { - let height: i32 = image.len(); - let width: i32 = image[0].len(); - let bits: BitMatrix = BitMatrix::new(width, height, None, None); - { - let mut i: i32 = 0; - while i < height { - { - let image_i: Vec = image[i]; - { - let mut j: i32 = 0; - while j < width { - { - if image_i[j] { - bits.set(j, i); - } - } - j += 1; - } - } - } - i += 1; - } - } - - return bits; - } - - pub fn parse( - string_representation: &String, - set_string: &String, - unset_string: &String, - ) -> Result { - if string_representation == null { - return Err(IllegalArgumentException::new()); - } - let mut bits: [bool; string_representation.length()] = - [false; string_representation.length()]; - let bits_pos: i32 = 0; - let row_start_pos: i32 = 0; - let row_length: i32 = -1; - let n_rows: i32 = 0; - let mut pos: i32 = 0; - while pos < string_representation.length() { - if string_representation.char_at(pos) == '\n' - || string_representation.char_at(pos) == '\r' - { - if bits_pos > row_start_pos { - if row_length == -1 { - row_length = bits_pos - row_start_pos; - } else if bits_pos - row_start_pos != row_length { - return Err(IllegalArgumentException::new("row lengths do not match")); - } - row_start_pos = bits_pos; - n_rows += 1; - } - pos += 1; - } else if string_representation[..pos].starts_with(&set_string) { - pos += set_string.length(); - bits[bits_pos] = true; - bits_pos += 1; - } else if string_representation[..pos].starts_with(&unset_string) { - pos += unset_string.length(); - bits[bits_pos] = false; - bits_pos += 1; - } else { - return Err(IllegalArgumentException::new(format!( - "illegal character encountered: {}", - string_representation.substring(pos) - ))); - } - } - // no EOL at end? - if bits_pos > row_start_pos { - if row_length == -1 { - row_length = bits_pos - row_start_pos; - } else if bits_pos - row_start_pos != row_length { - return Err(IllegalArgumentException::new("row lengths do not match")); - } - n_rows += 1; - } - let matrix: BitMatrix = BitMatrix::new(row_length, n_rows, None, None); - { - let mut i: i32 = 0; - while i < bits_pos { - { - if bits[i] { - matrix.set(i % row_length, i / row_length); - } - } - i += 1; - } - } - - return Ok(matrix); - } - - /** - *

Gets the requested bit, where true means black.

- * - * @param x The horizontal component (i.e. which column) - * @param y The vertical component (i.e. which row) - * @return value of given bit in matrix - */ - pub fn get(&self, x: i32, y: i32) -> bool { - let offset: i32 = y * self.row_size + (x / 32); - return ((self.bits[offset] >> /* >>> */ (x & 0x1f)) & 1) != 0; - } - - /** - *

Sets the given bit to true.

- * - * @param x The horizontal component (i.e. which column) - * @param y The vertical component (i.e. which row) - */ - pub fn set(&self, x: i32, y: i32) { - let mut offset: i32 = y * self.row_size + (x / 32); - self.bits[offset] |= 1 << (x & 0x1f); - } - - pub fn unset(&self, x: i32, y: i32) { - let mut offset: i32 = y * self.row_size + (x / 32); - self.bits[offset] &= !(1 << (x & 0x1f)); - } - - /** - *

Flips the given bit.

- * - * @param x The horizontal component (i.e. which column) - * @param y The vertical component (i.e. which row) - */ - pub fn flip(&self, x: i32, y: i32) { - let mut offset: i32 = y * self.row_size + (x / 32); - self.bits[offset] ^= 1 << (x & 0x1f); - } - - /** - *

Flips every bit in the matrix.

- */ - pub fn flip(&self) { - let max: i32 = self.bits.len(); - { - let mut i: i32 = 0; - while i < max { - { - self.bits[i] = !self.bits[i]; - } - i += 1; - } - } - } - - /** - * Exclusive-or (XOR): Flip the bit in this {@code BitMatrix} if the corresponding - * mask bit is set. - * - * @param mask XOR mask - */ - pub fn xor(&self, mask: &BitMatrix) -> Result<(), IllegalArgumentException> { - if self.width != mask.width || self.height != mask.height || self.row_size != mask.rowSize { - return Err(IllegalArgumentException::new( - "input matrix dimensions do not match", - )); - } - let row_array: BitArray = BitArray::new(None, Some(self.width)); - { - let mut y: i32 = 0; - while y < self.height { - { - let mut offset: i32 = y * self.row_size; - let row: Vec = mask.get_row(y, &row_array).get_bit_array(); - { - let mut x: i32 = 0; - while x < self.row_size { - { - self.bits[offset + x] ^= row[x]; - } - x += 1; - } - } - } - y += 1; - } - } - Ok(()) - } - - /** - * Clears all bits (sets to false). - */ - pub fn clear(&self) { - let max: i32 = self.bits.len(); - { - let mut i: i32 = 0; - while i < max { - { - self.bits[i] = 0; - } - i += 1; - } - } - } - - /** - *

Sets a square region of the bit matrix to true.

- * - * @param left The horizontal position to begin at (inclusive) - * @param top The vertical position to begin at (inclusive) - * @param width The width of the region - * @param height The height of the region - */ - pub fn set_region( - &self, - left: i32, - top: i32, - width: i32, - height: i32, - ) -> Result<(), IllegalArgumentException> { - if top < 0 || left < 0 { - return Err(IllegalArgumentException::new( - "Left and top must be nonnegative", - )); - } - if height < 1 || width < 1 { - return Err(IllegalArgumentException::new( - "Height and width must be at least 1", - )); - } - let right: i32 = left + width; - let bottom: i32 = top + height; - if bottom > self.height || right > self.width { - return Err(IllegalArgumentException::new( - "The region must fit inside the matrix", - )); - } - { - let mut y: i32 = top; - while y < bottom { - { - let mut offset: i32 = y * self.row_size; - { - let mut x: i32 = left; - while x < right { - { - self.bits[offset + (x / 32)] |= 1 << (x & 0x1f); - } - x += 1; - } - } - } - y += 1; - } - } - Ok(()) - } - - /** - * A fast method to retrieve one row of data from the matrix as a BitArray. - * - * @param y The row to retrieve - * @param row An optional caller-allocated BitArray, will be allocated if null or too small - * @return The resulting BitArray - this reference should always be used even when passing - * your own row - */ - pub fn get_row(&self, y: i32, row: &BitArray) -> BitArray { - if row == null || row.get_size() < self.width { - row = &BitArray::new(None, Some(self.width)); - } else { - row.clear(); - } - let offset: i32 = y * self.row_size; - { - let mut x: i32 = 0; - while x < self.row_size { - { - row.set_bulk(x * 32, self.bits[offset + x]); - } - x += 1; - } - } - - return row; - } - - /** - * @param y row to set - * @param row {@link BitArray} to copy from - */ - pub fn set_row(&self, y: i32, row: &BitArray) { - System::arraycopy( - &row.get_bit_array(), - 0, - &self.bits, - y * self.row_size, - self.row_size, - ); - } - - /** - * Modifies this {@code BitMatrix} to represent the same but rotated the given degrees (0, 90, 180, 270) - * - * @param degrees number of degrees to rotate through counter-clockwise (0, 90, 180, 270) - */ - pub fn rotate(&self, degrees: i32) -> Result<(), IllegalArgumentException> { - match degrees % 360 { - 0 => Ok(()), - 90 => { - self.rotate90(); - Ok(()) - } - 180 => { - self.rotate180(); - Ok(()) - } - 270 => { - self.rotate90(); - self.rotate180(); - Ok(()) - } - _ => Err(IllegalArgumentException::new( - "degrees must be a multiple of 0, 90, 180, or 270", - )), - } - } - - /** - * Modifies this {@code BitMatrix} to represent the same but rotated 180 degrees - */ - pub fn rotate180(&self) { - let top_row: BitArray = BitArray::new(None, Some(self.width)); - let bottom_row: BitArray = BitArray::new(None, Some(self.width)); - let max_height: i32 = (self.height + 1) / 2; - { - let mut i: i32 = 0; - while i < max_height { - { - top_row = self.get_row(i, &top_row); - let bottom_row_index: i32 = self.height - 1 - i; - bottom_row = self.get_row(bottom_row_index, &bottom_row); - top_row.reverse(); - bottom_row.reverse(); - self.set_row(i, &bottom_row); - self.set_row(bottom_row_index, &top_row); - } - i += 1; - } - } - } - - /** - * Modifies this {@code BitMatrix} to represent the same but rotated 90 degrees counterclockwise - */ - pub fn rotate90(&self) { - let new_width: i32 = self.height; - let new_height: i32 = self.width; - let new_row_size: i32 = (new_width + 31) / 32; - let new_bits: [i32; new_row_size * new_height] = [0; new_row_size * new_height]; - { - let mut y: i32 = 0; - while y < self.height { - { - { - let mut x: i32 = 0; - while x < self.width { - { - let offset: i32 = y * self.row_size + (x / 32); - if ((self.bits[offset] >> /* >>> */ (x & 0x1f)) & 1) != 0 { - let new_offset: i32 = - (new_height - 1 - x) * new_row_size + (y / 32); - new_bits[new_offset] |= 1 << (y & 0x1f); - } - } - x += 1; - } - } - } - y += 1; - } - } - - self.width = new_width; - self.height = new_height; - self.row_size = new_row_size; - self.bits = new_bits; - } - - /** - * This is useful in detecting the enclosing rectangle of a 'pure' barcode. - * - * @return {@code left,top,width,height} enclosing rectangle of all 1 bits, or null if it is all white - */ - pub fn get_enclosing_rectangle(&self) -> Option> { - let mut left: i32 = self.width; - let mut top: i32 = self.height; - let mut right: i32 = -1; - let mut bottom: i32 = -1; - { - let mut y: i32 = 0; - while y < self.height { - { - { - let mut x32: i32 = 0; - while x32 < self.row_size { - { - let the_bits: i32 = self.bits[y * self.row_size + x32]; - if the_bits != 0 { - if y < top { - top = y; - } - if y > bottom { - bottom = y; - } - if x32 * 32 < left { - let mut bit: i32 = 0; - while (the_bits << (31 - bit)) == 0 { - bit += 1; - } - if (x32 * 32 + bit) < left { - left = x32 * 32 + bit; - } - } - if x32 * 32 + 31 > right { - let mut bit: i32 = 31; - while (the_bits >> /* >>> */ bit) == 0 { - bit -= 1; - } - if (x32 * 32 + bit) > right { - right = x32 * 32 + bit; - } - } - } - } - x32 += 1; - } - } - } - y += 1; - } - } - - if right < left || bottom < top { - return null; - } - return Some(vec![left, top, right - left + 1, bottom - top + 1]); - } - - /** - * This is useful in detecting a corner of a 'pure' barcode. - * - * @return {@code x,y} coordinate of top-left-most 1 bit, or null if it is all white - */ - pub fn get_top_left_on_bit(&self) -> Option> { - let bits_offset: i32 = 0; - while bits_offset < self.bits.len() && self.bits[bits_offset] == 0 { - bits_offset += 1; - } - if bits_offset == self.bits.len() { - return null; - } - let y: i32 = bits_offset / self.row_size; - let mut x: i32 = (bits_offset % self.row_size) * 32; - let the_bits: i32 = self.bits[bits_offset]; - let mut bit: i32 = 0; - while (the_bits << (31 - bit)) == 0 { - bit += 1; - } - x += bit; - return Some(vec![x, y]); - } - - pub fn get_bottom_right_on_bit(&self) -> Vec { - let bits_offset: i32 = self.bits.len() - 1; - while bits_offset >= 0 && self.bits[bits_offset] == 0 { - bits_offset -= 1; - } - if bits_offset < 0 { - return null; - } - let y: i32 = bits_offset / self.row_size; - let mut x: i32 = (bits_offset % self.row_size) * 32; - let the_bits: i32 = self.bits[bits_offset]; - let mut bit: i32 = 31; - while (the_bits >> /* >>> */ bit) == 0 { - bit -= 1; - } - x += bit; - return vec![x, y]; - } - - /** - * @return The width of the matrix - */ - pub fn get_width(&self) -> i32 { - return self.width; - } - - /** - * @return The height of the matrix - */ - pub fn get_height(&self) -> i32 { - return self.height; - } - - /** - * @return The row size of the matrix - */ - pub fn get_row_size(&self) -> i32 { - return self.row_size; - } - - pub fn hash_code(&self) -> i32 { - let mut hash: i32 = self.width; - hash = 31 * hash + self.width; - hash = 31 * hash + self.height; - hash = 31 * hash + self.row_size; - hash = 31 * hash + Arrays::hash_code(&self.bits); - return hash; - } - - /** - * @param setString representation of a set bit - * @param unsetString representation of an unset bit - * @param lineSeparator newline character in string representation - * @return string representation of entire matrix utilizing given strings and line separator - * @deprecated call {@link #toString(String,String)} only, which uses \n line separator always - */ - pub fn to_string( - &self, - set_string: Option<&str>, - unset_string: Option<&str>, - line_separator: Option<&str>, - ) -> String { - return self.build_to_string( - set_string.unwrap_or("X "), - unset_string.unwrap_or(" "), - line_separator.unwrap_or("\n"), - ); - } - - fn build_to_string( - &self, - set_string: &String, - unset_string: &String, - line_separator: &String, - ) -> String { - let result: StringBuilder = StringBuilder::new(self.height * (self.width + 1)); - { - let mut y: i32 = 0; - while y < self.height { - { - { - let mut x: i32 = 0; - while x < self.width { - { - result.append(if self.get(x, y) { - set_string - } else { - unset_string - }); - } - x += 1; - } - } - - result.append(&line_separator); - } - y += 1; - } - } - - return result.to_string(); - } - - /*pub fn clone(&self) -> BitMatrix { - return BitMatrix::new(self.width, self.height, self.row_size, &self.bits.clone()); - }*/ -} - -// BitSource.java -/** - *

This provides an easy abstraction to read bits at a time from a sequence of bytes, where the - * number of bits read is not often a multiple of 8.

- * - *

This class is thread-safe but not reentrant -- unless the caller modifies the bytes array - * it passed in, in which case all bets are off.

- * - * @author Sean Owen - */ -pub struct BitSource { - bytes: Vec, - - byte_offset: i32, - - bit_offset: i32, -} - -impl BitSource { - /** - * @param bytes bytes from which this will read bits. Bits will be read from the first byte first. - * Bits are read within a byte from most-significant to least-significant bit. - */ - pub fn new(bytes: &Vec) -> Self { - let mut new_bs; - new_bs.bytes = bytes; - - new_bs - } - - /** - * @return index of next bit in current byte which would be read by the next call to {@link #readBits(int)}. - */ - pub fn get_bit_offset(&self) -> i32 { - return self.bit_offset; - } - - /** - * @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}. - */ - pub fn get_byte_offset(&self) -> i32 { - return self.byte_offset; - } - - /** - * @param numBits number of bits to read - * @return int representing the bits read. The bits will appear as the least-significant - * bits of the int - * @throws IllegalArgumentException if numBits isn't in [1,32] or more than is available - */ - pub fn read_bits(&self, num_bits: i32) -> Result { - if num_bits < 1 || num_bits > 32 || num_bits > self.available() { - return Err(IllegalArgumentException::new(&String::value_of(num_bits))); - } - let mut result: i32 = 0; - // First, read remainder from current byte - if self.bit_offset > 0 { - let bits_left: i32 = 8 - self.bit_offset; - let to_read: i32 = Math::min(num_bits, bits_left); - let bits_to_not_read: i32 = bits_left - to_read; - let mask: i32 = (0xFF >> (8 - to_read)) << bits_to_not_read; - result = (self.bytes[self.byte_offset] & mask) >> bits_to_not_read; - num_bits -= to_read; - self.bit_offset += to_read; - if self.bit_offset == 8 { - self.bit_offset = 0; - self.byte_offset += 1; - } - } - // Next read whole bytes - if num_bits > 0 { - while num_bits >= 8 { - result = (result << 8) | (self.bytes[self.byte_offset] & 0xFF); - self.byte_offset += 1; - num_bits -= 8; - } - // Finally read a partial byte - if num_bits > 0 { - let bits_to_not_read: i32 = 8 - num_bits; - let mask: i32 = (0xFF >> bits_to_not_read) << bits_to_not_read; - result = (result << num_bits) - | ((self.bytes[self.byte_offset] & mask) >> bits_to_not_read); - self.bit_offset += num_bits; - } - } - return Ok(result); - } - - /** - * @return number of bits that can be read successfully - */ - pub fn available(&self) -> i32 { - return 8 * (self.bytes.len() - self.byte_offset) - self.bit_offset; - } -} - -// CharacterSetECI.java -/** - * Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1 - * of ISO 18004. - * - * @author Sean Owen - */ -pub enum CharacterSetECI { - // Enum name is a Java encoding valid for java.lang and java.io - Cp437, - ISO8859_1, - ISO8859_2, - ISO8859_3, - ISO8859_4, - ISO8859_5, - // ISO8859_6(8, "ISO-8859-6"), - ISO8859_7, - // ISO8859_8(10, "ISO-8859-8"), - ISO8859_9, - // ISO8859_10(12, "ISO-8859-10"), - // ISO8859_11(13, "ISO-8859-11"), - ISO8859_13, - // ISO8859_14(16, "ISO-8859-14"), - ISO8859_15, - ISO8859_16, - SJIS, - Cp1250, - Cp1251, - Cp1252, - Cp1256, - UnicodeBigUnmarked, - UTF8, - ASCII, - Big5, - GB18030, - EUC_KR, /* - - // Enum name is a Java encoding valid for java.lang and java.io - Cp437(new int[]{0,2}), - ISO8859_1(new int[]{1,3}, "ISO-8859-1"), - ISO8859_2(4, "ISO-8859-2"), - ISO8859_3(5, "ISO-8859-3"), - ISO8859_4(6, "ISO-8859-4"), - ISO8859_5(7, "ISO-8859-5"), - // ISO8859_6(8, "ISO-8859-6"), - ISO8859_7(9, "ISO-8859-7"), - // ISO8859_8(10, "ISO-8859-8"), - ISO8859_9(11, "ISO-8859-9"), - // ISO8859_10(12, "ISO-8859-10"), - // ISO8859_11(13, "ISO-8859-11"), - ISO8859_13(15, "ISO-8859-13"), - // ISO8859_14(16, "ISO-8859-14"), - ISO8859_15(17, "ISO-8859-15"), - ISO8859_16(18, "ISO-8859-16"), - SJIS(20, "Shift_JIS"), - Cp1250(21, "windows-1250"), - Cp1251(22, "windows-1251"), - Cp1252(23, "windows-1252"), - Cp1256(24, "windows-1256"), - UnicodeBigUnmarked(25, "UTF-16BE", "UnicodeBig"), - UTF8(26, "UTF-8"), - ASCII(new int[] {27, 170}, "US-ASCII"), - Big5(28), - GB18030(29, "GB2312", "EUC_CN", "GBK"), - EUC_KR(30, "EUC-KR"); - - */ -} - -impl CharacterSetECI { - /* - fn new( value: i32) -> CharacterSetECI { - this( : vec![i32; 1] = vec![value, ] - ); - } - - fn new( value: i32, other_encoding_names: &String) -> CharacterSetECI { - let .values = : vec![i32; 1] = vec![value, ] - ; - let .otherEncodingNames = other_encoding_names; - } - - fn new( values: &Vec, other_encoding_names: &String) -> CharacterSetECI { - let .values = values; - let .otherEncodingNames = other_encoding_names; - } - - pub fn get_charset(&self) -> Charset { - return Charset::for_name(&name()); - } - */ - - /** - * @param charset Java character set object - * @return CharacterSetECI representing ECI for character encoding, or null if it is legal - * but unsupported - */ - pub fn get_character_set_e_c_i(charset: &str) -> Result, &'static str> { - //return NAME_TO_ECI::get(&charset.name()); - let eci = match charset { - "Cp437" => Self::Cp437, - "ISO-8859-1" => Self::ISO8859_1, - "ISO-8859-2" => Self::ISO8859_2, - "ISO-8859-3" => Self::ISO8859_3, - "ISO-8859-4" => Self::ISO8859_4, - "ISO-8859-5" => Self::ISO8859_5, - "ISO-8859-7" => Self::ISO8859_7, - "ISO-8859-9" => Self::ISO8859_9, - "ISO-8859-13" => Self::ISO8859_13, - "ISO-8859-15" => Self::ISO8859_15, - "ISO-8859-16" => Self::ISO8859_16, - "Shift_JIS" => Self::SJIS, - "windows-1250" => Self::Cp1250, - "windows-1251" => Self::Cp1251, - "windows-1252" => Self::Cp1252, - "windows-1256" => Self::Cp1256, - "UTF-16BE" | "UnicodeBig" => Self::UnicodeBigUnmarked, - "UTF-8" => Self::UTF8, - "US-ASCII" => Self::ASCII, - "Big5" => Self::Big5, - "GB2312" | "EUC_CN" | "GBK" => Self::GB18030, - "EUC-KR" => Self::EUC_KR, - _ => return Err("Invalid charset"), - }; - Ok(Some(eci)) - } - - /** - * @param value character set ECI value - * @return {@code CharacterSetECI} representing ECI of given value, or null if it is legal but - * unsupported - * @throws FormatException if ECI value is invalid - */ - pub fn get_character_set_e_c_i_by_value( - value: i32, - ) -> Result, FormatException> { - if value < 0 || value >= 900 { - return Err(FormatException::get_format_instance()); - } - let eci = match value { - 0 | 2 => Self::Cp437, - 1 | 3 => Self::ISO8859_1, - 4 => Self::ISO8859_2, - 5 => Self::ISO8859_3, - 6 => Self::ISO8859_4, - 7 => Self::ISO8859_5, - 9 => Self::ISO8859_7, - 11 => Self::ISO8859_9, - 15 => Self::ISO8859_13, - 17 => Self::ISO8859_15, - 18 => Self::ISO8859_16, - 20 => Self::SJIS, - 21 => Self::Cp1250, - 22 => Self::Cp1251, - 23 => Self::Cp1252, - 24 => Self::Cp1256, - 25 => Self::UnicodeBigUnmarked, - 26 => Self::UTF8, - 27 | 170 => Self::ASCII, - 28 => Self::Big5, - 29 => Self::GB18030, - 30 => Self::EUC_KR, - _ => return Err(FormatException::get_format_instance()), - }; - return Ok(Some(eci)); - } - - pub fn get_value(v: Self) -> i32 { - match v { - CharacterSetECI::Cp437 => 0, - CharacterSetECI::ISO8859_1 => 1, - CharacterSetECI::ISO8859_2 => 4, - CharacterSetECI::ISO8859_3 => 5, - CharacterSetECI::ISO8859_4 => 6, - CharacterSetECI::ISO8859_5 => 7, - CharacterSetECI::ISO8859_7 => 9, - CharacterSetECI::ISO8859_9 => 11, - CharacterSetECI::ISO8859_13 => 15, - CharacterSetECI::ISO8859_15 => 17, - CharacterSetECI::ISO8859_16 => 18, - CharacterSetECI::SJIS => 20, - CharacterSetECI::Cp1250 => 21, - CharacterSetECI::Cp1251 => 22, - CharacterSetECI::Cp1252 => 23, - CharacterSetECI::Cp1256 => 24, - CharacterSetECI::UnicodeBigUnmarked => 25, - CharacterSetECI::UTF8 => 26, - CharacterSetECI::ASCII => 27, - CharacterSetECI::Big5 => 28, - CharacterSetECI::GB18030 => 29, - CharacterSetECI::EUC_KR => 30, - } - } - - /* - * @param name character set ECI encoding name - * @return CharacterSetECI representing ECI for character encoding, or null if it is legal - * but unsupported - */ - /* - pub fn get_character_set_e_c_i_by_name( name: &str) -> Result { - return NAME_TO_ECI::get(&name); - } - */ -} - -// DecoderResult.java -/** - *

Encapsulates the result of decoding a matrix of bits. This typically - * applies to 2D barcode formats. For now it contains the raw bytes obtained, - * as well as a String interpretation of those bytes, if applicable.

- * - * @author Sean Owen - */ -pub struct DecoderResult { - raw_bytes: Vec, - - num_bits: i32, - - text: String, - - byte_segments: List>, - - ec_level: String, - - errors_corrected: Integer, - - erasures: Integer, - - other: Object, - - structured_append_parity: i32, - - structured_append_sequence_number: i32, - - symbology_modifier: i32, -} - -impl DecoderResult { - pub fn new( - raw_bytes: &Vec, - text: &String, - byte_segments: &Vec>, - ec_level: &String, - sa_sequence: Option, - sa_parity: Option, - symbology_modifier: Option, - ) -> Self { - let mut new_dr: Self; - - new_dr.raw_bytes = raw_bytes; - new_dr.text = text; - new_dr.byte_segments = byte_segments; - new_dr.ec_level = ec_level; - - new_dr.symbology_modifier = symbology_modifier.unwrap_or(0); - - new_dr.structured_append_parity = sa_parity.unwrap_or(-1); - new_dr.structured_append_sequence_number = sa_sequence.unwrap_or(-1); - - new_dr.num_bits = raw_bytes.len() * 8; - - new_dr - } - /** - * @return raw bytes representing the result, or {@code null} if not applicable - */ - pub fn get_raw_bytes(&self) -> Option> { - return Some(self.raw_bytes); - } - - /** - * @return how many bits of {@link #getRawBytes()} are valid; typically 8 times its length - * @since 3.3.0 - */ - pub fn get_num_bits(&self) -> i32 { - return self.num_bits; - } - - /** - * @param numBits overrides the number of bits that are valid in {@link #getRawBytes()} - * @since 3.3.0 - */ - pub fn set_num_bits(&self, num_bits: i32) { - self.numBits = num_bits; - } - - /** - * @return text representation of the result - */ - pub fn get_text(&self) -> String { - return self.text; - } - - /** - * @return list of byte segments in the result, or {@code null} if not applicable - */ - pub fn get_byte_segments(&self) -> Option>> { - return self.byte_segments; - } - - /** - * @return name of error correction level used, or {@code null} if not applicable - */ - pub fn get_e_c_level(&self) -> Option { - return Some(self.ec_level); - } - - /** - * @return number of errors corrected, or {@code null} if not applicable - */ - pub fn get_errors_corrected(&self) -> Option { - return self.errors_corrected; - } - - pub fn set_errors_corrected(&self, errors_corrected: &Integer) { - self.errorsCorrected = errors_corrected; - } - - /** - * @return number of erasures corrected, or {@code null} if not applicable - */ - pub fn get_erasures(&self) -> Option { - return self.erasures; - } - - pub fn set_erasures(&self, erasures: &Integer) { - self.erasures = erasures; - } - - /** - * @return arbitrary additional metadata - */ - pub fn get_other(&self) -> Object { - return self.other; - } - - pub fn set_other(&self, other: &Object) { - self.other = other; - } - - pub fn has_structured_append(&self) -> bool { - return self.structured_append_parity >= 0 && self.structured_append_sequence_number >= 0; - } - - pub fn get_structured_append_parity(&self) -> i32 { - return self.structured_append_parity; - } - - pub fn get_structured_append_sequence_number(&self) -> i32 { - return self.structured_append_sequence_number; - } - - pub fn get_symbology_modifier(&self) -> i32 { - return self.symbology_modifier; - } -} - -// DefaultGridSampler.java - -/** - * @author Sean Owen - */ -pub struct DefaultGridSampler { - //super: GridSampler; -} - -impl GridSampler for DefaultGridSampler { - fn sample_grid( - &self, - image: &BitMatrix, - dimension_x: i32, - dimension_y: i32, - p1_to_x: f32, - p1_to_y: f32, - p2_to_x: f32, - p2_to_y: f32, - p3_to_x: f32, - p3_to_y: f32, - p4_to_x: f32, - p4_to_y: f32, - p1_from_x: f32, - p1_from_y: f32, - p2_from_x: f32, - p2_from_y: f32, - p3_from_x: f32, - p3_from_y: f32, - p4_from_x: f32, - p4_from_y: f32, - ) -> Result { - let transform: PerspectiveTransform = PerspectiveTransform::quadrilateral_to_quadrilateral( - p1_to_x, p1_to_y, p2_to_x, p2_to_y, p3_to_x, p3_to_y, p4_to_x, p4_to_y, p1_from_x, - p1_from_y, p2_from_x, p2_from_y, p3_from_x, p3_from_y, p4_from_x, p4_from_y, - ); - return Ok(self.sample_grid(image, dimension_x, dimension_y, transform)); - } - - fn sample_grid( - &self, - image: &BitMatrix, - dimension_x: i32, - dimension_y: i32, - transform: &PerspectiveTransform, - ) -> Result { - if dimension_x <= 0 || dimension_y <= 0 { - return Err(NotFoundException::get_not_found_instance()); - } - let bits: BitMatrix = BitMatrix::new(dimension_x, dimension_y, None, None); - let mut points: [f32; 2.0 * dimension_x] = [0.0; 2.0 * dimension_x]; - { - let mut y: i32 = 0; - while y < dimension_y { - { - let max: i32 = points.len(); - let i_value: f32 = y + 0.5f32; - { - let mut x: i32 = 0; - while x < max { - { - points[x] = (x / 2.0) as f32 + 0.5f32; - points[x + 1] = i_value; - } - x += 2; - } - } - - transform.transform_points(&points); - // Quick check to see if points transformed to something inside the image; - // sufficient to check the endpoints - check_and_nudge_points(image, &points); - let tryResult1 = 0; - //'try1: loop { - //{ - { - let mut x: i32 = 0; - while x < max { - { - if image.get(points[x] as i32, points[x + 1] as i32) { - // Black(-ish) pixel - bits.set(x / 2, y); - } - } - x += 2; - } - } - - //} - //break 'try1 - //} - //match tryResult1 { - // catch ( aioobe: &ArrayIndexOutOfBoundsException) { - // return Err( NotFoundException::get_not_found_instance()); - // } 0 => break - //} - } - y += 1; - } - } - - return Ok(bits); - } -} - -// DetectorResult.java -/** - *

Encapsulates the result of detecting a barcode in an image. This includes the raw - * matrix of black/white pixels corresponding to the barcode, and possibly points of interest - * in the image, like the location of finder patterns or corners of the barcode in the image.

- * - * @author Sean Owen - */ - -/* pub struct DetectorResult { - bits: BitMatrix, - - points: Vec, -} - -impl DetectorResult { - pub fn new(bits: &BitMatrix, points: &Vec) -> Self { - Self { - bits: bits, - points: points, - } - } - - pub fn get_bits(&self) -> BitMatrix { - return self.bits; - } - - pub fn get_points(&self) -> Vec { - return self.points; - } -} -*/ - -pub trait DetectorResult { - //pub fn new(bits: &BitMatrix, points: &Vec) -> Self; - pub fn get_bits(&self) -> BitMatrix; - pub fn get_points(&self) -> Vec; -} - -// ECIEncoderSet.java -/** - * Set of CharsetEncoders for a given input string - * - * Invariants: - * - The list contains only encoders from CharacterSetECI (list is shorter then the list of encoders available on - * the platform for which ECI values are defined). - * - The list contains encoders at least one encoder for every character in the input. - * - The first encoder in the list is always the ISO-8859-1 encoder even of no character in the input can be encoded - * by it. - * - If the input contains a character that is not in ISO-8859-1 then the last two entries in the list will be the - * UTF-8 encoder and the UTF-16BE encoder. - * - * @author Alex Geller - */ - -// List of encoders that potentially encode characters not in ISO-8859-1 in one byte. -//const ENCODERS: List = ArrayList<>::new(); -pub struct ECIEncoderSet { - encoders: Vec, - - priority_encoder_index: i32, -} - -impl ECIEncoderSet { - /*static { - let names: vec![Vec; 20] = vec!["IBM437", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-10", "ISO-8859-11", "ISO-8859-13", "ISO-8859-14", "ISO-8859-15", "ISO-8859-16", "windows-1250", "windows-1251", "windows-1252", "windows-1256", "Shift_JIS", ] - ; - for let name: String in names { - if CharacterSetECI::get_character_set_e_c_i_by_name(&name) != null { - let tryResult1 = 0; - 'try1: loop { - { - ENCODERS::add(&Charset::for_name(&name)::new_encoder()); - } - break 'try1 - } - match tryResult1 { - catch ( e: &UnsupportedCharsetException) { - } 0 => break - } - - } - } - }*/ - - /** - * Constructs an encoder set - * - * @param stringToEncode the string that needs to be encoded - * @param priorityCharset The preferred {@link Charset} or null. - * @param fnc1 fnc1 denotes the character in the input that represents the FNC1 character or -1 for a non-GS1 bar - * code. When specified, it is considered an error to pass it as argument to the methods canEncode() or encode(). - */ - pub fn new(string_to_encode: &str, priority_charset: &Charset, fnc1: i32) -> ECIEncoderSet { - let needed_encoders: Vec = Vec::new(); - //we always need the ISO-8859-1 encoder. It is the default encoding - needed_encoders.add(&StandardCharsets::ISO_8859_1::new_encoder()); - let need_unicode_encoder: bool = - priority_charset != null && priority_charset.name().starts_with("UTF"); - //Walk over the input string and see if all characters can be encoded with the list of encoders - { - let mut i: i32 = 0; - while i < string_to_encode.length() { - { - let can_encode: bool = false; - for encoder in needed_encoders { - let c: char = string_to_encode.char_at(i); - if c == fnc1 || encoder.can_encode(c) { - can_encode = true; - break; - } - } - if !can_encode { - //for the character at position i we don't yet have an encoder in the list - for encoder in ENCODERS { - if encoder.can_encode(&string_to_encode.char_at(i)) { - //Good, we found an encoder that can encode the character. We add him to the list and continue scanning - //the input - needed_encoders.add(&encoder); - can_encode = true; - break; - } - } - } - if !can_encode { - //The character is not encodeable by any of the single byte encoders so we remember that we will need a - //Unicode encoder. - need_unicode_encoder = true; - } - } - i += 1; - } - } - - if needed_encoders.size() == 1 && !need_unicode_encoder { - //the entire input can be encoded by the ISO-8859-1 encoder - encoders = vec![needed_encoders.get(0)]; - } else { - // we need more than one single byte encoder or we need a Unicode encoder. - // In this case we append a UTF-8 and UTF-16 encoder to the list - encoders = [None; needed_encoders.size() + 2]; - let mut index: i32 = 0; - for encoder in needed_encoders { - encoders[index += 1] = encoder; - } - encoders[index] = StandardCharsets::UTF_8::new_encoder(); - encoders[index + 1] = StandardCharsets::UTF_16BE::new_encoder(); - } - //Compute priorityEncoderIndex by looking up priorityCharset in encoders - let priority_encoder_index_value: i32 = -1; - if priority_charset != null { - { - let mut i: i32 = 0; - while i < encoders.len() { - { - if encoders[i] != null - && priority_charset - .name() - .equals(&encoders[i].charset().name()) - { - priority_encoder_index_value = i; - break; - } - } - i += 1; - } - } - } - priority_encoder_index = priority_encoder_index_value; - //invariants - assert!(encoders[0].charset().equals(StandardCharsets::ISO_8859_1)); - } - - pub fn length(&self) -> i32 { - return self.encoders.len(); - } - - pub fn get_charset_name(&self, index: i32) -> String { - assert!(index < self.length()); - return self.encoders[index].charset().name(); - } - - pub fn get_charset(&self, index: i32) -> Charset { - assert!(index < self.length()); - return self.encoders[index].charset(); - } - - pub fn get_e_c_i_value(&self, encoder_index: i32) -> i32 { - return CharacterSetECI::get_value(CharacterSetECI::get_character_set_e_c_i( - &self.encoders[encoder_index].charset(), - )); - } - - /* - * returns -1 if no priority charset was defined - */ - pub fn get_priority_encoder_index(&self) -> i32 { - return self.priority_encoder_index; - } - - pub fn can_encode(&self, c: char, encoder_index: i32) -> bool { - assert!(encoder_index < self.length()); - let encoder: CharsetEncoder = self.encoders[encoder_index]; - return encoder.can_encode(format!("{}", c)); - } - - pub fn encode(&self, c: char, encoder_index: i32) -> Vec { - assert!(encoder_index < self.length()); - let encoder: CharsetEncoder = self.encoders[encoder_index]; - assert!(encoder.can_encode(format!("{}", c))); - return (format!("{}", c)).get_bytes(&encoder.charset()); - } - - pub fn encode(&self, s: &String, encoder_index: i32) -> Vec { - assert!(encoder_index < self.length()); - let encoder: CharsetEncoder = self.encoders[encoder_index]; - return s.get_bytes(&encoder.charset()); - } -} - -// ECIStringBuilder.java -/** - * Class that converts a sequence of ECIs and bytes into a string - * - * @author Alex Geller - */ -pub struct ECIStringBuilder { - current_bytes: StringBuilder, - - result: StringBuilder, - - current_charset: Charset, -} - -impl ECIStringBuilder { - pub fn new() -> Self { - let mut neweci_sb; - neweci_sb.current_bytes = StringBuilder::new(initial_capacity.unwrape_or(0)); - - neweci_sb - } - - /** - * Appends {@code value} as a byte value - * - * @param value character whose lowest byte is to be appended - */ - pub fn append(&self, value: char) { - self.current_bytes.append((value & 0xff) as char); - } - - /** - * Appends {@code value} as a byte value - * - * @param value byte to append - */ - pub fn append(&self, value: i8) { - self.current_bytes.append((value & 0xff) as char); - } - - /** - * Appends the characters in {@code value} as bytes values - * - * @param value string to append - */ - pub fn append(&self, value: &String) { - self.current_bytes.append(&value); - } - - /** - * Append the string repesentation of {@code value} (short for {@code append(String.valueOf(value))}) - * - * @param value int to append as a string - */ - pub fn append(&self, value: i32) { - self.append(&String::value_of(value)); - } - - /** - * Appends ECI value to output. - * - * @param value ECI value to append, as an int - * @throws FormatException on invalid ECI value - */ - pub fn append_e_c_i(&self, value: i32) -> Result<(), FormatException> { - self.encode_current_bytes_if_any(); - let character_set_e_c_i: CharacterSetECI = - CharacterSetECI::get_character_set_e_c_i_by_value(value); - if character_set_e_c_i == null { - return Err(FormatException::get_format_instance()); - } - self.current_charset = character_set_e_c_i.get_charset(); - Ok(()) - } - - fn encode_current_bytes_if_any(&self) { - if self.current_charset.equals(StandardCharsets::ISO_8859_1) { - if self.current_bytes.length() > 0 { - if self.result == null { - self.result = self.current_bytes; - self.current_bytes = StringBuilder::new(); - } else { - self.result.append(&self.current_bytes); - self.current_bytes = StringBuilder::new(); - } - } - } else if self.current_bytes.length() > 0 { - let bytes: Vec = self - .current_bytes - .to_string() - .get_bytes(StandardCharsets::ISO_8859_1); - self.current_bytes = StringBuilder::new(); - if self.result == null { - //self.result = StringBuilder::new(String::new(&bytes, &self.current_charset)); - self.result = StringBuilder::new(String::from(&bytes)); - } else { - //self.result.append(String::new(&bytes, &self.current_charset)); - self.result.append(String::from(&bytes)); - } - } - } - - /** - * Appends the characters from {@code value} (unlike all other append methods of this class who append bytes) - * - * @param value characters to append - */ - pub fn append_characters(&self, value: &StringBuilder) { - self.encode_current_bytes_if_any(); - self.result.append(&value); - } - - /** - * Short for {@code toString().length()} (if possible, use {@link #isEmpty()} instead) - * - * @return length of string representation in characters - */ - pub fn length(&self) -> i32 { - return self.to_string().length(); - } - - /** - * @return true iff nothing has been appended - */ - pub fn is_empty(&self) -> bool { - return self.current_bytes.length() == 0 - && (self.result == null || self.result.length() == 0); - } - - pub fn to_string(&self) -> String { - self.encode_current_bytes_if_any(); - return if self.result == null { - "".to_owned() - } else { - self.result.to_string() - }; - } -} - -// HybridBinarizer.java -/** - * This class implements a local thresholding algorithm, which while slower than the - * GlobalHistogramBinarizer, is fairly efficient for what it does. It is designed for - * high frequency images of barcodes with black data on white backgrounds. For this application, - * it does a much better job than a global blackpoint with severe shadows and gradients. - * However it tends to produce artifacts on lower frequency images and is therefore not - * a good general purpose binarizer for uses outside ZXing. - * - * This class extends GlobalHistogramBinarizer, using the older histogram approach for 1D readers, - * and the newer local approach for 2D readers. 1D decoding using a per-row histogram is already - * inherently local, and only fails for horizontal gradients. We can revisit that problem later, - * but for now it was not a win to use local blocks for 1D. - * - * This Binarizer is the default for the unit tests and the recommended class for library users. - * - * @author dswitkin@google.com (Daniel Switkin) - */ - -// This class uses 5x5 blocks to compute local luminance, where each block is 8x8 pixels. -// So this is the smallest dimension in each axis we can accept. -const BLOCK_SIZE_POWER: i32 = 3; - -// ...0100...00 -const BLOCK_SIZE: i32 = 1 << BLOCK_SIZE_POWER; - -// ...0011...11 -const BLOCK_SIZE_MASK: i32 = BLOCK_SIZE - 1; - -const MINIMUM_DIMENSION: i32 = BLOCK_SIZE * 5; - -const MIN_DYNAMIC_RANGE: i32 = 24; -pub struct HybridBinarizer { - //super: GlobalHistogramBinarizer; - matrix: BitMatrix, -} - -impl GlobalHistogramBinarizer for HybridBinarizer { - /** - * Calculates the final BitMatrix once for all requests. This could be called once from the - * constructor instead, but there are some advantages to doing it lazily, such as making - * profiling easier, and not doing heavy lifting when callers don't expect it. - */ - fn get_black_matrix(&self) -> Result { - if self.matrix != null { - return Ok(self.matrix); - } - let source: LuminanceSource = get_luminance_source(); - let width: i32 = source.get_width(); - let height: i32 = source.get_height(); - if width >= MINIMUM_DIMENSION && height >= MINIMUM_DIMENSION { - let luminances: Vec = source.get_matrix(); - let sub_width: i32 = width >> BLOCK_SIZE_POWER; - if (width & BLOCK_SIZE_MASK) != 0 { - sub_width += 1; - } - let sub_height: i32 = height >> BLOCK_SIZE_POWER; - if (height & BLOCK_SIZE_MASK) != 0 { - sub_height += 1; - } - let black_points: Vec> = - ::calculate_black_points(&luminances, sub_width, sub_height, width, height); - let new_matrix: BitMatrix = BitMatrix::new(width, height, None, None); - ::calculate_threshold_for_block( - &luminances, - sub_width, - sub_height, - width, - height, - &black_points, - new_matrix, - ); - self.matrix = new_matrix; - } else { - // If the image is too small, fall back to the global histogram approach. - self.matrix = super.get_black_matrix(); - } - return Ok(self.matrix); - } - - fn create_binarizer(&self, source: &LuminanceSource) -> Binarizer { - return HybridBinarizer::new(source); - } -} - -impl HybridBinarizer { - pub fn new(source: &LuminanceSource) -> Self { - //super(source); - HybridBinarizer::new(source) - } - - /** - * For each block in the image, calculate the average black point using a 5x5 grid - * of the blocks around it. Also handles the corner cases (fractional blocks are computed based - * on the last pixels in the row/column which are also used in the previous block). - */ - fn calculate_threshold_for_block( - luminances: &Vec, - sub_width: i32, - sub_height: i32, - width: i32, - height: i32, - black_points: &Vec>, - matrix: &BitMatrix, - ) { - let max_y_offset: i32 = height - BLOCK_SIZE; - let max_x_offset: i32 = width - BLOCK_SIZE; - { - let mut y: i32 = 0; - while y < sub_height { - { - let mut yoffset: i32 = y << BLOCK_SIZE_POWER; - if yoffset > max_y_offset { - yoffset = max_y_offset; - } - let top: i32 = ::cap(y, sub_height - 3); - { - let mut x: i32 = 0; - while x < sub_width { - { - let mut xoffset: i32 = x << BLOCK_SIZE_POWER; - if xoffset > max_x_offset { - xoffset = max_x_offset; - } - let left: i32 = ::cap(x, sub_width - 3); - let mut sum: i32 = 0; - { - let mut z: i32 = -2; - while z <= 2 { - { - let black_row: Vec = black_points[top + z]; - sum += black_row[left - 2] - + black_row[left - 1] - + black_row[left] - + black_row[left + 1] - + black_row[left + 2]; - } - z += 1; - } - } - - let average: i32 = sum / 25; - ::threshold_block( - &luminances, - xoffset, - yoffset, - average, - width, - matrix, - ); - } - x += 1; - } - } - } - y += 1; - } - } - } - - fn cap(value: i32, max: i32) -> i32 { - return if value < 2 { 2 } else { Math::min(value, max) }; - } - - /** - * Applies a single threshold to a block of pixels. - */ - fn threshold_block( - luminances: &Vec, - xoffset: i32, - yoffset: i32, - threshold: i32, - stride: i32, - matrix: &BitMatrix, - ) { - { - let mut y: i32 = 0; - let mut offset: i32 = yoffset * stride + xoffset; - while y < BLOCK_SIZE { - { - { - let mut x: i32 = 0; - while x < BLOCK_SIZE { - { - // Comparison needs to be <= so that black == 0 pixels are black even if the threshold is 0. - if (luminances[offset + x] & 0xFF) <= threshold { - matrix.set(xoffset + x, yoffset + y); - } - } - x += 1; - } - } - } - y += 1; - offset += stride; - } - } - } - - /** - * Calculates a single black point for each block of pixels and saves it away. - * See the following thread for a discussion of this algorithm: - * http://groups.google.com/group/zxing/browse_thread/thread/d06efa2c35a7ddc0 - */ - fn calculate_black_points( - luminances: &Vec, - sub_width: i32, - sub_height: i32, - width: i32, - height: i32, - ) -> Vec> { - let max_y_offset: i32 = height - BLOCK_SIZE; - let max_x_offset: i32 = width - BLOCK_SIZE; - let black_points: [[i32; sub_width]; sub_height] = [[0; sub_width]; sub_height]; - { - let mut y: i32 = 0; - while y < sub_height { - { - let mut yoffset: i32 = y << BLOCK_SIZE_POWER; - if yoffset > max_y_offset { - yoffset = max_y_offset; - } - { - let mut x: i32 = 0; - while x < sub_width { - { - let mut xoffset: i32 = x << BLOCK_SIZE_POWER; - if xoffset > max_x_offset { - xoffset = max_x_offset; - } - let mut sum: i32 = 0; - let mut min: i32 = 0xFF; - let mut max: i32 = 0; - { - let mut yy: i32 = 0; - let mut offset: i32 = yoffset * width + xoffset; - while yy < BLOCK_SIZE { - { - { - let mut xx: i32 = 0; - while xx < BLOCK_SIZE { - { - let pixel: i32 = - luminances[offset + xx] & 0xFF; - sum += pixel; - // still looking for good contrast - if pixel < min { - min = pixel; - } - if pixel > max { - max = pixel; - } - } - xx += 1; - } - } - - // short-circuit min/max tests once dynamic range is met - if max - min > MIN_DYNAMIC_RANGE { - // finish the rest of the rows quickly - { - yy += 1; - offset += width; - while yy < BLOCK_SIZE { - { - { - let mut xx: i32 = 0; - while xx < BLOCK_SIZE { - { - sum += luminances - [offset + xx] - & 0xFF; - } - xx += 1; - } - } - } - yy += 1; - offset += width; - } - } - } - } - yy += 1; - offset += width; - } - } - - // The default estimate is the average of the values in the block. - let mut average: i32 = sum >> (BLOCK_SIZE_POWER * 2); - if max - min <= MIN_DYNAMIC_RANGE { - // If variation within the block is low, assume this is a block with only light or only - // dark pixels. In that case we do not want to use the average, as it would divide this - // low contrast area into black and white pixels, essentially creating data out of noise. - // - // The default assumption is that the block is light/background. Since no estimate for - // the level of dark pixels exists locally, use half the min for the block. - average = min / 2; - if y > 0 && x > 0 { - // Correct the "white background" assumption for blocks that have neighbors by comparing - // the pixels in this block to the previously calculated black points. This is based on - // the fact that dark barcode symbology is always surrounded by some amount of light - // background for which reasonable black point estimates were made. The bp estimated at - // the boundaries is used for the interior. - // The (min < bp) is arbitrary but works better than other heuristics that were tried. - let average_neighbor_black_point: i32 = (black_points - [y - 1][x] - + (2 * black_points[y][x - 1]) - + black_points[y - 1][x - 1]) - / 4; - if min < average_neighbor_black_point { - average = average_neighbor_black_point; - } - } - } - black_points[y][x] = average; - } - x += 1; - } - } - } - y += 1; - } - } - - return black_points; - } -} - -// MinimalECIInput.java -/** - * Class that converts a character string into a sequence of ECIs and bytes - * - * The implementation uses the Dijkstra algorithm to produce minimal encodings - * - * @author Alex Geller - */ - -// approximated (latch + 2 codewords) -const COST_PER_ECI: i32 = 3; -pub struct MinimalECIInput { - bytes: Vec, - - fnc1: i32, -} - -impl ECIInput for MinimalECIInput { - fn have_n_characters(&self, index: i32, n: i32) -> bool { - if index + n - 1 >= self.bytes.len() { - return false; - } - { - let mut i: i32 = 0; - while i < n { - { - if self.is_e_c_i(index + i) { - return false; - } - } - i += 1; - } - } - - return true; - } - - /** - * Returns the {@code int} ECI value at the specified index. An index ranges from zero - * to {@code length() - 1}. The first {@code byte} value of the sequence is at - * index zero, the next at index one, and so on, as for array - * indexing. - * - * @param index the index of the {@code int} value to be returned - * - * @return the specified {@code int} ECI value. - * The ECI specified the encoding of all bytes with a higher index until the - * next ECI or until the end of the input if no other ECI follows. - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - * @throws IllegalArgumentException - * if the value at the {@code index} argument is not an ECI (@see #isECI) - */ - fn get_e_c_i_value( - &self, - index: i32, - ) -> Result { - if index < 0 || index >= self.length() { - return Err(IndexOutOfBoundsException::new(format!("{}", index))); - } - if !self.is_e_c_i(index) { - return Err(IllegalArgumentException::new(format!( - "value at {} is not an ECI but a character", - index - ))); - } - return self.bytes[index] - 256; - } - - /** - * Determines if a value is an ECI - * - * @param index the index of the value - * - * @return true if the value at position {@code index} is an ECI - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - */ - fn is_e_c_i(&self, index: i32) -> Result { - if index < 0 || index >= self.length() { - return Err(IndexOutOfBoundsException::new(format!("{}", index))); - } - return Ok(self.bytes[index] > 255 && self.bytes[index] <= 999); - } - - /** - * Returns a {@code CharSequence} that is a subsequence of this sequence. - * The subsequence starts with the {@code char} value at the specified index and - * ends with the {@code char} value at index {@code end - 1}. The length - * (in {@code char}s) of the - * returned sequence is {@code end - start}, so if {@code start == end} - * then an empty sequence is returned. - * - * @param start the start index, inclusive - * @param end the end index, exclusive - * - * @return the specified subsequence - * - * @throws IndexOutOfBoundsException - * if {@code start} or {@code end} are negative, - * if {@code end} is greater than {@code length()}, - * or if {@code start} is greater than {@code end} - * @throws IllegalArgumentException - * if a value in the range {@code start}-{@code end} is an ECI (@see #isECI) - */ - fn sub_sequence( - &self, - start: i32, - end: i32, - ) -> Result { - if start < 0 || start > end || end > self.length() { - return Err(IndexOutOfBoundsException::new(format!("{}", start))); - } - let result: StringBuilder = StringBuilder::new(); - { - let mut i: i32 = start; - while i < end { - { - if self.is_e_c_i(i) { - return Err(IllegalArgumentException::new(format!( - "value at {} is not a character but an ECI", - i - ))); - } - result.append(&self.char_at(i)); - } - i += 1; - } - } - - return result; - } - - /** - * Returns the {@code byte} value at the specified index. An index ranges from zero - * to {@code length() - 1}. The first {@code byte} value of the sequence is at - * index zero, the next at index one, and so on, as for array - * indexing. - * - * @param index the index of the {@code byte} value to be returned - * - * @return the specified {@code byte} value as character or the FNC1 character - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - * @throws IllegalArgumentException - * if the value at the {@code index} argument is an ECI (@see #isECI) - */ - fn char_at( - &self, - index: i32, - ) -> Result { - if index < 0 || index >= self.length() { - return Err(IndexOutOfBoundsException::new(format!("{}", index))); - } - if self.is_e_c_i(index) { - return Err(IllegalArgumentException::new(format!( - "value at {} is not a character but an ECI", - index - ))); - } - return if self.is_f_n_c1(index) { - Ok(self.fnc1 as char) - } else { - Ok(self.bytes[index] as char) - }; - } - - /** - * Returns the length of this input. The length is the number - * of {@code byte}s, FNC1 characters or ECIs in the sequence. - * - * @return the number of {@code char}s in this sequence - */ - fn length(&self) -> i32 { - return self.bytes.len(); - } -} - -impl MinimalECIInput { - /** - * Constructs a minimal input - * - * @param stringToEncode the character string to encode - * @param priorityCharset The preferred {@link Charset}. When the value of the argument is null, the algorithm - * chooses charsets that leads to a minimal representation. Otherwise the algorithm will use the priority - * charset to encode any character in the input that can be encoded by it if the charset is among the - * supported charsets. - * @param fnc1 denotes the character in the input that represents the FNC1 character or -1 if this is not GS1 - * input. - */ - pub fn new(string_to_encode: &String, priority_charset: &Charset, fnc1: i32) -> Self { - let mut new_mecii: Self; - new_mecii.fnc1 = fnc1; - let encoder_set: ECIEncoderSet = - ECIEncoderSet::new(&string_to_encode, &priority_charset, fnc1); - if encoder_set.length() == 1 { - //optimization for the case when all can be encoded without ECI in ISO-8859-1 - bytes = [0; string_to_encode.length()]; - { - let mut i: i32 = 0; - while i < bytes.len() { - { - let c: char = string_to_encode.char_at(i); - bytes[i] = if c == fnc1 { 1000 } else { c as i32 }; - } - i += 1; - } - } - } else { - bytes = ::encode_minimally(&string_to_encode, encoder_set, fnc1); - } - } - - pub fn get_f_n_c1_character(&self) -> i32 { - return self.fnc1; - } - - /** - * Determines if a value is the FNC1 character - * - * @param index the index of the value - * - * @return true if the value at position {@code index} is the FNC1 character - * - * @throws IndexOutOfBoundsException - * if the {@code index} argument is negative or not less than - * {@code length()} - */ - pub fn is_f_n_c1(&self, index: i32) -> Result { - if index < 0 || index >= self.length() { - return Err(IndexOutOfBoundsException::new(format!("{}", index))); - } - return Ok(self.bytes[index] == 1000); - } - - pub fn to_string(&self) -> String { - let result: StringBuilder = StringBuilder::new(); - { - let mut i: i32 = 0; - while i < self.length() { - { - if i > 0 { - result.append(", "); - } - if self.is_e_c_i(i) { - result.append("ECI("); - result.append(&self.get_e_c_i_value(i)); - result.append(')'); - } else if self.char_at(i) < 128 { - result.append('\''); - result.append(&self.char_at(i)); - result.append('\''); - } else { - result.append(self.char_at(i) as i32); - } - } - i += 1; - } - } - - return result.to_string(); - } - - fn add_edge(edges: &Vec>, to: i32, edge: &InputEdge) { - if edges[to][edge.encoderIndex] == null - || edges[to][edge.encoderIndex].cachedTotalSize > edge.cachedTotalSize - { - edges[to][edge.encoderIndex] = edge; - } - } - - fn add_edges( - string_to_encode: &String, - encoder_set: &ECIEncoderSet, - edges: &Vec>, - from: i32, - previous: &InputEdge, - fnc1: i32, - ) { - let ch: char = string_to_encode.char_at(from); - let mut start: i32 = 0; - let mut end: i32 = encoder_set.length(); - if encoder_set.get_priority_encoder_index() >= 0 - && (ch == fnc1 || encoder_set.can_encode(ch, &encoder_set.get_priority_encoder_index())) - { - start = encoder_set.get_priority_encoder_index(); - end = start + 1; - } - { - let mut i: i32 = start; - while i < end { - { - if ch == fnc1 || encoder_set.can_encode(ch, i) { - ::add_edge( - edges, - from + 1, - InputEdge::new(ch, encoder_set, i, previous, fnc1), - ); - } - } - i += 1; - } - } - } - - fn encode_minimally( - string_to_encode: &String, - encoder_set: &ECIEncoderSet, - fnc1: i32, - ) -> Result, RuntimeException> { - let input_length: i32 = string_to_encode.length(); - // Array that represents vertices. There is a vertex for every character and encoding. - let mut edges: [[Option; encoder_set.length()]; input_length + 1] = - [[None; encoder_set.length()]; input_length + 1]; - ::add_edges(&string_to_encode, encoder_set, edges, 0, null, fnc1); - { - let mut i: i32 = 1; - while i <= input_length { - { - { - let mut j: i32 = 0; - while j < encoder_set.length() { - { - if edges[i][j] != null && i < input_length { - ::add_edges( - &string_to_encode, - encoder_set, - edges, - i, - edges[i][j], - fnc1, - ); - } - } - j += 1; - } - } - - //optimize memory by removing edges that have been passed. - { - let mut j: i32 = 0; - while j < encoder_set.length() { - { - edges[i - 1][j] = null; - } - j += 1; - } - } - } - i += 1; - } - } - - let minimal_j: i32 = -1; - let minimal_size: i32 = Integer::MAX_VALUE; - { - let mut j: i32 = 0; - while j < encoder_set.length() { - { - if edges[input_length][j] != null { - let edge: InputEdge = edges[input_length][j]; - if edge.cachedTotalSize < minimal_size { - minimal_size = edge.cachedTotalSize; - minimal_j = j; - } - } - } - j += 1; - } - } - - if minimal_j < 0 { - return Err(RuntimeException::new(format!( - "Internal error: failed to encode \"{}\"", - string_to_encode - ))); - } - let ints_a_l: List = Vec::new(); - let mut current: InputEdge = edges[input_length][minimal_j]; - while current != null { - if current.is_f_n_c1() { - ints_a_l.add(0, 1000); - } else { - let bytes: Vec = encoder_set.encode(current.c, current.encoderIndex); - { - let mut i: i32 = bytes.len() - 1; - while i >= 0 { - { - ints_a_l.add(0, (bytes[i] & 0xFF)); - } - i -= 1; - } - } - } - let previous_encoder_index: i32 = if current.previous == null { - 0 - } else { - current.previous.encoderIndex - }; - if previous_encoder_index != current.encoderIndex { - ints_a_l.add(0, 256 + encoder_set.get_e_c_i_value(current.encoderIndex)); - } - current = current.previous; - } - let mut ints: [i32; ints_a_l.size()] = [0; ints_a_l.size()]; - { - let mut i: i32 = 0; - while i < ints.len() { - { - ints[i] = ints_a_l.get(i); - } - i += 1; - } - } - - return ints; - } -} - -struct InputEdge { - c: char, - - //the encoding of this edge - encoder_index: i32, - - previous: InputEdge, - - cached_total_size: i32, -} - -impl InputEdge { - fn new( - c: char, - encoder_set: &ECIEncoderSet, - encoder_index: i32, - previous: &InputEdge, - fnc1: i32, - ) -> Self { - let mut new_ie: Self; - new_ie.c = if c == fnc1 { 1000 } else { c }; - new_ie.encoderIndex = encoder_index; - new_ie.previous = previous; - let mut size: i32 = if new_ie.c == 1000 { - 1 - } else { - encoder_set.encode(c, encoder_index).len() - }; - let previous_encoder_index: i32 = if previous == null { - 0 - } else { - previous.encoderIndex - }; - if previous_encoder_index != encoder_index { - size += COST_PER_ECI; - } - if previous != null { - size += previous.cachedTotalSize; - } - new_ie.cachedTotalSize = size; - - new_ie - } - - fn is_f_n_c1(&self) -> bool { - return self.c == 1000; - } -} - -// PerspectiveTransform.java -/** - *

This class implements a perspective transform in two dimensions. Given four source and four - * destination points, it will compute the transformation implied between them. The code is based - * directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.

- * - * @author Sean Owen - */ -pub struct PerspectiveTransform { - a11: f32, - - a12: f32, - - a13: f32, - - a21: f32, - - a22: f32, - - a23: f32, - - a31: f32, - - a32: f32, - - a33: f32, -} - -impl PerspectiveTransform { - fn new( - a11: f32, - a21: f32, - a31: f32, - a12: f32, - a22: f32, - a32: f32, - a13: f32, - a23: f32, - a33: f32, - ) -> Self { - Self { - a11: a11, - a12: a12, - a13: a13, - a21: a21, - a22: a22, - a23: a23, - a31: a31, - a32: a32, - a33: a33, - } - } - - pub fn quadrilateral_to_quadrilateral( - x0: f32, - y0: f32, - x1: f32, - y1: f32, - x2: f32, - y2: f32, - x3: f32, - y3: f32, - x0p: f32, - y0p: f32, - x1p: f32, - y1p: f32, - x2p: f32, - y2p: f32, - x3p: f32, - y3p: f32, - ) -> PerspectiveTransform { - let q_to_s: PerspectiveTransform = - ::quadrilateral_to_square(x0, y0, x1, y1, x2, y2, x3, y3); - let s_to_q: PerspectiveTransform = - ::square_to_quadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p); - return s_to_q.times(&q_to_s); - } - - pub fn transform_points(&self, points: &Vec) { - let a11: f32 = self.a11; - let a12: f32 = self.a12; - let a13: f32 = self.a13; - let a21: f32 = self.a21; - let a22: f32 = self.a22; - let a23: f32 = self.a23; - let a31: f32 = self.a31; - let a32: f32 = self.a32; - let a33: f32 = self.a33; - // points.length must be even - let max_i: i32 = points.len() - 1; - { - let mut i: i32 = 0; - while i < max_i { - { - let x: f32 = points[i]; - let y: f32 = points[i + 1]; - let denominator: f32 = a13 * x + a23 * y + a33; - points[i] = (a11 * x + a21 * y + a31) / denominator; - points[i + 1] = (a12 * x + a22 * y + a32) / denominator; - } - i += 2; - } - } - } - - pub fn transform_points(&self, x_values: &Vec, y_values: &Vec) { - let n: i32 = x_values.len(); - { - let mut i: i32 = 0; - while i < n { - { - let x: f32 = x_values[i]; - let y: f32 = y_values[i]; - let denominator: f32 = self.a13 * x + self.a23 * y + self.a33; - x_values[i] = (self.a11 * x + self.a21 * y + self.a31) / denominator; - y_values[i] = (self.a12 * x + self.a22 * y + self.a32) / denominator; - } - i += 1; - } - } - } - - pub fn square_to_quadrilateral( - x0: f32, - y0: f32, - x1: f32, - y1: f32, - x2: f32, - y2: f32, - x3: f32, - y3: f32, - ) -> PerspectiveTransform { - let dx3: f32 = x0 - x1 + x2 - x3; - let dy3: f32 = y0 - y1 + y2 - y3; - if dx3 == 0.0f32 && dy3 == 0.0f32 { - // Affine - return PerspectiveTransform::new( - x1 - x0, - x2 - x1, - x0, - y1 - y0, - y2 - y1, - y0, - 0.0f32, - 0.0f32, - 1.0f32, - ); - } else { - let dx1: f32 = x1 - x2; - let dx2: f32 = x3 - x2; - let dy1: f32 = y1 - y2; - let dy2: f32 = y3 - y2; - let denominator: f32 = dx1 * dy2 - dx2 * dy1; - let a13: f32 = (dx3 * dy2 - dx2 * dy3) / denominator; - let a23: f32 = (dx1 * dy3 - dx3 * dy1) / denominator; - return PerspectiveTransform::new( - x1 - x0 + a13 * x1, - x3 - x0 + a23 * x3, - x0, - y1 - y0 + a13 * y1, - y3 - y0 + a23 * y3, - y0, - a13, - a23, - 1.0f32, - ); - } - } - - pub fn quadrilateral_to_square( - x0: f32, - y0: f32, - x1: f32, - y1: f32, - x2: f32, - y2: f32, - x3: f32, - y3: f32, - ) -> PerspectiveTransform { - // Here, the adjoint serves as the inverse: - return ::square_to_quadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).build_adjoint(); - } - - fn build_adjoint(&self) -> PerspectiveTransform { - // Adjoint is the transpose of the cofactor matrix: - return PerspectiveTransform::new( - self.a22 * self.a33 - self.a23 * self.a32, - self.a23 * self.a31 - self.a21 * self.a33, - self.a21 * self.a32 - self.a22 * self.a31, - self.a13 * self.a32 - self.a12 * self.a33, - self.a11 * self.a33 - self.a13 * self.a31, - self.a12 * self.a31 - self.a11 * self.a32, - self.a12 * self.a23 - self.a13 * self.a22, - self.a13 * self.a21 - self.a11 * self.a23, - self.a11 * self.a22 - self.a12 * self.a21, - ); - } - - fn times(&self, other: &PerspectiveTransform) -> PerspectiveTransform { - return PerspectiveTransform::new( - self.a11 * other.a11 + self.a21 * other.a12 + self.a31 * other.a13, - self.a11 * other.a21 + self.a21 * other.a22 + self.a31 * other.a23, - self.a11 * other.a31 + self.a21 * other.a32 + self.a31 * other.a33, - self.a12 * other.a11 + self.a22 * other.a12 + self.a32 * other.a13, - self.a12 * other.a21 + self.a22 * other.a22 + self.a32 * other.a23, - self.a12 * other.a31 + self.a22 * other.a32 + self.a32 * other.a33, - self.a13 * other.a11 + self.a23 * other.a12 + self.a33 * other.a13, - self.a13 * other.a21 + self.a23 * other.a22 + self.a33 * other.a23, - self.a13 * other.a31 + self.a23 * other.a32 + self.a33 * other.a33, - ); - } -} - -// StringUtils.java -/** - * Common string-related functions. - * - * @author Sean Owen - * @author Alex Dupre - */ - -const PLATFORM_DEFAULT_ENCODING: Charset = Charset::default_charset(); - -const SHIFT_JIS_CHARSET: Charset = Charset::for_name("SJIS"); - -const GB2312_CHARSET: Charset = Charset::for_name("GB2312"); - -const EUC_JP: Charset = Charset::for_name("EUC_JP"); - -const ASSUME_SHIFT_JIS: bool = SHIFT_JIS_CHARSET::equals(&PLATFORM_DEFAULT_ENCODING) - || EUC_JP::equals(&PLATFORM_DEFAULT_ENCODING); - -// Retained for ABI compatibility with earlier versions -const SHIFT_JIS: &'static str = "SJIS"; - -const GB2312: &'static str = "GB2312"; -pub struct StringUtils {} - -impl StringUtils { - fn new() -> StringUtils {} - - /** - * @param bytes bytes encoding a string, whose encoding should be guessed - * @param hints decode hints if applicable - * @return name of guessed encoding; at the moment will only guess one of: - * "SJIS", "UTF8", "ISO8859_1", or the platform default encoding if none - * of these can possibly be correct - */ - pub fn guess_encoding(bytes: &Vec, hints: &HashMap) -> &str { - let c: Charset = ::guess_charset(&bytes, &hints); - if c == SHIFT_JIS_CHARSET { - return "SJIS"; - } else if c == StandardCharsets::UTF_8 { - return "UTF8"; - } else if c == StandardCharsets::ISO_8859_1 { - return "ISO8859_1"; - } - return c.name(); - } - - /** - * @param bytes bytes encoding a string, whose encoding should be guessed - * @param hints decode hints if applicable - * @return Charset of guessed encoding; at the moment will only guess one of: - * {@link #SHIFT_JIS_CHARSET}, {@link StandardCharsets#UTF_8}, - * {@link StandardCharsets#ISO_8859_1}, {@link StandardCharsets#UTF_16}, - * or the platform default encoding if - * none of these can possibly be correct - */ - pub fn guess_charset(bytes: &Vec, hints: &HashMap) -> Charset { - if hints != null && hints.contains_key(DecodeHintType::CHARACTER_SET) { - return Charset::for_name(&hints.get(DecodeHintType::CHARACTER_SET).to_string()); - } - // First try UTF-16, assuming anything with its BOM is UTF-16 - if bytes.len() > 2 - && ((bytes[0] == 0xFE as i8 && bytes[1] == 0xFF as i8) - || (bytes[0] == 0xFF as i8 && bytes[1] == 0xFE as i8)) - { - return StandardCharsets::UTF_16; - } - // For now, merely tries to distinguish ISO-8859-1, UTF-8 and Shift_JIS, - // which should be by far the most common encodings. - let length: i32 = bytes.len(); - let can_be_i_s_o88591: bool = true; - let can_be_shift_j_i_s: bool = true; - let can_be_u_t_f8: bool = true; - let utf8_bytes_left: i32 = 0; - let utf2_bytes_chars: i32 = 0; - let utf3_bytes_chars: i32 = 0; - let utf4_bytes_chars: i32 = 0; - let sjis_bytes_left: i32 = 0; - let sjis_katakana_chars: i32 = 0; - let sjis_cur_katakana_word_length: i32 = 0; - let sjis_cur_double_bytes_word_length: i32 = 0; - let sjis_max_katakana_word_length: i32 = 0; - let sjis_max_double_bytes_word_length: i32 = 0; - let iso_high_other: i32 = 0; - let utf8bom: bool = bytes.len() > 3 - && bytes[0] == 0xEF as i8 - && bytes[1] == 0xBB as i8 - && bytes[2] == 0xBF as i8; - { - let mut i: i32 = 0; - while i < length && (can_be_i_s_o88591 || can_be_shift_j_i_s || can_be_u_t_f8) { - { - let value: i32 = bytes[i] & 0xFF; - // UTF-8 stuff - if can_be_u_t_f8 { - if utf8_bytes_left > 0 { - if (value & 0x80) == 0 { - can_be_u_t_f8 = false; - } else { - utf8_bytes_left -= 1; - } - } else if (value & 0x80) != 0 { - if (value & 0x40) == 0 { - can_be_u_t_f8 = false; - } else { - utf8_bytes_left += 1; - if (value & 0x20) == 0 { - utf2_bytes_chars += 1; - } else { - utf8_bytes_left += 1; - if (value & 0x10) == 0 { - utf3_bytes_chars += 1; - } else { - utf8_bytes_left += 1; - if (value & 0x08) == 0 { - utf4_bytes_chars += 1; - } else { - can_be_u_t_f8 = false; - } - } - } - } - } - } - // ISO-8859-1 stuff - if can_be_i_s_o88591 { - if value > 0x7F && value < 0xA0 { - can_be_i_s_o88591 = false; - } else if value > 0x9F && (value < 0xC0 || value == 0xD7 || value == 0xF7) { - iso_high_other += 1; - } - } - // Shift_JIS stuff - if can_be_shift_j_i_s { - if sjis_bytes_left > 0 { - if value < 0x40 || value == 0x7F || value > 0xFC { - can_be_shift_j_i_s = false; - } else { - sjis_bytes_left -= 1; - } - } else if value == 0x80 || value == 0xA0 || value > 0xEF { - can_be_shift_j_i_s = false; - } else if value > 0xA0 && value < 0xE0 { - sjis_katakana_chars += 1; - sjis_cur_double_bytes_word_length = 0; - sjis_cur_katakana_word_length += 1; - if sjis_cur_katakana_word_length > sjis_max_katakana_word_length { - sjis_max_katakana_word_length = sjis_cur_katakana_word_length; - } - } else if value > 0x7F { - sjis_bytes_left += 1; - //sjisDoubleBytesChars++; - sjis_cur_katakana_word_length = 0; - sjis_cur_double_bytes_word_length += 1; - if sjis_cur_double_bytes_word_length > sjis_max_double_bytes_word_length - { - sjis_max_double_bytes_word_length = - sjis_cur_double_bytes_word_length; - } - } else { - //sjisLowChars++; - sjis_cur_katakana_word_length = 0; - sjis_cur_double_bytes_word_length = 0; - } - } - } - i += 1; - } - } - - if can_be_u_t_f8 && utf8_bytes_left > 0 { - can_be_u_t_f8 = false; - } - if can_be_shift_j_i_s && sjis_bytes_left > 0 { - can_be_shift_j_i_s = false; - } - // Easy -- if there is BOM or at least 1 valid not-single byte character (and no evidence it can't be UTF-8), done - if can_be_u_t_f8 && (utf8bom || utf2_bytes_chars + utf3_bytes_chars + utf4_bytes_chars > 0) - { - return StandardCharsets::UTF_8; - } - // Easy -- if assuming Shift_JIS or >= 3 valid consecutive not-ascii characters (and no evidence it can't be), done - if can_be_shift_j_i_s - && (ASSUME_SHIFT_JIS - || sjis_max_katakana_word_length >= 3 - || sjis_max_double_bytes_word_length >= 3) - { - return SHIFT_JIS_CHARSET; - } - // - then we conclude Shift_JIS, else ISO-8859-1 - if can_be_i_s_o88591 && can_be_shift_j_i_s { - return if (sjis_max_katakana_word_length == 2 && sjis_katakana_chars == 2) - || iso_high_other * 10 >= length - { - SHIFT_JIS_CHARSET - } else { - StandardCharsets::ISO_8859_1 - }; - } - // Otherwise, try in order ISO-8859-1, Shift JIS, UTF-8 and fall back to default platform encoding - if can_be_i_s_o88591 { - return StandardCharsets::ISO_8859_1; - } - if can_be_shift_j_i_s { - return SHIFT_JIS_CHARSET; - } - if can_be_u_t_f8 { - return StandardCharsets::UTF_8; - } - // Otherwise, we take a wild guess with platform encoding - return PLATFORM_DEFAULT_ENCODING; - } -} diff --git a/src/common/detector.rs b/src/common/detector.rs deleted file mode 100644 index d253f9b..0000000 --- a/src/common/detector.rs +++ /dev/null @@ -1,708 +0,0 @@ -use crate::common::{BitMatrix, BitMatrix}; -use crate::{NotFoundException, ResultPoint}; - -// MathUtils.java -/** - * General math-related and numeric utility functions. - */ -pub struct MathUtils {} - -impl MathUtils { - fn new() -> Self { - Self {} - } - - /** - * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its - * argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut - * differ slightly from {@link Math#round(float)} in that half rounds down for negative - * values. -2.5 rounds to -3, not -2. For purposes here it makes no difference. - * - * @param d real value to round - * @return nearest {@code int} - */ - pub fn round(d: f32) -> i32 { - return (d + (if d < 0.0f32 { -0.5f32 } else { 0.5f32 })) as i32; - } - - /** - * @param aX point A x coordinate - * @param aY point A y coordinate - * @param bX point B x coordinate - * @param bY point B y coordinate - * @return Euclidean distance between points A and B - */ - pub fn distance(a_x: f32, a_y: f32, b_x: f32, b_y: f32) -> f32 { - let x_diff: f64 = a_x - b_x; - let y_diff: f64 = a_y - b_y; - return Math::sqrt(x_diff * x_diff + y_diff * y_diff) as f32; - } - - /** - * @param aX point A x coordinate - * @param aY point A y coordinate - * @param bX point B x coordinate - * @param bY point B y coordinate - * @return Euclidean distance between points A and B - */ - pub fn distance(a_x: i32, a_y: i32, b_x: i32, b_y: i32) -> f32 { - let x_diff: f64 = a_x - b_x; - let y_diff: f64 = a_y - b_y; - return Math::sqrt(x_diff * x_diff + y_diff * y_diff) as f32; - } - - /** - * @param array values to sum - * @return sum of values in array - */ - pub fn sum(array: &Vec) -> i32 { - let mut count: i32 = 0; - for a in array { - count += a; - } - return count; - } -} - -// MonochromeRectangleDetector.java -/** - *

A somewhat generic detector that looks for a barcode-like rectangular region within an image. - * It looks within a mostly white region of an image for a region of black and white, but mostly - * black. It returns the four corners of the region, as best it can determine.

- * - * @author Sean Owen - * @deprecated without replacement since 3.3.0 - */ - -const MAX_MODULES: i32 = 32; -#[deprecated] -pub struct MonochromeRectangleDetector { - image: BitMatrix, -} - -impl MonochromeRectangleDetector { - pub fn new(image: &BitMatrix) -> Self { - Self { image } - } - - /** - *

Detects a rectangular region of black and white -- mostly black -- with a region of mostly - * white, in an image.

- * - * @return {@link ResultPoint}[] describing the corners of the rectangular region. The first and - * last points are opposed on the diagonal, as are the second and third. The first point will be - * the topmost point and the last, the bottommost. The second point will be leftmost and the - * third, the rightmost - * @throws NotFoundException if no Data Matrix Code can be found - */ - pub fn detect(&self) -> Result, Rc> { - let height: i32 = self.image.get_height(); - let width: i32 = self.image.get_width(); - let half_height: i32 = height / 2; - let half_width: i32 = width / 2; - let delta_y: i32 = Math::max(1, height / (MAX_MODULES * 8)); - let delta_x: i32 = Math::max(1, width / (MAX_MODULES * 8)); - let mut top: i32 = 0; - let mut bottom: i32 = height; - let mut left: i32 = 0; - let mut right: i32 = width; - let point_a: ResultPoint = self.find_corner_from_center( - half_width, - 0, - left, - right, - half_height, - -delta_y, - top, - bottom, - half_width / 2, - ); - top = point_a.get_y() as i32 - 1; - let point_b: ResultPoint = self.find_corner_from_center( - half_width, - -delta_x, - left, - right, - half_height, - 0, - top, - bottom, - half_height / 2, - ); - left = point_b.get_x() as i32 - 1; - let point_c: ResultPoint = self.find_corner_from_center( - half_width, - delta_x, - left, - right, - half_height, - 0, - top, - bottom, - half_height / 2, - ); - right = point_c.get_x() as i32 + 1; - let point_d: ResultPoint = self.find_corner_from_center( - half_width, - 0, - left, - right, - half_height, - delta_y, - top, - bottom, - half_width / 2, - ); - bottom = point_d.get_y() as i32 + 1; - // Go try to find point A again with better information -- might have been off at first. - point_a = self.find_corner_from_center( - half_width, - 0, - left, - right, - half_height, - -delta_y, - top, - bottom, - half_width / 4, - ); - return Ok(vec![point_a, point_b, point_c, point_d]); - } - - /** - * Attempts to locate a corner of the barcode by scanning up, down, left or right from a center - * point which should be within the barcode. - * - * @param centerX center's x component (horizontal) - * @param deltaX same as deltaY but change in x per step instead - * @param left minimum value of x - * @param right maximum value of x - * @param centerY center's y component (vertical) - * @param deltaY change in y per step. If scanning up this is negative; down, positive; - * left or right, 0 - * @param top minimum value of y to search through (meaningless when di == 0) - * @param bottom maximum value of y - * @param maxWhiteRun maximum run of white pixels that can still be considered to be within - * the barcode - * @return a {@link ResultPoint} encapsulating the corner that was found - * @throws NotFoundException if such a point cannot be found - */ - fn find_corner_from_center( - &self, - center_x: i32, - delta_x: i32, - left: i32, - right: i32, - center_y: i32, - delta_y: i32, - top: i32, - bottom: i32, - max_white_run: i32, - ) -> Result { - let last_range: Vec = null; - { - let mut y: i32 = center_y; - let mut x: i32 = center_x; - while y < bottom && y >= top && x < right && x >= left { - { - let mut range: Vec; - if delta_x == 0 { - // horizontal slices, up and down - range = self.black_white_range(y, max_white_run, left, right, true); - } else { - // vertical slices, left and right - range = self.black_white_range(x, max_white_run, top, bottom, false); - } - if range == null { - if last_range == null { - return Err(NotFoundException::get_not_found_instance()); - } - // lastRange was found - if delta_x == 0 { - let last_y: i32 = y - delta_y; - if last_range[0] < center_x { - if last_range[1] > center_x { - // straddle, choose one or the other based on direction - return Ok(ResultPoint::new( - last_range[if delta_y > 0 { 0 } else { 1 }], - last_y, - )); - } - return Ok(ResultPoint::new(last_range[0], last_y)); - } else { - return Ok(ResultPoint::new(last_range[1], last_y)); - } - } else { - let last_x: i32 = x - delta_x; - if last_range[0] < center_y { - if last_range[1] > center_y { - return Ok(ResultPoint::new( - last_x, - last_range[if delta_x < 0 { 0 } else { 1 }], - )); - } - return Ok(ResultPoint::new(last_x, last_range[0])); - } else { - return Ok(ResultPoint::new(last_x, last_range[1])); - } - } - } - last_range = range; - } - y += delta_y; - x += delta_x; - } - } - - return Err(NotFoundException::get_not_found_instance()); - } - - /** - * Computes the start and end of a region of pixels, either horizontally or vertically, that could - * be part of a Data Matrix barcode. - * - * @param fixedDimension if scanning horizontally, this is the row (the fixed vertical location) - * where we are scanning. If scanning vertically it's the column, the fixed horizontal location - * @param maxWhiteRun largest run of white pixels that can still be considered part of the - * barcode region - * @param minDim minimum pixel location, horizontally or vertically, to consider - * @param maxDim maximum pixel location, horizontally or vertically, to consider - * @param horizontal if true, we're scanning left-right, instead of up-down - * @return int[] with start and end of found range, or null if no such range is found - * (e.g. only white was found) - */ - fn black_white_range( - &self, - fixed_dimension: i32, - max_white_run: i32, - min_dim: i32, - max_dim: i32, - horizontal: bool, - ) -> Option> { - let center: i32 = (min_dim + max_dim) / 2; - // Scan left/up first - let mut start: i32 = center; - while start >= min_dim { - if if horizontal { - self.image.get(start, fixed_dimension) - } else { - self.image.get(fixed_dimension, start) - } { - start -= 1; - } else { - let white_run_start: i32 = start; - loop { - { - start -= 1; - } - if !(start >= min_dim - && !(if horizontal { - self.image.get(start, fixed_dimension) - } else { - self.image.get(fixed_dimension, start) - })) - { - break; - } - } - let white_run_size: i32 = white_run_start - start; - if start < min_dim || white_run_size > max_white_run { - start = white_run_start; - break; - } - } - } - start += 1; - // Then try right/down - let mut end: i32 = center; - while end < max_dim { - if if horizontal { - self.image.get(end, fixed_dimension) - } else { - self.image.get(fixed_dimension, end) - } { - end += 1; - } else { - let white_run_start: i32 = end; - loop { - { - end += 1; - } - if !(end < max_dim - && !(if horizontal { - self.image.get(end, fixed_dimension) - } else { - self.image.get(fixed_dimension, end) - })) - { - break; - } - } - let white_run_size: i32 = end - white_run_start; - if end >= max_dim || white_run_size > max_white_run { - end = white_run_start; - break; - } - } - } - end -= 1; - return if end > start { - Some(vec![start, end]) - } else { - null - }; - } -} - -// WhiteRectangleDetector.java -/** - *

- * Detects a candidate barcode-like rectangular region within an image. It - * starts around the center of the image, increases the size of the candidate - * region until it finds a white rectangular region. By keeping track of the - * last black points it encountered, it determines the corners of the barcode. - *

- * - * @author David Olivier - */ - -const INIT_SIZE: i32 = 10; - -const CORR: i32 = 1; -pub struct WhiteRectangleDetector { - image: BitMatrix, - - height: i32, - - width: i32, - - left_init: i32, - - right_init: i32, - - down_init: i32, - - up_init: i32, -} - -impl WhiteRectangleDetector { - /** - * @param image barcode image to find a rectangle in - * @param initSize initial size of search area around center - * @param x x position of search center - * @param y y position of search center - * @throws NotFoundException if image is too small to accommodate {@code initSize} - */ - pub fn new( - image: &BitMatrix, - init_size: Option, - x_in: Option, - y_in: Option, - ) -> Result { - let mut new_wrd: Self; - let x = x_in.unwrap_or(image.get_width() / 2); - let y = y_in.unwrap_or(image.get_height() / 2); - - new_wrd.image = image; - new_wrd.height = image.get_height(); - new_wrd.width = image.get_width(); - let halfsize: i32 = init_size.unwrap_or(INIT_SIZE) / 2; - new_wrd.left_init = x - halfsize; - new_wrd.right_init = x + halfsize; - new_wrd.up_init = y - halfsize; - new_wrd.down_init = y + halfsize; - - if up_init < 0 || left_init < 0 || down_init >= height || right_init >= width { - return Err(NotFoundException::get_not_found_instance()); - } - - Ok(new_wrd) - } - - /** - *

- * Detects a candidate barcode-like rectangular region within an image. It - * starts around the center of the image, increases the size of the candidate - * region until it finds a white rectangular region. - *

- * - * @return {@link ResultPoint}[] describing the corners of the rectangular - * region. The first and last points are opposed on the diagonal, as - * are the second and third. The first point will be the topmost - * point and the last, the bottommost. The second point will be - * leftmost and the third, the rightmost - * @throws NotFoundException if no Data Matrix Code can be found - */ - pub fn detect(&self) -> Result, NotFoundException> { - let mut left: i32 = self.left_init; - let mut right: i32 = self.right_init; - let mut up: i32 = self.up_init; - let mut down: i32 = self.down_init; - let size_exceeded: bool = false; - let a_black_point_found_on_border: bool = true; - let at_least_one_black_point_found_on_right: bool = false; - let at_least_one_black_point_found_on_bottom: bool = false; - let at_least_one_black_point_found_on_left: bool = false; - let at_least_one_black_point_found_on_top: bool = false; - while a_black_point_found_on_border { - a_black_point_found_on_border = false; - // ..... - // . | - // ..... - let right_border_not_white: bool = true; - while (right_border_not_white || !at_least_one_black_point_found_on_right) - && right < self.width - { - right_border_not_white = self.contains_black_point(up, down, right, false); - if right_border_not_white { - right += 1; - a_black_point_found_on_border = true; - at_least_one_black_point_found_on_right = true; - } else if !at_least_one_black_point_found_on_right { - right += 1; - } - } - if right >= self.width { - size_exceeded = true; - break; - } - // ..... - // . . - // .___. - let bottom_border_not_white: bool = true; - while (bottom_border_not_white || !at_least_one_black_point_found_on_bottom) - && down < self.height - { - bottom_border_not_white = self.contains_black_point(left, right, down, true); - if bottom_border_not_white { - down += 1; - a_black_point_found_on_border = true; - at_least_one_black_point_found_on_bottom = true; - } else if !at_least_one_black_point_found_on_bottom { - down += 1; - } - } - if down >= self.height { - size_exceeded = true; - break; - } - // ..... - // | . - // ..... - let left_border_not_white: bool = true; - while (left_border_not_white || !at_least_one_black_point_found_on_left) && left >= 0 { - left_border_not_white = self.contains_black_point(up, down, left, false); - if left_border_not_white { - left -= 1; - a_black_point_found_on_border = true; - at_least_one_black_point_found_on_left = true; - } else if !at_least_one_black_point_found_on_left { - left -= 1; - } - } - if left < 0 { - size_exceeded = true; - break; - } - // .___. - // . . - // ..... - let top_border_not_white: bool = true; - while (top_border_not_white || !at_least_one_black_point_found_on_top) && up >= 0 { - top_border_not_white = self.contains_black_point(left, right, up, true); - if top_border_not_white { - up -= 1; - a_black_point_found_on_border = true; - at_least_one_black_point_found_on_top = true; - } else if !at_least_one_black_point_found_on_top { - up -= 1; - } - } - if up < 0 { - size_exceeded = true; - break; - } - } - if !size_exceeded { - let max_size: i32 = right - left; - let mut z: ResultPoint = null; - { - let mut i: i32 = 1; - while z == null && i < max_size { - { - z = self.get_black_point_on_segment(left, down - i, left + i, down); - } - i += 1; - } - } - - if z == null { - return Err(NotFoundException::get_not_found_instance()); - } - let mut t: ResultPoint = null; - //go down right - { - let mut i: i32 = 1; - while t == null && i < max_size { - { - t = self.get_black_point_on_segment(left, up + i, left + i, up); - } - i += 1; - } - } - - if t == null { - return Err(NotFoundException::get_not_found_instance()); - } - let mut x: ResultPoint = null; - //go down left - { - let mut i: i32 = 1; - while x == null && i < max_size { - { - x = self.get_black_point_on_segment(right, up + i, right - i, up); - } - i += 1; - } - } - - if x == null { - return Err(NotFoundException::get_not_found_instance()); - } - let mut y: ResultPoint = null; - //go up left - { - let mut i: i32 = 1; - while y == null && i < max_size { - { - y = self.get_black_point_on_segment(right, down - i, right - i, down); - } - i += 1; - } - } - - if y == null { - return Err(NotFoundException::get_not_found_instance()); - } - return Ok(self.center_edges(&y, &z, &x, &t)); - } else { - return Err(NotFoundException::get_not_found_instance()); - } - } - - fn get_black_point_on_segment( - &self, - a_x: f32, - a_y: f32, - b_x: f32, - b_y: f32, - ) -> Option { - let dist: i32 = MathUtils::round(&MathUtils::distance(a_x, a_y, b_x, b_y)); - let x_step: f32 = (b_x - a_x) / dist; - let y_step: f32 = (b_y - a_y) / dist; - { - let mut i: i32 = 0; - while i < dist { - { - let x: i32 = MathUtils::round(a_x + i * x_step); - let y: i32 = MathUtils::round(a_y + i * y_step); - if self.image.get(x, y) { - return Some(ResultPoint::new(x, y)); - } - } - i += 1; - } - } - - return null; - } - - /** - * recenters the points of a constant distance towards the center - * - * @param y bottom most point - * @param z left most point - * @param x right most point - * @param t top most point - * @return {@link ResultPoint}[] describing the corners of the rectangular - * region. The first and last points are opposed on the diagonal, as - * are the second and third. The first point will be the topmost - * point and the last, the bottommost. The second point will be - * leftmost and the third, the rightmost - */ - fn center_edges( - &self, - y: &ResultPoint, - z: &ResultPoint, - x: &ResultPoint, - t: &ResultPoint, - ) -> Vec { - // - // t t - // z x - // x OR z - // y y - // - let yi: f32 = y.get_x(); - let yj: f32 = y.get_y(); - let zi: f32 = z.get_x(); - let zj: f32 = z.get_y(); - let xi: f32 = x.get_x(); - let xj: f32 = x.get_y(); - let ti: f32 = t.get_x(); - let tj: f32 = t.get_y(); - if yi < self.width / 2.0f32 { - return vec![ - ResultPoint::new(ti - CORR, tj + CORR), - ResultPoint::new(zi + CORR, zj + CORR), - ResultPoint::new(xi - CORR, xj - CORR), - ResultPoint::new(yi + CORR, yj - CORR), - ]; - } else { - return vec![ - ResultPoint::new(ti + CORR, tj + CORR), - ResultPoint::new(zi + CORR, zj - CORR), - ResultPoint::new(xi - CORR, xj + CORR), - ResultPoint::new(yi - CORR, yj - CORR), - ]; - } - } - - /** - * Determines whether a segment contains a black point - * - * @param a min value of the scanned coordinate - * @param b max value of the scanned coordinate - * @param fixed value of fixed coordinate - * @param horizontal set to true if scan must be horizontal, false if vertical - * @return true if a black point has been found, else false. - */ - fn contains_black_point(&self, a: i32, b: i32, fixed: i32, horizontal: bool) -> bool { - if horizontal { - { - let mut x: i32 = a; - while x <= b { - { - if self.image.get(x, fixed) { - return true; - } - } - x += 1; - } - } - } else { - { - let mut y: i32 = a; - while y <= b { - { - if self.image.get(fixed, y) { - return true; - } - } - y += 1; - } - } - } - return false; - } -} diff --git a/src/common/readsolomon.rs b/src/common/readsolomon.rs deleted file mode 100644 index a3aeede..0000000 --- a/src/common/readsolomon.rs +++ /dev/null @@ -1,849 +0,0 @@ -// GenericGFPoly.java -/** - *

Represents a polynomial whose coefficients are elements of a GF. - * Instances of this class are immutable.

- * - *

Much credit is due to William Rucklidge since portions of this code are an indirect - * port of his C++ Reed-Solomon implementation.

- * - * @author Sean Owen - */ -struct GenericGFPoly { - field: GenericGF, - - coefficients: Vec, -} - -impl GenericGFPoly { - /** - * @param field the {@link GenericGF} instance representing the field to use - * to perform computations - * @param coefficients coefficients as ints representing elements of GF(size), arranged - * from most significant (highest-power term) coefficient to least significant - * @throws IllegalArgumentException if argument is null or empty, - * or if leading coefficient is 0 and this is not a - * constant polynomial (that is, it is not the monomial "0") - */ - fn new(field: &GenericGF, coefficients: &Vec) -> Result { - let mut new_poly: GenericGFPoly; - if coefficients.len() == 0 { - return Err(IllegalArgumentException::new()); - } - new_poly.field = field; - let coefficients_length: i32 = coefficients.len(); - if coefficients_length > 1 && coefficients[0] == 0 { - // Leading term must be non-zero for anything except the constant polynomial "0" - let first_non_zero: i32 = 1; - while first_non_zero < coefficients_length && coefficients[first_non_zero] == 0 { - first_non_zero += 1; - } - if first_non_zero == coefficients_length { - new_poly.coefficients = vec![0]; - } else { - new_poly.coefficients = coefficients; - //System::arraycopy(&coefficients, first_non_zero, let .coefficients, 0, let .coefficients.len()); - } - } else { - new_poly.coefficients = coefficients; - } - Ok(new_poly) - } - - fn get_coefficients(&self) -> Vec { - return self.coefficients; - } - - /** - * @return degree of this polynomial - */ - fn get_degree(&self) -> i32 { - return self.coefficients.len() - 1; - } - - /** - * @return true iff this polynomial is the monomial "0" - */ - fn is_zero(&self) -> bool { - return self.coefficients[0] == 0; - } - - /** - * @return coefficient of x^degree term in this polynomial - */ - fn get_coefficient(&self, degree: i32) -> i32 { - return self.coefficients[self.coefficients.len() - 1 - degree]; - } - - /** - * @return evaluation of this polynomial at a given point - */ - fn evaluate_at(&self, a: i32) -> i32 { - if a == 0 { - // Just return the x^0 coefficient - return self.get_coefficient(0); - } - if a == 1 { - // Just the sum of the coefficients - let mut result: i32 = 0; - for coefficient in self.coefficients { - result = GenericGF::add_or_subtract(result, coefficient); - } - return result; - } - let mut result: i32 = self.coefficients[0]; - let size: i32 = self.coefficients.len(); - { - let mut i: i32 = 1; - while i < size { - { - result = GenericGF::add_or_subtract( - &self.field.multiply(a, result), - self.coefficients[i], - ); - } - i += 1; - } - } - - return result; - } - - fn add_or_subtract( - &self, - other: &GenericGFPoly, - ) -> Result { - if !self.field.equals(other.field) { - return Err(IllegalArgumentException::new( - "GenericGFPolys do not have same GenericGF field", - )); - } - if self.is_zero() { - return other; - } - if other.is_zero() { - return self; - } - let smaller_coefficients: Vec = self.coefficients; - let larger_coefficients: Vec = other.coefficients; - if smaller_coefficients.len() > larger_coefficients.len() { - let temp: Vec = smaller_coefficients; - smaller_coefficients = larger_coefficients; - larger_coefficients = temp; - } - let sum_diff: [i32; larger_coefficients.len()] = [0; larger_coefficients.len()]; - let length_diff: i32 = larger_coefficients.len() - smaller_coefficients.len(); - // Copy high-order terms only found in higher-degree polynomial's coefficients - System::arraycopy(&larger_coefficients, 0, &sum_diff, 0, length_diff); - { - let mut i: i32 = length_diff; - while i < larger_coefficients.len() { - { - sum_diff[i] = GenericGF::add_or_subtract( - smaller_coefficients[i - length_diff], - larger_coefficients[i], - ); - } - i += 1; - } - } - - return GenericGFPoly::new(&self.field, &sum_diff); - } - - fn multiply(&self, other: &GenericGFPoly) -> Result { - if !self.field.equals(other.field) { - return Err(IllegalArgumentException::new( - "GenericGFPolys do not have same GenericGF field", - )); - } - if self.is_zero() || other.is_zero() { - return Ok(self.field.get_zero()); - } - let a_coefficients: Vec = self.coefficients; - let a_length: i32 = a_coefficients.len(); - let b_coefficients: Vec = other.coefficients; - let b_length: i32 = b_coefficients.len(); - let mut product: [i32; a_length + b_length - 1] = [0; a_length + b_length - 1]; - { - let mut i: i32 = 0; - while i < a_length { - { - let a_coeff: i32 = a_coefficients[i]; - { - let mut j: i32 = 0; - while j < b_length { - { - product[i + j] = GenericGF::add_or_subtract( - product[i + j], - &self.field.multiply(a_coeff, b_coefficients[j]), - ); - } - j += 1; - } - } - } - i += 1; - } - } - - return GenericGFPoly::new(&self.field, &product); - } - - fn multiply(&self, scalar: i32) -> GenericGFPoly { - if scalar == 0 { - return self.field.get_zero(); - } - if scalar == 1 { - return self; - } - let size: i32 = self.coefficients.len(); - let mut product: [i32; size] = [0; size]; - { - let mut i: i32 = 0; - while i < size { - { - product[i] = self.field.multiply(self.coefficients[i], scalar); - } - i += 1; - } - } - - return GenericGFPoly::new(&self.field, &product); - } - - fn multiply_by_monomial( - &self, - degree: i32, - coefficient: i32, - ) -> Result { - if degree < 0 { - return Err(IllegalArgumentException::new()); - } - if coefficient == 0 { - return Ok(self.field.get_zero()); - } - let size: i32 = self.coefficients.len(); - let mut product: [i32; size + degree] = [0; size + degree]; - { - let mut i: i32 = 0; - while i < size { - { - product[i] = self.field.multiply(self.coefficients[i], coefficient); - } - i += 1; - } - } - - return GenericGFPoly::new(&self.field, &product); - } - - fn divide( - &self, - other: &GenericGFPoly, - ) -> Result, IllegalArgumentException> { - if !self.field.equals(other.field) { - return Err(IllegalArgumentException::new( - "GenericGFPolys do not have same GenericGF field", - )); - } - if other.is_zero() { - return Err(IllegalArgumentException::new("Divide by 0")); - } - let mut quotient: GenericGFPoly = self.field.get_zero(); - let mut remainder: GenericGFPoly = self; - let denominator_leading_term: i32 = other.get_coefficient(&other.get_degree()); - let inverse_denominator_leading_term: i32 = self.field.inverse(denominator_leading_term); - while remainder.get_degree() >= other.get_degree() && !remainder.is_zero() { - let degree_difference: i32 = remainder.get_degree() - other.get_degree(); - let scale: i32 = self.field.multiply( - &remainder.get_coefficient(&remainder.get_degree()), - inverse_denominator_leading_term, - ); - let term: GenericGFPoly = other.multiply_by_monomial(degree_difference, scale); - let iteration_quotient: GenericGFPoly = - self.field.build_monomial(degree_difference, scale); - quotient = quotient.add_or_subtract(&iteration_quotient); - remainder = remainder.add_or_subtract(&term); - } - return Ok(vec![quotient, remainder]); - } - - pub fn to_string(&self) -> String { - if self.is_zero() { - return "0".to_owned(); - } - let result: StringBuilder = StringBuilder::new(8 * self.get_degree()); - { - let mut degree: i32 = self.get_degree(); - while degree >= 0 { - { - let mut coefficient: i32 = self.get_coefficient(degree); - if coefficient != 0 { - if coefficient < 0 { - if degree == self.get_degree() { - result.append("-"); - } else { - result.append(" - "); - } - coefficient = -coefficient; - } else { - if result.length() > 0 { - result.append(" + "); - } - } - if degree == 0 || coefficient != 1 { - let alpha_power: i32 = self.field.log(coefficient); - if alpha_power == 0 { - result.append('1'); - } else if alpha_power == 1 { - result.append('a'); - } else { - result.append("a^"); - result.append(alpha_power); - } - } - if degree != 0 { - if degree == 1 { - result.append('x'); - } else { - result.append("x^"); - result.append(degree); - } - } - } - } - degree -= 1; - } - } - - return result.to_string(); - } -} - -// GenericGF.java -/** - *

This class contains utility methods for performing mathematical operations over - * the Galois Fields. Operations use a given primitive polynomial in calculations.

- * - *

Throughout this package, elements of the GF are represented as an {@code int} - * for convenience and speed (but at the cost of memory). - *

- * - * @author Sean Owen - * @author David Olivier - */ - -// x^12 + x^6 + x^5 + x^3 + 1 -const AZTEC_DATA_12: GenericGF = GenericGF::new(0x1069, 4096, 1); - -// x^10 + x^3 + 1 -const AZTEC_DATA_10: GenericGF = GenericGF::new(0x409, 1024, 1); - -// x^6 + x + 1 -const AZTEC_DATA_6: GenericGF = GenericGF::new(0x43, 64, 1); - -// x^4 + x + 1 -const AZTEC_PARAM: GenericGF = GenericGF::new(0x13, 16, 1); - -// x^8 + x^4 + x^3 + x^2 + 1 -const QR_CODE_FIELD_256: GenericGF = GenericGF::new(0x011D, 256, 0); - -// x^8 + x^5 + x^3 + x^2 + 1 -const DATA_MATRIX_FIELD_256: GenericGF = GenericGF::new(0x012D, 256, 1); - -const AZTEC_DATA_8: GenericGF = DATA_MATRIX_FIELD_256; - -const MAXICODE_FIELD_64: GenericGF = AZTEC_DATA_6; - -pub struct GenericGF { - exp_table: Vec, - - log_table: Vec, - - zero: GenericGFPoly, - - one: GenericGFPoly, - - size: i32, - - primitive: i32, - - generator_base: i32, -} - -impl GenericGF { - /** - * Create a representation of GF(size) using the given primitive polynomial. - * - * @param primitive irreducible polynomial whose coefficients are represented by - * the bits of an int, where the least-significant bit represents the constant - * coefficient - * @param size the size of the field - * @param b the factor b in the generator polynomial can be 0- or 1-based - * (g(x) = (x+a^b)(x+a^(b+1))...(x+a^(b+2t-1))). - * In most cases it should be 1, but for QR code it is 0. - */ - pub fn new(primitive: i32, size: i32, b: i32) -> Self { - let mut new_generic_gf: GenericGF; - new_generic_gf.primitive = primitive; - new_generic_gf.size = size; - new_generic_gf.generatorBase = b; - exp_table = [0; size]; - log_table = [0; size]; - let mut x: i32 = 1; - { - let mut i: i32 = 0; - while i < size { - { - exp_table[i] = x; - // we're assuming the generator alpha is 2 - x *= 2; - if x >= size { - x ^= primitive; - x &= size - 1; - } - } - i += 1; - } - } - - { - let mut i: i32 = 0; - while i < size - 1 { - { - log_table[exp_table[i]] = i; - } - i += 1; - } - } - - // logTable[0] == 0 but this should never be used - new_generic_gf.zero = GenericGFPoly::new(0, &vec![0]); - new_generic_gf.one = GenericGFPoly::new(0, &vec![1]); - - new_generic_gf - } - - fn get_zero(&self) -> GenericGFPoly { - return self.zero; - } - - fn get_one(&self) -> GenericGFPoly { - return self.one; - } - - /** - * @return the monomial representing coefficient * x^degree - */ - fn build_monomial( - &self, - degree: i32, - coefficient: i32, - ) -> Result { - if degree < 0 { - return Err(IllegalArgumentException::new()); - } - if coefficient == 0 { - return Ok(self.zero); - } - let mut coefficients: [i32; degree + 1] = [0; degree + 1]; - coefficients[0] = coefficient; - return GenericGFPoly::new(self, &coefficients); - } - - /** - * Implements both addition and subtraction -- they are the same in GF(size). - * - * @return sum/difference of a and b - */ - fn add_or_subtract(a: i32, b: i32) -> i32 { - return a ^ b; - } - - /** - * @return 2 to the power of a in GF(size) - */ - fn exp(&self, a: i32) -> i32 { - return self.exp_table[a]; - } - - /** - * @return base 2 log of a in GF(size) - */ - fn log(&self, a: i32) -> Result { - if a == 0 { - return Err(IllegalArgumentException::new()); - } - return self.log_table[a]; - } - - /** - * @return multiplicative inverse of a - */ - fn inverse(&self, a: i32) -> Result { - if a == 0 { - return Err(ArithmeticException::new()); - } - return self.exp_table[self.size - self.log_table[a] - 1]; - } - - /** - * @return product of a and b in GF(size) - */ - fn multiply(&self, a: i32, b: i32) -> i32 { - if a == 0 || b == 0 { - return 0; - } - return self.exp_table[(self.log_table[a] + self.log_table[b]) % (self.size - 1)]; - } - - pub fn get_size(&self) -> i32 { - return self.size; - } - - pub fn get_generator_base(&self) -> i32 { - return self.generator_base; - } - - pub fn to_string(&self) -> String { - return format!( - "GF(0x{},{})", - Integer::to_hex_string(self.primitive), - self.size - ); - } -} - -// ReedSolomonDecoder.java -/** - *

Implements Reed-Solomon decoding, as the name implies.

- * - *

The algorithm will not be explained here, but the following references were helpful - * in creating this implementation:

- * - * - * - *

Much credit is due to William Rucklidge since portions of this code are an indirect - * port of his C++ Reed-Solomon implementation.

- * - * @author Sean Owen - * @author William Rucklidge - * @author sanfordsquires - */ -pub struct ReedSolomonDecoder { - field: GenericGF, -} - -impl ReedSolomonDecoder { - pub fn new(field: &GenericGF) -> Self { - Self { field } - } - - /** - *

Decodes given set of received codewords, which include both data and error-correction - * codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place, - * in the input.

- * - * @param received data and error-correction codewords - * @param twoS number of error-correction codewords available - * @throws ReedSolomonException if decoding fails for any reason - */ - pub fn decode(&self, received: &Vec, two_s: i32) -> Result<(), ReedSolomonException> { - let poly: GenericGFPoly = GenericGFPoly::new(&self.field, &received); - let syndrome_coefficients: [i32; two_s] = [0; two_s]; - let no_error: bool = true; - { - let mut i: i32 = 0; - while i < two_s { - { - let eval: i32 = - poly.evaluate_at(&self.field.exp(i + self.field.get_generator_base())); - syndrome_coefficients[syndrome_coefficients.len() - 1 - i] = eval; - if eval != 0 { - no_error = false; - } - } - i += 1; - } - } - - if no_error { - return; - } - let syndrome: GenericGFPoly = GenericGFPoly::new(&self.field, &syndrome_coefficients); - let sigma_omega: Vec = - self.run_euclidean_algorithm(&self.field.build_monomial(two_s, 1), &syndrome, two_s); - let sigma: GenericGFPoly = sigma_omega[0]; - let omega: GenericGFPoly = sigma_omega[1]; - let error_locations: Vec = self.find_error_locations(&sigma); - let error_magnitudes: Vec = self.find_error_magnitudes(&omega, &error_locations); - { - let mut i: i32 = 0; - while i < error_locations.len() { - { - let mut position: i32 = received.len() - 1 - self.field.log(error_locations[i]); - if position < 0 { - return Err(ReedSolomonException::new("Bad error location")); - } - received[position] = - GenericGF::add_or_subtract(received[position], error_magnitudes[i]); - } - i += 1; - } - } - Ok(()) - } - - fn run_euclidean_algorithm( - &self, - a: &GenericGFPoly, - b: &GenericGFPoly, - R: i32, - ) -> Result, ReedSolomonException + IllegalStateException> { - // Assume a's degree is >= b's - if a.get_degree() < b.get_degree() { - let temp: GenericGFPoly = a; - a = b; - b = &temp; - } - let r_last: GenericGFPoly = a; - let mut r: GenericGFPoly = b; - let t_last: GenericGFPoly = self.field.get_zero(); - let mut t: GenericGFPoly = self.field.get_one(); - // Run Euclidean algorithm until r's degree is less than R/2 - while 2 * r.get_degree() >= R { - let r_last_last: GenericGFPoly = r_last; - let t_last_last: GenericGFPoly = t_last; - r_last = r; - t_last = t; - // Divide rLastLast by rLast, with quotient in q and remainder in r - if r_last.is_zero() { - // Oops, Euclidean algorithm already terminated? - return Err(ReedSolomonException::new("r_{i-1} was zero")); - } - r = r_last_last; - let mut q: GenericGFPoly = self.field.get_zero(); - let denominator_leading_term: i32 = r_last.get_coefficient(&r_last.get_degree()); - let dlt_inverse: i32 = self.field.inverse(denominator_leading_term); - while r.get_degree() >= r_last.get_degree() && !r.is_zero() { - let degree_diff: i32 = r.get_degree() - r_last.get_degree(); - let scale: i32 = self - .field - .multiply(&r.get_coefficient(&r.get_degree()), dlt_inverse); - q = q.add_or_subtract(&self.field.build_monomial(degree_diff, scale)); - r = r.add_or_subtract(&r_last.multiply_by_monomial(degree_diff, scale)); - } - t = q.multiply(&t_last).add_or_subtract(t_last_last); - if r.get_degree() >= r_last.get_degree() { - return Err(IllegalStateException::new(format!( - "Division algorithm failed to reduce polynomial? r: {}, rLast: {}", - r, r_last - ))); - } - } - let sigma_tilde_at_zero: i32 = t.get_coefficient(0); - if sigma_tilde_at_zero == 0 { - return Err(ReedSolomonException::new("sigmaTilde(0) was zero")); - } - let inverse: i32 = self.field.inverse(sigma_tilde_at_zero); - let sigma: GenericGFPoly = t.multiply(inverse); - let omega: GenericGFPoly = r.multiply(inverse); - return Ok(vec![sigma, omega]); - } - - fn find_error_locations( - &self, - error_locator: &GenericGFPoly, - ) -> Result, ReedSolomonException> { - // This is a direct application of Chien's search - let num_errors: i32 = error_locator.get_degree(); - if num_errors == 1 { - // shortcut - return Ok(vec![error_locator.get_coefficient(1)]); - } - let mut result: [i32; num_errors] = [0; num_errors]; - let mut e: i32 = 0; - { - let mut i: i32 = 1; - while i < self.field.get_size() && e < num_errors { - { - if error_locator.evaluate_at(i) == 0 { - result[e] = self.field.inverse(i); - e += 1; - } - } - i += 1; - } - } - - if e != num_errors { - return Err(ReedSolomonException::new( - "Error locator degree does not match number of roots", - )); - } - return Ok(result); - } - - fn find_error_magnitudes( - &self, - error_evaluator: &GenericGFPoly, - error_locations: &Vec, - ) -> Vec { - // This is directly applying Forney's Formula - let s: i32 = error_locations.len(); - let mut result: [i32; s] = [0; s]; - { - let mut i: i32 = 0; - while i < s { - { - let xi_inverse: i32 = self.field.inverse(error_locations[i]); - let mut denominator: i32 = 1; - { - let mut j: i32 = 0; - while j < s { - { - if i != j { - //denominator = field.multiply(denominator, - // GenericGF.addOrSubtract(1, field.multiply(errorLocations[j], xiInverse))); - // Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug. - // Below is a funny-looking workaround from Steven Parkes - let term: i32 = - self.field.multiply(error_locations[j], xi_inverse); - let term_plus1: i32 = if (term & 0x1) == 0 { - term | 1 - } else { - term & 1 - }; - denominator = self.field.multiply(denominator, term_plus1); - } - } - j += 1; - } - } - - result[i] = self.field.multiply( - &error_evaluator.evaluate_at(xi_inverse), - &self.field.inverse(denominator), - ); - if self.field.get_generator_base() != 0 { - result[i] = self.field.multiply(result[i], xi_inverse); - } - } - i += 1; - } - } - - return result; - } -} - -// ReedSolomonEncoder.java -/** - *

Implements Reed-Solomon encoding, as the name implies.

- * - * @author Sean Owen - * @author William Rucklidge - */ -pub struct ReedSolomonEncoder { - field: GenericGF, - - cached_generators: Vector, -} - -impl ReedSolomonEncoder { - pub fn new(field: &GenericGF) -> Self { - let mut new_rse; - new_rse.field = field; - new_rse.cachedGenerators = Vector::new(); - cached_generators.add(GenericGFPoly::new(field, &vec![1])); - new_rse - } - - fn build_generator(&self, degree: i32) -> GenericGFPoly { - if degree >= self.cached_generators.size() { - let last_generator: GenericGFPoly = self - .cached_generators - .get(self.cached_generators.size() - 1); - { - let mut d: i32 = self.cached_generators.size(); - while d <= degree { - { - let next_generator: GenericGFPoly = - last_generator.multiply(GenericGFPoly::new( - &self.field, - &vec![1, self.field.exp(d - 1 + self.field.get_generator_base())], - )); - self.cached_generators.add(next_generator); - last_generator = next_generator; - } - d += 1; - } - } - } - return self.cached_generators.get(degree); - } - - pub fn encode( - &self, - to_encode: &Vec, - ec_bytes: i32, - ) -> Result<(), IllegalArgumentException> { - if ec_bytes == 0 { - return Err(IllegalArgumentException::new("No error correction bytes")); - } - let data_bytes: i32 = to_encode.len() - ec_bytes; - if data_bytes <= 0 { - return Err(IllegalArgumentException::new("No data bytes provided")); - } - let generator: GenericGFPoly = self.build_generator(ec_bytes); - let info_coefficients: [i32; data_bytes] = [0; data_bytes]; - System::arraycopy(&to_encode, 0, &info_coefficients, 0, data_bytes); - let mut info: GenericGFPoly = GenericGFPoly::new(&self.field, &info_coefficients); - info = info.multiply_by_monomial(ec_bytes, 1); - let remainder: GenericGFPoly = info.divide(&generator)[1]; - let coefficients: Vec = remainder.get_coefficients(); - let num_zero_coefficients: i32 = ec_bytes - coefficients.len(); - { - let mut i: i32 = 0; - while i < num_zero_coefficients { - { - to_encode[data_bytes + i] = 0; - } - i += 1; - } - } - - System::arraycopy( - &coefficients, - 0, - &to_encode, - data_bytes + num_zero_coefficients, - coefficients.len(), - ); - Ok(()) - } -} - -// ReedSolomonException.java -/** - *

Thrown when an exception occurs during Reed-Solomon decoding, such as when - * there are too many errors to correct.

- * - * @author Sean Owen - */ -pub struct ReedSolomonException { - message: String, -} - -impl ReedSolomonException { - pub fn new(message: &String) -> Self { - ReedSolomonException { message } - } -} diff --git a/src/datamatrix.rs b/src/datamatrix.rs deleted file mode 100644 index b7b2ae0..0000000 --- a/src/datamatrix.rs +++ /dev/null @@ -1,406 +0,0 @@ -pub mod decoder; -pub mod detector; -pub mod encoder; - -use crate::common::{BitMatrix, DecoderResult, DetectorResult}; -use crate::datamatrix::decoder::Decoder; -use crate::datamatrix::detector::Detector; -use crate::datamatrix::encoder::{ - DefaultPlacement, ErrorCorrection, HighLevelEncoder, MinimalEncoder, SymbolInfo, - SymbolShapeHint, -}; -use crate::qrcode::encoder::ByteMatrix; -use crate::{ - BarcodeFormat, BinaryBitmap, ChecksumException, DecodeHintType, Dimension, EncodeHintType, - FormatException, NotFoundException, RXingResult, Reader, ResultMetadataType, ResultPoint, - Writer, -}; - -// DataMatrixReader.java -/** - * This implementation can detect and decode Data Matrix codes in an image. - * - * @author bbrown@google.com (Brian Brown) - */ - -const NO_POINTS: [Option; 0] = [None; 0]; -pub struct DataMatrixReader { - decoder: Decoder, -} - -impl Reader for DataMatrixReader { - /** - * Locates and decodes a Data Matrix code in an image. - * - * @return a String representing the content encoded by the Data Matrix code - * @throws NotFoundException if a Data Matrix code cannot be found - * @throws FormatException if a Data Matrix code cannot be decoded - * @throws ChecksumException if error correction fails - */ - fn decode( - &self, - image: &BinaryBitmap, - hints: &Map, - ) -> Result { - let decoder_result: DecoderResult; - let mut points: Vec; - if hints != null && hints.contains_key(DecodeHintType::PURE_BARCODE) { - let bits: BitMatrix = ::extract_pure_bits(&image.get_black_matrix()); - decoder_result = self.decoder.decode(bits); - points = NO_POINTS; - } else { - let detector_result: DetectorResult = Detector::new(&image.get_black_matrix()).detect(); - decoder_result = self.decoder.decode(&detector_result.get_bits()); - points = detector_result.get_points(); - } - let result: Result = Result::new( - &decoder_result.get_text(), - &decoder_result.get_raw_bytes(), - points, - BarcodeFormat::DATA_MATRIX, - ); - let byte_segments: List> = decoder_result.get_byte_segments(); - if byte_segments != null { - result.put_metadata(ResultMetadataType::BYTE_SEGMENTS, &byte_segments); - } - let ec_level: String = decoder_result.get_e_c_level(); - if ec_level != null { - result.put_metadata(ResultMetadataType::ERROR_CORRECTION_LEVEL, &ec_level); - } - result.put_metadata( - ResultMetadataType::SYMBOLOGY_IDENTIFIER, - format!("]d{}", decoder_result.get_symbology_modifier()), - ); - return Ok(result); - } - - fn reset(&self) { - // do nothing - } -} - -impl DataMatrixReader { - pub fn new() -> Self { - Self { - decoder: Decoder::new(), - } - } - - /** - * This method detects a code in a "pure" image -- that is, pure monochrome image - * which contains only an unrotated, unskewed, image of a code, with some white border - * around it. This is a specialized method that works exceptionally fast in this special - * case. - */ - fn extract_pure_bits(image: &BitMatrix) -> Result { - let left_top_black: Vec = image.get_top_left_on_bit(); - let right_bottom_black: Vec = image.get_bottom_right_on_bit(); - if left_top_black == null || right_bottom_black == null { - return Err(NotFoundException::get_not_found_instance()); - } - let module_size: i32 = self.module_size(&left_top_black, image); - let mut top: i32 = left_top_black[1]; - let bottom: i32 = right_bottom_black[1]; - let mut left: i32 = left_top_black[0]; - let right: i32 = right_bottom_black[0]; - let matrix_width: i32 = (right - left + 1) / module_size; - let matrix_height: i32 = (bottom - top + 1) / module_size; - if matrix_width <= 0 || matrix_height <= 0 { - return Err(NotFoundException::get_not_found_instance()); - } - // Push in the "border" by half the module width so that we start - // sampling in the middle of the module. Just in case the image is a - // little off, this will help recover. - let nudge: i32 = module_size / 2; - top += nudge; - left += nudge; - // Now just read off the bits - let bits: BitMatrix = BitMatrix::new(matrix_width, matrix_height); - { - let mut y: i32 = 0; - while y < matrix_height { - { - let i_offset: i32 = top + y * module_size; - { - let mut x: i32 = 0; - while x < matrix_width { - { - if image.get(left + x * module_size, i_offset) { - bits.set(x, y); - } - } - x += 1; - } - } - } - y += 1; - } - } - - return Ok(bits); - } - - fn module_size(left_top_black: &Vec, image: &BitMatrix) -> Result { - let width: i32 = image.get_width(); - let mut x: i32 = left_top_black[0]; - let y: i32 = left_top_black[1]; - while x < width && image.get(x, y) { - x += 1; - } - if x == width { - return Err(NotFoundException::get_not_found_instance()); - } - let module_size: i32 = x - left_top_black[0]; - if module_size == 0 { - return Err(NotFoundException::get_not_found_instance()); - } - return Ok(module_size); - } -} - -// DataMatrixWriter.java -/** - * This object renders a Data Matrix code as a BitMatrix 2D array of greyscale values. - * - * @author dswitkin@google.com (Daniel Switkin) - * @author Guillaume Le Biller Added to zxing lib. - */ -pub struct DataMatrixWriter {} - -impl Writer for DataMatrixWriter { - fn encode( - &self, - contents: &String, - format: &BarcodeFormat, - width: i32, - height: i32, - hints: &Map, - ) -> BitMatrix { - if contents.is_empty() { - return Err(IllegalArgumentException::new("Found empty contents")); - } - if format != BarcodeFormat::DATA_MATRIX { - return Err(IllegalArgumentException::new(format!( - "Can only encode DATA_MATRIX, but got {}", - format - ))); - } - if width < 0 || height < 0 { - return Err(IllegalArgumentException::new(format!( - "Requested dimensions can't be negative: {}x{}", - width, height - ))); - } - // Try to get force shape & min / max size - let mut shape: SymbolShapeHint = SymbolShapeHint::FORCE_NONE; - let min_size: Dimension = null; - let max_size: Dimension = null; - if hints != null { - let requested_shape: SymbolShapeHint = - hints.get(EncodeHintType::DATA_MATRIX_SHAPE) as SymbolShapeHint; - if requested_shape != null { - shape = requested_shape; - } - let requested_min_size: Dimension = hints.get(EncodeHintType::MIN_SIZE) as Dimension; - if requested_min_size != null { - min_size = requested_min_size; - } - let requested_max_size: Dimension = hints.get(EncodeHintType::MAX_SIZE) as Dimension; - if requested_max_size != null { - max_size = requested_max_size; - } - } - //1. step: Data encodation - let mut encoded: String; - let has_compaction_hint: bool = hints != null - && hints.contains_key(EncodeHintType::DATA_MATRIX_COMPACT) - && Boolean::parse_boolean(&hints.get(EncodeHintType::DATA_MATRIX_COMPACT).to_string()); - if has_compaction_hint { - let has_g_s1_format_hint: bool = hints.contains_key(EncodeHintType::GS1_FORMAT) - && Boolean::parse_boolean(&hints.get(EncodeHintType::GS1_FORMAT).to_string()); - let mut charset: Charset = null; - let has_encoding_hint: bool = hints.contains_key(EncodeHintType::CHARACTER_SET); - if has_encoding_hint { - charset = Charset::for_name(&hints.get(EncodeHintType::CHARACTER_SET).to_string()); - } - encoded = MinimalEncoder::encode_high_level( - &contents, - &charset, - if has_g_s1_format_hint { 0x1D } else { -1 }, - &shape, - ); - } else { - let has_force_c40_hint: bool = hints != null - && hints.contains_key(EncodeHintType::FORCE_C40) - && Boolean::parse_boolean(&hints.get(EncodeHintType::FORCE_C40).to_string()); - encoded = HighLevelEncoder::encode_high_level( - &contents, - shape, - min_size, - max_size, - has_force_c40_hint, - ); - } - let symbol_info: SymbolInfo = - SymbolInfo::lookup(&encoded.length(), shape, min_size, max_size, true); - //2. step: ECC generation - let codewords: String = ErrorCorrection::encode_e_c_c200(&encoded, &symbol_info); - //3. step: Module placement in Matrix - let placement: DefaultPlacement = DefaultPlacement::new( - &codewords, - &symbol_info.get_symbol_data_width(), - &symbol_info.get_symbol_data_height(), - ); - placement.place(); - //4. step: low-level encoding - return ::encode_low_level(placement, symbol_info, width, height); - } -} - -impl DataMatrixWriter { - /** - * Encode the given symbol info to a bit matrix. - * - * @param placement The DataMatrix placement. - * @param symbolInfo The symbol info to encode. - * @return The bit matrix generated. - */ - fn encode_low_level( - placement: &DefaultPlacement, - symbol_info: &SymbolInfo, - width: i32, - height: i32, - ) -> BitMatrix { - let symbol_width: i32 = symbol_info.get_symbol_data_width(); - let symbol_height: i32 = symbol_info.get_symbol_data_height(); - let matrix: ByteMatrix = ByteMatrix::new( - &symbol_info.get_symbol_width(), - &symbol_info.get_symbol_height(), - ); - let matrix_y: i32 = 0; - { - let mut y: i32 = 0; - while y < symbol_height { - { - // Fill the top edge with alternate 0 / 1 - let matrix_x: i32; - if (y % symbol_info.matrixHeight) == 0 { - matrix_x = 0; - { - let mut x: i32 = 0; - while x < symbol_info.get_symbol_width() { - { - matrix.set(matrix_x, matrix_y, (x % 2) == 0); - matrix_x += 1; - } - x += 1; - } - } - - matrix_y += 1; - } - matrix_x = 0; - { - let mut x: i32 = 0; - while x < symbol_width { - { - // Fill the right edge with full 1 - if (x % symbol_info.matrixWidth) == 0 { - matrix.set(matrix_x, matrix_y, true); - matrix_x += 1; - } - matrix.set(matrix_x, matrix_y, &placement.get_bit(x, y)); - matrix_x += 1; - // Fill the right edge with alternate 0 / 1 - if (x % symbol_info.matrixWidth) == symbol_info.matrixWidth - 1 { - matrix.set(matrix_x, matrix_y, (y % 2) == 0); - matrix_x += 1; - } - } - x += 1; - } - } - - matrix_y += 1; - // Fill the bottom edge with full 1 - if (y % symbol_info.matrixHeight) == symbol_info.matrixHeight - 1 { - matrix_x = 0; - { - let mut x: i32 = 0; - while x < symbol_info.get_symbol_width() { - { - matrix.set(matrix_x, matrix_y, true); - matrix_x += 1; - } - x += 1; - } - } - - matrix_y += 1; - } - } - y += 1; - } - } - - return ::convert_byte_matrix_to_bit_matrix(matrix, width, height); - } - - /** - * Convert the ByteMatrix to BitMatrix. - * - * @param reqHeight The requested height of the image (in pixels) with the Datamatrix code - * @param reqWidth The requested width of the image (in pixels) with the Datamatrix code - * @param matrix The input matrix. - * @return The output matrix. - */ - fn convert_byte_matrix_to_bit_matrix( - matrix: &ByteMatrix, - req_width: i32, - req_height: i32, - ) -> BitMatrix { - let matrix_width: i32 = matrix.get_width(); - let matrix_height: i32 = matrix.get_height(); - let output_width: i32 = Math::max(req_width, matrix_width); - let output_height: i32 = Math::max(req_height, matrix_height); - let multiple: i32 = Math::min(output_width / matrix_width, output_height / matrix_height); - let left_padding: i32 = (output_width - (matrix_width * multiple)) / 2; - let top_padding: i32 = (output_height - (matrix_height * multiple)) / 2; - let mut output: BitMatrix; - // remove padding if requested width and height are too small - if req_height < matrix_height || req_width < matrix_width { - left_padding = 0; - top_padding = 0; - output = BitMatrix::new(matrix_width, matrix_height); - } else { - output = BitMatrix::new(req_width, req_height); - } - output.clear(); - { - let input_y: i32 = 0; - let output_y: i32 = top_padding; - while input_y < matrix_height { - { - // Write the contents of this row of the bytematrix - { - let input_x: i32 = 0; - let output_x: i32 = left_padding; - while input_x < matrix_width { - { - if matrix.get(input_x, input_y) == 1 { - output.set_region(output_x, output_y, multiple, multiple); - } - } - input_x += 1; - output_x += multiple; - } - } - } - input_y += 1; - output_y += multiple; - } - } - - return output; - } -} diff --git a/src/datamatrix/decoder.rs b/src/datamatrix/decoder.rs deleted file mode 100644 index 15d504b..0000000 --- a/src/datamatrix/decoder.rs +++ /dev/null @@ -1,2067 +0,0 @@ -use crate::common::reedsolomon::{GenericGF, ReedSolomonDecoder, ReedSolomonException}; -use crate::common::{BitMatrix, BitSource, DecoderResult, ECIStringBuilder}; -use crate::{ChecksumException, FormatException, FormatException}; - -// BitMatrixParser.java -/** - * @author bbrown@google.com (Brian Brown) - */ -struct BitMatrixParser { - mapping_bit_matrix: BitMatrix, - - read_mapping_matrix: BitMatrix, - - version: Version, -} - -impl BitMatrixParser { - /** - * @param bitMatrix {@link BitMatrix} to parse - * @throws FormatException if dimension is < 8 or > 144 or not 0 mod 2 - */ - fn new(bit_matrix: &BitMatrix) -> Result { - let dimension: i32 = bit_matrix.get_height(); - if dimension < 8 || dimension > 144 || (dimension & 0x01) != 0 { - return Err(FormatException::get_format_instance()); - } - let new_bmp: Self; - new_bmp.version = ::read_version(bit_matrix); - new_bmp.mappingBitMatrix = self.extract_data_region(bit_matrix); - new_bmp.readMappingMatrix = BitMatrix::new( - &new_bmp.mappingBitMatrix.get_width(), - &new_bmp.mappingBitMatrix.get_height(), - ); - - Ok(new_bmp) - } - - fn get_version(&self) -> Version { - return self.version; - } - - /** - *

Creates the version object based on the dimension of the original bit matrix from - * the datamatrix code.

- * - *

See ISO 16022:2006 Table 7 - ECC 200 symbol attributes

- * - * @param bitMatrix Original {@link BitMatrix} including alignment patterns - * @return {@link Version} encapsulating the Data Matrix Code's "version" - * @throws FormatException if the dimensions of the mapping matrix are not valid - * Data Matrix dimensions. - */ - fn read_version(bit_matrix: &BitMatrix) -> Result> { - let num_rows: i32 = bit_matrix.get_height(); - let num_columns: i32 = bit_matrix.get_width(); - return Ok(Version::get_version_for_dimensions(num_rows, num_columns)); - } - - /** - *

Reads the bits in the {@link BitMatrix} representing the mapping matrix (No alignment patterns) - * in the correct order in order to reconstitute the codewords bytes contained within the - * Data Matrix Code.

- * - * @return bytes encoded within the Data Matrix Code - * @throws FormatException if the exact number of bytes expected is not read - */ - fn read_codewords(&self) -> Result, FormatException> { - let mut result: [i8; self.version.get_total_codewords()] = - [0; self.version.get_total_codewords()]; - let result_offset: i32 = 0; - let mut row: i32 = 4; - let mut column: i32 = 0; - let num_rows: i32 = self.mapping_bit_matrix.get_height(); - let num_columns: i32 = self.mapping_bit_matrix.get_width(); - let corner1_read: bool = false; - let corner2_read: bool = false; - let corner3_read: bool = false; - let corner4_read: bool = false; - // Read all of the codewords - loop { - { - // Check the four corner cases - if (row == num_rows) && (column == 0) && !corner1_read { - result[result_offset += 1] = self.read_corner1(num_rows, num_columns) as i8; - row -= 2; - column += 2; - corner1_read = true; - } else if (row == num_rows - 2) - && (column == 0) - && ((num_columns & 0x03) != 0) - && !corner2_read - { - result[result_offset += 1] = self.read_corner2(num_rows, num_columns) as i8; - row -= 2; - column += 2; - corner2_read = true; - } else if (row == num_rows + 4) - && (column == 2) - && ((num_columns & 0x07) == 0) - && !corner3_read - { - result[result_offset += 1] = self.read_corner3(num_rows, num_columns) as i8; - row -= 2; - column += 2; - corner3_read = true; - } else if (row == num_rows - 2) - && (column == 0) - && ((num_columns & 0x07) == 4) - && !corner4_read - { - result[result_offset += 1] = self.read_corner4(num_rows, num_columns) as i8; - row -= 2; - column += 2; - corner4_read = true; - } else { - // Sweep upward diagonally to the right - loop { - { - if (row < num_rows) - && (column >= 0) - && !self.read_mapping_matrix.get(column, row) - { - result[result_offset += 1] = - self.read_utah(row, column, num_rows, num_columns) as i8; - } - row -= 2; - column += 2; - } - if !((row >= 0) && (column < num_columns)) { - break; - } - } - row += 1; - column += 3; - // Sweep downward diagonally to the left - loop { - { - if (row >= 0) - && (column < num_columns) - && !self.read_mapping_matrix.get(column, row) - { - result[result_offset += 1] = - self.read_utah(row, column, num_rows, num_columns) as i8; - } - row += 2; - column -= 2; - } - if !((row < num_rows) && (column >= 0)) { - break; - } - } - row += 3; - column += 1; - } - } - if !((row < num_rows) || (column < num_columns)) { - break; - } - } - if result_offset != self.version.get_total_codewords() { - return Err(FormatException::get_format_instance()); - } - return Ok(result); - } - - /** - *

Reads a bit of the mapping matrix accounting for boundary wrapping.

- * - * @param row Row to read in the mapping matrix - * @param column Column to read in the mapping matrix - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return value of the given bit in the mapping matrix - */ - fn read_module(&self, row: i32, column: i32, num_rows: i32, num_columns: i32) -> bool { - // Adjust the row and column indices based on boundary wrapping - if row < 0 { - row += num_rows; - column += 4 - ((num_rows + 4) & 0x07); - } - if column < 0 { - column += num_columns; - row += 4 - ((num_columns + 4) & 0x07); - } - if row >= num_rows { - row -= num_rows; - } - self.read_mapping_matrix.set(column, row); - return self.mapping_bit_matrix.get(column, row); - } - - /** - *

Reads the 8 bits of the standard Utah-shaped pattern.

- * - *

See ISO 16022:2006, 5.8.1 Figure 6

- * - * @param row Current row in the mapping matrix, anchored at the 8th bit (LSB) of the pattern - * @param column Current column in the mapping matrix, anchored at the 8th bit (LSB) of the pattern - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the utah shape - */ - fn read_utah(&self, row: i32, column: i32, num_rows: i32, num_columns: i32) -> i32 { - let current_byte: i32 = 0; - if self.read_module(row - 2, column - 2, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(row - 2, column - 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(row - 1, column - 2, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(row - 1, column - 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(row - 1, column, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(row, column - 2, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(row, column - 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(row, column, num_rows, num_columns) { - current_byte |= 1; - } - return current_byte; - } - - /** - *

Reads the 8 bits of the special corner condition 1.

- * - *

See ISO 16022:2006, Figure F.3

- * - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the Corner condition 1 - */ - fn read_corner1(&self, num_rows: i32, num_columns: i32) -> i32 { - let current_byte: i32 = 0; - if self.read_module(num_rows - 1, 0, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(num_rows - 1, 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(num_rows - 1, 2, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(0, num_columns - 2, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(0, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(1, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(2, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(3, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - return current_byte; - } - - /** - *

Reads the 8 bits of the special corner condition 2.

- * - *

See ISO 16022:2006, Figure F.4

- * - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the Corner condition 2 - */ - fn read_corner2(&self, num_rows: i32, num_columns: i32) -> i32 { - let current_byte: i32 = 0; - if self.read_module(num_rows - 3, 0, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(num_rows - 2, 0, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(num_rows - 1, 0, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(0, num_columns - 4, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(0, num_columns - 3, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(0, num_columns - 2, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(0, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(1, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - return current_byte; - } - - /** - *

Reads the 8 bits of the special corner condition 3.

- * - *

See ISO 16022:2006, Figure F.5

- * - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the Corner condition 3 - */ - fn read_corner3(&self, num_rows: i32, num_columns: i32) -> i32 { - let current_byte: i32 = 0; - if self.read_module(num_rows - 1, 0, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(num_rows - 1, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(0, num_columns - 3, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(0, num_columns - 2, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(0, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(1, num_columns - 3, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(1, num_columns - 2, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(1, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - return current_byte; - } - - /** - *

Reads the 8 bits of the special corner condition 4.

- * - *

See ISO 16022:2006, Figure F.6

- * - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the Corner condition 4 - */ - fn read_corner4(&self, num_rows: i32, num_columns: i32) -> i32 { - let current_byte: i32 = 0; - if self.read_module(num_rows - 3, 0, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(num_rows - 2, 0, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(num_rows - 1, 0, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(0, num_columns - 2, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(0, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(1, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(2, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - current_byte <<= 1; - if self.read_module(3, num_columns - 1, num_rows, num_columns) { - current_byte |= 1; - } - return current_byte; - } - - /** - *

Extracts the data region from a {@link BitMatrix} that contains - * alignment patterns.

- * - * @param bitMatrix Original {@link BitMatrix} with alignment patterns - * @return BitMatrix that has the alignment patterns removed - */ - fn extract_data_region(&self, bit_matrix: &BitMatrix) -> BitMatrix { - let symbol_size_rows: i32 = self.version.get_symbol_size_rows(); - let symbol_size_columns: i32 = self.version.get_symbol_size_columns(); - if bit_matrix.get_height() != symbol_size_rows { - return Err(IllegalArgumentException::new( - "Dimension of bitMatrix must match the version size", - )); - } - let data_region_size_rows: i32 = self.version.get_data_region_size_rows(); - let data_region_size_columns: i32 = self.version.get_data_region_size_columns(); - let num_data_regions_row: i32 = symbol_size_rows / data_region_size_rows; - let num_data_regions_column: i32 = symbol_size_columns / data_region_size_columns; - let size_data_region_row: i32 = num_data_regions_row * data_region_size_rows; - let size_data_region_column: i32 = num_data_regions_column * data_region_size_columns; - let bit_matrix_without_alignment: BitMatrix = - BitMatrix::new(size_data_region_column, size_data_region_row); - { - let data_region_row: i32 = 0; - while data_region_row < num_data_regions_row { - { - let data_region_row_offset: i32 = data_region_row * data_region_size_rows; - { - let data_region_column: i32 = 0; - while data_region_column < num_data_regions_column { - { - let data_region_column_offset: i32 = - data_region_column * data_region_size_columns; - { - let mut i: i32 = 0; - while i < data_region_size_rows { - { - let read_row_offset: i32 = data_region_row - * (data_region_size_rows + 2) - + 1 - + i; - let write_row_offset: i32 = data_region_row_offset + i; - { - let mut j: i32 = 0; - while j < data_region_size_columns { - { - let read_column_offset: i32 = - data_region_column - * (data_region_size_columns + 2) - + 1 - + j; - if bit_matrix.get( - read_column_offset, - read_row_offset, - ) { - let write_column_offset: i32 = - data_region_column_offset + j; - bit_matrix_without_alignment.set( - write_column_offset, - write_row_offset, - ); - } - } - j += 1; - } - } - } - i += 1; - } - } - } - data_region_column += 1; - } - } - } - data_region_row += 1; - } - } - - return bit_matrix_without_alignment; - } -} - -// DataBlock.java -/** - *

Encapsulates a block of data within a Data Matrix Code. Data Matrix Codes may split their data into - * multiple blocks, each of which is a unit of data and error-correction codewords. Each - * is represented by an instance of this class.

- * - * @author bbrown@google.com (Brian Brown) - */ -struct DataBlock { - num_data_codewords: i32, - - codewords: Vec, -} - -impl DataBlock { - fn new(num_data_codewords: i32, codewords: &Vec) -> Self { - Self { - num_data_codewords, - codewords: codewords, - } - } - - /** - *

When Data Matrix Codes use multiple data blocks, they actually interleave the bytes of each of them. - * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This - * method will separate the data into original blocks.

- * - * @param rawCodewords bytes as read directly from the Data Matrix Code - * @param version version of the Data Matrix Code - * @return DataBlocks containing original bytes, "de-interleaved" from representation in the - * Data Matrix Code - */ - fn get_data_blocks(raw_codewords: &Vec, version: &Version) -> Vec { - // Figure out the number and size of data blocks used by this version - let ec_blocks: Version::ECBlocks = version.get_e_c_blocks(); - // First count the total number of data blocks - let total_blocks: i32 = 0; - let ec_block_array: Vec = ec_blocks.get_e_c_blocks(); - for ec_block in ec_block_array { - total_blocks += ec_block.get_count(); - } - // Now establish DataBlocks of the appropriate size and number of data codewords - let mut result: [Option; total_blocks] = [None; total_blocks]; - let num_result_blocks: i32 = 0; - for ec_block in ec_block_array { - { - let mut i: i32 = 0; - while i < ec_block.get_count() { - { - let num_data_codewords: i32 = ec_block.get_data_codewords(); - let num_block_codewords: i32 = - ec_blocks.get_e_c_codewords() + num_data_codewords; - result[num_result_blocks += 1] = - DataBlock::new(num_data_codewords, [0; num_block_codewords]); - } - i += 1; - } - } - } - // All blocks have the same amount of data, except that the last n - // (where n may be 0) have 1 less byte. Figure out where these start. - // TODO(bbrown): There is only one case where there is a difference for Data Matrix for size 144 - let longer_blocks_total_codewords: i32 = result[0].codewords.len(); - //int shorterBlocksTotalCodewords = longerBlocksTotalCodewords - 1; - let longer_blocks_num_data_codewords: i32 = - longer_blocks_total_codewords - ec_blocks.get_e_c_codewords(); - let shorter_blocks_num_data_codewords: i32 = longer_blocks_num_data_codewords - 1; - // The last elements of result may be 1 element shorter for 144 matrix - // first fill out as many elements as all of them have minus 1 - let raw_codewords_offset: i32 = 0; - { - let mut i: i32 = 0; - while i < shorter_blocks_num_data_codewords { - { - { - let mut j: i32 = 0; - while j < num_result_blocks { - { - result[j].codewords[i] = raw_codewords[raw_codewords_offset += 1]; - } - j += 1; - } - } - } - i += 1; - } - } - - // Fill out the last data block in the longer ones - let special_version: bool = version.get_version_number() == 24; - let num_longer_blocks: i32 = if special_version { - 8 - } else { - num_result_blocks - }; - { - let mut j: i32 = 0; - while j < num_longer_blocks { - { - result[j].codewords[longer_blocks_num_data_codewords - 1] = - raw_codewords[raw_codewords_offset += 1]; - } - j += 1; - } - } - - // Now add in error correction blocks - let max: i32 = result[0].codewords.len(); - { - let mut i: i32 = longer_blocks_num_data_codewords; - while i < max { - { - { - let mut j: i32 = 0; - while j < num_result_blocks { - { - let j_offset: i32 = if special_version { - (j + 8) % num_result_blocks - } else { - j - }; - let i_offset: i32 = if special_version && j_offset > 7 { - i - 1 - } else { - i - }; - result[j_offset].codewords[i_offset] = - raw_codewords[raw_codewords_offset += 1]; - } - j += 1; - } - } - } - i += 1; - } - } - - if raw_codewords_offset != raw_codewords.len() { - return Err(IllegalArgumentException::new()); - } - return result; - } - - fn get_num_data_codewords(&self) -> i32 { - return self.num_data_codewords; - } - - fn get_codewords(&self) -> Vec { - return self.codewords; - } -} - -// DecodedBitStreamParser.java -/** - *

Data Matrix Codes can encode text as bits in one of several modes, and can use multiple modes - * in one Data Matrix Code. This class decodes the bits back into text.

- * - *

See ISO 16022:2006, 5.2.1 - 5.2.9.2

- * - * @author bbrown@google.com (Brian Brown) - * @author Sean Owen - */ - -/** - * See ISO 16022:2006, Annex C Table C.1 - * The C40 Basic Character Set (*'s used for placeholders for the shift values) - */ -const C40_BASIC_SET_CHARS: vec![Vec; 40] = vec![ - '*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', - 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', - 'Y', 'Z', -]; - -const C40_SHIFT2_SET_CHARS: vec![Vec; 27] = vec![ - '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', - '>', '?', '@', '[', '\\', ']', '^', '_', -]; - -const TEXT_BASIC_SET_CHARS: vec![Vec; 40] = vec![ - '*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', - 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', - 'y', 'z', -]; - -// Shift 2 for Text is the same encoding as C40 -const TEXT_SHIFT2_SET_CHARS: Vec = C40_SHIFT2_SET_CHARS; - -const TEXT_SHIFT3_SET_CHARS: vec![Vec; 32] = vec![ - '`', - 'A', - 'B', - 'C', - 'D', - 'E', - 'F', - 'G', - 'H', - 'I', - 'J', - 'K', - 'L', - 'M', - 'N', - 'O', - 'P', - 'Q', - 'R', - 'S', - 'T', - 'U', - 'V', - 'W', - 'X', - 'Y', - 'Z', - '{', - '|', - '}', - '~', - 127 as char, -]; - -enum Mode { - // Not really a mode - PAD_ENCODE(), - ASCII_ENCODE(), - C40_ENCODE(), - TEXT_ENCODE(), - ANSIX12_ENCODE(), - EDIFACT_ENCODE(), - BASE256_ENCODE(), - ECI_ENCODE(), -} - -struct DecodedBitStreamParser {} - -impl DecodedBitStreamParser { - fn new() -> DecodedBitStreamParser {} - - fn decode(bytes: &Vec) -> Result> { - let bits: BitSource = BitSource::new(&bytes); - let result: ECIStringBuilder = ECIStringBuilder::new(); - let result_trailer: StringBuilder = StringBuilder::new(0); - let byte_segments: List> = Vec::new(); - let mut mode: Mode = Mode::ASCII_ENCODE; - // Could look directly at 'bytes', if we're sure of not having to account for multi byte values - let fnc1_positions: Set = HashSet::new(); - let symbology_modifier: i32; - let is_e_c_iencoded: bool = false; - loop { - { - if mode == Mode::ASCII_ENCODE { - mode = ::decode_ascii_segment(bits, result, &result_trailer, &fnc1_positions); - } else { - match mode { - C40_ENCODE => { - ::decode_c40_segment(bits, result, &fnc1_positions); - break; - } - TEXT_ENCODE => { - ::decode_text_segment(bits, result, &fnc1_positions); - break; - } - ANSIX12_ENCODE => { - ::decode_ansi_x12_segment(bits, result); - break; - } - EDIFACT_ENCODE => { - ::decode_edifact_segment(bits, result); - break; - } - BASE256_ENCODE => { - ::decode_base256_segment(bits, result, &byte_segments); - break; - } - ECI_ENCODE => { - ::decode_e_c_i_segment(bits, result); - // ECI detection only, atm continue decoding as ASCII - is_e_c_iencoded = true; - break; - } - _ => { - return Err(FormatException::get_format_instance()); - } - } - mode = Mode::ASCII_ENCODE; - } - } - if !(mode != Mode::PAD_ENCODE && bits.available() > 0) { - break; - } - } - if result_trailer.length() > 0 { - result.append_characters(&result_trailer); - } - if is_e_c_iencoded { - // https://honeywellaidc.force.com/supportppr/s/article/List-of-barcode-symbology-AIM-Identifiers - if fnc1_positions.contains(0) || fnc1_positions.contains(4) { - symbology_modifier = 5; - } else if fnc1_positions.contains(1) || fnc1_positions.contains(5) { - symbology_modifier = 6; - } else { - symbology_modifier = 4; - } - } else { - if fnc1_positions.contains(0) || fnc1_positions.contains(4) { - symbology_modifier = 2; - } else if fnc1_positions.contains(1) || fnc1_positions.contains(5) { - symbology_modifier = 3; - } else { - symbology_modifier = 1; - } - } - return Ok(DecoderResult::new( - &bytes, - &result.to_string(), - &byte_segments, - null, - Some(symbology_modifier), - None, - None, - )); - } - - /** - * See ISO 16022:2006, 5.2.3 and Annex C, Table C.2 - */ - fn decode_ascii_segment( - bits: &BitSource, - result: &ECIStringBuilder, - result_trailer: &StringBuilder, - fnc1positions: &Set, - ) -> Result> { - let upper_shift: bool = false; - loop { - { - let one_byte: i32 = bits.read_bits(8); - if one_byte == 0 { - return Err(FormatException::get_format_instance()); - } else if one_byte <= 128 { - // ASCII data (ASCII value + 1) - if upper_shift { - one_byte += 128; - //upperShift = false; - } - result.append((one_byte - 1) as char); - return Ok(Mode::ASCII_ENCODE); - } else if one_byte == 129 { - // Pad - return Ok(Mode::PAD_ENCODE); - } else if one_byte <= 229 { - // 2-digit data 00-99 (Numeric Value + 130) - let value: i32 = one_byte - 130; - if value < 10 { - // pad with '0' for single digit values - result.append('0'); - } - result.append(value); - } else { - match one_byte { - // Latch to C40 encodation - 230 => { - return Ok(Mode::C40_ENCODE); - } - // Latch to Base 256 encodation - 231 => { - return Ok(Mode::BASE256_ENCODE); - } - // FNC1 - 232 => { - fnc1positions.add(&result.length()); - // translate as ASCII 29 - result.append(29 as char); - break; - } - // Structured Append - 233 => {} - // Reader Programming - 234 => { - //throw ReaderException.getInstance(); - break; - } - // Upper Shift (shift to Extended ASCII) - 235 => { - upper_shift = true; - break; - } - // 05 Macro - 236 => { - result.append("[)>\u{001E05}\u{001D}"); - result_trailer.insert(0, "\u{001E}\u{0004}"); - break; - } - // 06 Macro - 237 => { - result.append("[)>\u{001E06}\u{001D}"); - resultTrailer.insert(0, "\u{001E}\u{0004}"); - break; - } - // Latch to ANSI X12 encodation - 238 => { - return Ok(Mode::ANSIX12_ENCODE); - } - // Latch to Text encodation - 239 => { - return Ok(Mode::TEXT_ENCODE); - } - // Latch to EDIFACT encodation - 240 => { - return Ok(Mode::EDIFACT_ENCODE); - } - // ECI Character - 241 => { - return Ok(Mode::ECI_ENCODE); - } - _ => { - // but work around encoders that end with 254, latch back to ASCII - if one_byte != 254 || bits.available() != 0 { - return Err(FormatException::get_format_instance()); - } - break; - } - } - } - } - if !(bits.available() > 0) { - break; - } - } - return Ok(Mode::ASCII_ENCODE); - } - - /** - * See ISO 16022:2006, 5.2.5 and Annex C, Table C.1 - */ - fn decode_c40_segment( - bits: &BitSource, - result: &ECIStringBuilder, - fnc1positions: &Set, - ) -> Result<(), FormatException> { - // Three C40 values are encoded in a 16-bit value as - // (1600 * C1) + (40 * C2) + C3 + 1 - // TODO(bbrown): The Upper Shift with C40 doesn't work in the 4 value scenario all the time - let upper_shift: bool = false; - let c_values: [i32; 3] = [0; 3]; - let mut shift: i32 = 0; - loop { - { - // If there is only one byte left then it will be encoded as ASCII - if bits.available() == 8 { - return; - } - let first_byte: i32 = bits.read_bits(8); - if first_byte == 254 { - // Unlatch codeword - return; - } - ::parse_two_bytes(first_byte, &bits.read_bits(8), &c_values); - { - let mut i: i32 = 0; - while i < 3 { - { - let c_value: i32 = c_values[i]; - match shift { - 0 => { - if c_value < 3 { - shift = c_value + 1; - } else if c_value < C40_BASIC_SET_CHARS.len() { - let c40char: char = C40_BASIC_SET_CHARS[c_value]; - if upper_shift { - result.append((c40char + 128) as char); - upper_shift = false; - } else { - result.append(c40char); - } - } else { - return Err(FormatException::get_format_instance()); - } - break; - } - 1 => { - if upper_shift { - result.append((c_value + 128) as char); - upper_shift = false; - } else { - result.append(c_value as char); - } - shift = 0; - break; - } - 2 => { - if c_value < C40_SHIFT2_SET_CHARS.len() { - let c40char: char = C40_SHIFT2_SET_CHARS[c_value]; - if upper_shift { - result.append((c40char + 128) as char); - upper_shift = false; - } else { - result.append(c40char); - } - } else { - match c_value { - // FNC1 - 27 => { - fnc1positions.add(&result.length()); - // translate as ASCII 29 - result.append(29 as char); - break; - } - // Upper Shift - 30 => { - upper_shift = true; - break; - } - _ => { - return Err(FormatException::get_format_instance()); - } - } - } - shift = 0; - break; - } - 3 => { - if upper_shift { - result.append((c_value + 224) as char); - upper_shift = false; - } else { - result.append((c_value + 96) as char); - } - shift = 0; - break; - } - _ => { - return Err(FormatException::get_format_instance()); - } - } - } - i += 1; - } - } - } - if !(bits.available() > 0) { - break; - } - } - Ok(()) - } - - /** - * See ISO 16022:2006, 5.2.6 and Annex C, Table C.2 - */ - fn decode_text_segment( - bits: &BitSource, - result: &ECIStringBuilder, - fnc1positions: &Set, - ) -> Result> { - // Three Text values are encoded in a 16-bit value as - // (1600 * C1) + (40 * C2) + C3 + 1 - // TODO(bbrown): The Upper Shift with Text doesn't work in the 4 value scenario all the time - let upper_shift: bool = false; - let c_values: [i32; 3] = [0; 3]; - let mut shift: i32 = 0; - loop { - { - // If there is only one byte left then it will be encoded as ASCII - if bits.available() == 8 { - return; - } - let first_byte: i32 = bits.read_bits(8); - if first_byte == 254 { - // Unlatch codeword - return; - } - ::parse_two_bytes(first_byte, &bits.read_bits(8), &c_values); - { - let mut i: i32 = 0; - while i < 3 { - { - let c_value: i32 = c_values[i]; - match shift { - 0 => { - if c_value < 3 { - shift = c_value + 1; - } else if c_value < TEXT_BASIC_SET_CHARS.len() { - let text_char: char = TEXT_BASIC_SET_CHARS[c_value]; - if upper_shift { - result.append((text_char + 128) as char); - upper_shift = false; - } else { - result.append(text_char); - } - } else { - return Err(FormatException::get_format_instance()); - } - break; - } - 1 => { - if upper_shift { - result.append((c_value + 128) as char); - upper_shift = false; - } else { - result.append(c_value as char); - } - shift = 0; - break; - } - 2 => { - // Shift 2 for Text is the same encoding as C40 - if c_value < TEXT_SHIFT2_SET_CHARS.len() { - let text_char: char = TEXT_SHIFT2_SET_CHARS[c_value]; - if upper_shift { - result.append((text_char + 128) as char); - upper_shift = false; - } else { - result.append(text_char); - } - } else { - match c_value { - // FNC1 - 27 => { - fnc1positions.add(&result.length()); - // translate as ASCII 29 - result.append(29 as char); - break; - } - // Upper Shift - 30 => { - upper_shift = true; - break; - } - _ => { - return Err(FormatException::get_format_instance()); - } - } - } - shift = 0; - break; - } - 3 => { - if c_value < TEXT_SHIFT3_SET_CHARS.len() { - let text_char: char = TEXT_SHIFT3_SET_CHARS[c_value]; - if upper_shift { - result.append((text_char + 128) as char); - upper_shift = false; - } else { - result.append(text_char); - } - shift = 0; - } else { - return Err(FormatException::get_format_instance()); - } - break; - } - _ => { - return Err(FormatException::get_format_instance()); - } - } - } - i += 1; - } - } - } - if !(bits.available() > 0) { - break; - } - } - Ok(()) - } - - /** - * See ISO 16022:2006, 5.2.7 - */ - fn decode_ansi_x12_segment( - bits: &BitSource, - result: &ECIStringBuilder, - ) -> Result> { - // Three ANSI X12 values are encoded in a 16-bit value as - // (1600 * C1) + (40 * C2) + C3 + 1 - let c_values: [i32; 3] = [0; 3]; - loop { - { - // If there is only one byte left then it will be encoded as ASCII - if bits.available() == 8 { - return; - } - let first_byte: i32 = bits.read_bits(8); - if first_byte == 254 { - // Unlatch codeword - return; - } - ::parse_two_bytes(first_byte, &bits.read_bits(8), &c_values); - { - let mut i: i32 = 0; - while i < 3 { - { - let c_value: i32 = c_values[i]; - match c_value { - // X12 segment terminator - 0 => { - result.append('\r'); - break; - } - // X12 segment separator * - 1 => { - result.append('*'); - break; - } - // X12 sub-element separator > - 2 => { - result.append('>'); - break; - } - // space - 3 => { - result.append(' '); - break; - } - _ => { - if c_value < 14 { - // 0 - 9 - result.append((c_value + 44) as char); - } else if c_value < 40 { - // A - Z - result.append((c_value + 51) as char); - } else { - return Err(FormatException::get_format_instance()); - } - break; - } - } - } - i += 1; - } - } - } - if !(bits.available() > 0) { - break; - } - } - Ok(()) - } - - fn parse_two_bytes(first_byte: i32, second_byte: i32, result: &Vec) { - let full_bit_value: i32 = (first_byte << 8) + second_byte - 1; - let mut temp: i32 = full_bit_value / 1600; - result[0] = temp; - full_bit_value -= temp * 1600; - temp = full_bit_value / 40; - result[1] = temp; - result[2] = full_bit_value - temp * 40; - } - - /** - * See ISO 16022:2006, 5.2.8 and Annex C Table C.3 - */ - fn decode_edifact_segment(bits: &BitSource, result: &ECIStringBuilder) { - loop { - { - // If there is only two or less bytes left then it will be encoded as ASCII - if bits.available() <= 16 { - return; - } - { - let mut i: i32 = 0; - while i < 4 { - { - let edifact_value: i32 = bits.read_bits(6); - // Check for the unlatch character - if edifact_value == 0x1F { - // 011111 - // Read rest of byte, which should be 0, and stop - let bits_left: i32 = 8 - bits.get_bit_offset(); - if bits_left != 8 { - bits.read_bits(bits_left); - } - return; - } - if (edifact_value & 0x20) == 0 { - // no 1 in the leading (6th) bit - // Add a leading 01 to the 6 bit binary value - edifact_value |= 0x40; - } - result.append(edifact_value as char); - } - i += 1; - } - } - } - if !(bits.available() > 0) { - break; - } - } - } - - /** - * See ISO 16022:2006, 5.2.9 and Annex B, B.2 - */ - fn decode_base256_segment( - bits: &BitSource, - result: &ECIStringBuilder, - byte_segments: &Collection>, - ) -> Result<(), FormatException> { - // Figure out how long the Base 256 Segment is. - // position is 1-indexed - let codeword_position: i32 = 1 + bits.get_byte_offset(); - let d1: i32 = ::unrandomize255_state(&bits.read_bits(8), codeword_position += 1); - let mut count: i32; - if d1 == 0 { - // Read the remainder of the symbol - count = bits.available() / 8; - } else if d1 < 250 { - count = d1; - } else { - count = 250 * (d1 - 249) - + ::unrandomize255_state(&bits.read_bits(8), codeword_position += 1); - } - // We're seeing NegativeArraySizeException errors from users. - if count < 0 { - return Err(FormatException::get_format_instance()); - } - let mut bytes: [i8; count] = [0; count]; - { - let mut i: i32 = 0; - while i < count { - { - // http://www.bcgen.com/demo/IDAutomationStreamingDataMatrix.aspx?MODE=3&D=Fred&PFMT=3&PT=F&X=0.3&O=0&LM=0.2 - if bits.available() < 8 { - return Err(FormatException::get_format_instance()); - } - bytes[i] = - ::unrandomize255_state(&bits.read_bits(8), codeword_position += 1) as i8; - } - i += 1; - } - } - - byte_segments.add(&bytes); - { - use encoding::all::ISO_8859_1; - use encoding::{DecoderTrap, Encoding}; - - result.append( - ISO_8859_1 - .decode(&bytes, DecoderTrap::Strict) - .unwrap_or("".to_owned()), - ) - // result.append(String::new(&bytes, StandardCharsets::ISO_8859_1)); - } - Ok(()) - } - - /** - * See ISO 16022:2007, 5.4.1 - */ - fn decode_e_c_i_segment( - bits: &BitSource, - result: &ECIStringBuilder, - ) -> Result<(), FormatException> { - if bits.available() < 8 { - return Err(FormatException::get_format_instance()); - } - let c1: i32 = bits.read_bits(8); - if c1 <= 127 { - result.append_e_c_i(c1 - 1); - } - Ok(()) - //currently we only support character set ECIs - /*} else { - if (bits.available() < 8) { - throw FormatException.getFormatInstance(); - } - int c2 = bits.readBits(8); - if (c1 >= 128 && c1 <= 191) { - } else { - if (bits.available() < 8) { - throw FormatException.getFormatInstance(); - } - int c3 = bits.readBits(8); - } - }*/ - } - - /** - * See ISO 16022:2006, Annex B, B.2 - */ - fn unrandomize255_state( - randomized_base256_codeword: i32, - base256_codeword_position: i32, - ) -> i32 { - let pseudo_random_number: i32 = ((149 * base256_codeword_position) % 255) + 1; - let temp_variable: i32 = randomized_base256_codeword - pseudo_random_number; - return if temp_variable >= 0 { - temp_variable - } else { - temp_variable + 256 - }; - } -} - -// Decoder.java -/** - *

The main class which implements Data Matrix Code decoding -- as opposed to locating and extracting - * the Data Matrix Code from an image.

- * - * @author bbrown@google.com (Brian Brown) - */ -pub struct Decoder { - rs_decoder: ReedSolomonDecoder, -} - -impl Decoder { - pub fn new() -> Decoder { - rs_decoder = ReedSolomonDecoder::new(GenericGF::DATA_MATRIX_FIELD_256); - } - - /** - *

Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans. - * "true" is taken to mean a black module.

- * - * @param image booleans representing white/black Data Matrix Code modules - * @return text and bytes encoded within the Data Matrix Code - * @throws FormatException if the Data Matrix Code cannot be decoded - * @throws ChecksumException if error correction fails - */ - pub fn decode(&self, image: &Vec>) -> Result> { - return Ok(self.decode(&BitMatrix::parse(&image))); - } - - /** - *

Decodes a Data Matrix Code represented as a {@link BitMatrix}. A 1 or "true" is taken - * to mean a black module.

- * - * @param bits booleans representing white/black Data Matrix Code modules - * @return text and bytes encoded within the Data Matrix Code - * @throws FormatException if the Data Matrix Code cannot be decoded - * @throws ChecksumException if error correction fails - */ - pub fn decode(&self, bits: &BitMatrix) -> Result> { - // Construct a parser and read version, error-correction level - let parser: BitMatrixParser = BitMatrixParser::new(bits); - let version: Version = parser.get_version(); - // Read codewords - let codewords: Vec = parser.read_codewords(); - // Separate into data blocks - let data_blocks: Vec = DataBlock::get_data_blocks(&codewords, &version); - // Count total number of data bytes - let total_bytes: i32 = 0; - for db in data_blocks { - total_bytes += db.get_num_data_codewords(); - } - let result_bytes: [i8; total_bytes] = [0; total_bytes]; - let data_blocks_count: i32 = data_blocks.len(); - // Error-correct and copy data blocks together into a stream of bytes - { - let mut j: i32 = 0; - while j < data_blocks_count { - { - let data_block: DataBlock = data_blocks[j]; - let codeword_bytes: Vec = data_block.get_codewords(); - let num_data_codewords: i32 = data_block.get_num_data_codewords(); - self.correct_errors(&codeword_bytes, num_data_codewords); - { - let mut i: i32 = 0; - while i < num_data_codewords { - { - // De-interlace data blocks. - result_bytes[i * data_blocks_count + j] = codeword_bytes[i]; - } - i += 1; - } - } - } - j += 1; - } - } - - // Decode the contents of that stream of bytes - return Ok(DecodedBitStreamParser::decode(&result_bytes)); - } - - /** - *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to - * correct the errors in-place using Reed-Solomon error correction.

- * - * @param codewordBytes data and error correction codewords - * @param numDataCodewords number of codewords that are data bytes - * @throws ChecksumException if error correction fails - */ - fn correct_errors( - &self, - codeword_bytes: &Vec, - num_data_codewords: i32, - ) -> Result<(), ChecksumException> { - let num_codewords: i32 = codeword_bytes.len(); - // First read into an array of ints - let codewords_ints: [i32; num_codewords] = [0; num_codewords]; - { - let mut i: i32 = 0; - while i < num_codewords { - { - codewords_ints[i] = codeword_bytes[i] & 0xFF; - } - i += 1; - } - } - - self.rs_decoder - .decode(&codewords_ints, codeword_bytes.len() - num_data_codewords); - - // We don't care about errors in the error-correction codewords - { - let mut i: i32 = 0; - while i < num_data_codewords { - { - codeword_bytes[i] = codewords_ints[i] as i8; - } - i += 1; - } - } - Ok(()) - } -} - -// Version.java -/** - * The Version object encapsulates attributes about a particular - * size Data Matrix Code. - * - * @author bbrown@google.com (Brian Brown) - */ - -const VERSIONS: Vec = ::build_versions(); -pub struct Version { - version_number: i32, - - symbol_size_rows: i32, - - symbol_size_columns: i32, - - data_region_size_rows: i32, - - data_region_size_columns: i32, - - ec_blocks: ECBlocks, - - total_codewords: i32, -} - -impl Version { - fn new( - version_number: i32, - symbol_size_rows: i32, - symbol_size_columns: i32, - data_region_size_rows: i32, - data_region_size_columns: i32, - ec_blocks: &ECBlocks, - ) -> Self { - let new_v: Self; - new_v.versionNumber = version_number; - new_v.symbolSizeRows = symbol_size_rows; - new_v.symbolSizeColumns = symbol_size_columns; - new_v.dataRegionSizeRows = data_region_size_rows; - new_v.dataRegionSizeColumns = data_region_size_columns; - new_v.ecBlocks = ec_blocks; - // Calculate the total number of codewords - let mut total: i32 = 0; - let ec_codewords: i32 = ec_blocks.get_e_c_codewords(); - let ecb_array: Vec = ec_blocks.get_e_c_blocks(); - for ec_block in ecb_array { - total += ec_block.get_count() * (ec_block.get_data_codewords() + ec_codewords); - } - new_v.totalCodewords = total; - - new_v - } - - pub fn get_version_number(&self) -> i32 { - return self.version_number; - } - - pub fn get_symbol_size_rows(&self) -> i32 { - return self.symbol_size_rows; - } - - pub fn get_symbol_size_columns(&self) -> i32 { - return self.symbol_size_columns; - } - - pub fn get_data_region_size_rows(&self) -> i32 { - return self.data_region_size_rows; - } - - pub fn get_data_region_size_columns(&self) -> i32 { - return self.data_region_size_columns; - } - - pub fn get_total_codewords(&self) -> i32 { - return self.total_codewords; - } - - fn get_e_c_blocks(&self) -> ECBlocks { - return self.ec_blocks; - } - - /** - *

Deduces version information from Data Matrix dimensions.

- * - * @param numRows Number of rows in modules - * @param numColumns Number of columns in modules - * @return Version for a Data Matrix Code of those dimensions - * @throws FormatException if dimensions do correspond to a valid Data Matrix size - */ - pub fn get_version_for_dimensions( - num_rows: i32, - num_columns: i32, - ) -> Result> { - if (num_rows & 0x01) != 0 || (num_columns & 0x01) != 0 { - return Err(FormatException::get_format_instance()); - } - for version in VERSIONS { - if version.symbolSizeRows == num_rows && version.symbolSizeColumns == num_columns { - return Ok(version); - } - } - return Err(FormatException::get_format_instance()); - } - - pub fn to_string(&self) -> String { - return String::value_of(self.version_number); - } - - /** - * See ISO 16022:2006 5.5.1 Table 7 - */ - fn build_versions() -> Vec { - return vec![ - Version::new(1, 10, 10, 8, 8, &ECBlocks::new_simple(5, &ECB::new(1, 3))), - Version::new(2, 12, 12, 10, 10, &ECBlocks::new_simple(7, &ECB::new(1, 5))), - Version::new( - 3, - 14, - 14, - 12, - 12, - &ECBlocks::new_simple(10, &ECB::new(1, 8)), - ), - Version::new( - 4, - 16, - 16, - 14, - 14, - &ECBlocks::new_simple(12, &ECB::new(1, 12)), - ), - Version::new( - 5, - 18, - 18, - 16, - 16, - &ECBlocks::new_simple(14, &ECB::new(1, 18)), - ), - Version::new( - 6, - 20, - 20, - 18, - 18, - &ECBlocks::new_simple(18, &ECB::new(1, 22)), - ), - Version::new( - 7, - 22, - 22, - 20, - 20, - &ECBlocks::new_simple(20, &ECB::new(1, 30)), - ), - Version::new( - 8, - 24, - 24, - 22, - 22, - &ECBlocks::new_simple(24, &ECB::new(1, 36)), - ), - Version::new( - 9, - 26, - 26, - 24, - 24, - &ECBlocks::new_simple(28, &ECB::new(1, 44)), - ), - Version::new( - 10, - 32, - 32, - 14, - 14, - &ECBlocks::new_simple(36, &ECB::new(1, 62)), - ), - Version::new( - 11, - 36, - 36, - 16, - 16, - &ECBlocks::new_simple(42, &ECB::new(1, 86)), - ), - Version::new( - 12, - 40, - 40, - 18, - 18, - &ECBlocks::new_simple(48, &ECB::new(1, 114)), - ), - Version::new( - 13, - 44, - 44, - 20, - 20, - &ECBlocks::new_simple(56, &ECB::new(1, 144)), - ), - Version::new( - 14, - 48, - 48, - 22, - 22, - &ECBlocks::new_simple(68, &ECB::new(1, 174)), - ), - Version::new( - 15, - 52, - 52, - 24, - 24, - &ECBlocks::new_simple(42, &ECB::new(2, 102)), - ), - Version::new( - 16, - 64, - 64, - 14, - 14, - &ECBlocks::new_simple(56, &ECB::new(2, 140)), - ), - Version::new( - 17, - 72, - 72, - 16, - 16, - &ECBlocks::new_simple(36, &ECB::new(4, 92)), - ), - Version::new( - 18, - 80, - 80, - 18, - 18, - &ECBlocks::new_simple(48, &ECB::new(4, 114)), - ), - Version::new( - 19, - 88, - 88, - 20, - 20, - &ECBlocks::new_simple(56, &ECB::new(4, 144)), - ), - Version::new( - 20, - 96, - 96, - 22, - 22, - &ECBlocks::new_simple(68, &ECB::new(4, 174)), - ), - Version::new( - 21, - 104, - 104, - 24, - 24, - &ECBlocks::new_simple(56, &ECB::new(6, 136)), - ), - Version::new( - 22, - 120, - 120, - 18, - 18, - &ECBlocks::new_simple(68, &ECB::new(6, 175)), - ), - Version::new( - 23, - 132, - 132, - 20, - 20, - &ECBlocks::new_simple(62, &ECB::new(8, 163)), - ), - Version::new( - 24, - 144, - 144, - 22, - 22, - &ECBlocks::new(62, &ECB::new(8, 156), &ECB::new(2, 155)), - ), - Version::new(25, 8, 18, 6, 16, &ECBlocks::new_simple(7, &ECB::new(1, 5))), - Version::new( - 26, - 8, - 32, - 6, - 14, - &ECBlocks::new_simple(11, &ECB::new(1, 10)), - ), - Version::new( - 27, - 12, - 26, - 10, - 24, - &ECBlocks::new_simple(14, &ECB::new(1, 16)), - ), - Version::new( - 28, - 12, - 36, - 10, - 16, - &ECBlocks::new_simple(18, &ECB::new(1, 22)), - ), - Version::new( - 29, - 16, - 36, - 14, - 16, - &ECBlocks::new_simple(24, &ECB::new(1, 32)), - ), - Version::new( - 30, - 16, - 48, - 14, - 22, - &ECBlocks::new_simple(28, &ECB::new(1, 49)), - ), // ISO 21471:2020 (DMRE) 5.5.1 Table 7 - Version::new( - 31, - 8, - 48, - 6, - 22, - &ECBlocks::new_simple(15, &ECB::new(1, 18)), - ), - Version::new( - 32, - 8, - 64, - 6, - 14, - &ECBlocks::new_simple(18, &ECB::new(1, 24)), - ), - Version::new( - 33, - 8, - 80, - 6, - 18, - &ECBlocks::new_simple(22, &ECB::new(1, 32)), - ), - Version::new( - 34, - 8, - 96, - 6, - 22, - &ECBlocks::new_simple(28, &ECB::new(1, 38)), - ), - Version::new( - 35, - 8, - 120, - 6, - 18, - &ECBlocks::new_simple(32, &ECB::new(1, 49)), - ), - Version::new( - 36, - 8, - 144, - 6, - 22, - &ECBlocks::new_simple(36, &ECB::new(1, 63)), - ), - Version::new( - 37, - 12, - 64, - 10, - 14, - &ECBlocks::new_simple(27, &ECB::new(1, 43)), - ), - Version::new( - 38, - 12, - 88, - 10, - 20, - &ECBlocks::new_simple(36, &ECB::new(1, 64)), - ), - Version::new( - 39, - 16, - 64, - 14, - 14, - &ECBlocks::new_simple(36, &ECB::new(1, 62)), - ), - Version::new( - 40, - 20, - 36, - 18, - 16, - &ECBlocks::new_simple(28, &ECB::new(1, 44)), - ), - Version::new( - 41, - 20, - 44, - 18, - 20, - &ECBlocks::new_simple(34, &ECB::new(1, 56)), - ), - Version::new( - 42, - 20, - 64, - 18, - 14, - &ECBlocks::new_simple(42, &ECB::new(1, 84)), - ), - Version::new( - 43, - 22, - 48, - 20, - 22, - &ECBlocks::new_simple(38, &ECB::new(1, 72)), - ), - Version::new( - 44, - 24, - 48, - 22, - 22, - &ECBlocks::new_simple(41, &ECB::new(1, 80)), - ), - Version::new( - 45, - 24, - 64, - 22, - 14, - &ECBlocks::new_simple(46, &ECB::new(1, 108)), - ), - Version::new( - 46, - 26, - 40, - 24, - 18, - &ECBlocks::new_simple(38, &ECB::new(1, 70)), - ), - Version::new( - 47, - 26, - 48, - 24, - 22, - &ECBlocks::new_simple(42, &ECB::new(1, 90)), - ), - Version::new( - 48, - 26, - 64, - 24, - 14, - &ECBlocks::new_simple(50, &ECB::new(1, 118)), - ), - ]; - } -} - -/** - *

Encapsulates a set of error-correction blocks in one symbol version. Most versions will - * use blocks of differing sizes within one version, so, this encapsulates the parameters for - * each set of blocks. It also holds the number of error-correction codewords per block since it - * will be the same across all blocks within one version.

- */ -struct ECBlocks { - ec_codewords: i32, - - ec_blocks: Vec, -} - -impl ECBlocks { - fn new_simple(ec_codewords: i32, ec_blocks: &ECB) -> Self { - Self { - ec_codewords: ec_codewords, - ec_blocks: vec![ec_blocks], - } - } - - fn new(ec_codewords: i32, ec_blocks1: &ECB, ec_blocks2: &ECB) -> ECBlocks { - Self { - ec_codewords: ec_codewords, - ec_blocks: vec![ec_blocks1, ec_blocks2], - } - } - - fn get_e_c_codewords(&self) -> i32 { - return self.ec_codewords; - } - - fn get_e_c_blocks(&self) -> Vec { - return self.ec_blocks; - } -} - -/** -*

Encapsulates the parameters for one error-correction block in one symbol version. -* This includes the number of data codewords, and the number of times a block with these -* parameters is used consecutively in the Data Matrix code version's format.

-*/ -struct ECB { - count: i32, - - data_codewords: i32, -} - -impl ECB { - fn new(count: i32, data_codewords: i32) -> Self { - Self { - count, - data_codewords, - } - } - - fn get_count(&self) -> i32 { - return self.count; - } - - fn get_data_codewords(&self) -> i32 { - return self.data_codewords; - } -} diff --git a/src/datamatrix/detector.rs b/src/datamatrix/detector.rs deleted file mode 100644 index ced3adb..0000000 --- a/src/datamatrix/detector.rs +++ /dev/null @@ -1,363 +0,0 @@ -use crate::common::detector::WhiteRectangleDetector; -use crate::common::{BitMatrix, DetectorResult, GridSampler}; -use crate::{NotFoundException, ResultPoint}; - -// Detector.java -/** - *

Encapsulates logic that can detect a Data Matrix Code in an image, even if the Data Matrix Code - * is rotated or skewed, or partially obscured.

- * - * @author Sean Owen - */ -pub struct Detector { - image: BitMatrix, - - rectangle_detector: WhiteRectangleDetector, -} - -impl Detector { - pub fn new(image: &BitMatrix) -> Result { - let d: Self; - d.image = image; - d.rectangle_detector = WhiteRectangleDetector::new(image, None, None, None); - - Ok(d) - } - - /** - *

Detects a Data Matrix Code in an image.

- * - * @return {@link DetectorResult} encapsulating results of detecting a Data Matrix Code - * @throws NotFoundException if no Data Matrix Code can be found - */ - pub fn detect(&self) -> Result { - let corner_points: Vec = self.rectangle_detector.detect(); - let mut points: Vec = self.detect_solid1(&corner_points); - points = self.detect_solid2(points?); - points[3] = self.correct_top_right(points?); - if points[3] == null { - return Err(NotFoundException::get_not_found_instance()); - } - points = self.shift_to_module_center(points?); - let top_left: ResultPoint = points[0]; - let bottom_left: ResultPoint = points[1]; - let bottom_right: ResultPoint = points[2]; - let top_right: ResultPoint = points[3]; - let dimension_top: i32 = self.transitions_between(&top_left, &top_right) + 1; - let dimension_right: i32 = self.transitions_between(&bottom_right, &top_right) + 1; - if (dimension_top & 0x01) == 1 { - dimension_top += 1; - } - if (dimension_right & 0x01) == 1 { - dimension_right += 1; - } - if 4 * dimension_top < 6 * dimension_right && 4 * dimension_right < 6 * dimension_top { - // The matrix is square - dimension_top = dimension_right = Math::max(dimension_top, dimension_right); - } - let bits: BitMatrix = ::sample_grid( - self.image, - top_left, - bottom_left, - bottom_right, - top_right, - dimension_top, - dimension_right, - ); - return Ok(DetectorResult::new( - bits, - vec![top_left, bottom_left, bottom_right, top_right], - )); - } - - fn shift_point(point: &ResultPoint, to: &ResultPoint, div: i32) -> ResultPoint { - let x: f32 = (to.get_x() - point.get_x()) / (div + 1); - let y: f32 = (to.get_y() - point.get_y()) / (div + 1); - return ResultPoint::new(point.get_x() + x, point.get_y() + y); - } - - fn move_away(point: &ResultPoint, from_x: f32, from_y: f32) -> ResultPoint { - let mut x: f32 = point.get_x(); - let mut y: f32 = point.get_y(); - if x < from_x { - x -= 1.0; - } else { - x += 1.0; - } - if y < from_y { - y -= 1.0; - } else { - y += 1.0; - } - return ResultPoint::new(x, y); - } - - /** - * Detect a solid side which has minimum transition. - */ - fn detect_solid1(&self, corner_points: &Vec) -> Vec { - // 0 2 - // 1 3 - let point_a: ResultPoint = corner_points[0]; - let point_b: ResultPoint = corner_points[1]; - let point_c: ResultPoint = corner_points[3]; - let point_d: ResultPoint = corner_points[2]; - let tr_a_b: i32 = self.transitions_between(&point_a, &point_b); - let tr_b_c: i32 = self.transitions_between(&point_b, &point_c); - let tr_c_d: i32 = self.transitions_between(&point_c, &point_d); - let tr_d_a: i32 = self.transitions_between(&point_d, &point_a); - // 0..3 - // : : - // 1--2 - let mut min: i32 = tr_a_b; - let mut points: vec![Vec; 4] = vec![point_d, point_a, point_b, point_c]; - if min > tr_b_c { - min = tr_b_c; - points[0] = point_a; - points[1] = point_b; - points[2] = point_c; - points[3] = point_d; - } - if min > tr_c_d { - min = tr_c_d; - points[0] = point_b; - points[1] = point_c; - points[2] = point_d; - points[3] = point_a; - } - if min > tr_d_a { - points[0] = point_c; - points[1] = point_d; - points[2] = point_a; - points[3] = point_b; - } - return points; - } - - /** - * Detect a second solid side next to first solid side. - */ - fn detect_solid2(&self, points: &Vec) -> Vec { - // A..D - // : : - // B--C - let point_a: ResultPoint = points[0]; - let point_b: ResultPoint = points[1]; - let point_c: ResultPoint = points[2]; - let point_d: ResultPoint = points[3]; - // Transition detection on the edge is not stable. - // To safely detect, shift the points to the module center. - let tr: i32 = self.transitions_between(&point_a, &point_d); - let point_bs: ResultPoint = ::shift_point(point_b, point_c, (tr + 1) * 4); - let point_cs: ResultPoint = ::shift_point(point_c, point_b, (tr + 1) * 4); - let tr_b_a: i32 = self.transitions_between(&point_bs, &point_a); - let tr_c_d: i32 = self.transitions_between(&point_cs, &point_d); - // 1--2 - if tr_b_a < tr_c_d { - // solid sides: A-B-C - points[0] = point_a; - points[1] = point_b; - points[2] = point_c; - points[3] = point_d; - } else { - // solid sides: B-C-D - points[0] = point_b; - points[1] = point_c; - points[2] = point_d; - points[3] = point_a; - } - return points; - } - - /** - * Calculates the corner position of the white top right module. - */ - fn correct_top_right(&self, points: &Vec) -> ResultPoint { - // A..D - // | : - // B--C - let point_a: ResultPoint = points[0]; - let point_b: ResultPoint = points[1]; - let point_c: ResultPoint = points[2]; - let point_d: ResultPoint = points[3]; - // shift points for safe transition detection. - let tr_top: i32 = self.transitions_between(&point_a, &point_d); - let tr_right: i32 = self.transitions_between(&point_b, &point_d); - let point_as: ResultPoint = ::shift_point(point_a, point_b, (tr_right + 1) * 4); - let point_cs: ResultPoint = ::shift_point(point_c, point_b, (tr_top + 1) * 4); - tr_top = self.transitions_between(&point_as, &point_d); - tr_right = self.transitions_between(&point_cs, &point_d); - let candidate1: ResultPoint = ResultPoint::new( - point_d.get_x() + (point_c.get_x() - point_b.get_x()) / (tr_top + 1), - point_d.get_y() + (point_c.get_y() - point_b.get_y()) / (tr_top + 1), - ); - let candidate2: ResultPoint = ResultPoint::new( - point_d.get_x() + (point_a.get_x() - point_b.get_x()) / (tr_right + 1), - point_d.get_y() + (point_a.get_y() - point_b.get_y()) / (tr_right + 1), - ); - if !self.is_valid(&candidate1) { - if self.is_valid(&candidate2) { - return candidate2; - } - return null; - } - if !self.is_valid(&candidate2) { - return candidate1; - } - let sumc1: i32 = self.transitions_between(&point_as, &candidate1) - + self.transitions_between(&point_cs, &candidate1); - let sumc2: i32 = self.transitions_between(&point_as, &candidate2) - + self.transitions_between(&point_cs, &candidate2); - if sumc1 > sumc2 { - return candidate1; - } else { - return candidate2; - } - } - - /** - * Shift the edge points to the module center. - */ - fn shift_to_module_center(&self, points: &Vec) -> Vec { - // A..D - // | : - // B--C - let point_a: ResultPoint = points[0]; - let point_b: ResultPoint = points[1]; - let point_c: ResultPoint = points[2]; - let point_d: ResultPoint = points[3]; - // calculate pseudo dimensions - let dim_h: i32 = self.transitions_between(&point_a, &point_d) + 1; - let dim_v: i32 = self.transitions_between(&point_c, &point_d) + 1; - // shift points for safe dimension detection - let point_as: ResultPoint = ::shift_point(point_a, point_b, dim_v * 4); - let point_cs: ResultPoint = ::shift_point(point_c, point_b, dim_h * 4); - // calculate more precise dimensions - dim_h = self.transitions_between(&point_as, &point_d) + 1; - dim_v = self.transitions_between(&point_cs, &point_d) + 1; - if (dim_h & 0x01) == 1 { - dim_h += 1; - } - if (dim_v & 0x01) == 1 { - dim_v += 1; - } - // WhiteRectangleDetector returns points inside of the rectangle. - // I want points on the edges. - let center_x: f32 = - (point_a.get_x() + point_b.get_x() + point_c.get_x() + point_d.get_x()) / 4; - let center_y: f32 = - (point_a.get_y() + point_b.get_y() + point_c.get_y() + point_d.get_y()) / 4; - point_a = ::move_away(point_a, center_x, center_y); - point_b = ::move_away(point_b, center_x, center_y); - point_c = ::move_away(point_c, center_x, center_y); - point_d = ::move_away(point_d, center_x, center_y); - let point_bs: ResultPoint; - let point_ds: ResultPoint; - // shift points to the center of each modules - point_as = ::shift_point(point_a, point_b, dim_v * 4); - point_as = ::shift_point(point_as, point_d, dim_h * 4); - point_bs = ::shift_point(point_b, point_a, dim_v * 4); - point_bs = ::shift_point(point_bs, point_c, dim_h * 4); - point_cs = ::shift_point(point_c, point_d, dim_v * 4); - point_cs = ::shift_point(point_cs, point_b, dim_h * 4); - point_ds = ::shift_point(point_d, point_c, dim_v * 4); - point_ds = ::shift_point(point_ds, point_a, dim_h * 4); - return vec![point_as, point_bs, point_cs, point_ds]; - } - - fn is_valid(&self, p: &ResultPoint) -> bool { - return p.get_x() >= 0 - && p.get_x() <= self.image.get_width() - 1 - && p.get_y() > 0 - && p.get_y() <= self.image.get_height() - 1; - } - - fn sample_grid( - image: &BitMatrix, - top_left: &ResultPoint, - bottom_left: &ResultPoint, - bottom_right: &ResultPoint, - top_right: &ResultPoint, - dimension_x: i32, - dimension_y: i32, - ) -> Result> { - let sampler: GridSampler = GridSampler::get_instance(); - return Ok(sampler.sample_grid( - image, - dimension_x, - dimension_y, - 0.5f32, - 0.5f32, - dimension_x - 0.5f32, - 0.5f32, - dimension_x - 0.5f32, - dimension_y - 0.5f32, - 0.5f32, - dimension_y - 0.5f32, - &top_left.get_x(), - &top_left.get_y(), - &top_right.get_x(), - &top_right.get_y(), - &bottom_right.get_x(), - &bottom_right.get_y(), - &bottom_left.get_x(), - &bottom_left.get_y(), - )); - } - - /** - * Counts the number of black/white transitions between two points, using something like Bresenham's algorithm. - */ - fn transitions_between(&self, from: &ResultPoint, to: &ResultPoint) -> i32 { - // See QR Code Detector, sizeOfBlackWhiteBlackRun() - let from_x: i32 = from.get_x() as i32; - let from_y: i32 = from.get_y() as i32; - let to_x: i32 = to.get_x() as i32; - let to_y: i32 = Math::min(self.image.get_height() - 1, to.get_y() as i32); - let steep: bool = Math::abs(to_y - from_y) > Math::abs(to_x - from_x); - if steep { - let mut temp: i32 = from_x; - from_x = from_y; - from_y = temp; - temp = to_x; - to_x = to_y; - to_y = temp; - } - let dx: i32 = Math::abs(to_x - from_x); - let dy: i32 = Math::abs(to_y - from_y); - let mut error: i32 = -dx / 2; - let ystep: i32 = if from_y < to_y { 1 } else { -1 }; - let xstep: i32 = if from_x < to_x { 1 } else { -1 }; - let mut transitions: i32 = 0; - let in_black: bool = self.image.get( - if steep { from_y } else { from_x }, - if steep { from_x } else { from_y }, - ); - { - let mut x: i32 = from_x; - let mut y: i32 = from_y; - while x != to_x { - { - let is_black: bool = self - .image - .get(if steep { y } else { x }, if steep { x } else { y }); - if is_black != in_black { - transitions += 1; - in_black = is_black; - } - error += dy; - if error > 0 { - if y == to_y { - break; - } - y += ystep; - error -= dx; - } - } - x += xstep; - } - } - - return transitions; - } -} diff --git a/src/datamatrix/encoder.rs b/src/datamatrix/encoder.rs deleted file mode 100644 index f9ea8f2..0000000 --- a/src/datamatrix/encoder.rs +++ /dev/null @@ -1,3329 +0,0 @@ -use crate::common::MinimalECIInput; -use crate::Dimension; - -type CharSequence = Vec; - -// ASCIIEncoder.java - -struct ASCIIEncoder {} - -impl Encoder for ASCIIEncoder {} - -impl ASCIIEncoder { - pub fn get_encoding_mode(&self) -> i32 { - return HighLevelEncoder::ASCII_ENCODATION; - } - - pub fn encode(&self, context: &EncoderContext) { - //step B - let n: i32 = HighLevelEncoder::determine_consecutive_digit_count( - &context.get_message(), - context.pos, - ); - if n >= 2 { - context.write_codeword(&::encode_a_s_c_i_i_digits( - &context.get_message().char_at(context.pos), - &context.get_message().char_at(context.pos + 1), - )); - context.pos += 2; - } else { - let c: char = context.get_current_char(); - let new_mode: i32 = HighLevelEncoder::look_ahead_test( - &context.get_message(), - context.pos, - &self.get_encoding_mode(), - ); - if new_mode != self.get_encoding_mode() { - match new_mode { - HighLevelEncoder::BASE256_ENCODATION => { - context.write_codeword(HighLevelEncoder::LATCH_TO_BASE256); - context.signal_encoder_change(HighLevelEncoder::BASE256_ENCODATION); - return; - } - HighLevelEncoder::C40_ENCODATION => { - context.write_codeword(HighLevelEncoder::LATCH_TO_C40); - context.signal_encoder_change(HighLevelEncoder::C40_ENCODATION); - return; - } - HighLevelEncoder::X12_ENCODATION => { - context.write_codeword(HighLevelEncoder::LATCH_TO_ANSIX12); - context.signal_encoder_change(HighLevelEncoder::X12_ENCODATION); - } - HighLevelEncoder::TEXT_ENCODATION => { - context.write_codeword(HighLevelEncoder::LATCH_TO_TEXT); - context.signal_encoder_change(HighLevelEncoder::TEXT_ENCODATION); - } - HighLevelEncoder::EDIFACT_ENCODATION => { - context.write_codeword(HighLevelEncoder::LATCH_TO_EDIFACT); - context.signal_encoder_change(HighLevelEncoder::EDIFACT_ENCODATION); - } - _ => { - return Err(IllegalStateException::new(format!( - "Illegal mode: {}", - new_mode - ))); - } - } - } else if HighLevelEncoder::is_extended_a_s_c_i_i(c) { - context.write_codeword(HighLevelEncoder::UPPER_SHIFT); - context.write_codeword((c - 128 + 1) as char); - context.pos += 1; - } else { - context.write_codeword((c + 1) as char); - context.pos += 1; - } - } - } - - fn encode_a_s_c_i_i_digits(digit1: char, digit2: char) -> char { - if HighLevelEncoder::is_digit(digit1) && HighLevelEncoder::is_digit(digit2) { - let num: i32 = (digit1 - 48) * 10 + (digit2 - 48); - return (num + 130) as char; - } - return Err(IllegalArgumentException::new(format!( - "not digits: {}{}", - digit1, digit2 - ))); - } -} - -// Base256Encoder.java -struct Base256Encoder {} - -impl Encoder for Base256Encoder {} - -impl Base256Encoder { - pub fn get_encoding_mode(&self) -> i32 { - return HighLevelEncoder::BASE256_ENCODATION; - } - - pub fn encode(&self, context: &EncoderContext) { - let buffer: StringBuilder = StringBuilder::new(); - //Initialize length field - buffer.append('\0'); - while context.has_more_characters() { - let c: char = context.get_current_char(); - buffer.append(c); - context.pos += 1; - let new_mode: i32 = HighLevelEncoder::look_ahead_test( - &context.get_message(), - context.pos, - &self.get_encoding_mode(), - ); - if new_mode != self.get_encoding_mode() { - // Return to ASCII encodation, which will actually handle latch to new mode - context.signal_encoder_change(HighLevelEncoder::ASCII_ENCODATION); - break; - } - } - let data_count: i32 = buffer.length() - 1; - let length_field_size: i32 = 1; - let current_size: i32 = context.get_codeword_count() + data_count + length_field_size; - context.update_symbol_info(current_size); - let must_pad: bool = (context.get_symbol_info().get_data_capacity() - current_size) > 0; - if context.has_more_characters() || must_pad { - if data_count <= 249 { - buffer.set_char_at(0, data_count as char); - } else if data_count <= 1555 { - buffer.set_char_at(0, ((data_count / 250) + 249) as char); - buffer.insert(1, (data_count % 250) as char); - } else { - return Err(IllegalStateException::new(format!( - "Message length not in valid ranges: {}", - data_count - ))); - } - } - { - let mut i: i32 = 0; - let c: i32 = buffer.length(); - while i < c { - { - context.write_codeword(&::randomize255_state( - &buffer.char_at(i), - context.get_codeword_count() + 1, - )); - } - i += 1; - } - } - } - - fn randomize255_state(ch: char, codeword_position: i32) -> char { - let pseudo_random: i32 = ((149 * codeword_position) % 255) + 1; - let temp_variable: i32 = ch + pseudo_random; - if temp_variable <= 255 { - return temp_variable as char; - } else { - return (temp_variable - 256) as char; - } - } -} - -// C40Encoder.java -struct C40Encoder {} - -impl Encoder for C40Encoder {} - -impl C40Encoder { - pub fn get_encoding_mode(&self) -> i32 { - return HighLevelEncoder::C40_ENCODATION; - } - - fn encode_maximal(&self, context: &EncoderContext) { - let buffer: StringBuilder = StringBuilder::new(); - let last_char_size: i32 = 0; - let backtrack_start_position: i32 = context.pos; - let backtrack_buffer_length: i32 = 0; - while context.has_more_characters() { - let c: char = context.get_current_char(); - context.pos += 1; - last_char_size = self.encode_char(c, &buffer); - if buffer.length() % 3 == 0 { - backtrack_start_position = context.pos; - backtrack_buffer_length = buffer.length(); - } - } - if backtrack_buffer_length != buffer.length() { - let unwritten: i32 = (buffer.length() / 3) * 2; - // +1 for the latch to C40 - let cur_codeword_count: i32 = context.get_codeword_count() + unwritten + 1; - context.update_symbol_info(cur_codeword_count); - let available: i32 = context.get_symbol_info().get_data_capacity() - cur_codeword_count; - let rest: i32 = buffer.length() % 3; - if (rest == 2 && available != 2) - || (rest == 1 && (last_char_size > 3 || available != 1)) - { - buffer.set_length(backtrack_buffer_length); - context.pos = backtrack_start_position; - } - } - if buffer.length() > 0 { - context.write_codeword(HighLevelEncoder::LATCH_TO_C40); - } - self.handle_e_o_d(context, &buffer); - } - - pub fn encode(&self, context: &EncoderContext) { - //step C - let buffer: StringBuilder = StringBuilder::new(); - while context.has_more_characters() { - let c: char = context.get_current_char(); - context.pos += 1; - let last_char_size: i32 = self.encode_char(c, &buffer); - let unwritten: i32 = (buffer.length() / 3) * 2; - let cur_codeword_count: i32 = context.get_codeword_count() + unwritten; - context.update_symbol_info(cur_codeword_count); - let available: i32 = context.get_symbol_info().get_data_capacity() - cur_codeword_count; - if !context.has_more_characters() { - //Avoid having a single C40 value in the last triplet - let removed: StringBuilder = StringBuilder::new(); - if (buffer.length() % 3) == 2 && available != 2 { - last_char_size = - self.backtrack_one_character(context, &buffer, &removed, last_char_size); - } - while (buffer.length() % 3) == 1 && (last_char_size > 3 || available != 1) { - last_char_size = - self.backtrack_one_character(context, &buffer, &removed, last_char_size); - } - break; - } - let count: i32 = buffer.length(); - if (count % 3) == 0 { - let new_mode: i32 = HighLevelEncoder::look_ahead_test( - &context.get_message(), - context.pos, - &self.get_encoding_mode(), - ); - if new_mode != self.get_encoding_mode() { - // Return to ASCII encodation, which will actually handle latch to new mode - context.signal_encoder_change(HighLevelEncoder::ASCII_ENCODATION); - break; - } - } - } - self.handle_e_o_d(context, &buffer); - } - - fn backtrack_one_character( - &self, - context: &EncoderContext, - buffer: &StringBuilder, - removed: &StringBuilder, - last_char_size: i32, - ) -> i32 { - let count: i32 = buffer.length(); - buffer.delete(count - last_char_size, count); - context.pos -= 1; - let c: char = context.get_current_char(); - last_char_size = self.encode_char(c, &removed); - //Deal with possible reduction in symbol size - context.reset_symbol_info(); - return last_char_size; - } - - fn write_next_triplet(context: &EncoderContext, buffer: &StringBuilder) { - context.write_codewords(&::encode_to_codewords(&buffer)); - buffer.delete(0, 3); - } - - /** - * Handle "end of data" situations - * - * @param context the encoder context - * @param buffer the buffer with the remaining encoded characters - */ - fn handle_e_o_d(&self, context: &EncoderContext, buffer: &StringBuilder) { - let unwritten: i32 = (buffer.length() / 3) * 2; - let rest: i32 = buffer.length() % 3; - let cur_codeword_count: i32 = context.get_codeword_count() + unwritten; - context.update_symbol_info(cur_codeword_count); - let available: i32 = context.get_symbol_info().get_data_capacity() - cur_codeword_count; - if rest == 2 { - //Shift 1 - buffer.append('\0'); - while buffer.length() >= 3 { - ::write_next_triplet(context, &buffer); - } - if context.has_more_characters() { - context.write_codeword(HighLevelEncoder::C40_UNLATCH); - } - } else if available == 1 && rest == 1 { - while buffer.length() >= 3 { - ::write_next_triplet(context, &buffer); - } - if context.has_more_characters() { - context.write_codeword(HighLevelEncoder::C40_UNLATCH); - } - // else no unlatch - context.pos -= 1; - } else if rest == 0 { - while buffer.length() >= 3 { - ::write_next_triplet(context, &buffer); - } - if available > 0 || context.has_more_characters() { - context.write_codeword(HighLevelEncoder::C40_UNLATCH); - } - } else { - return Err(IllegalStateException::new( - "Unexpected case. Please report!", - )); - } - context.signal_encoder_change(HighLevelEncoder::ASCII_ENCODATION); - } - - fn encode_char(&self, c: char, sb: &StringBuilder) -> i32 { - if c == ' ' { - sb.append('\u{0003}'); - return 1; - } - if c >= '0' && c <= '9' { - sb.append((c - 48 + 4) as char); - return 1; - } - if c >= 'A' && c <= 'Z' { - sb.append((c - 65 + 14) as char); - return 1; - } - if c < ' ' { - //Shift 1 Set - sb.append('\0'); - sb.append(c); - return 2; - } - if c <= '/' { - //Shift 2 Set - sb.append('\u{0001}'); - sb.append((c - 33) as char); - return 2; - } - if c <= '@' { - //Shift 2 Set - sb.append('\u{0001}'); - sb.append((c - 58 + 15) as char); - return 2; - } - if c <= '_' { - //Shift 2 Set - sb.append('\u{0001}'); - sb.append((c - 91 + 22) as char); - return 2; - } - if c <= 127 { - //Shift 3 Set - sb.append('\u{0002}'); - sb.append((c - 96) as char); - return 2; - } - //Shift 2, Upper Shift - sb.append("\u{0001}\u{001e}"); - let mut len: i32 = 2; - len += self.encode_char((c - 128) as char, &sb); - return len; - } - - fn encode_to_codewords(sb: &CharSequence) -> String { - let v: i32 = (1600 * sb.char_at(0)) + (40 * sb.char_at(1)) + sb.char_at(2) + 1; - let cw1: char = (v / 256) as char; - let cw2: char = (v % 256) as char; - - String::from(vec![cw1, cw2]) - } -} - -// DataMatrixSymbolInfo144.java -struct DataMatrixSymbolInfo144 { - super_type: SymbolInfo, -} - -impl DataMatrixSymbolInfo144 { - fn new() -> Self { - Self { - super_type: SymbolInfo::new(false, 1558, 620, 22, 22, 36, -1, 62), - } - } - - pub fn get_interleaved_block_count(&self) -> i32 { - return 10; - } - - pub fn get_data_length_for_interleaved_block(&self, index: i32) -> i32 { - return if (index <= 8) { 156 } else { 155 }; - } -} - -// DefaultPlacement.java -/** - * Symbol Character Placement Program. Adapted from Annex M.1 in ISO/IEC 16022:2000(E). - */ -pub struct DefaultPlacement { - codewords: CharSequence, - - numrows: i32, - - numcols: i32, - - bits: Vec, -} - -impl DefaultPlacement { - /** - * Main constructor - * - * @param codewords the codewords to place - * @param numcols the number of columns - * @param numrows the number of rows - */ - pub fn new(codewords: &CharSequence, numcols: i32, numrows: i32) -> Self { - let new_dp: DefaultPlacement; - new_dp.codewords = codewords; - new_dp.numcols = numcols; - new_dp.numrows = numrows; - new_dp.bits = [-1; numcols * numrows]; - - new_dp - } - - fn get_numrows(&self) -> i32 { - return self.numrows; - } - - fn get_numcols(&self) -> i32 { - return self.numcols; - } - - fn get_bits(&self) -> Vec { - return self.bits; - } - - pub fn get_bit(&self, col: i32, row: i32) -> bool { - return self.bits[row * self.numcols + col] == 1; - } - - fn set_bit(&self, col: i32, row: i32, bit: bool) { - self.bits[row * self.numcols + col] = (if bit { 1 } else { 0 }) as i8; - } - - fn no_bit(&self, col: i32, row: i32) -> bool { - return self.bits[row * self.numcols + col] < 0; - } - - pub fn place(&self) { - let mut pos: i32 = 0; - let mut row: i32 = 4; - let mut col: i32 = 0; - loop { - { - // repeatedly first check for one of the special corner cases, then... - if (row == self.numrows) && (col == 0) { - self.corner1(pos += 1); - } - if (row == self.numrows - 2) && (col == 0) && ((self.numcols % 4) != 0) { - self.corner2(pos += 1); - } - if (row == self.numrows - 2) && (col == 0) && (self.numcols % 8 == 4) { - self.corner3(pos += 1); - } - if (row == self.numrows + 4) && (col == 2) && ((self.numcols % 8) == 0) { - self.corner4(pos += 1); - } - // sweep upward diagonally, inserting successive characters... - loop { - { - if (row < self.numrows) && (col >= 0) && self.no_bit(col, row) { - self.utah(row, col, pos += 1); - } - row -= 2; - col += 2; - } - if !(row >= 0 && (col < self.numcols)) { - break; - } - } - row += 1; - col += 3; - // and then sweep downward diagonally, inserting successive characters, ... - loop { - { - if (row >= 0) && (col < self.numcols) && self.no_bit(col, row) { - self.utah(row, col, pos += 1); - } - row += 2; - col -= 2; - } - if !((row < self.numrows) && (col >= 0)) { - break; - } - } - row += 3; - col += 1; - // ...until the entire array is scanned - } - if !((row < self.numrows) || (col < self.numcols)) { - break; - } - } - // Lastly, if the lower right-hand corner is untouched, fill in fixed pattern - if self.no_bit(self.numcols - 1, self.numrows - 1) { - self.set_bit(self.numcols - 1, self.numrows - 1, true); - self.set_bit(self.numcols - 2, self.numrows - 2, true); - } - } - - fn module(&self, row: i32, col: i32, pos: i32, bit: i32) { - if row < 0 { - row += self.numrows; - col += 4 - ((self.numrows + 4) % 8); - } - if col < 0 { - col += self.numcols; - row += 4 - ((self.numcols + 4) % 8); - } - // Note the conversion: - let mut v: i32 = self.codewords.char_at(pos); - v &= 1 << (8 - bit); - self.set_bit(col, row, v != 0); - } - - /** - * Places the 8 bits of a utah-shaped symbol character in ECC200. - * - * @param row the row - * @param col the column - * @param pos character position - */ - fn utah(&self, row: i32, col: i32, pos: i32) { - self.module(row - 2, col - 2, pos, 1); - self.module(row - 2, col - 1, pos, 2); - self.module(row - 1, col - 2, pos, 3); - self.module(row - 1, col - 1, pos, 4); - self.module(row - 1, col, pos, 5); - self.module(row, col - 2, pos, 6); - self.module(row, col - 1, pos, 7); - self.module(row, col, pos, 8); - } - - fn corner1(&self, pos: i32) { - self.module(self.numrows - 1, 0, pos, 1); - self.module(self.numrows - 1, 1, pos, 2); - self.module(self.numrows - 1, 2, pos, 3); - self.module(0, self.numcols - 2, pos, 4); - self.module(0, self.numcols - 1, pos, 5); - self.module(1, self.numcols - 1, pos, 6); - self.module(2, self.numcols - 1, pos, 7); - self.module(3, self.numcols - 1, pos, 8); - } - - fn corner2(&self, pos: i32) { - self.module(self.numrows - 3, 0, pos, 1); - self.module(self.numrows - 2, 0, pos, 2); - self.module(self.numrows - 1, 0, pos, 3); - self.module(0, self.numcols - 4, pos, 4); - self.module(0, self.numcols - 3, pos, 5); - self.module(0, self.numcols - 2, pos, 6); - self.module(0, self.numcols - 1, pos, 7); - self.module(1, self.numcols - 1, pos, 8); - } - - fn corner3(&self, pos: i32) { - self.module(self.numrows - 3, 0, pos, 1); - self.module(self.numrows - 2, 0, pos, 2); - self.module(self.numrows - 1, 0, pos, 3); - self.module(0, self.numcols - 2, pos, 4); - self.module(0, self.numcols - 1, pos, 5); - self.module(1, self.numcols - 1, pos, 6); - self.module(2, self.numcols - 1, pos, 7); - self.module(3, self.numcols - 1, pos, 8); - } - - fn corner4(&self, pos: i32) { - self.module(self.numrows - 1, 0, pos, 1); - self.module(self.numrows - 1, self.numcols - 1, pos, 2); - self.module(0, self.numcols - 3, pos, 3); - self.module(0, self.numcols - 2, pos, 4); - self.module(0, self.numcols - 1, pos, 5); - self.module(1, self.numcols - 3, pos, 6); - self.module(1, self.numcols - 2, pos, 7); - self.module(1, self.numcols - 1, pos, 8); - } -} - -// EdifactEncoder.java -struct EdifactEncoder {} - -impl Encoder for EdifactEncoder {} - -impl EdifactEncoder { - pub fn get_encoding_mode(&self) -> i32 { - return HighLevelEncoder::EDIFACT_ENCODATION; - } - - pub fn encode(&self, context: &EncoderContext) { - //step F - let buffer: StringBuilder = StringBuilder::new(); - while context.has_more_characters() { - let c: char = context.get_current_char(); - ::encode_char(c, &buffer); - context.pos += 1; - let count: i32 = buffer.length(); - if count >= 4 { - context.write_codewords(&::encode_to_codewords(&buffer)); - buffer.delete(0, 4); - let new_mode: i32 = HighLevelEncoder::look_ahead_test( - &context.get_message(), - context.pos, - &self.get_encoding_mode(), - ); - if new_mode != self.get_encoding_mode() { - // Return to ASCII encodation, which will actually handle latch to new mode - context.signal_encoder_change(HighLevelEncoder::ASCII_ENCODATION); - break; - } - } - } - //Unlatch - buffer.append(31 as char); - ::handle_e_o_d(context, &buffer); - } - - /** - * Handle "end of data" situations - * - * @param context the encoder context - * @param buffer the buffer with the remaining encoded characters - */ - fn handle_e_o_d(context: &EncoderContext, buffer: &CharSequence) { - let count: i32 = buffer.length(); - if count == 0 { - //Already finished - return; - } - if count == 1 { - //Only an unlatch at the end - context.update_symbol_info_simple(); - let mut available: i32 = - context.get_symbol_info().get_data_capacity() - context.get_codeword_count(); - let remaining: i32 = context.get_remaining_characters(); - // The following two lines are a hack inspired by the 'fix' from https://sourceforge.net/p/barcode4j/svn/221/ - if remaining > available { - context.update_symbol_info(context.get_codeword_count() + 1); - available = - context.get_symbol_info().get_data_capacity() - context.get_codeword_count(); - } - if remaining <= available && available <= 2 { - //No unlatch - return; - } - } - if count > 4 { - return Err(IllegalStateException::new("Count must not exceed 4")); - } - let rest_chars: i32 = count - 1; - let encoded: String = ::encode_to_codewords(&buffer); - let end_of_symbol_reached: bool = !context.has_more_characters(); - let rest_in_ascii: bool = end_of_symbol_reached && rest_chars <= 2; - if rest_chars <= 2 { - context.update_symbol_info(context.get_codeword_count() + rest_chars); - let available: i32 = - context.get_symbol_info().get_data_capacity() - context.get_codeword_count(); - if available >= 3 { - rest_in_ascii = false; - context.update_symbol_info(context.get_codeword_count() + encoded.length()); - //available = context.symbolInfo.dataCapacity - context.getCodewordCount(); - } - } - if rest_in_ascii { - context.reset_symbol_info(); - context.pos -= rest_chars; - } else { - context.write_codewords(&encoded); - } - - context.signal_encoder_change(HighLevelEncoder::ASCII_ENCODATION); - } - - fn encode_char(c: char, sb: &StringBuilder) { - if c >= ' ' && c <= '?' { - sb.append(c); - } else if c >= '@' && c <= '^' { - sb.append((c - 64) as char); - } else { - HighLevelEncoder::illegal_character(c); - } - } - - fn encode_to_codewords(sb: &CharSequence) -> String { - let len: i32 = sb.length(); - if len == 0 { - return Err(IllegalStateException::new( - "StringBuilder must not be empty", - )); - } - let c1: char = sb.char_at(0); - let c2: char = if len >= 2 { sb.char_at(1) } else { 0 }; - let c3: char = if len >= 3 { sb.char_at(2) } else { 0 }; - let c4: char = if len >= 4 { sb.char_at(3) } else { 0 }; - let v: i32 = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4; - let cw1: char = ((v >> 16) & 255) as char; - let cw2: char = ((v >> 8) & 255) as char; - let cw3: char = (v & 255) as char; - let res: StringBuilder = StringBuilder::new(3); - res.append(cw1); - if len >= 2 { - res.append(cw2); - } - if len >= 3 { - res.append(cw3); - } - return res.to_string(); - } -} - -// Encoder.java -trait Encoder { - fn get_encoding_mode(&self) -> i32; - - fn encode(&self, context: &EncoderContext); -} - -// EncoderContext.java -struct EncoderContext { - msg: String, - - shape: SymbolShapeHint, - - min_size: Dimension, - - max_size: Dimension, - - codewords: StringBuilder, - - pos: i32, - - new_encoding: i32, - - symbol_info: SymbolInfo, - - skip_at_end: i32, -} - -impl EncoderContext { - fn new(msg: &String) -> Self { - //From this point on Strings are not Unicode anymore! - let msg_binary: Vec = msg.get_bytes(StandardCharsets::ISO_8859_1); - let sb: StringBuilder = StringBuilder::new(msg_binary.len()); - { - let mut i: i32 = 0; - let c: i32 = msg_binary.len(); - while i < c { - { - let ch: char = (msg_binary[i] & 0xff) as char; - if ch == '?' && msg.char_at(i) != '?' { - return Err(IllegalArgumentException::new( - "Message contains characters outside ISO-8859-1 encoding.", - )); - } - sb.append(ch); - } - i += 1; - } - } - - let new_ec: Self; - //Not Unicode here! - new_ec.msg = sb.to_string(); - shape = SymbolShapeHint::FORCE_NONE; - new_ec.codewords = StringBuilder::new(&msg.length()); - new_encoding = -1; - - new_ec - } - - pub fn set_symbol_shape(&self, shape: &SymbolShapeHint) { - self.shape = shape; - } - - pub fn set_size_constraints(&self, min_size: &Dimension, max_size: &Dimension) { - self.minSize = min_size; - self.maxSize = max_size; - } - - pub fn get_message(&self) -> String { - return self.msg; - } - - pub fn set_skip_at_end(&self, count: i32) { - self.skipAtEnd = count; - } - - pub fn get_current_char(&self) -> char { - return self.msg.char_at(self.pos); - } - - pub fn get_current(&self) -> char { - return self.msg.char_at(self.pos); - } - - pub fn get_codewords(&self) -> StringBuilder { - return self.codewords; - } - - pub fn write_codewords(&self, codewords: &String) { - self.codewords.append(&codewords); - } - - pub fn write_codeword(&self, codeword: char) { - self.codewords.append(codeword); - } - - pub fn get_codeword_count(&self) -> i32 { - return self.codewords.length(); - } - - pub fn get_new_encoding(&self) -> i32 { - return self.new_encoding; - } - - pub fn signal_encoder_change(&self, encoding: i32) { - self.newEncoding = encoding; - } - - pub fn reset_encoder_signal(&self) { - self.newEncoding = -1; - } - - pub fn has_more_characters(&self) -> bool { - return self.pos < self.get_total_message_char_count(); - } - - fn get_total_message_char_count(&self) -> i32 { - return self.msg.length() - self.skip_at_end; - } - - pub fn get_remaining_characters(&self) -> i32 { - return self.get_total_message_char_count() - self.pos; - } - - pub fn get_symbol_info(&self) -> SymbolInfo { - return self.symbol_info; - } - - pub fn update_symbol_info_simple(&self) { - self.update_symbol_info(&self.get_codeword_count()); - } - - pub fn update_symbol_info(&self, len: i32) { - if self.symbolInfo == null || len > self.symbolInfo.get_data_capacity() { - self.symbolInfo = - SymbolInfo::lookup(len, self.shape, self.min_size, self.max_size, true); - } - } - - pub fn reset_symbol_info(&self) { - self.symbolInfo = null; - } -} - -// ErrorCorrection.java -/** - * Error Correction Code for ECC200. - */ - -/** - * Lookup table which factors to use for which number of error correction codewords. - * See FACTORS. - */ -const FACTOR_SETS: vec![Vec; 16] = - vec![5, 7, 10, 11, 12, 14, 18, 20, 24, 28, 36, 42, 48, 56, 62, 68]; - -/** - * Precomputed polynomial factors for ECC 200. - */ -const FACTORS: vec![vec![Vec>; 68]; 16] = vec![ - vec![228, 48, 15, 111, 62], - vec![23, 68, 144, 134, 240, 92, 254], - vec![28, 24, 185, 166, 223, 248, 116, 255, 110, 61], - vec![175, 138, 205, 12, 194, 168, 39, 245, 60, 97, 120], - vec![41, 153, 158, 91, 61, 42, 142, 213, 97, 178, 100, 242], - vec![ - 156, 97, 192, 252, 95, 9, 157, 119, 138, 45, 18, 186, 83, 185, - ], - vec![ - 83, 195, 100, 39, 188, 75, 66, 61, 241, 213, 109, 129, 94, 254, 225, 48, 90, 188, - ], - vec![ - 15, 195, 244, 9, 233, 71, 168, 2, 188, 160, 153, 145, 253, 79, 108, 82, 27, 174, 186, 172, - ], - vec![ - 52, 190, 88, 205, 109, 39, 176, 21, 155, 197, 251, 223, 155, 21, 5, 172, 254, 124, 12, 181, - 184, 96, 50, 193, - ], - vec![ - 211, 231, 43, 97, 71, 96, 103, 174, 37, 151, 170, 53, 75, 34, 249, 121, 17, 138, 110, 213, - 141, 136, 120, 151, 233, 168, 93, 255, - ], - vec![ - 245, 127, 242, 218, 130, 250, 162, 181, 102, 120, 84, 179, 220, 251, 80, 182, 229, 18, 2, - 4, 68, 33, 101, 137, 95, 119, 115, 44, 175, 184, 59, 25, 225, 98, 81, 112, - ], - vec![ - 77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133, 242, 8, 175, 95, 100, 9, - 167, 105, 214, 111, 57, 121, 21, 1, 253, 57, 54, 101, 248, 202, 69, 50, 150, 177, 226, 5, - 9, 5, - ], - vec![ - 245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, 205, 188, 237, 87, 191, 106, 16, - 147, 118, 23, 37, 90, 170, 205, 131, 88, 120, 100, 66, 138, 186, 240, 82, 44, 176, 87, 187, - 147, 160, 175, 69, 213, 92, 253, 225, 19, - ], - vec![ - 175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192, 215, 235, 150, 159, 36, - 223, 38, 200, 132, 54, 228, 146, 218, 234, 117, 203, 29, 232, 144, 238, 22, 150, 201, 117, - 62, 207, 164, 13, 137, 245, 127, 67, 247, 28, 155, 43, 203, 107, 233, 53, 143, 46, - ], - vec![ - 242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143, 108, 196, 37, 185, 112, 134, - 230, 245, 63, 197, 190, 250, 106, 185, 221, 175, 64, 114, 71, 161, 44, 147, 6, 27, 218, 51, - 63, 87, 10, 40, 130, 188, 17, 163, 31, 176, 170, 4, 107, 232, 7, 94, 166, 224, 124, 86, 47, - 11, 204, - ], - vec![ - 220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36, 73, 127, 213, 136, 248, - 180, 234, 197, 158, 177, 68, 122, 93, 213, 15, 160, 227, 236, 66, 139, 153, 185, 202, 167, - 179, 25, 220, 232, 96, 210, 231, 136, 223, 239, 181, 241, 59, 52, 172, 25, 49, 232, 211, - 189, 64, 54, 108, 153, 132, 63, 96, 103, 82, 186, - ], -]; - -const MODULO_VALUE: i32 = 0x12D; - -pub struct ErrorCorrection { - LOG: Vec, - - ALOG: Vec, -} - -impl ErrorCorrection { - fn new() -> Self { - //Create log and antilog table - let LOG = [0; 256]; - let ALOG = [0; 255]; - let mut p: i32 = 1; - { - let mut i: i32 = 0; - while i < 255 { - { - ALOG[i] = p; - LOG[p] = i; - p *= 2; - if p >= 256 { - p ^= MODULO_VALUE; - } - } - i += 1; - } - } - Self { - LOG: LOG, - ALOG: ALOG, - } - } - - /** - * Creates the ECC200 error correction for an encoded message. - * - * @param codewords the codewords - * @param symbolInfo information about the symbol to be encoded - * @return the codewords with interleaved error correction. - */ - pub fn encode_e_c_c200(codewords: &String, symbol_info: &SymbolInfo) -> String { - if codewords.length() != symbol_info.get_data_capacity() { - return Err(IllegalArgumentException::new( - "The number of codewords does not match the selected symbol", - )); - } - let sb: StringBuilder = - StringBuilder::new(symbol_info.get_data_capacity() + symbol_info.get_error_codewords()); - sb.append(&codewords); - let block_count: i32 = symbol_info.get_interleaved_block_count(); - if block_count == 1 { - let ecc: String = ::create_e_c_c_block(&codewords, &symbol_info.get_error_codewords()); - sb.append(&ecc); - } else { - sb.set_length(&sb.capacity()); - let data_sizes: [i32; block_count] = [0; block_count]; - let error_sizes: [i32; block_count] = [0; block_count]; - { - let mut i: i32 = 0; - while i < block_count { - { - data_sizes[i] = symbol_info.get_data_length_for_interleaved_block(i + 1); - error_sizes[i] = symbol_info.get_error_length_for_interleaved_block(i + 1); - } - i += 1; - } - } - - { - let mut block: i32 = 0; - while block < block_count { - { - let temp: StringBuilder = StringBuilder::new(data_sizes[block]); - { - let mut d: i32 = block; - while d < symbol_info.get_data_capacity() { - { - temp.append(&codewords.char_at(d)); - } - d += block_count; - } - } - - let ecc: String = - ::create_e_c_c_block(&temp.to_string(), error_sizes[block]); - let mut pos: i32 = 0; - { - let mut e: i32 = block; - while e < error_sizes[block] * block_count { - { - sb.set_char_at( - symbol_info.get_data_capacity() + e, - &ecc.char_at(pos += 1), - ); - } - e += block_count; - } - } - } - block += 1; - } - } - } - return sb.to_string(); - } - - fn create_e_c_c_block(codewords: &CharSequence, num_e_c_words: i32) -> String { - let mut table: i32 = -1; - { - let mut i: i32 = 0; - while i < FACTOR_SETS.len() { - { - if FACTOR_SETS[i] == num_e_c_words { - table = i; - break; - } - } - i += 1; - } - } - - if table < 0 { - return Err(IllegalArgumentException::new(format!( - "Illegal number of error correction codewords specified: {}", - num_e_c_words - ))); - } - let poly: Vec = FACTORS[table]; - let mut ecc: [Option; num_e_c_words] = [None; num_e_c_words]; - { - let mut i: i32 = 0; - while i < num_e_c_words { - { - ecc[i] = 0; - } - i += 1; - } - } - - { - let mut i: i32 = 0; - while i < codewords.length() { - { - let m: i32 = ecc[num_e_c_words - 1] ^ codewords.char_at(i); - { - let mut k: i32 = num_e_c_words - 1; - while k > 0 { - { - if m != 0 && poly[k] != 0 { - ecc[k] = - (ecc[k - 1] ^ ALOG[(LOG[m] + LOG[poly[k]]) % 255]) as char; - } else { - ecc[k] = ecc[k - 1]; - } - } - k -= 1; - } - } - - if m != 0 && poly[0] != 0 { - ecc[0] = Some(ALOG[(LOG[m] + LOG[poly[0]]) % 255] as char); - } else { - ecc[0] = 0; - } - } - i += 1; - } - } - - let ecc_reversed: [Option; num_e_c_words] = [None; num_e_c_words]; - { - let mut i: i32 = 0; - while i < num_e_c_words { - { - ecc_reversed[i] = ecc[num_e_c_words - i - 1]; - } - i += 1; - } - } - - return String::value_of(&ecc_reversed); - } -} - -// HighLevelEncoder.java -/** - * DataMatrix ECC 200 data encoder following the algorithm described in ISO/IEC 16022:200(E) in - * annex S. - */ - -/** - * Padding character - */ -const PAD: char = 129; - -/** - * mode latch to C40 encodation mode - */ -const LATCH_TO_C40: char = 230; - -/** - * mode latch to Base 256 encodation mode - */ -const LATCH_TO_BASE256: char = 231; - -/** - * FNC1 Codeword - */ -//private static final char FNC1 = 232; -/** - * Structured Append Codeword - */ -//private static final char STRUCTURED_APPEND = 233; -/** - * Reader Programming - */ -//private static final char READER_PROGRAMMING = 234; -/** - * Upper Shift - */ -const UPPER_SHIFT: char = 235; - -/** - * 05 Macro - */ -const MACRO_05: char = 236; - -/** - * 06 Macro - */ -const MACRO_06: char = 237; - -/** - * mode latch to ANSI X.12 encodation mode - */ -const LATCH_TO_ANSIX12: char = 238; - -/** - * mode latch to Text encodation mode - */ -const LATCH_TO_TEXT: char = 239; - -/** - * mode latch to EDIFACT encodation mode - */ -const LATCH_TO_EDIFACT: char = 240; - -/** - * ECI character (Extended Channel Interpretation) - */ -//private static final char ECI = 241; -/** - * Unlatch from C40 encodation - */ -const C40_UNLATCH: char = 254; - -/** - * Unlatch from X12 encodation - */ -const X12_UNLATCH: char = 254; - -/** - * 05 Macro header - */ -const MACRO_05_HEADER: &'static str = "[)>05"; - -/** - * 06 Macro header - */ -const MACRO_06_HEADER: &'static str = "[)>06"; - -/** - * Macro trailer - */ -const MACRO_TRAILER: &'static str = ""; - -const ASCII_ENCODATION: i32 = 0; - -const C40_ENCODATION: i32 = 1; - -const TEXT_ENCODATION: i32 = 2; - -const X12_ENCODATION: i32 = 3; - -const EDIFACT_ENCODATION: i32 = 4; - -const BASE256_ENCODATION: i32 = 5; -pub struct HighLevelEncoder {} - -impl HighLevelEncoder { - fn new() -> HighLevelEncoder {} - - fn randomize253_state(codeword_position: i32) -> char { - let pseudo_random: i32 = ((149 * codeword_position) % 253) + 1; - let temp_variable: i32 = PAD + pseudo_random; - return (if temp_variable <= 254 { - temp_variable - } else { - temp_variable - 254 - }) as char; - } - - /** - * Performs message encoding of a DataMatrix message using the algorithm described in annex P - * of ISO/IEC 16022:2000(E). - * - * @param msg the message - * @return the encoded message (the char values range from 0 to 255) - */ - pub fn encode_high_level_msg_only(msg: &String) -> String { - return ::encode_high_level(&msg, SymbolShapeHint::FORCE_NONE, null, null, false); - } - - /** - * Performs message encoding of a DataMatrix message using the algorithm described in annex P - * of ISO/IEC 16022:2000(E). - * - * @param msg the message - * @param shape requested shape. May be {@code SymbolShapeHint.FORCE_NONE}, - * {@code SymbolShapeHint.FORCE_SQUARE} or {@code SymbolShapeHint.FORCE_RECTANGLE}. - * @param minSize the minimum symbol size constraint or null for no constraint - * @param maxSize the maximum symbol size constraint or null for no constraint - * @return the encoded message (the char values range from 0 to 255) - */ - pub fn encode_high_level_complex( - msg: &String, - shape: &SymbolShapeHint, - min_size: &Dimension, - max_size: &Dimension, - ) -> String { - return ::encode_high_level(&msg, shape, min_size, max_size, false); - } - - /** - * Performs message encoding of a DataMatrix message using the algorithm described in annex P - * of ISO/IEC 16022:2000(E). - * - * @param msg the message - * @param shape requested shape. May be {@code SymbolShapeHint.FORCE_NONE}, - * {@code SymbolShapeHint.FORCE_SQUARE} or {@code SymbolShapeHint.FORCE_RECTANGLE}. - * @param minSize the minimum symbol size constraint or null for no constraint - * @param maxSize the maximum symbol size constraint or null for no constraint - * @param forceC40 enforce C40 encoding - * @return the encoded message (the char values range from 0 to 255) - */ - pub fn encode_high_level_comples_encforce( - msg: &String, - shape: &SymbolShapeHint, - min_size: &Dimension, - max_size: &Dimension, - force_c40: bool, - ) -> String { - //the codewords 0..255 are encoded as Unicode characters - let c40_encoder: C40Encoder = C40Encoder::new(); - let encoders: vec![Vec; 6] = vec![ - ASCIIEncoder::new(), - c40_encoder, - TextEncoder::new(), - X12Encoder::new(), - EdifactEncoder::new(), - Base256Encoder::new(), - ]; - let mut context: EncoderContext = EncoderContext::new(&msg); - context.set_symbol_shape(shape); - context.set_size_constraints(min_size, max_size); - if msg.starts_with(&MACRO_05_HEADER) && msg.ends_with(&MACRO_TRAILER) { - context.write_codeword(MACRO_05); - context.set_skip_at_end(2); - context.pos += MACRO_05_HEADER::length(); - } else if msg.starts_with(&MACRO_06_HEADER) && msg.ends_with(&MACRO_TRAILER) { - context.write_codeword(MACRO_06); - context.set_skip_at_end(2); - context.pos += MACRO_06_HEADER::length(); - } - //Default mode - let encoding_mode: i32 = ASCII_ENCODATION; - if force_c40 { - c40_encoder.encode_maximal(&context); - encoding_mode = context.get_new_encoding(); - context.reset_encoder_signal(); - } - while context.has_more_characters() { - encoders[encoding_mode].encode(context); - if context.get_new_encoding() >= 0 { - encoding_mode = context.get_new_encoding(); - context.reset_encoder_signal(); - } - } - let len: i32 = context.get_codeword_count(); - context.update_symbol_info_simple(); - let capacity: i32 = context.get_symbol_info().get_data_capacity(); - if len < capacity - && encoding_mode != ASCII_ENCODATION - && encoding_mode != BASE256_ENCODATION - && encoding_mode != EDIFACT_ENCODATION - { - //Unlatch (254) - context.write_codeword('þ'); - } - //Padding - let codewords: StringBuilder = context.get_codewords(); - if codewords.length() < capacity { - codewords.append(PAD); - } - while codewords.length() < capacity { - codewords.append(&::randomize253_state(codewords.length() + 1)); - } - return context.get_codewords().to_string(); - } - - fn look_ahead_test(msg: &Vec, startpos: i32, current_mode: i32) -> i32 { - let new_mode: i32 = ::look_ahead_test_intern(&msg, startpos, current_mode); - if current_mode == X12_ENCODATION && new_mode == X12_ENCODATION { - let endpos: i32 = Math::min(startpos + 3, &msg.length()); - { - let mut i: i32 = startpos; - while i < endpos { - { - if !::is_native_x12(&msg.char_at(i)) { - return ASCII_ENCODATION; - } - } - i += 1; - } - } - } else if current_mode == EDIFACT_ENCODATION && new_mode == EDIFACT_ENCODATION { - let endpos: i32 = Math::min(startpos + 4, &msg.length()); - { - let mut i: i32 = startpos; - while i < endpos { - { - if !::is_native_e_d_i_f_a_c_t(&msg.char_at(i)) { - return ASCII_ENCODATION; - } - } - i += 1; - } - } - } - return new_mode; - } - - fn look_ahead_test_intern(msg: &CharSequence, startpos: i32, current_mode: i32) -> i32 { - if startpos >= msg.length() { - return current_mode; - } - let char_counts: Vec; - //step J - if current_mode == ASCII_ENCODATION { - char_counts = vec![0.0, 1.0, 1.0, 1.0, 1.0, 1.25f, ]; - } else { - char_counts = vec![1.0, 2.0, 2.0, 2.0, 2.0, 2.25f, ]; - char_counts[current_mode] = 0.0; - } - let chars_processed: i32 = 0; - let mins: [i8; 6] = [0; 6]; - let int_char_counts: [i32; 6] = [0; 6]; - while true { - //step K - if (startpos + chars_processed) == msg.length() { - Arrays::fill(&mins, 0 as i8); - Arrays::fill(&int_char_counts, 0); - let min: i32 = - ::find_minimums(&char_counts, &int_char_counts, Integer::MAX_VALUE, &mins); - let min_count: i32 = ::get_minimum_count(&mins); - if int_char_counts[ASCII_ENCODATION] == min { - return ASCII_ENCODATION; - } - if min_count == 1 { - if mins[BASE256_ENCODATION] > 0 { - return BASE256_ENCODATION; - } - if mins[EDIFACT_ENCODATION] > 0 { - return EDIFACT_ENCODATION; - } - if mins[TEXT_ENCODATION] > 0 { - return TEXT_ENCODATION; - } - if mins[X12_ENCODATION] > 0 { - return X12_ENCODATION; - } - } - return C40_ENCODATION; - } - let c: char = msg.char_at(startpos + chars_processed); - chars_processed += 1; - //step L - if ::is_digit(c) { - char_counts[ASCII_ENCODATION] += 0.5f32; - } else if ::is_extended_a_s_c_i_i(c) { - char_counts[ASCII_ENCODATION] = Math::ceil(char_counts[ASCII_ENCODATION]) as f32; - char_counts[ASCII_ENCODATION] += 2.0f32; - } else { - char_counts[ASCII_ENCODATION] = Math::ceil(char_counts[ASCII_ENCODATION]) as f32; - char_counts[ASCII_ENCODATION] += 1; - } - //step M - if ::is_native_c40(c) { - char_counts[C40_ENCODATION] += 2.0f32 / 3.0f32; - } else if ::is_extended_a_s_c_i_i(c) { - char_counts[C40_ENCODATION] += 8.0f32 / 3.0f32; - } else { - char_counts[C40_ENCODATION] += 4.0f32 / 3.0f32; - } - //step N - if ::is_native_text(c) { - char_counts[TEXT_ENCODATION] += 2.0f32 / 3.0f32; - } else if ::is_extended_a_s_c_i_i(c) { - char_counts[TEXT_ENCODATION] += 8.0f32 / 3.0f32; - } else { - char_counts[TEXT_ENCODATION] += 4.0f32 / 3.0f32; - } - //step O - if ::is_native_x12(c) { - char_counts[X12_ENCODATION] += 2.0f32 / 3.0f32; - } else if ::is_extended_a_s_c_i_i(c) { - char_counts[X12_ENCODATION] += 13.0f32 / 3.0f32; - } else { - char_counts[X12_ENCODATION] += 10.0f32 / 3.0f32; - } - //step P - if ::is_native_e_d_i_f_a_c_t(c) { - char_counts[EDIFACT_ENCODATION] += 3.0f32 / 4.0f32; - } else if ::is_extended_a_s_c_i_i(c) { - char_counts[EDIFACT_ENCODATION] += 17.0f32 / 4.0f32; - } else { - char_counts[EDIFACT_ENCODATION] += 13.0f32 / 4.0f32; - } - // step Q - if ::is_special_b256(c) { - char_counts[BASE256_ENCODATION] += 4.0f32; - } else { - char_counts[BASE256_ENCODATION] += 1; - } - //step R - if chars_processed >= 4 { - Arrays::fill(&mins, 0 as i8); - Arrays::fill(&int_char_counts, 0); - ::find_minimums(&char_counts, &int_char_counts, Integer::MAX_VALUE, &mins); - if int_char_counts[ASCII_ENCODATION] - < ::min( - int_char_counts[BASE256_ENCODATION], - int_char_counts[C40_ENCODATION], - int_char_counts[TEXT_ENCODATION], - int_char_counts[X12_ENCODATION], - int_char_counts[EDIFACT_ENCODATION], - ) - { - return ASCII_ENCODATION; - } - if int_char_counts[BASE256_ENCODATION] < int_char_counts[ASCII_ENCODATION] - || int_char_counts[BASE256_ENCODATION] + 1 - < ::min( - int_char_counts[C40_ENCODATION], - int_char_counts[TEXT_ENCODATION], - int_char_counts[X12_ENCODATION], - int_char_counts[EDIFACT_ENCODATION], - ) - { - return BASE256_ENCODATION; - } - if int_char_counts[EDIFACT_ENCODATION] + 1 - < ::min( - int_char_counts[BASE256_ENCODATION], - int_char_counts[C40_ENCODATION], - int_char_counts[TEXT_ENCODATION], - int_char_counts[X12_ENCODATION], - int_char_counts[ASCII_ENCODATION], - ) - { - return EDIFACT_ENCODATION; - } - if int_char_counts[TEXT_ENCODATION] + 1 - < ::min( - int_char_counts[BASE256_ENCODATION], - int_char_counts[C40_ENCODATION], - int_char_counts[EDIFACT_ENCODATION], - int_char_counts[X12_ENCODATION], - int_char_counts[ASCII_ENCODATION], - ) - { - return TEXT_ENCODATION; - } - if int_char_counts[X12_ENCODATION] + 1 - < ::min( - int_char_counts[BASE256_ENCODATION], - int_char_counts[C40_ENCODATION], - int_char_counts[EDIFACT_ENCODATION], - int_char_counts[TEXT_ENCODATION], - int_char_counts[ASCII_ENCODATION], - ) - { - return X12_ENCODATION; - } - if int_char_counts[C40_ENCODATION] + 1 - < ::min( - int_char_counts[ASCII_ENCODATION], - int_char_counts[BASE256_ENCODATION], - int_char_counts[EDIFACT_ENCODATION], - int_char_counts[TEXT_ENCODATION], - ) - { - if int_char_counts[C40_ENCODATION] < int_char_counts[X12_ENCODATION] { - return C40_ENCODATION; - } - if int_char_counts[C40_ENCODATION] == int_char_counts[X12_ENCODATION] { - let mut p: i32 = startpos + chars_processed + 1; - while p < msg.length() { - let tc: char = msg.char_at(p); - if ::is_x12_term_sep(tc) { - return X12_ENCODATION; - } - if !::is_native_x12(tc) { - break; - } - p += 1; - } - return C40_ENCODATION; - } - } - } - } - } - - fn min(f1: i32, f2: i32, f3: i32, f4: i32, f5: i32) -> i32 { - return Math::min(&::min(f1, f2, f3, f4), f5); - } - - fn min(f1: i32, f2: i32, f3: i32, f4: i32) -> i32 { - return Math::min(f1, &Math::min(f2, &Math::min(f3, f4))); - } - - fn find_minimums( - char_counts: &Vec, - int_char_counts: &Vec, - min: i32, - mins: &Vec, - ) -> i32 { - { - let mut i: i32 = 0; - while i < 6 { - { - let current: i32 = (int_char_counts[i] = Math::ceil(char_counts[i]) as i32); - if min > current { - min = current; - Arrays::fill(&mins, 0 as i8); - } - if min == current { - mins[i] += 1; - } - } - i += 1; - } - } - - return min; - } - - fn get_minimum_count(mins: &Vec) -> i32 { - let min_count: i32 = 0; - { - let mut i: i32 = 0; - while i < 6 { - { - min_count += mins[i]; - } - i += 1; - } - } - - return min_count; - } - - fn is_digit(ch: char) -> bool { - return ch >= '0' && ch <= '9'; - } - - fn is_extended_a_s_c_i_i(ch: char) -> bool { - return ch >= 128 && ch <= 255; - } - - fn is_native_c40(ch: char) -> bool { - return (ch == ' ') || (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z'); - } - - fn is_native_text(ch: char) -> bool { - return (ch == ' ') || (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z'); - } - - fn is_native_x12(ch: char) -> bool { - return ::is_x12_term_sep(ch) - || (ch == ' ') - || (ch >= '0' && ch <= '9') - || (ch >= 'A' && ch <= 'Z'); - } - - fn is_x12_term_sep(ch: char) -> bool { - return //CR - (ch == '\r') || (ch == '*') || (ch == '>'); - } - - fn is_native_e_d_i_f_a_c_t(ch: char) -> bool { - return ch >= ' ' && ch <= '^'; - } - - fn is_special_b256(ch: char) -> bool { - //TODO NOT IMPLEMENTED YET!!! - return false; - } - - /** - * Determines the number of consecutive characters that are encodable using numeric compaction. - * - * @param msg the message - * @param startpos the start position within the message - * @return the requested character count - */ - pub fn determine_consecutive_digit_count(msg: &Vec, startpos: i32) -> i32 { - let len: i32 = msg.length(); - let mut idx: i32 = startpos; - while idx < len && ::is_digit(&msg.char_at(idx)) { - idx += 1; - } - return idx - startpos; - } - - fn illegal_character(c: char) { - let mut hex: String = Integer::to_hex_string(c); - hex = format!("{}{}", "0000".substring(0, 4 - hex.length()), hex); - return Err(IllegalArgumentException::new(format!( - "Illegal character: {} (0x{})", - c, hex - ))); - } -} - -// MinimalEncoder.java -/** - * Encoder that encodes minimally - * - * Algorithm: - * - * Uses Dijkstra to produce mathematically minimal encodings that are in some cases smaller than the results produced - * by the algorithm described in annex S in the specification ISO/IEC 16022:200(E). The biggest improvment of this - * algorithm over that one is the case when the algorithm enters the most inefficient mode, the B256 mode. The - * algorithm from the specification algorithm will exit this mode only if it encounters digits so that arbitrarily - * inefficient results can be produced if the postfix contains no digits. - * - * Multi ECI support and ECI switching: - * - * For multi language content the algorithm selects the most compact representation using ECI modes. Note that unlike - * the compaction algorithm used for QR-Codes, this implementation operates in two stages and therfore is not - * mathematically optimal. In the first stage, the input string is encoded minimally as a stream of ECI character set - * selectors and bytes encoded in the selected encoding. In this stage the algorithm might for example decide to - * encode ocurrences of the characters "\u0150\u015C" (O-double-acute, S-circumflex) in UTF-8 by a single ECI or - * alternatively by multiple ECIs that switch between IS0-8859-2 and ISO-8859-3 (e.g. in the case that the input - * contains many * characters from ISO-8859-2 (Latin 2) and few from ISO-8859-3 (Latin 3)). - * In a second stage this stream of ECIs and bytes is minimally encoded using the various Data Matrix encoding modes. - * While both stages encode mathematically minimally it is not ensured that the result is mathematically minimal since - * the size growth for inserting an ECI in the first stage can only be approximated as the first stage does not know - * in which mode the ECI will occur in the second stage (may, or may not require an extra latch to ASCII depending on - * the current mode). The reason for this shortcoming are difficulties in implementing it in a straightforward and - * readable manner. - * - * GS1 support - * - * FNC1 delimiters can be encoded in the input string by using the FNC1 character specified in the encoding function. - * When a FNC1 character is specified then a leading FNC1 will be encoded and all ocurrences of delimiter characters - * while result in FNC1 codewords in the symbol. - * - * @author Alex Geller - */ - -const C40_SHIFT2_CHARS: vec![Vec; 27] = vec![ - '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', - '>', '?', '@', '[', '\\', ']', '^', '_', -]; - -enum Mode { - ASCII(), - C40(), - TEXT(), - X12(), - EDF(), - B256(), -} -pub struct MinimalEncoder {} - -impl MinimalEncoder { - fn new() -> MinimalEncoder {} - - fn is_extended_a_s_c_i_i(ch: char, fnc1: i32) -> bool { - return ch != fnc1 && ch >= 128 && ch <= 255; - } - - fn is_in_c40_shift1_set(ch: char) -> bool { - return ch <= 31; - } - - fn is_in_c40_shift2_set(ch: char, fnc1: i32) -> bool { - for c40_shift2_char in C40_SHIFT2_CHARS { - if c40_shift2_char == ch { - return true; - } - } - return ch == fnc1; - } - - fn is_in_text_shift1_set(ch: char) -> bool { - return ::is_in_c40_shift1_set(ch); - } - - fn is_in_text_shift2_set(ch: char, fnc1: i32) -> bool { - return ::is_in_c40_shift2_set(ch, fnc1); - } - - pub fn encode_high_level_simple(msg: &String) -> String { - return ::encode_high_level(&msg, null, -1, SymbolShapeHint::FORCE_NONE); - } - - pub fn encode_high_level( - msg: &String, - priority_charset: &Charset, - fnc1: i32, - shape: &SymbolShapeHint, - ) -> String { - let macro_id: i32 = 0; - if msg.starts_with(HighLevelEncoder::MACRO_05_HEADER) - && msg.ends_with(HighLevelEncoder::MACRO_TRAILER) - { - macro_id = 5; - msg = msg.substring( - &HighLevelEncoder::MACRO_05_HEADER::length(), - msg.length() - 2, - ); - } else if msg.starts_with(HighLevelEncoder::MACRO_06_HEADER) - && msg.ends_with(HighLevelEncoder::MACRO_TRAILER) - { - macro_id = 6; - msg = msg.substring( - &HighLevelEncoder::MACRO_06_HEADER::length(), - msg.length() - 2, - ); - } - { - use encoding::all::ISO_8859_1; - use encoding::{DecoderTrap, Encoding}; - let st = ::encode(&msg, &priority_charset, fnc1, shape, macro_id); - ISO_8859_1 - .decode(st, DecoderTrap::Strict) - .unwrap_or("".to_owned()) - - //return String::new(&::encode(&msg, &priority_charset, fnc1, shape, macro_id), StandardCharsets::ISO_8859_1); - } - } - - fn encode( - input: &String, - priority_charset: &Charset, - fnc1: i32, - shape: &SymbolShapeHint, - macro_id: i32, - ) -> Vec { - return ::encode_minimally(Input::new(&input, &priority_charset, fnc1, shape, macro_id)) - .get_bytes(); - } - - fn add_edge(edges: &Vec>, edge: &Edge) { - let vertex_index: i32 = edge.fromPosition + edge.characterLength; - if edges[vertex_index][edge.get_end_mode().ordinal()] == null - || edges[vertex_index][edge.get_end_mode().ordinal()].cachedTotalSize - > edge.cachedTotalSize - { - edges[vertex_index][edge.get_end_mode().ordinal()] = edge; - } - } - - fn get_number_of_c40_words( - input: &Input, - from: i32, - c40: bool, - character_length: &Vec, - ) -> i32 { - let thirds_count: i32 = 0; - { - let mut i: i32 = from; - while i < input.length() { - { - if input.is_e_c_i(i) { - character_length[0] = 0; - return 0; - } - let ci: char = input.char_at(i); - if c40 && HighLevelEncoder::is_native_c40(ci) - || !c40 && HighLevelEncoder::is_native_text(ci) - { - thirds_count += 1; - } else if !::is_extended_a_s_c_i_i(ci, &input.get_f_n_c1_character()) { - thirds_count += 2; - } else { - let ascii_value: i32 = ci & 0xff; - if ascii_value >= 128 - && (c40 && HighLevelEncoder::is_native_c40((ascii_value - 128) as char) - || !c40 - && HighLevelEncoder::is_native_text( - (ascii_value - 128) as char, - )) - { - thirds_count += 3; - } else { - thirds_count += 4; - } - } - if thirds_count % 3 == 0 - || ((thirds_count - 2) % 3 == 0 && i + 1 == input.length()) - { - character_length[0] = i - from + 1; - return Math::ceil((thirds_count as f64) / 3.0) as i32; - } - } - i += 1; - } - } - - character_length[0] = 0; - return 0; - } - - fn add_edges(input: &Input, edges: &Vec>, from: i32, previous: &Edge) { - if input.is_e_c_i(from) { - ::add_edge(edges, Edge::new(input, Mode::ASCII, from, 1, previous)); - return; - } - let ch: char = input.char_at(from); - if previous == null || previous.get_end_mode() != Mode::EDF { - if HighLevelEncoder::is_digit(ch) - && input.have_n_characters(from, 2) - && HighLevelEncoder::is_digit(&input.char_at(from + 1)) - { - ::add_edge(edges, Edge::new(input, Mode::ASCII, from, 2, previous)); - } else { - ::add_edge(edges, Edge::new(input, Mode::ASCII, from, 1, previous)); - } - let modes: vec![Vec; 2] = vec![Mode::C40, Mode::TEXT]; - for mode in modes { - let character_length: [i32; 1] = [0; 1]; - if ::get_number_of_c40_words(input, from, mode == Mode::C40, &character_length) > 0 - { - ::add_edge( - edges, - Edge::new(input, mode, from, character_length[0], previous), - ); - } - } - if input.have_n_characters(from, 3) - && HighLevelEncoder::is_native_x12(&input.char_at(from)) - && HighLevelEncoder::is_native_x12(&input.char_at(from + 1)) - && HighLevelEncoder::is_native_x12(&input.char_at(from + 2)) - { - ::add_edge(edges, Edge::new(input, Mode::X12, from, 3, previous)); - } - ::add_edge(edges, Edge::new(input, Mode::B256, from, 1, previous)); - } - //unless it is 2 characters away from the end of the input. - let mut i: i32; - { - i = 0; - while i < 3 { - { - let pos: i32 = from + i; - if input.have_n_characters(pos, 1) - && HighLevelEncoder::is_native_e_d_i_f_a_c_t(&input.char_at(pos)) - { - ::add_edge(edges, Edge::new(input, Mode::EDF, from, i + 1, previous)); - } else { - break; - } - } - i += 1; - } - } - - if i == 3 - && input.have_n_characters(from, 4) - && HighLevelEncoder::is_native_e_d_i_f_a_c_t(&input.char_at(from + 3)) - { - ::add_edge(edges, Edge::new(input, Mode::EDF, from, 4, previous)); - } - } - - fn encode_minimally(input: &Input) -> Result { - let input_length: i32 = input.length(); - // Array that represents vertices. There is a vertex for every character and mode. - // The last dimension in the array below encodes the 6 modes ASCII, C40, TEXT, X12, EDF and B256 - let mut edges: [[Option; 6]; input_length + 1] = [[None; 6]; input_length + 1]; - ::add_edges(input, edges, 0, null); - { - let mut i: i32 = 1; - while i <= input_length { - { - { - let mut j: i32 = 0; - while j < 6 { - { - if edges[i][j] != null && i < input_length { - ::add_edges(input, edges, i, edges[i][j]); - } - } - j += 1; - } - } - - //optimize memory by removing edges that have been passed. - { - let mut j: i32 = 0; - while j < 6 { - { - edges[i - 1][j] = null; - } - j += 1; - } - } - } - i += 1; - } - } - - let minimal_j: i32 = -1; - let minimal_size: i32 = Integer::MAX_VALUE; - { - let mut j: i32 = 0; - while j < 6 { - { - if edges[input_length][j] != null { - let edge: Edge = edges[input_length][j]; - //C40, TEXT and X12 need an - let size: i32 = if j >= 1 && j <= 3 { - edge.cachedTotalSize + 1 - } else { - edge.cachedTotalSize - }; - // extra unlatch at the end - if size < minimal_size { - minimal_size = size; - minimal_j = j; - } - } - } - j += 1; - } - } - - if minimal_j < 0 { - return Err(RuntimeException::new(format!( - "Internal error: failed to encode \"{}\"", - input - ))); - } - return Result::new(edges[input_length][minimal_j]); - } - - const all_codeword_capacities: vec![Vec; 28] = vec![ - 3, 5, 8, 10, 12, 16, 18, 22, 30, 32, 36, 44, 49, 62, 86, 114, 144, 174, 204, 280, 368, 456, - 576, 696, 816, 1050, 1304, 1558, - ]; - - const square_codeword_capacities: vec![Vec; 24] = vec![ - 3, 5, 8, 12, 18, 22, 30, 36, 44, 62, 86, 114, 144, 174, 204, 280, 368, 456, 576, 696, 816, - 1050, 1304, 1558, - ]; - - const rectangular_codeword_capacities: vec![Vec; 6] = vec![5, 10, 16, 33, 32, 49]; -} - -struct Edge { - input: Input, - - //the mode at the start of this edge. - mode: Mode, - - from_position: i32, - - character_length: i32, - - previous: Edge, - - cached_total_size: i32, -} - -impl Edge { - fn new( - input: &Input, - mode: &Mode, - from_position: i32, - character_length: i32, - previous: &Edge, - ) -> Self { - let new_edge: Self; - new_edge.input = input; - new_edge.mode = mode; - new_edge.fromPosition = from_position; - new_edge.characterLength = character_length; - new_edge.previous = previous; - assert!(from_position + character_length <= input.length()); - let mut size: i32 = if previous != null { - previous.cachedTotalSize - } else { - 0 - }; - let previous_mode: Mode = self.get_previous_mode(); - /* - * Switching modes - * ASCII -> C40: latch 230 - * ASCII -> TEXT: latch 239 - * ASCII -> X12: latch 238 - * ASCII -> EDF: latch 240 - * ASCII -> B256: latch 231 - * C40 -> ASCII: word(c1,c2,c3), 254 - * TEXT -> ASCII: word(c1,c2,c3), 254 - * X12 -> ASCII: word(c1,c2,c3), 254 - * EDIFACT -> ASCII: Unlatch character,0,0,0 or c1,Unlatch character,0,0 or c1,c2,Unlatch character,0 or - * c1,c2,c3,Unlatch character - * B256 -> ASCII: without latch after n bytes - */ - match mode { - ASCII => { - size += 1; - if input.is_e_c_i(from_position) - || ::is_extended_a_s_c_i_i( - &input.char_at(from_position), - &input.get_f_n_c1_character(), - ) - { - size += 1; - } - if previous_mode == Mode::C40 - || previous_mode == Mode::TEXT - || previous_mode == Mode::X12 - { - // unlatch 254 to ASCII - size += 1; - } - } - B256 => { - size += 1; - if previous_mode != Mode::B256 { - //byte count - size += 1; - } else if self.get_b256_size() == 250 { - //extra byte count - size += 1; - } - if previous_mode == Mode::ASCII { - //latch to B256 - size += 1; - } else if previous_mode == Mode::C40 - || previous_mode == Mode::TEXT - || previous_mode == Mode::X12 - { - //unlatch to ASCII, latch to B256 - size += 2; - } - } - C40 => {} - TEXT => {} - X12 => { - if mode == Mode::X12 { - size += 2; - } else { - let char_len: [i32; 1] = [0; 1]; - size += ::get_number_of_c40_words( - input, - from_position, - mode == Mode::C40, - &char_len, - ) * 2; - } - if previous_mode == Mode::ASCII || previous_mode == Mode::B256 { - //additional byte for latch from ASCII to this mode - size += 1; - } else if previous_mode != mode - && (previous_mode == Mode::C40 - || previous_mode == Mode::TEXT - || previous_mode == Mode::X12) - { - //unlatch 254 to ASCII followed by latch to this mode - size += 2; - } - } - EDF => { - size += 3; - if previous_mode == Mode::ASCII || previous_mode == Mode::B256 { - //additional byte for latch from ASCII to this mode - size += 1; - } else if previous_mode == Mode::C40 - || previous_mode == Mode::TEXT - || previous_mode == Mode::X12 - { - //unlatch 254 to ASCII followed by latch to this mode - size += 2; - } - } - } - cached_total_size = size; - } - - // does not count beyond 250 - fn get_b256_size(&self) -> i32 { - let mut cnt: i32 = 0; - let mut current: Edge = self; - while current != null && current.mode == Mode::B256 && cnt <= 250 { - cnt += 1; - current = current.previous; - } - return cnt; - } - - fn get_previous_start_mode(&self) -> Mode { - return if self.previous == null { - Mode::ASCII - } else { - self.previous.mode - }; - } - - fn get_previous_mode(&self) -> Mode { - return if self.previous == null { - Mode::ASCII - } else { - self.previous.get_end_mode() - }; - } - - /** Returns Mode.ASCII in case that: - * - Mode is EDIFACT and characterLength is less than 4 or the remaining characters can be encoded in at most 2 - * ASCII bytes. - * - Mode is C40, TEXT or X12 and the remaining characters can be encoded in at most 1 ASCII byte. - * Returns mode in all other cases. - * */ - fn get_end_mode(&self) -> Mode { - if self.mode == Mode::EDF { - if self.character_length < 4 { - return Mode::ASCII; - } - // see 5.2.8.2 EDIFACT encodation Rules - let last_a_s_c_i_i: i32 = self.get_last_a_s_c_i_i(); - if last_a_s_c_i_i > 0 - && self.get_codewords_remaining(self.cached_total_size + last_a_s_c_i_i) - <= 2 - last_a_s_c_i_i - { - return Mode::ASCII; - } - } - if self.mode == Mode::C40 || self.mode == Mode::TEXT || self.mode == Mode::X12 { - // see 5.2.5.2 C40 encodation rules and 5.2.7.2 ANSI X12 encodation rules - if self.from_position + self.character_length >= self.input.length() - && self.get_codewords_remaining(self.cached_total_size) == 0 - { - return Mode::ASCII; - } - let last_a_s_c_i_i: i32 = self.get_last_a_s_c_i_i(); - if last_a_s_c_i_i == 1 && self.get_codewords_remaining(self.cached_total_size + 1) == 0 - { - return Mode::ASCII; - } - } - return self.mode; - } - - fn get_mode(&self) -> Mode { - return self.mode; - } - - /** Peeks ahead and returns 1 if the postfix consists of exactly two digits, 2 if the postfix consists of exactly - * two consecutive digits and a non extended character or of 4 digits. - * Returns 0 in any other case - **/ - fn get_last_a_s_c_i_i(&self) -> i32 { - let length: i32 = self.input.length(); - let from: i32 = self.from_position + self.character_length; - if length - from > 4 || from >= length { - return 0; - } - if length - from == 1 { - if ::is_extended_a_s_c_i_i( - &self.input.char_at(from), - &self.input.get_f_n_c1_character(), - ) { - return 0; - } - return 1; - } - if length - from == 2 { - if ::is_extended_a_s_c_i_i( - &self.input.char_at(from), - &self.input.get_f_n_c1_character(), - ) || ::is_extended_a_s_c_i_i( - &self.input.char_at(from + 1), - &self.input.get_f_n_c1_character(), - ) { - return 0; - } - if HighLevelEncoder::is_digit(&self.input.char_at(from)) - && HighLevelEncoder::is_digit(&self.input.char_at(from + 1)) - { - return 1; - } - return 2; - } - if length - from == 3 { - if HighLevelEncoder::is_digit(&self.input.char_at(from)) - && HighLevelEncoder::is_digit(&self.input.char_at(from + 1)) - && !::is_extended_a_s_c_i_i( - &self.input.char_at(from + 2), - &self.input.get_f_n_c1_character(), - ) - { - return 2; - } - if HighLevelEncoder::is_digit(&self.input.char_at(from + 1)) - && HighLevelEncoder::is_digit(&self.input.char_at(from + 2)) - && !::is_extended_a_s_c_i_i( - &self.input.char_at(from), - &self.input.get_f_n_c1_character(), - ) - { - return 2; - } - return 0; - } - if HighLevelEncoder::is_digit(&self.input.char_at(from)) - && HighLevelEncoder::is_digit(&self.input.char_at(from + 1)) - && HighLevelEncoder::is_digit(&self.input.char_at(from + 2)) - && HighLevelEncoder::is_digit(&self.input.char_at(from + 3)) - { - return 2; - } - return 0; - } - - /** Returns the capacity in codewords of the smallest symbol that has enough capacity to fit the given minimal - * number of codewords. - **/ - fn get_min_symbol_size(&self, minimum: i32) -> i32 { - match self.input.get_shape_hint() { - FORCE_SQUARE => { - for capacity in square_codeword_capacities { - if capacity >= minimum { - return capacity; - } - } - } - FORCE_RECTANGLE => { - for capacity in rectangular_codeword_capacities { - if capacity >= minimum { - return capacity; - } - } - } - } - for capacity in all_codeword_capacities { - if capacity >= minimum { - return capacity; - } - } - return all_codeword_capacities[all_codeword_capacities.len() - 1]; - } - - /** Returns the remaining capacity in codewords of the smallest symbol that has enough capacity to fit the given - * minimal number of codewords. - **/ - fn get_codewords_remaining(&self, minimum: i32) -> i32 { - return self.get_min_symbol_size(minimum) - minimum; - } - - fn get_bytes(c: i32) -> Vec { - let mut result: [i8; 1] = [0; 1]; - result[0] = c as i8; - return result; - } - - fn get_bytes(c1: i32, c2: i32) -> Vec { - let mut result: [i8; 2] = [0; 2]; - result[0] = c1 as i8; - result[1] = c2 as i8; - return result; - } - - fn set_c40_word(bytes: &Vec, offset: i32, c1: i32, c2: i32, c3: i32) { - let val16: i32 = (1600 * (c1 & 0xff)) + (40 * (c2 & 0xff)) + (c3 & 0xff) + 1; - bytes[offset] = (val16 / 256) as i8; - bytes[offset + 1] = (val16 % 256) as i8; - } - - fn get_x12_value(c: char) -> i32 { - return if c == 13 { - 0 - } else { - if c == 42 { - 1 - } else { - if c == 62 { - 2 - } else { - if c == 32 { - 3 - } else { - if c >= 48 && c <= 57 { - c - 44 - } else { - if c >= 65 && c <= 90 { - c - 51 - } else { - c - } - } - } - } - } - }; - } - - fn get_x12_words(&self) -> Vec { - assert!(self.character_length % 3 == 0); - let result: [i8; self.character_length / 3 * 2] = [0; self.character_length / 3 * 2]; - { - let mut i: i32 = 0; - while i < result.len() { - { - ::set_c40_word( - &result, - i, - &::get_x12_value(&self.input.char_at(self.from_position + i / 2 * 3)), - &::get_x12_value(&self.input.char_at(self.from_position + i / 2 * 3 + 1)), - &::get_x12_value(&self.input.char_at(self.from_position + i / 2 * 3 + 2)), - ); - } - i += 2; - } - } - - return result; - } - - fn get_shift_value(c: char, c40: bool, fnc1: i32) -> i32 { - return if (c40 && ::is_in_c40_shift1_set(c) || !c40 && ::is_in_text_shift1_set(c)) { - 0 - } else { - if (c40 && ::is_in_c40_shift2_set(c, fnc1) || !c40 && ::is_in_text_shift2_set(c, fnc1)) - { - 1 - } else { - 2 - } - }; - } - - fn get_c40_value(c40: bool, set_index: i32, c: char, fnc1: i32) -> i32 { - if c == fnc1 { - assert!(set_index == 2); - return 27; - } - if c40 { - return if c <= 31 { - c - } else { - if c == 32 { - 3 - } else { - if c <= 47 { - c - 33 - } else { - if c <= 57 { - c - 44 - } else { - if c <= 64 { - c - 43 - } else { - if c <= 90 { - c - 51 - } else { - if c <= 95 { - c - 69 - } else { - if c <= 127 { - c - 96 - } else { - c - } - } - } - } - } - } - } - }; - } else { - return if c == 0 { - 0 - } else { - if - //is this a bug in the spec? - set_index == 0 && c <= 3 { - //is this a bug in the spec? - c - 1 - } else { - if set_index == 1 && c <= 31 { - c - } else { - if c == 32 { - 3 - } else { - if c >= 33 && c <= 47 { - c - 33 - } else { - if c >= 48 && c <= 57 { - c - 44 - } else { - if c >= 58 && c <= 64 { - c - 43 - } else { - if c >= 65 && c <= 90 { - c - 64 - } else { - if c >= 91 && c <= 95 { - c - 69 - } else { - if c == 96 { - 0 - } else { - if c >= 97 && c <= 122 { - c - 83 - } else { - if c >= 123 && c <= 127 { - c - 96 - } else { - c - } - } - } - } - } - } - } - } - } - } - } - }; - } - } - - fn get_c40_words(&self, c40: bool, fnc1: i32) -> Vec { - let c40_values: List = Vec::new(); - { - let mut i: i32 = 0; - while i < self.character_length { - { - let ci: char = self.input.char_at(self.from_position + i); - if c40 && HighLevelEncoder::is_native_c40(ci) - || !c40 && HighLevelEncoder::is_native_text(ci) - { - c40_values.add(::get_c40_value(c40, 0, ci, fnc1) as i8); - } else if !::is_extended_a_s_c_i_i(ci, fnc1) { - let shift_value: i32 = ::get_shift_value(ci, c40, fnc1); - //Shift[123] - c40_values.add(shift_value as i8); - c40_values.add(::get_c40_value(c40, shift_value, ci, fnc1) as i8); - } else { - let ascii_value: char = ((ci & 0xff) - 128) as char; - if c40 && HighLevelEncoder::is_native_c40(ascii_value) - || !c40 && HighLevelEncoder::is_native_text(ascii_value) - { - //Shift 2 - c40_values.add(1 as i8); - //Upper Shift - c40_values.add(30 as i8); - c40_values.add(::get_c40_value(c40, 0, ascii_value, fnc1) as i8); - } else { - //Shift 2 - c40_values.add(1 as i8); - //Upper Shift - c40_values.add(30 as i8); - let shift_value: i32 = ::get_shift_value(ascii_value, c40, fnc1); - // Shift[123] - c40_values.add(shift_value as i8); - c40_values - .add(::get_c40_value(c40, shift_value, ascii_value, fnc1) as i8); - } - } - } - i += 1; - } - } - - if (c40_values.size() % 3) != 0 { - assert!( - (c40_values.size() - 2) % 3 == 0 - && self.from_position + self.character_length == self.input.length() - ); - // pad with 0 (Shift 1) - c40_values.add(0 as i8); - } - let result: [i8; c40_values.size() / 3 * 2] = [0; c40_values.size() / 3 * 2]; - let byte_index: i32 = 0; - { - let mut i: i32 = 0; - while i < c40_values.size() { - { - ::set_c40_word( - &result, - byte_index, - c40_values.get(i) & 0xff, - c40_values.get(i + 1) & 0xff, - c40_values.get(i + 2) & 0xff, - ); - byte_index += 2; - } - i += 3; - } - } - - return result; - } - - fn get_e_d_f_bytes(&self) -> Vec { - let number_of_thirds: i32 = Math::ceil(self.character_length / 4.0) as i32; - let mut result: [i8; number_of_thirds * 3] = [0; number_of_thirds * 3]; - let mut pos: i32 = self.from_position; - let end_pos: i32 = Math::min( - self.from_position + self.character_length - 1, - self.input.length() - 1, - ); - { - let mut i: i32 = 0; - while i < number_of_thirds { - { - let edf_values: [i32; 4] = [0; 4]; - { - let mut j: i32 = 0; - while j < 4 { - { - if pos <= end_pos { - edf_values[j] = self.input.char_at(pos += 1) & 0x3f; - } else { - edf_values[j] = if pos == end_pos + 1 { 0x1f } else { 0 }; - } - } - j += 1; - } - } - - let mut val24: i32 = edf_values[0] << 18; - val24 |= edf_values[1] << 12; - val24 |= edf_values[2] << 6; - val24 |= edf_values[3]; - result[i] = ((val24 >> 16) & 0xff) as i8; - result[i + 1] = ((val24 >> 8) & 0xff) as i8; - result[i + 2] = (val24 & 0xff) as i8; - } - i += 3; - } - } - - return result; - } - - fn get_latch_bytes(&self) -> Vec { - match self.get_previous_mode() { - ASCII => {} - //after B256 ends (via length) we are back to ASCII - B256 => match self.mode { - B256 => { - return ::get_bytes(231); - } - C40 => { - return ::get_bytes(230); - } - TEXT => { - return ::get_bytes(239); - } - X12 => { - return ::get_bytes(238); - } - EDF => { - return ::get_bytes(240); - } - }, - C40 => {} - TEXT => {} - X12 => { - if self.mode != self.get_previous_mode() { - match self.mode { - ASCII => { - return ::get_bytes(254); - } - B256 => { - return ::get_bytes(254, 231); - } - C40 => { - return ::get_bytes(254, 230); - } - TEXT => { - return ::get_bytes(254, 239); - } - X12 => { - return ::get_bytes(254, 238); - } - EDF => { - return ::get_bytes(254, 240); - } - } - } - } - EDF => { - //The rightmost EDIFACT edge always contains an unlatch character - assert!(self.mode == Mode::EDF); - } - } - return [0; 0]; - } - - // Important: The function does not return the length bytes (one or two) in case of B256 encoding - fn get_data_bytes(&self) -> Vec { - match self.mode { - ASCII => { - if self.input.is_e_c_i(self.from_position) { - return ::get_bytes(241, self.input.get_e_c_i_value(self.from_position) + 1); - } else if ::is_extended_a_s_c_i_i( - &self.input.char_at(self.from_position), - &self.input.get_f_n_c1_character(), - ) { - return ::get_bytes(235, self.input.char_at(self.from_position) - 127); - } else if self.character_length == 2 { - return ::get_bytes( - (self.input.char_at(self.from_position) - '0') * 10 - + self.input.char_at(self.from_position + 1) - - '0' - + 130, - ); - } else if self.input.is_f_n_c1(self.from_position) { - return ::get_bytes(232); - } else { - return ::get_bytes(self.input.char_at(self.from_position) + 1); - } - } - B256 => { - return ::get_bytes(&self.input.char_at(self.from_position)); - } - C40 => { - return self.get_c40_words(true, &self.input.get_f_n_c1_character()); - } - TEXT => { - return self.get_c40_words(false, &self.input.get_f_n_c1_character()); - } - X12 => { - return self.get_x12_words(); - } - EDF => { - return self.get_e_d_f_bytes(); - } - } - assert!(false); - return [0; 0]; - } -} - -struct Result { - bytes: Vec, -} - -impl Result { - fn new(solution: &Edge) -> Result { - let input: Input = solution.input; - let mut size: i32 = 0; - let bytes_a_l: List = Vec::new(); - let randomize_postfix_length: List = Vec::new(); - let randomize_lengths: List = Vec::new(); - if (solution.mode == Mode::C40 || solution.mode == Mode::TEXT || solution.mode == Mode::X12) - && solution.get_end_mode() != Mode::ASCII - { - size += ::prepend(&MinimalEncoder::Edge::get_bytes(254), &bytes_a_l); - } - let mut current: Edge = solution; - while current != null { - size += ::prepend(¤t.get_data_bytes(), &bytes_a_l); - if current.previous == null || current.get_previous_start_mode() != current.get_mode() { - if current.get_mode() == Mode::B256 { - if size <= 249 { - bytes_a_l.add(0, size as i8); - size += 1; - } else { - bytes_a_l.add(0, (size % 250) as i8); - bytes_a_l.add(0, (size / 250 + 249) as i8); - size += 2; - } - randomize_postfix_length.add(&bytes_a_l.size()); - randomize_lengths.add(size); - } - ::prepend(¤t.get_latch_bytes(), &bytes_a_l); - size = 0; - } - current = current.previous; - } - if input.get_macro_id() == 5 { - size += ::prepend(&MinimalEncoder::Edge::get_bytes(236), &bytes_a_l); - } else if input.get_macro_id() == 6 { - size += ::prepend(&MinimalEncoder::Edge::get_bytes(237), &bytes_a_l); - } - if input.get_f_n_c1_character() > 0 { - size += ::prepend(&MinimalEncoder::Edge::get_bytes(232), &bytes_a_l); - } - { - let mut i: i32 = 0; - while i < randomize_postfix_length.size() { - { - ::apply_random_pattern( - &bytes_a_l, - bytes_a_l.size() - randomize_postfix_length.get(i), - &randomize_lengths.get(i), - ); - } - i += 1; - } - } - - //add padding - let capacity: i32 = solution.get_min_symbol_size(&bytes_a_l.size()); - if bytes_a_l.size() < capacity { - bytes_a_l.add(129 as i8); - } - while bytes_a_l.size() < capacity { - bytes_a_l.add(::randomize253_state(bytes_a_l.size() + 1) as i8); - } - bytes = [0; bytes_a_l.size()]; - { - let mut i: i32 = 0; - while i < bytes.len() { - { - bytes[i] = bytes_a_l.get(i); - } - i += 1; - } - } - } - - fn prepend(bytes: &Vec, into: &List) -> i32 { - { - let mut i: i32 = bytes.len() - 1; - while i >= 0 { - { - into.add(0, bytes[i]); - } - i -= 1; - } - } - - return bytes.len(); - } - - fn randomize253_state(codeword_position: i32) -> i32 { - let pseudo_random: i32 = ((149 * codeword_position) % 253) + 1; - let temp_variable: i32 = 129 + pseudo_random; - return if temp_variable <= 254 { - temp_variable - } else { - temp_variable - 254 - }; - } - - fn apply_random_pattern(bytes_a_l: &List, start_position: i32, length: i32) { - { - let mut i: i32 = 0; - while i < length { - { - //See "B.1 253-state algorithm - const Pad_codeword_position: i32 = start_position + i; - const Pad_codeword_value: i32 = bytes_a_l.get(Pad_codeword_position) & 0xff; - let pseudo_random_number: i32 = ((149 * (Pad_codeword_position + 1)) % 255) + 1; - let temp_variable: i32 = Pad_codeword_value + pseudo_random_number; - bytes_a_l.set( - Pad_codeword_position, - (if temp_variable <= 255 { - temp_variable - } else { - temp_variable - 256 - }) as i8, - ); - } - i += 1; - } - } - } - - pub fn get_bytes(&self) -> Vec { - return self.bytes; - } -} - -struct Input { - _super: MinimalECIInput, - - shape: SymbolShapeHint, - - macro_id: i32, -} - -impl Input { - fn new( - string_to_encode: &String, - priority_charset: &Charset, - fnc1: i32, - shape: &SymbolShapeHint, - macro_id: i32, - ) -> Self { - Self { - _super: MinimalECIInput::new(&string_to_encode, &priority_charset, fnc1), - shape: shape, - macro_id: macro_id, - } - } - - fn get_macro_id(&self) -> i32 { - return self.macro_id; - } - - fn get_shape_hint(&self) -> SymbolShapeHint { - return self.shape; - } -} - -// SymbolInfo.java -/** - * Symbol info table for DataMatrix. - * - * @version $Id$ - */ - -const PROD_SYMBOLS: vec![Vec; 30] = vec![ - SymbolInfo::new_simple(false, 3, 5, 8, 8, 1), - SymbolInfo::new_simple(false, 5, 7, 10, 10, 1), /*rect*/ - SymbolInfo::new_simple(true, 5, 7, 16, 6, 1), - SymbolInfo::new_simple(false, 8, 10, 12, 12, 1), /*rect*/ - SymbolInfo::new_simple(true, 10, 11, 14, 6, 2), - SymbolInfo::new_simple(false, 12, 12, 14, 14, 1), /*rect*/ - SymbolInfo::new_simple(true, 16, 14, 24, 10, 1), - SymbolInfo::new_simple(false, 18, 14, 16, 16, 1), - SymbolInfo::new_simple(false, 22, 18, 18, 18, 1), /*rect*/ - SymbolInfo::new_simple(true, 22, 18, 16, 10, 2), - SymbolInfo::new_simple(false, 30, 20, 20, 20, 1), /*rect*/ - SymbolInfo::new_simple(true, 32, 24, 16, 14, 2), - SymbolInfo::new_simple(false, 36, 24, 22, 22, 1), - SymbolInfo::new_simple(false, 44, 28, 24, 24, 1), /*rect*/ - SymbolInfo::new_simple(true, 49, 28, 22, 14, 2), - SymbolInfo::new_simple(false, 62, 36, 14, 14, 4), - SymbolInfo::new_simple(false, 86, 42, 16, 16, 4), - SymbolInfo::new_simple(false, 114, 48, 18, 18, 4), - SymbolInfo::new_simple(false, 144, 56, 20, 20, 4), - SymbolInfo::new_simple(false, 174, 68, 22, 22, 4), - SymbolInfo::new(false, 204, 84, 24, 24, 4, 102, 42), - SymbolInfo::new(false, 280, 112, 14, 14, 16, 140, 56), - SymbolInfo::new(false, 368, 144, 16, 16, 16, 92, 36), - SymbolInfo::new(false, 456, 192, 18, 18, 16, 114, 48), - SymbolInfo::new(false, 576, 224, 20, 20, 16, 144, 56), - SymbolInfo::new(false, 696, 272, 22, 22, 16, 174, 68), - SymbolInfo::new(false, 816, 336, 24, 24, 16, 136, 56), - SymbolInfo::new(false, 1050, 408, 18, 18, 36, 175, 68), - SymbolInfo::new(false, 1304, 496, 20, 20, 36, 163, 62), - DataMatrixSymbolInfo144::new(), -]; - -pub struct SymbolInfo { - rectangular: bool, - - data_capacity: i32, - - error_codewords: i32, - - matrix_width: i32, - - matrix_height: i32, - - data_regions: i32, - - rs_block_data: i32, - - rs_block_error: i32, - - sumbols: Vec, -} - -impl SymbolInfo { - /** - * Overrides the symbol info set used by this class. Used for testing purposes. - * - * @param override the symbol info set to use - */ - pub fn override_symbol_set(&self, _override: &Vec) { - self.symbols = _override; - } - - pub fn new_simple( - rectangular: bool, - data_capacity: i32, - error_codewords: i32, - matrix_width: i32, - matrix_height: i32, - data_regions: i32, - ) -> Self { - Self::new( - rectangular, - data_capacity, - error_codewords, - matrix_width, - matrix_height, - data_regions, - data_capacity, - error_codewords, - ) - } - - fn new( - rectangular: bool, - data_capacity: i32, - error_codewords: i32, - matrix_width: i32, - matrix_height: i32, - data_regions: i32, - rs_block_data: i32, - rs_block_error: i32, - ) -> Self { - let new_si: Self; - - new_si.rectangular = rectangular; - new_si.dataCapacity = data_capacity; - new_si.errorCodewords = error_codewords; - new_si.matrixWidth = matrix_width; - new_si.matrixHeight = matrix_height; - new_si.dataRegions = data_regions; - new_si.rsBlockData = rs_block_data; - new_si.rsBlockError = rs_block_error; - - new_si - } - - pub fn lookup_simple(data_codewords: i32) -> SymbolInfo { - return ::lookup(data_codewords, SymbolShapeHint::FORCE_NONE, true); - } - - pub fn lookup_shape(data_codewords: i32, shape: &SymbolShapeHint) -> SymbolInfo { - return ::lookup(data_codewords, shape, true); - } - - pub fn lookup_allow_fail( - data_codewords: i32, - allow_rectangular: bool, - fail: bool, - ) -> SymbolInfo { - let shape: SymbolShapeHint = if allow_rectangular { - SymbolShapeHint::FORCE_NONE - } else { - SymbolShapeHint::FORCE_SQUARE - }; - return ::lookup(data_codewords, shape, fail); - } - - fn lookup_shape_fail(data_codewords: i32, shape: &SymbolShapeHint, fail: bool) -> SymbolInfo { - return ::lookup(data_codewords, shape, null, null, fail); - } - - pub fn lookup_complex( - data_codewords: i32, - shape: &SymbolShapeHint, - min_size: &Dimension, - max_size: &Dimension, - fail: bool, - ) -> SymbolInfo { - for symbol in symbols { - if shape == SymbolShapeHint::FORCE_SQUARE && symbol.rectangular { - continue; - } - if shape == SymbolShapeHint::FORCE_RECTANGLE && !symbol.rectangular { - continue; - } - if min_size != null - && (symbol.get_symbol_width() < min_size.get_width() - || symbol.get_symbol_height() < min_size.get_height()) - { - continue; - } - if max_size != null - && (symbol.get_symbol_width() > max_size.get_width() - || symbol.get_symbol_height() > max_size.get_height()) - { - continue; - } - if data_codewords <= symbol.dataCapacity { - return symbol; - } - } - if fail { - return Err(IllegalArgumentException::new(format!( - "Can't find a symbol arrangement that matches the message. Data codewords: {}", - data_codewords - ))); - } - return null; - } - - fn get_horizontal_data_regions(&self) -> Result { - match self.data_regions { - 1 => { - return Ok(1); - } - 2 => {} - 4 => { - return Ok(2); - } - 16 => { - return Ok(4); - } - 36 => { - return Ok(6); - } - _ => { - return Err(IllegalStateException::new( - "Cannot handle this number of data regions", - )); - } - } - } - - fn get_vertical_data_regions(&self) -> i32 { - match self.data_regions { - 1 => {} - 2 => { - return 1; - } - 4 => { - return 2; - } - 16 => { - return 4; - } - 36 => { - return 6; - } - _ => { - return Err(IllegalStateException::new( - "Cannot handle this number of data regions", - )); - } - } - } - - pub fn get_symbol_data_width(&self) -> i32 { - return self.get_horizontal_data_regions() * self.matrix_width; - } - - pub fn get_symbol_data_height(&self) -> i32 { - return self.get_vertical_data_regions() * self.matrix_height; - } - - pub fn get_symbol_width(&self) -> i32 { - return self.get_symbol_data_width() + (self.get_horizontal_data_regions() * 2); - } - - pub fn get_symbol_height(&self) -> i32 { - return self.get_symbol_data_height() + (self.get_vertical_data_regions() * 2); - } - - pub fn get_codeword_count(&self) -> i32 { - return self.data_capacity + self.error_codewords; - } - - pub fn get_interleaved_block_count(&self) -> i32 { - return self.data_capacity / self.rs_block_data; - } - - pub fn get_data_capacity(&self) -> i32 { - return self.data_capacity; - } - - pub fn get_error_codewords(&self) -> i32 { - return self.error_codewords; - } - - pub fn get_data_length_for_interleaved_block(&self, index: i32) -> i32 { - return self.rs_block_data; - } - - pub fn get_error_length_for_interleaved_block(&self, index: i32) -> i32 { - return self.rs_block_error; - } - - pub fn to_string(&self) -> String { - return format!( - "{} data region {}x{}, symbol size {}x{}, symbol data size {}x{}, codewords {}+{}", - (if self.rectangular { - "Rectangular Symbol:" - } else { - "Square Symbol:" - }), - self.matrix_width, - self.matrix_height, - self.get_symbol_width(), - self.get_symbol_height(), - self.get_symbol_data_width(), - self.get_symbol_data_height(), - self.data_capacity, - self.error_codewords - ); - } -} - -// SymbolShapeHint.java -/** - * Enumeration for DataMatrix symbol shape hint. It can be used to force square or rectangular - * symbols. - */ -pub enum SymbolShapeHint { - FORCE_NONE(), - FORCE_SQUARE(), - FORCE_RECTANGLE(), -} - -// TextEncoder.java -struct TextEncoder { - _super: C40Encoder, -} - -impl TextEncoder { - pub fn new() -> Self { - Self { - _super: C40Encoder::new(), - } - } - - pub fn get_encoding_mode(&self) -> i32 { - return HighLevelEncoder::TEXT_ENCODATION; - } - - fn encode_char(&self, c: char, sb: &StringBuilder) -> i32 { - if c == ' ' { - sb.append('\u{0003}'); - return 1; - } - if c >= '0' && c <= '9' { - sb.append((c - 48 + 4) as char); - return 1; - } - if c >= 'a' && c <= 'z' { - sb.append((c - 97 + 14) as char); - return 1; - } - if c < ' ' { - //Shift 1 Set - sb.append('\0'); - sb.append(c); - return 2; - } - if c <= '/' { - //Shift 2 Set - sb.append('\u{0001}'); - sb.append((c - 33) as char); - return 2; - } - if c <= '@' { - //Shift 2 Set - sb.append('\u{0001}'); - sb.append((c - 58 + 15) as char); - return 2; - } - if c >= '[' && c <= '_' { - //Shift 2 Set - sb.append('\u{0001}'); - sb.append((c - 91 + 22) as char); - return 2; - } - if c == '`' { - //Shift 3 Set - sb.append('\u{0002}'); - // '`' - 96 == 0 - sb.append(0 as char); - return 2; - } - if c <= 'Z' { - //Shift 3 Set - sb.append('\u{0002}'); - sb.append((c - 65 + 1) as char); - return 2; - } - if c <= 127 { - //Shift 3 Set - sb.append('\u{0002}'); - sb.append((c - 123 + 27) as char); - return 2; - } - //Shift 2, Upper Shift - sb.append("\u{0001}\u{001e}"); - let mut len: i32 = 2; - len += self.encode_char((c - 128) as char, &sb); - return len; - } -} - -// X12Encoder.java -struct X12Encoder { - _super: C40Encoder, -} - -impl X12Encoder { - pub fn new() -> Self { - Self { - _super: C40Encoder::new(), - } - } - - pub fn get_encoding_mode(&self) -> i32 { - return HighLevelEncoder::X12_ENCODATION; - } - - pub fn encode(&self, context: &EncoderContext) { - //step C - let buffer: StringBuilder = StringBuilder::new(); - while context.has_more_characters() { - let c: char = context.get_current_char(); - context.pos += 1; - self.encode_char(c, &buffer); - let count: i32 = buffer.length(); - if (count % 3) == 0 { - write_next_triplet(context, &buffer); - let new_mode: i32 = HighLevelEncoder::look_ahead_test( - &context.get_message(), - context.pos, - &self.get_encoding_mode(), - ); - if new_mode != self.get_encoding_mode() { - // Return to ASCII encodation, which will actually handle latch to new mode - context.signal_encoder_change(HighLevelEncoder::ASCII_ENCODATION); - break; - } - } - } - self.handle_e_o_d(context, &buffer); - } - - fn encode_char(&self, c: char, sb: &StringBuilder) -> i32 { - match c { - '\r' => { - sb.append('\0'); - } - '*' => { - sb.append('\u{0001}'); - } - '>' => { - sb.append('\u{0002}'); - } - ' ' => { - sb.append('\u{0003}'); - } - _ => { - if c >= '0' && c <= '9' { - sb.append((c - 48 + 4) as char); - } else if c >= 'A' && c <= 'Z' { - sb.append((c - 65 + 14) as char); - } else { - HighLevelEncoder::illegal_character(c); - } - } - } - return 1; - } - - fn handle_e_o_d(&self, context: &EncoderContext, buffer: &StringBuilder) { - context.update_symbol_info_simple(); - let available: i32 = - context.get_symbol_info().get_data_capacity() - context.get_codeword_count(); - let count: i32 = buffer.length(); - context.pos -= count; - if context.get_remaining_characters() > 1 - || available > 1 - || context.get_remaining_characters() != available - { - context.write_codeword(HighLevelEncoder::X12_UNLATCH); - } - if context.get_new_encoding() < 0 { - context.signal_encoder_change(HighLevelEncoder::ASCII_ENCODATION); - } - } -} diff --git a/src/maxicode.rs b/src/maxicode.rs deleted file mode 100644 index 088243e..0000000 --- a/src/maxicode.rs +++ /dev/null @@ -1,102 +0,0 @@ -pub mod decoder; - -use crate::{BarcodeFormat,BinaryBitmap,ChecksumException,DecodeHintType,FormatException,NotFoundException,Reader,XRingResultResultMetadataType,ResultPoint}; -use crate::common::{BitMatrix,DecoderResult}; -use crate::maxicode::decoder::Decoder; - -// MaxiCodeReader.java - -/** - * This implementation can detect and decode a MaxiCode in an image. - */ - -const NO_POINTS: [Option; 0] = [None; 0]; - -const MATRIX_WIDTH: i32 = 30; - -const MATRIX_HEIGHT: i32 = 33; -pub struct MaxiCodeReader { - - decoder: Decoder -} - -impl Reader for MaxiCodeReader{ -/** - * Locates and decodes a MaxiCode in an image. - * - * @return a String representing the content encoded by the MaxiCode - * @throws NotFoundException if a MaxiCode cannot be found - * @throws FormatException if a MaxiCode cannot be decoded - * @throws ChecksumException if error correction fails - */ - - fn decode(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException, ChecksumException, FormatException */Result> { - // Note that MaxiCode reader effectively always assumes PURE_BARCODE mode - // and can't detect it in an image - let bits: BitMatrix = ::extract_pure_bits(&image.get_black_matrix()); - let decoder_result: DecoderResult = self.decoder.decode(&bits, &hints); - let result: Result = Result::new(&decoder_result.get_text(), &decoder_result.get_raw_bytes(), NO_POINTS, BarcodeFormat::MAXICODE); - let ec_level: String = decoder_result.get_e_c_level(); - if ec_level != null { - result.put_metadata(ResultMetadataType::ERROR_CORRECTION_LEVEL, &ec_level); - } - return Ok(result); -} - - fn reset(&self) { -// do nothing -} -} - -impl MaxiCodeReader { - - pub fn new() -> Self { - Self { decoder: Decoder::new() } - } - - /** - * This method detects a code in a "pure" image -- that is, pure monochrome image - * which contains only an unrotated, unskewed, image of a code, with some white border - * around it. This is a specialized method that works exceptionally fast in this special - * case. - */ - fn extract_pure_bits( image: &BitMatrix) -> Result { - let enclosing_rectangle: Vec = image.get_enclosing_rectangle(); - if enclosing_rectangle == null { - return Err( NotFoundException::get_not_found_instance()); - } - let left: i32 = enclosing_rectangle[0]; - let top: i32 = enclosing_rectangle[1]; - let width: i32 = enclosing_rectangle[2]; - let height: i32 = enclosing_rectangle[3]; - // Now just read off the bits - let bits: BitMatrix = BitMatrix::new(MATRIX_WIDTH, MATRIX_HEIGHT); - { - let mut y: i32 = 0; - while y < MATRIX_HEIGHT { - { - let iy: i32 = Math::min(top + (y * height + height / 2) / MATRIX_HEIGHT, height - 1); - { - let mut x: i32 = 0; - while x < MATRIX_WIDTH { - { - // srowen: I don't quite understand why the formula below is necessary, but it - // can walk off the image if left + width = the right boundary. So cap it. - let ix: i32 = left + Math::min((x * width + width / 2 + (y & 0x01) * width / 2) / MATRIX_WIDTH, width - 1); - if image.get(ix, iy) { - bits.set(x, y); - } - } - x += 1; - } - } - - } - y += 1; - } - } - - return Ok(bits); - } -} - diff --git a/src/maxicode/decoder.rs b/src/maxicode/decoder.rs deleted file mode 100644 index c2d8c33..0000000 --- a/src/maxicode/decoder.rs +++ /dev/null @@ -1,450 +0,0 @@ -use crate::common::{BitMatrix,DecoderResult}; -use crate::{FormatException,ChecksumException,DecodeHintType,FormatException}; -use crate::common::reedsolomon::{GenericGF,ReedSolomonDecoder,ReedSolomonException}; - - -// BitMatrixParser.java -/** - * @author mike32767 - * @author Manuel Kasten - */ - -const BITNR: vec![vec![Vec>; 30]; 33] = vec![vec![121, 120, 127, 126, 133, 132, 139, 138, 145, 144, 151, 150, 157, 156, 163, 162, 169, 168, 175, 174, 181, 180, 187, 186, 193, 192, 199, 198, -2, -2, ] -, vec![123, 122, 129, 128, 135, 134, 141, 140, 147, 146, 153, 152, 159, 158, 165, 164, 171, 170, 177, 176, 183, 182, 189, 188, 195, 194, 201, 200, 816, -3, ] -, vec![125, 124, 131, 130, 137, 136, 143, 142, 149, 148, 155, 154, 161, 160, 167, 166, 173, 172, 179, 178, 185, 184, 191, 190, 197, 196, 203, 202, 818, 817, ] -, vec![283, 282, 277, 276, 271, 270, 265, 264, 259, 258, 253, 252, 247, 246, 241, 240, 235, 234, 229, 228, 223, 222, 217, 216, 211, 210, 205, 204, 819, -3, ] -, vec![285, 284, 279, 278, 273, 272, 267, 266, 261, 260, 255, 254, 249, 248, 243, 242, 237, 236, 231, 230, 225, 224, 219, 218, 213, 212, 207, 206, 821, 820, ] -, vec![287, 286, 281, 280, 275, 274, 269, 268, 263, 262, 257, 256, 251, 250, 245, 244, 239, 238, 233, 232, 227, 226, 221, 220, 215, 214, 209, 208, 822, -3, ] -, vec![289, 288, 295, 294, 301, 300, 307, 306, 313, 312, 319, 318, 325, 324, 331, 330, 337, 336, 343, 342, 349, 348, 355, 354, 361, 360, 367, 366, 824, 823, ] -, vec![291, 290, 297, 296, 303, 302, 309, 308, 315, 314, 321, 320, 327, 326, 333, 332, 339, 338, 345, 344, 351, 350, 357, 356, 363, 362, 369, 368, 825, -3, ] -, vec![293, 292, 299, 298, 305, 304, 311, 310, 317, 316, 323, 322, 329, 328, 335, 334, 341, 340, 347, 346, 353, 352, 359, 358, 365, 364, 371, 370, 827, 826, ] -, vec![409, 408, 403, 402, 397, 396, 391, 390, 79, 78, -2, -2, 13, 12, 37, 36, 2, -1, 44, 43, 109, 108, 385, 384, 379, 378, 373, 372, 828, -3, ] -, vec![411, 410, 405, 404, 399, 398, 393, 392, 81, 80, 40, -2, 15, 14, 39, 38, 3, -1, -1, 45, 111, 110, 387, 386, 381, 380, 375, 374, 830, 829, ] -, vec![413, 412, 407, 406, 401, 400, 395, 394, 83, 82, 41, -3, -3, -3, -3, -3, 5, 4, 47, 46, 113, 112, 389, 388, 383, 382, 377, 376, 831, -3, ] -, vec![415, 414, 421, 420, 427, 426, 103, 102, 55, 54, 16, -3, -3, -3, -3, -3, -3, -3, 20, 19, 85, 84, 433, 432, 439, 438, 445, 444, 833, 832, ] -, vec![417, 416, 423, 422, 429, 428, 105, 104, 57, 56, -3, -3, -3, -3, -3, -3, -3, -3, 22, 21, 87, 86, 435, 434, 441, 440, 447, 446, 834, -3, ] -, vec![419, 418, 425, 424, 431, 430, 107, 106, 59, 58, -3, -3, -3, -3, -3, -3, -3, -3, -3, 23, 89, 88, 437, 436, 443, 442, 449, 448, 836, 835, ] -, vec![481, 480, 475, 474, 469, 468, 48, -2, 30, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, 0, 53, 52, 463, 462, 457, 456, 451, 450, 837, -3, ] -, vec![483, 482, 477, 476, 471, 470, 49, -1, -2, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -2, -1, 465, 464, 459, 458, 453, 452, 839, 838, ] -, vec![485, 484, 479, 478, 473, 472, 51, 50, 31, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, 1, -2, 42, 467, 466, 461, 460, 455, 454, 840, -3, ] -, vec![487, 486, 493, 492, 499, 498, 97, 96, 61, 60, -3, -3, -3, -3, -3, -3, -3, -3, -3, 26, 91, 90, 505, 504, 511, 510, 517, 516, 842, 841, ] -, vec![489, 488, 495, 494, 501, 500, 99, 98, 63, 62, -3, -3, -3, -3, -3, -3, -3, -3, 28, 27, 93, 92, 507, 506, 513, 512, 519, 518, 843, -3, ] -, vec![491, 490, 497, 496, 503, 502, 101, 100, 65, 64, 17, -3, -3, -3, -3, -3, -3, -3, 18, 29, 95, 94, 509, 508, 515, 514, 521, 520, 845, 844, ] -, vec![559, 558, 553, 552, 547, 546, 541, 540, 73, 72, 32, -3, -3, -3, -3, -3, -3, 10, 67, 66, 115, 114, 535, 534, 529, 528, 523, 522, 846, -3, ] -, vec![561, 560, 555, 554, 549, 548, 543, 542, 75, 74, -2, -1, 7, 6, 35, 34, 11, -2, 69, 68, 117, 116, 537, 536, 531, 530, 525, 524, 848, 847, ] -, vec![563, 562, 557, 556, 551, 550, 545, 544, 77, 76, -2, 33, 9, 8, 25, 24, -1, -2, 71, 70, 119, 118, 539, 538, 533, 532, 527, 526, 849, -3, ] -, vec![565, 564, 571, 570, 577, 576, 583, 582, 589, 588, 595, 594, 601, 600, 607, 606, 613, 612, 619, 618, 625, 624, 631, 630, 637, 636, 643, 642, 851, 850, ] -, vec![567, 566, 573, 572, 579, 578, 585, 584, 591, 590, 597, 596, 603, 602, 609, 608, 615, 614, 621, 620, 627, 626, 633, 632, 639, 638, 645, 644, 852, -3, ] -, vec![569, 568, 575, 574, 581, 580, 587, 586, 593, 592, 599, 598, 605, 604, 611, 610, 617, 616, 623, 622, 629, 628, 635, 634, 641, 640, 647, 646, 854, 853, ] -, vec![727, 726, 721, 720, 715, 714, 709, 708, 703, 702, 697, 696, 691, 690, 685, 684, 679, 678, 673, 672, 667, 666, 661, 660, 655, 654, 649, 648, 855, -3, ] -, vec![729, 728, 723, 722, 717, 716, 711, 710, 705, 704, 699, 698, 693, 692, 687, 686, 681, 680, 675, 674, 669, 668, 663, 662, 657, 656, 651, 650, 857, 856, ] -, vec![731, 730, 725, 724, 719, 718, 713, 712, 707, 706, 701, 700, 695, 694, 689, 688, 683, 682, 677, 676, 671, 670, 665, 664, 659, 658, 653, 652, 858, -3, ] -, vec![733, 732, 739, 738, 745, 744, 751, 750, 757, 756, 763, 762, 769, 768, 775, 774, 781, 780, 787, 786, 793, 792, 799, 798, 805, 804, 811, 810, 860, 859, ] -, vec![735, 734, 741, 740, 747, 746, 753, 752, 759, 758, 765, 764, 771, 770, 777, 776, 783, 782, 789, 788, 795, 794, 801, 800, 807, 806, 813, 812, 861, -3, ] -, vec![737, 736, 743, 742, 749, 748, 755, 754, 761, 760, 767, 766, 773, 772, 779, 778, 785, 784, 791, 790, 797, 796, 803, 802, 809, 808, 815, 814, 863, 862, ] -, ] -; -struct BitMatrixParser { - - bit_matrix: BitMatrix -} - -impl BitMatrixParser { - - /** - * @param bitMatrix {@link BitMatrix} to parse - */ - fn new( bit_matrix: &BitMatrix) -> Self { - Self { - bit_matrix - } - } - - fn read_codewords(&self) -> Vec { - let mut result: [i8; 144] = [0; 144]; - let height: i32 = self.bit_matrix.get_height(); - let width: i32 = self.bit_matrix.get_width(); - { - let mut y: i32 = 0; - while y < height { - { - let bitnr_row: Vec = BITNR[y]; - { - let mut x: i32 = 0; - while x < width { - { - let mut bit: i32 = bitnr_row[x]; - if bit >= 0 && self.bit_matrix.get(x, y) { - result[bit / 6] |= (1 << (5 - (bit % 6))) as i8; - } - } - x += 1; - } - } - - } - y += 1; - } - } - - return result; - } -} - - -// DecodedBitStreamParser.java - -/** - *

MaxiCodes can encode text or structured information as bits in one of several modes, - * with multiple character sets in one code. This class decodes the bits back into text.

- * - * @author mike32767 - * @author Manuel Kasten - */ - -const SHIFTA: char = '\u{FFF0}'; - -const SHIFTB: char = '\u{FFF1}'; - -const SHIFTC: char = '\u{FFF2}'; - -const SHIFTD: char = '\u{FFF3}'; - -const SHIFTE: char = '\u{FFF4}'; - -const TWOSHIFTA: char ='\u{FFF5}'; - -const THREESHIFTA: char ='\u{FFF6}'; - -const LATCHA: char = '\u{FFF7}'; - -const LATCHB: char = '\u{FFF8}'; - -const LOCK: char = '\u{FFF9}'; - -const ECI: char ='\u{FFFA}'; - -const NS: char ='\u{FFFB}'; - -const PAD: char = '\u{FFFC}'; - -const FS: char = '\u{001C}'; - -const GS: char = '\u{001D}'; - -const RS: char = '\u{001E}'; - -const COUNTRY_BYTES: vec![Vec; 10] = vec![53, 54, 43, 44, 45, 46, 47, 48, 37, 38, ] -; - -const SERVICE_CLASS_BYTES: vec![Vec; 10] = vec![55, 56, 57, 58, 59, 60, 49, 50, 51, 52, ] -; - -const POSTCODE_2_LENGTH_BYTES: vec![Vec; 6] = vec![39, 40, 41, 42, 31, 32, ] -; - -const POSTCODE_2_BYTES: vec![Vec; 30] = vec![33, 34, 35, 36, 25, 26, 27, 28, 29, 30, 19, 20, 21, 22, 23, 24, 13, 14, 15, 16, 17, 18, 7, 8, 9, 10, 11, 12, 1, 2, ] -; - -const POSTCODE_3_BYTES: vec![vec![Vec>; 6]; 6] = vec![vec![39, 40, 41, 42, 31, 32, ] -, vec![33, 34, 35, 36, 25, 26, ] -, vec![27, 28, 29, 30, 19, 20, ] -, vec![21, 22, 23, 24, 13, 14, ] -, vec![15, 16, 17, 18, 7, 8, ] -, vec![9, 10, 11, 12, 1, 2, ] -, ] -; - - -const SETS: vec![Vec; 5] = vec![ - format!("\rABCDEFGHIJKLMNOPQRSTUVWXYZ{}{}{}{}{} {}\"#$%&'()*+,-./0123456789:{}{}{}{}{}" , ECI , FS , GS , RS , NS , PAD ,SHIFTB , SHIFTC , SHIFTD , SHIFTE , LATCHB), - format!("`abcdefghijklmnopqrstuvwxyz{}{}{}{}{}\{{}\}{}{}{}{}{}{}{}{}{}", ECI, FS, GS , RS , NS , PAD ,PAD , TWOSHIFTA , THREESHIFTA , PAD ,SHIFTA , SHIFTC , SHIFTD, SHIFTE , LATCHA), - format!("\u{00C0}\u{00C1}\u{00C2}\u{00C3}\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA{}{}{}{}{}\u00DB\u00DC\u00DD\u00DE\u00DF\u00AA\u00AC\u00B1\u00B2\u00B3\u00B5\u00B9\u00BA\u00BC\u00BD\u00BE\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089{} {}{}{}{}",ECI , FS , GS , RS , NS ,LATCHA , LOCK , SHIFTD , SHIFTE , LATCHB), - format!("\u{00E0}\u{00E1}\u{00E2}\u{00E3}\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA{}{}{}{}{}\u00FB\u00FC\u00FD\u00FE\u00FF\u00A1\u00A8\u00AB\u00AF\u00B0\u00B4\u00B7\u00B8\u00BB\u00BF\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094{} {}{}{}{}" ,ECI , FS , GS, RS , NS ,LATCHA , SHIFTC , LOCK , SHIFTE , LATCHB), - format!("\u{0000}\u{0001}\u{0002}\u{0003}\u0004\u0005\u0006\u0007\u0008\u0009\n\u000B\u000C\r\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A{}{}{}\u001B{}{}{}{}\u001F\u009F\u00A0\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A9\u00AD\u00AE\u00B6\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E{} {}{}{}{}" ,ECI , PAD, PAD , NS , FS , GS , RS , LATCHA , SHIFTC , SHIFTD , LOCK , LATCHB) -]; - -struct DecodedBitStreamParser { -} - -impl DecodedBitStreamParser { - - fn new() -> DecodedBitStreamParser { - } - - fn decode( bytes: &Vec, mode: i32) -> /* throws FormatException */Result> { - let result: StringBuilder = StringBuilder::new(144); - match mode { - 2 => - { - } - 3 => - { - let mut postcode: String; - if mode == 2 { - let pc: i32 = ::get_post_code2(&bytes); - let ps2_length: i32 = ::get_post_code2_length(&bytes); - if ps2_length > 10 { - return Err( FormatException::get_format_instance()); - } - let df: NumberFormat = DecimalFormat::new(&"0000000000".substring(0, ps2_length)); - postcode = df.format(pc); - } else { - postcode = ::get_post_code3(&bytes); - } - let three_digits: NumberFormat = DecimalFormat::new("000"); - let country: String = three_digits.format(&::get_country(&bytes)); - let service: String = three_digits.format(&::get_service_class(&bytes)); - result.append(&::get_message(&bytes, 10, 84)); - if result.to_string().starts_with(format!("[)>{}01{}", RS, GS)) { - result.insert(9, format!("{}{}{}{}{}{}", postcode, GS, country, GS, service, GS)); - } else { - result.insert(0, format!("{}{}{}{}{}{}", postcode, GS, country, GS, service, GS)); - } - } - 4 => - { - result.append(&::get_message(&bytes, 1, 93)); - } - 5 => - { - result.append(&::get_message(&bytes, 1, 77)); - } - } - return Ok(DecoderResult::new(&bytes, &result.to_string(), null, &String::value_of(mode), None, None, None)); - } - - fn get_bit( bit: i32, bytes: &Vec) -> i32 { - bit -= 1; - return if (bytes[bit / 6] & (1 << (5 - (bit % 6)))) == 0 { 0 } else { 1 }; - } - - fn get_int( bytes: &Vec, x: &Vec) -> i32 { - let mut val: i32 = 0; - { - let mut i: i32 = 0; - while i < x.len() { - { - val += ::get_bit(x[i], &bytes) << (x.len() - i - 1); - } - i += 1; - } - } - - return val; - } - - fn get_country( bytes: &Vec) -> i32 { - return ::get_int(&bytes, &COUNTRY_BYTES); - } - - fn get_service_class( bytes: &Vec) -> i32 { - return ::get_int(&bytes, &SERVICE_CLASS_BYTES); - } - - fn get_post_code2_length( bytes: &Vec) -> i32 { - return ::get_int(&bytes, &POSTCODE_2_LENGTH_BYTES); - } - - fn get_post_code2( bytes: &Vec) -> i32 { - return ::get_int(&bytes, &POSTCODE_2_BYTES); - } - - fn get_post_code3( bytes: &Vec) -> String { - let sb: StringBuilder = StringBuilder::new(POSTCODE_3_BYTES.len()); - for p3bytes in POSTCODE_3_BYTES { - sb.append(&SETS[0].char_at(&::get_int(&bytes, &p3bytes))); - } - return sb.to_string(); - } - - fn get_message( bytes: &Vec, start: i32, len: i32) -> String { - let sb: StringBuilder = StringBuilder::new(); - let mut shift: i32 = -1; - let mut set: i32 = 0; - let mut lastset: i32 = 0; - { - let mut i: i32 = start; - while i < start + len { - { - let c: char = SETS[set].char_at(bytes[i]); - match c { - LATCHA => - { - set = 0; - shift = -1; - break; - } - LATCHB => - { - set = 1; - shift = -1; - break; - } - SHIFTA => - { - } - SHIFTB => - { - } - SHIFTC => - { - } - SHIFTD => - { - } - SHIFTE => - { - lastset = set; - set = c - SHIFTA; - shift = 1; - break; - } - TWOSHIFTA => - { - lastset = set; - set = 0; - shift = 2; - break; - } - THREESHIFTA => - { - lastset = set; - set = 0; - shift = 3; - break; - } - NS => - { - let nsval: i32 = (bytes[i += 1] << 24) + (bytes[i += 1] << 18) + (bytes[i += 1] << 12) + (bytes[i += 1] << 6) + bytes[i += 1]; - sb.append(&DecimalFormat::new("000000000").format(nsval)); - break; - } - LOCK => - { - shift = -1; - break; - } - _ => - { - sb.append(c); - } - } - if shift -= 1 == 0 { - set = lastset; - } - } - i += 1; - } - } - - while sb.length() > 0 && sb.char_at(sb.length() - 1) == PAD { - sb.set_length(sb.length() - 1); - } - return sb.to_string(); - } -} - -// Decoder.java -/** - *

The main class which implements MaxiCode decoding -- as opposed to locating and extracting - * the MaxiCode from an image.

- * - * @author Manuel Kasten - */ - -const ALL: i32 = 0; - -const EVEN: i32 = 1; - -const ODD: i32 = 2; -pub struct Decoder { - - rs_decoder: ReedSolomonDecoder -} - -impl Decoder { - - pub fn new() -> Decoder { - rs_decoder = ReedSolomonDecoder::new(GenericGF::MAXICODE_FIELD_64); - } - - pub fn decode_simple(&self, bits: &BitMatrix) -> Result { - return Ok(self.decode(bits, null)); - } - - pub fn decode(&self, bits: &BitMatrix, hints: &Map) -> Result { - let parser: BitMatrixParser = BitMatrixParser::new(bits); - let codewords: Vec = parser.read_codewords(); - self.correct_errors(&codewords, 0, 10, 10, ALL); - let mode: i32 = codewords[0] & 0x0F; - let mut datawords: Vec; - match mode { - 2 => - { - } - 3 => - { - } - 4 => - { - self.correct_errors(&codewords, 20, 84, 40, EVEN); - self.correct_errors(&codewords, 20, 84, 40, ODD); - datawords = [0; 94]; - } - 5 => - { - self.correct_errors(&codewords, 20, 68, 56, EVEN); - self.correct_errors(&codewords, 20, 68, 56, ODD); - datawords = [0; 78]; - } - _ => - { - return Err( FormatException::get_format_instance()); - } - } - System::arraycopy(&codewords, 0, &datawords, 0, 10); - System::arraycopy(&codewords, 20, &datawords, 10, datawords.len() - 10); - return Ok(DecodedBitStreamParser::decode(&datawords, mode)); - } - - fn correct_errors(&self, codeword_bytes: &Vec, start: i32, data_codewords: i32, ec_codewords: i32, mode: i32) -> Result<(), ChecksumException> { - let codewords: i32 = data_codewords + ec_codewords; - // in EVEN or ODD mode only half the codewords - let mut divisor: i32 = if mode == ALL { 1 } else { 2 }; - // First read into an array of ints - let codewords_ints: [i32; codewords / divisor] = [0; codewords / divisor]; - { - let mut i: i32 = 0; - while i < codewords { - { - if (mode == ALL) || (i % 2 == (mode - 1)) { - codewords_ints[i / divisor] = codeword_bytes[i + start] & 0xFF; - } - } - i += 1; - } - } - - - self.rs_decoder.decode(&codewords_ints, ec_codewords / divisor); - - - // We don't care about errors in the error-correction codewords - { - let mut i: i32 = 0; - while i < data_codewords { - { - if (mode == ALL) || (i % 2 == (mode - 1)) { - codeword_bytes[i + start] = codewords_ints[i / divisor] as i8; - } - } - i += 1; - } - } - - Ok(()) - - } -} - diff --git a/src/multi.rs b/src/multi.rs deleted file mode 100644 index fd49870..0000000 --- a/src/multi.rs +++ /dev/null @@ -1,285 +0,0 @@ -use crate::{BinaryBitmap,DecodeHintType,NotFoundException,RXingResult,Reader,ReaderException,ResultPoint,ChecksumException,FormatException}; - -// ByQuadrantReader.java -/** - * This class attempts to decode a barcode from an image, not by scanning the whole image, - * but by scanning subsets of the image. This is important when there may be multiple barcodes in - * an image, and detecting a barcode may find parts of multiple barcode and fail to decode - * (e.g. QR Codes). Instead this scans the four quadrants of the image -- and also the center - * 'quadrant' to cover the case where a barcode is found in the center. - * - * @see GenericMultipleBarcodeReader - */ -pub struct ByQuadrantReader { - - let delegate: Reader; -} - -impl Reader for ByQuadrantReader { - pub fn decode(&self, image: &BinaryBitmap) -> /* throws NotFoundException, ChecksumException, FormatException */Result> { - return Ok(self.decode(image, null)); - } - - pub fn decode(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException, ChecksumException, FormatException */Result> { - let width: i32 = image.get_width(); - let height: i32 = image.get_height(); - let half_width: i32 = width / 2; - let half_height: i32 = height / 2; - let tryResult1 = 0; - 'try1: loop { - { - // No need to call makeAbsolute as results will be relative to original top left here - return Ok(self.delegate.decode(&image.crop(0, 0, half_width, half_height), &hints)); - } - break 'try1 - } - match tryResult1 { - catch ( re: &NotFoundException) { - } 0 => break - } - - let tryResult1 = 0; - 'try1: loop { - { - let result: Result = self.delegate.decode(&image.crop(half_width, 0, half_width, half_height), &hints); - ::make_absolute(&result.get_result_points(), half_width, 0); - return Ok(result); - } - break 'try1 - } - match tryResult1 { - catch ( re: &NotFoundException) { - } 0 => break - } - - let tryResult1 = 0; - 'try1: loop { - { - let result: Result = self.delegate.decode(&image.crop(0, half_height, half_width, half_height), &hints); - ::make_absolute(&result.get_result_points(), 0, half_height); - return Ok(result); - } - break 'try1 - } - match tryResult1 { - catch ( re: &NotFoundException) { - } 0 => break - } - - let tryResult1 = 0; - 'try1: loop { - { - let result: Result = self.delegate.decode(&image.crop(half_width, half_height, half_width, half_height), &hints); - ::make_absolute(&result.get_result_points(), half_width, half_height); - return Ok(result); - } - break 'try1 - } - match tryResult1 { - catch ( re: &NotFoundException) { - } 0 => break - } - - let quarter_width: i32 = half_width / 2; - let quarter_height: i32 = half_height / 2; - let center: BinaryBitmap = image.crop(quarter_width, quarter_height, half_width, half_height); - let result: Result = self.delegate.decode(center, &hints); - ::make_absolute(&result.get_result_points(), quarter_width, quarter_height); - return Ok(result); - } - - pub fn reset(&self) { - self.delegate.reset(); - } -} - -impl ByQuadrantReader { - - pub fn new( delegate: &Reader) -> ByQuadrantReader { - let .delegate = delegate; - } - - - - fn make_absolute( points: &Vec, left_offset: i32, top_offset: i32) { - if points != null { - { - let mut i: i32 = 0; - while i < points.len() { - { - let relative: ResultPoint = points[i]; - if relative != null { - points[i] = ResultPoint::new(relative.get_x() + left_offset, relative.get_y() + top_offset); - } - } - i += 1; - } - } - - } - } -} - - -// MultipleBarcodeReader.java -/** - * Implementation of this interface attempt to read several barcodes from one image. - * - * @see com.google.zxing.Reader - * @author Sean Owen - */ -pub trait MultipleBarcodeReader { - - fn decode_multiple(&self, image: &BinaryBitmap) -> /* throws NotFoundException */Result, Rc> ; - - fn decode_multiple(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException */Result, Rc> ; -} - -// GenericMultipleBarcodeReader.java -/** - *

Attempts to locate multiple barcodes in an image by repeatedly decoding portion of the image. - * After one barcode is found, the areas left, above, right and below the barcode's - * {@link ResultPoint}s are scanned, recursively.

- * - *

A caller may want to also employ {@link ByQuadrantReader} when attempting to find multiple - * 2D barcodes, like QR Codes, in an image, where the presence of multiple barcodes might prevent - * detecting any one of them.

- * - *

That is, instead of passing a {@link Reader} a caller might pass - * {@code new ByQuadrantReader(reader)}.

- * - * @author Sean Owen - */ - -const MIN_DIMENSION_TO_RECUR: i32 = 100; - -const MAX_DEPTH: i32 = 4; - -const EMPTY_RESULT_ARRAY: [Option; 0] = [None; 0]; - -pub struct GenericMultipleBarcodeReader { - - let delegate: Reader; -} - -impl MultipleBarcodeReader for GenericMultipleBarcodeReader { - pub fn decode_multiple(&self, image: &BinaryBitmap) -> /* throws NotFoundException */Result, Rc> { - return Ok(self.decode_multiple(image, null)); - } - - pub fn decode_multiple(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException */Result, Rc> { - let results: List = ArrayList<>::new(); - self.do_decode_multiple(image, &hints, &results, 0, 0, 0); - if results.is_empty() { - throw NotFoundException::get_not_found_instance(); - } - return Ok(results.to_array(EMPTY_RESULT_ARRAY)); - } -} - -impl GenericMultipleBarcodeReader { - - pub fn new( delegate: &Reader) -> GenericMultipleBarcodeReader { - let .delegate = delegate; - } - - - fn do_decode_multiple(&self, image: &BinaryBitmap, hints: &Map, results: &List, x_offset: i32, y_offset: i32, current_depth: i32) { - if current_depth > MAX_DEPTH { - return; - } - let mut result: Result; - let tryResult1 = 0; - 'try1: loop { - { - result = self.delegate.decode(image, &hints); - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &ReaderException) { - return; - } 0 => break - } - - let already_found: bool = false; - for let existing_result: Result in results { - if existing_result.get_text().equals(&result.get_text()) { - already_found = true; - break; - } - } - if !already_found { - results.add(&::translate_result_points(result, x_offset, y_offset)); - } - let result_points: Vec = result.get_result_points(); - if result_points == null || result_points.len() == 0 { - return; - } - let width: i32 = image.get_width(); - let height: i32 = image.get_height(); - let min_x: f32 = width; - let min_y: f32 = height; - let max_x: f32 = 0.0f; - let max_y: f32 = 0.0f; - for let point: ResultPoint in result_points { - if point == null { - continue; - } - let x: f32 = point.get_x(); - let y: f32 = point.get_y(); - if x < min_x { - min_x = x; - } - if y < min_y { - min_y = y; - } - if x > max_x { - max_x = x; - } - if y > max_y { - max_y = y; - } - } - // Decode left of barcode - if min_x > MIN_DIMENSION_TO_RECUR { - self.do_decode_multiple(&image.crop(0, 0, min_x as i32, height), &hints, &results, x_offset, y_offset, current_depth + 1); - } - // Decode above barcode - if min_y > MIN_DIMENSION_TO_RECUR { - self.do_decode_multiple(&image.crop(0, 0, width, min_y as i32), &hints, &results, x_offset, y_offset, current_depth + 1); - } - // Decode right of barcode - if max_x < width - MIN_DIMENSION_TO_RECUR { - self.do_decode_multiple(&image.crop(max_x as i32, 0, width - max_x as i32, height), &hints, &results, x_offset + max_x as i32, y_offset, current_depth + 1); - } - // Decode below barcode - if max_y < height - MIN_DIMENSION_TO_RECUR { - self.do_decode_multiple(&image.crop(0, max_y as i32, width, height - max_y as i32), &hints, &results, x_offset, y_offset + max_y as i32, current_depth + 1); - } - } - - fn translate_result_points( result: &Result, x_offset: i32, y_offset: i32) -> Result { - let old_result_points: Vec = result.get_result_points(); - if old_result_points == null { - return result; - } - let new_result_points: [Option; old_result_points.len()] = [None; old_result_points.len()]; - { - let mut i: i32 = 0; - while i < old_result_points.len() { - { - let old_point: ResultPoint = old_result_points[i]; - if old_point != null { - new_result_points[i] = ResultPoint::new(old_point.get_x() + x_offset, old_point.get_y() + y_offset); - } - } - i += 1; - } - } - - let new_result: Result = Result::new(&result.get_text(), &result.get_raw_bytes(), &result.get_num_bits(), new_result_points, &result.get_barcode_format(), &result.get_timestamp()); - new_result.put_all_metadata(&result.get_result_metadata()); - return new_result; - } -} diff --git a/src/multi/qrcode.rs b/src/multi/qrcode.rs deleted file mode 100644 index 922c385..0000000 --- a/src/multi/qrcode.rs +++ /dev/null @@ -1,129 +0,0 @@ -use crate::{BarcodeFormat,BinaryBitmap,DecodeHintType,NotFoundException,ReaderException,RXingResult,ResultMetadataType,ResultPoint}; -use crate::common::{DecoderResult,DetectorResult}; -use crate::multi::{MultipleBarcodeReader}; -use crate::multi::qrcode::detector::MultiDetector; -use create::qrcode::{QRCodeReader}; -use crate::multi::qrcode::decoder::QRCodeDecoderMetaData; - - -// QRCodeMultiReader.java -/** - * This implementation can detect and decode multiple QR Codes in an image. - * - * @author Sean Owen - * @author Hannes Erven - */ - -const EMPTY_RESULT_ARRAY: [Option; 0] = [None; 0]; - -const NO_POINTS: [Option; 0] = [None; 0]; -pub struct QRCodeMultiReader { - super: QRCodeReader; -} - -impl MultipleBarcodeReader for QRCodeMultiReader { - pub fn decode_multiple(&self, image: &BinaryBitmap) -> /* throws NotFoundException */Result, Rc> { - return Ok(self.decode_multiple(image, null)); - } - - pub fn decode_multiple(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException */Result, Rc> { - let mut results: List = ArrayList<>::new(); - let detector_results: Vec = MultiDetector::new(&image.get_black_matrix()).detect_multi(&hints); - for let detector_result: DetectorResult in detector_results { - let tryResult1 = 0; - 'try1: loop { - { - let decoder_result: DecoderResult = get_decoder().decode(&detector_result.get_bits(), &hints); - let points: Vec = detector_result.get_points(); - // If the code was mirrored: swap the bottom-left and the top-right points. - if decoder_result.get_other() instanceof QRCodeDecoderMetaData { - (decoder_result.get_other() as QRCodeDecoderMetaData).apply_mirrored_correction(points); - } - let result: Result = Result::new(&decoder_result.get_text(), &decoder_result.get_raw_bytes(), points, BarcodeFormat::QR_CODE); - let byte_segments: List> = decoder_result.get_byte_segments(); - if byte_segments != null { - result.put_metadata(ResultMetadataType::BYTE_SEGMENTS, &byte_segments); - } - let ec_level: String = decoder_result.get_e_c_level(); - if ec_level != null { - result.put_metadata(ResultMetadataType::ERROR_CORRECTION_LEVEL, &ec_level); - } - if decoder_result.has_structured_append() { - result.put_metadata(ResultMetadataType::STRUCTURED_APPEND_SEQUENCE, &decoder_result.get_structured_append_sequence_number()); - result.put_metadata(ResultMetadataType::STRUCTURED_APPEND_PARITY, &decoder_result.get_structured_append_parity()); - } - results.add(result); - } - break 'try1 - } - match tryResult1 { - catch ( re: &ReaderException) { - } 0 => break - } - - } - if results.is_empty() { - return Ok(EMPTY_RESULT_ARRAY); - } else { - results = ::process_structured_append(&results); - return Ok(results.to_array(EMPTY_RESULT_ARRAY)); - } - } -} - -impl QRCodeMultiReader { - - - - fn process_structured_append( results: &List) -> List { - let new_results: List = ArrayList<>::new(); - let sa_results: List = ArrayList<>::new(); - for let result: Result in results { - if result.get_result_metadata().contains_key(ResultMetadataType::STRUCTURED_APPEND_SEQUENCE) { - sa_results.add(result); - } else { - new_results.add(result); - } - } - if sa_results.is_empty() { - return results; - } - // sort and concatenate the SA list items - Collections::sort(&sa_results, SAComparator::new()); - let new_text: StringBuilder = StringBuilder::new(); - let new_raw_bytes: ByteArrayOutputStream = ByteArrayOutputStream::new(); - let new_byte_segment: ByteArrayOutputStream = ByteArrayOutputStream::new(); - for let sa_result: Result in sa_results { - new_text.append(&sa_result.get_text()); - let sa_bytes: Vec = sa_result.get_raw_bytes(); - new_raw_bytes.write(&sa_bytes, 0, sa_bytes.len()); - let byte_segments: Iterable> = sa_result.get_result_metadata().get(ResultMetadataType::BYTE_SEGMENTS) as Iterable>; - if byte_segments != null { - for let segment: Vec in byte_segments { - new_byte_segment.write(&segment, 0, segment.len()); - } - } - } - let new_result: Result = Result::new(&new_text.to_string(), &new_raw_bytes.to_byte_array(), NO_POINTS, BarcodeFormat::QR_CODE); - if new_byte_segment.size() > 0 { - new_result.put_metadata(ResultMetadataType::BYTE_SEGMENTS, &Collections::singleton_list(&new_byte_segment.to_byte_array())); - } - new_results.add(new_result); - return new_results; - } - - #[derive(Comparator, Serializable)] - struct SAComparator { - } - - impl SAComparator { - - pub fn compare(&self, a: &Result, b: &Result) -> i32 { - let a_number: i32 = a.get_result_metadata().get(ResultMetadataType::STRUCTURED_APPEND_SEQUENCE) as i32; - let b_number: i32 = b.get_result_metadata().get(ResultMetadataType::STRUCTURED_APPEND_SEQUENCE) as i32; - return Integer::compare(a_number, b_number); - } - } - -} - diff --git a/src/multi/qrcode/detector.rs b/src/multi/qrcode/detector.rs deleted file mode 100644 index 46cd848..0000000 --- a/src/multi/qrcode/detector.rs +++ /dev/null @@ -1,344 +0,0 @@ -use crate::{DecodeHintType,NotFoundException,ReaderException,ResultPointCallback}; -use crate::common::{BitMatrix,DetectorResult}; -use crate::qrcode::detector::{Detector,FinderPatternInfo,FinderPattern,FinderPatternFinder}; - -// MultiDetector.java -/** - *

Encapsulates logic that can detect one or more QR Codes in an image, even if the QR Code - * is rotated or skewed, or partially obscured.

- * - * @author Sean Owen - * @author Hannes Erven - */ - -const EMPTY_DETECTOR_RESULTS: [Option; 0] = [None; 0]; -pub struct MultiDetector { - super: Detector; -} - -impl Detector for MultiDetector{} - -impl MultiDetector { - - pub fn new( image: &BitMatrix) -> MultiDetector { - super(image); - } - - pub fn detect_multi(&self, hints: &Map) -> /* throws NotFoundException */Result, Rc> { - let image: BitMatrix = get_image(); - let result_point_callback: ResultPointCallback = if hints == null { null } else { hints.get(DecodeHintType::NEED_RESULT_POINT_CALLBACK) as ResultPointCallback }; - let finder: MultiFinderPatternFinder = MultiFinderPatternFinder::new(image, result_point_callback); - let infos: Vec = finder.find_multi(&hints); - if infos.len() == 0 { - throw NotFoundException::get_not_found_instance(); - } - let result: List = ArrayList<>::new(); - for let info: FinderPatternInfo in infos { - let tryResult1 = 0; - 'try1: loop { - { - result.add(&process_finder_pattern_info(info)); - } - break 'try1 - } - match tryResult1 { - catch ( e: &ReaderException) { - } 0 => break - } - - } - if result.is_empty() { - return Ok(EMPTY_DETECTOR_RESULTS); - } else { - return Ok(result.to_array(EMPTY_DETECTOR_RESULTS)); - } - } -} - -// MultiFinderPatternFinder.java -/** - *

This class attempts to find finder patterns in a QR Code. Finder patterns are the square - * markers at three corners of a QR Code.

- * - *

This class is thread-safe but not reentrant. Each thread must allocate its own object. - * - *

In contrast to {@link FinderPatternFinder}, this class will return an array of all possible - * QR code locations in the image.

- * - *

Use the TRY_HARDER hint to ask for a more thorough detection.

- * - * @author Sean Owen - * @author Hannes Erven - */ - -const EMPTY_RESULT_ARRAY: [Option; 0] = [None; 0]; - -const EMPTY_FP_ARRAY: [Option; 0] = [None; 0]; - -const EMPTY_FP_2D_ARRAY: [Option; 0] = [None; 0]; - -// TODO MIN_MODULE_COUNT and MAX_MODULE_COUNT would be great hints to ask the user for -// since it limits the number of regions to decode -// max. legal count of modules per QR code edge (177) -const MAX_MODULE_COUNT_PER_EDGE: f32 = 180; - -// min. legal count per modules per QR code edge (11) -const MIN_MODULE_COUNT_PER_EDGE: f32 = 9; - -/** - * More or less arbitrary cutoff point for determining if two finder patterns might belong - * to the same code if they differ less than DIFF_MODSIZE_CUTOFF_PERCENT percent in their - * estimated modules sizes. - */ -const DIFF_MODSIZE_CUTOFF_PERCENT: f32 = 0.05f; - -/** - * More or less arbitrary cutoff point for determining if two finder patterns might belong - * to the same code if they differ less than DIFF_MODSIZE_CUTOFF pixels/module in their - * estimated modules sizes. - */ -const DIFF_MODSIZE_CUTOFF: f32 = 0.5f; -pub struct MultiFinderPatternFinder { - super: FinderPatternFinder; -} - -impl FinderPatternFinder for MultiFinderPatternFinder {} - -impl MultiFinderPatternFinder { - - /** - * A comparator that orders FinderPatterns by their estimated module size. - */ - #[derive(Comparator, Serializable)] - struct ModuleSizeComparator { - } - - impl ModuleSizeComparator { - - pub fn compare(&self, center1: &FinderPattern, center2: &FinderPattern) -> i32 { - let value: f32 = center2.get_estimated_module_size() - center1.get_estimated_module_size(); - return if value < 0.0 { -1 } else { if value > 0.0 { 1 } else { 0 } }; - } - } - - - pub fn new( image: &BitMatrix, result_point_callback: &ResultPointCallback) -> MultiFinderPatternFinder { - super(image, result_point_callback); - } - - /** - * @return the 3 best {@link FinderPattern}s from our list of candidates. The "best" are - * those that have been detected at least 2 times, and whose module - * size differs from the average among those patterns the least - * @throws NotFoundException if 3 such finder patterns do not exist - */ - fn select_multiple_best_patterns(&self) -> /* throws NotFoundException */Result>, Rc> { - let possible_centers: List = ArrayList<>::new(); - for let fp: FinderPattern in get_possible_centers() { - if fp.get_count() >= 2 { - possible_centers.add(fp); - } - } - let size: i32 = possible_centers.size(); - if size < 3 { - // Couldn't find enough finder patterns - throw NotFoundException::get_not_found_instance(); - } - /* - * Begin HE modifications to safely detect multiple codes of equal size - */ - if size == 3 { - return Ok( : vec![FinderPattern; 1] = vec![possible_centers.to_array(EMPTY_FP_ARRAY), ] - ); - } - // Sort by estimated module size to speed up the upcoming checks - Collections::sort(&possible_centers, ModuleSizeComparator::new()); - /* - * Now lets start: build a list of tuples of three finder locations that - * - feature similar module sizes - * - are placed in a distance so the estimated module count is within the QR specification - * - have similar distance between upper left/right and left top/bottom finder patterns - * - form a triangle with 90° angle (checked by comparing top right/bottom left distance - * with pythagoras) - * - * Note: we allow each point to be used for more than one code region: this might seem - * counterintuitive at first, but the performance penalty is not that big. At this point, - * we cannot make a good quality decision whether the three finders actually represent - * a QR code, or are just by chance laid out so it looks like there might be a QR code there. - * So, if the layout seems right, lets have the decoder try to decode. - */ - // holder for the results - let results: List> = ArrayList<>::new(); - { - let mut i1: i32 = 0; - while i1 < (size - 2) { - { - let p1: FinderPattern = possible_centers.get(i1); - if p1 == null { - continue; - } - { - let mut i2: i32 = i1 + 1; - while i2 < (size - 1) { - { - let p2: FinderPattern = possible_centers.get(i2); - if p2 == null { - continue; - } - // Compare the expected module sizes; if they are really off, skip - let v_mod_size12: f32 = (p1.get_estimated_module_size() - p2.get_estimated_module_size()) / Math::min(&p1.get_estimated_module_size(), &p2.get_estimated_module_size()); - let v_mod_size12_a: f32 = Math::abs(p1.get_estimated_module_size() - p2.get_estimated_module_size()); - if v_mod_size12_a > DIFF_MODSIZE_CUTOFF && v_mod_size12 >= DIFF_MODSIZE_CUTOFF_PERCENT { - // any more interesting elements for the given p1. - break; - } - { - let mut i3: i32 = i2 + 1; - while i3 < size { - { - let p3: FinderPattern = possible_centers.get(i3); - if p3 == null { - continue; - } - // Compare the expected module sizes; if they are really off, skip - let v_mod_size23: f32 = (p2.get_estimated_module_size() - p3.get_estimated_module_size()) / Math::min(&p2.get_estimated_module_size(), &p3.get_estimated_module_size()); - let v_mod_size23_a: f32 = Math::abs(p2.get_estimated_module_size() - p3.get_estimated_module_size()); - if v_mod_size23_a > DIFF_MODSIZE_CUTOFF && v_mod_size23 >= DIFF_MODSIZE_CUTOFF_PERCENT { - // any more interesting elements for the given p1. - break; - } - let test: vec![Vec; 3] = vec![p1, p2, p3, ] - ; - ResultPoint::order_best_patterns(test); - // Calculate the distances: a = topleft-bottomleft, b=topleft-topright, c = diagonal - let info: FinderPatternInfo = FinderPatternInfo::new(test); - let d_a: f32 = ResultPoint::distance(&info.get_top_left(), &info.get_bottom_left()); - let d_c: f32 = ResultPoint::distance(&info.get_top_right(), &info.get_bottom_left()); - let d_b: f32 = ResultPoint::distance(&info.get_top_left(), &info.get_top_right()); - // Check the sizes - let estimated_module_count: f32 = (d_a + d_b) / (p1.get_estimated_module_size() * 2.0f); - if estimated_module_count > MAX_MODULE_COUNT_PER_EDGE || estimated_module_count < MIN_MODULE_COUNT_PER_EDGE { - continue; - } - // Calculate the difference of the edge lengths in percent - let v_a_b_b_c: f32 = Math::abs((d_a - d_b) / Math::min(d_a, d_b)); - if v_a_b_b_c >= 0.1f { - continue; - } - // Calculate the diagonal length by assuming a 90° angle at topleft - let d_cpy: f32 = Math::sqrt(d_a as f64 * d_a + d_b as f64 * d_b) as f32; - // Compare to the real distance in % - let v_py_c: f32 = Math::abs((d_c - d_cpy) / Math::min(d_c, d_cpy)); - if v_py_c >= 0.1f { - continue; - } - // All tests passed! - results.add(test); - } - i3 += 1; - } - } - - } - i2 += 1; - } - } - - } - i1 += 1; - } - } - - if !results.is_empty() { - return Ok(results.to_array(EMPTY_FP_2D_ARRAY)); - } - // Nothing found! - throw NotFoundException::get_not_found_instance(); - } - - pub fn find_multi(&self, hints: &Map) -> /* throws NotFoundException */Result, Rc> { - let try_harder: bool = hints != null && hints.contains_key(DecodeHintType::TRY_HARDER); - let image: BitMatrix = get_image(); - let max_i: i32 = image.get_height(); - let max_j: i32 = image.get_width(); - // We are looking for black/white/black/white/black modules in - // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far - // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the - // image, and then account for the center being 3 modules in size. This gives the smallest - // number of pixels the center could be, so skip this often. When trying harder, look for all - // QR versions regardless of how dense they are. - let i_skip: i32 = (3 * max_i) / (4 * MAX_MODULES); - if i_skip < MIN_SKIP || try_harder { - i_skip = MIN_SKIP; - } - let state_count: [i32; 5] = [0; 5]; - { - let mut i: i32 = i_skip - 1; - while i < max_i { - { - // Get a row of black/white values - do_clear_counts(&state_count); - let current_state: i32 = 0; - { - let mut j: i32 = 0; - while j < max_j { - { - if image.get(j, i) { - // Black pixel - if (current_state & 1) == 1 { - // Counting white pixels - current_state += 1; - } - state_count[current_state] += 1; - } else { - // White pixel - if (current_state & 1) == 0 { - // Counting black pixels - if current_state == 4 { - // A winner? - if found_pattern_cross(&state_count) && handle_possible_center(&state_count, i, j) { - // Yes - // Clear state to start looking again - current_state = 0; - do_clear_counts(&state_count); - } else { - // No, shift counts back by two - do_shift_counts2(&state_count); - current_state = 3; - } - } else { - state_count[current_state += 1] += 1; - } - } else { - // Counting white pixels - state_count[current_state] += 1; - } - } - } - j += 1; - } - } - - if found_pattern_cross(&state_count) { - handle_possible_center(&state_count, i, max_j); - } - } - i += i_skip; - } - } - - // for i=iSkip-1 ... - let pattern_info: Vec> = self.select_multiple_best_patterns(); - let result: List = ArrayList<>::new(); - for let pattern: Vec in pattern_info { - ResultPoint::order_best_patterns(pattern); - result.add(FinderPatternInfo::new(pattern)); - } - if result.is_empty() { - return Ok(EMPTY_RESULT_ARRAY); - } else { - return Ok(result.to_array(EMPTY_RESULT_ARRAY)); - } - } -} - diff --git a/src/oned.rs b/src/oned.rs deleted file mode 100644 index b344df0..0000000 --- a/src/oned.rs +++ /dev/null @@ -1,6246 +0,0 @@ -use crate::{BarcodeFormat,DecodeHintType,NotFoundException,XRingResult,ResultMetadataType,ResultPoint,ChecksumException,FormatException,Reader,ReaderException,EncodeHintType,Writer,BinaryBitmap,ResultPointCallback}; -use crate::common::{BitArray,BitMatrix}; -use crate::oned::rss::{RSS14Reader}; -use crate::oned::rss::expanded::{RSSExpandedReader}; - -// NEW FILE: coda_bar_reader.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

Decodes Codabar barcodes.

- * - * @author Bas Vijfwinkel - * @author David Walker - */ - -// These values are critical for determining how permissive the decoding -// will be. All stripe sizes must be within the window these define, as -// compared to the average stripe size. - const MAX_ACCEPTABLE: f32 = 2.0f; - - const PADDING: f32 = 1.5f; - - const ALPHABET_STRING: &'static str = "0123456789-$:/.+ABCD"; - - const ALPHABET: Vec = ALPHABET_STRING::to_char_array(); - -/** - * These represent the encodings of characters, as patterns of wide and narrow bars. The 7 least-significant bits of - * each int correspond to the pattern of wide and narrow, with 1s representing "wide" and 0s representing narrow. - */ - const CHARACTER_ENCODINGS: vec![Vec; 20] = vec![// 0-9 -0x003, // 0-9 -0x006, // 0-9 -0x009, // 0-9 -0x060, // 0-9 -0x012, // 0-9 -0x042, // 0-9 -0x021, // 0-9 -0x024, // 0-9 -0x030, // 0-9 -0x048, // -$:/.+ABCD -0x00c, // -$:/.+ABCD -0x018, // -$:/.+ABCD -0x045, // -$:/.+ABCD -0x051, // -$:/.+ABCD -0x054, // -$:/.+ABCD -0x015, // -$:/.+ABCD -0x01A, // -$:/.+ABCD -0x029, // -$:/.+ABCD -0x00B, // -$:/.+ABCD -0x00E, ] -; - -// minimal number of characters that should be present (including start and stop characters) -// under normal circumstances this should be set to 3, but can be set higher -// as a last-ditch attempt to reduce false positives. - const MIN_CHARACTER_LENGTH: i32 = 3; - -// official start and end patterns - const STARTEND_ENCODING: vec![Vec; 4] = vec!['A', 'B', 'C', 'D', ] -; -pub struct CodaBarReader { - super: OneDReader; - - // some Codabar generator allow the Codabar string to be closed by every - // character. This will cause lots of false positives! - // some industries use a checksum standard but this is not part of the original Codabar standard - // for more information see : http://www.mecsw.com/specs/codabar.html - // Keep some instance variables to avoid reallocations - let decode_row_result: StringBuilder; - - let mut counters: Vec; - - let counter_length: i32; -} - -impl CodaBarReader { - - pub fn new() -> CodaBarReader { - decode_row_result = StringBuilder::new(20); - counters = : [i32; 80] = [0; 80]; - counter_length = 0; - } - - pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException */Result> { - Arrays::fill(&self.counters, 0); - self.set_counters(row); - let start_offset: i32 = self.find_start_pattern(); - let next_start: i32 = start_offset; - self.decode_row_result.set_length(0); - loop { { - let char_offset: i32 = self.to_narrow_wide_pattern(next_start); - if char_offset == -1 { - throw NotFoundException::get_not_found_instance(); - } - // Hack: We store the position in the alphabet table into a - // StringBuilder, so that we can access the decoded patterns in - // validatePattern. We'll translate to the actual characters later. - self.decode_row_result.append(char_offset as char); - next_start += 8; - // Stop as soon as we see the end character. - if self.decode_row_result.length() > 1 && ::array_contains(&STARTEND_ENCODING, ALPHABET[char_offset]) { - break; - } - }if !(// no fixed end pattern so keep on reading while data is available - next_start < self.counter_length) break;} - // Look for whitespace after pattern: - let trailing_whitespace: i32 = self.counters[next_start - 1]; - let last_pattern_size: i32 = 0; - { - let mut i: i32 = -8; - while i < -1 { - { - last_pattern_size += self.counters[next_start + i]; - } - i += 1; - } - } - - // at the end of the row. (I.e. the barcode barely fits.) - if next_start < self.counter_length && trailing_whitespace < last_pattern_size / 2 { - throw NotFoundException::get_not_found_instance(); - } - self.validate_pattern(start_offset); - // Translate character table offsets to actual characters. - { - let mut i: i32 = 0; - while i < self.decode_row_result.length() { - { - self.decode_row_result.set_char_at(i, ALPHABET[self.decode_row_result.char_at(i)]); - } - i += 1; - } - } - - // Ensure a valid start and end character - let startchar: char = self.decode_row_result.char_at(0); - if !::array_contains(&STARTEND_ENCODING, startchar) { - throw NotFoundException::get_not_found_instance(); - } - let endchar: char = self.decode_row_result.char_at(self.decode_row_result.length() - 1); - if !::array_contains(&STARTEND_ENCODING, endchar) { - throw NotFoundException::get_not_found_instance(); - } - // remove stop/start characters character and check if a long enough string is contained - if self.decode_row_result.length() <= MIN_CHARACTER_LENGTH { - // Almost surely a false positive ( start + stop + at least 1 character) - throw NotFoundException::get_not_found_instance(); - } - if hints == null || !hints.contains_key(DecodeHintType::RETURN_CODABAR_START_END) { - self.decode_row_result.delete_char_at(self.decode_row_result.length() - 1); - self.decode_row_result.delete_char_at(0); - } - let running_count: i32 = 0; - { - let mut i: i32 = 0; - while i < start_offset { - { - running_count += self.counters[i]; - } - i += 1; - } - } - - let left: f32 = running_count; - { - let mut i: i32 = start_offset; - while i < next_start - 1 { - { - running_count += self.counters[i]; - } - i += 1; - } - } - - let right: f32 = running_count; - let result: Result = Result::new(&self.decode_row_result.to_string(), null, : vec![ResultPoint; 2] = vec![ResultPoint::new(left, row_number), ResultPoint::new(right, row_number), ] - , BarcodeFormat::CODABAR); - result.put_metadata(ResultMetadataType::SYMBOLOGY_IDENTIFIER, "]F0"); - return Ok(result); - } - - fn validate_pattern(&self, start: i32) -> /* throws NotFoundException */Result> { - // First, sum up the total size of our four categories of stripe sizes; - let mut sizes: vec![Vec; 4] = vec![0, 0, 0, 0, ] - ; - let mut counts: vec![Vec; 4] = vec![0, 0, 0, 0, ] - ; - let end: i32 = self.decode_row_result.length() - 1; - // We break out of this loop in the middle, in order to handle - // inter-character spaces properly. - let mut pos: i32 = start; - { - let mut i: i32 = 0; - while i <= end { - { - let mut pattern: i32 = CHARACTER_ENCODINGS[self.decode_row_result.char_at(i)]; - { - let mut j: i32 = 6; - while j >= 0 { - { - // Even j = bars, while odd j = spaces. Categories 2 and 3 are for - // long stripes, while 0 and 1 are for short stripes. - let mut category: i32 = (j & 1) + (pattern & 1) * 2; - sizes[category] += self.counters[pos + j]; - counts[category] += 1; - pattern >>= 1; - } - j -= 1; - } - } - - // We ignore the inter-character space - it could be of any size. - pos += 8; - } - i += 1; - } - } - - // Calculate our allowable size thresholds using fixed-point math. - let mut maxes: [f32; 4.0] = [0.0; 4.0]; - let mut mins: [f32; 4.0] = [0.0; 4.0]; - // should be on the "wrong" side of that line. - { - let mut i: i32 = 0; - while i < 2 { - { - // Accept arbitrarily small "short" stripes. - mins[i] = 0.0f; - mins[i + 2] = (sizes[i] as f32 / counts[i] + sizes[i + 2] as f32 / counts[i + 2]) / 2.0f; - maxes[i] = mins[i + 2]; - maxes[i + 2] = (sizes[i + 2] * MAX_ACCEPTABLE + PADDING) / counts[i + 2]; - } - i += 1; - } - } - - // Now verify that all of the stripes are within the thresholds. - pos = start; - { - let mut i: i32 = 0; - while i <= end { - { - let mut pattern: i32 = CHARACTER_ENCODINGS[self.decode_row_result.char_at(i)]; - { - let mut j: i32 = 6; - while j >= 0 { - { - // Even j = bars, while odd j = spaces. Categories 2 and 3 are for - // long stripes, while 0 and 1 are for short stripes. - let category: i32 = (j & 1) + (pattern & 1) * 2; - let size: i32 = self.counters[pos + j]; - if size < mins[category] || size > maxes[category] { - throw NotFoundException::get_not_found_instance(); - } - pattern >>= 1; - } - j -= 1; - } - } - - pos += 8; - } - i += 1; - } - } - - } - - /** - * Records the size of all runs of white and black pixels, starting with white. - * This is just like recordPattern, except it records all the counters, and - * uses our builtin "counters" member for storage. - * @param row row to count from - */ - fn set_counters(&self, row: &BitArray) -> /* throws NotFoundException */Result> { - self.counter_length = 0; - // Start from the first white bit. - let mut i: i32 = row.get_next_unset(0); - let end: i32 = row.get_size(); - if i >= end { - throw NotFoundException::get_not_found_instance(); - } - let is_white: bool = true; - let mut count: i32 = 0; - while i < end { - if row.get(i) != is_white { - count += 1; - } else { - self.counter_append(count); - count = 1; - is_white = !is_white; - } - i += 1; - } - self.counter_append(count); - } - - fn counter_append(&self, e: i32) { - self.counters[self.counter_length] = e; - self.counter_length += 1; - if self.counter_length >= self.counters.len() { - let temp: [i32; self.counter_length * 2] = [0; self.counter_length * 2]; - System::arraycopy(&self.counters, 0, &temp, 0, self.counter_length); - self.counters = temp; - } - } - - fn find_start_pattern(&self) -> /* throws NotFoundException */Result> { - { - let mut i: i32 = 1; - while i < self.counter_length { - { - let char_offset: i32 = self.to_narrow_wide_pattern(i); - if char_offset != -1 && ::array_contains(&STARTEND_ENCODING, ALPHABET[char_offset]) { - // Look for whitespace before start pattern, >= 50% of width of start pattern - // We make an exception if the whitespace is the first element. - let pattern_size: i32 = 0; - { - let mut j: i32 = i; - while j < i + 7 { - { - pattern_size += self.counters[j]; - } - j += 1; - } - } - - if i == 1 || self.counters[i - 1] >= pattern_size / 2 { - return Ok(i); - } - } - } - i += 2; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - fn array_contains( array: &Vec, key: char) -> bool { - if array != null { - for let c: char in array { - if c == key { - return true; - } - } - } - return false; - } - - // Assumes that counters[position] is a bar. - fn to_narrow_wide_pattern(&self, position: i32) -> i32 { - let end: i32 = position + 7; - if end >= self.counter_length { - return -1; - } - let the_counters: Vec = self.counters; - let max_bar: i32 = 0; - let min_bar: i32 = Integer::MAX_VALUE; - { - let mut j: i32 = position; - while j < end { - { - let current_counter: i32 = the_counters[j]; - if current_counter < min_bar { - min_bar = current_counter; - } - if current_counter > max_bar { - max_bar = current_counter; - } - } - j += 2; - } - } - - let threshold_bar: i32 = (min_bar + max_bar) / 2; - let max_space: i32 = 0; - let min_space: i32 = Integer::MAX_VALUE; - { - let mut j: i32 = position + 1; - while j < end { - { - let current_counter: i32 = the_counters[j]; - if current_counter < min_space { - min_space = current_counter; - } - if current_counter > max_space { - max_space = current_counter; - } - } - j += 2; - } - } - - let threshold_space: i32 = (min_space + max_space) / 2; - let mut bitmask: i32 = 1 << 7; - let mut pattern: i32 = 0; - { - let mut i: i32 = 0; - while i < 7 { - { - let threshold: i32 = if (i & 1) == 0 { threshold_bar } else { threshold_space }; - bitmask >>= 1; - if the_counters[position + i] > threshold { - pattern |= bitmask; - } - } - i += 1; - } - } - - { - let mut i: i32 = 0; - while i < CHARACTER_ENCODINGS.len() { - { - if CHARACTER_ENCODINGS[i] == pattern { - return i; - } - } - i += 1; - } - } - - return -1; - } -} - -// NEW FILE: coda_bar_writer.rs -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * This class renders CodaBar as {@code boolean[]}. - * - * @author dsbnatut@gmail.com (Kazuki Nishiura) - */ - - const START_END_CHARS: vec![Vec; 4] = vec!['A', 'B', 'C', 'D', ] -; - - const ALT_START_END_CHARS: vec![Vec; 4] = vec!['T', 'N', '*', 'E', ] -; - - const CHARS_WHICH_ARE_TEN_LENGTH_EACH_AFTER_DECODED: vec![Vec; 4] = vec!['/', ':', '+', '.', ] -; - - const DEFAULT_GUARD: char = START_END_CHARS[0]; -pub struct CodaBarWriter { - super: OneDimensionalCodeWriter; -} - -impl CodaBarWriter { - - pub fn get_supported_write_formats(&self) -> Collection { - return Collections::singleton(BarcodeFormat::CODABAR); - } - - pub fn encode(&self, contents: &String) -> Vec { - if contents.length() < 2 { - // Can't have a start/end guard, so tentatively add default guards - contents = format!("{}{}{}", DEFAULT_GUARD, contents, DEFAULT_GUARD); - } else { - // Verify input and calculate decoded length. - let first_char: char = Character::to_upper_case(&contents.char_at(0)); - let last_char: char = Character::to_upper_case(&contents.char_at(contents.length() - 1)); - let starts_normal: bool = CodaBarReader::array_contains(&START_END_CHARS, first_char); - let ends_normal: bool = CodaBarReader::array_contains(&START_END_CHARS, last_char); - let starts_alt: bool = CodaBarReader::array_contains(&ALT_START_END_CHARS, first_char); - let ends_alt: bool = CodaBarReader::array_contains(&ALT_START_END_CHARS, last_char); - if starts_normal { - if !ends_normal { - throw IllegalArgumentException::new(format!("Invalid start/end guards: {}", contents)); - } - // else already has valid start/end - } else if starts_alt { - if !ends_alt { - throw IllegalArgumentException::new(format!("Invalid start/end guards: {}", contents)); - } - // else already has valid start/end - } else { - // Doesn't start with a guard - if ends_normal || ends_alt { - throw IllegalArgumentException::new(format!("Invalid start/end guards: {}", contents)); - } - // else doesn't end with guard either, so add a default - contents = format!("{}{}{}", DEFAULT_GUARD, contents, DEFAULT_GUARD); - } - } - // The start character and the end character are decoded to 10 length each. - let result_length: i32 = 20; - { - let mut i: i32 = 1; - while i < contents.length() - 1 { - { - if Character::is_digit(&contents.char_at(i)) || contents.char_at(i) == '-' || contents.char_at(i) == '$' { - result_length += 9; - } else if CodaBarReader::array_contains(&CHARS_WHICH_ARE_TEN_LENGTH_EACH_AFTER_DECODED, &contents.char_at(i)) { - result_length += 10; - } else { - throw IllegalArgumentException::new(format!("Cannot encode : '{}\'", contents.char_at(i))); - } - } - i += 1; - } - } - - // A blank is placed between each character. - result_length += contents.length() - 1; - let mut result: [bool; result_length] = [false; result_length]; - let mut position: i32 = 0; - { - let mut index: i32 = 0; - while index < contents.length() { - { - let mut c: char = Character::to_upper_case(&contents.char_at(index)); - if index == 0 || index == contents.length() - 1 { - // The start/end chars are not in the CodaBarReader.ALPHABET. - match c { - 'T' => - { - c = 'A'; - break; - } - 'N' => - { - c = 'B'; - break; - } - '*' => - { - c = 'C'; - break; - } - 'E' => - { - c = 'D'; - break; - } - } - } - let mut code: i32 = 0; - { - let mut i: i32 = 0; - while i < CodaBarReader::ALPHABET::len() { - { - // Found any, because I checked above. - if c == CodaBarReader::ALPHABET[i] { - code = CodaBarReader::CHARACTER_ENCODINGS[i]; - break; - } - } - i += 1; - } - } - - let mut color: bool = true; - let mut counter: i32 = 0; - let mut bit: i32 = 0; - while bit < 7 { - // A character consists of 7 digit. - result[position] = color; - position += 1; - if ((code >> (6 - bit)) & 1) == 0 || counter == 1 { - // Flip the color. - color = !color; - bit += 1; - counter = 0; - } else { - counter += 1; - } - } - if index < contents.length() - 1 { - result[position] = false; - position += 1; - } - } - index += 1; - } - } - - return result; - } -} - -// NEW FILE: code128_reader.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

Decodes Code 128 barcodes.

- * - * @author Sean Owen - */ - - const CODE_PATTERNS: vec![vec![Vec>; 7]; 107] = vec![// 0 -vec![2, 1, 2, 2, 2, 2, ] -, vec![2, 2, 2, 1, 2, 2, ] -, vec![2, 2, 2, 2, 2, 1, ] -, vec![1, 2, 1, 2, 2, 3, ] -, vec![1, 2, 1, 3, 2, 2, ] -, // 5 -vec![1, 3, 1, 2, 2, 2, ] -, vec![1, 2, 2, 2, 1, 3, ] -, vec![1, 2, 2, 3, 1, 2, ] -, vec![1, 3, 2, 2, 1, 2, ] -, vec![2, 2, 1, 2, 1, 3, ] -, // 10 -vec![2, 2, 1, 3, 1, 2, ] -, vec![2, 3, 1, 2, 1, 2, ] -, vec![1, 1, 2, 2, 3, 2, ] -, vec![1, 2, 2, 1, 3, 2, ] -, vec![1, 2, 2, 2, 3, 1, ] -, // 15 -vec![1, 1, 3, 2, 2, 2, ] -, vec![1, 2, 3, 1, 2, 2, ] -, vec![1, 2, 3, 2, 2, 1, ] -, vec![2, 2, 3, 2, 1, 1, ] -, vec![2, 2, 1, 1, 3, 2, ] -, // 20 -vec![2, 2, 1, 2, 3, 1, ] -, vec![2, 1, 3, 2, 1, 2, ] -, vec![2, 2, 3, 1, 1, 2, ] -, vec![3, 1, 2, 1, 3, 1, ] -, vec![3, 1, 1, 2, 2, 2, ] -, // 25 -vec![3, 2, 1, 1, 2, 2, ] -, vec![3, 2, 1, 2, 2, 1, ] -, vec![3, 1, 2, 2, 1, 2, ] -, vec![3, 2, 2, 1, 1, 2, ] -, vec![3, 2, 2, 2, 1, 1, ] -, // 30 -vec![2, 1, 2, 1, 2, 3, ] -, vec![2, 1, 2, 3, 2, 1, ] -, vec![2, 3, 2, 1, 2, 1, ] -, vec![1, 1, 1, 3, 2, 3, ] -, vec![1, 3, 1, 1, 2, 3, ] -, // 35 -vec![1, 3, 1, 3, 2, 1, ] -, vec![1, 1, 2, 3, 1, 3, ] -, vec![1, 3, 2, 1, 1, 3, ] -, vec![1, 3, 2, 3, 1, 1, ] -, vec![2, 1, 1, 3, 1, 3, ] -, // 40 -vec![2, 3, 1, 1, 1, 3, ] -, vec![2, 3, 1, 3, 1, 1, ] -, vec![1, 1, 2, 1, 3, 3, ] -, vec![1, 1, 2, 3, 3, 1, ] -, vec![1, 3, 2, 1, 3, 1, ] -, // 45 -vec![1, 1, 3, 1, 2, 3, ] -, vec![1, 1, 3, 3, 2, 1, ] -, vec![1, 3, 3, 1, 2, 1, ] -, vec![3, 1, 3, 1, 2, 1, ] -, vec![2, 1, 1, 3, 3, 1, ] -, // 50 -vec![2, 3, 1, 1, 3, 1, ] -, vec![2, 1, 3, 1, 1, 3, ] -, vec![2, 1, 3, 3, 1, 1, ] -, vec![2, 1, 3, 1, 3, 1, ] -, vec![3, 1, 1, 1, 2, 3, ] -, // 55 -vec![3, 1, 1, 3, 2, 1, ] -, vec![3, 3, 1, 1, 2, 1, ] -, vec![3, 1, 2, 1, 1, 3, ] -, vec![3, 1, 2, 3, 1, 1, ] -, vec![3, 3, 2, 1, 1, 1, ] -, // 60 -vec![3, 1, 4, 1, 1, 1, ] -, vec![2, 2, 1, 4, 1, 1, ] -, vec![4, 3, 1, 1, 1, 1, ] -, vec![1, 1, 1, 2, 2, 4, ] -, vec![1, 1, 1, 4, 2, 2, ] -, // 65 -vec![1, 2, 1, 1, 2, 4, ] -, vec![1, 2, 1, 4, 2, 1, ] -, vec![1, 4, 1, 1, 2, 2, ] -, vec![1, 4, 1, 2, 2, 1, ] -, vec![1, 1, 2, 2, 1, 4, ] -, // 70 -vec![1, 1, 2, 4, 1, 2, ] -, vec![1, 2, 2, 1, 1, 4, ] -, vec![1, 2, 2, 4, 1, 1, ] -, vec![1, 4, 2, 1, 1, 2, ] -, vec![1, 4, 2, 2, 1, 1, ] -, // 75 -vec![2, 4, 1, 2, 1, 1, ] -, vec![2, 2, 1, 1, 1, 4, ] -, vec![4, 1, 3, 1, 1, 1, ] -, vec![2, 4, 1, 1, 1, 2, ] -, vec![1, 3, 4, 1, 1, 1, ] -, // 80 -vec![1, 1, 1, 2, 4, 2, ] -, vec![1, 2, 1, 1, 4, 2, ] -, vec![1, 2, 1, 2, 4, 1, ] -, vec![1, 1, 4, 2, 1, 2, ] -, vec![1, 2, 4, 1, 1, 2, ] -, // 85 -vec![1, 2, 4, 2, 1, 1, ] -, vec![4, 1, 1, 2, 1, 2, ] -, vec![4, 2, 1, 1, 1, 2, ] -, vec![4, 2, 1, 2, 1, 1, ] -, vec![2, 1, 2, 1, 4, 1, ] -, // 90 -vec![2, 1, 4, 1, 2, 1, ] -, vec![4, 1, 2, 1, 2, 1, ] -, vec![1, 1, 1, 1, 4, 3, ] -, vec![1, 1, 1, 3, 4, 1, ] -, vec![1, 3, 1, 1, 4, 1, ] -, // 95 -vec![1, 1, 4, 1, 1, 3, ] -, vec![1, 1, 4, 3, 1, 1, ] -, vec![4, 1, 1, 1, 1, 3, ] -, vec![4, 1, 1, 3, 1, 1, ] -, vec![1, 1, 3, 1, 4, 1, ] -, // 100 -vec![1, 1, 4, 1, 3, 1, ] -, vec![3, 1, 1, 1, 4, 1, ] -, vec![4, 1, 1, 1, 3, 1, ] -, vec![2, 1, 1, 4, 1, 2, ] -, vec![2, 1, 1, 2, 1, 4, ] -, // 105 -vec![2, 1, 1, 2, 3, 2, ] -, vec![2, 3, 3, 1, 1, 1, 2, ] -, ] -; - - const MAX_AVG_VARIANCE: f32 = 0.25f; - - const MAX_INDIVIDUAL_VARIANCE: f32 = 0.7f; - - const CODE_SHIFT: i32 = 98; - - const CODE_CODE_C: i32 = 99; - - const CODE_CODE_B: i32 = 100; - - const CODE_CODE_A: i32 = 101; - - const CODE_FNC_1: i32 = 102; - - const CODE_FNC_2: i32 = 97; - - const CODE_FNC_3: i32 = 96; - - const CODE_FNC_4_A: i32 = 101; - - const CODE_FNC_4_B: i32 = 100; - - const CODE_START_A: i32 = 103; - - const CODE_START_B: i32 = 104; - - const CODE_START_C: i32 = 105; - - const CODE_STOP: i32 = 106; -pub struct Code128Reader { - super: OneDReader; -} - -impl Code128Reader { - - fn find_start_pattern( row: &BitArray) -> /* throws NotFoundException */Result, Rc> { - let width: i32 = row.get_size(); - let row_offset: i32 = row.get_next_set(0); - let counter_position: i32 = 0; - let mut counters: [i32; 6] = [0; 6]; - let pattern_start: i32 = row_offset; - let is_white: bool = false; - let pattern_length: i32 = counters.len(); - { - let mut i: i32 = row_offset; - while i < width { - { - if row.get(i) != is_white { - counters[counter_position] += 1; - } else { - if counter_position == pattern_length - 1 { - let best_variance: f32 = MAX_AVG_VARIANCE; - let best_match: i32 = -1; - { - let start_code: i32 = CODE_START_A; - while start_code <= CODE_START_C { - { - let variance: f32 = pattern_match_variance(&counters, CODE_PATTERNS[start_code], MAX_INDIVIDUAL_VARIANCE); - if variance < best_variance { - best_variance = variance; - best_match = start_code; - } - } - start_code += 1; - } - } - - // Look for whitespace before start pattern, >= 50% of width of start pattern - if best_match >= 0 && row.is_range(&Math::max(0, pattern_start - (i - pattern_start) / 2), pattern_start, false) { - return Ok( : vec![i32; 3] = vec![pattern_start, i, best_match, ] - ); - } - pattern_start += counters[0] + counters[1]; - System::arraycopy(&counters, 2, &counters, 0, counter_position - 1); - counters[counter_position - 1] = 0; - counters[counter_position] = 0; - counter_position -= 1; - } else { - counter_position += 1; - } - counters[counter_position] = 1; - is_white = !is_white; - } - } - i += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - fn decode_code( row: &BitArray, counters: &Vec, row_offset: i32) -> /* throws NotFoundException */Result> { - record_pattern(row, row_offset, &counters); - // worst variance we'll accept - let best_variance: f32 = MAX_AVG_VARIANCE; - let best_match: i32 = -1; - { - let mut d: i32 = 0; - while d < CODE_PATTERNS.len() { - { - let pattern: Vec = CODE_PATTERNS[d]; - let variance: f32 = pattern_match_variance(&counters, &pattern, MAX_INDIVIDUAL_VARIANCE); - if variance < best_variance { - best_variance = variance; - best_match = d; - } - } - d += 1; - } - } - - // TODO We're overlooking the fact that the STOP pattern has 7 values, not 6. - if best_match >= 0 { - return Ok(best_match); - } else { - throw NotFoundException::get_not_found_instance(); - } - } - - pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException, FormatException, ChecksumException */Result> { - let convert_f_n_c1: bool = hints != null && hints.contains_key(DecodeHintType::ASSUME_GS1); - let symbology_modifier: i32 = 0; - let start_pattern_info: Vec = ::find_start_pattern(row); - let start_code: i32 = start_pattern_info[2]; - let raw_codes: List = ArrayList<>::new(20); - raw_codes.add(start_code as i8); - let code_set: i32; - match start_code { - CODE_START_A => - { - code_set = CODE_CODE_A; - break; - } - CODE_START_B => - { - code_set = CODE_CODE_B; - break; - } - CODE_START_C => - { - code_set = CODE_CODE_C; - break; - } - _ => - { - throw FormatException::get_format_instance(); - } - } - let mut done: bool = false; - let is_next_shifted: bool = false; - let result: StringBuilder = StringBuilder::new(20); - let last_start: i32 = start_pattern_info[0]; - let next_start: i32 = start_pattern_info[1]; - let counters: [i32; 6] = [0; 6]; - let last_code: i32 = 0; - let mut code: i32 = 0; - let checksum_total: i32 = start_code; - let mut multiplier: i32 = 0; - let last_character_was_printable: bool = true; - let upper_mode: bool = false; - let shift_upper_mode: bool = false; - while !done { - let unshift: bool = is_next_shifted; - is_next_shifted = false; - // Save off last code - last_code = code; - // Decode another code from image - code = ::decode_code(row, &counters, next_start); - raw_codes.add(code as i8); - // Remember whether the last code was printable or not (excluding CODE_STOP) - if code != CODE_STOP { - last_character_was_printable = true; - } - // Add to checksum computation (if not CODE_STOP of course) - if code != CODE_STOP { - multiplier += 1; - checksum_total += multiplier * code; - } - // Advance to where the next code will to start - last_start = next_start; - for let counter: i32 in counters { - next_start += counter; - } - // Take care of illegal start codes - match code { - CODE_START_A => - { - } - CODE_START_B => - { - } - CODE_START_C => - { - throw FormatException::get_format_instance(); - } - } - match code_set { - CODE_CODE_A => - { - if code < 64 { - if shift_upper_mode == upper_mode { - result.append((' ' + code) as char); - } else { - result.append((' ' + code + 128) as char); - } - shift_upper_mode = false; - } else if code < 96 { - if shift_upper_mode == upper_mode { - result.append((code - 64) as char); - } else { - result.append((code + 64) as char); - } - shift_upper_mode = false; - } else { - // code was printable or not. - if code != CODE_STOP { - last_character_was_printable = false; - } - match code { - CODE_FNC_1 => - { - if result.length() == 0 { - // FNC1 at first or second character determines the symbology - symbology_modifier = 1; - } else if result.length() == 1 { - symbology_modifier = 2; - } - if convert_f_n_c1 { - if result.length() == 0 { - // GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code - // is FNC1 then this is GS1-128. We add the symbology identifier. - result.append("]C1"); - } else { - // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) - result.append(29 as char); - } - } - break; - } - CODE_FNC_2 => - { - symbology_modifier = 4; - break; - } - CODE_FNC_3 => - { - // do nothing? - break; - } - CODE_FNC_4_A => - { - if !upper_mode && shift_upper_mode { - upper_mode = true; - shift_upper_mode = false; - } else if upper_mode && shift_upper_mode { - upper_mode = false; - shift_upper_mode = false; - } else { - shift_upper_mode = true; - } - break; - } - CODE_SHIFT => - { - is_next_shifted = true; - code_set = CODE_CODE_B; - break; - } - CODE_CODE_B => - { - code_set = CODE_CODE_B; - break; - } - CODE_CODE_C => - { - code_set = CODE_CODE_C; - break; - } - CODE_STOP => - { - done = true; - break; - } - } - } - break; - } - CODE_CODE_B => - { - if code < 96 { - if shift_upper_mode == upper_mode { - result.append((' ' + code) as char); - } else { - result.append((' ' + code + 128) as char); - } - shift_upper_mode = false; - } else { - if code != CODE_STOP { - last_character_was_printable = false; - } - match code { - CODE_FNC_1 => - { - if result.length() == 0 { - // FNC1 at first or second character determines the symbology - symbology_modifier = 1; - } else if result.length() == 1 { - symbology_modifier = 2; - } - if convert_f_n_c1 { - if result.length() == 0 { - // GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code - // is FNC1 then this is GS1-128. We add the symbology identifier. - result.append("]C1"); - } else { - // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) - result.append(29 as char); - } - } - break; - } - CODE_FNC_2 => - { - symbology_modifier = 4; - break; - } - CODE_FNC_3 => - { - // do nothing? - break; - } - CODE_FNC_4_B => - { - if !upper_mode && shift_upper_mode { - upper_mode = true; - shift_upper_mode = false; - } else if upper_mode && shift_upper_mode { - upper_mode = false; - shift_upper_mode = false; - } else { - shift_upper_mode = true; - } - break; - } - CODE_SHIFT => - { - is_next_shifted = true; - code_set = CODE_CODE_A; - break; - } - CODE_CODE_A => - { - code_set = CODE_CODE_A; - break; - } - CODE_CODE_C => - { - code_set = CODE_CODE_C; - break; - } - CODE_STOP => - { - done = true; - break; - } - } - } - break; - } - CODE_CODE_C => - { - if code < 100 { - if code < 10 { - result.append('0'); - } - result.append(code); - } else { - if code != CODE_STOP { - last_character_was_printable = false; - } - match code { - CODE_FNC_1 => - { - if result.length() == 0 { - // FNC1 at first or second character determines the symbology - symbology_modifier = 1; - } else if result.length() == 1 { - symbology_modifier = 2; - } - if convert_f_n_c1 { - if result.length() == 0 { - // GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code - // is FNC1 then this is GS1-128. We add the symbology identifier. - result.append("]C1"); - } else { - // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) - result.append(29 as char); - } - } - break; - } - CODE_CODE_A => - { - code_set = CODE_CODE_A; - break; - } - CODE_CODE_B => - { - code_set = CODE_CODE_B; - break; - } - CODE_STOP => - { - done = true; - break; - } - } - } - break; - } - } - // Unshift back to another code set if we were shifted - if unshift { - code_set = if code_set == CODE_CODE_A { CODE_CODE_B } else { CODE_CODE_A }; - } - } - let last_pattern_size: i32 = next_start - last_start; - // Check for ample whitespace following pattern, but, to do this we first need to remember that - // we fudged decoding CODE_STOP since it actually has 7 bars, not 6. There is a black bar left - // to read off. Would be slightly better to properly read. Here we just skip it: - next_start = row.get_next_unset(next_start); - if !row.is_range(next_start, &Math::min(&row.get_size(), next_start + (next_start - last_start) / 2), false) { - throw NotFoundException::get_not_found_instance(); - } - // Pull out from sum the value of the penultimate check code - checksum_total -= multiplier * last_code; - // lastCode is the checksum then: - if checksum_total % 103 != last_code { - throw ChecksumException::get_checksum_instance(); - } - // Need to pull out the check digits from string - let result_length: i32 = result.length(); - if result_length == 0 { - // false positive - throw NotFoundException::get_not_found_instance(); - } - // be a printable character. If it was just interpreted as a control code, nothing to remove. - if result_length > 0 && last_character_was_printable { - if code_set == CODE_CODE_C { - result.delete(result_length - 2, result_length); - } else { - result.delete(result_length - 1, result_length); - } - } - let left: f32 = (start_pattern_info[1] + start_pattern_info[0]) / 2.0f; - let right: f32 = last_start + last_pattern_size / 2.0f; - let raw_codes_size: i32 = raw_codes.size(); - let raw_bytes: [i8; raw_codes_size] = [0; raw_codes_size]; - { - let mut i: i32 = 0; - while i < raw_codes_size { - { - raw_bytes[i] = raw_codes.get(i); - } - i += 1; - } - } - - let result_object: Result = Result::new(&result.to_string(), &raw_bytes, : vec![ResultPoint; 2] = vec![ResultPoint::new(left, row_number), ResultPoint::new(right, row_number), ] - , BarcodeFormat::CODE_128); - result_object.put_metadata(ResultMetadataType::SYMBOLOGY_IDENTIFIER, format!("]C{}", symbology_modifier)); - return Ok(result_object); - } -} - -// NEW FILE: code128_writer.rs -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * This object renders a CODE128 code as a {@link BitMatrix}. - * - * @author erik.barbara@gmail.com (Erik Barbara) - */ - - const CODE_START_A: i32 = 103; - - const CODE_START_B: i32 = 104; - - const CODE_START_C: i32 = 105; - - const CODE_CODE_A: i32 = 101; - - const CODE_CODE_B: i32 = 100; - - const CODE_CODE_C: i32 = 99; - - const CODE_STOP: i32 = 106; - -// Dummy characters used to specify control characters in input - const ESCAPE_FNC_1: char = 'ñ'; - - const ESCAPE_FNC_2: char = 'ò'; - - const ESCAPE_FNC_3: char = 'ó'; - - const ESCAPE_FNC_4: char = 'ô'; - -// Code A, Code B, Code C - const CODE_FNC_1: i32 = 102; - -// Code A, Code B - const CODE_FNC_2: i32 = 97; - -// Code A, Code B - const CODE_FNC_3: i32 = 96; - -// Code A - const CODE_FNC_4_A: i32 = 101; - -// Code B - const CODE_FNC_4_B: i32 = 100; -pub struct Code128Writer { - super: OneDimensionalCodeWriter; -} - -impl Code128Writer { - - // Results of minimal lookahead for code C - enum CType { - - UNCODABLE(), ONE_DIGIT(), TWO_DIGITS(), FNC_1() - } - - pub fn get_supported_write_formats(&self) -> Collection { - return Collections::singleton(BarcodeFormat::CODE_128); - } - - pub fn encode(&self, contents: &String) -> Vec { - return self.encode(&contents, null); - } - - pub fn encode(&self, contents: &String, hints: &Map) -> Vec { - let forced_code_set: i32 = ::check(&contents, &hints); - let has_compaction_hint: bool = hints != null && hints.contains_key(EncodeHintType::CODE128_COMPACT) && Boolean::parse_boolean(&hints.get(EncodeHintType::CODE128_COMPACT).to_string()); - return if has_compaction_hint { MinimalEncoder::new().encode(&contents) } else { ::encode_fast(&contents, forced_code_set) }; - } - - fn check( contents: &String, hints: &Map) -> i32 { - let length: i32 = contents.length(); - // Check length - if length < 1 || length > 80 { - throw IllegalArgumentException::new(format!("Contents length should be between 1 and 80 characters, but got {}", length)); - } - // Check for forced code set hint. - let forced_code_set: i32 = -1; - if hints != null && hints.contains_key(EncodeHintType::FORCE_CODE_SET) { - let code_set_hint: String = hints.get(EncodeHintType::FORCE_CODE_SET).to_string(); - match code_set_hint { - "A" => - { - forced_code_set = CODE_CODE_A; - break; - } - "B" => - { - forced_code_set = CODE_CODE_B; - break; - } - "C" => - { - forced_code_set = CODE_CODE_C; - break; - } - _ => - { - throw IllegalArgumentException::new(format!("Unsupported code set hint: {}", code_set_hint)); - } - } - } - // Check content - { - let mut i: i32 = 0; - while i < length { - { - let c: char = contents.char_at(i); - // check for non ascii characters that are not special GS1 characters - match c { - // special function characters - ESCAPE_FNC_1 => - { - } - ESCAPE_FNC_2 => - { - } - ESCAPE_FNC_3 => - { - } - ESCAPE_FNC_4 => - { - break; - } - // non ascii characters - _ => - { - if c > 127 { - // shift and manual code change are not supported - throw IllegalArgumentException::new(format!("Bad character in input: ASCII value={}", c as i32)); - } - } - } - // check characters for compatibility with forced code set - match forced_code_set { - CODE_CODE_A => - { - // allows no ascii above 95 (no lower caps, no special symbols) - if c > 95 && c <= 127 { - throw IllegalArgumentException::new(format!("Bad character in input for forced code set A: ASCII value={}", c as i32)); - } - break; - } - CODE_CODE_B => - { - // allows no ascii below 32 (terminal symbols) - if c <= 32 { - throw IllegalArgumentException::new(format!("Bad character in input for forced code set B: ASCII value={}", c as i32)); - } - break; - } - CODE_CODE_C => - { - // allows only numbers and no FNC 2/3/4 - if c < 48 || (c > 57 && c <= 127) || c == ESCAPE_FNC_2 || c == ESCAPE_FNC_3 || c == ESCAPE_FNC_4 { - throw IllegalArgumentException::new(format!("Bad character in input for forced code set C: ASCII value={}", c as i32)); - } - break; - } - } - } - i += 1; - } - } - - return forced_code_set; - } - - fn encode_fast( contents: &String, forced_code_set: i32) -> Vec { - let length: i32 = contents.length(); - // temporary storage for patterns - let patterns: Collection> = ArrayList<>::new(); - let check_sum: i32 = 0; - let check_weight: i32 = 1; - // selected code (CODE_CODE_B or CODE_CODE_C) - let code_set: i32 = 0; - // position in contents - let mut position: i32 = 0; - while position < length { - //Select code to use - let new_code_set: i32; - if forced_code_set == -1 { - new_code_set = ::choose_code(&contents, position, code_set); - } else { - new_code_set = forced_code_set; - } - //Get the pattern index - let pattern_index: i32; - if new_code_set == code_set { - // First handle escapes - match contents.char_at(position) { - ESCAPE_FNC_1 => - { - pattern_index = CODE_FNC_1; - break; - } - ESCAPE_FNC_2 => - { - pattern_index = CODE_FNC_2; - break; - } - ESCAPE_FNC_3 => - { - pattern_index = CODE_FNC_3; - break; - } - ESCAPE_FNC_4 => - { - if code_set == CODE_CODE_A { - pattern_index = CODE_FNC_4_A; - } else { - pattern_index = CODE_FNC_4_B; - } - break; - } - _ => - { - // Then handle normal characters otherwise - match code_set { - CODE_CODE_A => - { - pattern_index = contents.char_at(position) - ' '; - if pattern_index < 0 { - // everything below a space character comes behind the underscore in the code patterns table - pattern_index += '`'; - } - break; - } - CODE_CODE_B => - { - pattern_index = contents.char_at(position) - ' '; - break; - } - _ => - { - // CODE_CODE_C - if position + 1 == length { - // this is the last character, but the encoding is C, which always encodes two characers - throw IllegalArgumentException::new("Bad number of characters for digit only encoding."); - } - pattern_index = Integer::parse_int(&contents.substring(position, position + 2)); - // Also incremented below - position += 1; - break; - } - } - } - } - position += 1; - } else { - // Do we have a code set? - if code_set == 0 { - // No, we don't have a code set - match new_code_set { - CODE_CODE_A => - { - pattern_index = CODE_START_A; - break; - } - CODE_CODE_B => - { - pattern_index = CODE_START_B; - break; - } - _ => - { - pattern_index = CODE_START_C; - break; - } - } - } else { - // Yes, we have a code set - pattern_index = new_code_set; - } - code_set = new_code_set; - } - // Get the pattern - patterns.add(Code128Reader::CODE_PATTERNS[pattern_index]); - // Compute checksum - check_sum += pattern_index * check_weight; - if position != 0 { - check_weight += 1; - } - } - return ::produce_result(&patterns, check_sum); - } - - fn produce_result( patterns: &Collection>, check_sum: i32) -> Vec { - // Compute and append checksum - check_sum %= 103; - patterns.add(Code128Reader::CODE_PATTERNS[check_sum]); - // Append stop code - patterns.add(Code128Reader::CODE_PATTERNS[CODE_STOP]); - // Compute code width - let code_width: i32 = 0; - for let pattern: Vec in patterns { - for let width: i32 in pattern { - code_width += width; - } - } - // Compute result - let result: [bool; code_width] = [false; code_width]; - let mut pos: i32 = 0; - for let pattern: Vec in patterns { - pos += append_pattern(&result, pos, &pattern, true); - } - return result; - } - - fn find_c_type( value: &CharSequence, start: i32) -> CType { - let last: i32 = value.length(); - if start >= last { - return CType.UNCODABLE; - } - let mut c: char = value.char_at(start); - if c == ESCAPE_FNC_1 { - return CType.FNC_1; - } - if c < '0' || c > '9' { - return CType.UNCODABLE; - } - if start + 1 >= last { - return CType.ONE_DIGIT; - } - c = value.char_at(start + 1); - if c < '0' || c > '9' { - return CType.ONE_DIGIT; - } - return CType.TWO_DIGITS; - } - - fn choose_code( value: &CharSequence, start: i32, old_code: i32) -> i32 { - let mut lookahead: CType = ::find_c_type(&value, start); - if lookahead == CType.ONE_DIGIT { - if old_code == CODE_CODE_A { - return CODE_CODE_A; - } - return CODE_CODE_B; - } - if lookahead == CType.UNCODABLE { - if start < value.length() { - let c: char = value.char_at(start); - if c < ' ' || (old_code == CODE_CODE_A && (c < '`' || (c >= ESCAPE_FNC_1 && c <= ESCAPE_FNC_4))) { - // can continue in code A, encodes ASCII 0 to 95 or FNC1 to FNC4 - return CODE_CODE_A; - } - } - // no choice - return CODE_CODE_B; - } - if old_code == CODE_CODE_A && lookahead == CType.FNC_1 { - return CODE_CODE_A; - } - if old_code == CODE_CODE_C { - // can continue in code C - return CODE_CODE_C; - } - if old_code == CODE_CODE_B { - if lookahead == CType.FNC_1 { - // can continue in code B - return CODE_CODE_B; - } - // Seen two consecutive digits, see what follows - lookahead = ::find_c_type(&value, start + 2); - if lookahead == CType.UNCODABLE || lookahead == CType.ONE_DIGIT { - // not worth switching now - return CODE_CODE_B; - } - if lookahead == CType.FNC_1 { - // two digits, then FNC_1... - lookahead = ::find_c_type(&value, start + 3); - if lookahead == CType.TWO_DIGITS { - // then two more digits, switch - return CODE_CODE_C; - } else { - // otherwise not worth switching - return CODE_CODE_B; - } - } - // At this point, there are at least 4 consecutive digits. - // Look ahead to choose whether to switch now or on the next round. - let mut index: i32 = start + 4; - while (lookahead = ::find_c_type(&value, index)) == CType.TWO_DIGITS { - index += 2; - } - if lookahead == CType.ONE_DIGIT { - // odd number of digits, switch later - return CODE_CODE_B; - } - // even number of digits, switch now - return CODE_CODE_C; - } - // Here oldCode == 0, which means we are choosing the initial code - if lookahead == CType.FNC_1 { - // ignore FNC_1 - lookahead = ::find_c_type(&value, start + 1); - } - if lookahead == CType.TWO_DIGITS { - // at least two digits, start in code C - return CODE_CODE_C; - } - return CODE_CODE_B; - } - - /** - * Encodes minimally using Divide-And-Conquer with Memoization - **/ - - const A: &'static str = format!(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ \n \rÿ"); - - const B: &'static str = format!(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÿ"); - - const CODE_SHIFT: i32 = 98; - struct MinimalEncoder { - - let memoized_cost: Vec>; - - let min_path: Vec>; - } - - impl MinimalEncoder { - - enum Charset { - - A(), B(), C(), NONE() - } - - enum Latch { - - A(), B(), C(), SHIFT(), NONE() - } - - fn encode(&self, contents: &String) -> Vec { - self.memoized_cost = : [[i32; contents.length()]; 4] = [[0; contents.length()]; 4]; - self.min_path = : [[Option; contents.length()]; 4] = [[None; contents.length()]; 4]; - self.encode(&contents, Charset::NONE, 0); - let patterns: Collection> = ArrayList<>::new(); - let check_sum : vec![i32; 1] = vec![0, ] - ; - let check_weight : vec![i32; 1] = vec![1, ] - ; - let length: i32 = contents.length(); - let mut charset: Charset = Charset::NONE; - { - let mut i: i32 = 0; - while i < length { - { - let latch: Latch = self.min_path[charset.ordinal()][i]; - match latch { - A => - { - charset = Charset::A; - ::add_pattern(&patterns, if i == 0 { CODE_START_A } else { CODE_CODE_A }, &check_sum, &check_weight, i); - break; - } - B => - { - charset = Charset::B; - ::add_pattern(&patterns, if i == 0 { CODE_START_B } else { CODE_CODE_B }, &check_sum, &check_weight, i); - break; - } - C => - { - charset = Charset::C; - ::add_pattern(&patterns, if i == 0 { CODE_START_C } else { CODE_CODE_C }, &check_sum, &check_weight, i); - break; - } - SHIFT => - { - ::add_pattern(&patterns, CODE_SHIFT, &check_sum, &check_weight, i); - break; - } - } - if charset == Charset::C { - if contents.char_at(i) == ESCAPE_FNC_1 { - ::add_pattern(&patterns, CODE_FNC_1, &check_sum, &check_weight, i); - } else { - ::add_pattern(&patterns, &Integer::parse_int(&contents.substring(i, i + 2)), &check_sum, &check_weight, i); - //the algorithm never leads to a single trailing digit in character set C - assert!( i + 1 < length); - if i + 1 < length { - i += 1; - } - } - } else { - // charset A or B - let pattern_index: i32; - match contents.char_at(i) { - ESCAPE_FNC_1 => - { - pattern_index = CODE_FNC_1; - break; - } - ESCAPE_FNC_2 => - { - pattern_index = CODE_FNC_2; - break; - } - ESCAPE_FNC_3 => - { - pattern_index = CODE_FNC_3; - break; - } - ESCAPE_FNC_4 => - { - if (charset == Charset::A && latch != Latch::SHIFT) || (charset == Charset::B && latch == Latch::SHIFT) { - pattern_index = CODE_FNC_4_A; - } else { - pattern_index = CODE_FNC_4_B; - } - break; - } - _ => - { - pattern_index = contents.char_at(i) - ' '; - } - } - if (charset == Charset::A && latch != Latch::SHIFT) || (charset == Charset::B && latch == Latch::SHIFT) { - if pattern_index < 0 { - pattern_index += '`'; - } - } - ::add_pattern(&patterns, pattern_index, &check_sum, &check_weight, i); - } - } - i += 1; - } - } - - self.memoized_cost = null; - self.min_path = null; - return ::produce_result(&patterns, check_sum[0]); - } - - fn add_pattern( patterns: &Collection>, pattern_index: i32, check_sum: &Vec, check_weight: &Vec, position: i32) { - patterns.add(Code128Reader::CODE_PATTERNS[pattern_index]); - if position != 0 { - check_weight[0] += 1; - } - check_sum[0] += pattern_index * check_weight[0]; - } - - fn is_digit( c: char) -> bool { - return c >= '0' && c <= '9'; - } - - fn can_encode(&self, contents: &CharSequence, charset: &Charset, position: i32) -> bool { - let c: char = contents.char_at(position); - match charset { - A => - { - return c == ESCAPE_FNC_1 || c == ESCAPE_FNC_2 || c == ESCAPE_FNC_3 || c == ESCAPE_FNC_4 || A::index_of(c) >= 0; - } - B => - { - return c == ESCAPE_FNC_1 || c == ESCAPE_FNC_2 || c == ESCAPE_FNC_3 || c == ESCAPE_FNC_4 || B::index_of(c) >= 0; - } - C => - { - return c == ESCAPE_FNC_1 || (position + 1 < contents.length() && ::is_digit(c) && ::is_digit(&contents.char_at(position + 1))); - } - _ => - { - return false; - } - } - } - - /** - * Encode the string starting at position position starting with the character set charset - **/ - fn encode(&self, contents: &CharSequence, charset: &Charset, position: i32) -> i32 { - assert!( position < contents.length()); - let m_cost: i32 = self.memoized_cost[charset.ordinal()][position]; - if m_cost > 0 { - return m_cost; - } - let min_cost: i32 = Integer::MAX_VALUE; - let min_latch: Latch = Latch::NONE; - let at_end: bool = position + 1 >= contents.length(); - let sets : vec![Charset; 2] = vec![Charset::A, Charset::B, ] - ; - { - let mut i: i32 = 0; - while i <= 1 { - { - if self.can_encode(&contents, sets[i], position) { - let mut cost: i32 = 1; - let mut latch: Latch = Latch::NONE; - if charset != sets[i] { - cost += 1; - latch = Latch::value_of(&sets[i].to_string()); - } - if !at_end { - cost += self.encode(&contents, sets[i], position + 1); - } - if cost < min_cost { - min_cost = cost; - min_latch = latch; - } - cost = 1; - if charset == sets[(i + 1) % 2] { - cost += 1; - latch = Latch::SHIFT; - if !at_end { - cost += self.encode(&contents, charset, position + 1); - } - if cost < min_cost { - min_cost = cost; - min_latch = latch; - } - } - } - } - i += 1; - } - } - - if self.can_encode(&contents, Charset::C, position) { - let mut cost: i32 = 1; - let mut latch: Latch = Latch::NONE; - if charset != Charset::C { - cost += 1; - latch = Latch::C; - } - let advance: i32 = if contents.char_at(position) == ESCAPE_FNC_1 { 1 } else { 2 }; - if position + advance < contents.length() { - cost += self.encode(&contents, Charset::C, position + advance); - } - if cost < min_cost { - min_cost = cost; - min_latch = latch; - } - } - if min_cost == Integer::MAX_VALUE { - throw IllegalArgumentException::new(format!("Bad character in input: ASCII value={}", contents.char_at(position) as i32)); - } - self.memoized_cost[charset.ordinal()][position] = min_cost; - self.min_path[charset.ordinal()][position] = min_latch; - return min_cost; - } - } - -} - -// NEW FILE: code39_reader.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

Decodes Code 39 barcodes. Supports "Full ASCII Code 39" if USE_CODE_39_EXTENDED_MODE is set.

- * - * @author Sean Owen - * @see Code93Reader - */ - - const ALPHABET_STRING: &'static str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; - -/** - * These represent the encodings of characters, as patterns of wide and narrow bars. - * The 9 least-significant bits of each int correspond to the pattern of wide and narrow, - * with 1s representing "wide" and 0s representing narrow. - */ - const CHARACTER_ENCODINGS: vec![Vec; 43] = vec![// 0-9 -0x034, // 0-9 -0x121, // 0-9 -0x061, // 0-9 -0x160, // 0-9 -0x031, // 0-9 -0x130, // 0-9 -0x070, // 0-9 -0x025, // 0-9 -0x124, // 0-9 -0x064, // A-J -0x109, // A-J -0x049, // A-J -0x148, // A-J -0x019, // A-J -0x118, // A-J -0x058, // A-J -0x00D, // A-J -0x10C, // A-J -0x04C, // A-J -0x01C, // K-T -0x103, // K-T -0x043, // K-T -0x142, // K-T -0x013, // K-T -0x112, // K-T -0x052, // K-T -0x007, // K-T -0x106, // K-T -0x046, // K-T -0x016, // U-$ -0x181, // U-$ -0x0C1, // U-$ -0x1C0, // U-$ -0x091, // U-$ -0x190, // U-$ -0x0D0, // U-$ -0x085, // U-$ -0x184, // U-$ -0x0C4, // U-$ -0x0A8, // /-% -0x0A2, // /-% -0x08A, // /-% -0x02A, ] -; - - const ASTERISK_ENCODING: i32 = 0x094; -pub struct Code39Reader { - super: OneDReader; - - let using_check_digit: bool; - - let extended_mode: bool; - - let decode_row_result: StringBuilder; - - let mut counters: Vec; -} - -impl Code39Reader { - - /** - * Creates a reader that assumes all encoded data is data, and does not treat the final - * character as a check digit. It will not decoded "extended Code 39" sequences. - */ - pub fn new() -> Code39Reader { - this(false); - } - - /** - * Creates a reader that can be configured to check the last character as a check digit. - * It will not decoded "extended Code 39" sequences. - * - * @param usingCheckDigit if true, treat the last data character as a check digit, not - * data, and verify that the checksum passes. - */ - pub fn new( using_check_digit: bool) -> Code39Reader { - this(using_check_digit, false); - } - - /** - * Creates a reader that can be configured to check the last character as a check digit, - * or optionally attempt to decode "extended Code 39" sequences that are used to encode - * the full ASCII character set. - * - * @param usingCheckDigit if true, treat the last data character as a check digit, not - * data, and verify that the checksum passes. - * @param extendedMode if true, will attempt to decode extended Code 39 sequences in the - * text. - */ - pub fn new( using_check_digit: bool, extended_mode: bool) -> Code39Reader { - let .usingCheckDigit = using_check_digit; - let .extendedMode = extended_mode; - decode_row_result = StringBuilder::new(20); - counters = : [i32; 9] = [0; 9]; - } - - pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException, ChecksumException, FormatException */Result> { - let the_counters: Vec = self.counters; - Arrays::fill(&the_counters, 0); - let result: StringBuilder = self.decode_row_result; - result.set_length(0); - let start: Vec = ::find_asterisk_pattern(row, &the_counters); - // Read off white space - let next_start: i32 = row.get_next_set(start[1]); - let end: i32 = row.get_size(); - let decoded_char: char; - let last_start: i32; - loop { { - record_pattern(row, next_start, &the_counters); - let pattern: i32 = ::to_narrow_wide_pattern(&the_counters); - if pattern < 0 { - throw NotFoundException::get_not_found_instance(); - } - decoded_char = ::pattern_to_char(pattern); - result.append(decoded_char); - last_start = next_start; - for let counter: i32 in the_counters { - next_start += counter; - } - // Read off white space - next_start = row.get_next_set(next_start); - }if !(decoded_char != '*') break;} - // remove asterisk - result.set_length(result.length() - 1); - // Look for whitespace after pattern: - let last_pattern_size: i32 = 0; - for let counter: i32 in the_counters { - last_pattern_size += counter; - } - let white_space_after_end: i32 = next_start - last_start - last_pattern_size; - // (but if it's whitespace to the very end of the image, that's OK) - if next_start != end && (white_space_after_end * 2) < last_pattern_size { - throw NotFoundException::get_not_found_instance(); - } - if self.using_check_digit { - let max: i32 = result.length() - 1; - let mut total: i32 = 0; - { - let mut i: i32 = 0; - while i < max { - { - total += ALPHABET_STRING::index_of(&self.decode_row_result.char_at(i)); - } - i += 1; - } - } - - if result.char_at(max) != ALPHABET_STRING::char_at(total % 43) { - throw ChecksumException::get_checksum_instance(); - } - result.set_length(max); - } - if result.length() == 0 { - // false positive - throw NotFoundException::get_not_found_instance(); - } - let result_string: String; - if self.extended_mode { - result_string = ::decode_extended(&result); - } else { - result_string = result.to_string(); - } - let left: f32 = (start[1] + start[0]) / 2.0f; - let right: f32 = last_start + last_pattern_size / 2.0f; - let result_object: Result = Result::new(&result_string, null, : vec![ResultPoint; 2] = vec![ResultPoint::new(left, row_number), ResultPoint::new(right, row_number), ] - , BarcodeFormat::CODE_39); - result_object.put_metadata(ResultMetadataType::SYMBOLOGY_IDENTIFIER, "]A0"); - return Ok(result_object); - } - - fn find_asterisk_pattern( row: &BitArray, counters: &Vec) -> /* throws NotFoundException */Result, Rc> { - let width: i32 = row.get_size(); - let row_offset: i32 = row.get_next_set(0); - let counter_position: i32 = 0; - let pattern_start: i32 = row_offset; - let is_white: bool = false; - let pattern_length: i32 = counters.len(); - { - let mut i: i32 = row_offset; - while i < width { - { - if row.get(i) != is_white { - counters[counter_position] += 1; - } else { - if counter_position == pattern_length - 1 { - // Look for whitespace before start pattern, >= 50% of width of start pattern - if ::to_narrow_wide_pattern(&counters) == ASTERISK_ENCODING && row.is_range(&Math::max(0, pattern_start - ((i - pattern_start) / 2)), pattern_start, false) { - return Ok( : vec![i32; 2] = vec![pattern_start, i, ] - ); - } - pattern_start += counters[0] + counters[1]; - System::arraycopy(&counters, 2, &counters, 0, counter_position - 1); - counters[counter_position - 1] = 0; - counters[counter_position] = 0; - counter_position -= 1; - } else { - counter_position += 1; - } - counters[counter_position] = 1; - is_white = !is_white; - } - } - i += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - // For efficiency, returns -1 on failure. Not throwing here saved as many as 700 exceptions - // per image when using some of our blackbox images. - fn to_narrow_wide_pattern( counters: &Vec) -> i32 { - let num_counters: i32 = counters.len(); - let max_narrow_counter: i32 = 0; - let wide_counters: i32; - loop { { - let min_counter: i32 = Integer::MAX_VALUE; - for let counter: i32 in counters { - if counter < min_counter && counter > max_narrow_counter { - min_counter = counter; - } - } - max_narrow_counter = min_counter; - wide_counters = 0; - let total_wide_counters_width: i32 = 0; - let mut pattern: i32 = 0; - { - let mut i: i32 = 0; - while i < num_counters { - { - let counter: i32 = counters[i]; - if counter > max_narrow_counter { - pattern |= 1 << (num_counters - 1 - i); - wide_counters += 1; - total_wide_counters_width += counter; - } - } - i += 1; - } - } - - if wide_counters == 3 { - // counter is more than 1.5 times the average: - { - let mut i: i32 = 0; - while i < num_counters && wide_counters > 0 { - { - let counter: i32 = counters[i]; - if counter > max_narrow_counter { - wide_counters -= 1; - // totalWideCountersWidth = 3 * average, so this checks if counter >= 3/2 * average - if (counter * 2) >= total_wide_counters_width { - return -1; - } - } - } - i += 1; - } - } - - return pattern; - } - }if !(wide_counters > 3) break;} - return -1; - } - - fn pattern_to_char( pattern: i32) -> /* throws NotFoundException */Result> { - { - let mut i: i32 = 0; - while i < CHARACTER_ENCODINGS.len() { - { - if CHARACTER_ENCODINGS[i] == pattern { - return Ok(ALPHABET_STRING::char_at(i)); - } - } - i += 1; - } - } - - if pattern == ASTERISK_ENCODING { - return Ok('*'); - } - throw NotFoundException::get_not_found_instance(); - } - - fn decode_extended( encoded: &CharSequence) -> /* throws FormatException */Result> { - let length: i32 = encoded.length(); - let decoded: StringBuilder = StringBuilder::new(length); - { - let mut i: i32 = 0; - while i < length { - { - let c: char = encoded.char_at(i); - if c == '+' || c == '$' || c == '%' || c == '/' { - let next: char = encoded.char_at(i + 1); - let decoded_char: char = '\0'; - match c { - '+' => - { - // +A to +Z map to a to z - if next >= 'A' && next <= 'Z' { - decoded_char = (next + 32) as char; - } else { - throw FormatException::get_format_instance(); - } - break; - } - '$' => - { - // $A to $Z map to control codes SH to SB - if next >= 'A' && next <= 'Z' { - decoded_char = (next - 64) as char; - } else { - throw FormatException::get_format_instance(); - } - break; - } - '%' => - { - // %A to %E map to control codes ESC to US - if next >= 'A' && next <= 'E' { - decoded_char = (next - 38) as char; - } else if next >= 'F' && next <= 'J' { - decoded_char = (next - 11) as char; - } else if next >= 'K' && next <= 'O' { - decoded_char = (next + 16) as char; - } else if next >= 'P' && next <= 'T' { - decoded_char = (next + 43) as char; - } else if next == 'U' { - decoded_char = 0 as char; - } else if next == 'V' { - decoded_char = '@'; - } else if next == 'W' { - decoded_char = '`'; - } else if next == 'X' || next == 'Y' || next == 'Z' { - decoded_char = 127 as char; - } else { - throw FormatException::get_format_instance(); - } - break; - } - '/' => - { - // /A to /O map to ! to , and /Z maps to : - if next >= 'A' && next <= 'O' { - decoded_char = (next - 32) as char; - } else if next == 'Z' { - decoded_char = ':'; - } else { - throw FormatException::get_format_instance(); - } - break; - } - } - decoded.append(decoded_char); - // bump up i again since we read two characters - i += 1; - } else { - decoded.append(c); - } - } - i += 1; - } - } - - return Ok(decoded.to_string()); - } -} - -// NEW FILE: code39_writer.rs -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * This object renders a CODE39 code as a {@link BitMatrix}. - * - * @author erik.barbara@gmail.com (Erik Barbara) - */ -pub struct Code39Writer { - super: OneDimensionalCodeWriter; -} - -impl Code39Writer { - - pub fn get_supported_write_formats(&self) -> Collection { - return Collections::singleton(BarcodeFormat::CODE_39); - } - - pub fn encode(&self, contents: &String) -> Vec { - let mut length: i32 = contents.length(); - if length > 80 { - throw IllegalArgumentException::new(format!("Requested contents should be less than 80 digits long, but got {}", length)); - } - { - let mut i: i32 = 0; - while i < length { - { - let index_in_string: i32 = Code39Reader::ALPHABET_STRING::index_of(&contents.char_at(i)); - if index_in_string < 0 { - contents = ::try_to_convert_to_extended_mode(&contents); - length = contents.length(); - if length > 80 { - throw IllegalArgumentException::new(format!("Requested contents should be less than 80 digits long, but got {} (extended full ASCII mode)", length)); - } - break; - } - } - i += 1; - } - } - - let widths: [i32; 9] = [0; 9]; - let code_width: i32 = 24 + 1 + (13 * length); - let result: [bool; code_width] = [false; code_width]; - ::to_int_array(Code39Reader::ASTERISK_ENCODING, &widths); - let mut pos: i32 = append_pattern(&result, 0, &widths, true); - let narrow_white: vec![Vec; 1] = vec![1, ] - ; - pos += append_pattern(&result, pos, &narrow_white, false); - //append next character to byte matrix - { - let mut i: i32 = 0; - while i < length { - { - let index_in_string: i32 = Code39Reader::ALPHABET_STRING::index_of(&contents.char_at(i)); - ::to_int_array(Code39Reader::CHARACTER_ENCODINGS[index_in_string], &widths); - pos += append_pattern(&result, pos, &widths, true); - pos += append_pattern(&result, pos, &narrow_white, false); - } - i += 1; - } - } - - ::to_int_array(Code39Reader::ASTERISK_ENCODING, &widths); - append_pattern(&result, pos, &widths, true); - return result; - } - - fn to_int_array( a: i32, to_return: &Vec) { - { - let mut i: i32 = 0; - while i < 9 { - { - let temp: i32 = a & (1 << (8 - i)); - to_return[i] = if temp == 0 { 1 } else { 2 }; - } - i += 1; - } - } - - } - - fn try_to_convert_to_extended_mode( contents: &String) -> String { - let length: i32 = contents.length(); - let extended_content: StringBuilder = StringBuilder::new(); - { - let mut i: i32 = 0; - while i < length { - { - let character: char = contents.char_at(i); - match character { - '' => - { - extended_content.append("%U"); - break; - } - ' ' => - { - } - '-' => - { - } - '.' => - { - extended_content.append(character); - break; - } - '@' => - { - extended_content.append("%V"); - break; - } - '`' => - { - extended_content.append("%W"); - break; - } - _ => - { - if character <= 26 { - extended_content.append('$'); - extended_content.append(('A' + (character - 1)) as char); - } else if character < ' ' { - extended_content.append('%'); - extended_content.append(('A' + (character - 27)) as char); - } else if character <= ',' || character == '/' || character == ':' { - extended_content.append('/'); - extended_content.append(('A' + (character - 33)) as char); - } else if character <= '9' { - extended_content.append(('0' + (character - 48)) as char); - } else if character <= '?' { - extended_content.append('%'); - extended_content.append(('F' + (character - 59)) as char); - } else if character <= 'Z' { - extended_content.append(('A' + (character - 65)) as char); - } else if character <= '_' { - extended_content.append('%'); - extended_content.append(('K' + (character - 91)) as char); - } else if character <= 'z' { - extended_content.append('+'); - extended_content.append(('A' + (character - 97)) as char); - } else if character <= 127 { - extended_content.append('%'); - extended_content.append(('P' + (character - 123)) as char); - } else { - throw IllegalArgumentException::new(format!("Requested content contains a non-encodable character: '{}'", contents.char_at(i))); - } - break; - } - } - } - i += 1; - } - } - - return extended_content.to_string(); - } -} - -// NEW FILE: code93_reader.rs -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

Decodes Code 93 barcodes.

- * - * @author Sean Owen - * @see Code39Reader - */ - -// Note that 'abcd' are dummy characters in place of control characters. - const ALPHABET_STRING: &'static str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*"; - - const ALPHABET: Vec = ALPHABET_STRING::to_char_array(); - -/** - * These represent the encodings of characters, as patterns of wide and narrow bars. - * The 9 least-significant bits of each int correspond to the pattern of wide and narrow. - */ - const CHARACTER_ENCODINGS: vec![Vec; 48] = vec![// 0-9 -0x114, // 0-9 -0x148, // 0-9 -0x144, // 0-9 -0x142, // 0-9 -0x128, // 0-9 -0x124, // 0-9 -0x122, // 0-9 -0x150, // 0-9 -0x112, // 0-9 -0x10A, // A-J -0x1A8, // A-J -0x1A4, // A-J -0x1A2, // A-J -0x194, // A-J -0x192, // A-J -0x18A, // A-J -0x168, // A-J -0x164, // A-J -0x162, // A-J -0x134, // K-T -0x11A, // K-T -0x158, // K-T -0x14C, // K-T -0x146, // K-T -0x12C, // K-T -0x116, // K-T -0x1B4, // K-T -0x1B2, // K-T -0x1AC, // K-T -0x1A6, // U-Z -0x196, // U-Z -0x19A, // U-Z -0x16C, // U-Z -0x166, // U-Z -0x136, // U-Z -0x13A, // - - % -0x12E, // - - % -0x1D4, // - - % -0x1D2, // - - % -0x1CA, // - - % -0x16E, // - - % -0x176, // - - % -0x1AE, // Control chars? $-* -0x126, // Control chars? $-* -0x1DA, // Control chars? $-* -0x1D6, // Control chars? $-* -0x132, // Control chars? $-* -0x15E, ] -; - - const ASTERISK_ENCODING: i32 = CHARACTER_ENCODINGS[47]; -pub struct Code93Reader { - super: OneDReader; - - let decode_row_result: StringBuilder; - - let mut counters: Vec; -} - -impl Code93Reader { - - pub fn new() -> Code93Reader { - decode_row_result = StringBuilder::new(20); - counters = : [i32; 6] = [0; 6]; - } - - pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException, ChecksumException, FormatException */Result> { - let start: Vec = self.find_asterisk_pattern(row); - // Read off white space - let next_start: i32 = row.get_next_set(start[1]); - let end: i32 = row.get_size(); - let the_counters: Vec = self.counters; - Arrays::fill(&the_counters, 0); - let result: StringBuilder = self.decode_row_result; - result.set_length(0); - let decoded_char: char; - let last_start: i32; - loop { { - record_pattern(row, next_start, &the_counters); - let pattern: i32 = ::to_pattern(&the_counters); - if pattern < 0 { - throw NotFoundException::get_not_found_instance(); - } - decoded_char = ::pattern_to_char(pattern); - result.append(decoded_char); - last_start = next_start; - for let counter: i32 in the_counters { - next_start += counter; - } - // Read off white space - next_start = row.get_next_set(next_start); - }if !(decoded_char != '*') break;} - // remove asterisk - result.delete_char_at(result.length() - 1); - let last_pattern_size: i32 = 0; - for let counter: i32 in the_counters { - last_pattern_size += counter; - } - // Should be at least one more black module - if next_start == end || !row.get(next_start) { - throw NotFoundException::get_not_found_instance(); - } - if result.length() < 2 { - // false positive -- need at least 2 checksum digits - throw NotFoundException::get_not_found_instance(); - } - ::check_checksums(&result); - // Remove checksum digits - result.set_length(result.length() - 2); - let result_string: String = ::decode_extended(&result); - let left: f32 = (start[1] + start[0]) / 2.0f; - let right: f32 = last_start + last_pattern_size / 2.0f; - let result_object: Result = Result::new(&result_string, null, : vec![ResultPoint; 2] = vec![ResultPoint::new(left, row_number), ResultPoint::new(right, row_number), ] - , BarcodeFormat::CODE_93); - result_object.put_metadata(ResultMetadataType::SYMBOLOGY_IDENTIFIER, "]G0"); - return Ok(result_object); - } - - fn find_asterisk_pattern(&self, row: &BitArray) -> /* throws NotFoundException */Result, Rc> { - let width: i32 = row.get_size(); - let row_offset: i32 = row.get_next_set(0); - Arrays::fill(&self.counters, 0); - let the_counters: Vec = self.counters; - let pattern_start: i32 = row_offset; - let is_white: bool = false; - let pattern_length: i32 = the_counters.len(); - let counter_position: i32 = 0; - { - let mut i: i32 = row_offset; - while i < width { - { - if row.get(i) != is_white { - the_counters[counter_position] += 1; - } else { - if counter_position == pattern_length - 1 { - if ::to_pattern(&the_counters) == ASTERISK_ENCODING { - return Ok( : vec![i32; 2] = vec![pattern_start, i, ] - ); - } - pattern_start += the_counters[0] + the_counters[1]; - System::arraycopy(&the_counters, 2, &the_counters, 0, counter_position - 1); - the_counters[counter_position - 1] = 0; - the_counters[counter_position] = 0; - counter_position -= 1; - } else { - counter_position += 1; - } - the_counters[counter_position] = 1; - is_white = !is_white; - } - } - i += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - fn to_pattern( counters: &Vec) -> i32 { - let mut sum: i32 = 0; - for let counter: i32 in counters { - sum += counter; - } - let mut pattern: i32 = 0; - let max: i32 = counters.len(); - { - let mut i: i32 = 0; - while i < max { - { - let scaled: i32 = Math::round(counters[i] * 9.0f / sum); - if scaled < 1 || scaled > 4 { - return -1; - } - if (i & 0x01) == 0 { - { - let mut j: i32 = 0; - while j < scaled { - { - pattern = (pattern << 1) | 0x01; - } - j += 1; - } - } - - } else { - pattern <<= scaled; - } - } - i += 1; - } - } - - return pattern; - } - - fn pattern_to_char( pattern: i32) -> /* throws NotFoundException */Result> { - { - let mut i: i32 = 0; - while i < CHARACTER_ENCODINGS.len() { - { - if CHARACTER_ENCODINGS[i] == pattern { - return Ok(ALPHABET[i]); - } - } - i += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - fn decode_extended( encoded: &CharSequence) -> /* throws FormatException */Result> { - let length: i32 = encoded.length(); - let decoded: StringBuilder = StringBuilder::new(length); - { - let mut i: i32 = 0; - while i < length { - { - let c: char = encoded.char_at(i); - if c >= 'a' && c <= 'd' { - if i >= length - 1 { - throw FormatException::get_format_instance(); - } - let next: char = encoded.char_at(i + 1); - let decoded_char: char = '\0'; - match c { - 'd' => - { - // +A to +Z map to a to z - if next >= 'A' && next <= 'Z' { - decoded_char = (next + 32) as char; - } else { - throw FormatException::get_format_instance(); - } - break; - } - 'a' => - { - // $A to $Z map to control codes SH to SB - if next >= 'A' && next <= 'Z' { - decoded_char = (next - 64) as char; - } else { - throw FormatException::get_format_instance(); - } - break; - } - 'b' => - { - if next >= 'A' && next <= 'E' { - // %A to %E map to control codes ESC to USep - decoded_char = (next - 38) as char; - } else if next >= 'F' && next <= 'J' { - // %F to %J map to ; < = > ? - decoded_char = (next - 11) as char; - } else if next >= 'K' && next <= 'O' { - // %K to %O map to [ \ ] ^ _ - decoded_char = (next + 16) as char; - } else if next >= 'P' && next <= 'T' { - // %P to %T map to { | } ~ DEL - decoded_char = (next + 43) as char; - } else if next == 'U' { - // %U map to NUL - decoded_char = '\0'; - } else if next == 'V' { - // %V map to @ - decoded_char = '@'; - } else if next == 'W' { - // %W map to ` - decoded_char = '`'; - } else if next >= 'X' && next <= 'Z' { - // %X to %Z all map to DEL (127) - decoded_char = 127; - } else { - throw FormatException::get_format_instance(); - } - break; - } - 'c' => - { - // /A to /O map to ! to , and /Z maps to : - if next >= 'A' && next <= 'O' { - decoded_char = (next - 32) as char; - } else if next == 'Z' { - decoded_char = ':'; - } else { - throw FormatException::get_format_instance(); - } - break; - } - } - decoded.append(decoded_char); - // bump up i again since we read two characters - i += 1; - } else { - decoded.append(c); - } - } - i += 1; - } - } - - return Ok(decoded.to_string()); - } - - fn check_checksums( result: &CharSequence) -> /* throws ChecksumException */Result> { - let length: i32 = result.length(); - ::check_one_checksum(&result, length - 2, 20); - ::check_one_checksum(&result, length - 1, 15); - } - - fn check_one_checksum( result: &CharSequence, check_position: i32, weight_max: i32) -> /* throws ChecksumException */Result> { - let mut weight: i32 = 1; - let mut total: i32 = 0; - { - let mut i: i32 = check_position - 1; - while i >= 0 { - { - total += weight * ALPHABET_STRING::index_of(&result.char_at(i)); - if weight += 1 > weight_max { - weight = 1; - } - } - i -= 1; - } - } - - if result.char_at(check_position) != ALPHABET[total % 47] { - throw ChecksumException::get_checksum_instance(); - } - } -} - -// NEW FILE: code93_writer.rs -/* - * Copyright 2015 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * This object renders a CODE93 code as a BitMatrix - */ -pub struct Code93Writer { - super: OneDimensionalCodeWriter; -} - -impl Code93Writer { - - pub fn get_supported_write_formats(&self) -> Collection { - return Collections::singleton(BarcodeFormat::CODE_93); - } - - /** - * @param contents barcode contents to encode. It should not be encoded for extended characters. - * @return a {@code boolean[]} of horizontal pixels (false = white, true = black) - */ - pub fn encode(&self, contents: &String) -> Vec { - contents = ::convert_to_extended(&contents); - let length: i32 = contents.length(); - if length > 80 { - throw IllegalArgumentException::new(format!("Requested contents should be less than 80 digits long after converting to extended encoding, but got {}", length)); - } - //length of code + 2 start/stop characters + 2 checksums, each of 9 bits, plus a termination bar - let code_width: i32 = (contents.length() + 2 + 2) * 9 + 1; - let mut result: [bool; code_width] = [false; code_width]; - //start character (*) - let mut pos: i32 = ::append_pattern(&result, 0, Code93Reader::ASTERISK_ENCODING); - { - let mut i: i32 = 0; - while i < length { - { - let index_in_string: i32 = Code93Reader::ALPHABET_STRING::index_of(&contents.char_at(i)); - pos += ::append_pattern(&result, pos, Code93Reader::CHARACTER_ENCODINGS[index_in_string]); - } - i += 1; - } - } - - //add two checksums - let check1: i32 = ::compute_checksum_index(&contents, 20); - pos += ::append_pattern(&result, pos, Code93Reader::CHARACTER_ENCODINGS[check1]); - //append the contents to reflect the first checksum added - contents += Code93Reader::ALPHABET_STRING::char_at(check1); - let check2: i32 = ::compute_checksum_index(&contents, 15); - pos += ::append_pattern(&result, pos, Code93Reader::CHARACTER_ENCODINGS[check2]); - //end character (*) - pos += ::append_pattern(&result, pos, Code93Reader::ASTERISK_ENCODING); - //termination bar (single black bar) - result[pos] = true; - return result; - } - - /** - * @param target output to append to - * @param pos start position - * @param pattern pattern to append - * @param startColor unused - * @return 9 - * @deprecated without replacement; intended as an internal-only method - */ - pub fn append_pattern( target: &Vec, pos: i32, pattern: &Vec, start_color: bool) -> i32 { - for let bit: i32 in pattern { - target[pos += 1 !!!check!!! post increment] = bit != 0; - } - return 9; - } - - fn append_pattern( target: &Vec, pos: i32, a: i32) -> i32 { - { - let mut i: i32 = 0; - while i < 9 { - { - let temp: i32 = a & (1 << (8 - i)); - target[pos + i] = temp != 0; - } - i += 1; - } - } - - return 9; - } - - fn compute_checksum_index( contents: &String, max_weight: i32) -> i32 { - let mut weight: i32 = 1; - let mut total: i32 = 0; - { - let mut i: i32 = contents.length() - 1; - while i >= 0 { - { - let index_in_string: i32 = Code93Reader::ALPHABET_STRING::index_of(&contents.char_at(i)); - total += index_in_string * weight; - if weight += 1 > max_weight { - weight = 1; - } - } - i -= 1; - } - } - - return total % 47; - } - - fn convert_to_extended( contents: &String) -> String { - let length: i32 = contents.length(); - let extended_content: StringBuilder = StringBuilder::new(length * 2); - { - let mut i: i32 = 0; - while i < length { - { - let character: char = contents.char_at(i); - // ($)=a, (%)=b, (/)=c, (+)=d. see Code93Reader.ALPHABET_STRING - if character == 0 { - // NUL: (%)U - extended_content.append("bU"); - } else if character <= 26 { - // SOH - SUB: ($)A - ($)Z - extended_content.append('a'); - extended_content.append(('A' + character - 1) as char); - } else if character <= 31 { - // ESC - US: (%)A - (%)E - extended_content.append('b'); - extended_content.append(('A' + character - 27) as char); - } else if character == ' ' || character == '$' || character == '%' || character == '+' { - // space $ % + - extended_content.append(character); - } else if character <= ',' { - // ! " # & ' ( ) * ,: (/)A - (/)L - extended_content.append('c'); - extended_content.append(('A' + character - '!') as char); - } else if character <= '9' { - extended_content.append(character); - } else if character == ':' { - // :: (/)Z - extended_content.append("cZ"); - } else if character <= '?' { - // ; - ?: (%)F - (%)J - extended_content.append('b'); - extended_content.append(('F' + character - ';') as char); - } else if character == '@' { - // @: (%)V - extended_content.append("bV"); - } else if character <= 'Z' { - // A - Z - extended_content.append(character); - } else if character <= '_' { - // [ - _: (%)K - (%)O - extended_content.append('b'); - extended_content.append(('K' + character - '[') as char); - } else if character == '`' { - // `: (%)W - extended_content.append("bW"); - } else if character <= 'z' { - // a - z: (*)A - (*)Z - extended_content.append('d'); - extended_content.append(('A' + character - 'a') as char); - } else if character <= 127 { - // { - DEL: (%)P - (%)T - extended_content.append('b'); - extended_content.append(('P' + character - '{') as char); - } else { - throw IllegalArgumentException::new(format!("Requested content contains a non-encodable character: '{}'", character)); - } - } - i += 1; - } - } - - return extended_content.to_string(); - } -} - -// NEW FILE: e_a_n13_reader.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

Implements decoding of the EAN-13 format.

- * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - * @author alasdair@google.com (Alasdair Mackintosh) - */ - -// For an EAN-13 barcode, the first digit is represented by the parities used -// to encode the next six digits, according to the table below. For example, -// if the barcode is 5 123456 789012 then the value of the first digit is -// signified by using odd for '1', even for '2', even for '3', odd for '4', -// odd for '5', and even for '6'. See http://en.wikipedia.org/wiki/EAN-13 -// -// Parity of next 6 digits -// Digit 0 1 2 3 4 5 -// 0 Odd Odd Odd Odd Odd Odd -// 1 Odd Odd Even Odd Even Even -// 2 Odd Odd Even Even Odd Even -// 3 Odd Odd Even Even Even Odd -// 4 Odd Even Odd Odd Even Even -// 5 Odd Even Even Odd Odd Even -// 6 Odd Even Even Even Odd Odd -// 7 Odd Even Odd Even Odd Even -// 8 Odd Even Odd Even Even Odd -// 9 Odd Even Even Odd Even Odd -// -// Note that the encoding for '0' uses the same parity as a UPC barcode. Hence -// a UPC barcode can be converted to an EAN-13 barcode by prepending a 0. -// -// The encoding is represented by the following array, which is a bit pattern -// using Odd = 0 and Even = 1. For example, 5 is represented by: -// -// Odd Even Even Odd Odd Even -// in binary: -// 0 1 1 0 0 1 == 0x19 -// - const FIRST_DIGIT_ENCODINGS: vec![Vec; 10] = vec![0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A, ] -; -pub struct EAN13Reader { - super: UPCEANReader; - - let decode_middle_counters: Vec; -} - -impl EAN13Reader { - - pub fn new() -> EAN13Reader { - decode_middle_counters = : [i32; 4] = [0; 4]; - } - - pub fn decode_middle(&self, row: &BitArray, start_range: &Vec, result_string: &StringBuilder) -> /* throws NotFoundException */Result> { - let mut counters: Vec = self.decode_middle_counters; - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - let end: i32 = row.get_size(); - let row_offset: i32 = start_range[1]; - let lg_pattern_found: i32 = 0; - { - let mut x: i32 = 0; - while x < 6 && row_offset < end { - { - let best_match: i32 = decode_digit(row, &counters, row_offset, L_AND_G_PATTERNS); - result_string.append(('0' + best_match % 10) as char); - for let counter: i32 in counters { - row_offset += counter; - } - if best_match >= 10 { - lg_pattern_found |= 1 << (5 - x); - } - } - x += 1; - } - } - - ::determine_first_digit(&result_string, lg_pattern_found); - let middle_range: Vec = find_guard_pattern(row, row_offset, true, MIDDLE_PATTERN); - row_offset = middle_range[1]; - { - let mut x: i32 = 0; - while x < 6 && row_offset < end { - { - let best_match: i32 = decode_digit(row, &counters, row_offset, L_PATTERNS); - result_string.append(('0' + best_match) as char); - for let counter: i32 in counters { - row_offset += counter; - } - } - x += 1; - } - } - - return Ok(row_offset); - } - - fn get_barcode_format(&self) -> BarcodeFormat { - return BarcodeFormat::EAN_13; - } - - /** - * Based on pattern of odd-even ('L' and 'G') patterns used to encoded the explicitly-encoded - * digits in a barcode, determines the implicitly encoded first digit and adds it to the - * result string. - * - * @param resultString string to insert decoded first digit into - * @param lgPatternFound int whose bits indicates the pattern of odd/even L/G patterns used to - * encode digits - * @throws NotFoundException if first digit cannot be determined - */ - fn determine_first_digit( result_string: &StringBuilder, lg_pattern_found: i32) -> /* throws NotFoundException */Result> { - { - let mut d: i32 = 0; - while d < 10 { - { - if lg_pattern_found == FIRST_DIGIT_ENCODINGS[d] { - result_string.insert(0, ('0' + d) as char); - return; - } - } - d += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } -} - -// NEW FILE: e_a_n13_writer.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * This object renders an EAN13 code as a {@link BitMatrix}. - * - * @author aripollak@gmail.com (Ari Pollak) - */ - - const CODE_WIDTH: i32 = // start guard -3 + // left bars -(7 * 6) + // middle guard -5 + // right bars -(7 * 6) + // end guard -3; -pub struct EAN13Writer { - super: UPCEANWriter; -} - -impl EAN13Writer { - - pub fn get_supported_write_formats(&self) -> Collection { - return Collections::singleton(BarcodeFormat::EAN_13); - } - - pub fn encode(&self, contents: &String) -> Vec { - let length: i32 = contents.length(); - match length { - 12 => - { - // No check digit present, calculate it and add it - let mut check: i32; - let tryResult1 = 0; - 'try1: loop { - { - check = UPCEANReader::get_standard_u_p_c_e_a_n_checksum(&contents); - } - break 'try1 - } - match tryResult1 { - catch ( fe: &FormatException) { - throw IllegalArgumentException::new(fe); - } 0 => break - } - - contents += check; - break; - } - 13 => - { - let tryResult1 = 0; - 'try1: loop { - { - if !UPCEANReader::check_standard_u_p_c_e_a_n_checksum(&contents) { - throw IllegalArgumentException::new("Contents do not pass checksum"); - } - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &FormatException) { - throw IllegalArgumentException::new("Illegal contents"); - } 0 => break - } - - break; - } - _ => - { - throw IllegalArgumentException::new(format!("Requested contents should be 12 or 13 digits long, but got {}", length)); - } - } - check_numeric(&contents); - let first_digit: i32 = Character::digit(&contents.char_at(0), 10); - let parities: i32 = EAN13Reader.FIRST_DIGIT_ENCODINGS[first_digit]; - let result: [bool; CODE_WIDTH] = [false; CODE_WIDTH]; - let mut pos: i32 = 0; - pos += append_pattern(&result, pos, UPCEANReader.START_END_PATTERN, true); - // See EAN13Reader for a description of how the first digit & left bars are encoded - { - let mut i: i32 = 1; - while i <= 6 { - { - let mut digit: i32 = Character::digit(&contents.char_at(i), 10); - if (parities >> (6 - i) & 1) == 1 { - digit += 10; - } - pos += append_pattern(&result, pos, UPCEANReader.L_AND_G_PATTERNS[digit], false); - } - i += 1; - } - } - - pos += append_pattern(&result, pos, UPCEANReader.MIDDLE_PATTERN, false); - { - let mut i: i32 = 7; - while i <= 12 { - { - let digit: i32 = Character::digit(&contents.char_at(i), 10); - pos += append_pattern(&result, pos, UPCEANReader.L_PATTERNS[digit], true); - } - i += 1; - } - } - - append_pattern(&result, pos, UPCEANReader.START_END_PATTERN, true); - return result; - } -} - -// NEW FILE: e_a_n8_reader.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

Implements decoding of the EAN-8 format.

- * - * @author Sean Owen - */ -pub struct EAN8Reader { - super: UPCEANReader; - - let decode_middle_counters: Vec; -} - -impl EAN8Reader { - - pub fn new() -> EAN8Reader { - decode_middle_counters = : [i32; 4] = [0; 4]; - } - - pub fn decode_middle(&self, row: &BitArray, start_range: &Vec, result: &StringBuilder) -> /* throws NotFoundException */Result> { - let mut counters: Vec = self.decode_middle_counters; - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - let end: i32 = row.get_size(); - let row_offset: i32 = start_range[1]; - { - let mut x: i32 = 0; - while x < 4 && row_offset < end { - { - let best_match: i32 = decode_digit(row, &counters, row_offset, L_PATTERNS); - result.append(('0' + best_match) as char); - for let counter: i32 in counters { - row_offset += counter; - } - } - x += 1; - } - } - - let middle_range: Vec = find_guard_pattern(row, row_offset, true, MIDDLE_PATTERN); - row_offset = middle_range[1]; - { - let mut x: i32 = 0; - while x < 4 && row_offset < end { - { - let best_match: i32 = decode_digit(row, &counters, row_offset, L_PATTERNS); - result.append(('0' + best_match) as char); - for let counter: i32 in counters { - row_offset += counter; - } - } - x += 1; - } - } - - return Ok(row_offset); - } - - fn get_barcode_format(&self) -> BarcodeFormat { - return BarcodeFormat::EAN_8; - } -} - -// NEW FILE: e_a_n8_writer.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * This object renders an EAN8 code as a {@link BitMatrix}. - * - * @author aripollak@gmail.com (Ari Pollak) - */ - - const CODE_WIDTH: i32 = // start guard -3 + // left bars -(7 * 4) + // middle guard -5 + // right bars -(7 * 4) + // end guard -3; -pub struct EAN8Writer { - super: UPCEANWriter; -} - -impl EAN8Writer { - - pub fn get_supported_write_formats(&self) -> Collection { - return Collections::singleton(BarcodeFormat::EAN_8); - } - - /** - * @return a byte array of horizontal pixels (false = white, true = black) - */ - pub fn encode(&self, contents: &String) -> Vec { - let length: i32 = contents.length(); - match length { - 7 => - { - // No check digit present, calculate it and add it - let mut check: i32; - let tryResult1 = 0; - 'try1: loop { - { - check = UPCEANReader::get_standard_u_p_c_e_a_n_checksum(&contents); - } - break 'try1 - } - match tryResult1 { - catch ( fe: &FormatException) { - throw IllegalArgumentException::new(fe); - } 0 => break - } - - contents += check; - break; - } - 8 => - { - let tryResult1 = 0; - 'try1: loop { - { - if !UPCEANReader::check_standard_u_p_c_e_a_n_checksum(&contents) { - throw IllegalArgumentException::new("Contents do not pass checksum"); - } - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &FormatException) { - throw IllegalArgumentException::new("Illegal contents"); - } 0 => break - } - - break; - } - _ => - { - throw IllegalArgumentException::new(format!("Requested contents should be 7 or 8 digits long, but got {}", length)); - } - } - check_numeric(&contents); - let result: [bool; CODE_WIDTH] = [false; CODE_WIDTH]; - let mut pos: i32 = 0; - pos += append_pattern(&result, pos, UPCEANReader.START_END_PATTERN, true); - { - let mut i: i32 = 0; - while i <= 3 { - { - let digit: i32 = Character::digit(&contents.char_at(i), 10); - pos += append_pattern(&result, pos, UPCEANReader.L_PATTERNS[digit], false); - } - i += 1; - } - } - - pos += append_pattern(&result, pos, UPCEANReader.MIDDLE_PATTERN, false); - { - let mut i: i32 = 4; - while i <= 7 { - { - let digit: i32 = Character::digit(&contents.char_at(i), 10); - pos += append_pattern(&result, pos, UPCEANReader.L_PATTERNS[digit], true); - } - i += 1; - } - } - - append_pattern(&result, pos, UPCEANReader.START_END_PATTERN, true); - return result; - } -} - -// NEW FILE: e_a_n_manufacturer_org_support.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * Records EAN prefix to GS1 Member Organization, where the member organization - * correlates strongly with a country. This is an imperfect means of identifying - * a country of origin by EAN-13 barcode value. See - * - * http://en.wikipedia.org/wiki/List_of_GS1_country_codes. - * - * @author Sean Owen - */ -struct EANManufacturerOrgSupport { - - let ranges: List> = ArrayList<>::new(); - - let country_identifiers: List = ArrayList<>::new(); -} - -impl EANManufacturerOrgSupport { - - fn lookup_country_identifier(&self, product_code: &String) -> String { - self.init_if_needed(); - let prefix: i32 = Integer::parse_int(&product_code.substring(0, 3)); - let max: i32 = self.ranges.size(); - { - let mut i: i32 = 0; - while i < max { - { - let range: Vec = self.ranges.get(i); - let start: i32 = range[0]; - if prefix < start { - return null; - } - let end: i32 = if range.len() == 1 { start } else { range[1] }; - if prefix <= end { - return self.country_identifiers.get(i); - } - } - i += 1; - } - } - - return null; - } - - fn add(&self, range: &Vec, id: &String) { - self.ranges.add(&range); - self.country_identifiers.add(&id); - } - - fn init_if_needed(&self) { - if !self.ranges.is_empty() { - return; - } - self.add( : vec![i32; 2] = vec![0, 19, ] - , "US/CA"); - self.add( : vec![i32; 2] = vec![30, 39, ] - , "US"); - self.add( : vec![i32; 2] = vec![60, 139, ] - , "US/CA"); - self.add( : vec![i32; 2] = vec![300, 379, ] - , "FR"); - self.add( : vec![i32; 1] = vec![380, ] - , "BG"); - self.add( : vec![i32; 1] = vec![383, ] - , "SI"); - self.add( : vec![i32; 1] = vec![385, ] - , "HR"); - self.add( : vec![i32; 1] = vec![387, ] - , "BA"); - self.add( : vec![i32; 2] = vec![400, 440, ] - , "DE"); - self.add( : vec![i32; 2] = vec![450, 459, ] - , "JP"); - self.add( : vec![i32; 2] = vec![460, 469, ] - , "RU"); - self.add( : vec![i32; 1] = vec![471, ] - , "TW"); - self.add( : vec![i32; 1] = vec![474, ] - , "EE"); - self.add( : vec![i32; 1] = vec![475, ] - , "LV"); - self.add( : vec![i32; 1] = vec![476, ] - , "AZ"); - self.add( : vec![i32; 1] = vec![477, ] - , "LT"); - self.add( : vec![i32; 1] = vec![478, ] - , "UZ"); - self.add( : vec![i32; 1] = vec![479, ] - , "LK"); - self.add( : vec![i32; 1] = vec![480, ] - , "PH"); - self.add( : vec![i32; 1] = vec![481, ] - , "BY"); - self.add( : vec![i32; 1] = vec![482, ] - , "UA"); - self.add( : vec![i32; 1] = vec![484, ] - , "MD"); - self.add( : vec![i32; 1] = vec![485, ] - , "AM"); - self.add( : vec![i32; 1] = vec![486, ] - , "GE"); - self.add( : vec![i32; 1] = vec![487, ] - , "KZ"); - self.add( : vec![i32; 1] = vec![489, ] - , "HK"); - self.add( : vec![i32; 2] = vec![490, 499, ] - , "JP"); - self.add( : vec![i32; 2] = vec![500, 509, ] - , "GB"); - self.add( : vec![i32; 1] = vec![520, ] - , "GR"); - self.add( : vec![i32; 1] = vec![528, ] - , "LB"); - self.add( : vec![i32; 1] = vec![529, ] - , "CY"); - self.add( : vec![i32; 1] = vec![531, ] - , "MK"); - self.add( : vec![i32; 1] = vec![535, ] - , "MT"); - self.add( : vec![i32; 1] = vec![539, ] - , "IE"); - self.add( : vec![i32; 2] = vec![540, 549, ] - , "BE/LU"); - self.add( : vec![i32; 1] = vec![560, ] - , "PT"); - self.add( : vec![i32; 1] = vec![569, ] - , "IS"); - self.add( : vec![i32; 2] = vec![570, 579, ] - , "DK"); - self.add( : vec![i32; 1] = vec![590, ] - , "PL"); - self.add( : vec![i32; 1] = vec![594, ] - , "RO"); - self.add( : vec![i32; 1] = vec![599, ] - , "HU"); - self.add( : vec![i32; 2] = vec![600, 601, ] - , "ZA"); - self.add( : vec![i32; 1] = vec![603, ] - , "GH"); - self.add( : vec![i32; 1] = vec![608, ] - , "BH"); - self.add( : vec![i32; 1] = vec![609, ] - , "MU"); - self.add( : vec![i32; 1] = vec![611, ] - , "MA"); - self.add( : vec![i32; 1] = vec![613, ] - , "DZ"); - self.add( : vec![i32; 1] = vec![616, ] - , "KE"); - self.add( : vec![i32; 1] = vec![618, ] - , "CI"); - self.add( : vec![i32; 1] = vec![619, ] - , "TN"); - self.add( : vec![i32; 1] = vec![621, ] - , "SY"); - self.add( : vec![i32; 1] = vec![622, ] - , "EG"); - self.add( : vec![i32; 1] = vec![624, ] - , "LY"); - self.add( : vec![i32; 1] = vec![625, ] - , "JO"); - self.add( : vec![i32; 1] = vec![626, ] - , "IR"); - self.add( : vec![i32; 1] = vec![627, ] - , "KW"); - self.add( : vec![i32; 1] = vec![628, ] - , "SA"); - self.add( : vec![i32; 1] = vec![629, ] - , "AE"); - self.add( : vec![i32; 2] = vec![640, 649, ] - , "FI"); - self.add( : vec![i32; 2] = vec![690, 695, ] - , "CN"); - self.add( : vec![i32; 2] = vec![700, 709, ] - , "NO"); - self.add( : vec![i32; 1] = vec![729, ] - , "IL"); - self.add( : vec![i32; 2] = vec![730, 739, ] - , "SE"); - self.add( : vec![i32; 1] = vec![740, ] - , "GT"); - self.add( : vec![i32; 1] = vec![741, ] - , "SV"); - self.add( : vec![i32; 1] = vec![742, ] - , "HN"); - self.add( : vec![i32; 1] = vec![743, ] - , "NI"); - self.add( : vec![i32; 1] = vec![744, ] - , "CR"); - self.add( : vec![i32; 1] = vec![745, ] - , "PA"); - self.add( : vec![i32; 1] = vec![746, ] - , "DO"); - self.add( : vec![i32; 1] = vec![750, ] - , "MX"); - self.add( : vec![i32; 2] = vec![754, 755, ] - , "CA"); - self.add( : vec![i32; 1] = vec![759, ] - , "VE"); - self.add( : vec![i32; 2] = vec![760, 769, ] - , "CH"); - self.add( : vec![i32; 1] = vec![770, ] - , "CO"); - self.add( : vec![i32; 1] = vec![773, ] - , "UY"); - self.add( : vec![i32; 1] = vec![775, ] - , "PE"); - self.add( : vec![i32; 1] = vec![777, ] - , "BO"); - self.add( : vec![i32; 1] = vec![779, ] - , "AR"); - self.add( : vec![i32; 1] = vec![780, ] - , "CL"); - self.add( : vec![i32; 1] = vec![784, ] - , "PY"); - self.add( : vec![i32; 1] = vec![785, ] - , "PE"); - self.add( : vec![i32; 1] = vec![786, ] - , "EC"); - self.add( : vec![i32; 2] = vec![789, 790, ] - , "BR"); - self.add( : vec![i32; 2] = vec![800, 839, ] - , "IT"); - self.add( : vec![i32; 2] = vec![840, 849, ] - , "ES"); - self.add( : vec![i32; 1] = vec![850, ] - , "CU"); - self.add( : vec![i32; 1] = vec![858, ] - , "SK"); - self.add( : vec![i32; 1] = vec![859, ] - , "CZ"); - self.add( : vec![i32; 1] = vec![860, ] - , "YU"); - self.add( : vec![i32; 1] = vec![865, ] - , "MN"); - self.add( : vec![i32; 1] = vec![867, ] - , "KP"); - self.add( : vec![i32; 2] = vec![868, 869, ] - , "TR"); - self.add( : vec![i32; 2] = vec![870, 879, ] - , "NL"); - self.add( : vec![i32; 1] = vec![880, ] - , "KR"); - self.add( : vec![i32; 1] = vec![885, ] - , "TH"); - self.add( : vec![i32; 1] = vec![888, ] - , "SG"); - self.add( : vec![i32; 1] = vec![890, ] - , "IN"); - self.add( : vec![i32; 1] = vec![893, ] - , "VN"); - self.add( : vec![i32; 1] = vec![896, ] - , "PK"); - self.add( : vec![i32; 1] = vec![899, ] - , "ID"); - self.add( : vec![i32; 2] = vec![900, 919, ] - , "AT"); - self.add( : vec![i32; 2] = vec![930, 939, ] - , "AU"); - self.add( : vec![i32; 2] = vec![940, 949, ] - , "AZ"); - self.add( : vec![i32; 1] = vec![955, ] - , "MY"); - self.add( : vec![i32; 1] = vec![958, ] - , "MO"); - } -} - -// NEW FILE: i_t_f_reader.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

Implements decoding of the ITF format, or Interleaved Two of Five.

- * - *

This Reader will scan ITF barcodes of certain lengths only. - * At the moment it reads length 6, 8, 10, 12, 14, 16, 18, 20, 24, and 44 as these have appeared "in the wild". Not all - * lengths are scanned, especially shorter ones, to avoid false positives. This in turn is due to a lack of - * required checksum function.

- * - *

The checksum is optional and is not applied by this Reader. The consumer of the decoded - * value will have to apply a checksum if required.

- * - *

http://en.wikipedia.org/wiki/Interleaved_2_of_5 - * is a great reference for Interleaved 2 of 5 information.

- * - * @author kevin.osullivan@sita.aero, SITA Lab. - */ - - const MAX_AVG_VARIANCE: f32 = 0.38f; - - const MAX_INDIVIDUAL_VARIANCE: f32 = 0.5f; - -// Pixel width of a 3x wide line - const W: i32 = 3; - -// Pixel width of a 2x wide line - let w: i32 = 2; - -// Pixed width of a narrow line - const N: i32 = 1; - -/** Valid ITF lengths. Anything longer than the largest value is also allowed. */ - const DEFAULT_ALLOWED_LENGTHS: vec![Vec; 5] = vec![6, 8, 10, 12, 14, ] -; - -/** - * Start/end guard pattern. - * - * Note: The end pattern is reversed because the row is reversed before - * searching for the END_PATTERN - */ - const START_PATTERN: vec![Vec; 4] = vec![N, N, N, N, ] -; - - const END_PATTERN_REVERSED: vec![vec![Vec>; 3]; 2] = vec![// 2x -vec![N, N, w, ] -, // 3x -vec![N, N, W, ] -, ] -; - -// See ITFWriter.PATTERNS -/** - * Patterns of Wide / Narrow lines to indicate each digit - */ - const PATTERNS: vec![vec![Vec>; 5]; 20] = vec![// 0 -vec![N, N, w, w, N, ] -, // 1 -vec![w, N, N, N, w, ] -, // 2 -vec![N, w, N, N, w, ] -, // 3 -vec![w, w, N, N, N, ] -, // 4 -vec![N, N, w, N, w, ] -, // 5 -vec![w, N, w, N, N, ] -, // 6 -vec![N, w, w, N, N, ] -, // 7 -vec![N, N, N, w, w, ] -, // 8 -vec![w, N, N, w, N, ] -, // 9 -vec![N, w, N, w, N, ] -, // 0 -vec![N, N, W, W, N, ] -, // 1 -vec![W, N, N, N, W, ] -, // 2 -vec![N, W, N, N, W, ] -, // 3 -vec![W, W, N, N, N, ] -, // 4 -vec![N, N, W, N, W, ] -, // 5 -vec![W, N, W, N, N, ] -, // 6 -vec![N, W, W, N, N, ] -, // 7 -vec![N, N, N, W, W, ] -, // 8 -vec![W, N, N, W, N, ] -, // 9 -vec![N, W, N, W, N, ] -, ] -; -pub struct ITFReader { - super: OneDReader; - - // Stores the actual narrow line width of the image being decoded. - let narrow_line_width: i32 = -1; -} - -impl ITFReader { - - pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws FormatException, NotFoundException */Result> { - // Find out where the Middle section (payload) starts & ends - let start_range: Vec = self.decode_start(row); - let end_range: Vec = self.decode_end(row); - let result: StringBuilder = StringBuilder::new(20); - ::decode_middle(row, start_range[1], end_range[0], &result); - let result_string: String = result.to_string(); - let allowed_lengths: Vec = null; - if hints != null { - allowed_lengths = hints.get(DecodeHintType::ALLOWED_LENGTHS) as Vec; - } - if allowed_lengths == null { - allowed_lengths = DEFAULT_ALLOWED_LENGTHS; - } - // To avoid false positives with 2D barcodes (and other patterns), make - // an assumption that the decoded string must be a 'standard' length if it's short - let length: i32 = result_string.length(); - let length_o_k: bool = false; - let max_allowed_length: i32 = 0; - for let allowed_length: i32 in allowed_lengths { - if length == allowed_length { - length_o_k = true; - break; - } - if allowed_length > max_allowed_length { - max_allowed_length = allowed_length; - } - } - if !length_o_k && length > max_allowed_length { - length_o_k = true; - } - if !length_o_k { - throw FormatException::get_format_instance(); - } - let result_object: Result = Result::new(&result_string, // no natural byte representation for these barcodes - null, : vec![ResultPoint; 2] = vec![ResultPoint::new(start_range[1], row_number), ResultPoint::new(end_range[0], row_number), ] - , BarcodeFormat::ITF); - result_object.put_metadata(ResultMetadataType::SYMBOLOGY_IDENTIFIER, "]I0"); - return Ok(result_object); - } - - /** - * @param row row of black/white values to search - * @param payloadStart offset of start pattern - * @param resultString {@link StringBuilder} to append decoded chars to - * @throws NotFoundException if decoding could not complete successfully - */ - fn decode_middle( row: &BitArray, payload_start: i32, payload_end: i32, result_string: &StringBuilder) -> /* throws NotFoundException */Result> { - // Digits are interleaved in pairs - 5 black lines for one digit, and the - // 5 - // interleaved white lines for the second digit. - // Therefore, need to scan 10 lines and then - // split these into two arrays - let counter_digit_pair: [i32; 10] = [0; 10]; - let counter_black: [i32; 5] = [0; 5]; - let counter_white: [i32; 5] = [0; 5]; - while payload_start < payload_end { - // Get 10 runs of black/white. - record_pattern(row, payload_start, &counter_digit_pair); - // Split them into each array - { - let mut k: i32 = 0; - while k < 5 { - { - let two_k: i32 = 2 * k; - counter_black[k] = counter_digit_pair[two_k]; - counter_white[k] = counter_digit_pair[two_k + 1]; - } - k += 1; - } - } - - let best_match: i32 = ::decode_digit(&counter_black); - result_string.append(('0' + best_match) as char); - best_match = ::decode_digit(&counter_white); - result_string.append(('0' + best_match) as char); - for let counter_digit: i32 in counter_digit_pair { - payload_start += counter_digit; - } - } - } - - /** - * Identify where the start of the middle / payload section starts. - * - * @param row row of black/white values to search - * @return Array, containing index of start of 'start block' and end of - * 'start block' - */ - fn decode_start(&self, row: &BitArray) -> /* throws NotFoundException */Result, Rc> { - let end_start: i32 = ::skip_white_space(row); - let start_pattern: Vec = ::find_guard_pattern(row, end_start, &START_PATTERN); - // Determine the width of a narrow line in pixels. We can do this by - // getting the width of the start pattern and dividing by 4 because its - // made up of 4 narrow lines. - self.narrowLineWidth = (start_pattern[1] - start_pattern[0]) / 4; - self.validate_quiet_zone(row, start_pattern[0]); - return Ok(start_pattern); - } - - /** - * The start & end patterns must be pre/post fixed by a quiet zone. This - * zone must be at least 10 times the width of a narrow line. Scan back until - * we either get to the start of the barcode or match the necessary number of - * quiet zone pixels. - * - * Note: Its assumed the row is reversed when using this method to find - * quiet zone after the end pattern. - * - * ref: http://www.barcode-1.net/i25code.html - * - * @param row bit array representing the scanned barcode. - * @param startPattern index into row of the start or end pattern. - * @throws NotFoundException if the quiet zone cannot be found - */ - fn validate_quiet_zone(&self, row: &BitArray, start_pattern: i32) -> /* throws NotFoundException */Result> { - // expect to find this many pixels of quiet zone - let quiet_count: i32 = self.narrowLineWidth * 10; - // if there are not so many pixel at all let's try as many as possible - quiet_count = Math::min(quiet_count, start_pattern); - { - let mut i: i32 = start_pattern - 1; - while quiet_count > 0 && i >= 0 { - { - if row.get(i) { - break; - } - quiet_count -= 1; - } - i -= 1; - } - } - - if quiet_count != 0 { - // Unable to find the necessary number of quiet zone pixels. - throw NotFoundException::get_not_found_instance(); - } - } - - /** - * Skip all whitespace until we get to the first black line. - * - * @param row row of black/white values to search - * @return index of the first black line. - * @throws NotFoundException Throws exception if no black lines are found in the row - */ - fn skip_white_space( row: &BitArray) -> /* throws NotFoundException */Result> { - let width: i32 = row.get_size(); - let end_start: i32 = row.get_next_set(0); - if end_start == width { - throw NotFoundException::get_not_found_instance(); - } - return Ok(end_start); - } - - /** - * Identify where the end of the middle / payload section ends. - * - * @param row row of black/white values to search - * @return Array, containing index of start of 'end block' and end of 'end - * block' - */ - fn decode_end(&self, row: &BitArray) -> /* throws NotFoundException */Result, Rc> { - // For convenience, reverse the row and then - // search from 'the start' for the end block - row.reverse(); - let tryResult1 = 0; - 'try1: loop { - { - let end_start: i32 = ::skip_white_space(row); - let end_pattern: Vec; - let tryResult2 = 0; - 'try2: loop { - { - end_pattern = ::find_guard_pattern(row, end_start, END_PATTERN_REVERSED[0]); - } - break 'try2 - } - match tryResult2 { - catch ( nfe: &NotFoundException) { - end_pattern = ::find_guard_pattern(row, end_start, END_PATTERN_REVERSED[1]); - } 0 => break - } - - // The start & end patterns must be pre/post fixed by a quiet zone. This - // zone must be at least 10 times the width of a narrow line. - // ref: http://www.barcode-1.net/i25code.html - self.validate_quiet_zone(row, end_pattern[0]); - // Now recalculate the indices of where the 'endblock' starts & stops to - // accommodate - // the reversed nature of the search - let temp: i32 = end_pattern[0]; - end_pattern[0] = row.get_size() - end_pattern[1]; - end_pattern[1] = row.get_size() - temp; - return Ok(end_pattern); - } - break 'try1 - } - match tryResult1 { - 0 => break - } - finally { - // Put the row back the right way. - row.reverse(); - } - } - - /** - * @param row row of black/white values to search - * @param rowOffset position to start search - * @param pattern pattern of counts of number of black and white pixels that are - * being searched for as a pattern - * @return start/end horizontal offset of guard pattern, as an array of two - * ints - * @throws NotFoundException if pattern is not found - */ - fn find_guard_pattern( row: &BitArray, row_offset: i32, pattern: &Vec) -> /* throws NotFoundException */Result, Rc> { - let pattern_length: i32 = pattern.len(); - let mut counters: [i32; pattern_length] = [0; pattern_length]; - let width: i32 = row.get_size(); - let is_white: bool = false; - let counter_position: i32 = 0; - let pattern_start: i32 = row_offset; - { - let mut x: i32 = row_offset; - while x < width { - { - if row.get(x) != is_white { - counters[counter_position] += 1; - } else { - if counter_position == pattern_length - 1 { - if pattern_match_variance(&counters, &pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE { - return Ok( : vec![i32; 2] = vec![pattern_start, x, ] - ); - } - pattern_start += counters[0] + counters[1]; - System::arraycopy(&counters, 2, &counters, 0, counter_position - 1); - counters[counter_position - 1] = 0; - counters[counter_position] = 0; - counter_position -= 1; - } else { - counter_position += 1; - } - counters[counter_position] = 1; - is_white = !is_white; - } - } - x += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - /** - * Attempts to decode a sequence of ITF black/white lines into single - * digit. - * - * @param counters the counts of runs of observed black/white/black/... values - * @return The decoded digit - * @throws NotFoundException if digit cannot be decoded - */ - fn decode_digit( counters: &Vec) -> /* throws NotFoundException */Result> { - // worst variance we'll accept - let best_variance: f32 = MAX_AVG_VARIANCE; - let best_match: i32 = -1; - let max: i32 = PATTERNS.len(); - { - let mut i: i32 = 0; - while i < max { - { - let pattern: Vec = PATTERNS[i]; - let variance: f32 = pattern_match_variance(&counters, &pattern, MAX_INDIVIDUAL_VARIANCE); - if variance < best_variance { - best_variance = variance; - best_match = i; - } else if variance == best_variance { - // if we find a second 'best match' with the same variance, we can not reliably report to have a suitable match - best_match = -1; - } - } - i += 1; - } - } - - if best_match >= 0 { - return Ok(best_match % 10); - } else { - throw NotFoundException::get_not_found_instance(); - } - } -} - -// NEW FILE: i_t_f_writer.rs -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * This object renders a ITF code as a {@link BitMatrix}. - * - * @author erik.barbara@gmail.com (Erik Barbara) - */ - - const START_PATTERN: vec![Vec; 4] = vec![1, 1, 1, 1, ] -; - - const END_PATTERN: vec![Vec; 3] = vec![3, 1, 1, ] -; - -// Pixel width of a 3x wide line - const W: i32 = 3; - -// Pixed width of a narrow line - const N: i32 = 1; - -// See ITFReader.PATTERNS - const PATTERNS: vec![vec![Vec>; 5]; 10] = vec![// 0 -vec![N, N, W, W, N, ] -, // 1 -vec![W, N, N, N, W, ] -, // 2 -vec![N, W, N, N, W, ] -, // 3 -vec![W, W, N, N, N, ] -, // 4 -vec![N, N, W, N, W, ] -, // 5 -vec![W, N, W, N, N, ] -, // 6 -vec![N, W, W, N, N, ] -, // 7 -vec![N, N, N, W, W, ] -, // 8 -vec![W, N, N, W, N, ] -, // 9 -vec![N, W, N, W, N, ] -, ] -; -pub struct ITFWriter { - super: OneDimensionalCodeWriter; -} - -impl ITFWriter { - - pub fn get_supported_write_formats(&self) -> Collection { - return Collections::singleton(BarcodeFormat::ITF); - } - - pub fn encode(&self, contents: &String) -> Vec { - let length: i32 = contents.length(); - if length % 2 != 0 { - throw IllegalArgumentException::new("The length of the input should be even"); - } - if length > 80 { - throw IllegalArgumentException::new(format!("Requested contents should be less than 80 digits long, but got {}", length)); - } - check_numeric(&contents); - let result: [bool; 9 + 9 * length] = [false; 9 + 9 * length]; - let mut pos: i32 = append_pattern(&result, 0, &START_PATTERN, true); - { - let mut i: i32 = 0; - while i < length { - { - let one: i32 = Character::digit(&contents.char_at(i), 10); - let two: i32 = Character::digit(&contents.char_at(i + 1), 10); - let mut encoding: [i32; 10] = [0; 10]; - { - let mut j: i32 = 0; - while j < 5 { - { - encoding[2 * j] = PATTERNS[one][j]; - encoding[2 * j + 1] = PATTERNS[two][j]; - } - j += 1; - } - } - - pos += append_pattern(&result, pos, &encoding, true); - } - i += 2; - } - } - - append_pattern(&result, pos, &END_PATTERN, true); - return result; - } -} - -// NEW FILE: multi_format_one_d_reader.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - */ - - const EMPTY_ONED_ARRAY: [Option; 0] = [None; 0]; -pub struct MultiFormatOneDReader { - super: OneDReader; - - let readers: Vec; -} - -impl MultiFormatOneDReader { - - pub fn new( hints: &HashMap) -> MultiFormatOneDReader { - let possible_formats: Collection = if hints == null { null } else { hints.get(DecodeHintType::POSSIBLE_FORMATS) as Collection }; - let use_code39_check_digit: bool = hints != null && hints.get(DecodeHintType::ASSUME_CODE_39_CHECK_DIGIT) != null; - let mut readers: Collection = ArrayList<>::new(); - if possible_formats != null { - if possible_formats.contains(BarcodeFormat::EAN_13) || possible_formats.contains(BarcodeFormat::UPC_A) || possible_formats.contains(BarcodeFormat::EAN_8) || possible_formats.contains(BarcodeFormat::UPC_E) { - readers.add(MultiFormatUPCEANReader::new(&hints)); - } - if possible_formats.contains(BarcodeFormat::CODE_39) { - readers.add(Code39Reader::new(use_code39_check_digit)); - } - if possible_formats.contains(BarcodeFormat::CODE_93) { - readers.add(Code93Reader::new()); - } - if possible_formats.contains(BarcodeFormat::CODE_128) { - readers.add(Code128Reader::new()); - } - if possible_formats.contains(BarcodeFormat::ITF) { - readers.add(ITFReader::new()); - } - if possible_formats.contains(BarcodeFormat::CODABAR) { - readers.add(CodaBarReader::new()); - } - if possible_formats.contains(BarcodeFormat::RSS_14) { - readers.add(RSS14Reader::new()); - } - if possible_formats.contains(BarcodeFormat::RSS_EXPANDED) { - readers.add(RSSExpandedReader::new()); - } - } - if readers.is_empty() { - readers.add(MultiFormatUPCEANReader::new(&hints)); - readers.add(Code39Reader::new()); - readers.add(CodaBarReader::new()); - readers.add(Code93Reader::new()); - readers.add(Code128Reader::new()); - readers.add(ITFReader::new()); - readers.add(RSS14Reader::new()); - readers.add(RSSExpandedReader::new()); - } - let .readers = readers.to_array(EMPTY_ONED_ARRAY); - } - - pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException */Result> { - for let reader: OneDReader in self.readers { - let tryResult1 = 0; - 'try1: loop { - { - return Ok(reader.decode_row(row_number, row, &hints)); - } - break 'try1 - } - match tryResult1 { - catch ( re: &ReaderException) { - } 0 => break - } - - } - throw NotFoundException::get_not_found_instance(); - } - - pub fn reset(&self) { - for let reader: Reader in self.readers { - reader.reset(); - } - } -} - -// NEW FILE: multi_format_u_p_c_e_a_n_reader.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

A reader that can read all available UPC/EAN formats. If a caller wants to try to - * read all such formats, it is most efficient to use this implementation rather than invoke - * individual readers.

- * - * @author Sean Owen - */ - - const EMPTY_READER_ARRAY: [Option; 0] = [None; 0]; -pub struct MultiFormatUPCEANReader { - super: OneDReader; - - let readers: Vec; -} - -impl MultiFormatUPCEANReader { - - pub fn new( hints: &Map) -> MultiFormatUPCEANReader { - let possible_formats: Collection = if hints == null { null } else { hints.get(DecodeHintType::POSSIBLE_FORMATS) as Collection }; - let mut readers: Collection = ArrayList<>::new(); - if possible_formats != null { - if possible_formats.contains(BarcodeFormat::EAN_13) { - readers.add(EAN13Reader::new()); - } else if possible_formats.contains(BarcodeFormat::UPC_A) { - readers.add(UPCAReader::new()); - } - if possible_formats.contains(BarcodeFormat::EAN_8) { - readers.add(EAN8Reader::new()); - } - if possible_formats.contains(BarcodeFormat::UPC_E) { - readers.add(UPCEReader::new()); - } - } - if readers.is_empty() { - readers.add(EAN13Reader::new()); - // UPC-A is covered by EAN-13 - readers.add(EAN8Reader::new()); - readers.add(UPCEReader::new()); - } - let .readers = readers.to_array(EMPTY_READER_ARRAY); - } - - pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException */Result> { - // Compute this location once and reuse it on multiple implementations - let start_guard_pattern: Vec = UPCEANReader::find_start_guard_pattern(row); - for let reader: UPCEANReader in self.readers { - let tryResult1 = 0; - 'try1: loop { - { - let result: Result = reader.decode_row(row_number, row, &start_guard_pattern, &hints); - // Special case: a 12-digit code encoded in UPC-A is identical to a "0" - // followed by those 12 digits encoded as EAN-13. Each will recognize such a code, - // UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0". - // Individually these are correct and their readers will both read such a code - // and correctly call it EAN-13, or UPC-A, respectively. - // - // In this case, if we've been looking for both types, we'd like to call it - // a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read - // UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A - // result if appropriate. - // - // But, don't return UPC-A if UPC-A was not a requested format! - let ean13_may_be_u_p_c_a: bool = result.get_barcode_format() == BarcodeFormat::EAN_13 && result.get_text().char_at(0) == '0'; - let possible_formats: Collection = if hints == null { null } else { hints.get(DecodeHintType::POSSIBLE_FORMATS) as Collection }; - let can_return_u_p_c_a: bool = possible_formats == null || possible_formats.contains(BarcodeFormat::UPC_A); - if ean13_may_be_u_p_c_a && can_return_u_p_c_a { - // Transfer the metadata across - let result_u_p_c_a: Result = Result::new(&result.get_text().substring(1), &result.get_raw_bytes(), &result.get_result_points(), BarcodeFormat::UPC_A); - result_u_p_c_a.put_all_metadata(&result.get_result_metadata()); - return Ok(result_u_p_c_a); - } - return Ok(result); - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &ReaderException) { - } 0 => break - } - - } - throw NotFoundException::get_not_found_instance(); - } - - pub fn reset(&self) { - for let reader: Reader in self.readers { - reader.reset(); - } - } -} - -// NEW FILE: one_d_reader.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * Encapsulates functionality and implementation that is common to all families - * of one-dimensional barcodes. - * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - */ -#[derive(Reader)] -pub struct OneDReader { -} - -impl OneDReader { - - pub fn decode(&self, image: &BinaryBitmap) -> /* throws NotFoundException, FormatException */Result> { - return Ok(self.decode(image, null)); - } - - // Note that we don't try rotation without the try harder flag, even if rotation was supported. - pub fn decode(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException, FormatException */Result> { - let tryResult1 = 0; - 'try1: loop { - { - return Ok(self.do_decode(image, &hints)); - } - break 'try1 - } - match tryResult1 { - catch ( nfe: &NotFoundException) { - let try_harder: bool = hints != null && hints.contains_key(DecodeHintType::TRY_HARDER); - if try_harder && image.is_rotate_supported() { - let rotated_image: BinaryBitmap = image.rotate_counter_clockwise(); - let result: Result = self.do_decode(rotated_image, &hints); - let metadata: Map = result.get_result_metadata(); - let mut orientation: i32 = 270; - if metadata != null && metadata.contains_key(ResultMetadataType::ORIENTATION) { - orientation = (orientation + metadata.get(ResultMetadataType::ORIENTATION) as Integer) % 360; - } - result.put_metadata(ResultMetadataType::ORIENTATION, orientation); - let mut points: Vec = result.get_result_points(); - if points != null { - let height: i32 = rotated_image.get_height(); - { - let mut i: i32 = 0; - while i < points.len() { - { - points[i] = ResultPoint::new(height - points[i].get_y() - 1, &points[i].get_x()); - } - i += 1; - } - } - - } - return Ok(result); - } else { - throw nfe; - } - } 0 => break - } - - } - - pub fn reset(&self) { - // do nothing - } - - /** - * We're going to examine rows from the middle outward, searching alternately above and below the - * middle, and farther out each time. rowStep is the number of rows between each successive - * attempt above and below the middle. So we'd scan row middle, then middle - rowStep, then - * middle + rowStep, then middle - (2 * rowStep), etc. - * rowStep is bigger as the image is taller, but is always at least 1. We've somewhat arbitrarily - * decided that moving up and down by about 1/16 of the image is pretty good; we try more of the - * image if "trying harder". - * - * @param image The image to decode - * @param hints Any hints that were requested - * @return The contents of the decoded barcode - * @throws NotFoundException Any spontaneous errors which occur - */ - fn do_decode(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException */Result> { - let width: i32 = image.get_width(); - let height: i32 = image.get_height(); - let mut row: BitArray = BitArray::new(width); - let try_harder: bool = hints != null && hints.contains_key(DecodeHintType::TRY_HARDER); - let row_step: i32 = Math::max(1, height >> ( if try_harder { 8 } else { 5 })); - let max_lines: i32; - if try_harder { - // Look at the whole image, not just the center - max_lines = height; - } else { - // 15 rows spaced 1/32 apart is roughly the middle half of the image - max_lines = 15; - } - let middle: i32 = height / 2; - { - let mut x: i32 = 0; - while x < max_lines { - { - // Scanning from the middle out. Determine which row we're looking at next: - let row_steps_above_or_below: i32 = (x + 1) / 2; - // i.e. is x even? - let is_above: bool = (x & 0x01) == 0; - let row_number: i32 = middle + row_step * ( if is_above { row_steps_above_or_below } else { -row_steps_above_or_below }); - if row_number < 0 || row_number >= height { - // Oops, if we run off the top or bottom, stop - break; - } - // Estimate black point for this row and load it: - let tryResult1 = 0; - 'try1: loop { - { - row = image.get_black_row(row_number, row); - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &NotFoundException) { - continue; - } 0 => break - } - - // handle decoding upside down barcodes. - { - let mut attempt: i32 = 0; - while attempt < 2 { - { - if attempt == 1 { - // trying again? - // reverse the row and continue - row.reverse(); - // that start on the center line. - if hints != null && hints.contains_key(DecodeHintType::NEED_RESULT_POINT_CALLBACK) { - let new_hints: Map = EnumMap<>::new(DecodeHintType.class); - new_hints.put_all(&hints); - new_hints.remove(DecodeHintType::NEED_RESULT_POINT_CALLBACK); - hints = new_hints; - } - } - let tryResult1 = 0; - 'try1: loop { - { - // Look for a barcode - let result: Result = self.decode_row(row_number, row, &hints); - // We found our barcode - if attempt == 1 { - // But it was upside down, so note that - result.put_metadata(ResultMetadataType::ORIENTATION, 180); - // And remember to flip the result points horizontally. - let mut points: Vec = result.get_result_points(); - if points != null { - points[0] = ResultPoint::new(width - points[0].get_x() - 1, &points[0].get_y()); - points[1] = ResultPoint::new(width - points[1].get_x() - 1, &points[1].get_y()); - } - } - return Ok(result); - } - break 'try1 - } - match tryResult1 { - catch ( re: &ReaderException) { - } 0 => break - } - - } - attempt += 1; - } - } - - } - x += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - /** - * Records the size of successive runs of white and black pixels in a row, starting at a given point. - * The values are recorded in the given array, and the number of runs recorded is equal to the size - * of the array. If the row starts on a white pixel at the given start point, then the first count - * recorded is the run of white pixels starting from that point; likewise it is the count of a run - * of black pixels if the row begin on a black pixels at that point. - * - * @param row row to count from - * @param start offset into row to start at - * @param counters array into which to record counts - * @throws NotFoundException if counters cannot be filled entirely from row before running out - * of pixels - */ - pub fn record_pattern( row: &BitArray, start: i32, counters: &Vec) -> /* throws NotFoundException */Result> { - let num_counters: i32 = counters.len(); - Arrays::fill(&counters, 0, num_counters, 0); - let end: i32 = row.get_size(); - if start >= end { - throw NotFoundException::get_not_found_instance(); - } - let is_white: bool = !row.get(start); - let counter_position: i32 = 0; - let mut i: i32 = start; - while i < end { - if row.get(i) != is_white { - counters[counter_position] += 1; - } else { - if counter_position += 1 == num_counters { - break; - } else { - counters[counter_position] = 1; - is_white = !is_white; - } - } - i += 1; - } - // the last counter but ran off the side of the image, OK. Otherwise, a problem. - if !(counter_position == num_counters || (counter_position == num_counters - 1 && i == end)) { - throw NotFoundException::get_not_found_instance(); - } - } - - pub fn record_pattern_in_reverse( row: &BitArray, start: i32, counters: &Vec) -> /* throws NotFoundException */Result> { - // This could be more efficient I guess - let num_transitions_left: i32 = counters.len(); - let mut last: bool = row.get(start); - while start > 0 && num_transitions_left >= 0 { - if row.get(start -= 1) != last { - num_transitions_left -= 1; - last = !last; - } - } - if num_transitions_left >= 0 { - throw NotFoundException::get_not_found_instance(); - } - ::record_pattern(row, start + 1, &counters); - } - - /** - * Determines how closely a set of observed counts of runs of black/white values matches a given - * target pattern. This is reported as the ratio of the total variance from the expected pattern - * proportions across all pattern elements, to the length of the pattern. - * - * @param counters observed counters - * @param pattern expected pattern - * @param maxIndividualVariance The most any counter can differ before we give up - * @return ratio of total variance between counters and pattern compared to total pattern size - */ - pub fn pattern_match_variance( counters: &Vec, pattern: &Vec, max_individual_variance: f32) -> f32 { - let num_counters: i32 = counters.len(); - let mut total: i32 = 0; - let pattern_length: i32 = 0; - { - let mut i: i32 = 0; - while i < num_counters { - { - total += counters[i]; - pattern_length += pattern[i]; - } - i += 1; - } - } - - if total < pattern_length { - // to reliably match, so fail: - return Float::POSITIVE_INFINITY; - } - let unit_bar_width: f32 = total as f32 / pattern_length; - max_individual_variance *= unit_bar_width; - let total_variance: f32 = 0.0f; - { - let mut x: i32 = 0; - while x < num_counters { - { - let counter: i32 = counters[x]; - let scaled_pattern: f32 = pattern[x] * unit_bar_width; - let variance: f32 = if counter > scaled_pattern { counter - scaled_pattern } else { scaled_pattern - counter }; - if variance > max_individual_variance { - return Float::POSITIVE_INFINITY; - } - total_variance += variance; - } - x += 1; - } - } - - return total_variance / total; - } - - /** - *

Attempts to decode a one-dimensional barcode format given a single row of - * an image.

- * - * @param rowNumber row number from top of the row - * @param row the black/white pixel data of the row - * @param hints decode hints - * @return {@link Result} containing encoded string and start/end of barcode - * @throws NotFoundException if no potential barcode is found - * @throws ChecksumException if a potential barcode is found but does not pass its checksum - * @throws FormatException if a potential barcode is found but format is invalid - */ - pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException, ChecksumException, FormatException */Result> ; -} - -// NEW FILE: one_dimensional_code_writer.rs -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

Encapsulates functionality and implementation that is common to one-dimensional barcodes.

- * - * @author dsbnatut@gmail.com (Kazuki Nishiura) - */ - - const NUMERIC: Pattern = Pattern::compile("[0-9]+"); -#[derive(Writer)] -pub struct OneDimensionalCodeWriter { -} - -impl OneDimensionalCodeWriter { - - /** - * Encode the contents to boolean array expression of one-dimensional barcode. - * Start code and end code should be included in result, and side margins should not be included. - * - * @param contents barcode contents to encode - * @return a {@code boolean[]} of horizontal pixels (false = white, true = black) - */ - pub fn encode(&self, contents: &String) -> Vec ; - - /** - * Can be overwritten if the encode requires to read the hints map. Otherwise it defaults to {@code encode}. - * @param contents barcode contents to encode - * @param hints encoding hints - * @return a {@code boolean[]} of horizontal pixels (false = white, true = black) - */ - pub fn encode(&self, contents: &String, hints: &Map) -> Vec { - return self.encode(&contents); - } - - pub fn encode(&self, contents: &String, format: &BarcodeFormat, width: i32, height: i32) -> BitMatrix { - return self.encode(&contents, format, width, height, null); - } - - /** - * Encode the contents following specified format. - * {@code width} and {@code height} are required size. This method may return bigger size - * {@code BitMatrix} when specified size is too small. The user can set both {@code width} and - * {@code height} to zero to get minimum size barcode. If negative value is set to {@code width} - * or {@code height}, {@code IllegalArgumentException} is thrown. - */ - pub fn encode(&self, contents: &String, format: &BarcodeFormat, width: i32, height: i32, hints: &Map) -> BitMatrix { - if contents.is_empty() { - throw IllegalArgumentException::new("Found empty contents"); - } - if width < 0 || height < 0 { - throw IllegalArgumentException::new(format!("Negative size is not allowed. Input: {}x{}", width, height)); - } - let supported_formats: Collection = self.get_supported_write_formats(); - if supported_formats != null && !supported_formats.contains(format) { - throw IllegalArgumentException::new(format!("Can only encode {}, but got {}", supported_formats, format)); - } - let sides_margin: i32 = self.get_default_margin(); - if hints != null && hints.contains_key(EncodeHintType::MARGIN) { - sides_margin = Integer::parse_int(&hints.get(EncodeHintType::MARGIN).to_string()); - } - let code: Vec = self.encode(&contents, &hints); - return ::render_result(&code, width, height, sides_margin); - } - - pub fn get_supported_write_formats(&self) -> Collection { - return null; - } - - /** - * @return a byte array of horizontal pixels (0 = white, 1 = black) - */ - fn render_result( code: &Vec, width: i32, height: i32, sides_margin: i32) -> BitMatrix { - let input_width: i32 = code.len(); - // Add quiet zone on both sides. - let full_width: i32 = input_width + sides_margin; - let output_width: i32 = Math::max(width, full_width); - let output_height: i32 = Math::max(1, height); - let multiple: i32 = output_width / full_width; - let left_padding: i32 = (output_width - (input_width * multiple)) / 2; - let output: BitMatrix = BitMatrix::new(output_width, output_height); - { - let input_x: i32 = 0, let output_x: i32 = left_padding; - while input_x < input_width { - { - if code[input_x] { - output.set_region(output_x, 0, multiple, output_height); - } - } - input_x += 1; - output_x += multiple; - } - } - - return output; - } - - /** - * @param contents string to check for numeric characters - * @throws IllegalArgumentException if input contains characters other than digits 0-9. - */ - pub fn check_numeric( contents: &String) { - if !NUMERIC::matcher(&contents)::matches() { - throw IllegalArgumentException::new("Input should only contain digits 0-9"); - } - } - - /** - * @param target encode black/white pattern into this array - * @param pos position to start encoding at in {@code target} - * @param pattern lengths of black/white runs to encode - * @param startColor starting color - false for white, true for black - * @return the number of elements added to target. - */ - pub fn append_pattern( target: &Vec, pos: i32, pattern: &Vec, start_color: bool) -> i32 { - let mut color: bool = start_color; - let num_added: i32 = 0; - for let len: i32 in pattern { - { - let mut j: i32 = 0; - while j < len { - { - target[pos += 1 !!!check!!! post increment] = color; - } - j += 1; - } - } - - num_added += len; - // flip color after each segment - color = !color; - } - return num_added; - } - - pub fn get_default_margin(&self) -> i32 { - // This seems like a decent idea for a default for all formats. - return 10; - } -} - -// NEW FILE: u_p_c_a_reader.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

Implements decoding of the UPC-A format.

- * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - */ -pub struct UPCAReader { - super: UPCEANReader; - - let ean13_reader: UPCEANReader = EAN13Reader::new(); -} - -impl UPCAReader { - - pub fn decode_row(&self, row_number: i32, row: &BitArray, start_guard_range: &Vec, hints: &Map) -> /* throws NotFoundException, FormatException, ChecksumException */Result> { - return Ok(::maybe_return_result(&self.ean13_reader.decode_row(row_number, row, &start_guard_range, &hints))); - } - - pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException, FormatException, ChecksumException */Result> { - return Ok(::maybe_return_result(&self.ean13_reader.decode_row(row_number, row, &hints))); - } - - pub fn decode(&self, image: &BinaryBitmap) -> /* throws NotFoundException, FormatException */Result> { - return Ok(::maybe_return_result(&self.ean13_reader.decode(image))); - } - - pub fn decode(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException, FormatException */Result> { - return Ok(::maybe_return_result(&self.ean13_reader.decode(image, &hints))); - } - - fn get_barcode_format(&self) -> BarcodeFormat { - return BarcodeFormat::UPC_A; - } - - pub fn decode_middle(&self, row: &BitArray, start_range: &Vec, result_string: &StringBuilder) -> /* throws NotFoundException */Result> { - return Ok(self.ean13_reader.decode_middle(row, &start_range, &result_string)); - } - - fn maybe_return_result( result: &Result) -> /* throws FormatException */Result> { - let text: String = result.get_text(); - if text.char_at(0) == '0' { - let upca_result: Result = Result::new(&text.substring(1), null, &result.get_result_points(), BarcodeFormat::UPC_A); - if result.get_result_metadata() != null { - upca_result.put_all_metadata(&result.get_result_metadata()); - } - return Ok(upca_result); - } else { - throw FormatException::get_format_instance(); - } - } -} - -// NEW FILE: u_p_c_a_writer.rs -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * This object renders a UPC-A code as a {@link BitMatrix}. - * - * @author qwandor@google.com (Andrew Walbran) - */ -#[derive(Writer)] -pub struct UPCAWriter { - - let sub_writer: EAN13Writer = EAN13Writer::new(); -} - -impl UPCAWriter { - - pub fn encode(&self, contents: &String, format: &BarcodeFormat, width: i32, height: i32) -> BitMatrix { - return self.encode(&contents, format, width, height, null); - } - - pub fn encode(&self, contents: &String, format: &BarcodeFormat, width: i32, height: i32, hints: &Map) -> BitMatrix { - if format != BarcodeFormat::UPC_A { - throw IllegalArgumentException::new(format!("Can only encode UPC-A, but got {}", format)); - } - // Transform a UPC-A code into the equivalent EAN-13 code and write it that way - return self.sub_writer.encode(format!("0{}", contents), BarcodeFormat::EAN_13, width, height, &hints); - } -} - -// NEW FILE: u_p_c_e_a_n_extension2_support.rs -/* - * Copyright (C) 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * @see UPCEANExtension5Support - */ -struct UPCEANExtension2Support { - - let decode_middle_counters: [i32; 4] = [0; 4]; - - let decode_row_string_buffer: StringBuilder = StringBuilder::new(); -} - -impl UPCEANExtension2Support { - - fn decode_row(&self, row_number: i32, row: &BitArray, extension_start_range: &Vec) -> /* throws NotFoundException */Result> { - let result: StringBuilder = self.decode_row_string_buffer; - result.set_length(0); - let end: i32 = self.decode_middle(row, &extension_start_range, &result); - let result_string: String = result.to_string(); - let extension_data: Map = ::parse_extension_string(&result_string); - let extension_result: Result = Result::new(&result_string, null, : vec![ResultPoint; 2] = vec![ResultPoint::new((extension_start_range[0] + extension_start_range[1]) / 2.0f, row_number), ResultPoint::new(end, row_number), ] - , BarcodeFormat::UPC_EAN_EXTENSION); - if extension_data != null { - extension_result.put_all_metadata(&extension_data); - } - return Ok(extension_result); - } - - fn decode_middle(&self, row: &BitArray, start_range: &Vec, result_string: &StringBuilder) -> /* throws NotFoundException */Result> { - let mut counters: Vec = self.decode_middle_counters; - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - let end: i32 = row.get_size(); - let row_offset: i32 = start_range[1]; - let check_parity: i32 = 0; - { - let mut x: i32 = 0; - while x < 2 && row_offset < end { - { - let best_match: i32 = UPCEANReader::decode_digit(row, &counters, row_offset, UPCEANReader.L_AND_G_PATTERNS); - result_string.append(('0' + best_match % 10) as char); - for let counter: i32 in counters { - row_offset += counter; - } - if best_match >= 10 { - check_parity |= 1 << (1 - x); - } - if x != 1 { - // Read off separator if not last - row_offset = row.get_next_set(row_offset); - row_offset = row.get_next_unset(row_offset); - } - } - x += 1; - } - } - - if result_string.length() != 2 { - throw NotFoundException::get_not_found_instance(); - } - if Integer::parse_int(&result_string.to_string()) % 4 != check_parity { - throw NotFoundException::get_not_found_instance(); - } - return Ok(row_offset); - } - - /** - * @param raw raw content of extension - * @return formatted interpretation of raw content as a {@link Map} mapping - * one {@link ResultMetadataType} to appropriate value, or {@code null} if not known - */ - fn parse_extension_string( raw: &String) -> Map { - if raw.length() != 2 { - return null; - } - let result: Map = EnumMap<>::new(ResultMetadataType.class); - result.put(ResultMetadataType::ISSUE_NUMBER, &Integer::value_of(&raw)); - return result; - } -} - -// NEW FILE: u_p_c_e_a_n_extension5_support.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * @see UPCEANExtension2Support - */ - - const CHECK_DIGIT_ENCODINGS: vec![Vec; 10] = vec![0x18, 0x14, 0x12, 0x11, 0x0C, 0x06, 0x03, 0x0A, 0x09, 0x05, ] -; -struct UPCEANExtension5Support { - - let decode_middle_counters: [i32; 4] = [0; 4]; - - let decode_row_string_buffer: StringBuilder = StringBuilder::new(); -} - -impl UPCEANExtension5Support { - - fn decode_row(&self, row_number: i32, row: &BitArray, extension_start_range: &Vec) -> /* throws NotFoundException */Result> { - let result: StringBuilder = self.decode_row_string_buffer; - result.set_length(0); - let end: i32 = self.decode_middle(row, &extension_start_range, &result); - let result_string: String = result.to_string(); - let extension_data: Map = ::parse_extension_string(&result_string); - let extension_result: Result = Result::new(&result_string, null, : vec![ResultPoint; 2] = vec![ResultPoint::new((extension_start_range[0] + extension_start_range[1]) / 2.0f, row_number), ResultPoint::new(end, row_number), ] - , BarcodeFormat::UPC_EAN_EXTENSION); - if extension_data != null { - extension_result.put_all_metadata(&extension_data); - } - return Ok(extension_result); - } - - fn decode_middle(&self, row: &BitArray, start_range: &Vec, result_string: &StringBuilder) -> /* throws NotFoundException */Result> { - let mut counters: Vec = self.decode_middle_counters; - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - let end: i32 = row.get_size(); - let row_offset: i32 = start_range[1]; - let lg_pattern_found: i32 = 0; - { - let mut x: i32 = 0; - while x < 5 && row_offset < end { - { - let best_match: i32 = UPCEANReader::decode_digit(row, &counters, row_offset, UPCEANReader.L_AND_G_PATTERNS); - result_string.append(('0' + best_match % 10) as char); - for let counter: i32 in counters { - row_offset += counter; - } - if best_match >= 10 { - lg_pattern_found |= 1 << (4 - x); - } - if x != 4 { - // Read off separator if not last - row_offset = row.get_next_set(row_offset); - row_offset = row.get_next_unset(row_offset); - } - } - x += 1; - } - } - - if result_string.length() != 5 { - throw NotFoundException::get_not_found_instance(); - } - let check_digit: i32 = ::determine_check_digit(lg_pattern_found); - if ::extension_checksum(&result_string.to_string()) != check_digit { - throw NotFoundException::get_not_found_instance(); - } - return Ok(row_offset); - } - - fn extension_checksum( s: &CharSequence) -> i32 { - let length: i32 = s.length(); - let mut sum: i32 = 0; - { - let mut i: i32 = length - 2; - while i >= 0 { - { - sum += s.char_at(i) - '0'; - } - i -= 2; - } - } - - sum *= 3; - { - let mut i: i32 = length - 1; - while i >= 0 { - { - sum += s.char_at(i) - '0'; - } - i -= 2; - } - } - - sum *= 3; - return sum % 10; - } - - fn determine_check_digit( lg_pattern_found: i32) -> /* throws NotFoundException */Result> { - { - let mut d: i32 = 0; - while d < 10 { - { - if lg_pattern_found == CHECK_DIGIT_ENCODINGS[d] { - return Ok(d); - } - } - d += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - /** - * @param raw raw content of extension - * @return formatted interpretation of raw content as a {@link Map} mapping - * one {@link ResultMetadataType} to appropriate value, or {@code null} if not known - */ - fn parse_extension_string( raw: &String) -> Map { - if raw.length() != 5 { - return null; - } - let value: Object = ::parse_extension5_string(&raw); - if value == null { - return null; - } - let result: Map = EnumMap<>::new(ResultMetadataType.class); - result.put(ResultMetadataType::SUGGESTED_PRICE, &value); - return result; - } - - fn parse_extension5_string( raw: &String) -> String { - let mut currency: String; - match raw.char_at(0) { - '0' => - { - currency = "£"; - break; - } - '5' => - { - currency = "$"; - break; - } - '9' => - { - // Reference: http://www.jollytech.com - match raw { - "90000" => - { - // No suggested retail price - return null; - } - "99991" => - { - // Complementary - return "0.00"; - } - "99990" => - { - return "Used"; - } - } - // Otherwise... unknown currency? - currency = ""; - break; - } - _ => - { - currency = ""; - break; - } - } - let raw_amount: i32 = Integer::parse_int(&raw.substring(1)); - let units_string: String = String::value_of(raw_amount / 100); - let hundredths: i32 = raw_amount % 100; - let hundredths_string: String = if hundredths < 10 { format!("0{}", hundredths) } else { String::value_of(hundredths) }; - return format!("{}{}.{}", currency, units_string, hundredths_string); - } -} - -// NEW FILE: u_p_c_e_a_n_extension_support.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - - - const EXTENSION_START_PATTERN: vec![Vec; 3] = vec![1, 1, 2, ] -; -struct UPCEANExtensionSupport { - - let two_support: UPCEANExtension2Support = UPCEANExtension2Support::new(); - - let five_support: UPCEANExtension5Support = UPCEANExtension5Support::new(); -} - -impl UPCEANExtensionSupport { - - fn decode_row(&self, row_number: i32, row: &BitArray, row_offset: i32) -> /* throws NotFoundException */Result> { - let extension_start_range: Vec = UPCEANReader::find_guard_pattern(row, row_offset, false, &EXTENSION_START_PATTERN); - let tryResult1 = 0; - 'try1: loop { - { - return Ok(self.five_support.decode_row(row_number, row, &extension_start_range)); - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &ReaderException) { - return Ok(self.two_support.decode_row(row_number, row, &extension_start_range)); - } 0 => break - } - - } -} - -// NEW FILE: u_p_c_e_a_n_reader.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

Encapsulates functionality and implementation that is common to UPC and EAN families - * of one-dimensional barcodes.

- * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - * @author alasdair@google.com (Alasdair Mackintosh) - */ - -// These two values are critical for determining how permissive the decoding will be. -// We've arrived at these values through a lot of trial and error. Setting them any higher -// lets false positives creep in quickly. - const MAX_AVG_VARIANCE: f32 = 0.48f; - - const MAX_INDIVIDUAL_VARIANCE: f32 = 0.7f; - -/** - * Start/end guard pattern. - */ - const START_END_PATTERN: vec![Vec; 3] = vec![1, 1, 1, ] -; - -/** - * Pattern marking the middle of a UPC/EAN pattern, separating the two halves. - */ - const MIDDLE_PATTERN: vec![Vec; 5] = vec![1, 1, 1, 1, 1, ] -; - -/** - * end guard pattern. - */ - const END_PATTERN: vec![Vec; 6] = vec![1, 1, 1, 1, 1, 1, ] -; - -/** - * "Odd", or "L" patterns used to encode UPC/EAN digits. - */ - const L_PATTERNS: vec![vec![Vec>; 4]; 10] = vec![// 0 -vec![3, 2, 1, 1, ] -, // 1 -vec![2, 2, 2, 1, ] -, // 2 -vec![2, 1, 2, 2, ] -, // 3 -vec![1, 4, 1, 1, ] -, // 4 -vec![1, 1, 3, 2, ] -, // 5 -vec![1, 2, 3, 1, ] -, // 6 -vec![1, 1, 1, 4, ] -, // 7 -vec![1, 3, 1, 2, ] -, // 8 -vec![1, 2, 1, 3, ] -, // 9 -vec![3, 1, 1, 2, ] -, ] -; - -/** - * As above but also including the "even", or "G" patterns used to encode UPC/EAN digits. - */ - const L_AND_G_PATTERNS: Vec>; -pub struct UPCEANReader { - super: OneDReader; - - let decode_row_string_buffer: StringBuilder; - - let extension_reader: UPCEANExtensionSupport; - - let ean_man_support: EANManufacturerOrgSupport; -} - -impl UPCEANReader { - - static { - L_AND_G_PATTERNS = : [i32; 20] = [0; 20]; - System::arraycopy(&L_PATTERNS, 0, &L_AND_G_PATTERNS, 0, 10); - { - let mut i: i32 = 10; - while i < 20 { - { - let widths: Vec = L_PATTERNS[i - 10]; - let reversed_widths: [i32; widths.len()] = [0; widths.len()]; - { - let mut j: i32 = 0; - while j < widths.len() { - { - reversed_widths[j] = widths[widths.len() - j - 1]; - } - j += 1; - } - } - - L_AND_G_PATTERNS[i] = reversed_widths; - } - i += 1; - } - } - - } - - pub fn new() -> UPCEANReader { - decode_row_string_buffer = StringBuilder::new(20); - extension_reader = UPCEANExtensionSupport::new(); - ean_man_support = EANManufacturerOrgSupport::new(); - } - - fn find_start_guard_pattern( row: &BitArray) -> /* throws NotFoundException */Result, Rc> { - let found_start: bool = false; - let start_range: Vec = null; - let next_start: i32 = 0; - let counters: [i32; START_END_PATTERN.len()] = [0; START_END_PATTERN.len()]; - while !found_start { - Arrays::fill(&counters, 0, START_END_PATTERN.len(), 0); - start_range = ::find_guard_pattern(row, next_start, false, &START_END_PATTERN, &counters); - let start: i32 = start_range[0]; - next_start = start_range[1]; - // Make sure there is a quiet zone at least as big as the start pattern before the barcode. - // If this check would run off the left edge of the image, do not accept this barcode, - // as it is very likely to be a false positive. - let quiet_start: i32 = start - (next_start - start); - if quiet_start >= 0 { - found_start = row.is_range(quiet_start, start, false); - } - } - return Ok(start_range); - } - - pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException, ChecksumException, FormatException */Result> { - return Ok(self.decode_row(row_number, row, &::find_start_guard_pattern(row), &hints)); - } - - /** - *

Like {@link #decodeRow(int, BitArray, Map)}, but - * allows caller to inform method about where the UPC/EAN start pattern is - * found. This allows this to be computed once and reused across many implementations.

- * - * @param rowNumber row index into the image - * @param row encoding of the row of the barcode image - * @param startGuardRange start/end column where the opening start pattern was found - * @param hints optional hints that influence decoding - * @return {@link Result} encapsulating the result of decoding a barcode in the row - * @throws NotFoundException if no potential barcode is found - * @throws ChecksumException if a potential barcode is found but does not pass its checksum - * @throws FormatException if a potential barcode is found but format is invalid - */ - pub fn decode_row(&self, row_number: i32, row: &BitArray, start_guard_range: &Vec, hints: &Map) -> /* throws NotFoundException, ChecksumException, FormatException */Result> { - let result_point_callback: ResultPointCallback = if hints == null { null } else { hints.get(DecodeHintType::NEED_RESULT_POINT_CALLBACK) as ResultPointCallback }; - let symbology_identifier: i32 = 0; - if result_point_callback != null { - result_point_callback.found_possible_result_point(ResultPoint::new((start_guard_range[0] + start_guard_range[1]) / 2.0f, row_number)); - } - let result: StringBuilder = self.decode_row_string_buffer; - result.set_length(0); - let end_start: i32 = self.decode_middle(row, &start_guard_range, &result); - if result_point_callback != null { - result_point_callback.found_possible_result_point(ResultPoint::new(end_start, row_number)); - } - let end_range: Vec = self.decode_end(row, end_start); - if result_point_callback != null { - result_point_callback.found_possible_result_point(ResultPoint::new((end_range[0] + end_range[1]) / 2.0f, row_number)); - } - // Make sure there is a quiet zone at least as big as the end pattern after the barcode. The - // spec might want more whitespace, but in practice this is the maximum we can count on. - let end: i32 = end_range[1]; - let quiet_end: i32 = end + (end - end_range[0]); - if quiet_end >= row.get_size() || !row.is_range(end, quiet_end, false) { - throw NotFoundException::get_not_found_instance(); - } - let result_string: String = result.to_string(); - // UPC/EAN should never be less than 8 chars anyway - if result_string.length() < 8 { - throw FormatException::get_format_instance(); - } - if !self.check_checksum(&result_string) { - throw ChecksumException::get_checksum_instance(); - } - let left: f32 = (start_guard_range[1] + start_guard_range[0]) / 2.0f; - let right: f32 = (end_range[1] + end_range[0]) / 2.0f; - let format: BarcodeFormat = self.get_barcode_format(); - let decode_result: Result = Result::new(&result_string, // no natural byte representation for these barcodes - null, : vec![ResultPoint; 2] = vec![ResultPoint::new(left, row_number), ResultPoint::new(right, row_number), ] - , format); - let extension_length: i32 = 0; - let tryResult1 = 0; - 'try1: loop { - { - let extension_result: Result = self.extension_reader.decode_row(row_number, row, end_range[1]); - decode_result.put_metadata(ResultMetadataType::UPC_EAN_EXTENSION, &extension_result.get_text()); - decode_result.put_all_metadata(&extension_result.get_result_metadata()); - decode_result.add_result_points(&extension_result.get_result_points()); - extension_length = extension_result.get_text().length(); - } - break 'try1 - } - match tryResult1 { - catch ( re: &ReaderException) { - } 0 => break - } - - let allowed_extensions: Vec = if hints == null { null } else { hints.get(DecodeHintType::ALLOWED_EAN_EXTENSIONS) as Vec }; - if allowed_extensions != null { - let mut valid: bool = false; - for let length: i32 in allowed_extensions { - if extension_length == length { - valid = true; - break; - } - } - if !valid { - throw NotFoundException::get_not_found_instance(); - } - } - if format == BarcodeFormat::EAN_13 || format == BarcodeFormat::UPC_A { - let country_i_d: String = self.ean_man_support.lookup_country_identifier(&result_string); - if country_i_d != null { - decode_result.put_metadata(ResultMetadataType::POSSIBLE_COUNTRY, &country_i_d); - } - } - if format == BarcodeFormat::EAN_8 { - symbology_identifier = 4; - } - decode_result.put_metadata(ResultMetadataType::SYMBOLOGY_IDENTIFIER, format!("]E{}", symbology_identifier)); - return Ok(decode_result); - } - - /** - * @param s string of digits to check - * @return {@link #checkStandardUPCEANChecksum(CharSequence)} - * @throws FormatException if the string does not contain only digits - */ - fn check_checksum(&self, s: &String) -> /* throws FormatException */Result> { - return Ok(::check_standard_u_p_c_e_a_n_checksum(&s)); - } - - /** - * Computes the UPC/EAN checksum on a string of digits, and reports - * whether the checksum is correct or not. - * - * @param s string of digits to check - * @return true iff string of digits passes the UPC/EAN checksum algorithm - * @throws FormatException if the string does not contain only digits - */ - fn check_standard_u_p_c_e_a_n_checksum( s: &CharSequence) -> /* throws FormatException */Result> { - let length: i32 = s.length(); - if length == 0 { - return Ok(false); - } - let check: i32 = Character::digit(&s.char_at(length - 1), 10); - return Ok(::get_standard_u_p_c_e_a_n_checksum(&s.sub_sequence(0, length - 1)) == check); - } - - fn get_standard_u_p_c_e_a_n_checksum( s: &CharSequence) -> /* throws FormatException */Result> { - let length: i32 = s.length(); - let mut sum: i32 = 0; - { - let mut i: i32 = length - 1; - while i >= 0 { - { - let digit: i32 = s.char_at(i) - '0'; - if digit < 0 || digit > 9 { - throw FormatException::get_format_instance(); - } - sum += digit; - } - i -= 2; - } - } - - sum *= 3; - { - let mut i: i32 = length - 2; - while i >= 0 { - { - let digit: i32 = s.char_at(i) - '0'; - if digit < 0 || digit > 9 { - throw FormatException::get_format_instance(); - } - sum += digit; - } - i -= 2; - } - } - - return Ok((1000 - sum) % 10); - } - - fn decode_end(&self, row: &BitArray, end_start: i32) -> /* throws NotFoundException */Result, Rc> { - return Ok(::find_guard_pattern(row, end_start, false, &START_END_PATTERN)); - } - - fn find_guard_pattern( row: &BitArray, row_offset: i32, white_first: bool, pattern: &Vec) -> /* throws NotFoundException */Result, Rc> { - return Ok(::find_guard_pattern(row, row_offset, white_first, &pattern, : [i32; pattern.len()] = [0; pattern.len()])); - } - - /** - * @param row row of black/white values to search - * @param rowOffset position to start search - * @param whiteFirst if true, indicates that the pattern specifies white/black/white/... - * pixel counts, otherwise, it is interpreted as black/white/black/... - * @param pattern pattern of counts of number of black and white pixels that are being - * searched for as a pattern - * @param counters array of counters, as long as pattern, to re-use - * @return start/end horizontal offset of guard pattern, as an array of two ints - * @throws NotFoundException if pattern is not found - */ - fn find_guard_pattern( row: &BitArray, row_offset: i32, white_first: bool, pattern: &Vec, counters: &Vec) -> /* throws NotFoundException */Result, Rc> { - let width: i32 = row.get_size(); - row_offset = if white_first { row.get_next_unset(row_offset) } else { row.get_next_set(row_offset) }; - let counter_position: i32 = 0; - let pattern_start: i32 = row_offset; - let pattern_length: i32 = pattern.len(); - let is_white: bool = white_first; - { - let mut x: i32 = row_offset; - while x < width { - { - if row.get(x) != is_white { - counters[counter_position] += 1; - } else { - if counter_position == pattern_length - 1 { - if pattern_match_variance(&counters, &pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE { - return Ok( : vec![i32; 2] = vec![pattern_start, x, ] - ); - } - pattern_start += counters[0] + counters[1]; - System::arraycopy(&counters, 2, &counters, 0, counter_position - 1); - counters[counter_position - 1] = 0; - counters[counter_position] = 0; - counter_position -= 1; - } else { - counter_position += 1; - } - counters[counter_position] = 1; - is_white = !is_white; - } - } - x += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - /** - * Attempts to decode a single UPC/EAN-encoded digit. - * - * @param row row of black/white values to decode - * @param counters the counts of runs of observed black/white/black/... values - * @param rowOffset horizontal offset to start decoding from - * @param patterns the set of patterns to use to decode -- sometimes different encodings - * for the digits 0-9 are used, and this indicates the encodings for 0 to 9 that should - * be used - * @return horizontal offset of first pixel beyond the decoded digit - * @throws NotFoundException if digit cannot be decoded - */ - fn decode_digit( row: &BitArray, counters: &Vec, row_offset: i32, patterns: &Vec>) -> /* throws NotFoundException */Result> { - record_pattern(row, row_offset, &counters); - // worst variance we'll accept - let best_variance: f32 = MAX_AVG_VARIANCE; - let best_match: i32 = -1; - let max: i32 = patterns.len(); - { - let mut i: i32 = 0; - while i < max { - { - let pattern: Vec = patterns[i]; - let variance: f32 = pattern_match_variance(&counters, &pattern, MAX_INDIVIDUAL_VARIANCE); - if variance < best_variance { - best_variance = variance; - best_match = i; - } - } - i += 1; - } - } - - if best_match >= 0 { - return Ok(best_match); - } else { - throw NotFoundException::get_not_found_instance(); - } - } - - /** - * Get the format of this decoder. - * - * @return The 1D format. - */ - fn get_barcode_format(&self) -> BarcodeFormat ; - - /** - * Subclasses override this to decode the portion of a barcode between the start - * and end guard patterns. - * - * @param row row of black/white values to search - * @param startRange start/end offset of start guard pattern - * @param resultString {@link StringBuilder} to append decoded chars to - * @return horizontal offset of first pixel after the "middle" that was decoded - * @throws NotFoundException if decoding could not complete successfully - */ - pub fn decode_middle(&self, row: &BitArray, start_range: &Vec, result_string: &StringBuilder) -> /* throws NotFoundException */Result> ; -} - -// NEW FILE: u_p_c_e_a_n_writer.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

Encapsulates functionality and implementation that is common to UPC and EAN families - * of one-dimensional barcodes.

- * - * @author aripollak@gmail.com (Ari Pollak) - * @author dsbnatut@gmail.com (Kazuki Nishiura) - */ -pub struct UPCEANWriter { - super: OneDimensionalCodeWriter; -} - -impl UPCEANWriter { - - pub fn get_default_margin(&self) -> i32 { - // Use a different default more appropriate for UPC/EAN - return 9; - } -} - -// NEW FILE: u_p_c_e_reader.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - *

Implements decoding of the UPC-E format.

- *

This is a great reference for - * UPC-E information.

- * - * @author Sean Owen - */ - -/** - * The pattern that marks the middle, and end, of a UPC-E pattern. - * There is no "second half" to a UPC-E barcode. - */ - const MIDDLE_END_PATTERN: vec![Vec; 6] = vec![1, 1, 1, 1, 1, 1, ] -; - -// For an UPC-E barcode, the final digit is represented by the parities used -// to encode the middle six digits, according to the table below. -// -// Parity of next 6 digits -// Digit 0 1 2 3 4 5 -// 0 Even Even Even Odd Odd Odd -// 1 Even Even Odd Even Odd Odd -// 2 Even Even Odd Odd Even Odd -// 3 Even Even Odd Odd Odd Even -// 4 Even Odd Even Even Odd Odd -// 5 Even Odd Odd Even Even Odd -// 6 Even Odd Odd Odd Even Even -// 7 Even Odd Even Odd Even Odd -// 8 Even Odd Even Odd Odd Even -// 9 Even Odd Odd Even Odd Even -// -// The encoding is represented by the following array, which is a bit pattern -// using Odd = 0 and Even = 1. For example, 5 is represented by: -// -// Odd Even Even Odd Odd Even -// in binary: -// 0 1 1 0 0 1 == 0x19 -// -/** - * See {@link #L_AND_G_PATTERNS}; these values similarly represent patterns of - * even-odd parity encodings of digits that imply both the number system (0 or 1) - * used, and the check digit. - */ - const NUMSYS_AND_CHECK_DIGIT_PATTERNS: vec![vec![Vec>; 10]; 2] = vec![vec![0x38, 0x34, 0x32, 0x31, 0x2C, 0x26, 0x23, 0x2A, 0x29, 0x25, ] -, vec![0x07, 0x0B, 0x0D, 0x0E, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A, ] -, ] -; -pub struct UPCEReader { - super: UPCEANReader; - - let decode_middle_counters: Vec; -} - -impl UPCEReader { - - pub fn new() -> UPCEReader { - decode_middle_counters = : [i32; 4] = [0; 4]; - } - - pub fn decode_middle(&self, row: &BitArray, start_range: &Vec, result: &StringBuilder) -> /* throws NotFoundException */Result> { - let mut counters: Vec = self.decode_middle_counters; - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - let end: i32 = row.get_size(); - let row_offset: i32 = start_range[1]; - let lg_pattern_found: i32 = 0; - { - let mut x: i32 = 0; - while x < 6 && row_offset < end { - { - let best_match: i32 = decode_digit(row, &counters, row_offset, L_AND_G_PATTERNS); - result.append(('0' + best_match % 10) as char); - for let counter: i32 in counters { - row_offset += counter; - } - if best_match >= 10 { - lg_pattern_found |= 1 << (5 - x); - } - } - x += 1; - } - } - - ::determine_num_sys_and_check_digit(&result, lg_pattern_found); - return Ok(row_offset); - } - - pub fn decode_end(&self, row: &BitArray, end_start: i32) -> /* throws NotFoundException */Result, Rc> { - return Ok(find_guard_pattern(row, end_start, true, &MIDDLE_END_PATTERN)); - } - - pub fn check_checksum(&self, s: &String) -> /* throws FormatException */Result> { - return Ok(super.check_checksum(&::convert_u_p_c_eto_u_p_c_a(&s))); - } - - fn determine_num_sys_and_check_digit( result_string: &StringBuilder, lg_pattern_found: i32) -> /* throws NotFoundException */Result> { - { - let num_sys: i32 = 0; - while num_sys <= 1 { - { - { - let mut d: i32 = 0; - while d < 10 { - { - if lg_pattern_found == NUMSYS_AND_CHECK_DIGIT_PATTERNS[num_sys][d] { - result_string.insert(0, ('0' + num_sys) as char); - result_string.append(('0' + d) as char); - return; - } - } - d += 1; - } - } - - } - num_sys += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - fn get_barcode_format(&self) -> BarcodeFormat { - return BarcodeFormat::UPC_E; - } - - /** - * Expands a UPC-E value back into its full, equivalent UPC-A code value. - * - * @param upce UPC-E code as string of digits - * @return equivalent UPC-A code as string of digits - */ - pub fn convert_u_p_c_eto_u_p_c_a( upce: &String) -> String { - let upce_chars: [Option; 6] = [None; 6]; - upce.get_chars(1, 7, &upce_chars, 0); - let result: StringBuilder = StringBuilder::new(12); - result.append(&upce.char_at(0)); - let last_char: char = upce_chars[5]; - match last_char { - '0' => - { - } - '1' => - { - } - '2' => - { - result.append(&upce_chars, 0, 2); - result.append(last_char); - result.append("0000"); - result.append(&upce_chars, 2, 3); - break; - } - '3' => - { - result.append(&upce_chars, 0, 3); - result.append("00000"); - result.append(&upce_chars, 3, 2); - break; - } - '4' => - { - result.append(&upce_chars, 0, 4); - result.append("00000"); - result.append(upce_chars[4]); - break; - } - _ => - { - result.append(&upce_chars, 0, 5); - result.append("0000"); - result.append(last_char); - break; - } - } - // Only append check digit in conversion if supplied - if upce.length() >= 8 { - result.append(&upce.char_at(7)); - } - return result.to_string(); - } -} - -// NEW FILE: u_p_c_e_writer.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned; - -/** - * This object renders an UPC-E code as a {@link BitMatrix}. - * - * @author 0979097955s@gmail.com (RX) - */ - - const CODE_WIDTH: i32 = // start guard -3 + // bars -(7 * 6) + // end guard -6; -pub struct UPCEWriter { - super: UPCEANWriter; -} - -impl UPCEWriter { - - pub fn get_supported_write_formats(&self) -> Collection { - return Collections::singleton(BarcodeFormat::UPC_E); - } - - pub fn encode(&self, contents: &String) -> Vec { - let length: i32 = contents.length(); - match length { - 7 => - { - // No check digit present, calculate it and add it - let mut check: i32; - let tryResult1 = 0; - 'try1: loop { - { - check = UPCEANReader::get_standard_u_p_c_e_a_n_checksum(&UPCEReader::convert_u_p_c_eto_u_p_c_a(&contents)); - } - break 'try1 - } - match tryResult1 { - catch ( fe: &FormatException) { - throw IllegalArgumentException::new(fe); - } 0 => break - } - - contents += check; - break; - } - 8 => - { - let tryResult1 = 0; - 'try1: loop { - { - if !UPCEANReader::check_standard_u_p_c_e_a_n_checksum(&UPCEReader::convert_u_p_c_eto_u_p_c_a(&contents)) { - throw IllegalArgumentException::new("Contents do not pass checksum"); - } - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &FormatException) { - throw IllegalArgumentException::new("Illegal contents"); - } 0 => break - } - - break; - } - _ => - { - throw IllegalArgumentException::new(format!("Requested contents should be 7 or 8 digits long, but got {}", length)); - } - } - check_numeric(&contents); - let first_digit: i32 = Character::digit(&contents.char_at(0), 10); - if first_digit != 0 && first_digit != 1 { - throw IllegalArgumentException::new("Number system must be 0 or 1"); - } - let check_digit: i32 = Character::digit(&contents.char_at(7), 10); - let parities: i32 = UPCEReader.NUMSYS_AND_CHECK_DIGIT_PATTERNS[first_digit][check_digit]; - let result: [bool; CODE_WIDTH] = [false; CODE_WIDTH]; - let mut pos: i32 = append_pattern(&result, 0, UPCEANReader.START_END_PATTERN, true); - { - let mut i: i32 = 1; - while i <= 6 { - { - let mut digit: i32 = Character::digit(&contents.char_at(i), 10); - if (parities >> (6 - i) & 1) == 1 { - digit += 10; - } - pos += append_pattern(&result, pos, UPCEANReader.L_AND_G_PATTERNS[digit], false); - } - i += 1; - } - } - - append_pattern(&result, pos, UPCEANReader.END_PATTERN, false); - return result; - } -} - diff --git a/src/oned/rss.rs b/src/oned/rss.rs deleted file mode 100644 index 8ac3be6..0000000 --- a/src/oned/rss.rs +++ /dev/null @@ -1,959 +0,0 @@ -use crate::{NotFoundException,ResultPoint,BarcodeFormat,DecodeHintType,NotFoundException,RXingResult,ResultMetadataType,ResultPoint,ResultPointCallback}; -use crate::common::BitArray; -use crate::common::detector::{MathUtils}; -use crate::oned::{OneDReader}; - - - -// NEW FILE: abstract_r_s_s_reader.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss; - -/** - * Superclass of {@link OneDReader} implementations that read barcodes in the RSS family - * of formats. - */ - - const MAX_AVG_VARIANCE: f32 = 0.2f; - - const MAX_INDIVIDUAL_VARIANCE: f32 = 0.45f; - - const MIN_FINDER_PATTERN_RATIO: f32 = 9.5f / 12.0f; - - const MAX_FINDER_PATTERN_RATIO: f32 = 12.5f / 14.0f; -pub struct AbstractRSSReader { - super: OneDReader; - - let decode_finder_counters: Vec; - - let data_character_counters: Vec; - - let odd_rounding_errors: Vec; - - let even_rounding_errors: Vec; - - let odd_counts: Vec; - - let even_counts: Vec; -} - -impl AbstractRSSReader { - - pub fn new() -> AbstractRSSReader { - decode_finder_counters = : [i32; 4] = [0; 4]; - data_character_counters = : [i32; 8] = [0; 8]; - odd_rounding_errors = : [f32; 4.0] = [0.0; 4.0]; - even_rounding_errors = : [f32; 4.0] = [0.0; 4.0]; - odd_counts = : [i32; data_character_counters.len() / 2] = [0; data_character_counters.len() / 2]; - even_counts = : [i32; data_character_counters.len() / 2] = [0; data_character_counters.len() / 2]; - } - - pub fn get_decode_finder_counters(&self) -> Vec { - return self.decode_finder_counters; - } - - pub fn get_data_character_counters(&self) -> Vec { - return self.data_character_counters; - } - - pub fn get_odd_rounding_errors(&self) -> Vec { - return self.odd_rounding_errors; - } - - pub fn get_even_rounding_errors(&self) -> Vec { - return self.even_rounding_errors; - } - - pub fn get_odd_counts(&self) -> Vec { - return self.odd_counts; - } - - pub fn get_even_counts(&self) -> Vec { - return self.even_counts; - } - - pub fn parse_finder_value( counters: &Vec, finder_patterns: &Vec>) -> /* throws NotFoundException */Result> { - { - let mut value: i32 = 0; - while value < finder_patterns.len() { - { - if pattern_match_variance(&counters, finder_patterns[value], MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE { - return Ok(value); - } - } - value += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - /** - * @param array values to sum - * @return sum of values - * @deprecated call {@link MathUtils#sum(int[])} - */ - pub fn count( array: &Vec) -> i32 { - return MathUtils::sum(&array); - } - - pub fn increment( array: &Vec, errors: &Vec) { - let mut index: i32 = 0; - let biggest_error: f32 = errors[0]; - { - let mut i: i32 = 1; - while i < array.len() { - { - if errors[i] > biggest_error { - biggest_error = errors[i]; - index = i; - } - } - i += 1; - } - } - - array[index] += 1; - } - - pub fn decrement( array: &Vec, errors: &Vec) { - let mut index: i32 = 0; - let biggest_error: f32 = errors[0]; - { - let mut i: i32 = 1; - while i < array.len() { - { - if errors[i] < biggest_error { - biggest_error = errors[i]; - index = i; - } - } - i += 1; - } - } - - array[index] -= 1; - } - - pub fn is_finder_pattern( counters: &Vec) -> bool { - let first_two_sum: i32 = counters[0] + counters[1]; - let sum: i32 = first_two_sum + counters[2] + counters[3]; - let ratio: f32 = first_two_sum / sum as f32; - if ratio >= MIN_FINDER_PATTERN_RATIO && ratio <= MAX_FINDER_PATTERN_RATIO { - // passes ratio test in spec, but see if the counts are unreasonable - let min_counter: i32 = Integer::MAX_VALUE; - let max_counter: i32 = Integer::MIN_VALUE; - for let counter: i32 in counters { - if counter > max_counter { - max_counter = counter; - } - if counter < min_counter { - min_counter = counter; - } - } - return max_counter < 10 * min_counter; - } - return false; - } -} - -// NEW FILE: data_character.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss; - -/** - * Encapsulates a since character value in an RSS barcode, including its checksum information. - */ -pub struct DataCharacter { - - let value: i32; - - let checksum_portion: i32; -} - -impl DataCharacter { - - pub fn new( value: i32, checksum_portion: i32) -> DataCharacter { - let .value = value; - let .checksumPortion = checksum_portion; - } - - pub fn get_value(&self) -> i32 { - return self.value; - } - - pub fn get_checksum_portion(&self) -> i32 { - return self.checksum_portion; - } - - pub fn to_string(&self) -> String { - return format!("{}({})", self.value, self.checksum_portion); - } - - pub fn equals(&self, o: &Object) -> bool { - if !(o instanceof DataCharacter) { - return false; - } - let that: DataCharacter = o as DataCharacter; - return self.value == that.value && self.checksum_portion == that.checksumPortion; - } - - pub fn hash_code(&self) -> i32 { - return self.value ^ self.checksum_portion; - } -} - -// NEW FILE: finder_pattern.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss; - -/** - * Encapsulates an RSS barcode finder pattern, including its start/end position and row. - */ -pub struct FinderPattern { - - let value: i32; - - let start_end: Vec; - - let result_points: Vec; -} - -impl FinderPattern { - - pub fn new( value: i32, start_end: &Vec, start: i32, end: i32, row_number: i32) -> FinderPattern { - let .value = value; - let .startEnd = start_end; - let .resultPoints = : vec![ResultPoint; 2] = vec![ResultPoint::new(start, row_number), ResultPoint::new(end, row_number), ] - ; - } - - pub fn get_value(&self) -> i32 { - return self.value; - } - - pub fn get_start_end(&self) -> Vec { - return self.start_end; - } - - pub fn get_result_points(&self) -> Vec { - return self.result_points; - } - - pub fn equals(&self, o: &Object) -> bool { - if !(o instanceof FinderPattern) { - return false; - } - let that: FinderPattern = o as FinderPattern; - return self.value == that.value; - } - - pub fn hash_code(&self) -> i32 { - return self.value; - } -} - -// NEW FILE: pair.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss; - -struct Pair { - super: DataCharacter; - - let finder_pattern: FinderPattern; - - let mut count: i32; -} - -impl Pair { - - fn new( value: i32, checksum_portion: i32, finder_pattern: &FinderPattern) -> Pair { - super(value, checksum_portion); - let .finderPattern = finder_pattern; - } - - fn get_finder_pattern(&self) -> FinderPattern { - return self.finder_pattern; - } - - fn get_count(&self) -> i32 { - return self.count; - } - - fn increment_count(&self) { - self.count += 1; - } -} - -// NEW FILE: r_s_s14_reader.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss; - -/** - * Decodes RSS-14, including truncated and stacked variants. See ISO/IEC 24724:2006. - */ - - const OUTSIDE_EVEN_TOTAL_SUBSET: vec![Vec; 5] = vec![1, 10, 34, 70, 126, ] -; - - const INSIDE_ODD_TOTAL_SUBSET: vec![Vec; 4] = vec![4, 20, 48, 81, ] -; - - const OUTSIDE_GSUM: vec![Vec; 5] = vec![0, 161, 961, 2015, 2715, ] -; - - const INSIDE_GSUM: vec![Vec; 4] = vec![0, 336, 1036, 1516, ] -; - - const OUTSIDE_ODD_WIDEST: vec![Vec; 5] = vec![8, 6, 4, 3, 1, ] -; - - const INSIDE_ODD_WIDEST: vec![Vec; 4] = vec![2, 4, 6, 8, ] -; - - const FINDER_PATTERNS: vec![vec![Vec>; 4]; 9] = vec![vec![3, 8, 2, 1, ] -, vec![3, 5, 5, 1, ] -, vec![3, 3, 7, 1, ] -, vec![3, 1, 9, 1, ] -, vec![2, 7, 4, 1, ] -, vec![2, 5, 6, 1, ] -, vec![2, 3, 8, 1, ] -, vec![1, 5, 7, 1, ] -, vec![1, 3, 9, 1, ] -, ] -; -pub struct RSS14Reader { - super: AbstractRSSReader; - - let possible_left_pairs: List; - - let possible_right_pairs: List; -} - -impl RSS14Reader { - - pub fn new() -> RSS14Reader { - possible_left_pairs = ArrayList<>::new(); - possible_right_pairs = ArrayList<>::new(); - } - - pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException */Result> { - let left_pair: Pair = self.decode_pair(row, false, row_number, &hints); - ::add_or_tally(&self.possible_left_pairs, left_pair); - row.reverse(); - let right_pair: Pair = self.decode_pair(row, true, row_number, &hints); - ::add_or_tally(&self.possible_right_pairs, right_pair); - row.reverse(); - for let left: Pair in self.possible_left_pairs { - if left.get_count() > 1 { - for let right: Pair in self.possible_right_pairs { - if right.get_count() > 1 && ::check_checksum(left, right) { - return Ok(::construct_result(left, right)); - } - } - } - } - throw NotFoundException::get_not_found_instance(); - } - - fn add_or_tally( possible_pairs: &Collection, pair: &Pair) { - if pair == null { - return; - } - let mut found: bool = false; - for let other: Pair in possible_pairs { - if other.get_value() == pair.get_value() { - other.increment_count(); - found = true; - break; - } - } - if !found { - possible_pairs.add(pair); - } - } - - pub fn reset(&self) { - self.possible_left_pairs.clear(); - self.possible_right_pairs.clear(); - } - - fn construct_result( left_pair: &Pair, right_pair: &Pair) -> Result { - let symbol_value: i64 = 4537077 * left_pair.get_value() + right_pair.get_value(); - let text: String = String::value_of(symbol_value); - let buffer: StringBuilder = StringBuilder::new(14); - { - let mut i: i32 = 13 - text.length(); - while i > 0 { - { - buffer.append('0'); - } - i -= 1; - } - } - - buffer.append(&text); - let check_digit: i32 = 0; - { - let mut i: i32 = 0; - while i < 13 { - { - let digit: i32 = buffer.char_at(i) - '0'; - check_digit += if (i & 0x01) == 0 { 3 * digit } else { digit }; - } - i += 1; - } - } - - check_digit = 10 - (check_digit % 10); - if check_digit == 10 { - check_digit = 0; - } - buffer.append(check_digit); - let left_points: Vec = left_pair.get_finder_pattern().get_result_points(); - let right_points: Vec = right_pair.get_finder_pattern().get_result_points(); - let result: Result = Result::new(&buffer.to_string(), null, : vec![ResultPoint; 4] = vec![left_points[0], left_points[1], right_points[0], right_points[1], ] - , BarcodeFormat::RSS_14); - result.put_metadata(ResultMetadataType::SYMBOLOGY_IDENTIFIER, "]e0"); - return result; - } - - fn check_checksum( left_pair: &Pair, right_pair: &Pair) -> bool { - let check_value: i32 = (left_pair.get_checksum_portion() + 16 * right_pair.get_checksum_portion()) % 79; - let target_check_value: i32 = 9 * left_pair.get_finder_pattern().get_value() + right_pair.get_finder_pattern().get_value(); - if target_check_value > 72 { - target_check_value -= 1; - } - if target_check_value > 8 { - target_check_value -= 1; - } - return check_value == target_check_value; - } - - fn decode_pair(&self, row: &BitArray, right: bool, row_number: i32, hints: &Map) -> Pair { - let tryResult1 = 0; - 'try1: loop { - { - let start_end: Vec = self.find_finder_pattern(row, right); - let pattern: FinderPattern = self.parse_found_finder_pattern(row, row_number, right, &start_end); - let result_point_callback: ResultPointCallback = if hints == null { null } else { hints.get(DecodeHintType::NEED_RESULT_POINT_CALLBACK) as ResultPointCallback }; - if result_point_callback != null { - start_end = pattern.get_start_end(); - let mut center: f32 = (start_end[0] + start_end[1] - 1.0) / 2.0f; - if right { - // row is actually reversed - center = row.get_size() - 1.0 - center; - } - result_point_callback.found_possible_result_point(ResultPoint::new(center, row_number)); - } - let outside: DataCharacter = self.decode_data_character(row, pattern, true); - let inside: DataCharacter = self.decode_data_character(row, pattern, false); - return Pair::new(1597 * outside.get_value() + inside.get_value(), outside.get_checksum_portion() + 4 * inside.get_checksum_portion(), pattern); - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &NotFoundException) { - return null; - } 0 => break - } - - } - - fn decode_data_character(&self, row: &BitArray, pattern: &FinderPattern, outside_char: bool) -> /* throws NotFoundException */Result> { - let mut counters: Vec = get_data_character_counters(); - Arrays::fill(&counters, 0); - if outside_char { - record_pattern_in_reverse(row, pattern.get_start_end()[0], &counters); - } else { - record_pattern(row, pattern.get_start_end()[1], &counters); - // reverse it - { - let mut i: i32 = 0, let mut j: i32 = counters.len() - 1; - while i < j { - { - let temp: i32 = counters[i]; - counters[i] = counters[j]; - counters[j] = temp; - } - i += 1; - j -= 1; - } - } - - } - let num_modules: i32 = if outside_char { 16 } else { 15 }; - let element_width: f32 = MathUtils::sum(&counters) / num_modules as f32; - let odd_counts: Vec = self.get_odd_counts(); - let even_counts: Vec = self.get_even_counts(); - let odd_rounding_errors: Vec = self.get_odd_rounding_errors(); - let even_rounding_errors: Vec = self.get_even_rounding_errors(); - { - let mut i: i32 = 0; - while i < counters.len() { - { - let value: f32 = counters[i] / element_width; - // Round - let mut count: i32 = (value + 0.5f) as i32; - if count < 1 { - count = 1; - } else if count > 8 { - count = 8; - } - let mut offset: i32 = i / 2; - if (i & 0x01) == 0 { - odd_counts[offset] = count; - odd_rounding_errors[offset] = value - count; - } else { - even_counts[offset] = count; - even_rounding_errors[offset] = value - count; - } - } - i += 1; - } - } - - self.adjust_odd_even_counts(outside_char, num_modules); - let odd_sum: i32 = 0; - let odd_checksum_portion: i32 = 0; - { - let mut i: i32 = odd_counts.len() - 1; - while i >= 0 { - { - odd_checksum_portion *= 9; - odd_checksum_portion += odd_counts[i]; - odd_sum += odd_counts[i]; - } - i -= 1; - } - } - - let even_checksum_portion: i32 = 0; - let even_sum: i32 = 0; - { - let mut i: i32 = even_counts.len() - 1; - while i >= 0 { - { - even_checksum_portion *= 9; - even_checksum_portion += even_counts[i]; - even_sum += even_counts[i]; - } - i -= 1; - } - } - - let checksum_portion: i32 = odd_checksum_portion + 3 * even_checksum_portion; - if outside_char { - if (odd_sum & 0x01) != 0 || odd_sum > 12 || odd_sum < 4 { - throw NotFoundException::get_not_found_instance(); - } - let group: i32 = (12 - odd_sum) / 2; - let odd_widest: i32 = OUTSIDE_ODD_WIDEST[group]; - let even_widest: i32 = 9 - odd_widest; - let v_odd: i32 = RSSUtils::get_r_s_svalue(&odd_counts, odd_widest, false); - let v_even: i32 = RSSUtils::get_r_s_svalue(&even_counts, even_widest, true); - let t_even: i32 = OUTSIDE_EVEN_TOTAL_SUBSET[group]; - let g_sum: i32 = OUTSIDE_GSUM[group]; - return Ok(DataCharacter::new(v_odd * t_even + v_even + g_sum, checksum_portion)); - } else { - if (even_sum & 0x01) != 0 || even_sum > 10 || even_sum < 4 { - throw NotFoundException::get_not_found_instance(); - } - let group: i32 = (10 - even_sum) / 2; - let odd_widest: i32 = INSIDE_ODD_WIDEST[group]; - let even_widest: i32 = 9 - odd_widest; - let v_odd: i32 = RSSUtils::get_r_s_svalue(&odd_counts, odd_widest, true); - let v_even: i32 = RSSUtils::get_r_s_svalue(&even_counts, even_widest, false); - let t_odd: i32 = INSIDE_ODD_TOTAL_SUBSET[group]; - let g_sum: i32 = INSIDE_GSUM[group]; - return Ok(DataCharacter::new(v_even * t_odd + v_odd + g_sum, checksum_portion)); - } - } - - fn find_finder_pattern(&self, row: &BitArray, right_finder_pattern: bool) -> /* throws NotFoundException */Result, Rc> { - let mut counters: Vec = get_decode_finder_counters(); - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - let width: i32 = row.get_size(); - let is_white: bool = false; - let row_offset: i32 = 0; - while row_offset < width { - is_white = !row.get(row_offset); - if right_finder_pattern == is_white { - // Will encounter white first when searching for right finder pattern - break; - } - row_offset += 1; - } - let counter_position: i32 = 0; - let pattern_start: i32 = row_offset; - { - let mut x: i32 = row_offset; - while x < width { - { - if row.get(x) != is_white { - counters[counter_position] += 1; - } else { - if counter_position == 3 { - if is_finder_pattern(&counters) { - return Ok( : vec![i32; 2] = vec![pattern_start, x, ] - ); - } - pattern_start += counters[0] + counters[1]; - counters[0] = counters[2]; - counters[1] = counters[3]; - counters[2] = 0; - counters[3] = 0; - counter_position -= 1; - } else { - counter_position += 1; - } - counters[counter_position] = 1; - is_white = !is_white; - } - } - x += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - fn parse_found_finder_pattern(&self, row: &BitArray, row_number: i32, right: bool, start_end: &Vec) -> /* throws NotFoundException */Result> { - // Actually we found elements 2-5 - let first_is_black: bool = row.get(start_end[0]); - let first_element_start: i32 = start_end[0] - 1; - // Locate element 1 - while first_element_start >= 0 && first_is_black != row.get(first_element_start) { - first_element_start -= 1; - } - first_element_start += 1; - let first_counter: i32 = start_end[0] - first_element_start; - // Make 'counters' hold 1-4 - let mut counters: Vec = get_decode_finder_counters(); - System::arraycopy(&counters, 0, &counters, 1, counters.len() - 1); - counters[0] = first_counter; - let value: i32 = parse_finder_value(&counters, &FINDER_PATTERNS); - let mut start: i32 = first_element_start; - let mut end: i32 = start_end[1]; - if right { - // row is actually reversed - start = row.get_size() - 1 - start; - end = row.get_size() - 1 - end; - } - return Ok(FinderPattern::new(value, : vec![i32; 2] = vec![first_element_start, start_end[1], ] - , start, end, row_number)); - } - - fn adjust_odd_even_counts(&self, outside_char: bool, num_modules: i32) -> /* throws NotFoundException */Result> { - let odd_sum: i32 = MathUtils::sum(&get_odd_counts()); - let even_sum: i32 = MathUtils::sum(&get_even_counts()); - let increment_odd: bool = false; - let decrement_odd: bool = false; - let increment_even: bool = false; - let decrement_even: bool = false; - if outside_char { - if odd_sum > 12 { - decrement_odd = true; - } else if odd_sum < 4 { - increment_odd = true; - } - if even_sum > 12 { - decrement_even = true; - } else if even_sum < 4 { - increment_even = true; - } - } else { - if odd_sum > 11 { - decrement_odd = true; - } else if odd_sum < 5 { - increment_odd = true; - } - if even_sum > 10 { - decrement_even = true; - } else if even_sum < 4 { - increment_even = true; - } - } - let mismatch: i32 = odd_sum + even_sum - num_modules; - let odd_parity_bad: bool = (odd_sum & 0x01) == ( if outside_char { 1 } else { 0 }); - let even_parity_bad: bool = (even_sum & 0x01) == 1; - /*if (mismatch == 2) { - if (!(oddParityBad && evenParityBad)) { - throw ReaderException.getInstance(); - } - decrementOdd = true; - decrementEven = true; - } else if (mismatch == -2) { - if (!(oddParityBad && evenParityBad)) { - throw ReaderException.getInstance(); - } - incrementOdd = true; - incrementEven = true; - } else */ - match mismatch { - 1 => - { - if odd_parity_bad { - if even_parity_bad { - throw NotFoundException::get_not_found_instance(); - } - decrement_odd = true; - } else { - if !even_parity_bad { - throw NotFoundException::get_not_found_instance(); - } - decrement_even = true; - } - break; - } - -1 => - { - if odd_parity_bad { - if even_parity_bad { - throw NotFoundException::get_not_found_instance(); - } - increment_odd = true; - } else { - if !even_parity_bad { - throw NotFoundException::get_not_found_instance(); - } - increment_even = true; - } - break; - } - 0 => - { - if odd_parity_bad { - if !even_parity_bad { - throw NotFoundException::get_not_found_instance(); - } - // Both bad - if odd_sum < even_sum { - increment_odd = true; - decrement_even = true; - } else { - decrement_odd = true; - increment_even = true; - } - } else { - if even_parity_bad { - throw NotFoundException::get_not_found_instance(); - } - // Nothing to do! - } - break; - } - _ => - { - throw NotFoundException::get_not_found_instance(); - } - } - if increment_odd { - if decrement_odd { - throw NotFoundException::get_not_found_instance(); - } - increment(&get_odd_counts(), &get_odd_rounding_errors()); - } - if decrement_odd { - decrement(&get_odd_counts(), &get_odd_rounding_errors()); - } - if increment_even { - if decrement_even { - throw NotFoundException::get_not_found_instance(); - } - increment(&get_even_counts(), &get_odd_rounding_errors()); - } - if decrement_even { - decrement(&get_even_counts(), &get_even_rounding_errors()); - } - } -} - -// NEW FILE: r_s_s_utils.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss; - -/** Adapted from listings in ISO/IEC 24724 Appendix B and Appendix G. */ -pub struct RSSUtils { -} - -impl RSSUtils { - - fn new() -> RSSUtils { - } - - pub fn get_r_s_svalue( widths: &Vec, max_width: i32, no_narrow: bool) -> i32 { - let mut n: i32 = 0; - for let width: i32 in widths { - n += width; - } - let mut val: i32 = 0; - let narrow_mask: i32 = 0; - let elements: i32 = widths.len(); - { - let mut bar: i32 = 0; - while bar < elements - 1 { - { - let elm_width: i32; - { - elm_width = 1; - narrow_mask |= 1 << bar; - while elm_width < widths[bar] { - { - let sub_val: i32 = ::combins(n - elm_width - 1, elements - bar - 2); - if no_narrow && (narrow_mask == 0) && (n - elm_width - (elements - bar - 1) >= elements - bar - 1) { - sub_val -= ::combins(n - elm_width - (elements - bar), elements - bar - 2); - } - if elements - bar - 1 > 1 { - let less_val: i32 = 0; - { - let mxw_element: i32 = n - elm_width - (elements - bar - 2); - while mxw_element > max_width { - { - less_val += ::combins(n - elm_width - mxw_element - 1, elements - bar - 3); - } - mxw_element -= 1; - } - } - - sub_val -= less_val * (elements - 1 - bar); - } else if n - elm_width > max_width { - sub_val -= 1; - } - val += sub_val; - } - elm_width += 1; - narrow_mask &= ~(1 << bar); - } - } - - n -= elm_width; - } - bar += 1; - } - } - - return val; - } - - fn combins( n: i32, r: i32) -> i32 { - let max_denom: i32; - let min_denom: i32; - if n - r > r { - min_denom = r; - max_denom = n - r; - } else { - min_denom = n - r; - max_denom = r; - } - let mut val: i32 = 1; - let mut j: i32 = 1; - { - let mut i: i32 = n; - while i > max_denom { - { - val *= i; - if j <= min_denom { - val /= j; - j += 1; - } - } - i -= 1; - } - } - - while j <= min_denom { - val /= j; - j += 1; - } - return val; - } -} - diff --git a/src/oned/rss/expanded.rs b/src/oned/rss/expanded.rs deleted file mode 100644 index 0de6532..0000000 --- a/src/oned/rss/expanded.rs +++ /dev/null @@ -1,1044 +0,0 @@ -use crate::{BarcodeFormat,DecodeHintType,FormatException,NotFoundException,RXingResult,ResultMetadataType,ResultPoint}; -use crate::common::BitArray; -use crate::oned::rss::{DataCharacter,FinderPattern,AbstractRSSReader,RSSUtils}; -use crate::oned::rss::expanded::decoders::AbstractExpandedDecoder; - - -// NEW FILE: bit_array_builder.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -struct BitArrayBuilder { -} - -impl BitArrayBuilder { - - fn new() -> BitArrayBuilder { - } - - fn build_bit_array( pairs: &List) -> BitArray { - let char_number: i32 = (pairs.size() * 2) - 1; - if pairs.get(pairs.size() - 1).get_right_char() == null { - char_number -= 1; - } - let size: i32 = 12 * char_number; - let binary: BitArray = BitArray::new(size); - let acc_pos: i32 = 0; - let first_pair: ExpandedPair = pairs.get(0); - let first_value: i32 = first_pair.get_right_char().get_value(); - { - let mut i: i32 = 11; - while i >= 0 { - { - if (first_value & (1 << i)) != 0 { - binary.set(acc_pos); - } - acc_pos += 1; - } - i -= 1; - } - } - - { - let mut i: i32 = 1; - while i < pairs.size() { - { - let current_pair: ExpandedPair = pairs.get(i); - let left_value: i32 = current_pair.get_left_char().get_value(); - { - let mut j: i32 = 11; - while j >= 0 { - { - if (left_value & (1 << j)) != 0 { - binary.set(acc_pos); - } - acc_pos += 1; - } - j -= 1; - } - } - - if current_pair.get_right_char() != null { - let right_value: i32 = current_pair.get_right_char().get_value(); - { - let mut j: i32 = 11; - while j >= 0 { - { - if (right_value & (1 << j)) != 0 { - binary.set(acc_pos); - } - acc_pos += 1; - } - j -= 1; - } - } - - } - } - i += 1; - } - } - - return binary; - } -} - -// NEW FILE: expanded_pair.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -struct ExpandedPair { - - let left_char: DataCharacter; - - let right_char: DataCharacter; - - let finder_pattern: FinderPattern; -} - -impl ExpandedPair { - - fn new( left_char: &DataCharacter, right_char: &DataCharacter, finder_pattern: &FinderPattern) -> ExpandedPair { - let .leftChar = left_char; - let .rightChar = right_char; - let .finderPattern = finder_pattern; - } - - fn get_left_char(&self) -> DataCharacter { - return self.leftChar; - } - - fn get_right_char(&self) -> DataCharacter { - return self.rightChar; - } - - fn get_finder_pattern(&self) -> FinderPattern { - return self.finderPattern; - } - - fn must_be_last(&self) -> bool { - return self.rightChar == null; - } - - pub fn to_string(&self) -> String { - return format!("[ {} , {} : {} ]", self.left_char, self.right_char, ( if self.finder_pattern == null { "null" } else { self.finder_pattern.get_value() })); - } - - pub fn equals(&self, o: &Object) -> bool { - if !(o instanceof ExpandedPair) { - return false; - } - let that: ExpandedPair = o as ExpandedPair; - return Objects::equals(self.left_char, that.leftChar) && Objects::equals(self.right_char, that.rightChar) && Objects::equals(self.finder_pattern, that.finderPattern); - } - - pub fn hash_code(&self) -> i32 { - return Objects::hash_code(self.left_char) ^ Objects::hash_code(self.right_char) ^ Objects::hash_code(self.finder_pattern); - } -} - -// NEW FILE: expanded_row.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded; - -/** - * One row of an RSS Expanded Stacked symbol, consisting of 1+ expanded pairs. - */ -struct ExpandedRow { - - let pairs: List; - - let row_number: i32; -} - -impl ExpandedRow { - - fn new( pairs: &List, row_number: i32) -> ExpandedRow { - let .pairs = ArrayList<>::new(&pairs); - let .rowNumber = row_number; - } - - fn get_pairs(&self) -> List { - return self.pairs; - } - - fn get_row_number(&self) -> i32 { - return self.rowNumber; - } - - fn is_equivalent(&self, other_pairs: &List) -> bool { - return self.pairs.equals(&other_pairs); - } - - pub fn to_string(&self) -> String { - return format!("{ {} }", self.pairs); - } - - /** - * Two rows are equal if they contain the same pairs in the same order. - */ - pub fn equals(&self, o: &Object) -> bool { - if !(o instanceof ExpandedRow) { - return false; - } - let that: ExpandedRow = o as ExpandedRow; - return self.pairs.equals(that.pairs); - } - - pub fn hash_code(&self) -> i32 { - return self.pairs.hash_code(); - } -} - -// NEW FILE: r_s_s_expanded_reader.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - - const SYMBOL_WIDEST: vec![Vec; 5] = vec![7, 5, 4, 3, 1, ] -; - - const EVEN_TOTAL_SUBSET: vec![Vec; 5] = vec![4, 20, 52, 104, 204, ] -; - - const GSUM: vec![Vec; 5] = vec![0, 348, 1388, 2948, 3988, ] -; - - const FINDER_PATTERNS: vec![vec![Vec>; 4]; 6] = vec![// A -vec![1, 8, 4, 1, ] -, // B -vec![3, 6, 4, 1, ] -, // C -vec![3, 4, 6, 1, ] -, // D -vec![3, 2, 8, 1, ] -, // E -vec![2, 6, 5, 1, ] -, // F -vec![2, 2, 9, 1, ] -, ] -; - - const WEIGHTS: vec![vec![Vec>; 8]; 23] = vec![vec![1, 3, 9, 27, 81, 32, 96, 77, ] -, vec![20, 60, 180, 118, 143, 7, 21, 63, ] -, vec![189, 145, 13, 39, 117, 140, 209, 205, ] -, vec![193, 157, 49, 147, 19, 57, 171, 91, ] -, vec![62, 186, 136, 197, 169, 85, 44, 132, ] -, vec![185, 133, 188, 142, 4, 12, 36, 108, ] -, vec![113, 128, 173, 97, 80, 29, 87, 50, ] -, vec![150, 28, 84, 41, 123, 158, 52, 156, ] -, vec![46, 138, 203, 187, 139, 206, 196, 166, ] -, vec![76, 17, 51, 153, 37, 111, 122, 155, ] -, vec![43, 129, 176, 106, 107, 110, 119, 146, ] -, vec![16, 48, 144, 10, 30, 90, 59, 177, ] -, vec![109, 116, 137, 200, 178, 112, 125, 164, ] -, vec![70, 210, 208, 202, 184, 130, 179, 115, ] -, vec![134, 191, 151, 31, 93, 68, 204, 190, ] -, vec![148, 22, 66, 198, 172, 94, 71, 2, ] -, vec![6, 18, 54, 162, 64, 192, 154, 40, ] -, vec![120, 149, 25, 75, 14, 42, 126, 167, ] -, vec![79, 26, 78, 23, 69, 207, 199, 175, ] -, vec![103, 98, 83, 38, 114, 131, 182, 124, ] -, vec![161, 61, 183, 127, 170, 88, 53, 159, ] -, vec![55, 165, 73, 8, 24, 72, 5, 15, ] -, vec![45, 135, 194, 160, 58, 174, 100, 89, ] -, ] -; - - const FINDER_PAT_A: i32 = 0; - - const FINDER_PAT_B: i32 = 1; - - const FINDER_PAT_C: i32 = 2; - - const FINDER_PAT_D: i32 = 3; - - const FINDER_PAT_E: i32 = 4; - - const FINDER_PAT_F: i32 = 5; - - const FINDER_PATTERN_SEQUENCES: vec![vec![Vec>; 11]; 10] = vec![vec![FINDER_PAT_A, FINDER_PAT_A, ] -, vec![FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, ] -, vec![FINDER_PAT_A, FINDER_PAT_C, FINDER_PAT_B, FINDER_PAT_D, ] -, vec![FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_C, ] -, vec![FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_D, FINDER_PAT_F, ] -, vec![FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F, ] -, vec![FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_D, ] -, vec![FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_E, ] -, vec![FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F, ] -, vec![FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F, ] -, ] -; - - const MAX_PAIRS: i32 = 11; -pub struct RSSExpandedReader { - super: AbstractRSSReader; - - let pairs: List = ArrayList<>::new(MAX_PAIRS); - - let rows: List = ArrayList<>::new(); - - let start_end: [i32; 2] = [0; 2]; - - let start_from_even: bool; -} - -impl RSSExpandedReader { - - pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException, FormatException */Result> { - // Rows can start with even pattern in case in prev rows there where odd number of patters. - // So lets try twice - self.pairs.clear(); - self.startFromEven = false; - let tryResult1 = 0; - 'try1: loop { - { - return Ok(::construct_result(&self.decode_row2pairs(row_number, row))); - } - break 'try1 - } - match tryResult1 { - catch ( e: &NotFoundException) { - } 0 => break - } - - self.pairs.clear(); - self.startFromEven = true; - return Ok(::construct_result(&self.decode_row2pairs(row_number, row))); - } - - pub fn reset(&self) { - self.pairs.clear(); - self.rows.clear(); - } - - // Not private for testing - fn decode_row2pairs(&self, row_number: i32, row: &BitArray) -> /* throws NotFoundException */Result, Rc> { - let mut done: bool = false; - while !done { - let tryResult1 = 0; - 'try1: loop { - { - self.pairs.add(&self.retrieve_next_pair(row, self.pairs, row_number)); - } - break 'try1 - } - match tryResult1 { - catch ( nfe: &NotFoundException) { - if self.pairs.is_empty() { - throw nfe; - } - done = true; - } 0 => break - } - - } - // TODO: verify sequence of finder patterns as in checkPairSequence() - if self.check_checksum() { - return Ok(self.pairs); - } - let try_stacked_decode: bool = !self.rows.is_empty(); - // TODO: deal with reversed rows - self.store_row(row_number); - if try_stacked_decode { - // When the image is 180-rotated, then rows are sorted in wrong direction. - // Try twice with both the directions. - let mut ps: List = self.check_rows(false); - if ps != null { - return Ok(ps); - } - ps = self.check_rows(true); - if ps != null { - return Ok(ps); - } - } - throw NotFoundException::get_not_found_instance(); - } - - fn check_rows(&self, reverse: bool) -> List { - // Stacked barcode can have up to 11 rows, so 25 seems reasonable enough - if self.rows.size() > 25 { - // We will never have a chance to get result, so clear it - self.rows.clear(); - return Ok(null); - } - self.pairs.clear(); - if reverse { - Collections::reverse(self.rows); - } - let mut ps: List = null; - let tryResult1 = 0; - 'try1: loop { - { - ps = self.check_rows(ArrayList<>::new(), 0); - } - break 'try1 - } - match tryResult1 { - catch ( e: &NotFoundException) { - } 0 => break - } - - if reverse { - Collections::reverse(self.rows); - } - return Ok(ps); - } - - // Try to construct a valid rows sequence - // Recursion is used to implement backtracking - fn check_rows(&self, collected_rows: &List, current_row: i32) -> /* throws NotFoundException */Result, Rc> { - { - let mut i: i32 = current_row; - while i < self.rows.size() { - { - let row: ExpandedRow = self.rows.get(i); - self.pairs.clear(); - for let collected_row: ExpandedRow in collected_rows { - self.pairs.add_all(&collected_row.get_pairs()); - } - self.pairs.add_all(&row.get_pairs()); - if ::is_valid_sequence(self.pairs) { - if self.check_checksum() { - return Ok(self.pairs); - } - let rs: List = ArrayList<>::new(&collected_rows); - rs.add(row); - let tryResult1 = 0; - 'try1: loop { - { - // Recursion: try to add more rows - return Ok(self.check_rows(&rs, i + 1)); - } - break 'try1 - } - match tryResult1 { - catch ( e: &NotFoundException) { - } 0 => break - } - - } - } - i += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - // Whether the pairs form a valid find pattern sequence, - // either complete or a prefix - fn is_valid_sequence( pairs: &List) -> bool { - for let sequence: Vec in FINDER_PATTERN_SEQUENCES { - if pairs.size() <= sequence.len() { - let mut stop: bool = true; - { - let mut j: i32 = 0; - while j < pairs.size() { - { - if pairs.get(j).get_finder_pattern().get_value() != sequence[j] { - stop = false; - break; - } - } - j += 1; - } - } - - if stop { - return true; - } - } - } - return false; - } - - fn store_row(&self, row_number: i32) { - // Discard if duplicate above or below; otherwise insert in order by row number. - let insert_pos: i32 = 0; - let prev_is_same: bool = false; - let next_is_same: bool = false; - while insert_pos < self.rows.size() { - let erow: ExpandedRow = self.rows.get(insert_pos); - if erow.get_row_number() > row_number { - next_is_same = erow.is_equivalent(self.pairs); - break; - } - prev_is_same = erow.is_equivalent(self.pairs); - insert_pos += 1; - } - if next_is_same || prev_is_same { - return; - } - // Check whether the row is part of an already detected row - if ::is_partial_row(self.pairs, self.rows) { - return; - } - self.rows.add(insert_pos, ExpandedRow::new(self.pairs, row_number)); - ::remove_partial_rows(self.pairs, self.rows); - } - - // Remove all the rows that contains only specified pairs - fn remove_partial_rows( pairs: &Collection, rows: &Collection) { - { - let iterator: Iterator = rows.iterator(); - while iterator.has_next(){ - let r: ExpandedRow = iterator.next(); - if r.get_pairs().size() != pairs.size() { - let all_found: bool = true; - for let p: ExpandedPair in r.get_pairs() { - if !pairs.contains(p) { - all_found = false; - break; - } - } - if all_found { - // 'pairs' contains all the pairs from the row 'r' - iterator.remove(); - } - } - } - } - - } - - // Returns true when one of the rows already contains all the pairs - fn is_partial_row( pairs: &Iterable, rows: &Iterable) -> bool { - for let r: ExpandedRow in rows { - let all_found: bool = true; - for let p: ExpandedPair in pairs { - let mut found: bool = false; - for let pp: ExpandedPair in r.get_pairs() { - if p.equals(pp) { - found = true; - break; - } - } - if !found { - all_found = false; - break; - } - } - if all_found { - // the row 'r' contain all the pairs from 'pairs' - return true; - } - } - return false; - } - - // Only used for unit testing - fn get_rows(&self) -> List { - return self.rows; - } - - // Not private for unit testing - fn construct_result( pairs: &List) -> /* throws NotFoundException, FormatException */Result> { - let binary: BitArray = BitArrayBuilder::build_bit_array(&pairs); - let decoder: AbstractExpandedDecoder = AbstractExpandedDecoder::create_decoder(binary); - let resulting_string: String = decoder.parse_information(); - let first_points: Vec = pairs.get(0).get_finder_pattern().get_result_points(); - let last_points: Vec = pairs.get(pairs.size() - 1).get_finder_pattern().get_result_points(); - let result: Result = Result::new(&resulting_string, null, : vec![ResultPoint; 4] = vec![first_points[0], first_points[1], last_points[0], last_points[1], ] - , BarcodeFormat::RSS_EXPANDED); - result.put_metadata(ResultMetadataType::SYMBOLOGY_IDENTIFIER, "]e0"); - return Ok(result); - } - - fn check_checksum(&self) -> bool { - let first_pair: ExpandedPair = self.pairs.get(0); - let check_character: DataCharacter = first_pair.get_left_char(); - let first_character: DataCharacter = first_pair.get_right_char(); - if first_character == null { - return false; - } - let mut checksum: i32 = first_character.get_checksum_portion(); - let mut s: i32 = 2; - { - let mut i: i32 = 1; - while i < self.pairs.size() { - { - let current_pair: ExpandedPair = self.pairs.get(i); - checksum += current_pair.get_left_char().get_checksum_portion(); - s += 1; - let current_right_char: DataCharacter = current_pair.get_right_char(); - if current_right_char != null { - checksum += current_right_char.get_checksum_portion(); - s += 1; - } - } - i += 1; - } - } - - checksum %= 211; - let check_character_value: i32 = 211 * (s - 4) + checksum; - return check_character_value == check_character.get_value(); - } - - fn get_next_second_bar( row: &BitArray, initial_pos: i32) -> i32 { - let current_pos: i32; - if row.get(initial_pos) { - current_pos = row.get_next_unset(initial_pos); - current_pos = row.get_next_set(current_pos); - } else { - current_pos = row.get_next_set(initial_pos); - current_pos = row.get_next_unset(current_pos); - } - return current_pos; - } - - // not private for testing - fn retrieve_next_pair(&self, row: &BitArray, previous_pairs: &List, row_number: i32) -> /* throws NotFoundException */Result> { - let is_odd_pattern: bool = previous_pairs.size() % 2 == 0; - if self.start_from_even { - is_odd_pattern = !is_odd_pattern; - } - let mut pattern: FinderPattern; - let keep_finding: bool = true; - let forced_offset: i32 = -1; - loop { { - self.find_next_pair(row, &previous_pairs, forced_offset); - pattern = self.parse_found_finder_pattern(row, row_number, is_odd_pattern); - if pattern == null { - forced_offset = ::get_next_second_bar(row, self.startEnd[0]); - } else { - keep_finding = false; - } - }if !(keep_finding) break;} - // When stacked symbol is split over multiple rows, there's no way to guess if this pair can be last or not. - // boolean mayBeLast = checkPairSequence(previousPairs, pattern); - let left_char: DataCharacter = self.decode_data_character(row, pattern, is_odd_pattern, true); - if !previous_pairs.is_empty() && previous_pairs.get(previous_pairs.size() - 1).must_be_last() { - throw NotFoundException::get_not_found_instance(); - } - let right_char: DataCharacter; - let tryResult1 = 0; - 'try1: loop { - { - right_char = self.decode_data_character(row, pattern, is_odd_pattern, false); - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &NotFoundException) { - right_char = null; - } 0 => break - } - - return Ok(ExpandedPair::new(left_char, right_char, pattern)); - } - - fn find_next_pair(&self, row: &BitArray, previous_pairs: &List, forced_offset: i32) -> /* throws NotFoundException */Result> { - let mut counters: Vec = self.get_decode_finder_counters(); - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - let width: i32 = row.get_size(); - let row_offset: i32; - if forced_offset >= 0 { - row_offset = forced_offset; - } else if previous_pairs.is_empty() { - row_offset = 0; - } else { - let last_pair: ExpandedPair = previous_pairs.get(previous_pairs.size() - 1); - row_offset = last_pair.get_finder_pattern().get_start_end()[1]; - } - let searching_even_pair: bool = previous_pairs.size() % 2 != 0; - if self.start_from_even { - searching_even_pair = !searching_even_pair; - } - let is_white: bool = false; - while row_offset < width { - is_white = !row.get(row_offset); - if !is_white { - break; - } - row_offset += 1; - } - let counter_position: i32 = 0; - let pattern_start: i32 = row_offset; - { - let mut x: i32 = row_offset; - while x < width { - { - if row.get(x) != is_white { - counters[counter_position] += 1; - } else { - if counter_position == 3 { - if searching_even_pair { - ::reverse_counters(&counters); - } - if is_finder_pattern(&counters) { - self.startEnd[0] = pattern_start; - self.startEnd[1] = x; - return; - } - if searching_even_pair { - ::reverse_counters(&counters); - } - pattern_start += counters[0] + counters[1]; - counters[0] = counters[2]; - counters[1] = counters[3]; - counters[2] = 0; - counters[3] = 0; - counter_position -= 1; - } else { - counter_position += 1; - } - counters[counter_position] = 1; - is_white = !is_white; - } - } - x += 1; - } - } - - throw NotFoundException::get_not_found_instance(); - } - - fn reverse_counters( counters: &Vec) { - let mut length: i32 = counters.len(); - { - let mut i: i32 = 0; - while i < length / 2 { - { - let tmp: i32 = counters[i]; - counters[i] = counters[length - i - 1]; - counters[length - i - 1] = tmp; - } - i += 1; - } - } - - } - - fn parse_found_finder_pattern(&self, row: &BitArray, row_number: i32, odd_pattern: bool) -> FinderPattern { - // Actually we found elements 2-5. - let first_counter: i32; - let mut start: i32; - let mut end: i32; - if odd_pattern { - // If pattern number is odd, we need to locate element 1 *before* the current block. - let first_element_start: i32 = self.startEnd[0] - 1; - // Locate element 1 - while first_element_start >= 0 && !row.get(first_element_start) { - first_element_start -= 1; - } - first_element_start += 1; - first_counter = self.startEnd[0] - first_element_start; - start = first_element_start; - end = self.startEnd[1]; - } else { - // If pattern number is even, the pattern is reversed, so we need to locate element 1 *after* the current block. - start = self.startEnd[0]; - end = row.get_next_unset(self.startEnd[1] + 1); - first_counter = end - self.startEnd[1]; - } - // Make 'counters' hold 1-4 - let mut counters: Vec = self.get_decode_finder_counters(); - System::arraycopy(&counters, 0, &counters, 1, counters.len() - 1); - counters[0] = first_counter; - let mut value: i32; - let tryResult1 = 0; - 'try1: loop { - { - value = parse_finder_value(&counters, &FINDER_PATTERNS); - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &NotFoundException) { - return null; - } 0 => break - } - - return FinderPattern::new(value, : vec![i32; 2] = vec![start, end, ] - , start, end, row_number); - } - - fn decode_data_character(&self, row: &BitArray, pattern: &FinderPattern, is_odd_pattern: bool, left_char: bool) -> /* throws NotFoundException */Result> { - let mut counters: Vec = self.get_data_character_counters(); - Arrays::fill(&counters, 0); - if left_char { - record_pattern_in_reverse(row, pattern.get_start_end()[0], &counters); - } else { - record_pattern(row, pattern.get_start_end()[1], &counters); - // reverse it - { - let mut i: i32 = 0, let mut j: i32 = counters.len() - 1; - while i < j { - { - let temp: i32 = counters[i]; - counters[i] = counters[j]; - counters[j] = temp; - } - i += 1; - j -= 1; - } - } - - } - //counters[] has the pixels of the module - //left and right data characters have all the same length - let num_modules: i32 = 17; - let element_width: f32 = MathUtils::sum(&counters) / num_modules as f32; - // Sanity check: element width for pattern and the character should match - let expected_element_width: f32 = (pattern.get_start_end()[1] - pattern.get_start_end()[0]) / 15.0f; - if Math::abs(element_width - expected_element_width) / expected_element_width > 0.3f { - throw NotFoundException::get_not_found_instance(); - } - let odd_counts: Vec = self.get_odd_counts(); - let even_counts: Vec = self.get_even_counts(); - let odd_rounding_errors: Vec = self.get_odd_rounding_errors(); - let even_rounding_errors: Vec = self.get_even_rounding_errors(); - { - let mut i: i32 = 0; - while i < counters.len() { - { - let value: f32 = 1.0f * counters[i] / element_width; - // Round - let mut count: i32 = (value + 0.5f) as i32; - if count < 1 { - if value < 0.3f { - throw NotFoundException::get_not_found_instance(); - } - count = 1; - } else if count > 8 { - if value > 8.7f { - throw NotFoundException::get_not_found_instance(); - } - count = 8; - } - let mut offset: i32 = i / 2; - if (i & 0x01) == 0 { - odd_counts[offset] = count; - odd_rounding_errors[offset] = value - count; - } else { - even_counts[offset] = count; - even_rounding_errors[offset] = value - count; - } - } - i += 1; - } - } - - self.adjust_odd_even_counts(num_modules); - let weight_row_number: i32 = 4 * pattern.get_value() + ( if is_odd_pattern { 0 } else { 2 }) + ( if left_char { 0 } else { 1 }) - 1; - let odd_sum: i32 = 0; - let odd_checksum_portion: i32 = 0; - { - let mut i: i32 = odd_counts.len() - 1; - while i >= 0 { - { - if ::is_not_a1left(pattern, is_odd_pattern, left_char) { - let weight: i32 = WEIGHTS[weight_row_number][2 * i]; - odd_checksum_portion += odd_counts[i] * weight; - } - odd_sum += odd_counts[i]; - } - i -= 1; - } - } - - let even_checksum_portion: i32 = 0; - { - let mut i: i32 = even_counts.len() - 1; - while i >= 0 { - { - if ::is_not_a1left(pattern, is_odd_pattern, left_char) { - let weight: i32 = WEIGHTS[weight_row_number][2 * i + 1]; - even_checksum_portion += even_counts[i] * weight; - } - } - i -= 1; - } - } - - let checksum_portion: i32 = odd_checksum_portion + even_checksum_portion; - if (odd_sum & 0x01) != 0 || odd_sum > 13 || odd_sum < 4 { - throw NotFoundException::get_not_found_instance(); - } - let group: i32 = (13 - odd_sum) / 2; - let odd_widest: i32 = SYMBOL_WIDEST[group]; - let even_widest: i32 = 9 - odd_widest; - let v_odd: i32 = RSSUtils::get_r_s_svalue(&odd_counts, odd_widest, true); - let v_even: i32 = RSSUtils::get_r_s_svalue(&even_counts, even_widest, false); - let t_even: i32 = EVEN_TOTAL_SUBSET[group]; - let g_sum: i32 = GSUM[group]; - let value: i32 = v_odd * t_even + v_even + g_sum; - return Ok(DataCharacter::new(value, checksum_portion)); - } - - fn is_not_a1left( pattern: &FinderPattern, is_odd_pattern: bool, left_char: bool) -> bool { - // A1: pattern.getValue is 0 (A), and it's an oddPattern, and it is a left char - return !(pattern.get_value() == 0 && is_odd_pattern && left_char); - } - - fn adjust_odd_even_counts(&self, num_modules: i32) -> /* throws NotFoundException */Result> { - let odd_sum: i32 = MathUtils::sum(&self.get_odd_counts()); - let even_sum: i32 = MathUtils::sum(&self.get_even_counts()); - let increment_odd: bool = false; - let decrement_odd: bool = false; - if odd_sum > 13 { - decrement_odd = true; - } else if odd_sum < 4 { - increment_odd = true; - } - let increment_even: bool = false; - let decrement_even: bool = false; - if even_sum > 13 { - decrement_even = true; - } else if even_sum < 4 { - increment_even = true; - } - let mismatch: i32 = odd_sum + even_sum - num_modules; - let odd_parity_bad: bool = (odd_sum & 0x01) == 1; - let even_parity_bad: bool = (even_sum & 0x01) == 0; - match mismatch { - 1 => - { - if odd_parity_bad { - if even_parity_bad { - throw NotFoundException::get_not_found_instance(); - } - decrement_odd = true; - } else { - if !even_parity_bad { - throw NotFoundException::get_not_found_instance(); - } - decrement_even = true; - } - break; - } - -1 => - { - if odd_parity_bad { - if even_parity_bad { - throw NotFoundException::get_not_found_instance(); - } - increment_odd = true; - } else { - if !even_parity_bad { - throw NotFoundException::get_not_found_instance(); - } - increment_even = true; - } - break; - } - 0 => - { - if odd_parity_bad { - if !even_parity_bad { - throw NotFoundException::get_not_found_instance(); - } - // Both bad - if odd_sum < even_sum { - increment_odd = true; - decrement_even = true; - } else { - decrement_odd = true; - increment_even = true; - } - } else { - if even_parity_bad { - throw NotFoundException::get_not_found_instance(); - } - // Nothing to do! - } - break; - } - _ => - { - throw NotFoundException::get_not_found_instance(); - } - } - if increment_odd { - if decrement_odd { - throw NotFoundException::get_not_found_instance(); - } - increment(&self.get_odd_counts(), &self.get_odd_rounding_errors()); - } - if decrement_odd { - decrement(&self.get_odd_counts(), &self.get_odd_rounding_errors()); - } - if increment_even { - if decrement_even { - throw NotFoundException::get_not_found_instance(); - } - increment(&self.get_even_counts(), &self.get_odd_rounding_errors()); - } - if decrement_even { - decrement(&self.get_even_counts(), &self.get_even_rounding_errors()); - } - } -} - diff --git a/src/oned/rss/expanded/decoders.rs b/src/oned/rss/expanded/decoders.rs deleted file mode 100644 index 36fbd64..0000000 --- a/src/oned/rss/expanded/decoders.rs +++ /dev/null @@ -1,1795 +0,0 @@ -use crate::{FormatException,NotFoundException}; -use crate::common::BitArray; - - - - -// NEW FILE: a_i013103decoder.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -struct AI013103decoder { - super: AI013x0xDecoder; -} - -impl AI013103decoder { - - fn new( information: &BitArray) -> AI013103decoder { - super(information); - } - - pub fn add_weight_code(&self, buf: &StringBuilder, weight: i32) { - buf.append("(3103)"); - } - - pub fn check_weight(&self, weight: i32) -> i32 { - return weight; - } -} - -// NEW FILE: a_i01320x_decoder.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -struct AI01320xDecoder { - super: AI013x0xDecoder; -} - -impl AI01320xDecoder { - - fn new( information: &BitArray) -> AI01320xDecoder { - super(information); - } - - pub fn add_weight_code(&self, buf: &StringBuilder, weight: i32) { - if weight < 10000 { - buf.append("(3202)"); - } else { - buf.append("(3203)"); - } - } - - pub fn check_weight(&self, weight: i32) -> i32 { - if weight < 10000 { - return weight; - } - return weight - 10000; - } -} - -// NEW FILE: a_i01392x_decoder.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ - - const HEADER_SIZE: i32 = 5 + 1 + 2; - - const LAST_DIGIT_SIZE: i32 = 2; -struct AI01392xDecoder { - super: AI01decoder; -} - -impl AI01392xDecoder { - - fn new( information: &BitArray) -> AI01392xDecoder { - super(information); - } - - pub fn parse_information(&self) -> /* throws NotFoundException, FormatException */Result> { - if self.get_information().get_size() < HEADER_SIZE + GTIN_SIZE { - throw NotFoundException::get_not_found_instance(); - } - let buf: StringBuilder = StringBuilder::new(); - encode_compressed_gtin(&buf, HEADER_SIZE); - let last_a_idigit: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE); - buf.append("(392"); - buf.append(last_a_idigit); - buf.append(')'); - let decoded_information: DecodedInformation = self.get_general_decoder().decode_general_purpose_field(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, null); - buf.append(&decoded_information.get_new_string()); - return Ok(buf.to_string()); - } -} - -// NEW FILE: a_i01393x_decoder.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ - - const HEADER_SIZE: i32 = 5 + 1 + 2; - - const LAST_DIGIT_SIZE: i32 = 2; - - const FIRST_THREE_DIGITS_SIZE: i32 = 10; -struct AI01393xDecoder { - super: AI01decoder; -} - -impl AI01393xDecoder { - - fn new( information: &BitArray) -> AI01393xDecoder { - super(information); - } - - pub fn parse_information(&self) -> /* throws NotFoundException, FormatException */Result> { - if self.get_information().get_size() < HEADER_SIZE + GTIN_SIZE { - throw NotFoundException::get_not_found_instance(); - } - let buf: StringBuilder = StringBuilder::new(); - encode_compressed_gtin(&buf, HEADER_SIZE); - let last_a_idigit: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE); - buf.append("(393"); - buf.append(last_a_idigit); - buf.append(')'); - let first_three_digits: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, FIRST_THREE_DIGITS_SIZE); - if first_three_digits / 100 == 0 { - buf.append('0'); - } - if first_three_digits / 10 == 0 { - buf.append('0'); - } - buf.append(first_three_digits); - let general_information: DecodedInformation = self.get_general_decoder().decode_general_purpose_field(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE + FIRST_THREE_DIGITS_SIZE, null); - buf.append(&general_information.get_new_string()); - return Ok(buf.to_string()); - } -} - -// NEW FILE: a_i013x0x1x_decoder.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - - const HEADER_SIZE: i32 = 7 + 1; - - const WEIGHT_SIZE: i32 = 20; - - const DATE_SIZE: i32 = 16; -struct AI013x0x1xDecoder { - super: AI01weightDecoder; - - let date_code: String; - - let first_a_idigits: String; -} - -impl AI013x0x1xDecoder { - - fn new( information: &BitArray, first_a_idigits: &String, date_code: &String) -> AI013x0x1xDecoder { - super(information); - let .dateCode = date_code; - let .firstAIdigits = first_a_idigits; - } - - pub fn parse_information(&self) -> /* throws NotFoundException */Result> { - if self.get_information().get_size() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE + DATE_SIZE { - throw NotFoundException::get_not_found_instance(); - } - let buf: StringBuilder = StringBuilder::new(); - encode_compressed_gtin(&buf, HEADER_SIZE); - encode_compressed_weight(&buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); - self.encode_compressed_date(&buf, HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE); - return Ok(buf.to_string()); - } - - fn encode_compressed_date(&self, buf: &StringBuilder, current_pos: i32) { - let numeric_date: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(current_pos, DATE_SIZE); - if numeric_date == 38400 { - return; - } - buf.append('('); - buf.append(self.dateCode); - buf.append(')'); - let day: i32 = numeric_date % 32; - numeric_date /= 32; - let month: i32 = numeric_date % 12 + 1; - numeric_date /= 12; - let year: i32 = numeric_date; - if year / 10 == 0 { - buf.append('0'); - } - buf.append(year); - if month / 10 == 0 { - buf.append('0'); - } - buf.append(month); - if day / 10 == 0 { - buf.append('0'); - } - buf.append(day); - } - - pub fn add_weight_code(&self, buf: &StringBuilder, weight: i32) { - buf.append('('); - buf.append(self.firstAIdigits); - buf.append(weight / 100000); - buf.append(')'); - } - - pub fn check_weight(&self, weight: i32) -> i32 { - return weight % 100000; - } -} - -// NEW FILE: a_i013x0x_decoder.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ - - const HEADER_SIZE: i32 = 4 + 1; - - const WEIGHT_SIZE: i32 = 15; -struct AI013x0xDecoder { - super: AI01weightDecoder; -} - -impl AI013x0xDecoder { - - fn new( information: &BitArray) -> AI013x0xDecoder { - super(information); - } - - pub fn parse_information(&self) -> /* throws NotFoundException */Result> { - if self.get_information().get_size() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE { - throw NotFoundException::get_not_found_instance(); - } - let buf: StringBuilder = StringBuilder::new(); - encode_compressed_gtin(&buf, HEADER_SIZE); - encode_compressed_weight(&buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); - return Ok(buf.to_string()); - } -} - -// NEW FILE: a_i01_and_other_a_is.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - -//first bit encodes the linkage flag, - const HEADER_SIZE: i32 = 1 + 1 + 2; -struct AI01AndOtherAIs { - super: AI01decoder; -} - -impl AI01AndOtherAIs { - - //the second one is the encodation method, and the other two are for the variable length - fn new( information: &BitArray) -> AI01AndOtherAIs { - super(information); - } - - pub fn parse_information(&self) -> /* throws NotFoundException, FormatException */Result> { - let buff: StringBuilder = StringBuilder::new(); - buff.append("(01)"); - let initial_gtin_position: i32 = buff.length(); - let first_gtin_digit: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(HEADER_SIZE, 4); - buff.append(first_gtin_digit); - self.encode_compressed_gtin_without_a_i(&buff, HEADER_SIZE + 4, initial_gtin_position); - return Ok(self.get_general_decoder().decode_all_codes(&buff, HEADER_SIZE + 44)); - } -} - -// NEW FILE: a_i01decoder.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - - const GTIN_SIZE: i32 = 40; -struct AI01decoder { - super: AbstractExpandedDecoder; -} - -impl AI01decoder { - - fn new( information: &BitArray) -> AI01decoder { - super(information); - } - - fn encode_compressed_gtin(&self, buf: &StringBuilder, current_pos: i32) { - buf.append("(01)"); - let initial_position: i32 = buf.length(); - buf.append('9'); - self.encode_compressed_gtin_without_a_i(&buf, current_pos, initial_position); - } - - fn encode_compressed_gtin_without_a_i(&self, buf: &StringBuilder, current_pos: i32, initial_buffer_position: i32) { - { - let mut i: i32 = 0; - while i < 4 { - { - let current_block: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(current_pos + 10 * i, 10); - if current_block / 100 == 0 { - buf.append('0'); - } - if current_block / 10 == 0 { - buf.append('0'); - } - buf.append(current_block); - } - i += 1; - } - } - - ::append_check_digit(&buf, initial_buffer_position); - } - - fn append_check_digit( buf: &StringBuilder, current_pos: i32) { - let check_digit: i32 = 0; - { - let mut i: i32 = 0; - while i < 13 { - { - let digit: i32 = buf.char_at(i + current_pos) - '0'; - check_digit += if (i & 0x01) == 0 { 3 * digit } else { digit }; - } - i += 1; - } - } - - check_digit = 10 - (check_digit % 10); - if check_digit == 10 { - check_digit = 0; - } - buf.append(check_digit); - } -} - -// NEW FILE: a_i01weight_decoder.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -struct AI01weightDecoder { - super: AI01decoder; -} - -impl AI01weightDecoder { - - fn new( information: &BitArray) -> AI01weightDecoder { - super(information); - } - - fn encode_compressed_weight(&self, buf: &StringBuilder, current_pos: i32, weight_size: i32) { - let original_weight_numeric: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(current_pos, weight_size); - self.add_weight_code(&buf, original_weight_numeric); - let weight_numeric: i32 = self.check_weight(original_weight_numeric); - let current_divisor: i32 = 100000; - { - let mut i: i32 = 0; - while i < 5 { - { - if weight_numeric / current_divisor == 0 { - buf.append('0'); - } - current_divisor /= 10; - } - i += 1; - } - } - - buf.append(weight_numeric); - } - - pub fn add_weight_code(&self, buf: &StringBuilder, weight: i32) ; - - pub fn check_weight(&self, weight: i32) -> i32 ; -} - -// NEW FILE: abstract_expanded_decoder.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -pub struct AbstractExpandedDecoder { - - let information: BitArray; - - let general_decoder: GeneralAppIdDecoder; -} - -impl AbstractExpandedDecoder { - - fn new( information: &BitArray) -> AbstractExpandedDecoder { - let .information = information; - let .generalDecoder = GeneralAppIdDecoder::new(information); - } - - pub fn get_information(&self) -> BitArray { - return self.information; - } - - pub fn get_general_decoder(&self) -> GeneralAppIdDecoder { - return self.general_decoder; - } - - pub fn parse_information(&self) -> /* throws NotFoundException, FormatException */Result> ; - - pub fn create_decoder( information: &BitArray) -> AbstractExpandedDecoder { - if information.get(1) { - return AI01AndOtherAIs::new(information); - } - if !information.get(2) { - return AnyAIDecoder::new(information); - } - let four_bit_encodation_method: i32 = GeneralAppIdDecoder::extract_numeric_value_from_bit_array(information, 1, 4); - match four_bit_encodation_method { - 4 => - { - return AI013103decoder::new(information); - } - 5 => - { - return AI01320xDecoder::new(information); - } - } - let five_bit_encodation_method: i32 = GeneralAppIdDecoder::extract_numeric_value_from_bit_array(information, 1, 5); - match five_bit_encodation_method { - 12 => - { - return AI01392xDecoder::new(information); - } - 13 => - { - return AI01393xDecoder::new(information); - } - } - let seven_bit_encodation_method: i32 = GeneralAppIdDecoder::extract_numeric_value_from_bit_array(information, 1, 7); - match seven_bit_encodation_method { - 56 => - { - return AI013x0x1xDecoder::new(information, "310", "11"); - } - 57 => - { - return AI013x0x1xDecoder::new(information, "320", "11"); - } - 58 => - { - return AI013x0x1xDecoder::new(information, "310", "13"); - } - 59 => - { - return AI013x0x1xDecoder::new(information, "320", "13"); - } - 60 => - { - return AI013x0x1xDecoder::new(information, "310", "15"); - } - 61 => - { - return AI013x0x1xDecoder::new(information, "320", "15"); - } - 62 => - { - return AI013x0x1xDecoder::new(information, "310", "17"); - } - 63 => - { - return AI013x0x1xDecoder::new(information, "320", "17"); - } - } - throw IllegalStateException::new(format!("unknown decoder: {}", information)); - } -} - -// NEW FILE: any_a_i_decoder.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - - const HEADER_SIZE: i32 = 2 + 1 + 2; -struct AnyAIDecoder { - super: AbstractExpandedDecoder; -} - -impl AnyAIDecoder { - - fn new( information: &BitArray) -> AnyAIDecoder { - super(information); - } - - pub fn parse_information(&self) -> /* throws NotFoundException, FormatException */Result> { - let buf: StringBuilder = StringBuilder::new(); - return Ok(self.get_general_decoder().decode_all_codes(&buf, HEADER_SIZE)); - } -} - -// NEW FILE: block_parsed_result.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -struct BlockParsedResult { - - let decoded_information: DecodedInformation; - - let finished: bool; -} - -impl BlockParsedResult { - - fn new() -> BlockParsedResult { - this(null, false); - } - - fn new( information: &DecodedInformation, finished: bool) -> BlockParsedResult { - let .finished = finished; - let .decodedInformation = information; - } - - fn get_decoded_information(&self) -> DecodedInformation { - return self.decodedInformation; - } - - fn is_finished(&self) -> bool { - return self.finished; - } -} - -// NEW FILE: current_parsing_state.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -struct CurrentParsingState { - - let mut position: i32; - - let mut encoding: State; -} - -impl CurrentParsingState { - - enum State { - - NUMERIC(), ALPHA(), ISO_IEC_646() - } - - fn new() -> CurrentParsingState { - let .position = 0; - let .encoding = State::NUMERIC; - } - - fn get_position(&self) -> i32 { - return self.position; - } - - fn set_position(&self, position: i32) { - self.position = position; - } - - fn increment_position(&self, delta: i32) { - self.position += delta; - } - - fn is_alpha(&self) -> bool { - return self.encoding == State::ALPHA; - } - - fn is_numeric(&self) -> bool { - return self.encoding == State::NUMERIC; - } - - fn is_iso_iec646(&self) -> bool { - return self.encoding == State::ISO_IEC_646; - } - - fn set_numeric(&self) { - self.encoding = State::NUMERIC; - } - - fn set_alpha(&self) { - self.encoding = State::ALPHA; - } - - fn set_iso_iec646(&self) { - self.encoding = State::ISO_IEC_646; - } -} - -// NEW FILE: decoded_char.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - -// It's not in Alphanumeric neither in ISO/IEC 646 charset - const FNC1: char = '$'; -struct DecodedChar { - super: DecodedObject; - - let value: char; -} - -impl DecodedChar { - - fn new( new_position: i32, value: char) -> DecodedChar { - super(new_position); - let .value = value; - } - - fn get_value(&self) -> char { - return self.value; - } - - fn is_f_n_c1(&self) -> bool { - return self.value == FNC1; - } -} - -// NEW FILE: decoded_information.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -struct DecodedInformation { - super: DecodedObject; - - let new_string: String; - - let remaining_value: i32; - - let mut remaining: bool; -} - -impl DecodedInformation { - - fn new( new_position: i32, new_string: &String) -> DecodedInformation { - super(new_position); - let .newString = new_string; - let .remaining = false; - let .remainingValue = 0; - } - - fn new( new_position: i32, new_string: &String, remaining_value: i32) -> DecodedInformation { - super(new_position); - let .remaining = true; - let .remainingValue = remaining_value; - let .newString = new_string; - } - - fn get_new_string(&self) -> String { - return self.newString; - } - - fn is_remaining(&self) -> bool { - return self.remaining; - } - - fn get_remaining_value(&self) -> i32 { - return self.remainingValue; - } -} - -// NEW FILE: decoded_numeric.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - - const FNC1: i32 = 10; -struct DecodedNumeric { - super: DecodedObject; - - let first_digit: i32; - - let second_digit: i32; -} - -impl DecodedNumeric { - - fn new( new_position: i32, first_digit: i32, second_digit: i32) -> DecodedNumeric throws FormatException { - super(new_position); - if first_digit < 0 || first_digit > 10 || second_digit < 0 || second_digit > 10 { - throw FormatException::get_format_instance(); - } - let .firstDigit = first_digit; - let .secondDigit = second_digit; - } - - fn get_first_digit(&self) -> i32 { - return self.firstDigit; - } - - fn get_second_digit(&self) -> i32 { - return self.secondDigit; - } - - fn get_value(&self) -> i32 { - return self.firstDigit * 10 + self.secondDigit; - } - - fn is_first_digit_f_n_c1(&self) -> bool { - return self.firstDigit == FNC1; - } - - fn is_second_digit_f_n_c1(&self) -> bool { - return self.secondDigit == FNC1; - } -} - -// NEW FILE: decoded_object.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -struct DecodedObject { - - let new_position: i32; -} - -impl DecodedObject { - - fn new( new_position: i32) -> DecodedObject { - let .newPosition = new_position; - } - - fn get_new_position(&self) -> i32 { - return self.newPosition; - } -} - -// NEW FILE: field_parser.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - - const TWO_DIGIT_DATA_LENGTH: Map = HashMap<>::new(); - - const THREE_DIGIT_DATA_LENGTH: Map = HashMap<>::new(); - - const THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH: Map = HashMap<>::new(); - - const FOUR_DIGIT_DATA_LENGTH: Map = HashMap<>::new(); -struct FieldParser { -} - -impl FieldParser { - - static { - TWO_DIGIT_DATA_LENGTH::put("00", &DataLength::fixed(18)); - TWO_DIGIT_DATA_LENGTH::put("01", &DataLength::fixed(14)); - TWO_DIGIT_DATA_LENGTH::put("02", &DataLength::fixed(14)); - TWO_DIGIT_DATA_LENGTH::put("10", &DataLength::variable(20)); - TWO_DIGIT_DATA_LENGTH::put("11", &DataLength::fixed(6)); - TWO_DIGIT_DATA_LENGTH::put("12", &DataLength::fixed(6)); - TWO_DIGIT_DATA_LENGTH::put("13", &DataLength::fixed(6)); - TWO_DIGIT_DATA_LENGTH::put("15", &DataLength::fixed(6)); - TWO_DIGIT_DATA_LENGTH::put("17", &DataLength::fixed(6)); - TWO_DIGIT_DATA_LENGTH::put("20", &DataLength::fixed(2)); - TWO_DIGIT_DATA_LENGTH::put("21", &DataLength::variable(20)); - TWO_DIGIT_DATA_LENGTH::put("22", &DataLength::variable(29)); - TWO_DIGIT_DATA_LENGTH::put("30", &DataLength::variable(8)); - TWO_DIGIT_DATA_LENGTH::put("37", &DataLength::variable(8)); - //internal company codes - { - let mut i: i32 = 90; - while i <= 99 { - { - TWO_DIGIT_DATA_LENGTH::put(&String::value_of(i), &DataLength::variable(30)); - } - i += 1; - } - } - - } - - static { - THREE_DIGIT_DATA_LENGTH::put("240", &DataLength::variable(30)); - THREE_DIGIT_DATA_LENGTH::put("241", &DataLength::variable(30)); - THREE_DIGIT_DATA_LENGTH::put("242", &DataLength::variable(6)); - THREE_DIGIT_DATA_LENGTH::put("250", &DataLength::variable(30)); - THREE_DIGIT_DATA_LENGTH::put("251", &DataLength::variable(30)); - THREE_DIGIT_DATA_LENGTH::put("253", &DataLength::variable(17)); - THREE_DIGIT_DATA_LENGTH::put("254", &DataLength::variable(20)); - THREE_DIGIT_DATA_LENGTH::put("400", &DataLength::variable(30)); - THREE_DIGIT_DATA_LENGTH::put("401", &DataLength::variable(30)); - THREE_DIGIT_DATA_LENGTH::put("402", &DataLength::fixed(17)); - THREE_DIGIT_DATA_LENGTH::put("403", &DataLength::variable(30)); - THREE_DIGIT_DATA_LENGTH::put("410", &DataLength::fixed(13)); - THREE_DIGIT_DATA_LENGTH::put("411", &DataLength::fixed(13)); - THREE_DIGIT_DATA_LENGTH::put("412", &DataLength::fixed(13)); - THREE_DIGIT_DATA_LENGTH::put("413", &DataLength::fixed(13)); - THREE_DIGIT_DATA_LENGTH::put("414", &DataLength::fixed(13)); - THREE_DIGIT_DATA_LENGTH::put("420", &DataLength::variable(20)); - THREE_DIGIT_DATA_LENGTH::put("421", &DataLength::variable(15)); - THREE_DIGIT_DATA_LENGTH::put("422", &DataLength::fixed(3)); - THREE_DIGIT_DATA_LENGTH::put("423", &DataLength::variable(15)); - THREE_DIGIT_DATA_LENGTH::put("424", &DataLength::fixed(3)); - THREE_DIGIT_DATA_LENGTH::put("425", &DataLength::fixed(3)); - THREE_DIGIT_DATA_LENGTH::put("426", &DataLength::fixed(3)); - } - - static { - { - let mut i: i32 = 310; - while i <= 316 { - { - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put(&String::value_of(i), &DataLength::fixed(6)); - } - i += 1; - } - } - - { - let mut i: i32 = 320; - while i <= 336 { - { - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put(&String::value_of(i), &DataLength::fixed(6)); - } - i += 1; - } - } - - { - let mut i: i32 = 340; - while i <= 357 { - { - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put(&String::value_of(i), &DataLength::fixed(6)); - } - i += 1; - } - } - - { - let mut i: i32 = 360; - while i <= 369 { - { - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put(&String::value_of(i), &DataLength::fixed(6)); - } - i += 1; - } - } - - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put("390", &DataLength::variable(15)); - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put("391", &DataLength::variable(18)); - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put("392", &DataLength::variable(15)); - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put("393", &DataLength::variable(18)); - THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put("703", &DataLength::variable(30)); - } - - static { - FOUR_DIGIT_DATA_LENGTH::put("7001", &DataLength::fixed(13)); - FOUR_DIGIT_DATA_LENGTH::put("7002", &DataLength::variable(30)); - FOUR_DIGIT_DATA_LENGTH::put("7003", &DataLength::fixed(10)); - FOUR_DIGIT_DATA_LENGTH::put("8001", &DataLength::fixed(14)); - FOUR_DIGIT_DATA_LENGTH::put("8002", &DataLength::variable(20)); - FOUR_DIGIT_DATA_LENGTH::put("8003", &DataLength::variable(30)); - FOUR_DIGIT_DATA_LENGTH::put("8004", &DataLength::variable(30)); - FOUR_DIGIT_DATA_LENGTH::put("8005", &DataLength::fixed(6)); - FOUR_DIGIT_DATA_LENGTH::put("8006", &DataLength::fixed(18)); - FOUR_DIGIT_DATA_LENGTH::put("8007", &DataLength::variable(30)); - FOUR_DIGIT_DATA_LENGTH::put("8008", &DataLength::variable(12)); - FOUR_DIGIT_DATA_LENGTH::put("8018", &DataLength::fixed(18)); - FOUR_DIGIT_DATA_LENGTH::put("8020", &DataLength::variable(25)); - FOUR_DIGIT_DATA_LENGTH::put("8100", &DataLength::fixed(6)); - FOUR_DIGIT_DATA_LENGTH::put("8101", &DataLength::fixed(10)); - FOUR_DIGIT_DATA_LENGTH::put("8102", &DataLength::fixed(2)); - FOUR_DIGIT_DATA_LENGTH::put("8110", &DataLength::variable(70)); - FOUR_DIGIT_DATA_LENGTH::put("8200", &DataLength::variable(70)); - } - - fn new() -> FieldParser { - } - - fn parse_fields_in_general_purpose( raw_information: &String) -> /* throws NotFoundException */Result> { - if raw_information.is_empty() { - return Ok(null); - } - if raw_information.length() < 2 { - throw NotFoundException::get_not_found_instance(); - } - let two_digit_data_length: DataLength = TWO_DIGIT_DATA_LENGTH::get(&raw_information.substring(0, 2)); - if two_digit_data_length != null { - if two_digit_data_length.variable { - return Ok(::process_variable_a_i(2, two_digit_data_length.len(), &raw_information)); - } - return Ok(::process_fixed_a_i(2, two_digit_data_length.len(), &raw_information)); - } - if raw_information.length() < 3 { - throw NotFoundException::get_not_found_instance(); - } - let first_three_digits: String = raw_information.substring(0, 3); - let three_digit_data_length: DataLength = THREE_DIGIT_DATA_LENGTH::get(&first_three_digits); - if three_digit_data_length != null { - if three_digit_data_length.variable { - return Ok(::process_variable_a_i(3, three_digit_data_length.len(), &raw_information)); - } - return Ok(::process_fixed_a_i(3, three_digit_data_length.len(), &raw_information)); - } - if raw_information.length() < 4 { - throw NotFoundException::get_not_found_instance(); - } - let three_digit_plus_digit_data_length: DataLength = THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::get(&first_three_digits); - if three_digit_plus_digit_data_length != null { - if three_digit_plus_digit_data_length.variable { - return Ok(::process_variable_a_i(4, three_digit_plus_digit_data_length.len(), &raw_information)); - } - return Ok(::process_fixed_a_i(4, three_digit_plus_digit_data_length.len(), &raw_information)); - } - let first_four_digit_length: DataLength = FOUR_DIGIT_DATA_LENGTH::get(&raw_information.substring(0, 4)); - if first_four_digit_length != null { - if first_four_digit_length.variable { - return Ok(::process_variable_a_i(4, first_four_digit_length.len(), &raw_information)); - } - return Ok(::process_fixed_a_i(4, first_four_digit_length.len(), &raw_information)); - } - throw NotFoundException::get_not_found_instance(); - } - - fn process_fixed_a_i( ai_size: i32, field_size: i32, raw_information: &String) -> /* throws NotFoundException */Result> { - if raw_information.length() < ai_size { - throw NotFoundException::get_not_found_instance(); - } - let ai: String = raw_information.substring(0, ai_size); - if raw_information.length() < ai_size + field_size { - throw NotFoundException::get_not_found_instance(); - } - let field: String = raw_information.substring(ai_size, ai_size + field_size); - let remaining: String = raw_information.substring(ai_size + field_size); - let result: String = format!("({}){}", ai, field); - let parsed_a_i: String = ::parse_fields_in_general_purpose(&remaining); - return Ok( if parsed_a_i == null { result } else { format!("{}{}", result, parsed_a_i) }); - } - - fn process_variable_a_i( ai_size: i32, variable_field_size: i32, raw_information: &String) -> /* throws NotFoundException */Result> { - let ai: String = raw_information.substring(0, ai_size); - let max_size: i32 = Math::min(&raw_information.length(), ai_size + variable_field_size); - let field: String = raw_information.substring(ai_size, max_size); - let remaining: String = raw_information.substring(max_size); - let result: String = format!("({}){}", ai, field); - let parsed_a_i: String = ::parse_fields_in_general_purpose(&remaining); - return Ok( if parsed_a_i == null { result } else { format!("{}{}", result, parsed_a_i) }); - } - - struct DataLength { - - let variable: bool; - - let length: i32; - } - - impl DataLength { - - fn new( variable: bool, length: i32) -> DataLength { - let .variable = variable; - let .len() = length; - } - - fn fixed( length: i32) -> DataLength { - return DataLength::new(false, length); - } - - fn variable( length: i32) -> DataLength { - return DataLength::new(true, length); - } - } - -} - -// NEW FILE: general_app_id_decoder.rs -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::oned::rss::expanded::decoders; - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -struct GeneralAppIdDecoder { - - let information: BitArray; - - let current: CurrentParsingState = CurrentParsingState::new(); - - let buffer: StringBuilder = StringBuilder::new(); -} - -impl GeneralAppIdDecoder { - - fn new( information: &BitArray) -> GeneralAppIdDecoder { - let .information = information; - } - - fn decode_all_codes(&self, buff: &StringBuilder, initial_position: i32) -> /* throws NotFoundException, FormatException */Result> { - let current_position: i32 = initial_position; - let mut remaining: String = null; - loop { { - let info: DecodedInformation = self.decode_general_purpose_field(current_position, &remaining); - let parsed_fields: String = FieldParser::parse_fields_in_general_purpose(&info.get_new_string()); - if parsed_fields != null { - buff.append(&parsed_fields); - } - if info.is_remaining() { - remaining = String::value_of(&info.get_remaining_value()); - } else { - remaining = null; - } - if current_position == info.get_new_position() { - // No step forward! - break; - } - current_position = info.get_new_position(); - }if !(true) break;} - return Ok(buff.to_string()); - } - - fn is_still_numeric(&self, pos: i32) -> bool { - // and one of the first 4 bits is "1". - if pos + 7 > self.information.get_size() { - return pos + 4 <= self.information.get_size(); - } - { - let mut i: i32 = pos; - while i < pos + 3 { - { - if self.information.get(i) { - return true; - } - } - i += 1; - } - } - - return self.information.get(pos + 3); - } - - fn decode_numeric(&self, pos: i32) -> /* throws FormatException */Result> { - if pos + 7 > self.information.get_size() { - let numeric: i32 = ::extract_numeric_value_from_bit_array(pos, 4); - if numeric == 0 { - return Ok(DecodedNumeric::new(&self.information.get_size(), DecodedNumeric::FNC1, DecodedNumeric::FNC1)); - } - return Ok(DecodedNumeric::new(&self.information.get_size(), numeric - 1, DecodedNumeric::FNC1)); - } - let numeric: i32 = ::extract_numeric_value_from_bit_array(pos, 7); - let digit1: i32 = (numeric - 8) / 11; - let digit2: i32 = (numeric - 8) % 11; - return Ok(DecodedNumeric::new(pos + 7, digit1, digit2)); - } - - fn extract_numeric_value_from_bit_array(&self, pos: i32, bits: i32) -> i32 { - return ::extract_numeric_value_from_bit_array(self.information, pos, bits); - } - - fn extract_numeric_value_from_bit_array( information: &BitArray, pos: i32, bits: i32) -> i32 { - let mut value: i32 = 0; - { - let mut i: i32 = 0; - while i < bits { - { - if information.get(pos + i) { - value |= 1 << (bits - i - 1); - } - } - i += 1; - } - } - - return value; - } - - fn decode_general_purpose_field(&self, pos: i32, remaining: &String) -> /* throws FormatException */Result> { - self.buffer.set_length(0); - if remaining != null { - self.buffer.append(&remaining); - } - self.current.set_position(pos); - let last_decoded: DecodedInformation = self.parse_blocks(); - if last_decoded != null && last_decoded.is_remaining() { - return Ok(DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string(), &last_decoded.get_remaining_value())); - } - return Ok(DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string())); - } - - fn parse_blocks(&self) -> /* throws FormatException */Result> { - let is_finished: bool; - let mut result: BlockParsedResult; - loop { { - let initial_position: i32 = self.current.get_position(); - if self.current.is_alpha() { - result = self.parse_alpha_block(); - is_finished = result.is_finished(); - } else if self.current.is_iso_iec646() { - result = self.parse_iso_iec646_block(); - is_finished = result.is_finished(); - } else { - // it must be numeric - result = self.parse_numeric_block(); - is_finished = result.is_finished(); - } - let position_changed: bool = initial_position != self.current.get_position(); - if !position_changed && !is_finished { - break; - } - }if !(!is_finished) break;} - return Ok(result.get_decoded_information()); - } - - fn parse_numeric_block(&self) -> /* throws FormatException */Result> { - while self.is_still_numeric(&self.current.get_position()) { - let numeric: DecodedNumeric = self.decode_numeric(&self.current.get_position()); - self.current.set_position(&numeric.get_new_position()); - if numeric.is_first_digit_f_n_c1() { - let mut information: DecodedInformation; - if numeric.is_second_digit_f_n_c1() { - information = DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string()); - } else { - information = DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string(), &numeric.get_second_digit()); - } - return Ok(BlockParsedResult::new(information, true)); - } - self.buffer.append(&numeric.get_first_digit()); - if numeric.is_second_digit_f_n_c1() { - let information: DecodedInformation = DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string()); - return Ok(BlockParsedResult::new(information, true)); - } - self.buffer.append(&numeric.get_second_digit()); - } - if self.is_numeric_to_alpha_numeric_latch(&self.current.get_position()) { - self.current.set_alpha(); - self.current.increment_position(4); - } - return Ok(BlockParsedResult::new()); - } - - fn parse_iso_iec646_block(&self) -> /* throws FormatException */Result> { - while self.is_still_iso_iec646(&self.current.get_position()) { - let iso: DecodedChar = self.decode_iso_iec646(&self.current.get_position()); - self.current.set_position(&iso.get_new_position()); - if iso.is_f_n_c1() { - let information: DecodedInformation = DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string()); - return Ok(BlockParsedResult::new(information, true)); - } - self.buffer.append(&iso.get_value()); - } - if self.is_alpha_or646_to_numeric_latch(&self.current.get_position()) { - self.current.increment_position(3); - self.current.set_numeric(); - } else if self.is_alpha_to646_to_alpha_latch(&self.current.get_position()) { - if self.current.get_position() + 5 < self.information.get_size() { - self.current.increment_position(5); - } else { - self.current.set_position(&self.information.get_size()); - } - self.current.set_alpha(); - } - return Ok(BlockParsedResult::new()); - } - - fn parse_alpha_block(&self) -> BlockParsedResult { - while self.is_still_alpha(&self.current.get_position()) { - let alpha: DecodedChar = self.decode_alphanumeric(&self.current.get_position()); - self.current.set_position(&alpha.get_new_position()); - if alpha.is_f_n_c1() { - let information: DecodedInformation = DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string()); - //end of the char block - return BlockParsedResult::new(information, true); - } - self.buffer.append(&alpha.get_value()); - } - if self.is_alpha_or646_to_numeric_latch(&self.current.get_position()) { - self.current.increment_position(3); - self.current.set_numeric(); - } else if self.is_alpha_to646_to_alpha_latch(&self.current.get_position()) { - if self.current.get_position() + 5 < self.information.get_size() { - self.current.increment_position(5); - } else { - self.current.set_position(&self.information.get_size()); - } - self.current.set_iso_iec646(); - } - return BlockParsedResult::new(); - } - - fn is_still_iso_iec646(&self, pos: i32) -> bool { - if pos + 5 > self.information.get_size() { - return false; - } - let five_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 5); - if five_bit_value >= 5 && five_bit_value < 16 { - return true; - } - if pos + 7 > self.information.get_size() { - return false; - } - let seven_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 7); - if seven_bit_value >= 64 && seven_bit_value < 116 { - return true; - } - if pos + 8 > self.information.get_size() { - return false; - } - let eight_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 8); - return eight_bit_value >= 232 && eight_bit_value < 253; - } - - fn decode_iso_iec646(&self, pos: i32) -> /* throws FormatException */Result> { - let five_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 5); - if five_bit_value == 15 { - return Ok(DecodedChar::new(pos + 5, DecodedChar::FNC1)); - } - if five_bit_value >= 5 && five_bit_value < 15 { - return Ok(DecodedChar::new(pos + 5, ('0' + five_bit_value - 5) as char)); - } - let seven_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 7); - if seven_bit_value >= 64 && seven_bit_value < 90 { - return Ok(DecodedChar::new(pos + 7, (seven_bit_value + 1) as char)); - } - if seven_bit_value >= 90 && seven_bit_value < 116 { - return Ok(DecodedChar::new(pos + 7, (seven_bit_value + 7) as char)); - } - let eight_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 8); - let mut c: char; - match eight_bit_value { - 232 => - { - c = '!'; - break; - } - 233 => - { - c = '"'; - break; - } - 234 => - { - c = '%'; - break; - } - 235 => - { - c = '&'; - break; - } - 236 => - { - c = '\''; - break; - } - 237 => - { - c = '('; - break; - } - 238 => - { - c = ')'; - break; - } - 239 => - { - c = '*'; - break; - } - 240 => - { - c = '+'; - break; - } - 241 => - { - c = ','; - break; - } - 242 => - { - c = '-'; - break; - } - 243 => - { - c = '.'; - break; - } - 244 => - { - c = '/'; - break; - } - 245 => - { - c = ':'; - break; - } - 246 => - { - c = ';'; - break; - } - 247 => - { - c = '<'; - break; - } - 248 => - { - c = '='; - break; - } - 249 => - { - c = '>'; - break; - } - 250 => - { - c = '?'; - break; - } - 251 => - { - c = '_'; - break; - } - 252 => - { - c = ' '; - break; - } - _ => - { - throw FormatException::get_format_instance(); - } - } - return Ok(DecodedChar::new(pos + 8, c)); - } - - fn is_still_alpha(&self, pos: i32) -> bool { - if pos + 5 > self.information.get_size() { - return false; - } - // We now check if it's a valid 5-bit value (0..9 and FNC1) - let five_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 5); - if five_bit_value >= 5 && five_bit_value < 16 { - return true; - } - if pos + 6 > self.information.get_size() { - return false; - } - let six_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 6); - // 63 not included - return six_bit_value >= 16 && six_bit_value < 63; - } - - fn decode_alphanumeric(&self, pos: i32) -> DecodedChar { - let five_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 5); - if five_bit_value == 15 { - return DecodedChar::new(pos + 5, DecodedChar::FNC1); - } - if five_bit_value >= 5 && five_bit_value < 15 { - return DecodedChar::new(pos + 5, ('0' + five_bit_value - 5) as char); - } - let six_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 6); - if six_bit_value >= 32 && six_bit_value < 58 { - return DecodedChar::new(pos + 6, (six_bit_value + 33) as char); - } - let mut c: char; - match six_bit_value { - 58 => - { - c = '*'; - break; - } - 59 => - { - c = ','; - break; - } - 60 => - { - c = '-'; - break; - } - 61 => - { - c = '.'; - break; - } - 62 => - { - c = '/'; - break; - } - _ => - { - throw IllegalStateException::new(format!("Decoding invalid alphanumeric value: {}", six_bit_value)); - } - } - return DecodedChar::new(pos + 6, c); - } - - fn is_alpha_to646_to_alpha_latch(&self, pos: i32) -> bool { - if pos + 1 > self.information.get_size() { - return false; - } - { - let mut i: i32 = 0; - while i < 5 && i + pos < self.information.get_size() { - { - if i == 2 { - if !self.information.get(pos + 2) { - return false; - } - } else if self.information.get(pos + i) { - return false; - } - } - i += 1; - } - } - - return true; - } - - fn is_alpha_or646_to_numeric_latch(&self, pos: i32) -> bool { - // Next is alphanumeric if there are 3 positions and they are all zeros - if pos + 3 > self.information.get_size() { - return false; - } - { - let mut i: i32 = pos; - while i < pos + 3 { - { - if self.information.get(i) { - return false; - } - } - i += 1; - } - } - - return true; - } - - fn is_numeric_to_alpha_numeric_latch(&self, pos: i32) -> bool { - // if there is a subset of this just before the end of the symbol - if pos + 1 > self.information.get_size() { - return false; - } - { - let mut i: i32 = 0; - while i < 4 && i + pos < self.information.get_size() { - { - if self.information.get(pos + i) { - return false; - } - } - i += 1; - } - } - - return true; - } -} - diff --git a/src/pdf417.rs b/src/pdf417.rs deleted file mode 100644 index dceaf68..0000000 --- a/src/pdf417.rs +++ /dev/null @@ -1,570 +0,0 @@ -use crate::{BarcodeFormat,BinaryBitmap,ChecksumException,DecodeHintType,FormatException,NotFoundException,Reader,XRingResult,ResultMetadataType,ResultPoint,EncodeHintType,Writer,WriterException,}; -use crate::common::{DecoderResult,BitMatrix}; -use crate::multi::{MultipleBarcodeReader}; -use crate::pdf417::decoder::PDF417ScanningDecoder; -use crate::pdf417::detector::{Detector,PDF417DetectorResult}; -use crate::pdf417::encoder::{Compaction,Dimensions,PDF417}; - -// NEW FILE: p_d_f417_common.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417; - -/** - * @author SITA Lab (kevin.osullivan@sita.aero) - * @author Guenther Grau - */ - - const NUMBER_OF_CODEWORDS: i32 = 929; - -// Maximum Codewords (Data + Error). - const MAX_CODEWORDS_IN_BARCODE: i32 = NUMBER_OF_CODEWORDS - 1; - - const MIN_ROWS_IN_BARCODE: i32 = 3; - - const MAX_ROWS_IN_BARCODE: i32 = 90; - -// One left row indication column + max 30 data columns + one right row indicator column -//public static final int MAX_CODEWORDS_IN_ROW = 32; - const MODULES_IN_CODEWORD: i32 = 17; - - const MODULES_IN_STOP_PATTERN: i32 = 18; - - const BARS_IN_MODULE: i32 = 8; - - const EMPTY_INT_ARRAY; - -/** - * The sorted table of all possible symbols. Extracted from the PDF417 - * specification. The index of a symbol in this table corresponds to the - * index into the codeword table. - */ - const SYMBOL_TABLE: vec![Vec; 2787] = vec![0x1025e, 0x1027a, 0x1029e, 0x102bc, 0x102f2, 0x102f4, 0x1032e, 0x1034e, 0x1035c, 0x10396, 0x103a6, 0x103ac, 0x10422, 0x10428, 0x10436, 0x10442, 0x10444, 0x10448, 0x10450, 0x1045e, 0x10466, 0x1046c, 0x1047a, 0x10482, 0x1049e, 0x104a0, 0x104bc, 0x104c6, 0x104d8, 0x104ee, 0x104f2, 0x104f4, 0x10504, 0x10508, 0x10510, 0x1051e, 0x10520, 0x1053c, 0x10540, 0x10578, 0x10586, 0x1058c, 0x10598, 0x105b0, 0x105be, 0x105ce, 0x105dc, 0x105e2, 0x105e4, 0x105e8, 0x105f6, 0x1062e, 0x1064e, 0x1065c, 0x1068e, 0x1069c, 0x106b8, 0x106de, 0x106fa, 0x10716, 0x10726, 0x1072c, 0x10746, 0x1074c, 0x10758, 0x1076e, 0x10792, 0x10794, 0x107a2, 0x107a4, 0x107a8, 0x107b6, 0x10822, 0x10828, 0x10842, 0x10848, 0x10850, 0x1085e, 0x10866, 0x1086c, 0x1087a, 0x10882, 0x10884, 0x10890, 0x1089e, 0x108a0, 0x108bc, 0x108c6, 0x108cc, 0x108d8, 0x108ee, 0x108f2, 0x108f4, 0x10902, 0x10908, 0x1091e, 0x10920, 0x1093c, 0x10940, 0x10978, 0x10986, 0x10998, 0x109b0, 0x109be, 0x109ce, 0x109dc, 0x109e2, 0x109e4, 0x109e8, 0x109f6, 0x10a08, 0x10a10, 0x10a1e, 0x10a20, 0x10a3c, 0x10a40, 0x10a78, 0x10af0, 0x10b06, 0x10b0c, 0x10b18, 0x10b30, 0x10b3e, 0x10b60, 0x10b7c, 0x10b8e, 0x10b9c, 0x10bb8, 0x10bc2, 0x10bc4, 0x10bc8, 0x10bd0, 0x10bde, 0x10be6, 0x10bec, 0x10c2e, 0x10c4e, 0x10c5c, 0x10c62, 0x10c64, 0x10c68, 0x10c76, 0x10c8e, 0x10c9c, 0x10cb8, 0x10cc2, 0x10cc4, 0x10cc8, 0x10cd0, 0x10cde, 0x10ce6, 0x10cec, 0x10cfa, 0x10d0e, 0x10d1c, 0x10d38, 0x10d70, 0x10d7e, 0x10d82, 0x10d84, 0x10d88, 0x10d90, 0x10d9e, 0x10da0, 0x10dbc, 0x10dc6, 0x10dcc, 0x10dd8, 0x10dee, 0x10df2, 0x10df4, 0x10e16, 0x10e26, 0x10e2c, 0x10e46, 0x10e58, 0x10e6e, 0x10e86, 0x10e8c, 0x10e98, 0x10eb0, 0x10ebe, 0x10ece, 0x10edc, 0x10f0a, 0x10f12, 0x10f14, 0x10f22, 0x10f28, 0x10f36, 0x10f42, 0x10f44, 0x10f48, 0x10f50, 0x10f5e, 0x10f66, 0x10f6c, 0x10fb2, 0x10fb4, 0x11022, 0x11028, 0x11042, 0x11048, 0x11050, 0x1105e, 0x1107a, 0x11082, 0x11084, 0x11090, 0x1109e, 0x110a0, 0x110bc, 0x110c6, 0x110cc, 0x110d8, 0x110ee, 0x110f2, 0x110f4, 0x11102, 0x1111e, 0x11120, 0x1113c, 0x11140, 0x11178, 0x11186, 0x11198, 0x111b0, 0x111be, 0x111ce, 0x111dc, 0x111e2, 0x111e4, 0x111e8, 0x111f6, 0x11208, 0x1121e, 0x11220, 0x11278, 0x112f0, 0x1130c, 0x11330, 0x1133e, 0x11360, 0x1137c, 0x1138e, 0x1139c, 0x113b8, 0x113c2, 0x113c8, 0x113d0, 0x113de, 0x113e6, 0x113ec, 0x11408, 0x11410, 0x1141e, 0x11420, 0x1143c, 0x11440, 0x11478, 0x114f0, 0x115e0, 0x1160c, 0x11618, 0x11630, 0x1163e, 0x11660, 0x1167c, 0x116c0, 0x116f8, 0x1171c, 0x11738, 0x11770, 0x1177e, 0x11782, 0x11784, 0x11788, 0x11790, 0x1179e, 0x117a0, 0x117bc, 0x117c6, 0x117cc, 0x117d8, 0x117ee, 0x1182e, 0x11834, 0x1184e, 0x1185c, 0x11862, 0x11864, 0x11868, 0x11876, 0x1188e, 0x1189c, 0x118b8, 0x118c2, 0x118c8, 0x118d0, 0x118de, 0x118e6, 0x118ec, 0x118fa, 0x1190e, 0x1191c, 0x11938, 0x11970, 0x1197e, 0x11982, 0x11984, 0x11990, 0x1199e, 0x119a0, 0x119bc, 0x119c6, 0x119cc, 0x119d8, 0x119ee, 0x119f2, 0x119f4, 0x11a0e, 0x11a1c, 0x11a38, 0x11a70, 0x11a7e, 0x11ae0, 0x11afc, 0x11b08, 0x11b10, 0x11b1e, 0x11b20, 0x11b3c, 0x11b40, 0x11b78, 0x11b8c, 0x11b98, 0x11bb0, 0x11bbe, 0x11bce, 0x11bdc, 0x11be2, 0x11be4, 0x11be8, 0x11bf6, 0x11c16, 0x11c26, 0x11c2c, 0x11c46, 0x11c4c, 0x11c58, 0x11c6e, 0x11c86, 0x11c98, 0x11cb0, 0x11cbe, 0x11cce, 0x11cdc, 0x11ce2, 0x11ce4, 0x11ce8, 0x11cf6, 0x11d06, 0x11d0c, 0x11d18, 0x11d30, 0x11d3e, 0x11d60, 0x11d7c, 0x11d8e, 0x11d9c, 0x11db8, 0x11dc4, 0x11dc8, 0x11dd0, 0x11dde, 0x11de6, 0x11dec, 0x11dfa, 0x11e0a, 0x11e12, 0x11e14, 0x11e22, 0x11e24, 0x11e28, 0x11e36, 0x11e42, 0x11e44, 0x11e50, 0x11e5e, 0x11e66, 0x11e6c, 0x11e82, 0x11e84, 0x11e88, 0x11e90, 0x11e9e, 0x11ea0, 0x11ebc, 0x11ec6, 0x11ecc, 0x11ed8, 0x11eee, 0x11f1a, 0x11f2e, 0x11f32, 0x11f34, 0x11f4e, 0x11f5c, 0x11f62, 0x11f64, 0x11f68, 0x11f76, 0x12048, 0x1205e, 0x12082, 0x12084, 0x12090, 0x1209e, 0x120a0, 0x120bc, 0x120d8, 0x120f2, 0x120f4, 0x12108, 0x1211e, 0x12120, 0x1213c, 0x12140, 0x12178, 0x12186, 0x12198, 0x121b0, 0x121be, 0x121e2, 0x121e4, 0x121e8, 0x121f6, 0x12204, 0x12210, 0x1221e, 0x12220, 0x12278, 0x122f0, 0x12306, 0x1230c, 0x12330, 0x1233e, 0x12360, 0x1237c, 0x1238e, 0x1239c, 0x123b8, 0x123c2, 0x123c8, 0x123d0, 0x123e6, 0x123ec, 0x1241e, 0x12420, 0x1243c, 0x124f0, 0x125e0, 0x12618, 0x1263e, 0x12660, 0x1267c, 0x126c0, 0x126f8, 0x12738, 0x12770, 0x1277e, 0x12782, 0x12784, 0x12790, 0x1279e, 0x127a0, 0x127bc, 0x127c6, 0x127cc, 0x127d8, 0x127ee, 0x12820, 0x1283c, 0x12840, 0x12878, 0x128f0, 0x129e0, 0x12bc0, 0x12c18, 0x12c30, 0x12c3e, 0x12c60, 0x12c7c, 0x12cc0, 0x12cf8, 0x12df0, 0x12e1c, 0x12e38, 0x12e70, 0x12e7e, 0x12ee0, 0x12efc, 0x12f04, 0x12f08, 0x12f10, 0x12f20, 0x12f3c, 0x12f40, 0x12f78, 0x12f86, 0x12f8c, 0x12f98, 0x12fb0, 0x12fbe, 0x12fce, 0x12fdc, 0x1302e, 0x1304e, 0x1305c, 0x13062, 0x13068, 0x1308e, 0x1309c, 0x130b8, 0x130c2, 0x130c8, 0x130d0, 0x130de, 0x130ec, 0x130fa, 0x1310e, 0x13138, 0x13170, 0x1317e, 0x13182, 0x13184, 0x13190, 0x1319e, 0x131a0, 0x131bc, 0x131c6, 0x131cc, 0x131d8, 0x131f2, 0x131f4, 0x1320e, 0x1321c, 0x13270, 0x1327e, 0x132e0, 0x132fc, 0x13308, 0x1331e, 0x13320, 0x1333c, 0x13340, 0x13378, 0x13386, 0x13398, 0x133b0, 0x133be, 0x133ce, 0x133dc, 0x133e2, 0x133e4, 0x133e8, 0x133f6, 0x1340e, 0x1341c, 0x13438, 0x13470, 0x1347e, 0x134e0, 0x134fc, 0x135c0, 0x135f8, 0x13608, 0x13610, 0x1361e, 0x13620, 0x1363c, 0x13640, 0x13678, 0x136f0, 0x1370c, 0x13718, 0x13730, 0x1373e, 0x13760, 0x1377c, 0x1379c, 0x137b8, 0x137c2, 0x137c4, 0x137c8, 0x137d0, 0x137de, 0x137e6, 0x137ec, 0x13816, 0x13826, 0x1382c, 0x13846, 0x1384c, 0x13858, 0x1386e, 0x13874, 0x13886, 0x13898, 0x138b0, 0x138be, 0x138ce, 0x138dc, 0x138e2, 0x138e4, 0x138e8, 0x13906, 0x1390c, 0x13930, 0x1393e, 0x13960, 0x1397c, 0x1398e, 0x1399c, 0x139b8, 0x139c8, 0x139d0, 0x139de, 0x139e6, 0x139ec, 0x139fa, 0x13a06, 0x13a0c, 0x13a18, 0x13a30, 0x13a3e, 0x13a60, 0x13a7c, 0x13ac0, 0x13af8, 0x13b0e, 0x13b1c, 0x13b38, 0x13b70, 0x13b7e, 0x13b88, 0x13b90, 0x13b9e, 0x13ba0, 0x13bbc, 0x13bcc, 0x13bd8, 0x13bee, 0x13bf2, 0x13bf4, 0x13c12, 0x13c14, 0x13c22, 0x13c24, 0x13c28, 0x13c36, 0x13c42, 0x13c48, 0x13c50, 0x13c5e, 0x13c66, 0x13c6c, 0x13c82, 0x13c84, 0x13c90, 0x13c9e, 0x13ca0, 0x13cbc, 0x13cc6, 0x13ccc, 0x13cd8, 0x13cee, 0x13d02, 0x13d04, 0x13d08, 0x13d10, 0x13d1e, 0x13d20, 0x13d3c, 0x13d40, 0x13d78, 0x13d86, 0x13d8c, 0x13d98, 0x13db0, 0x13dbe, 0x13dce, 0x13ddc, 0x13de4, 0x13de8, 0x13df6, 0x13e1a, 0x13e2e, 0x13e32, 0x13e34, 0x13e4e, 0x13e5c, 0x13e62, 0x13e64, 0x13e68, 0x13e76, 0x13e8e, 0x13e9c, 0x13eb8, 0x13ec2, 0x13ec4, 0x13ec8, 0x13ed0, 0x13ede, 0x13ee6, 0x13eec, 0x13f26, 0x13f2c, 0x13f3a, 0x13f46, 0x13f4c, 0x13f58, 0x13f6e, 0x13f72, 0x13f74, 0x14082, 0x1409e, 0x140a0, 0x140bc, 0x14104, 0x14108, 0x14110, 0x1411e, 0x14120, 0x1413c, 0x14140, 0x14178, 0x1418c, 0x14198, 0x141b0, 0x141be, 0x141e2, 0x141e4, 0x141e8, 0x14208, 0x14210, 0x1421e, 0x14220, 0x1423c, 0x14240, 0x14278, 0x142f0, 0x14306, 0x1430c, 0x14318, 0x14330, 0x1433e, 0x14360, 0x1437c, 0x1438e, 0x143c2, 0x143c4, 0x143c8, 0x143d0, 0x143e6, 0x143ec, 0x14408, 0x14410, 0x1441e, 0x14420, 0x1443c, 0x14440, 0x14478, 0x144f0, 0x145e0, 0x1460c, 0x14618, 0x14630, 0x1463e, 0x14660, 0x1467c, 0x146c0, 0x146f8, 0x1471c, 0x14738, 0x14770, 0x1477e, 0x14782, 0x14784, 0x14788, 0x14790, 0x147a0, 0x147bc, 0x147c6, 0x147cc, 0x147d8, 0x147ee, 0x14810, 0x14820, 0x1483c, 0x14840, 0x14878, 0x148f0, 0x149e0, 0x14bc0, 0x14c30, 0x14c3e, 0x14c60, 0x14c7c, 0x14cc0, 0x14cf8, 0x14df0, 0x14e38, 0x14e70, 0x14e7e, 0x14ee0, 0x14efc, 0x14f04, 0x14f08, 0x14f10, 0x14f1e, 0x14f20, 0x14f3c, 0x14f40, 0x14f78, 0x14f86, 0x14f8c, 0x14f98, 0x14fb0, 0x14fce, 0x14fdc, 0x15020, 0x15040, 0x15078, 0x150f0, 0x151e0, 0x153c0, 0x15860, 0x1587c, 0x158c0, 0x158f8, 0x159f0, 0x15be0, 0x15c70, 0x15c7e, 0x15ce0, 0x15cfc, 0x15dc0, 0x15df8, 0x15e08, 0x15e10, 0x15e20, 0x15e40, 0x15e78, 0x15ef0, 0x15f0c, 0x15f18, 0x15f30, 0x15f60, 0x15f7c, 0x15f8e, 0x15f9c, 0x15fb8, 0x1604e, 0x1605c, 0x1608e, 0x1609c, 0x160b8, 0x160c2, 0x160c4, 0x160c8, 0x160de, 0x1610e, 0x1611c, 0x16138, 0x16170, 0x1617e, 0x16184, 0x16188, 0x16190, 0x1619e, 0x161a0, 0x161bc, 0x161c6, 0x161cc, 0x161d8, 0x161f2, 0x161f4, 0x1620e, 0x1621c, 0x16238, 0x16270, 0x1627e, 0x162e0, 0x162fc, 0x16304, 0x16308, 0x16310, 0x1631e, 0x16320, 0x1633c, 0x16340, 0x16378, 0x16386, 0x1638c, 0x16398, 0x163b0, 0x163be, 0x163ce, 0x163dc, 0x163e2, 0x163e4, 0x163e8, 0x163f6, 0x1640e, 0x1641c, 0x16438, 0x16470, 0x1647e, 0x164e0, 0x164fc, 0x165c0, 0x165f8, 0x16610, 0x1661e, 0x16620, 0x1663c, 0x16640, 0x16678, 0x166f0, 0x16718, 0x16730, 0x1673e, 0x16760, 0x1677c, 0x1678e, 0x1679c, 0x167b8, 0x167c2, 0x167c4, 0x167c8, 0x167d0, 0x167de, 0x167e6, 0x167ec, 0x1681c, 0x16838, 0x16870, 0x168e0, 0x168fc, 0x169c0, 0x169f8, 0x16bf0, 0x16c10, 0x16c1e, 0x16c20, 0x16c3c, 0x16c40, 0x16c78, 0x16cf0, 0x16de0, 0x16e18, 0x16e30, 0x16e3e, 0x16e60, 0x16e7c, 0x16ec0, 0x16ef8, 0x16f1c, 0x16f38, 0x16f70, 0x16f7e, 0x16f84, 0x16f88, 0x16f90, 0x16f9e, 0x16fa0, 0x16fbc, 0x16fc6, 0x16fcc, 0x16fd8, 0x17026, 0x1702c, 0x17046, 0x1704c, 0x17058, 0x1706e, 0x17086, 0x1708c, 0x17098, 0x170b0, 0x170be, 0x170ce, 0x170dc, 0x170e8, 0x17106, 0x1710c, 0x17118, 0x17130, 0x1713e, 0x17160, 0x1717c, 0x1718e, 0x1719c, 0x171b8, 0x171c2, 0x171c4, 0x171c8, 0x171d0, 0x171de, 0x171e6, 0x171ec, 0x171fa, 0x17206, 0x1720c, 0x17218, 0x17230, 0x1723e, 0x17260, 0x1727c, 0x172c0, 0x172f8, 0x1730e, 0x1731c, 0x17338, 0x17370, 0x1737e, 0x17388, 0x17390, 0x1739e, 0x173a0, 0x173bc, 0x173cc, 0x173d8, 0x173ee, 0x173f2, 0x173f4, 0x1740c, 0x17418, 0x17430, 0x1743e, 0x17460, 0x1747c, 0x174c0, 0x174f8, 0x175f0, 0x1760e, 0x1761c, 0x17638, 0x17670, 0x1767e, 0x176e0, 0x176fc, 0x17708, 0x17710, 0x1771e, 0x17720, 0x1773c, 0x17740, 0x17778, 0x17798, 0x177b0, 0x177be, 0x177dc, 0x177e2, 0x177e4, 0x177e8, 0x17822, 0x17824, 0x17828, 0x17836, 0x17842, 0x17844, 0x17848, 0x17850, 0x1785e, 0x17866, 0x1786c, 0x17882, 0x17884, 0x17888, 0x17890, 0x1789e, 0x178a0, 0x178bc, 0x178c6, 0x178cc, 0x178d8, 0x178ee, 0x178f2, 0x178f4, 0x17902, 0x17904, 0x17908, 0x17910, 0x1791e, 0x17920, 0x1793c, 0x17940, 0x17978, 0x17986, 0x1798c, 0x17998, 0x179b0, 0x179be, 0x179ce, 0x179dc, 0x179e2, 0x179e4, 0x179e8, 0x179f6, 0x17a04, 0x17a08, 0x17a10, 0x17a1e, 0x17a20, 0x17a3c, 0x17a40, 0x17a78, 0x17af0, 0x17b06, 0x17b0c, 0x17b18, 0x17b30, 0x17b3e, 0x17b60, 0x17b7c, 0x17b8e, 0x17b9c, 0x17bb8, 0x17bc4, 0x17bc8, 0x17bd0, 0x17bde, 0x17be6, 0x17bec, 0x17c2e, 0x17c32, 0x17c34, 0x17c4e, 0x17c5c, 0x17c62, 0x17c64, 0x17c68, 0x17c76, 0x17c8e, 0x17c9c, 0x17cb8, 0x17cc2, 0x17cc4, 0x17cc8, 0x17cd0, 0x17cde, 0x17ce6, 0x17cec, 0x17d0e, 0x17d1c, 0x17d38, 0x17d70, 0x17d82, 0x17d84, 0x17d88, 0x17d90, 0x17d9e, 0x17da0, 0x17dbc, 0x17dc6, 0x17dcc, 0x17dd8, 0x17dee, 0x17e26, 0x17e2c, 0x17e3a, 0x17e46, 0x17e4c, 0x17e58, 0x17e6e, 0x17e72, 0x17e74, 0x17e86, 0x17e8c, 0x17e98, 0x17eb0, 0x17ece, 0x17edc, 0x17ee2, 0x17ee4, 0x17ee8, 0x17ef6, 0x1813a, 0x18172, 0x18174, 0x18216, 0x18226, 0x1823a, 0x1824c, 0x18258, 0x1826e, 0x18272, 0x18274, 0x18298, 0x182be, 0x182e2, 0x182e4, 0x182e8, 0x182f6, 0x1835e, 0x1837a, 0x183ae, 0x183d6, 0x18416, 0x18426, 0x1842c, 0x1843a, 0x18446, 0x18458, 0x1846e, 0x18472, 0x18474, 0x18486, 0x184b0, 0x184be, 0x184ce, 0x184dc, 0x184e2, 0x184e4, 0x184e8, 0x184f6, 0x18506, 0x1850c, 0x18518, 0x18530, 0x1853e, 0x18560, 0x1857c, 0x1858e, 0x1859c, 0x185b8, 0x185c2, 0x185c4, 0x185c8, 0x185d0, 0x185de, 0x185e6, 0x185ec, 0x185fa, 0x18612, 0x18614, 0x18622, 0x18628, 0x18636, 0x18642, 0x18650, 0x1865e, 0x1867a, 0x18682, 0x18684, 0x18688, 0x18690, 0x1869e, 0x186a0, 0x186bc, 0x186c6, 0x186cc, 0x186d8, 0x186ee, 0x186f2, 0x186f4, 0x1872e, 0x1874e, 0x1875c, 0x18796, 0x187a6, 0x187ac, 0x187d2, 0x187d4, 0x18826, 0x1882c, 0x1883a, 0x18846, 0x1884c, 0x18858, 0x1886e, 0x18872, 0x18874, 0x18886, 0x18898, 0x188b0, 0x188be, 0x188ce, 0x188dc, 0x188e2, 0x188e4, 0x188e8, 0x188f6, 0x1890c, 0x18930, 0x1893e, 0x18960, 0x1897c, 0x1898e, 0x189b8, 0x189c2, 0x189c8, 0x189d0, 0x189de, 0x189e6, 0x189ec, 0x189fa, 0x18a18, 0x18a30, 0x18a3e, 0x18a60, 0x18a7c, 0x18ac0, 0x18af8, 0x18b1c, 0x18b38, 0x18b70, 0x18b7e, 0x18b82, 0x18b84, 0x18b88, 0x18b90, 0x18b9e, 0x18ba0, 0x18bbc, 0x18bc6, 0x18bcc, 0x18bd8, 0x18bee, 0x18bf2, 0x18bf4, 0x18c22, 0x18c24, 0x18c28, 0x18c36, 0x18c42, 0x18c48, 0x18c50, 0x18c5e, 0x18c66, 0x18c7a, 0x18c82, 0x18c84, 0x18c90, 0x18c9e, 0x18ca0, 0x18cbc, 0x18ccc, 0x18cf2, 0x18cf4, 0x18d04, 0x18d08, 0x18d10, 0x18d1e, 0x18d20, 0x18d3c, 0x18d40, 0x18d78, 0x18d86, 0x18d98, 0x18dce, 0x18de2, 0x18de4, 0x18de8, 0x18e2e, 0x18e32, 0x18e34, 0x18e4e, 0x18e5c, 0x18e62, 0x18e64, 0x18e68, 0x18e8e, 0x18e9c, 0x18eb8, 0x18ec2, 0x18ec4, 0x18ec8, 0x18ed0, 0x18efa, 0x18f16, 0x18f26, 0x18f2c, 0x18f46, 0x18f4c, 0x18f58, 0x18f6e, 0x18f8a, 0x18f92, 0x18f94, 0x18fa2, 0x18fa4, 0x18fa8, 0x18fb6, 0x1902c, 0x1903a, 0x19046, 0x1904c, 0x19058, 0x19072, 0x19074, 0x19086, 0x19098, 0x190b0, 0x190be, 0x190ce, 0x190dc, 0x190e2, 0x190e8, 0x190f6, 0x19106, 0x1910c, 0x19130, 0x1913e, 0x19160, 0x1917c, 0x1918e, 0x1919c, 0x191b8, 0x191c2, 0x191c8, 0x191d0, 0x191de, 0x191e6, 0x191ec, 0x191fa, 0x19218, 0x1923e, 0x19260, 0x1927c, 0x192c0, 0x192f8, 0x19338, 0x19370, 0x1937e, 0x19382, 0x19384, 0x19390, 0x1939e, 0x193a0, 0x193bc, 0x193c6, 0x193cc, 0x193d8, 0x193ee, 0x193f2, 0x193f4, 0x19430, 0x1943e, 0x19460, 0x1947c, 0x194c0, 0x194f8, 0x195f0, 0x19638, 0x19670, 0x1967e, 0x196e0, 0x196fc, 0x19702, 0x19704, 0x19708, 0x19710, 0x19720, 0x1973c, 0x19740, 0x19778, 0x19786, 0x1978c, 0x19798, 0x197b0, 0x197be, 0x197ce, 0x197dc, 0x197e2, 0x197e4, 0x197e8, 0x19822, 0x19824, 0x19842, 0x19848, 0x19850, 0x1985e, 0x19866, 0x1987a, 0x19882, 0x19884, 0x19890, 0x1989e, 0x198a0, 0x198bc, 0x198cc, 0x198f2, 0x198f4, 0x19902, 0x19908, 0x1991e, 0x19920, 0x1993c, 0x19940, 0x19978, 0x19986, 0x19998, 0x199ce, 0x199e2, 0x199e4, 0x199e8, 0x19a08, 0x19a10, 0x19a1e, 0x19a20, 0x19a3c, 0x19a40, 0x19a78, 0x19af0, 0x19b18, 0x19b3e, 0x19b60, 0x19b9c, 0x19bc2, 0x19bc4, 0x19bc8, 0x19bd0, 0x19be6, 0x19c2e, 0x19c34, 0x19c4e, 0x19c5c, 0x19c62, 0x19c64, 0x19c68, 0x19c8e, 0x19c9c, 0x19cb8, 0x19cc2, 0x19cc8, 0x19cd0, 0x19ce6, 0x19cfa, 0x19d0e, 0x19d1c, 0x19d38, 0x19d70, 0x19d7e, 0x19d82, 0x19d84, 0x19d88, 0x19d90, 0x19da0, 0x19dcc, 0x19df2, 0x19df4, 0x19e16, 0x19e26, 0x19e2c, 0x19e46, 0x19e4c, 0x19e58, 0x19e74, 0x19e86, 0x19e8c, 0x19e98, 0x19eb0, 0x19ebe, 0x19ece, 0x19ee2, 0x19ee4, 0x19ee8, 0x19f0a, 0x19f12, 0x19f14, 0x19f22, 0x19f24, 0x19f28, 0x19f42, 0x19f44, 0x19f48, 0x19f50, 0x19f5e, 0x19f6c, 0x19f9a, 0x19fae, 0x19fb2, 0x19fb4, 0x1a046, 0x1a04c, 0x1a072, 0x1a074, 0x1a086, 0x1a08c, 0x1a098, 0x1a0b0, 0x1a0be, 0x1a0e2, 0x1a0e4, 0x1a0e8, 0x1a0f6, 0x1a106, 0x1a10c, 0x1a118, 0x1a130, 0x1a13e, 0x1a160, 0x1a17c, 0x1a18e, 0x1a19c, 0x1a1b8, 0x1a1c2, 0x1a1c4, 0x1a1c8, 0x1a1d0, 0x1a1de, 0x1a1e6, 0x1a1ec, 0x1a218, 0x1a230, 0x1a23e, 0x1a260, 0x1a27c, 0x1a2c0, 0x1a2f8, 0x1a31c, 0x1a338, 0x1a370, 0x1a37e, 0x1a382, 0x1a384, 0x1a388, 0x1a390, 0x1a39e, 0x1a3a0, 0x1a3bc, 0x1a3c6, 0x1a3cc, 0x1a3d8, 0x1a3ee, 0x1a3f2, 0x1a3f4, 0x1a418, 0x1a430, 0x1a43e, 0x1a460, 0x1a47c, 0x1a4c0, 0x1a4f8, 0x1a5f0, 0x1a61c, 0x1a638, 0x1a670, 0x1a67e, 0x1a6e0, 0x1a6fc, 0x1a702, 0x1a704, 0x1a708, 0x1a710, 0x1a71e, 0x1a720, 0x1a73c, 0x1a740, 0x1a778, 0x1a786, 0x1a78c, 0x1a798, 0x1a7b0, 0x1a7be, 0x1a7ce, 0x1a7dc, 0x1a7e2, 0x1a7e4, 0x1a7e8, 0x1a830, 0x1a860, 0x1a87c, 0x1a8c0, 0x1a8f8, 0x1a9f0, 0x1abe0, 0x1ac70, 0x1ac7e, 0x1ace0, 0x1acfc, 0x1adc0, 0x1adf8, 0x1ae04, 0x1ae08, 0x1ae10, 0x1ae20, 0x1ae3c, 0x1ae40, 0x1ae78, 0x1aef0, 0x1af06, 0x1af0c, 0x1af18, 0x1af30, 0x1af3e, 0x1af60, 0x1af7c, 0x1af8e, 0x1af9c, 0x1afb8, 0x1afc4, 0x1afc8, 0x1afd0, 0x1afde, 0x1b042, 0x1b05e, 0x1b07a, 0x1b082, 0x1b084, 0x1b088, 0x1b090, 0x1b09e, 0x1b0a0, 0x1b0bc, 0x1b0cc, 0x1b0f2, 0x1b0f4, 0x1b102, 0x1b104, 0x1b108, 0x1b110, 0x1b11e, 0x1b120, 0x1b13c, 0x1b140, 0x1b178, 0x1b186, 0x1b198, 0x1b1ce, 0x1b1e2, 0x1b1e4, 0x1b1e8, 0x1b204, 0x1b208, 0x1b210, 0x1b21e, 0x1b220, 0x1b23c, 0x1b240, 0x1b278, 0x1b2f0, 0x1b30c, 0x1b33e, 0x1b360, 0x1b39c, 0x1b3c2, 0x1b3c4, 0x1b3c8, 0x1b3d0, 0x1b3e6, 0x1b410, 0x1b41e, 0x1b420, 0x1b43c, 0x1b440, 0x1b478, 0x1b4f0, 0x1b5e0, 0x1b618, 0x1b660, 0x1b67c, 0x1b6c0, 0x1b738, 0x1b782, 0x1b784, 0x1b788, 0x1b790, 0x1b79e, 0x1b7a0, 0x1b7cc, 0x1b82e, 0x1b84e, 0x1b85c, 0x1b88e, 0x1b89c, 0x1b8b8, 0x1b8c2, 0x1b8c4, 0x1b8c8, 0x1b8d0, 0x1b8e6, 0x1b8fa, 0x1b90e, 0x1b91c, 0x1b938, 0x1b970, 0x1b97e, 0x1b982, 0x1b984, 0x1b988, 0x1b990, 0x1b99e, 0x1b9a0, 0x1b9cc, 0x1b9f2, 0x1b9f4, 0x1ba0e, 0x1ba1c, 0x1ba38, 0x1ba70, 0x1ba7e, 0x1bae0, 0x1bafc, 0x1bb08, 0x1bb10, 0x1bb20, 0x1bb3c, 0x1bb40, 0x1bb98, 0x1bbce, 0x1bbe2, 0x1bbe4, 0x1bbe8, 0x1bc16, 0x1bc26, 0x1bc2c, 0x1bc46, 0x1bc4c, 0x1bc58, 0x1bc72, 0x1bc74, 0x1bc86, 0x1bc8c, 0x1bc98, 0x1bcb0, 0x1bcbe, 0x1bcce, 0x1bce2, 0x1bce4, 0x1bce8, 0x1bd06, 0x1bd0c, 0x1bd18, 0x1bd30, 0x1bd3e, 0x1bd60, 0x1bd7c, 0x1bd9c, 0x1bdc2, 0x1bdc4, 0x1bdc8, 0x1bdd0, 0x1bde6, 0x1bdfa, 0x1be12, 0x1be14, 0x1be22, 0x1be24, 0x1be28, 0x1be42, 0x1be44, 0x1be48, 0x1be50, 0x1be5e, 0x1be66, 0x1be82, 0x1be84, 0x1be88, 0x1be90, 0x1be9e, 0x1bea0, 0x1bebc, 0x1becc, 0x1bef4, 0x1bf1a, 0x1bf2e, 0x1bf32, 0x1bf34, 0x1bf4e, 0x1bf5c, 0x1bf62, 0x1bf64, 0x1bf68, 0x1c09a, 0x1c0b2, 0x1c0b4, 0x1c11a, 0x1c132, 0x1c134, 0x1c162, 0x1c164, 0x1c168, 0x1c176, 0x1c1ba, 0x1c21a, 0x1c232, 0x1c234, 0x1c24e, 0x1c25c, 0x1c262, 0x1c264, 0x1c268, 0x1c276, 0x1c28e, 0x1c2c2, 0x1c2c4, 0x1c2c8, 0x1c2d0, 0x1c2de, 0x1c2e6, 0x1c2ec, 0x1c2fa, 0x1c316, 0x1c326, 0x1c33a, 0x1c346, 0x1c34c, 0x1c372, 0x1c374, 0x1c41a, 0x1c42e, 0x1c432, 0x1c434, 0x1c44e, 0x1c45c, 0x1c462, 0x1c464, 0x1c468, 0x1c476, 0x1c48e, 0x1c49c, 0x1c4b8, 0x1c4c2, 0x1c4c8, 0x1c4d0, 0x1c4de, 0x1c4e6, 0x1c4ec, 0x1c4fa, 0x1c51c, 0x1c538, 0x1c570, 0x1c57e, 0x1c582, 0x1c584, 0x1c588, 0x1c590, 0x1c59e, 0x1c5a0, 0x1c5bc, 0x1c5c6, 0x1c5cc, 0x1c5d8, 0x1c5ee, 0x1c5f2, 0x1c5f4, 0x1c616, 0x1c626, 0x1c62c, 0x1c63a, 0x1c646, 0x1c64c, 0x1c658, 0x1c66e, 0x1c672, 0x1c674, 0x1c686, 0x1c68c, 0x1c698, 0x1c6b0, 0x1c6be, 0x1c6ce, 0x1c6dc, 0x1c6e2, 0x1c6e4, 0x1c6e8, 0x1c712, 0x1c714, 0x1c722, 0x1c728, 0x1c736, 0x1c742, 0x1c744, 0x1c748, 0x1c750, 0x1c75e, 0x1c766, 0x1c76c, 0x1c77a, 0x1c7ae, 0x1c7d6, 0x1c7ea, 0x1c81a, 0x1c82e, 0x1c832, 0x1c834, 0x1c84e, 0x1c85c, 0x1c862, 0x1c864, 0x1c868, 0x1c876, 0x1c88e, 0x1c89c, 0x1c8b8, 0x1c8c2, 0x1c8c8, 0x1c8d0, 0x1c8de, 0x1c8e6, 0x1c8ec, 0x1c8fa, 0x1c90e, 0x1c938, 0x1c970, 0x1c97e, 0x1c982, 0x1c984, 0x1c990, 0x1c99e, 0x1c9a0, 0x1c9bc, 0x1c9c6, 0x1c9cc, 0x1c9d8, 0x1c9ee, 0x1c9f2, 0x1c9f4, 0x1ca38, 0x1ca70, 0x1ca7e, 0x1cae0, 0x1cafc, 0x1cb02, 0x1cb04, 0x1cb08, 0x1cb10, 0x1cb20, 0x1cb3c, 0x1cb40, 0x1cb78, 0x1cb86, 0x1cb8c, 0x1cb98, 0x1cbb0, 0x1cbbe, 0x1cbce, 0x1cbdc, 0x1cbe2, 0x1cbe4, 0x1cbe8, 0x1cbf6, 0x1cc16, 0x1cc26, 0x1cc2c, 0x1cc3a, 0x1cc46, 0x1cc58, 0x1cc72, 0x1cc74, 0x1cc86, 0x1ccb0, 0x1ccbe, 0x1ccce, 0x1cce2, 0x1cce4, 0x1cce8, 0x1cd06, 0x1cd0c, 0x1cd18, 0x1cd30, 0x1cd3e, 0x1cd60, 0x1cd7c, 0x1cd9c, 0x1cdc2, 0x1cdc4, 0x1cdc8, 0x1cdd0, 0x1cdde, 0x1cde6, 0x1cdfa, 0x1ce22, 0x1ce28, 0x1ce42, 0x1ce50, 0x1ce5e, 0x1ce66, 0x1ce7a, 0x1ce82, 0x1ce84, 0x1ce88, 0x1ce90, 0x1ce9e, 0x1cea0, 0x1cebc, 0x1cecc, 0x1cef2, 0x1cef4, 0x1cf2e, 0x1cf32, 0x1cf34, 0x1cf4e, 0x1cf5c, 0x1cf62, 0x1cf64, 0x1cf68, 0x1cf96, 0x1cfa6, 0x1cfac, 0x1cfca, 0x1cfd2, 0x1cfd4, 0x1d02e, 0x1d032, 0x1d034, 0x1d04e, 0x1d05c, 0x1d062, 0x1d064, 0x1d068, 0x1d076, 0x1d08e, 0x1d09c, 0x1d0b8, 0x1d0c2, 0x1d0c4, 0x1d0c8, 0x1d0d0, 0x1d0de, 0x1d0e6, 0x1d0ec, 0x1d0fa, 0x1d11c, 0x1d138, 0x1d170, 0x1d17e, 0x1d182, 0x1d184, 0x1d188, 0x1d190, 0x1d19e, 0x1d1a0, 0x1d1bc, 0x1d1c6, 0x1d1cc, 0x1d1d8, 0x1d1ee, 0x1d1f2, 0x1d1f4, 0x1d21c, 0x1d238, 0x1d270, 0x1d27e, 0x1d2e0, 0x1d2fc, 0x1d302, 0x1d304, 0x1d308, 0x1d310, 0x1d31e, 0x1d320, 0x1d33c, 0x1d340, 0x1d378, 0x1d386, 0x1d38c, 0x1d398, 0x1d3b0, 0x1d3be, 0x1d3ce, 0x1d3dc, 0x1d3e2, 0x1d3e4, 0x1d3e8, 0x1d3f6, 0x1d470, 0x1d47e, 0x1d4e0, 0x1d4fc, 0x1d5c0, 0x1d5f8, 0x1d604, 0x1d608, 0x1d610, 0x1d620, 0x1d640, 0x1d678, 0x1d6f0, 0x1d706, 0x1d70c, 0x1d718, 0x1d730, 0x1d73e, 0x1d760, 0x1d77c, 0x1d78e, 0x1d79c, 0x1d7b8, 0x1d7c2, 0x1d7c4, 0x1d7c8, 0x1d7d0, 0x1d7de, 0x1d7e6, 0x1d7ec, 0x1d826, 0x1d82c, 0x1d83a, 0x1d846, 0x1d84c, 0x1d858, 0x1d872, 0x1d874, 0x1d886, 0x1d88c, 0x1d898, 0x1d8b0, 0x1d8be, 0x1d8ce, 0x1d8e2, 0x1d8e4, 0x1d8e8, 0x1d8f6, 0x1d90c, 0x1d918, 0x1d930, 0x1d93e, 0x1d960, 0x1d97c, 0x1d99c, 0x1d9c2, 0x1d9c4, 0x1d9c8, 0x1d9d0, 0x1d9e6, 0x1d9fa, 0x1da0c, 0x1da18, 0x1da30, 0x1da3e, 0x1da60, 0x1da7c, 0x1dac0, 0x1daf8, 0x1db38, 0x1db82, 0x1db84, 0x1db88, 0x1db90, 0x1db9e, 0x1dba0, 0x1dbcc, 0x1dbf2, 0x1dbf4, 0x1dc22, 0x1dc42, 0x1dc44, 0x1dc48, 0x1dc50, 0x1dc5e, 0x1dc66, 0x1dc7a, 0x1dc82, 0x1dc84, 0x1dc88, 0x1dc90, 0x1dc9e, 0x1dca0, 0x1dcbc, 0x1dccc, 0x1dcf2, 0x1dcf4, 0x1dd04, 0x1dd08, 0x1dd10, 0x1dd1e, 0x1dd20, 0x1dd3c, 0x1dd40, 0x1dd78, 0x1dd86, 0x1dd98, 0x1ddce, 0x1dde2, 0x1dde4, 0x1dde8, 0x1de2e, 0x1de32, 0x1de34, 0x1de4e, 0x1de5c, 0x1de62, 0x1de64, 0x1de68, 0x1de8e, 0x1de9c, 0x1deb8, 0x1dec2, 0x1dec4, 0x1dec8, 0x1ded0, 0x1dee6, 0x1defa, 0x1df16, 0x1df26, 0x1df2c, 0x1df46, 0x1df4c, 0x1df58, 0x1df72, 0x1df74, 0x1df8a, 0x1df92, 0x1df94, 0x1dfa2, 0x1dfa4, 0x1dfa8, 0x1e08a, 0x1e092, 0x1e094, 0x1e0a2, 0x1e0a4, 0x1e0a8, 0x1e0b6, 0x1e0da, 0x1e10a, 0x1e112, 0x1e114, 0x1e122, 0x1e124, 0x1e128, 0x1e136, 0x1e142, 0x1e144, 0x1e148, 0x1e150, 0x1e166, 0x1e16c, 0x1e17a, 0x1e19a, 0x1e1b2, 0x1e1b4, 0x1e20a, 0x1e212, 0x1e214, 0x1e222, 0x1e224, 0x1e228, 0x1e236, 0x1e242, 0x1e248, 0x1e250, 0x1e25e, 0x1e266, 0x1e26c, 0x1e27a, 0x1e282, 0x1e284, 0x1e288, 0x1e290, 0x1e2a0, 0x1e2bc, 0x1e2c6, 0x1e2cc, 0x1e2d8, 0x1e2ee, 0x1e2f2, 0x1e2f4, 0x1e31a, 0x1e332, 0x1e334, 0x1e35c, 0x1e362, 0x1e364, 0x1e368, 0x1e3ba, 0x1e40a, 0x1e412, 0x1e414, 0x1e422, 0x1e428, 0x1e436, 0x1e442, 0x1e448, 0x1e450, 0x1e45e, 0x1e466, 0x1e46c, 0x1e47a, 0x1e482, 0x1e484, 0x1e490, 0x1e49e, 0x1e4a0, 0x1e4bc, 0x1e4c6, 0x1e4cc, 0x1e4d8, 0x1e4ee, 0x1e4f2, 0x1e4f4, 0x1e502, 0x1e504, 0x1e508, 0x1e510, 0x1e51e, 0x1e520, 0x1e53c, 0x1e540, 0x1e578, 0x1e586, 0x1e58c, 0x1e598, 0x1e5b0, 0x1e5be, 0x1e5ce, 0x1e5dc, 0x1e5e2, 0x1e5e4, 0x1e5e8, 0x1e5f6, 0x1e61a, 0x1e62e, 0x1e632, 0x1e634, 0x1e64e, 0x1e65c, 0x1e662, 0x1e668, 0x1e68e, 0x1e69c, 0x1e6b8, 0x1e6c2, 0x1e6c4, 0x1e6c8, 0x1e6d0, 0x1e6e6, 0x1e6fa, 0x1e716, 0x1e726, 0x1e72c, 0x1e73a, 0x1e746, 0x1e74c, 0x1e758, 0x1e772, 0x1e774, 0x1e792, 0x1e794, 0x1e7a2, 0x1e7a4, 0x1e7a8, 0x1e7b6, 0x1e812, 0x1e814, 0x1e822, 0x1e824, 0x1e828, 0x1e836, 0x1e842, 0x1e844, 0x1e848, 0x1e850, 0x1e85e, 0x1e866, 0x1e86c, 0x1e87a, 0x1e882, 0x1e884, 0x1e888, 0x1e890, 0x1e89e, 0x1e8a0, 0x1e8bc, 0x1e8c6, 0x1e8cc, 0x1e8d8, 0x1e8ee, 0x1e8f2, 0x1e8f4, 0x1e902, 0x1e904, 0x1e908, 0x1e910, 0x1e920, 0x1e93c, 0x1e940, 0x1e978, 0x1e986, 0x1e98c, 0x1e998, 0x1e9b0, 0x1e9be, 0x1e9ce, 0x1e9dc, 0x1e9e2, 0x1e9e4, 0x1e9e8, 0x1e9f6, 0x1ea04, 0x1ea08, 0x1ea10, 0x1ea20, 0x1ea40, 0x1ea78, 0x1eaf0, 0x1eb06, 0x1eb0c, 0x1eb18, 0x1eb30, 0x1eb3e, 0x1eb60, 0x1eb7c, 0x1eb8e, 0x1eb9c, 0x1ebb8, 0x1ebc2, 0x1ebc4, 0x1ebc8, 0x1ebd0, 0x1ebde, 0x1ebe6, 0x1ebec, 0x1ec1a, 0x1ec2e, 0x1ec32, 0x1ec34, 0x1ec4e, 0x1ec5c, 0x1ec62, 0x1ec64, 0x1ec68, 0x1ec8e, 0x1ec9c, 0x1ecb8, 0x1ecc2, 0x1ecc4, 0x1ecc8, 0x1ecd0, 0x1ece6, 0x1ecfa, 0x1ed0e, 0x1ed1c, 0x1ed38, 0x1ed70, 0x1ed7e, 0x1ed82, 0x1ed84, 0x1ed88, 0x1ed90, 0x1ed9e, 0x1eda0, 0x1edcc, 0x1edf2, 0x1edf4, 0x1ee16, 0x1ee26, 0x1ee2c, 0x1ee3a, 0x1ee46, 0x1ee4c, 0x1ee58, 0x1ee6e, 0x1ee72, 0x1ee74, 0x1ee86, 0x1ee8c, 0x1ee98, 0x1eeb0, 0x1eebe, 0x1eece, 0x1eedc, 0x1eee2, 0x1eee4, 0x1eee8, 0x1ef12, 0x1ef22, 0x1ef24, 0x1ef28, 0x1ef36, 0x1ef42, 0x1ef44, 0x1ef48, 0x1ef50, 0x1ef5e, 0x1ef66, 0x1ef6c, 0x1ef7a, 0x1efae, 0x1efb2, 0x1efb4, 0x1efd6, 0x1f096, 0x1f0a6, 0x1f0ac, 0x1f0ba, 0x1f0ca, 0x1f0d2, 0x1f0d4, 0x1f116, 0x1f126, 0x1f12c, 0x1f13a, 0x1f146, 0x1f14c, 0x1f158, 0x1f16e, 0x1f172, 0x1f174, 0x1f18a, 0x1f192, 0x1f194, 0x1f1a2, 0x1f1a4, 0x1f1a8, 0x1f1da, 0x1f216, 0x1f226, 0x1f22c, 0x1f23a, 0x1f246, 0x1f258, 0x1f26e, 0x1f272, 0x1f274, 0x1f286, 0x1f28c, 0x1f298, 0x1f2b0, 0x1f2be, 0x1f2ce, 0x1f2dc, 0x1f2e2, 0x1f2e4, 0x1f2e8, 0x1f2f6, 0x1f30a, 0x1f312, 0x1f314, 0x1f322, 0x1f328, 0x1f342, 0x1f344, 0x1f348, 0x1f350, 0x1f35e, 0x1f366, 0x1f37a, 0x1f39a, 0x1f3ae, 0x1f3b2, 0x1f3b4, 0x1f416, 0x1f426, 0x1f42c, 0x1f43a, 0x1f446, 0x1f44c, 0x1f458, 0x1f46e, 0x1f472, 0x1f474, 0x1f486, 0x1f48c, 0x1f498, 0x1f4b0, 0x1f4be, 0x1f4ce, 0x1f4dc, 0x1f4e2, 0x1f4e4, 0x1f4e8, 0x1f4f6, 0x1f506, 0x1f50c, 0x1f518, 0x1f530, 0x1f53e, 0x1f560, 0x1f57c, 0x1f58e, 0x1f59c, 0x1f5b8, 0x1f5c2, 0x1f5c4, 0x1f5c8, 0x1f5d0, 0x1f5de, 0x1f5e6, 0x1f5ec, 0x1f5fa, 0x1f60a, 0x1f612, 0x1f614, 0x1f622, 0x1f624, 0x1f628, 0x1f636, 0x1f642, 0x1f644, 0x1f648, 0x1f650, 0x1f65e, 0x1f666, 0x1f67a, 0x1f682, 0x1f684, 0x1f688, 0x1f690, 0x1f69e, 0x1f6a0, 0x1f6bc, 0x1f6cc, 0x1f6f2, 0x1f6f4, 0x1f71a, 0x1f72e, 0x1f732, 0x1f734, 0x1f74e, 0x1f75c, 0x1f762, 0x1f764, 0x1f768, 0x1f776, 0x1f796, 0x1f7a6, 0x1f7ac, 0x1f7ba, 0x1f7d2, 0x1f7d4, 0x1f89a, 0x1f8ae, 0x1f8b2, 0x1f8b4, 0x1f8d6, 0x1f8ea, 0x1f91a, 0x1f92e, 0x1f932, 0x1f934, 0x1f94e, 0x1f95c, 0x1f962, 0x1f964, 0x1f968, 0x1f976, 0x1f996, 0x1f9a6, 0x1f9ac, 0x1f9ba, 0x1f9ca, 0x1f9d2, 0x1f9d4, 0x1fa1a, 0x1fa2e, 0x1fa32, 0x1fa34, 0x1fa4e, 0x1fa5c, 0x1fa62, 0x1fa64, 0x1fa68, 0x1fa76, 0x1fa8e, 0x1fa9c, 0x1fab8, 0x1fac2, 0x1fac4, 0x1fac8, 0x1fad0, 0x1fade, 0x1fae6, 0x1faec, 0x1fb16, 0x1fb26, 0x1fb2c, 0x1fb3a, 0x1fb46, 0x1fb4c, 0x1fb58, 0x1fb6e, 0x1fb72, 0x1fb74, 0x1fb8a, 0x1fb92, 0x1fb94, 0x1fba2, 0x1fba4, 0x1fba8, 0x1fbb6, 0x1fbda, ] -; - -/** - * This table contains to codewords for all symbols. - */ - const CODEWORD_TABLE: vec![Vec; 2787] = vec![2627, 1819, 2622, 2621, 1813, 1812, 2729, 2724, 2723, 2779, 2774, 2773, 902, 896, 908, 868, 865, 861, 859, 2511, 873, 871, 1780, 835, 2493, 825, 2491, 842, 837, 844, 1764, 1762, 811, 810, 809, 2483, 807, 2482, 806, 2480, 815, 814, 813, 812, 2484, 817, 816, 1745, 1744, 1742, 1746, 2655, 2637, 2635, 2626, 2625, 2623, 2628, 1820, 2752, 2739, 2737, 2728, 2727, 2725, 2730, 2785, 2783, 2778, 2777, 2775, 2780, 787, 781, 747, 739, 736, 2413, 754, 752, 1719, 692, 689, 681, 2371, 678, 2369, 700, 697, 694, 703, 1688, 1686, 642, 638, 2343, 631, 2341, 627, 2338, 651, 646, 643, 2345, 654, 652, 1652, 1650, 1647, 1654, 601, 599, 2322, 596, 2321, 594, 2319, 2317, 611, 610, 608, 606, 2324, 603, 2323, 615, 614, 612, 1617, 1616, 1614, 1612, 616, 1619, 1618, 2575, 2538, 2536, 905, 901, 898, 909, 2509, 2507, 2504, 870, 867, 864, 860, 2512, 875, 872, 1781, 2490, 2489, 2487, 2485, 1748, 836, 834, 832, 830, 2494, 827, 2492, 843, 841, 839, 845, 1765, 1763, 2701, 2676, 2674, 2653, 2648, 2656, 2634, 2633, 2631, 2629, 1821, 2638, 2636, 2770, 2763, 2761, 2750, 2745, 2753, 2736, 2735, 2733, 2731, 1848, 2740, 2738, 2786, 2784, 591, 588, 576, 569, 566, 2296, 1590, 537, 534, 526, 2276, 522, 2274, 545, 542, 539, 548, 1572, 1570, 481, 2245, 466, 2242, 462, 2239, 492, 485, 482, 2249, 496, 494, 1534, 1531, 1528, 1538, 413, 2196, 406, 2191, 2188, 425, 419, 2202, 415, 2199, 432, 430, 427, 1472, 1467, 1464, 433, 1476, 1474, 368, 367, 2160, 365, 2159, 362, 2157, 2155, 2152, 378, 377, 375, 2166, 372, 2165, 369, 2162, 383, 381, 379, 2168, 1419, 1418, 1416, 1414, 385, 1411, 384, 1423, 1422, 1420, 1424, 2461, 802, 2441, 2439, 790, 786, 783, 794, 2409, 2406, 2403, 750, 742, 738, 2414, 756, 753, 1720, 2367, 2365, 2362, 2359, 1663, 693, 691, 684, 2373, 680, 2370, 702, 699, 696, 704, 1690, 1687, 2337, 2336, 2334, 2332, 1624, 2329, 1622, 640, 637, 2344, 634, 2342, 630, 2340, 650, 648, 645, 2346, 655, 653, 1653, 1651, 1649, 1655, 2612, 2597, 2595, 2571, 2568, 2565, 2576, 2534, 2529, 2526, 1787, 2540, 2537, 907, 904, 900, 910, 2503, 2502, 2500, 2498, 1768, 2495, 1767, 2510, 2508, 2506, 869, 866, 863, 2513, 876, 874, 1782, 2720, 2713, 2711, 2697, 2694, 2691, 2702, 2672, 2670, 2664, 1828, 2678, 2675, 2647, 2646, 2644, 2642, 1823, 2639, 1822, 2654, 2652, 2650, 2657, 2771, 1855, 2765, 2762, 1850, 1849, 2751, 2749, 2747, 2754, 353, 2148, 344, 342, 336, 2142, 332, 2140, 345, 1375, 1373, 306, 2130, 299, 2128, 295, 2125, 319, 314, 311, 2132, 1354, 1352, 1349, 1356, 262, 257, 2101, 253, 2096, 2093, 274, 273, 267, 2107, 263, 2104, 280, 278, 275, 1316, 1311, 1308, 1320, 1318, 2052, 202, 2050, 2044, 2040, 219, 2063, 212, 2060, 208, 2055, 224, 221, 2066, 1260, 1258, 1252, 231, 1248, 229, 1266, 1264, 1261, 1268, 155, 1998, 153, 1996, 1994, 1991, 1988, 165, 164, 2007, 162, 2006, 159, 2003, 2000, 172, 171, 169, 2012, 166, 2010, 1186, 1184, 1182, 1179, 175, 1176, 173, 1192, 1191, 1189, 1187, 176, 1194, 1193, 2313, 2307, 2305, 592, 589, 2294, 2292, 2289, 578, 572, 568, 2297, 580, 1591, 2272, 2267, 2264, 1547, 538, 536, 529, 2278, 525, 2275, 547, 544, 541, 1574, 1571, 2237, 2235, 2229, 1493, 2225, 1489, 478, 2247, 470, 2244, 465, 2241, 493, 488, 484, 2250, 498, 495, 1536, 1533, 1530, 1539, 2187, 2186, 2184, 2182, 1432, 2179, 1430, 2176, 1427, 414, 412, 2197, 409, 2195, 405, 2193, 2190, 426, 424, 421, 2203, 418, 2201, 431, 429, 1473, 1471, 1469, 1466, 434, 1477, 1475, 2478, 2472, 2470, 2459, 2457, 2454, 2462, 803, 2437, 2432, 2429, 1726, 2443, 2440, 792, 789, 785, 2401, 2399, 2393, 1702, 2389, 1699, 2411, 2408, 2405, 745, 741, 2415, 758, 755, 1721, 2358, 2357, 2355, 2353, 1661, 2350, 1660, 2347, 1657, 2368, 2366, 2364, 2361, 1666, 690, 687, 2374, 683, 2372, 701, 698, 705, 1691, 1689, 2619, 2617, 2610, 2608, 2605, 2613, 2593, 2588, 2585, 1803, 2599, 2596, 2563, 2561, 2555, 1797, 2551, 1795, 2573, 2570, 2567, 2577, 2525, 2524, 2522, 2520, 1786, 2517, 1785, 2514, 1783, 2535, 2533, 2531, 2528, 1788, 2541, 2539, 906, 903, 911, 2721, 1844, 2715, 2712, 1838, 1836, 2699, 2696, 2693, 2703, 1827, 1826, 1824, 2673, 2671, 2669, 2666, 1829, 2679, 2677, 1858, 1857, 2772, 1854, 1853, 1851, 1856, 2766, 2764, 143, 1987, 139, 1986, 135, 133, 131, 1984, 128, 1983, 125, 1981, 138, 137, 136, 1985, 1133, 1132, 1130, 112, 110, 1974, 107, 1973, 104, 1971, 1969, 122, 121, 119, 117, 1977, 114, 1976, 124, 1115, 1114, 1112, 1110, 1117, 1116, 84, 83, 1953, 81, 1952, 78, 1950, 1948, 1945, 94, 93, 91, 1959, 88, 1958, 85, 1955, 99, 97, 95, 1961, 1086, 1085, 1083, 1081, 1078, 100, 1090, 1089, 1087, 1091, 49, 47, 1917, 44, 1915, 1913, 1910, 1907, 59, 1926, 56, 1925, 53, 1922, 1919, 66, 64, 1931, 61, 1929, 1042, 1040, 1038, 71, 1035, 70, 1032, 68, 1048, 1047, 1045, 1043, 1050, 1049, 12, 10, 1869, 1867, 1864, 1861, 21, 1880, 19, 1877, 1874, 1871, 28, 1888, 25, 1886, 22, 1883, 982, 980, 977, 974, 32, 30, 991, 989, 987, 984, 34, 995, 994, 992, 2151, 2150, 2147, 2146, 2144, 356, 355, 354, 2149, 2139, 2138, 2136, 2134, 1359, 343, 341, 338, 2143, 335, 2141, 348, 347, 346, 1376, 1374, 2124, 2123, 2121, 2119, 1326, 2116, 1324, 310, 308, 305, 2131, 302, 2129, 298, 2127, 320, 318, 316, 313, 2133, 322, 321, 1355, 1353, 1351, 1357, 2092, 2091, 2089, 2087, 1276, 2084, 1274, 2081, 1271, 259, 2102, 256, 2100, 252, 2098, 2095, 272, 269, 2108, 266, 2106, 281, 279, 277, 1317, 1315, 1313, 1310, 282, 1321, 1319, 2039, 2037, 2035, 2032, 1203, 2029, 1200, 1197, 207, 2053, 205, 2051, 201, 2049, 2046, 2043, 220, 218, 2064, 215, 2062, 211, 2059, 228, 226, 223, 2069, 1259, 1257, 1254, 232, 1251, 230, 1267, 1265, 1263, 2316, 2315, 2312, 2311, 2309, 2314, 2304, 2303, 2301, 2299, 1593, 2308, 2306, 590, 2288, 2287, 2285, 2283, 1578, 2280, 1577, 2295, 2293, 2291, 579, 577, 574, 571, 2298, 582, 581, 1592, 2263, 2262, 2260, 2258, 1545, 2255, 1544, 2252, 1541, 2273, 2271, 2269, 2266, 1550, 535, 532, 2279, 528, 2277, 546, 543, 549, 1575, 1573, 2224, 2222, 2220, 1486, 2217, 1485, 2214, 1482, 1479, 2238, 2236, 2234, 2231, 1496, 2228, 1492, 480, 477, 2248, 473, 2246, 469, 2243, 490, 487, 2251, 497, 1537, 1535, 1532, 2477, 2476, 2474, 2479, 2469, 2468, 2466, 2464, 1730, 2473, 2471, 2453, 2452, 2450, 2448, 1729, 2445, 1728, 2460, 2458, 2456, 2463, 805, 804, 2428, 2427, 2425, 2423, 1725, 2420, 1724, 2417, 1722, 2438, 2436, 2434, 2431, 1727, 2444, 2442, 793, 791, 788, 795, 2388, 2386, 2384, 1697, 2381, 1696, 2378, 1694, 1692, 2402, 2400, 2398, 2395, 1703, 2392, 1701, 2412, 2410, 2407, 751, 748, 744, 2416, 759, 757, 1807, 2620, 2618, 1806, 1805, 2611, 2609, 2607, 2614, 1802, 1801, 1799, 2594, 2592, 2590, 2587, 1804, 2600, 2598, 1794, 1793, 1791, 1789, 2564, 2562, 2560, 2557, 1798, 2554, 1796, 2574, 2572, 2569, 2578, 1847, 1846, 2722, 1843, 1842, 1840, 1845, 2716, 2714, 1835, 1834, 1832, 1830, 1839, 1837, 2700, 2698, 2695, 2704, 1817, 1811, 1810, 897, 862, 1777, 829, 826, 838, 1760, 1758, 808, 2481, 1741, 1740, 1738, 1743, 2624, 1818, 2726, 2776, 782, 740, 737, 1715, 686, 679, 695, 1682, 1680, 639, 628, 2339, 647, 644, 1645, 1643, 1640, 1648, 602, 600, 597, 595, 2320, 593, 2318, 609, 607, 604, 1611, 1610, 1608, 1606, 613, 1615, 1613, 2328, 926, 924, 892, 886, 899, 857, 850, 2505, 1778, 824, 823, 821, 819, 2488, 818, 2486, 833, 831, 828, 840, 1761, 1759, 2649, 2632, 2630, 2746, 2734, 2732, 2782, 2781, 570, 567, 1587, 531, 527, 523, 540, 1566, 1564, 476, 467, 463, 2240, 486, 483, 1524, 1521, 1518, 1529, 411, 403, 2192, 399, 2189, 423, 416, 1462, 1457, 1454, 428, 1468, 1465, 2210, 366, 363, 2158, 360, 2156, 357, 2153, 376, 373, 370, 2163, 1410, 1409, 1407, 1405, 382, 1402, 380, 1417, 1415, 1412, 1421, 2175, 2174, 777, 774, 771, 784, 732, 725, 722, 2404, 743, 1716, 676, 674, 668, 2363, 665, 2360, 685, 1684, 1681, 626, 624, 622, 2335, 620, 2333, 617, 2330, 641, 635, 649, 1646, 1644, 1642, 2566, 928, 925, 2530, 2527, 894, 891, 888, 2501, 2499, 2496, 858, 856, 854, 851, 1779, 2692, 2668, 2665, 2645, 2643, 2640, 2651, 2768, 2759, 2757, 2744, 2743, 2741, 2748, 352, 1382, 340, 337, 333, 1371, 1369, 307, 300, 296, 2126, 315, 312, 1347, 1342, 1350, 261, 258, 250, 2097, 246, 2094, 271, 268, 264, 1306, 1301, 1298, 276, 1312, 1309, 2115, 203, 2048, 195, 2045, 191, 2041, 213, 209, 2056, 1246, 1244, 1238, 225, 1234, 222, 1256, 1253, 1249, 1262, 2080, 2079, 154, 1997, 150, 1995, 147, 1992, 1989, 163, 160, 2004, 156, 2001, 1175, 1174, 1172, 1170, 1167, 170, 1164, 167, 1185, 1183, 1180, 1177, 174, 1190, 1188, 2025, 2024, 2022, 587, 586, 564, 559, 556, 2290, 573, 1588, 520, 518, 512, 2268, 508, 2265, 530, 1568, 1565, 461, 457, 2233, 450, 2230, 446, 2226, 479, 471, 489, 1526, 1523, 1520, 397, 395, 2185, 392, 2183, 389, 2180, 2177, 410, 2194, 402, 422, 1463, 1461, 1459, 1456, 1470, 2455, 799, 2433, 2430, 779, 776, 773, 2397, 2394, 2390, 734, 728, 724, 746, 1717, 2356, 2354, 2351, 2348, 1658, 677, 675, 673, 670, 667, 688, 1685, 1683, 2606, 2589, 2586, 2559, 2556, 2552, 927, 2523, 2521, 2518, 2515, 1784, 2532, 895, 893, 890, 2718, 2709, 2707, 2689, 2687, 2684, 2663, 2662, 2660, 2658, 1825, 2667, 2769, 1852, 2760, 2758, 142, 141, 1139, 1138, 134, 132, 129, 126, 1982, 1129, 1128, 1126, 1131, 113, 111, 108, 105, 1972, 101, 1970, 120, 118, 115, 1109, 1108, 1106, 1104, 123, 1113, 1111, 82, 79, 1951, 75, 1949, 72, 1946, 92, 89, 86, 1956, 1077, 1076, 1074, 1072, 98, 1069, 96, 1084, 1082, 1079, 1088, 1968, 1967, 48, 45, 1916, 42, 1914, 39, 1911, 1908, 60, 57, 54, 1923, 50, 1920, 1031, 1030, 1028, 1026, 67, 1023, 65, 1020, 62, 1041, 1039, 1036, 1033, 69, 1046, 1044, 1944, 1943, 1941, 11, 9, 1868, 7, 1865, 1862, 1859, 20, 1878, 16, 1875, 13, 1872, 970, 968, 966, 963, 29, 960, 26, 23, 983, 981, 978, 975, 33, 971, 31, 990, 988, 985, 1906, 1904, 1902, 993, 351, 2145, 1383, 331, 330, 328, 326, 2137, 323, 2135, 339, 1372, 1370, 294, 293, 291, 289, 2122, 286, 2120, 283, 2117, 309, 303, 317, 1348, 1346, 1344, 245, 244, 242, 2090, 239, 2088, 236, 2085, 2082, 260, 2099, 249, 270, 1307, 1305, 1303, 1300, 1314, 189, 2038, 186, 2036, 183, 2033, 2030, 2026, 206, 198, 2047, 194, 216, 1247, 1245, 1243, 1240, 227, 1237, 1255, 2310, 2302, 2300, 2286, 2284, 2281, 565, 563, 561, 558, 575, 1589, 2261, 2259, 2256, 2253, 1542, 521, 519, 517, 514, 2270, 511, 533, 1569, 1567, 2223, 2221, 2218, 2215, 1483, 2211, 1480, 459, 456, 453, 2232, 449, 474, 491, 1527, 1525, 1522, 2475, 2467, 2465, 2451, 2449, 2446, 801, 800, 2426, 2424, 2421, 2418, 1723, 2435, 780, 778, 775, 2387, 2385, 2382, 2379, 1695, 2375, 1693, 2396, 735, 733, 730, 727, 749, 1718, 2616, 2615, 2604, 2603, 2601, 2584, 2583, 2581, 2579, 1800, 2591, 2550, 2549, 2547, 2545, 1792, 2542, 1790, 2558, 929, 2719, 1841, 2710, 2708, 1833, 1831, 2690, 2688, 2686, 1815, 1809, 1808, 1774, 1756, 1754, 1737, 1736, 1734, 1739, 1816, 1711, 1676, 1674, 633, 629, 1638, 1636, 1633, 1641, 598, 1605, 1604, 1602, 1600, 605, 1609, 1607, 2327, 887, 853, 1775, 822, 820, 1757, 1755, 1584, 524, 1560, 1558, 468, 464, 1514, 1511, 1508, 1519, 408, 404, 400, 1452, 1447, 1444, 417, 1458, 1455, 2208, 364, 361, 358, 2154, 1401, 1400, 1398, 1396, 374, 1393, 371, 1408, 1406, 1403, 1413, 2173, 2172, 772, 726, 723, 1712, 672, 669, 666, 682, 1678, 1675, 625, 623, 621, 618, 2331, 636, 632, 1639, 1637, 1635, 920, 918, 884, 880, 889, 849, 848, 847, 846, 2497, 855, 852, 1776, 2641, 2742, 2787, 1380, 334, 1367, 1365, 301, 297, 1340, 1338, 1335, 1343, 255, 251, 247, 1296, 1291, 1288, 265, 1302, 1299, 2113, 204, 196, 192, 2042, 1232, 1230, 1224, 214, 1220, 210, 1242, 1239, 1235, 1250, 2077, 2075, 151, 148, 1993, 144, 1990, 1163, 1162, 1160, 1158, 1155, 161, 1152, 157, 1173, 1171, 1168, 1165, 168, 1181, 1178, 2021, 2020, 2018, 2023, 585, 560, 557, 1585, 516, 509, 1562, 1559, 458, 447, 2227, 472, 1516, 1513, 1510, 398, 396, 393, 390, 2181, 386, 2178, 407, 1453, 1451, 1449, 1446, 420, 1460, 2209, 769, 764, 720, 712, 2391, 729, 1713, 664, 663, 661, 659, 2352, 656, 2349, 671, 1679, 1677, 2553, 922, 919, 2519, 2516, 885, 883, 881, 2685, 2661, 2659, 2767, 2756, 2755, 140, 1137, 1136, 130, 127, 1125, 1124, 1122, 1127, 109, 106, 102, 1103, 1102, 1100, 1098, 116, 1107, 1105, 1980, 80, 76, 73, 1947, 1068, 1067, 1065, 1063, 90, 1060, 87, 1075, 1073, 1070, 1080, 1966, 1965, 46, 43, 40, 1912, 36, 1909, 1019, 1018, 1016, 1014, 58, 1011, 55, 1008, 51, 1029, 1027, 1024, 1021, 63, 1037, 1034, 1940, 1939, 1937, 1942, 8, 1866, 4, 1863, 1, 1860, 956, 954, 952, 949, 946, 17, 14, 969, 967, 964, 961, 27, 957, 24, 979, 976, 972, 1901, 1900, 1898, 1896, 986, 1905, 1903, 350, 349, 1381, 329, 327, 324, 1368, 1366, 292, 290, 287, 284, 2118, 304, 1341, 1339, 1337, 1345, 243, 240, 237, 2086, 233, 2083, 254, 1297, 1295, 1293, 1290, 1304, 2114, 190, 187, 184, 2034, 180, 2031, 177, 2027, 199, 1233, 1231, 1229, 1226, 217, 1223, 1241, 2078, 2076, 584, 555, 554, 552, 550, 2282, 562, 1586, 507, 506, 504, 502, 2257, 499, 2254, 515, 1563, 1561, 445, 443, 441, 2219, 438, 2216, 435, 2212, 460, 454, 475, 1517, 1515, 1512, 2447, 798, 797, 2422, 2419, 770, 768, 766, 2383, 2380, 2376, 721, 719, 717, 714, 731, 1714, 2602, 2582, 2580, 2548, 2546, 2543, 923, 921, 2717, 2706, 2705, 2683, 2682, 2680, 1771, 1752, 1750, 1733, 1732, 1731, 1735, 1814, 1707, 1670, 1668, 1631, 1629, 1626, 1634, 1599, 1598, 1596, 1594, 1603, 1601, 2326, 1772, 1753, 1751, 1581, 1554, 1552, 1504, 1501, 1498, 1509, 1442, 1437, 1434, 401, 1448, 1445, 2206, 1392, 1391, 1389, 1387, 1384, 359, 1399, 1397, 1394, 1404, 2171, 2170, 1708, 1672, 1669, 619, 1632, 1630, 1628, 1773, 1378, 1363, 1361, 1333, 1328, 1336, 1286, 1281, 1278, 248, 1292, 1289, 2111, 1218, 1216, 1210, 197, 1206, 193, 1228, 1225, 1221, 1236, 2073, 2071, 1151, 1150, 1148, 1146, 152, 1143, 149, 1140, 145, 1161, 1159, 1156, 1153, 158, 1169, 1166, 2017, 2016, 2014, 2019, 1582, 510, 1556, 1553, 452, 448, 1506, 1500, 394, 391, 387, 1443, 1441, 1439, 1436, 1450, 2207, 765, 716, 713, 1709, 662, 660, 657, 1673, 1671, 916, 914, 879, 878, 877, 882, 1135, 1134, 1121, 1120, 1118, 1123, 1097, 1096, 1094, 1092, 103, 1101, 1099, 1979, 1059, 1058, 1056, 1054, 77, 1051, 74, 1066, 1064, 1061, 1071, 1964, 1963, 1007, 1006, 1004, 1002, 999, 41, 996, 37, 1017, 1015, 1012, 1009, 52, 1025, 1022, 1936, 1935, 1933, 1938, 942, 940, 938, 935, 932, 5, 2, 955, 953, 950, 947, 18, 943, 15, 965, 962, 958, 1895, 1894, 1892, 1890, 973, 1899, 1897, 1379, 325, 1364, 1362, 288, 285, 1334, 1332, 1330, 241, 238, 234, 1287, 1285, 1283, 1280, 1294, 2112, 188, 185, 181, 178, 2028, 1219, 1217, 1215, 1212, 200, 1209, 1227, 2074, 2072, 583, 553, 551, 1583, 505, 503, 500, 513, 1557, 1555, 444, 442, 439, 436, 2213, 455, 451, 1507, 1505, 1502, 796, 763, 762, 760, 767, 711, 710, 708, 706, 2377, 718, 715, 1710, 2544, 917, 915, 2681, 1627, 1597, 1595, 2325, 1769, 1749, 1747, 1499, 1438, 1435, 2204, 1390, 1388, 1385, 1395, 2169, 2167, 1704, 1665, 1662, 1625, 1623, 1620, 1770, 1329, 1282, 1279, 2109, 1214, 1207, 1222, 2068, 2065, 1149, 1147, 1144, 1141, 146, 1157, 1154, 2013, 2011, 2008, 2015, 1579, 1549, 1546, 1495, 1487, 1433, 1431, 1428, 1425, 388, 1440, 2205, 1705, 658, 1667, 1664, 1119, 1095, 1093, 1978, 1057, 1055, 1052, 1062, 1962, 1960, 1005, 1003, 1000, 997, 38, 1013, 1010, 1932, 1930, 1927, 1934, 941, 939, 936, 933, 6, 930, 3, 951, 948, 944, 1889, 1887, 1884, 1881, 959, 1893, 1891, 35, 1377, 1360, 1358, 1327, 1325, 1322, 1331, 1277, 1275, 1272, 1269, 235, 1284, 2110, 1205, 1204, 1201, 1198, 182, 1195, 179, 1213, 2070, 2067, 1580, 501, 1551, 1548, 440, 437, 1497, 1494, 1490, 1503, 761, 709, 707, 1706, 913, 912, 2198, 1386, 2164, 2161, 1621, 1766, 2103, 1208, 2058, 2054, 1145, 1142, 2005, 2002, 1999, 2009, 1488, 1429, 1426, 2200, 1698, 1659, 1656, 1975, 1053, 1957, 1954, 1001, 998, 1924, 1921, 1918, 1928, 937, 934, 931, 1879, 1876, 1873, 1870, 945, 1885, 1882, 1323, 1273, 1270, 2105, 1202, 1199, 1196, 1211, 2061, 2057, 1576, 1543, 1540, 1484, 1481, 1478, 1491, 1700, ] -; -pub struct PDF417Common { -} - -impl PDF417Common { - - fn new() -> PDF417Common { - } - - /** - * @param moduleBitCount values to sum - * @return sum of values - * @deprecated call {@link MathUtils#sum(int[])} - */ - pub fn get_bit_count_sum( module_bit_count: &Vec) -> i32 { - return MathUtils::sum(&module_bit_count); - } - - pub fn to_int_array( list: &Collection) -> Vec { - if list == null || list.is_empty() { - return EMPTY_INT_ARRAY; - } - let mut result: [i32; list.size()] = [0; list.size()]; - let mut i: i32 = 0; - for let integer: Integer in list { - result[i += 1 !!!check!!! post increment] = integer; - } - return result; - } - - /** - * @param symbol encoded symbol to translate to a codeword - * @return the codeword corresponding to the symbol. - */ - pub fn get_codeword( symbol: i32) -> i32 { - let i: i32 = Arrays::binary_search(&SYMBOL_TABLE, symbol & 0x3FFFF); - if i < 0 { - return -1; - } - return (CODEWORD_TABLE[i] - 1) % NUMBER_OF_CODEWORDS; - } -} - -// NEW FILE: p_d_f417_reader.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417; - -/** - * This implementation can detect and decode PDF417 codes in an image. - * - * @author Guenther Grau - */ - - const EMPTY_RESULT_ARRAY: [Option; 0] = [None; 0]; -#[derive(Reader, MultipleBarcodeReader)] -pub struct PDF417Reader { -} - -impl PDF417Reader { - - /** - * Locates and decodes a PDF417 code in an image. - * - * @return a String representing the content encoded by the PDF417 code - * @throws NotFoundException if a PDF417 code cannot be found, - * @throws FormatException if a PDF417 cannot be decoded - */ - pub fn decode(&self, image: &BinaryBitmap) -> /* throws NotFoundException, FormatException, ChecksumException */Result> { - return Ok(::decode(image, null)); - } - - pub fn decode(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException, FormatException, ChecksumException */Result> { - let result: Vec = ::decode(image, &hints, false); - if result.len() == 0 || result[0] == null { - throw NotFoundException::get_not_found_instance(); - } - return Ok(result[0]); - } - - pub fn decode_multiple(&self, image: &BinaryBitmap) -> /* throws NotFoundException */Result, Rc> { - return Ok(self.decode_multiple(image, null)); - } - - pub fn decode_multiple(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException */Result, Rc> { - let tryResult1 = 0; - 'try1: loop { - { - return Ok(::decode(image, &hints, true)); - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &FormatExceptionChecksumException | ) { - throw NotFoundException::get_not_found_instance(); - } 0 => break - } - - } - - fn decode( image: &BinaryBitmap, hints: &Map, multiple: bool) -> /* throws NotFoundException, FormatException, ChecksumException */Result, Rc> { - let results: List = ArrayList<>::new(); - let detector_result: PDF417DetectorResult = Detector::detect(image, &hints, multiple); - for let points: Vec in detector_result.get_points() { - let decoder_result: DecoderResult = PDF417ScanningDecoder::decode(&detector_result.get_bits(), points[4], points[5], points[6], points[7], &::get_min_codeword_width(points), &::get_max_codeword_width(points)); - let result: Result = Result::new(&decoder_result.get_text(), &decoder_result.get_raw_bytes(), points, BarcodeFormat::PDF_417); - result.put_metadata(ResultMetadataType::ERROR_CORRECTION_LEVEL, &decoder_result.get_e_c_level()); - let pdf417_result_metadata: PDF417ResultMetadata = decoder_result.get_other() as PDF417ResultMetadata; - if pdf417_result_metadata != null { - result.put_metadata(ResultMetadataType::PDF417_EXTRA_METADATA, pdf417_result_metadata); - } - result.put_metadata(ResultMetadataType::ORIENTATION, &detector_result.get_rotation()); - result.put_metadata(ResultMetadataType::SYMBOLOGY_IDENTIFIER, format!("]L{}", decoder_result.get_symbology_modifier())); - results.add(result); - } - return Ok(results.to_array(EMPTY_RESULT_ARRAY)); - } - - fn get_max_width( p1: &ResultPoint, p2: &ResultPoint) -> i32 { - if p1 == null || p2 == null { - return 0; - } - return Math::abs(p1.get_x() - p2.get_x()) as i32; - } - - fn get_min_width( p1: &ResultPoint, p2: &ResultPoint) -> i32 { - if p1 == null || p2 == null { - return Integer::MAX_VALUE; - } - return Math::abs(p1.get_x() - p2.get_x()) as i32; - } - - fn get_max_codeword_width( p: &Vec) -> i32 { - return Math::max(&Math::max(&::get_max_width(p[0], p[4]), ::get_max_width(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD / PDF417Common.MODULES_IN_STOP_PATTERN), &Math::max(&::get_max_width(p[1], p[5]), ::get_max_width(p[7], p[3]) * PDF417Common.MODULES_IN_CODEWORD / PDF417Common.MODULES_IN_STOP_PATTERN)); - } - - fn get_min_codeword_width( p: &Vec) -> i32 { - return Math::min(&Math::min(&::get_min_width(p[0], p[4]), ::get_min_width(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD / PDF417Common.MODULES_IN_STOP_PATTERN), &Math::min(&::get_min_width(p[1], p[5]), ::get_min_width(p[7], p[3]) * PDF417Common.MODULES_IN_CODEWORD / PDF417Common.MODULES_IN_STOP_PATTERN)); - } - - pub fn reset(&self) { - // nothing needs to be reset - } -} - -// NEW FILE: p_d_f417_result_metadata.rs -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417; - -/** - * @author Guenther Grau - */ -pub struct PDF417ResultMetadata { - - let segment_index: i32; - - let file_id: String; - - let last_segment: bool; - - let segment_count: i32 = -1; - - let sender: String; - - let addressee: String; - - let file_name: String; - - let file_size: i64 = -1; - - let timestamp: i64 = -1; - - let checksum: i32 = -1; - - let optional_data: Vec; -} - -impl PDF417ResultMetadata { - - /** - * The Segment ID represents the segment of the whole file distributed over different symbols. - * - * @return File segment index - */ - pub fn get_segment_index(&self) -> i32 { - return self.segment_index; - } - - pub fn set_segment_index(&self, segment_index: i32) { - self.segmentIndex = segment_index; - } - - /** - * Is the same for each related PDF417 symbol - * - * @return File ID - */ - pub fn get_file_id(&self) -> String { - return self.file_id; - } - - pub fn set_file_id(&self, file_id: &String) { - self.fileId = file_id; - } - - /** - * @return always null - * @deprecated use dedicated already parsed fields - */ - pub fn get_optional_data(&self) -> Vec { - return self.optional_data; - } - - /** - * @param optionalData old optional data format as int array - * @deprecated parse and use new fields - */ - pub fn set_optional_data(&self, optional_data: &Vec) { - self.optionalData = optional_data; - } - - /** - * @return true if it is the last segment - */ - pub fn is_last_segment(&self) -> bool { - return self.last_segment; - } - - pub fn set_last_segment(&self, last_segment: bool) { - self.lastSegment = last_segment; - } - - /** - * @return count of segments, -1 if not set - */ - pub fn get_segment_count(&self) -> i32 { - return self.segment_count; - } - - pub fn set_segment_count(&self, segment_count: i32) { - self.segmentCount = segment_count; - } - - pub fn get_sender(&self) -> String { - return self.sender; - } - - pub fn set_sender(&self, sender: &String) { - self.sender = sender; - } - - pub fn get_addressee(&self) -> String { - return self.addressee; - } - - pub fn set_addressee(&self, addressee: &String) { - self.addressee = addressee; - } - - /** - * Filename of the encoded file - * - * @return filename - */ - pub fn get_file_name(&self) -> String { - return self.file_name; - } - - pub fn set_file_name(&self, file_name: &String) { - self.fileName = file_name; - } - - /** - * filesize in bytes of the encoded file - * - * @return filesize in bytes, -1 if not set - */ - pub fn get_file_size(&self) -> i64 { - return self.file_size; - } - - pub fn set_file_size(&self, file_size: i64) { - self.fileSize = file_size; - } - - /** - * 16-bit CRC checksum using CCITT-16 - * - * @return crc checksum, -1 if not set - */ - pub fn get_checksum(&self) -> i32 { - return self.checksum; - } - - pub fn set_checksum(&self, checksum: i32) { - self.checksum = checksum; - } - - /** - * unix epock timestamp, elapsed seconds since 1970-01-01 - * - * @return elapsed seconds, -1 if not set - */ - pub fn get_timestamp(&self) -> i64 { - return self.timestamp; - } - - pub fn set_timestamp(&self, timestamp: i64) { - self.timestamp = timestamp; - } -} - -// NEW FILE: p_d_f417_writer.rs -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417; - -/** - * @author Jacob Haynes - * @author qwandor@google.com (Andrew Walbran) - */ - -/** - * default white space (margin) around the code - */ - const WHITE_SPACE: i32 = 30; - -/** - * default error correction level - */ - const DEFAULT_ERROR_CORRECTION_LEVEL: i32 = 2; -#[derive(Writer)] -pub struct PDF417Writer { -} - -impl PDF417Writer { - - pub fn encode(&self, contents: &String, format: &BarcodeFormat, width: i32, height: i32, hints: &Map) -> /* throws WriterException */Result> { - if format != BarcodeFormat::PDF_417 { - throw IllegalArgumentException::new(format!("Can only encode PDF_417, but got {}", format)); - } - let encoder: PDF417 = PDF417::new(); - let mut margin: i32 = WHITE_SPACE; - let error_correction_level: i32 = DEFAULT_ERROR_CORRECTION_LEVEL; - let auto_e_c_i: bool = false; - if hints != null { - if hints.contains_key(EncodeHintType::PDF417_COMPACT) { - encoder.set_compact(&Boolean::parse_boolean(&hints.get(EncodeHintType::PDF417_COMPACT).to_string())); - } - if hints.contains_key(EncodeHintType::PDF417_COMPACTION) { - encoder.set_compaction(&Compaction::value_of(&hints.get(EncodeHintType::PDF417_COMPACTION).to_string())); - } - if hints.contains_key(EncodeHintType::PDF417_DIMENSIONS) { - let dimensions: Dimensions = hints.get(EncodeHintType::PDF417_DIMENSIONS) as Dimensions; - encoder.set_dimensions(&dimensions.get_max_cols(), &dimensions.get_min_cols(), &dimensions.get_max_rows(), &dimensions.get_min_rows()); - } - if hints.contains_key(EncodeHintType::MARGIN) { - margin = Integer::parse_int(&hints.get(EncodeHintType::MARGIN).to_string()); - } - if hints.contains_key(EncodeHintType::ERROR_CORRECTION) { - error_correction_level = Integer::parse_int(&hints.get(EncodeHintType::ERROR_CORRECTION).to_string()); - } - if hints.contains_key(EncodeHintType::CHARACTER_SET) { - let encoding: Charset = Charset::for_name(&hints.get(EncodeHintType::CHARACTER_SET).to_string()); - encoder.set_encoding(&encoding); - } - auto_e_c_i = hints.contains_key(EncodeHintType::PDF417_AUTO_ECI) && Boolean::parse_boolean(&hints.get(EncodeHintType::PDF417_AUTO_ECI).to_string()); - } - return Ok(::bit_matrix_from_encoder(encoder, &contents, error_correction_level, width, height, margin, auto_e_c_i)); - } - - pub fn encode(&self, contents: &String, format: &BarcodeFormat, width: i32, height: i32) -> /* throws WriterException */Result> { - return Ok(self.encode(&contents, format, width, height, null)); - } - - /** - * Takes encoder, accounts for width/height, and retrieves bit matrix - */ - fn bit_matrix_from_encoder( encoder: &PDF417, contents: &String, error_correction_level: i32, width: i32, height: i32, margin: i32, auto_e_c_i: bool) -> /* throws WriterException */Result> { - encoder.generate_barcode_logic(&contents, error_correction_level, auto_e_c_i); - let aspect_ratio: i32 = 4; - let original_scale: Vec> = encoder.get_barcode_matrix().get_scaled_matrix(1, aspect_ratio); - let mut rotated: bool = false; - if (height > width) != (original_scale[0].len() < original_scale.len()) { - original_scale = ::rotate_array(&original_scale); - rotated = true; - } - let scale_x: i32 = width / original_scale[0].len(); - let scale_y: i32 = height / original_scale.len(); - let scale: i32 = Math::min(scale_x, scale_y); - if scale > 1 { - let scaled_matrix: Vec> = encoder.get_barcode_matrix().get_scaled_matrix(scale, scale * aspect_ratio); - if rotated { - scaled_matrix = ::rotate_array(&scaled_matrix); - } - return Ok(::bit_matrix_from_bit_array(&scaled_matrix, margin)); - } - return Ok(::bit_matrix_from_bit_array(&original_scale, margin)); - } - - /** - * This takes an array holding the values of the PDF 417 - * - * @param input a byte array of information with 0 is black, and 1 is white - * @param margin border around the barcode - * @return BitMatrix of the input - */ - fn bit_matrix_from_bit_array( input: &Vec>, margin: i32) -> BitMatrix { - // Creates the bit matrix with extra space for whitespace - let output: BitMatrix = BitMatrix::new(input[0].len() + 2 * margin, input.len() + 2 * margin); - output.clear(); - { - let mut y: i32 = 0, let y_output: i32 = output.get_height() - margin - 1; - while y < input.len() { - { - let input_y: Vec = input[y]; - { - let mut x: i32 = 0; - while x < input[0].len() { - { - // Zero is white in the byte matrix - if input_y[x] == 1 { - output.set(x + margin, y_output); - } - } - x += 1; - } - } - - } - y += 1; - y_output -= 1; - } - } - - return output; - } - - /** - * Takes and rotates the it 90 degrees - */ - fn rotate_array( bitarray: &Vec>) -> Vec> { - let mut temp: [[i8; bitarray.len()]; bitarray[0].len()] = [[0; bitarray.len()]; bitarray[0].len()]; - { - let mut ii: i32 = 0; - while ii < bitarray.len() { - { - // This makes the direction consistent on screen when rotating the - // screen; - let mut inverseii: i32 = bitarray.len() - ii - 1; - { - let mut jj: i32 = 0; - while jj < bitarray[0].len() { - { - temp[jj][inverseii] = bitarray[ii][jj]; - } - jj += 1; - } - } - - } - ii += 1; - } - } - - return temp; - } -} - diff --git a/src/pdf417/decoder.rs b/src/pdf417/decoder.rs deleted file mode 100644 index 935eb01..0000000 --- a/src/pdf417/decoder.rs +++ /dev/null @@ -1,2849 +0,0 @@ -use crate::pdf417::decoder::ec::ErrorCorrection; -use crate::common::detector::MathUtils; -use crate::common::{BitMatrix,ECIStringBuilder,DecoderResult}; -use crate::{NotFoundException,ResultPoint,FormatException,ChecksumException,}; -use crate::pdf417::{PDF417Common,PDF417ResultMetadata}; - - -// NEW FILE: barcode_metadata.rs -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder; - -/** - * @author Guenther Grau - */ -struct BarcodeMetadata { - - let column_count: i32; - - let error_correction_level: i32; - - let row_count_upper_part: i32; - - let row_count_lower_part: i32; - - let row_count: i32; -} - -impl BarcodeMetadata { - - fn new( column_count: i32, row_count_upper_part: i32, row_count_lower_part: i32, error_correction_level: i32) -> BarcodeMetadata { - let .columnCount = column_count; - let .errorCorrectionLevel = error_correction_level; - let .rowCountUpperPart = row_count_upper_part; - let .rowCountLowerPart = row_count_lower_part; - let .rowCount = row_count_upper_part + row_count_lower_part; - } - - fn get_column_count(&self) -> i32 { - return self.column_count; - } - - fn get_error_correction_level(&self) -> i32 { - return self.error_correction_level; - } - - fn get_row_count(&self) -> i32 { - return self.row_count; - } - - fn get_row_count_upper_part(&self) -> i32 { - return self.row_count_upper_part; - } - - fn get_row_count_lower_part(&self) -> i32 { - return self.row_count_lower_part; - } -} - -// NEW FILE: barcode_value.rs -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder; - -/** - * @author Guenther Grau - */ -struct BarcodeValue { - - let values: Map = HashMap<>::new(); -} - -impl BarcodeValue { - - /** - * Add an occurrence of a value - */ - fn set_value(&self, value: i32) { - let mut confidence: Integer = self.values.get(value); - if confidence == null { - confidence = 0; - } - confidence += 1; - self.values.put(value, &confidence); - } - - /** - * Determines the maximum occurrence of a set value and returns all values which were set with this occurrence. - * @return an array of int, containing the values with the highest occurrence, or null, if no value was set - */ - fn get_value(&self) -> Vec { - let max_confidence: i32 = -1; - let result: Collection = ArrayList<>::new(); - for let entry: Entry in self.values.entry_set() { - if entry.get_value() > max_confidence { - max_confidence = entry.get_value(); - result.clear(); - result.add(&entry.get_key()); - } else if entry.get_value() == max_confidence { - result.add(&entry.get_key()); - } - } - return PDF417Common::to_int_array(&result); - } - - fn get_confidence(&self, value: i32) -> Integer { - return self.values.get(value); - } -} - -// NEW FILE: bounding_box.rs -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder; - -/** - * @author Guenther Grau - */ -struct BoundingBox { - - let mut image: BitMatrix; - - let top_left: ResultPoint; - - let bottom_left: ResultPoint; - - let top_right: ResultPoint; - - let bottom_right: ResultPoint; - - let min_x: i32; - - let max_x: i32; - - let min_y: i32; - - let max_y: i32; -} - -impl BoundingBox { - - fn new( image: &BitMatrix, top_left: &ResultPoint, bottom_left: &ResultPoint, top_right: &ResultPoint, bottom_right: &ResultPoint) -> BoundingBox throws NotFoundException { - let left_unspecified: bool = top_left == null || bottom_left == null; - let right_unspecified: bool = top_right == null || bottom_right == null; - if left_unspecified && right_unspecified { - throw NotFoundException::get_not_found_instance(); - } - if left_unspecified { - top_left = ResultPoint::new(0, &top_right.get_y()); - bottom_left = ResultPoint::new(0, &bottom_right.get_y()); - } else if right_unspecified { - top_right = ResultPoint::new(image.get_width() - 1, &top_left.get_y()); - bottom_right = ResultPoint::new(image.get_width() - 1, &bottom_left.get_y()); - } - let .image = image; - let .topLeft = top_left; - let .bottomLeft = bottom_left; - let .topRight = top_right; - let .bottomRight = bottom_right; - let .minX = Math::min(&top_left.get_x(), &bottom_left.get_x()) as i32; - let .maxX = Math::max(&top_right.get_x(), &bottom_right.get_x()) as i32; - let .minY = Math::min(&top_left.get_y(), &top_right.get_y()) as i32; - let .maxY = Math::max(&bottom_left.get_y(), &bottom_right.get_y()) as i32; - } - - fn new( bounding_box: &BoundingBox) -> BoundingBox { - let .image = bounding_box.image; - let .topLeft = bounding_box.topLeft; - let .bottomLeft = bounding_box.bottomLeft; - let .topRight = bounding_box.topRight; - let .bottomRight = bounding_box.bottomRight; - let .minX = bounding_box.minX; - let .maxX = bounding_box.maxX; - let .minY = bounding_box.minY; - let .maxY = bounding_box.maxY; - } - - fn merge( left_box: &BoundingBox, right_box: &BoundingBox) -> /* throws NotFoundException */Result> { - if left_box == null { - return Ok(right_box); - } - if right_box == null { - return Ok(left_box); - } - return Ok(BoundingBox::new(left_box.image, left_box.topLeft, left_box.bottomLeft, right_box.topRight, right_box.bottomRight)); - } - - fn add_missing_rows(&self, missing_start_rows: i32, missing_end_rows: i32, is_left: bool) -> /* throws NotFoundException */Result> { - let new_top_left: ResultPoint = self.top_left; - let new_bottom_left: ResultPoint = self.bottom_left; - let new_top_right: ResultPoint = self.top_right; - let new_bottom_right: ResultPoint = self.bottom_right; - if missing_start_rows > 0 { - let top: ResultPoint = if is_left { self.top_left } else { self.top_right }; - let new_min_y: i32 = top.get_y() as i32 - missing_start_rows; - if new_min_y < 0 { - new_min_y = 0; - } - let new_top: ResultPoint = ResultPoint::new(&top.get_x(), new_min_y); - if is_left { - new_top_left = new_top; - } else { - new_top_right = new_top; - } - } - if missing_end_rows > 0 { - let bottom: ResultPoint = if is_left { self.bottom_left } else { self.bottom_right }; - let new_max_y: i32 = bottom.get_y() as i32 + missing_end_rows; - if new_max_y >= self.image.get_height() { - new_max_y = self.image.get_height() - 1; - } - let new_bottom: ResultPoint = ResultPoint::new(&bottom.get_x(), new_max_y); - if is_left { - new_bottom_left = new_bottom; - } else { - new_bottom_right = new_bottom; - } - } - return Ok(BoundingBox::new(self.image, new_top_left, new_bottom_left, new_top_right, new_bottom_right)); - } - - fn get_min_x(&self) -> i32 { - return self.min_x; - } - - fn get_max_x(&self) -> i32 { - return self.max_x; - } - - fn get_min_y(&self) -> i32 { - return self.min_y; - } - - fn get_max_y(&self) -> i32 { - return self.max_y; - } - - fn get_top_left(&self) -> ResultPoint { - return self.top_left; - } - - fn get_top_right(&self) -> ResultPoint { - return self.top_right; - } - - fn get_bottom_left(&self) -> ResultPoint { - return self.bottom_left; - } - - fn get_bottom_right(&self) -> ResultPoint { - return self.bottom_right; - } -} - -// NEW FILE: codeword.rs -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder; - -/** - * @author Guenther Grau - */ - - const BARCODE_ROW_UNKNOWN: i32 = -1; -struct Codeword { - - let start_x: i32; - - let end_x: i32; - - let bucket: i32; - - let value: i32; - - let row_number: i32 = BARCODE_ROW_UNKNOWN; -} - -impl Codeword { - - fn new( start_x: i32, end_x: i32, bucket: i32, value: i32) -> Codeword { - let .startX = start_x; - let .endX = end_x; - let .bucket = bucket; - let .value = value; - } - - fn has_valid_row_number(&self) -> bool { - return self.is_valid_row_number(self.row_number); - } - - fn is_valid_row_number(&self, row_number: i32) -> bool { - return row_number != BARCODE_ROW_UNKNOWN && self.bucket == (row_number % 3) * 3; - } - - fn set_row_number_as_row_indicator_column(&self) { - self.row_number = (self.value / 30) * 3 + self.bucket / 3; - } - - fn get_width(&self) -> i32 { - return self.end_x - self.start_x; - } - - fn get_start_x(&self) -> i32 { - return self.start_x; - } - - fn get_end_x(&self) -> i32 { - return self.end_x; - } - - fn get_bucket(&self) -> i32 { - return self.bucket; - } - - fn get_value(&self) -> i32 { - return self.value; - } - - fn get_row_number(&self) -> i32 { - return self.row_number; - } - - fn set_row_number(&self, row_number: i32) { - self.rowNumber = row_number; - } - - pub fn to_string(&self) -> String { - return format!("{}|{}", self.row_number, self.value); - } -} - -// NEW FILE: decoded_bit_stream_parser.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder; - -/** - *

This class contains the methods for decoding the PDF417 codewords.

- * - * @author SITA Lab (kevin.osullivan@sita.aero) - * @author Guenther Grau - */ - - const TEXT_COMPACTION_MODE_LATCH: i32 = 900; - - const BYTE_COMPACTION_MODE_LATCH: i32 = 901; - - const NUMERIC_COMPACTION_MODE_LATCH: i32 = 902; - - const BYTE_COMPACTION_MODE_LATCH_6: i32 = 924; - - const ECI_USER_DEFINED: i32 = 925; - - const ECI_GENERAL_PURPOSE: i32 = 926; - - const ECI_CHARSET: i32 = 927; - - const BEGIN_MACRO_PDF417_CONTROL_BLOCK: i32 = 928; - - const BEGIN_MACRO_PDF417_OPTIONAL_FIELD: i32 = 923; - - const MACRO_PDF417_TERMINATOR: i32 = 922; - - const MODE_SHIFT_TO_BYTE_COMPACTION_MODE: i32 = 913; - - const MAX_NUMERIC_CODEWORDS: i32 = 15; - - const MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME: i32 = 0; - - const MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT: i32 = 1; - - const MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP: i32 = 2; - - const MACRO_PDF417_OPTIONAL_FIELD_SENDER: i32 = 3; - - const MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE: i32 = 4; - - const MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE: i32 = 5; - - const MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM: i32 = 6; - - const PL: i32 = 25; - - const LL: i32 = 27; - - const AS: i32 = 27; - - const ML: i32 = 28; - - const AL: i32 = 28; - - const PS: i32 = 29; - - const PAL: i32 = 29; - - const PUNCT_CHARS: Vec = ";<>@[\\]_`~!\r\t,:\n-.$/\"|*()?{}'".to_char_array(); - - const MIXED_CHARS: Vec = "0123456789&\r\t,:#-.$/+%*=^".to_char_array(); - -/** - * Table containing values for the exponent of 900. - * This is used in the numeric compaction decode algorithm. - */ - const EXP900: Vec; - - const NUMBER_OF_SEQUENCE_CODEWORDS: i32 = 2; -struct DecodedBitStreamParser { -} - -impl DecodedBitStreamParser { - - enum Mode { - - ALPHA(), LOWER(), MIXED(), PUNCT(), ALPHA_SHIFT(), PUNCT_SHIFT() - } - - static { - EXP900 = : [Option; 16] = [None; 16]; - EXP900[0] = BigInteger::ONE; - let nine_hundred: BigInteger = BigInteger::value_of(900); - EXP900[1] = nine_hundred; - { - let mut i: i32 = 2; - while i < EXP900.len() { - { - EXP900[i] = EXP900[i - 1]::multiply(&nine_hundred); - } - i += 1; - } - } - - } - - fn new() -> DecodedBitStreamParser { - } - - fn decode( codewords: &Vec, ec_level: &String) -> /* throws FormatException */Result> { - let result: ECIStringBuilder = ECIStringBuilder::new(codewords.len() * 2); - let code_index: i32 = ::text_compaction(&codewords, 1, result); - let result_metadata: PDF417ResultMetadata = PDF417ResultMetadata::new(); - while code_index < codewords[0] { - let code: i32 = codewords[code_index += 1 !!!check!!! post increment]; - match code { - TEXT_COMPACTION_MODE_LATCH => - { - code_index = ::text_compaction(&codewords, code_index, result); - break; - } - BYTE_COMPACTION_MODE_LATCH => - { - } - BYTE_COMPACTION_MODE_LATCH_6 => - { - code_index = ::byte_compaction(code, &codewords, code_index, result); - break; - } - MODE_SHIFT_TO_BYTE_COMPACTION_MODE => - { - result.append(codewords[code_index += 1 !!!check!!! post increment] as char); - break; - } - NUMERIC_COMPACTION_MODE_LATCH => - { - code_index = ::numeric_compaction(&codewords, code_index, result); - break; - } - ECI_CHARSET => - { - result.append_e_c_i(codewords[code_index += 1 !!!check!!! post increment]); - break; - } - ECI_GENERAL_PURPOSE => - { - // Can't do anything with generic ECI; skip its 2 characters - code_index += 2; - break; - } - ECI_USER_DEFINED => - { - // Can't do anything with user ECI; skip its 1 character - code_index += 1; - break; - } - BEGIN_MACRO_PDF417_CONTROL_BLOCK => - { - code_index = ::decode_macro_block(&codewords, code_index, result_metadata); - break; - } - BEGIN_MACRO_PDF417_OPTIONAL_FIELD => - { - } - MACRO_PDF417_TERMINATOR => - { - // Should not see these outside a macro block - throw FormatException::get_format_instance(); - } - _ => - { - // Default to text compaction. During testing numerous barcodes - // appeared to be missing the starting mode. In these cases defaulting - // to text compaction seems to work. - code_index -= 1; - code_index = ::text_compaction(&codewords, code_index, result); - break; - } - } - } - if result.is_empty() && result_metadata.get_file_id() == null { - throw FormatException::get_format_instance(); - } - let decoder_result: DecoderResult = DecoderResult::new(null, &result.to_string(), null, &ec_level); - decoder_result.set_other(result_metadata); - return Ok(decoder_result); - } - - fn decode_macro_block( codewords: &Vec, code_index: i32, result_metadata: &PDF417ResultMetadata) -> /* throws FormatException */Result> { - if code_index + NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0] { - // we must have at least two bytes left for the segment index - throw FormatException::get_format_instance(); - } - let segment_index_array: [i32; NUMBER_OF_SEQUENCE_CODEWORDS] = [0; NUMBER_OF_SEQUENCE_CODEWORDS]; - { - let mut i: i32 = 0; - while i < NUMBER_OF_SEQUENCE_CODEWORDS { - { - segment_index_array[i] = codewords[code_index]; - } - i += 1; - code_index += 1; - } - } - - let segment_index_string: String = ::decode_base900to_base10(&segment_index_array, NUMBER_OF_SEQUENCE_CODEWORDS); - if segment_index_string.is_empty() { - result_metadata.set_segment_index(0); - } else { - let tryResult1 = 0; - 'try1: loop { - { - result_metadata.set_segment_index(&Integer::parse_int(&segment_index_string)); - } - break 'try1 - } - match tryResult1 { - catch ( nfe: &NumberFormatException) { - throw FormatException::get_format_instance(); - } 0 => break - } - - } - // Decoding the fileId codewords as 0-899 numbers, each 0-filled to width 3. This follows the spec - // (See ISO/IEC 15438:2015 Annex H.6) and preserves all info, but some generators (e.g. TEC-IT) write - // the fileId using text compaction, so in those cases the fileId will appear mangled. - let file_id: StringBuilder = StringBuilder::new(); - while code_index < codewords[0] && code_index < codewords.len() && codewords[code_index] != MACRO_PDF417_TERMINATOR && codewords[code_index] != BEGIN_MACRO_PDF417_OPTIONAL_FIELD { - file_id.append(&String::format("%03d", codewords[code_index])); - code_index += 1; - } - if file_id.length() == 0 { - // at least one fileId codeword is required (Annex H.2) - throw FormatException::get_format_instance(); - } - result_metadata.set_file_id(&file_id.to_string()); - let optional_fields_start: i32 = -1; - if codewords[code_index] == BEGIN_MACRO_PDF417_OPTIONAL_FIELD { - optional_fields_start = code_index + 1; - } - while code_index < codewords[0] { - match codewords[code_index] { - BEGIN_MACRO_PDF417_OPTIONAL_FIELD => - { - code_index += 1; - match codewords[code_index] { - MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME => - { - let file_name: ECIStringBuilder = ECIStringBuilder::new(); - code_index = ::text_compaction(&codewords, code_index + 1, file_name); - result_metadata.set_file_name(&file_name.to_string()); - break; - } - MACRO_PDF417_OPTIONAL_FIELD_SENDER => - { - let sender: ECIStringBuilder = ECIStringBuilder::new(); - code_index = ::text_compaction(&codewords, code_index + 1, sender); - result_metadata.set_sender(&sender.to_string()); - break; - } - MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE => - { - let addressee: ECIStringBuilder = ECIStringBuilder::new(); - code_index = ::text_compaction(&codewords, code_index + 1, addressee); - result_metadata.set_addressee(&addressee.to_string()); - break; - } - MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT => - { - let segment_count: ECIStringBuilder = ECIStringBuilder::new(); - code_index = ::numeric_compaction(&codewords, code_index + 1, segment_count); - result_metadata.set_segment_count(&Integer::parse_int(&segment_count.to_string())); - break; - } - MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP => - { - let timestamp: ECIStringBuilder = ECIStringBuilder::new(); - code_index = ::numeric_compaction(&codewords, code_index + 1, timestamp); - result_metadata.set_timestamp(&Long::parse_long(×tamp.to_string())); - break; - } - MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM => - { - let checksum: ECIStringBuilder = ECIStringBuilder::new(); - code_index = ::numeric_compaction(&codewords, code_index + 1, checksum); - result_metadata.set_checksum(&Integer::parse_int(&checksum.to_string())); - break; - } - MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE => - { - let file_size: ECIStringBuilder = ECIStringBuilder::new(); - code_index = ::numeric_compaction(&codewords, code_index + 1, file_size); - result_metadata.set_file_size(&Long::parse_long(&file_size.to_string())); - break; - } - _ => - { - throw FormatException::get_format_instance(); - } - } - break; - } - MACRO_PDF417_TERMINATOR => - { - code_index += 1; - result_metadata.set_last_segment(true); - break; - } - _ => - { - throw FormatException::get_format_instance(); - } - } - } - // copy optional fields to additional options - if optional_fields_start != -1 { - let optional_fields_length: i32 = code_index - optional_fields_start; - if result_metadata.is_last_segment() { - // do not include terminator - optional_fields_length -= 1; - } - result_metadata.set_optional_data(&Arrays::copy_of_range(&codewords, optional_fields_start, optional_fields_start + optional_fields_length)); - } - return Ok(code_index); - } - - /** - * Text Compaction mode (see 5.4.1.5) permits all printable ASCII characters to be - * encoded, i.e. values 32 - 126 inclusive in accordance with ISO/IEC 646 (IRV), as - * well as selected control characters. - * - * @param codewords The array of codewords (data + error) - * @param codeIndex The current index into the codeword array. - * @param result The decoded data is appended to the result. - * @return The next index into the codeword array. - */ - fn text_compaction( codewords: &Vec, code_index: i32, result: &ECIStringBuilder) -> /* throws FormatException */Result> { - // 2 character per codeword - let text_compaction_data: [i32; (codewords[0] - code_index) * 2] = [0; (codewords[0] - code_index) * 2]; - // Used to hold the byte compaction value if there is a mode shift - let byte_compaction_data: [i32; (codewords[0] - code_index) * 2] = [0; (codewords[0] - code_index) * 2]; - let mut index: i32 = 0; - let mut end: bool = false; - let sub_mode: Mode = Mode::ALPHA; - while (code_index < codewords[0]) && !end { - let mut code: i32 = codewords[code_index += 1 !!!check!!! post increment]; - if code < TEXT_COMPACTION_MODE_LATCH { - text_compaction_data[index] = code / 30; - text_compaction_data[index + 1] = code % 30; - index += 2; - } else { - match code { - TEXT_COMPACTION_MODE_LATCH => - { - // reinitialize text compaction mode to alpha sub mode - text_compaction_data[index += 1 !!!check!!! post increment] = TEXT_COMPACTION_MODE_LATCH; - break; - } - BYTE_COMPACTION_MODE_LATCH => - { - } - BYTE_COMPACTION_MODE_LATCH_6 => - { - } - NUMERIC_COMPACTION_MODE_LATCH => - { - } - BEGIN_MACRO_PDF417_CONTROL_BLOCK => - { - } - BEGIN_MACRO_PDF417_OPTIONAL_FIELD => - { - } - MACRO_PDF417_TERMINATOR => - { - code_index -= 1; - end = true; - break; - } - MODE_SHIFT_TO_BYTE_COMPACTION_MODE => - { - // The Mode Shift codeword 913 shall cause a temporary - // switch from Text Compaction mode to Byte Compaction mode. - // This switch shall be in effect for only the next codeword, - // after which the mode shall revert to the prevailing sub-mode - // of the Text Compaction mode. Codeword 913 is only available - // in Text Compaction mode; its use is described in 5.4.2.4. - text_compaction_data[index] = MODE_SHIFT_TO_BYTE_COMPACTION_MODE; - code = codewords[code_index += 1 !!!check!!! post increment]; - byte_compaction_data[index] = code; - index += 1; - break; - } - ECI_CHARSET => - { - sub_mode = ::decode_text_compaction(&text_compaction_data, &byte_compaction_data, index, result, sub_mode); - result.append_e_c_i(codewords[code_index += 1 !!!check!!! post increment]); - text_compaction_data = : [i32; (codewords[0] - code_index) * 2] = [0; (codewords[0] - code_index) * 2]; - byte_compaction_data = : [i32; (codewords[0] - code_index) * 2] = [0; (codewords[0] - code_index) * 2]; - index = 0; - break; - } - } - } - } - ::decode_text_compaction(&text_compaction_data, &byte_compaction_data, index, result, sub_mode); - return Ok(code_index); - } - - /** - * The Text Compaction mode includes all the printable ASCII characters - * (i.e. values from 32 to 126) and three ASCII control characters: HT or tab - * (ASCII value 9), LF or line feed (ASCII value 10), and CR or carriage - * return (ASCII value 13). The Text Compaction mode also includes various latch - * and shift characters which are used exclusively within the mode. The Text - * Compaction mode encodes up to 2 characters per codeword. The compaction rules - * for converting data into PDF417 codewords are defined in 5.4.2.2. The sub-mode - * switches are defined in 5.4.2.3. - * - * @param textCompactionData The text compaction data. - * @param byteCompactionData The byte compaction data if there - * was a mode shift. - * @param length The size of the text compaction and byte compaction data. - * @param result The decoded data is appended to the result. - * @param startMode The mode in which decoding starts - * @return The mode in which decoding ended - */ - fn decode_text_compaction( text_compaction_data: &Vec, byte_compaction_data: &Vec, length: i32, result: &ECIStringBuilder, start_mode: &Mode) -> Mode { - // Beginning from an initial state - // The default compaction mode for PDF417 in effect at the start of each symbol shall always be Text - // Compaction mode Alpha sub-mode (uppercase alphabetic). A latch codeword from another mode to the Text - // Compaction mode shall always switch to the Text Compaction Alpha sub-mode. - let sub_mode: Mode = start_mode; - let prior_to_shift_mode: Mode = start_mode; - let latched_mode: Mode = start_mode; - let mut i: i32 = 0; - while i < length { - let sub_mode_ch: i32 = text_compaction_data[i]; - let mut ch: char = 0; - match sub_mode { - ALPHA => - { - // Alpha (uppercase alphabetic) - if sub_mode_ch < 26 { - // Upper case Alpha Character - ch = ('A' + sub_mode_ch) as char; - } else { - match sub_mode_ch { - 26 => - { - ch = ' '; - break; - } - LL => - { - sub_mode = Mode::LOWER; - latched_mode = sub_mode; - break; - } - ML => - { - sub_mode = Mode::MIXED; - latched_mode = sub_mode; - break; - } - PS => - { - // Shift to punctuation - prior_to_shift_mode = sub_mode; - sub_mode = Mode::PUNCT_SHIFT; - break; - } - MODE_SHIFT_TO_BYTE_COMPACTION_MODE => - { - result.append(byte_compaction_data[i] as char); - break; - } - TEXT_COMPACTION_MODE_LATCH => - { - sub_mode = Mode::ALPHA; - latched_mode = sub_mode; - break; - } - } - } - break; - } - LOWER => - { - // Lower (lowercase alphabetic) - if sub_mode_ch < 26 { - ch = ('a' + sub_mode_ch) as char; - } else { - match sub_mode_ch { - 26 => - { - ch = ' '; - break; - } - AS => - { - // Shift to alpha - prior_to_shift_mode = sub_mode; - sub_mode = Mode::ALPHA_SHIFT; - break; - } - ML => - { - sub_mode = Mode::MIXED; - latched_mode = sub_mode; - break; - } - PS => - { - // Shift to punctuation - prior_to_shift_mode = sub_mode; - sub_mode = Mode::PUNCT_SHIFT; - break; - } - MODE_SHIFT_TO_BYTE_COMPACTION_MODE => - { - result.append(byte_compaction_data[i] as char); - break; - } - TEXT_COMPACTION_MODE_LATCH => - { - sub_mode = Mode::ALPHA; - latched_mode = sub_mode; - break; - } - } - } - break; - } - MIXED => - { - // Mixed (numeric and some punctuation) - if sub_mode_ch < PL { - ch = MIXED_CHARS[sub_mode_ch]; - } else { - match sub_mode_ch { - PL => - { - sub_mode = Mode::PUNCT; - latched_mode = sub_mode; - break; - } - 26 => - { - ch = ' '; - break; - } - LL => - { - sub_mode = Mode::LOWER; - latched_mode = sub_mode; - break; - } - AL => - { - } - TEXT_COMPACTION_MODE_LATCH => - { - sub_mode = Mode::ALPHA; - latched_mode = sub_mode; - break; - } - PS => - { - // Shift to punctuation - prior_to_shift_mode = sub_mode; - sub_mode = Mode::PUNCT_SHIFT; - break; - } - MODE_SHIFT_TO_BYTE_COMPACTION_MODE => - { - result.append(byte_compaction_data[i] as char); - break; - } - } - } - break; - } - PUNCT => - { - // Punctuation - if sub_mode_ch < PAL { - ch = PUNCT_CHARS[sub_mode_ch]; - } else { - match sub_mode_ch { - PAL => - { - } - TEXT_COMPACTION_MODE_LATCH => - { - sub_mode = Mode::ALPHA; - latched_mode = sub_mode; - break; - } - MODE_SHIFT_TO_BYTE_COMPACTION_MODE => - { - result.append(byte_compaction_data[i] as char); - break; - } - } - } - break; - } - ALPHA_SHIFT => - { - // Restore sub-mode - sub_mode = prior_to_shift_mode; - if sub_mode_ch < 26 { - ch = ('A' + sub_mode_ch) as char; - } else { - match sub_mode_ch { - 26 => - { - ch = ' '; - break; - } - TEXT_COMPACTION_MODE_LATCH => - { - sub_mode = Mode::ALPHA; - break; - } - } - } - break; - } - PUNCT_SHIFT => - { - // Restore sub-mode - sub_mode = prior_to_shift_mode; - if sub_mode_ch < PAL { - ch = PUNCT_CHARS[sub_mode_ch]; - } else { - match sub_mode_ch { - PAL => - { - } - TEXT_COMPACTION_MODE_LATCH => - { - sub_mode = Mode::ALPHA; - break; - } - MODE_SHIFT_TO_BYTE_COMPACTION_MODE => - { - // PS before Shift-to-Byte is used as a padding character, - // see 5.4.2.4 of the specification - result.append(byte_compaction_data[i] as char); - break; - } - } - } - break; - } - } - if ch != 0 { - // Append decoded character to result - result.append(ch); - } - i += 1; - } - return latched_mode; - } - - /** - * Byte Compaction mode (see 5.4.3) permits all 256 possible 8-bit byte values to be encoded. - * This includes all ASCII characters value 0 to 127 inclusive and provides for international - * character set support. - * - * @param mode The byte compaction mode i.e. 901 or 924 - * @param codewords The array of codewords (data + error) - * @param codeIndex The current index into the codeword array. - * @param result The decoded data is appended to the result. - * @return The next index into the codeword array. - */ - fn byte_compaction( mode: i32, codewords: &Vec, code_index: i32, result: &ECIStringBuilder) -> /* throws FormatException */Result> { - let mut end: bool = false; - while code_index < codewords[0] && !end { - //handle leading ECIs - while code_index < codewords[0] && codewords[code_index] == ECI_CHARSET { - result.append_e_c_i(codewords[code_index += 1]); - code_index += 1; - } - if code_index >= codewords[0] || codewords[code_index] >= TEXT_COMPACTION_MODE_LATCH { - end = true; - } else { - //decode one block of 5 codewords to 6 bytes - let mut value: i64 = 0; - let mut count: i32 = 0; - loop { { - value = 900 * value + codewords[code_index += 1 !!!check!!! post increment]; - count += 1; - }if !(count < 5 && code_index < codewords[0] && codewords[code_index] < TEXT_COMPACTION_MODE_LATCH) break;} - if count == 5 && (mode == BYTE_COMPACTION_MODE_LATCH_6 || code_index < codewords[0] && codewords[code_index] < TEXT_COMPACTION_MODE_LATCH) { - { - let mut i: i32 = 0; - while i < 6 { - { - result.append((value >> (8 * (5 - i))) as i8); - } - i += 1; - } - } - - } else { - code_index -= count; - while (code_index < codewords[0]) && !end { - let code: i32 = codewords[code_index += 1 !!!check!!! post increment]; - if code < TEXT_COMPACTION_MODE_LATCH { - result.append(code as i8); - } else if code == ECI_CHARSET { - result.append_e_c_i(codewords[code_index += 1 !!!check!!! post increment]); - } else { - code_index -= 1; - end = true; - } - } - } - } - } - return Ok(code_index); - } - - /** - * Numeric Compaction mode (see 5.4.4) permits efficient encoding of numeric data strings. - * - * @param codewords The array of codewords (data + error) - * @param codeIndex The current index into the codeword array. - * @param result The decoded data is appended to the result. - * @return The next index into the codeword array. - */ - fn numeric_compaction( codewords: &Vec, code_index: i32, result: &ECIStringBuilder) -> /* throws FormatException */Result> { - let mut count: i32 = 0; - let mut end: bool = false; - let numeric_codewords: [i32; MAX_NUMERIC_CODEWORDS] = [0; MAX_NUMERIC_CODEWORDS]; - while code_index < codewords[0] && !end { - let code: i32 = codewords[code_index += 1 !!!check!!! post increment]; - if code_index == codewords[0] { - end = true; - } - if code < TEXT_COMPACTION_MODE_LATCH { - numeric_codewords[count] = code; - count += 1; - } else { - match code { - TEXT_COMPACTION_MODE_LATCH => - { - } - BYTE_COMPACTION_MODE_LATCH => - { - } - BYTE_COMPACTION_MODE_LATCH_6 => - { - } - BEGIN_MACRO_PDF417_CONTROL_BLOCK => - { - } - BEGIN_MACRO_PDF417_OPTIONAL_FIELD => - { - } - MACRO_PDF417_TERMINATOR => - { - } - ECI_CHARSET => - { - code_index -= 1; - end = true; - break; - } - } - } - if (count % MAX_NUMERIC_CODEWORDS == 0 || code == NUMERIC_COMPACTION_MODE_LATCH || end) && count > 0 { - // Re-invoking Numeric Compaction mode (by using codeword 902 - // while in Numeric Compaction mode) serves to terminate the - // current Numeric Compaction mode grouping as described in 5.4.4.2, - // and then to start a new one grouping. - result.append(&::decode_base900to_base10(&numeric_codewords, count)); - count = 0; - } - } - return Ok(code_index); - } - - /** - * Convert a list of Numeric Compacted codewords from Base 900 to Base 10. - * - * @param codewords The array of codewords - * @param count The number of codewords - * @return The decoded string representing the Numeric data. - */ - /* - EXAMPLE - Encode the fifteen digit numeric string 000213298174000 - Prefix the numeric string with a 1 and set the initial value of - t = 1 000 213 298 174 000 - Calculate codeword 0 - d0 = 1 000 213 298 174 000 mod 900 = 200 - - t = 1 000 213 298 174 000 div 900 = 1 111 348 109 082 - Calculate codeword 1 - d1 = 1 111 348 109 082 mod 900 = 282 - - t = 1 111 348 109 082 div 900 = 1 234 831 232 - Calculate codeword 2 - d2 = 1 234 831 232 mod 900 = 632 - - t = 1 234 831 232 div 900 = 1 372 034 - Calculate codeword 3 - d3 = 1 372 034 mod 900 = 434 - - t = 1 372 034 div 900 = 1 524 - Calculate codeword 4 - d4 = 1 524 mod 900 = 624 - - t = 1 524 div 900 = 1 - Calculate codeword 5 - d5 = 1 mod 900 = 1 - t = 1 div 900 = 0 - Codeword sequence is: 1, 624, 434, 632, 282, 200 - - Decode the above codewords involves - 1 x 900 power of 5 + 624 x 900 power of 4 + 434 x 900 power of 3 + - 632 x 900 power of 2 + 282 x 900 power of 1 + 200 x 900 power of 0 = 1000213298174000 - - Remove leading 1 => Result is 000213298174000 - */ - fn decode_base900to_base10( codewords: &Vec, count: i32) -> /* throws FormatException */Result> { - let mut result: BigInteger = BigInteger::ZERO; - { - let mut i: i32 = 0; - while i < count { - { - result = result.add(&EXP900[count - i - 1]::multiply(&BigInteger::value_of(codewords[i]))); - } - i += 1; - } - } - - let result_string: String = result.to_string(); - if result_string.char_at(0) != '1' { - throw FormatException::get_format_instance(); - } - return Ok(result_string.substring(1)); - } -} - -// NEW FILE: detection_result.rs -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder; - -/** - * @author Guenther Grau - */ - - const ADJUST_ROW_NUMBER_SKIP: i32 = 2; -struct DetectionResult { - - let barcode_metadata: BarcodeMetadata; - - let detection_result_columns: Vec; - - let bounding_box: BoundingBox; - - let barcode_column_count: i32; -} - -impl DetectionResult { - - fn new( barcode_metadata: &BarcodeMetadata, bounding_box: &BoundingBox) -> DetectionResult { - let .barcodeMetadata = barcode_metadata; - let .barcodeColumnCount = barcode_metadata.get_column_count(); - let .boundingBox = bounding_box; - detection_result_columns = : [Option; barcode_column_count + 2] = [None; barcode_column_count + 2]; - } - - fn get_detection_result_columns(&self) -> Vec { - self.adjust_indicator_column_row_numbers(self.detection_result_columns[0]); - self.adjust_indicator_column_row_numbers(self.detection_result_columns[self.barcode_column_count + 1]); - let unadjusted_codeword_count: i32 = PDF417Common.MAX_CODEWORDS_IN_BARCODE; - let previous_unadjusted_count: i32; - loop { { - previous_unadjusted_count = unadjusted_codeword_count; - unadjusted_codeword_count = self.adjust_row_numbers(); - }if !(unadjusted_codeword_count > 0 && unadjusted_codeword_count < previous_unadjusted_count) break;} - return self.detection_result_columns; - } - - fn adjust_indicator_column_row_numbers(&self, detection_result_column: &DetectionResultColumn) { - if detection_result_column != null { - (detection_result_column as DetectionResultRowIndicatorColumn).adjust_complete_indicator_column_row_numbers(self.barcode_metadata); - } - } - - // TODO ensure that no detected codewords with unknown row number are left - // we should be able to estimate the row height and use it as a hint for the row number - // we should also fill the rows top to bottom and bottom to top - /** - * @return number of codewords which don't have a valid row number. Note that the count is not accurate as codewords - * will be counted several times. It just serves as an indicator to see when we can stop adjusting row numbers - */ - fn adjust_row_numbers(&self) -> i32 { - let unadjusted_count: i32 = self.adjust_row_numbers_by_row(); - if unadjusted_count == 0 { - return 0; - } - { - let barcode_column: i32 = 1; - while barcode_column < self.barcode_column_count + 1 { - { - let codewords: Vec = self.detection_result_columns[barcode_column].get_codewords(); - { - let codewords_row: i32 = 0; - while codewords_row < codewords.len() { - { - if codewords[codewords_row] == null { - continue; - } - if !codewords[codewords_row].has_valid_row_number() { - self.adjust_row_numbers(barcode_column, codewords_row, codewords); - } - } - codewords_row += 1; - } - } - - } - barcode_column += 1; - } - } - - return unadjusted_count; - } - - fn adjust_row_numbers_by_row(&self) -> i32 { - self.adjust_row_numbers_from_both_r_i(); - // TODO we should only do full row adjustments if row numbers of left and right row indicator column match. - // Maybe it's even better to calculated the height (in codeword rows) and divide it by the number of barcode - // rows. This, together with the LRI and RRI row numbers should allow us to get a good estimate where a row - // number starts and ends. - let unadjusted_count: i32 = self.adjust_row_numbers_from_l_r_i(); - return unadjusted_count + self.adjust_row_numbers_from_r_r_i(); - } - - fn adjust_row_numbers_from_both_r_i(&self) { - if self.detection_result_columns[0] == null || self.detection_result_columns[self.barcode_column_count + 1] == null { - return; - } - const LRIcodewords: Vec = self.detection_result_columns[0].get_codewords(); - const RRIcodewords: Vec = self.detection_result_columns[self.barcode_column_count + 1].get_codewords(); - { - let codewords_row: i32 = 0; - while codewords_row < LRIcodewords.len() { - { - if LRIcodewords[codewords_row] != null && RRIcodewords[codewords_row] != null && LRIcodewords[codewords_row]::get_row_number() == RRIcodewords[codewords_row]::get_row_number() { - { - let barcode_column: i32 = 1; - while barcode_column <= self.barcode_column_count { - { - let codeword: Codeword = self.detection_result_columns[barcode_column].get_codewords()[codewords_row]; - if codeword == null { - continue; - } - codeword.set_row_number(&LRIcodewords[codewords_row]::get_row_number()); - if !codeword.has_valid_row_number() { - self.detection_result_columns[barcode_column].get_codewords()[codewords_row] = null; - } - } - barcode_column += 1; - } - } - - } - } - codewords_row += 1; - } - } - - } - - fn adjust_row_numbers_from_r_r_i(&self) -> i32 { - if self.detection_result_columns[self.barcode_column_count + 1] == null { - return 0; - } - let unadjusted_count: i32 = 0; - let codewords: Vec = self.detection_result_columns[self.barcode_column_count + 1].get_codewords(); - { - let codewords_row: i32 = 0; - while codewords_row < codewords.len() { - { - if codewords[codewords_row] == null { - continue; - } - let row_indicator_row_number: i32 = codewords[codewords_row].get_row_number(); - let invalid_row_counts: i32 = 0; - { - let barcode_column: i32 = self.barcode_column_count + 1; - while barcode_column > 0 && invalid_row_counts < ADJUST_ROW_NUMBER_SKIP { - { - let codeword: Codeword = self.detection_result_columns[barcode_column].get_codewords()[codewords_row]; - if codeword != null { - invalid_row_counts = ::adjust_row_number_if_valid(row_indicator_row_number, invalid_row_counts, codeword); - if !codeword.has_valid_row_number() { - unadjusted_count += 1; - } - } - } - barcode_column -= 1; - } - } - - } - codewords_row += 1; - } - } - - return unadjusted_count; - } - - fn adjust_row_numbers_from_l_r_i(&self) -> i32 { - if self.detection_result_columns[0] == null { - return 0; - } - let unadjusted_count: i32 = 0; - let codewords: Vec = self.detection_result_columns[0].get_codewords(); - { - let codewords_row: i32 = 0; - while codewords_row < codewords.len() { - { - if codewords[codewords_row] == null { - continue; - } - let row_indicator_row_number: i32 = codewords[codewords_row].get_row_number(); - let invalid_row_counts: i32 = 0; - { - let barcode_column: i32 = 1; - while barcode_column < self.barcode_column_count + 1 && invalid_row_counts < ADJUST_ROW_NUMBER_SKIP { - { - let codeword: Codeword = self.detection_result_columns[barcode_column].get_codewords()[codewords_row]; - if codeword != null { - invalid_row_counts = ::adjust_row_number_if_valid(row_indicator_row_number, invalid_row_counts, codeword); - if !codeword.has_valid_row_number() { - unadjusted_count += 1; - } - } - } - barcode_column += 1; - } - } - - } - codewords_row += 1; - } - } - - return unadjusted_count; - } - - fn adjust_row_number_if_valid( row_indicator_row_number: i32, invalid_row_counts: i32, codeword: &Codeword) -> i32 { - if codeword == null { - return invalid_row_counts; - } - if !codeword.has_valid_row_number() { - if codeword.is_valid_row_number(row_indicator_row_number) { - codeword.set_row_number(row_indicator_row_number); - invalid_row_counts = 0; - } else { - invalid_row_counts += 1; - } - } - return invalid_row_counts; - } - - fn adjust_row_numbers(&self, barcode_column: i32, codewords_row: i32, codewords: &Vec) { - let codeword: Codeword = codewords[codewords_row]; - let previous_column_codewords: Vec = self.detection_result_columns[barcode_column - 1].get_codewords(); - let next_column_codewords: Vec = previous_column_codewords; - if self.detection_result_columns[barcode_column + 1] != null { - next_column_codewords = self.detection_result_columns[barcode_column + 1].get_codewords(); - } - let other_codewords: [Option; 14] = [None; 14]; - other_codewords[2] = previous_column_codewords[codewords_row]; - other_codewords[3] = next_column_codewords[codewords_row]; - if codewords_row > 0 { - other_codewords[0] = codewords[codewords_row - 1]; - other_codewords[4] = previous_column_codewords[codewords_row - 1]; - other_codewords[5] = next_column_codewords[codewords_row - 1]; - } - if codewords_row > 1 { - other_codewords[8] = codewords[codewords_row - 2]; - other_codewords[10] = previous_column_codewords[codewords_row - 2]; - other_codewords[11] = next_column_codewords[codewords_row - 2]; - } - if codewords_row < codewords.len() - 1 { - other_codewords[1] = codewords[codewords_row + 1]; - other_codewords[6] = previous_column_codewords[codewords_row + 1]; - other_codewords[7] = next_column_codewords[codewords_row + 1]; - } - if codewords_row < codewords.len() - 2 { - other_codewords[9] = codewords[codewords_row + 2]; - other_codewords[12] = previous_column_codewords[codewords_row + 2]; - other_codewords[13] = next_column_codewords[codewords_row + 2]; - } - for let other_codeword: Codeword in other_codewords { - if ::adjust_row_number(codeword, other_codeword) { - return; - } - } - } - - /** - * @return true, if row number was adjusted, false otherwise - */ - fn adjust_row_number( codeword: &Codeword, other_codeword: &Codeword) -> bool { - if other_codeword == null { - return false; - } - if other_codeword.has_valid_row_number() && other_codeword.get_bucket() == codeword.get_bucket() { - codeword.set_row_number(&other_codeword.get_row_number()); - return true; - } - return false; - } - - fn get_barcode_column_count(&self) -> i32 { - return self.barcode_column_count; - } - - fn get_barcode_row_count(&self) -> i32 { - return self.barcode_metadata.get_row_count(); - } - - fn get_barcode_e_c_level(&self) -> i32 { - return self.barcode_metadata.get_error_correction_level(); - } - - fn set_bounding_box(&self, bounding_box: &BoundingBox) { - self.boundingBox = bounding_box; - } - - fn get_bounding_box(&self) -> BoundingBox { - return self.bounding_box; - } - - fn set_detection_result_column(&self, barcode_column: i32, detection_result_column: &DetectionResultColumn) { - self.detection_result_columns[barcode_column] = detection_result_column; - } - - fn get_detection_result_column(&self, barcode_column: i32) -> DetectionResultColumn { - return self.detection_result_columns[barcode_column]; - } - - pub fn to_string(&self) -> String { - let row_indicator_column: DetectionResultColumn = self.detection_result_columns[0]; - if row_indicator_column == null { - row_indicator_column = self.detection_result_columns[self.barcode_column_count + 1]; - } - let tryResult1 = 0; - 'try1: loop { - ( let formatter: Formatter = Formatter::new()) { - { - let codewords_row: i32 = 0; - while codewords_row < row_indicator_column.get_codewords().len() { - { - formatter.format("CW %3d:", codewords_row); - { - let barcode_column: i32 = 0; - while barcode_column < self.barcode_column_count + 2 { - { - if self.detection_result_columns[barcode_column] == null { - formatter.format(" | "); - continue; - } - let codeword: Codeword = self.detection_result_columns[barcode_column].get_codewords()[codewords_row]; - if codeword == null { - formatter.format(" | "); - continue; - } - formatter.format(" %3d|%3d", &codeword.get_row_number(), &codeword.get_value()); - } - barcode_column += 1; - } - } - - formatter.format("%n"); - } - codewords_row += 1; - } - } - - return formatter.to_string(); - } - break 'try1 - } - match tryResult1 { - 0 => break - } - - } -} - -// NEW FILE: detection_result_column.rs -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder; - -/** - * @author Guenther Grau - */ - - const MAX_NEARBY_DISTANCE: i32 = 5; -struct DetectionResultColumn { - - let bounding_box: BoundingBox; - - let mut codewords: Vec; -} - -impl DetectionResultColumn { - - fn new( bounding_box: &BoundingBox) -> DetectionResultColumn { - let .boundingBox = BoundingBox::new(bounding_box); - codewords = : [Option; bounding_box.get_max_y() - bounding_box.get_min_y() + 1] = [None; bounding_box.get_max_y() - bounding_box.get_min_y() + 1]; - } - - fn get_codeword_nearby(&self, image_row: i32) -> Codeword { - let mut codeword: Codeword = self.get_codeword(image_row); - if codeword != null { - return codeword; - } - { - let mut i: i32 = 1; - while i < MAX_NEARBY_DISTANCE { - { - let near_image_row: i32 = self.image_row_to_codeword_index(image_row) - i; - if near_image_row >= 0 { - codeword = self.codewords[near_image_row]; - if codeword != null { - return codeword; - } - } - near_image_row = self.image_row_to_codeword_index(image_row) + i; - if near_image_row < self.codewords.len() { - codeword = self.codewords[near_image_row]; - if codeword != null { - return codeword; - } - } - } - i += 1; - } - } - - return null; - } - - fn image_row_to_codeword_index(&self, image_row: i32) -> i32 { - return image_row - self.bounding_box.get_min_y(); - } - - fn set_codeword(&self, image_row: i32, codeword: &Codeword) { - self.codewords[self.image_row_to_codeword_index(image_row)] = codeword; - } - - fn get_codeword(&self, image_row: i32) -> Codeword { - return self.codewords[self.image_row_to_codeword_index(image_row)]; - } - - fn get_bounding_box(&self) -> BoundingBox { - return self.bounding_box; - } - - fn get_codewords(&self) -> Vec { - return self.codewords; - } - - pub fn to_string(&self) -> String { - let tryResult1 = 0; - 'try1: loop { - ( let formatter: Formatter = Formatter::new()) { - let mut row: i32 = 0; - for let codeword: Codeword in self.codewords { - if codeword == null { - formatter.format("%3d: | %n", row += 1 !!!check!!! post increment); - continue; - } - formatter.format("%3d: %3d|%3d%n", row += 1 !!!check!!! post increment, &codeword.get_row_number(), &codeword.get_value()); - } - return formatter.to_string(); - } - break 'try1 - } - match tryResult1 { - 0 => break - } - - } -} - -// NEW FILE: detection_result_row_indicator_column.rs -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder; - -/** - * @author Guenther Grau - */ -struct DetectionResultRowIndicatorColumn { - super: DetectionResultColumn; - - let is_left: bool; -} - -impl DetectionResultRowIndicatorColumn { - - fn new( bounding_box: &BoundingBox, is_left: bool) -> DetectionResultRowIndicatorColumn { - super(bounding_box); - let .isLeft = is_left; - } - - fn set_row_numbers(&self) { - for let codeword: Codeword in get_codewords() { - if codeword != null { - codeword.set_row_number_as_row_indicator_column(); - } - } - } - - // TODO implement properly - // TODO maybe we should add missing codewords to store the correct row number to make - // finding row numbers for other columns easier - // use row height count to make detection of invalid row numbers more reliable - fn adjust_complete_indicator_column_row_numbers(&self, barcode_metadata: &BarcodeMetadata) { - let mut codewords: Vec = get_codewords(); - self.set_row_numbers(); - self.remove_incorrect_codewords(codewords, barcode_metadata); - let bounding_box: BoundingBox = get_bounding_box(); - let top: ResultPoint = if self.is_left { bounding_box.get_top_left() } else { bounding_box.get_top_right() }; - let bottom: ResultPoint = if self.is_left { bounding_box.get_bottom_left() } else { bounding_box.get_bottom_right() }; - let first_row: i32 = image_row_to_codeword_index(top.get_y() as i32); - let last_row: i32 = image_row_to_codeword_index(bottom.get_y() as i32); - // We need to be careful using the average row height. Barcode could be skewed so that we have smaller and - // taller rows - //float averageRowHeight = (lastRow - firstRow) / (float) barcodeMetadata.getRowCount(); - let barcode_row: i32 = -1; - let max_row_height: i32 = 1; - let current_row_height: i32 = 0; - { - let codewords_row: i32 = first_row; - while codewords_row < last_row { - { - if codewords[codewords_row] == null { - continue; - } - let codeword: Codeword = codewords[codewords_row]; - let row_difference: i32 = codeword.get_row_number() - barcode_row; - if row_difference == 0 { - current_row_height += 1; - } else if row_difference == 1 { - max_row_height = Math::max(max_row_height, current_row_height); - current_row_height = 1; - barcode_row = codeword.get_row_number(); - } else if row_difference < 0 || codeword.get_row_number() >= barcode_metadata.get_row_count() || row_difference > codewords_row { - codewords[codewords_row] = null; - } else { - let checked_rows: i32; - if max_row_height > 2 { - checked_rows = (max_row_height - 2) * row_difference; - } else { - checked_rows = row_difference; - } - let close_previous_codeword_found: bool = checked_rows >= codewords_row; - { - let mut i: i32 = 1; - while i <= checked_rows && !close_previous_codeword_found { - { - // there must be (height * rowDifference) number of codewords missing. For now we assume height = 1. - // This should hopefully get rid of most problems already. - close_previous_codeword_found = codewords[codewords_row - i] != null; - } - i += 1; - } - } - - if close_previous_codeword_found { - codewords[codewords_row] = null; - } else { - barcode_row = codeword.get_row_number(); - current_row_height = 1; - } - } - } - codewords_row += 1; - } - } - - //return (int) (averageRowHeight + 0.5); - } - - fn get_row_heights(&self) -> Vec { - let barcode_metadata: BarcodeMetadata = self.get_barcode_metadata(); - if barcode_metadata == null { - return null; - } - self.adjust_incomplete_indicator_column_row_numbers(barcode_metadata); - let mut result: [i32; barcode_metadata.get_row_count()] = [0; barcode_metadata.get_row_count()]; - for let codeword: Codeword in get_codewords() { - if codeword != null { - let row_number: i32 = codeword.get_row_number(); - if row_number >= result.len() { - // We have more rows than the barcode metadata allows for, ignore them. - continue; - } - result[row_number] += 1; - } - // else throw exception? - } - return result; - } - - // TODO maybe we should add missing codewords to store the correct row number to make - // finding row numbers for other columns easier - // use row height count to make detection of invalid row numbers more reliable - fn adjust_incomplete_indicator_column_row_numbers(&self, barcode_metadata: &BarcodeMetadata) { - let bounding_box: BoundingBox = get_bounding_box(); - let top: ResultPoint = if self.is_left { bounding_box.get_top_left() } else { bounding_box.get_top_right() }; - let bottom: ResultPoint = if self.is_left { bounding_box.get_bottom_left() } else { bounding_box.get_bottom_right() }; - let first_row: i32 = image_row_to_codeword_index(top.get_y() as i32); - let last_row: i32 = image_row_to_codeword_index(bottom.get_y() as i32); - //float averageRowHeight = (lastRow - firstRow) / (float) barcodeMetadata.getRowCount(); - let mut codewords: Vec = get_codewords(); - let barcode_row: i32 = -1; - let max_row_height: i32 = 1; - let current_row_height: i32 = 0; - { - let codewords_row: i32 = first_row; - while codewords_row < last_row { - { - if codewords[codewords_row] == null { - continue; - } - let codeword: Codeword = codewords[codewords_row]; - codeword.set_row_number_as_row_indicator_column(); - let row_difference: i32 = codeword.get_row_number() - barcode_row; - if row_difference == 0 { - current_row_height += 1; - } else if row_difference == 1 { - max_row_height = Math::max(max_row_height, current_row_height); - current_row_height = 1; - barcode_row = codeword.get_row_number(); - } else if codeword.get_row_number() >= barcode_metadata.get_row_count() { - codewords[codewords_row] = null; - } else { - barcode_row = codeword.get_row_number(); - current_row_height = 1; - } - } - codewords_row += 1; - } - } - - //return (int) (averageRowHeight + 0.5); - } - - fn get_barcode_metadata(&self) -> BarcodeMetadata { - let codewords: Vec = get_codewords(); - let barcode_column_count: BarcodeValue = BarcodeValue::new(); - let barcode_row_count_upper_part: BarcodeValue = BarcodeValue::new(); - let barcode_row_count_lower_part: BarcodeValue = BarcodeValue::new(); - let barcode_e_c_level: BarcodeValue = BarcodeValue::new(); - for let codeword: Codeword in codewords { - if codeword == null { - continue; - } - codeword.set_row_number_as_row_indicator_column(); - let row_indicator_value: i32 = codeword.get_value() % 30; - let codeword_row_number: i32 = codeword.get_row_number(); - if !self.is_left { - codeword_row_number += 2; - } - match codeword_row_number % 3 { - 0 => - { - barcode_row_count_upper_part.set_value(row_indicator_value * 3 + 1); - break; - } - 1 => - { - barcode_e_c_level.set_value(row_indicator_value / 3); - barcode_row_count_lower_part.set_value(row_indicator_value % 3); - break; - } - 2 => - { - barcode_column_count.set_value(row_indicator_value + 1); - break; - } - } - } - // Maybe we should check if we have ambiguous values? - if (barcode_column_count.get_value().len() == 0) || (barcode_row_count_upper_part.get_value().len() == 0) || (barcode_row_count_lower_part.get_value().len() == 0) || (barcode_e_c_level.get_value().len() == 0) || barcode_column_count.get_value()[0] < 1 || barcode_row_count_upper_part.get_value()[0] + barcode_row_count_lower_part.get_value()[0] < PDF417Common.MIN_ROWS_IN_BARCODE || barcode_row_count_upper_part.get_value()[0] + barcode_row_count_lower_part.get_value()[0] > PDF417Common.MAX_ROWS_IN_BARCODE { - return null; - } - let barcode_metadata: BarcodeMetadata = BarcodeMetadata::new(barcode_column_count.get_value()[0], barcode_row_count_upper_part.get_value()[0], barcode_row_count_lower_part.get_value()[0], barcode_e_c_level.get_value()[0]); - self.remove_incorrect_codewords(codewords, barcode_metadata); - return barcode_metadata; - } - - fn remove_incorrect_codewords(&self, codewords: &Vec, barcode_metadata: &BarcodeMetadata) { - // TODO Maybe we should keep the incorrect codewords for the start and end positions? - { - let codeword_row: i32 = 0; - while codeword_row < codewords.len() { - { - let codeword: Codeword = codewords[codeword_row]; - if codewords[codeword_row] == null { - continue; - } - let row_indicator_value: i32 = codeword.get_value() % 30; - let codeword_row_number: i32 = codeword.get_row_number(); - if codeword_row_number > barcode_metadata.get_row_count() { - codewords[codeword_row] = null; - continue; - } - if !self.is_left { - codeword_row_number += 2; - } - match codeword_row_number % 3 { - 0 => - { - if row_indicator_value * 3 + 1 != barcode_metadata.get_row_count_upper_part() { - codewords[codeword_row] = null; - } - break; - } - 1 => - { - if row_indicator_value / 3 != barcode_metadata.get_error_correction_level() || row_indicator_value % 3 != barcode_metadata.get_row_count_lower_part() { - codewords[codeword_row] = null; - } - break; - } - 2 => - { - if row_indicator_value + 1 != barcode_metadata.get_column_count() { - codewords[codeword_row] = null; - } - break; - } - } - } - codeword_row += 1; - } - } - - } - - fn is_left(&self) -> bool { - return self.is_left; - } - - pub fn to_string(&self) -> String { - return format!("IsLeft: {}\n{}", self.is_left, super.to_string()); - } -} - -// NEW FILE: p_d_f417_codeword_decoder.rs -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder; - -/** - * @author Guenther Grau - * @author creatale GmbH (christoph.schulz@creatale.de) - */ - - const RATIOS_TABLE: [[f32; PDF417Common.BARS_IN_MODULE]; PDF417Common.SYMBOL_TABLE.len()] = [[0.0; PDF417Common.BARS_IN_MODULE]; PDF417Common.SYMBOL_TABLE.len()]; -struct PDF417CodewordDecoder { -} - -impl PDF417CodewordDecoder { - - static { - // Pre-computes the symbol ratio table. - { - let mut i: i32 = 0; - while i < PDF417Common.SYMBOL_TABLE.len() { - { - let current_symbol: i32 = PDF417Common.SYMBOL_TABLE[i]; - let current_bit: i32 = current_symbol & 0x1; - { - let mut j: i32 = 0; - while j < PDF417Common.BARS_IN_MODULE { - { - let mut size: f32 = 0.0f; - while (current_symbol & 0x1) == current_bit { - size += 1.0f; - current_symbol >>= 1; - } - current_bit = current_symbol & 0x1; - RATIOS_TABLE[i][PDF417Common.BARS_IN_MODULE - j - 1] = size / PDF417Common.MODULES_IN_CODEWORD; - } - j += 1; - } - } - - } - i += 1; - } - } - - } - - fn new() -> PDF417CodewordDecoder { - } - - fn get_decoded_value( module_bit_count: &Vec) -> i32 { - let decoded_value: i32 = ::get_decoded_codeword_value(&::sample_bit_counts(&module_bit_count)); - if decoded_value != -1 { - return decoded_value; - } - return ::get_closest_decoded_value(&module_bit_count); - } - - fn sample_bit_counts( module_bit_count: &Vec) -> Vec { - let bit_count_sum: f32 = MathUtils::sum(&module_bit_count); - let mut result: [i32; PDF417Common.BARS_IN_MODULE] = [0; PDF417Common.BARS_IN_MODULE]; - let bit_count_index: i32 = 0; - let sum_previous_bits: i32 = 0; - { - let mut i: i32 = 0; - while i < PDF417Common.MODULES_IN_CODEWORD { - { - let sample_index: f32 = bit_count_sum / (2.0 * PDF417Common.MODULES_IN_CODEWORD) + (i * bit_count_sum) / PDF417Common.MODULES_IN_CODEWORD; - if sum_previous_bits + module_bit_count[bit_count_index] <= sample_index { - sum_previous_bits += module_bit_count[bit_count_index]; - bit_count_index += 1; - } - result[bit_count_index] += 1; - } - i += 1; - } - } - - return result; - } - - fn get_decoded_codeword_value( module_bit_count: &Vec) -> i32 { - let decoded_value: i32 = ::get_bit_value(&module_bit_count); - return if PDF417Common::get_codeword(decoded_value) == -1 { -1 } else { decoded_value }; - } - - fn get_bit_value( module_bit_count: &Vec) -> i32 { - let mut result: i64 = 0; - { - let mut i: i32 = 0; - while i < module_bit_count.len() { - { - { - let mut bit: i32 = 0; - while bit < module_bit_count[i] { - { - result = (result << 1) | ( if i % 2 == 0 { 1 } else { 0 }); - } - bit += 1; - } - } - - } - i += 1; - } - } - - return result as i32; - } - - fn get_closest_decoded_value( module_bit_count: &Vec) -> i32 { - let bit_count_sum: i32 = MathUtils::sum(&module_bit_count); - let bit_count_ratios: [f32; PDF417Common.BARS_IN_MODULE] = [0.0; PDF417Common.BARS_IN_MODULE]; - if bit_count_sum > 1 { - { - let mut i: i32 = 0; - while i < bit_count_ratios.len() { - { - bit_count_ratios[i] = module_bit_count[i] / bit_count_sum as f32; - } - i += 1; - } - } - - } - let best_match_error: f32 = Float::MAX_VALUE; - let best_match: i32 = -1; - { - let mut j: i32 = 0; - while j < RATIOS_TABLE.len() { - { - let mut error: f32 = 0.0f; - let ratio_table_row: Vec = RATIOS_TABLE[j]; - { - let mut k: i32 = 0; - while k < PDF417Common.BARS_IN_MODULE { - { - let diff: f32 = ratio_table_row[k] - bit_count_ratios[k]; - error += diff * diff; - if error >= best_match_error { - break; - } - } - k += 1; - } - } - - if error < best_match_error { - best_match_error = error; - best_match = PDF417Common.SYMBOL_TABLE[j]; - } - } - j += 1; - } - } - - return best_match; - } -} - -// NEW FILE: p_d_f417_scanning_decoder.rs -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder; - -/** - * @author Guenther Grau - */ - - const CODEWORD_SKEW_SIZE: i32 = 2; - - const MAX_ERRORS: i32 = 3; - - const MAX_EC_CODEWORDS: i32 = 512; - - let error_correction: ErrorCorrection = ErrorCorrection::new(); -pub struct PDF417ScanningDecoder { -} - -impl PDF417ScanningDecoder { - - fn new() -> PDF417ScanningDecoder { - } - - // TODO don't pass in minCodewordWidth and maxCodewordWidth, pass in barcode columns for start and stop pattern - // columns. That way width can be deducted from the pattern column. - // This approach also allows to detect more details about the barcode, e.g. if a bar type (white or black) is wider - // than it should be. This can happen if the scanner used a bad blackpoint. - pub fn decode( image: &BitMatrix, image_top_left: &ResultPoint, image_bottom_left: &ResultPoint, image_top_right: &ResultPoint, image_bottom_right: &ResultPoint, min_codeword_width: i32, max_codeword_width: i32) -> /* throws NotFoundException, FormatException, ChecksumException */Result> { - let bounding_box: BoundingBox = BoundingBox::new(image, image_top_left, image_bottom_left, image_top_right, image_bottom_right); - let left_row_indicator_column: DetectionResultRowIndicatorColumn = null; - let right_row_indicator_column: DetectionResultRowIndicatorColumn = null; - let detection_result: DetectionResult; - { - let first_pass: bool = true; - loop { - { - if image_top_left != null { - left_row_indicator_column = ::get_row_indicator_column(image, bounding_box, image_top_left, true, min_codeword_width, max_codeword_width); - } - if image_top_right != null { - right_row_indicator_column = ::get_row_indicator_column(image, bounding_box, image_top_right, false, min_codeword_width, max_codeword_width); - } - detection_result = ::merge(left_row_indicator_column, right_row_indicator_column); - if detection_result == null { - throw NotFoundException::get_not_found_instance(); - } - let result_box: BoundingBox = detection_result.get_bounding_box(); - if first_pass && result_box != null && (result_box.get_min_y() < bounding_box.get_min_y() || result_box.get_max_y() > bounding_box.get_max_y()) { - bounding_box = result_box; - } else { - break; - } - } - first_pass = false; - } - } - - detection_result.set_bounding_box(bounding_box); - let max_barcode_column: i32 = detection_result.get_barcode_column_count() + 1; - detection_result.set_detection_result_column(0, left_row_indicator_column); - detection_result.set_detection_result_column(max_barcode_column, right_row_indicator_column); - let left_to_right: bool = left_row_indicator_column != null; - { - let barcode_column_count: i32 = 1; - while barcode_column_count <= max_barcode_column { - { - let barcode_column: i32 = if left_to_right { barcode_column_count } else { max_barcode_column - barcode_column_count }; - if detection_result.get_detection_result_column(barcode_column) != null { - // This will be the case for the opposite row indicator column, which doesn't need to be decoded again. - continue; - } - let detection_result_column: DetectionResultColumn; - if barcode_column == 0 || barcode_column == max_barcode_column { - detection_result_column = DetectionResultRowIndicatorColumn::new(bounding_box, barcode_column == 0); - } else { - detection_result_column = DetectionResultColumn::new(bounding_box); - } - detection_result.set_detection_result_column(barcode_column, detection_result_column); - let start_column: i32 = -1; - let previous_start_column: i32 = start_column; - // TODO start at a row for which we know the start position, then detect upwards and downwards from there. - { - let image_row: i32 = bounding_box.get_min_y(); - while image_row <= bounding_box.get_max_y() { - { - start_column = ::get_start_column(detection_result, barcode_column, image_row, left_to_right); - if start_column < 0 || start_column > bounding_box.get_max_x() { - if previous_start_column == -1 { - continue; - } - start_column = previous_start_column; - } - let codeword: Codeword = ::detect_codeword(image, &bounding_box.get_min_x(), &bounding_box.get_max_x(), left_to_right, start_column, image_row, min_codeword_width, max_codeword_width); - if codeword != null { - detection_result_column.set_codeword(image_row, codeword); - previous_start_column = start_column; - min_codeword_width = Math::min(min_codeword_width, &codeword.get_width()); - max_codeword_width = Math::max(max_codeword_width, &codeword.get_width()); - } - } - image_row += 1; - } - } - - } - barcode_column_count += 1; - } - } - - return Ok(::create_decoder_result(detection_result)); - } - - fn merge( left_row_indicator_column: &DetectionResultRowIndicatorColumn, right_row_indicator_column: &DetectionResultRowIndicatorColumn) -> /* throws NotFoundException */Result> { - if left_row_indicator_column == null && right_row_indicator_column == null { - return Ok(null); - } - let barcode_metadata: BarcodeMetadata = ::get_barcode_metadata(left_row_indicator_column, right_row_indicator_column); - if barcode_metadata == null { - return Ok(null); - } - let bounding_box: BoundingBox = BoundingBox::merge(&::adjust_bounding_box(left_row_indicator_column), &::adjust_bounding_box(right_row_indicator_column)); - return Ok(DetectionResult::new(barcode_metadata, bounding_box)); - } - - fn adjust_bounding_box( row_indicator_column: &DetectionResultRowIndicatorColumn) -> /* throws NotFoundException */Result> { - if row_indicator_column == null { - return Ok(null); - } - let row_heights: Vec = row_indicator_column.get_row_heights(); - if row_heights == null { - return Ok(null); - } - let max_row_height: i32 = ::get_max(&row_heights); - let missing_start_rows: i32 = 0; - for let row_height: i32 in row_heights { - missing_start_rows += max_row_height - row_height; - if row_height > 0 { - break; - } - } - let codewords: Vec = row_indicator_column.get_codewords(); - { - let mut row: i32 = 0; - while missing_start_rows > 0 && codewords[row] == null { - { - missing_start_rows -= 1; - } - row += 1; - } - } - - let missing_end_rows: i32 = 0; - { - let mut row: i32 = row_heights.len() - 1; - while row >= 0 { - { - missing_end_rows += max_row_height - row_heights[row]; - if row_heights[row] > 0 { - break; - } - } - row -= 1; - } - } - - { - let mut row: i32 = codewords.len() - 1; - while missing_end_rows > 0 && codewords[row] == null { - { - missing_end_rows -= 1; - } - row -= 1; - } - } - - return Ok(row_indicator_column.get_bounding_box().add_missing_rows(missing_start_rows, missing_end_rows, &row_indicator_column.is_left())); - } - - fn get_max( values: &Vec) -> i32 { - let max_value: i32 = -1; - for let value: i32 in values { - max_value = Math::max(max_value, value); - } - return max_value; - } - - fn get_barcode_metadata( left_row_indicator_column: &DetectionResultRowIndicatorColumn, right_row_indicator_column: &DetectionResultRowIndicatorColumn) -> BarcodeMetadata { - let left_barcode_metadata: BarcodeMetadata; - if left_row_indicator_column == null || (left_barcode_metadata = left_row_indicator_column.get_barcode_metadata()) == null { - return if right_row_indicator_column == null { null } else { right_row_indicator_column.get_barcode_metadata() }; - } - let right_barcode_metadata: BarcodeMetadata; - if right_row_indicator_column == null || (right_barcode_metadata = right_row_indicator_column.get_barcode_metadata()) == null { - return left_barcode_metadata; - } - if left_barcode_metadata.get_column_count() != right_barcode_metadata.get_column_count() && left_barcode_metadata.get_error_correction_level() != right_barcode_metadata.get_error_correction_level() && left_barcode_metadata.get_row_count() != right_barcode_metadata.get_row_count() { - return null; - } - return left_barcode_metadata; - } - - fn get_row_indicator_column( image: &BitMatrix, bounding_box: &BoundingBox, start_point: &ResultPoint, left_to_right: bool, min_codeword_width: i32, max_codeword_width: i32) -> DetectionResultRowIndicatorColumn { - let row_indicator_column: DetectionResultRowIndicatorColumn = DetectionResultRowIndicatorColumn::new(bounding_box, left_to_right); - { - let mut i: i32 = 0; - while i < 2 { - { - let increment: i32 = if i == 0 { 1 } else { -1 }; - let start_column: i32 = start_point.get_x() as i32; - { - let image_row: i32 = start_point.get_y() as i32; - while image_row <= bounding_box.get_max_y() && image_row >= bounding_box.get_min_y() { - { - let codeword: Codeword = ::detect_codeword(image, 0, &image.get_width(), left_to_right, start_column, image_row, min_codeword_width, max_codeword_width); - if codeword != null { - row_indicator_column.set_codeword(image_row, codeword); - if left_to_right { - start_column = codeword.get_start_x(); - } else { - start_column = codeword.get_end_x(); - } - } - } - image_row += increment; - } - } - - } - i += 1; - } - } - - return row_indicator_column; - } - - fn adjust_codeword_count( detection_result: &DetectionResult, barcode_matrix: &Vec>) -> /* throws NotFoundException */Result> { - let barcode_matrix01: BarcodeValue = barcode_matrix[0][1]; - let number_of_codewords: Vec = barcode_matrix01.get_value(); - let calculated_number_of_codewords: i32 = detection_result.get_barcode_column_count() * detection_result.get_barcode_row_count() - ::get_number_of_e_c_code_words(&detection_result.get_barcode_e_c_level()); - if number_of_codewords.len() == 0 { - if calculated_number_of_codewords < 1 || calculated_number_of_codewords > PDF417Common.MAX_CODEWORDS_IN_BARCODE { - throw NotFoundException::get_not_found_instance(); - } - barcode_matrix01.set_value(calculated_number_of_codewords); - } else if number_of_codewords[0] != calculated_number_of_codewords { - if calculated_number_of_codewords >= 1 && calculated_number_of_codewords <= PDF417Common.MAX_CODEWORDS_IN_BARCODE { - // The calculated one is more reliable as it is derived from the row indicator columns - barcode_matrix01.set_value(calculated_number_of_codewords); - } - } - } - - fn create_decoder_result( detection_result: &DetectionResult) -> /* throws FormatException, ChecksumException, NotFoundException */Result> { - let barcode_matrix: Vec> = ::create_barcode_matrix(detection_result); - ::adjust_codeword_count(detection_result, barcode_matrix); - let erasures: Collection = ArrayList<>::new(); - let mut codewords: [i32; detection_result.get_barcode_row_count() * detection_result.get_barcode_column_count()] = [0; detection_result.get_barcode_row_count() * detection_result.get_barcode_column_count()]; - let ambiguous_index_values_list: List> = ArrayList<>::new(); - let ambiguous_indexes_list: Collection = ArrayList<>::new(); - { - let mut row: i32 = 0; - while row < detection_result.get_barcode_row_count() { - { - { - let mut column: i32 = 0; - while column < detection_result.get_barcode_column_count() { - { - let values: Vec = barcode_matrix[row][column + 1].get_value(); - let codeword_index: i32 = row * detection_result.get_barcode_column_count() + column; - if values.len() == 0 { - erasures.add(codeword_index); - } else if values.len() == 1 { - codewords[codeword_index] = values[0]; - } else { - ambiguous_indexes_list.add(codeword_index); - ambiguous_index_values_list.add(&values); - } - } - column += 1; - } - } - - } - row += 1; - } - } - - let ambiguous_index_values: [i32; ambiguous_index_values_list.size()] = [0; ambiguous_index_values_list.size()]; - { - let mut i: i32 = 0; - while i < ambiguous_index_values.len() { - { - ambiguous_index_values[i] = ambiguous_index_values_list.get(i); - } - i += 1; - } - } - - return Ok(::create_decoder_result_from_ambiguous_values(&detection_result.get_barcode_e_c_level(), &codewords, &PDF417Common::to_int_array(&erasures), &PDF417Common::to_int_array(&ambiguous_indexes_list), &ambiguous_index_values)); - } - - /** - * This method deals with the fact, that the decoding process doesn't always yield a single most likely value. The - * current error correction implementation doesn't deal with erasures very well, so it's better to provide a value - * for these ambiguous codewords instead of treating it as an erasure. The problem is that we don't know which of - * the ambiguous values to choose. We try decode using the first value, and if that fails, we use another of the - * ambiguous values and try to decode again. This usually only happens on very hard to read and decode barcodes, - * so decoding the normal barcodes is not affected by this. - * - * @param erasureArray contains the indexes of erasures - * @param ambiguousIndexes array with the indexes that have more than one most likely value - * @param ambiguousIndexValues two dimensional array that contains the ambiguous values. The first dimension must - * be the same length as the ambiguousIndexes array - */ - fn create_decoder_result_from_ambiguous_values( ec_level: i32, codewords: &Vec, erasure_array: &Vec, ambiguous_indexes: &Vec, ambiguous_index_values: &Vec>) -> /* throws FormatException, ChecksumException */Result> { - let ambiguous_index_count: [i32; ambiguous_indexes.len()] = [0; ambiguous_indexes.len()]; - let mut tries: i32 = 100; - while tries -= 1 !!!check!!! post decrement > 0 { - { - let mut i: i32 = 0; - while i < ambiguous_index_count.len() { - { - codewords[ambiguous_indexes[i]] = ambiguous_index_values[i][ambiguous_index_count[i]]; - } - i += 1; - } - } - - let tryResult1 = 0; - 'try1: loop { - { - return Ok(::decode_codewords(&codewords, ec_level, &erasure_array)); - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &ChecksumException) { - } 0 => break - } - - if ambiguous_index_count.len() == 0 { - throw ChecksumException::get_checksum_instance(); - } - { - let mut i: i32 = 0; - while i < ambiguous_index_count.len() { - { - if ambiguous_index_count[i] < ambiguous_index_values[i].len() - 1 { - ambiguous_index_count[i] += 1; - break; - } else { - ambiguous_index_count[i] = 0; - if i == ambiguous_index_count.len() - 1 { - throw ChecksumException::get_checksum_instance(); - } - } - } - i += 1; - } - } - - } - throw ChecksumException::get_checksum_instance(); - } - - fn create_barcode_matrix( detection_result: &DetectionResult) -> Vec> { - let barcode_matrix: [[Option; detection_result.get_barcode_column_count() + 2]; detection_result.get_barcode_row_count()] = [[None; detection_result.get_barcode_column_count() + 2]; detection_result.get_barcode_row_count()]; - { - let mut row: i32 = 0; - while row < barcode_matrix.len() { - { - { - let mut column: i32 = 0; - while column < barcode_matrix[row].len() { - { - barcode_matrix[row][column] = BarcodeValue::new(); - } - column += 1; - } - } - - } - row += 1; - } - } - - let mut column: i32 = 0; - for let detection_result_column: DetectionResultColumn in detection_result.get_detection_result_columns() { - if detection_result_column != null { - for let codeword: Codeword in detection_result_column.get_codewords() { - if codeword != null { - let row_number: i32 = codeword.get_row_number(); - if row_number >= 0 { - if row_number >= barcode_matrix.len() { - // We have more rows than the barcode metadata allows for, ignore them. - continue; - } - barcode_matrix[row_number][column].set_value(&codeword.get_value()); - } - } - } - } - column += 1; - } - return barcode_matrix; - } - - fn is_valid_barcode_column( detection_result: &DetectionResult, barcode_column: i32) -> bool { - return barcode_column >= 0 && barcode_column <= detection_result.get_barcode_column_count() + 1; - } - - fn get_start_column( detection_result: &DetectionResult, barcode_column: i32, image_row: i32, left_to_right: bool) -> i32 { - let offset: i32 = if left_to_right { 1 } else { -1 }; - let mut codeword: Codeword = null; - if ::is_valid_barcode_column(detection_result, barcode_column - offset) { - codeword = detection_result.get_detection_result_column(barcode_column - offset).get_codeword(image_row); - } - if codeword != null { - return if left_to_right { codeword.get_end_x() } else { codeword.get_start_x() }; - } - codeword = detection_result.get_detection_result_column(barcode_column).get_codeword_nearby(image_row); - if codeword != null { - return if left_to_right { codeword.get_start_x() } else { codeword.get_end_x() }; - } - if ::is_valid_barcode_column(detection_result, barcode_column - offset) { - codeword = detection_result.get_detection_result_column(barcode_column - offset).get_codeword_nearby(image_row); - } - if codeword != null { - return if left_to_right { codeword.get_end_x() } else { codeword.get_start_x() }; - } - let skipped_columns: i32 = 0; - while ::is_valid_barcode_column(detection_result, barcode_column - offset) { - barcode_column -= offset; - for let previous_row_codeword: Codeword in detection_result.get_detection_result_column(barcode_column).get_codewords() { - if previous_row_codeword != null { - return ( if left_to_right { previous_row_codeword.get_end_x() } else { previous_row_codeword.get_start_x() }) + offset * skipped_columns * (previous_row_codeword.get_end_x() - previous_row_codeword.get_start_x()); - } - } - skipped_columns += 1; - } - return if left_to_right { detection_result.get_bounding_box().get_min_x() } else { detection_result.get_bounding_box().get_max_x() }; - } - - fn detect_codeword( image: &BitMatrix, min_column: i32, max_column: i32, left_to_right: bool, start_column: i32, image_row: i32, min_codeword_width: i32, max_codeword_width: i32) -> Codeword { - start_column = ::adjust_codeword_start_column(image, min_column, max_column, left_to_right, start_column, image_row); - // we usually know fairly exact now how long a codeword is. We should provide minimum and maximum expected length - // and try to adjust the read pixels, e.g. remove single pixel errors or try to cut off exceeding pixels. - // min and maxCodewordWidth should not be used as they are calculated for the whole barcode an can be inaccurate - // for the current position - let module_bit_count: Vec = ::get_module_bit_count(image, min_column, max_column, left_to_right, start_column, image_row); - if module_bit_count == null { - return null; - } - let end_column: i32; - let codeword_bit_count: i32 = MathUtils::sum(&module_bit_count); - if left_to_right { - end_column = start_column + codeword_bit_count; - } else { - { - let mut i: i32 = 0; - while i < module_bit_count.len() / 2 { - { - let tmp_count: i32 = module_bit_count[i]; - module_bit_count[i] = module_bit_count[module_bit_count.len() - 1 - i]; - module_bit_count[module_bit_count.len() - 1 - i] = tmp_count; - } - i += 1; - } - } - - end_column = start_column; - start_column = end_column - codeword_bit_count; - } - // sufficient for now - if !::check_codeword_skew(codeword_bit_count, min_codeword_width, max_codeword_width) { - // create the bit count from it and normalize it to 8. This would help with single pixel errors. - return null; - } - let decoded_value: i32 = PDF417CodewordDecoder::get_decoded_value(&module_bit_count); - let codeword: i32 = PDF417Common::get_codeword(decoded_value); - if codeword == -1 { - return null; - } - return Codeword::new(start_column, end_column, &::get_codeword_bucket_number(decoded_value), codeword); - } - - fn get_module_bit_count( image: &BitMatrix, min_column: i32, max_column: i32, left_to_right: bool, start_column: i32, image_row: i32) -> Vec { - let image_column: i32 = start_column; - let module_bit_count: [i32; 8] = [0; 8]; - let module_number: i32 = 0; - let increment: i32 = if left_to_right { 1 } else { -1 }; - let previous_pixel_value: bool = left_to_right; - while ( if left_to_right { image_column < max_column } else { image_column >= min_column }) && module_number < module_bit_count.len() { - if image.get(image_column, image_row) == previous_pixel_value { - module_bit_count[module_number] += 1; - image_column += increment; - } else { - module_number += 1; - previous_pixel_value = !previous_pixel_value; - } - } - if module_number == module_bit_count.len() || ((image_column == ( if left_to_right { max_column } else { min_column })) && module_number == module_bit_count.len() - 1) { - return module_bit_count; - } - return null; - } - - fn get_number_of_e_c_code_words( barcode_e_c_level: i32) -> i32 { - return 2 << barcode_e_c_level; - } - - fn adjust_codeword_start_column( image: &BitMatrix, min_column: i32, max_column: i32, left_to_right: bool, codeword_start_column: i32, image_row: i32) -> i32 { - let corrected_start_column: i32 = codeword_start_column; - let mut increment: i32 = if left_to_right { -1 } else { 1 }; - // there should be no black pixels before the start column. If there are, then we need to start earlier. - { - let mut i: i32 = 0; - while i < 2 { - { - while ( if left_to_right { corrected_start_column >= min_column } else { corrected_start_column < max_column }) && left_to_right == image.get(corrected_start_column, image_row) { - if Math::abs(codeword_start_column - corrected_start_column) > CODEWORD_SKEW_SIZE { - return codeword_start_column; - } - corrected_start_column += increment; - } - increment = -increment; - left_to_right = !left_to_right; - } - i += 1; - } - } - - return corrected_start_column; - } - - fn check_codeword_skew( codeword_size: i32, min_codeword_width: i32, max_codeword_width: i32) -> bool { - return min_codeword_width - CODEWORD_SKEW_SIZE <= codeword_size && codeword_size <= max_codeword_width + CODEWORD_SKEW_SIZE; - } - - fn decode_codewords( codewords: &Vec, ec_level: i32, erasures: &Vec) -> /* throws FormatException, ChecksumException */Result> { - if codewords.len() == 0 { - throw FormatException::get_format_instance(); - } - let num_e_c_codewords: i32 = 1 << (ec_level + 1); - let corrected_errors_count: i32 = ::correct_errors(&codewords, &erasures, num_e_c_codewords); - ::verify_codeword_count(&codewords, num_e_c_codewords); - // Decode the codewords - let decoder_result: DecoderResult = DecodedBitStreamParser::decode(&codewords, &String::value_of(ec_level)); - decoder_result.set_errors_corrected(corrected_errors_count); - decoder_result.set_erasures(erasures.len()); - return Ok(decoder_result); - } - - /** - *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to - * correct the errors in-place.

- * - * @param codewords data and error correction codewords - * @param erasures positions of any known erasures - * @param numECCodewords number of error correction codewords that are available in codewords - * @throws ChecksumException if error correction fails - */ - fn correct_errors( codewords: &Vec, erasures: &Vec, num_e_c_codewords: i32) -> /* throws ChecksumException */Result> { - if erasures != null && erasures.len() > num_e_c_codewords / 2 + MAX_ERRORS || num_e_c_codewords < 0 || num_e_c_codewords > MAX_EC_CODEWORDS { - // Too many errors or EC Codewords is corrupted - throw ChecksumException::get_checksum_instance(); - } - return Ok(error_correction.decode(&codewords, num_e_c_codewords, &erasures)); - } - - /** - * Verify that all is OK with the codeword array. - */ - fn verify_codeword_count( codewords: &Vec, num_e_c_codewords: i32) -> /* throws FormatException */Result> { - if codewords.len() < 4 { - // Count CW, At least one Data CW, Error Correction CW, Error Correction CW - throw FormatException::get_format_instance(); - } - // The first codeword, the Symbol Length Descriptor, shall always encode the total number of data - // codewords in the symbol, including the Symbol Length Descriptor itself, data codewords and pad - // codewords, but excluding the number of error correction codewords. - let number_of_codewords: i32 = codewords[0]; - if number_of_codewords > codewords.len() { - throw FormatException::get_format_instance(); - } - if number_of_codewords == 0 { - // Reset to the length of the array - 8 (Allow for at least level 3 Error Correction (8 Error Codewords) - if num_e_c_codewords < codewords.len() { - codewords[0] = codewords.len() - num_e_c_codewords; - } else { - throw FormatException::get_format_instance(); - } - } - } - - fn get_bit_count_for_codeword( codeword: i32) -> Vec { - let mut result: [i32; 8] = [0; 8]; - let previous_value: i32 = 0; - let mut i: i32 = result.len() - 1; - while true { - if (codeword & 0x1) != previous_value { - previous_value = codeword & 0x1; - i -= 1; - if i < 0 { - break; - } - } - result[i] += 1; - codeword >>= 1; - } - return result; - } - - fn get_codeword_bucket_number( codeword: i32) -> i32 { - return ::get_codeword_bucket_number(&::get_bit_count_for_codeword(codeword)); - } - - fn get_codeword_bucket_number( module_bit_count: &Vec) -> i32 { - return (module_bit_count[0] - module_bit_count[2] + module_bit_count[4] - module_bit_count[6] + 9) % 9; - } - - pub fn to_string( barcode_matrix: &Vec>) -> String { - let tryResult1 = 0; - 'try1: loop { - ( let formatter: Formatter = Formatter::new()) { - { - let mut row: i32 = 0; - while row < barcode_matrix.len() { - { - formatter.format("Row %2d: ", row); - { - let mut column: i32 = 0; - while column < barcode_matrix[row].len() { - { - let barcode_value: BarcodeValue = barcode_matrix[row][column]; - if barcode_value.get_value().len() == 0 { - formatter.format(" ", null as Vec); - } else { - formatter.format("%4d(%2d)", barcode_value.get_value()[0], &barcode_value.get_confidence(barcode_value.get_value()[0])); - } - } - column += 1; - } - } - - formatter.format("%n"); - } - row += 1; - } - } - - return formatter.to_string(); - } - break 'try1 - } - match tryResult1 { - 0 => break - } - - } -} - diff --git a/src/pdf417/decoder/ec.rs b/src/pdf417/decoder/ec.rs deleted file mode 100644 index d67dcbc..0000000 --- a/src/pdf417/decoder/ec.rs +++ /dev/null @@ -1,630 +0,0 @@ -use crate::ChecksumException; -use crate::pdf417::PDF417Common; - - - -// NEW FILE: error_correction.rs -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder::ec; - -/** - *

PDF417 error correction implementation.

- * - *

This example - * is quite useful in understanding the algorithm.

- * - * @author Sean Owen - * @see com.google.zxing.common.reedsolomon.ReedSolomonDecoder - */ -pub struct ErrorCorrection { - - let mut field: ModulusGF; -} - -impl ErrorCorrection { - - pub fn new() -> ErrorCorrection { - let .field = ModulusGF::PDF417_GF; - } - - /** - * @param received received codewords - * @param numECCodewords number of those codewords used for EC - * @param erasures location of erasures - * @return number of errors - * @throws ChecksumException if errors cannot be corrected, maybe because of too many errors - */ - pub fn decode(&self, received: &Vec, num_e_c_codewords: i32, erasures: &Vec) -> /* throws ChecksumException */Result> { - let poly: ModulusPoly = ModulusPoly::new(self.field, &received); - const S: [i32; num_e_c_codewords] = [0; num_e_c_codewords]; - let mut error: bool = false; - { - let mut i: i32 = num_e_c_codewords; - while i > 0 { - { - let eval: i32 = poly.evaluate_at(&self.field.exp(i)); - S[num_e_c_codewords - i] = eval; - if eval != 0 { - error = true; - } - } - i -= 1; - } - } - - if !error { - return Ok(0); - } - let known_errors: ModulusPoly = self.field.get_one(); - if erasures != null { - for let erasure: i32 in erasures { - let b: i32 = self.field.exp(received.len() - 1 - erasure); - // Add (1 - bx) term: - let term: ModulusPoly = ModulusPoly::new(self.field, : vec![i32; 2] = vec![self.field.subtract(0, b), 1, ] - ); - known_errors = known_errors.multiply(term); - } - } - let syndrome: ModulusPoly = ModulusPoly::new(self.field, &S); - //syndrome = syndrome.multiply(knownErrors); - let sigma_omega: Vec = self.run_euclidean_algorithm(&self.field.build_monomial(num_e_c_codewords, 1), syndrome, num_e_c_codewords); - let sigma: ModulusPoly = sigma_omega[0]; - let omega: ModulusPoly = sigma_omega[1]; - //sigma = sigma.multiply(knownErrors); - let error_locations: Vec = self.find_error_locations(sigma); - let error_magnitudes: Vec = self.find_error_magnitudes(omega, sigma, &error_locations); - { - let mut i: i32 = 0; - while i < error_locations.len() { - { - let mut position: i32 = received.len() - 1 - self.field.log(error_locations[i]); - if position < 0 { - throw ChecksumException::get_checksum_instance(); - } - received[position] = self.field.subtract(received[position], error_magnitudes[i]); - } - i += 1; - } - } - - return Ok(error_locations.len()); - } - - fn run_euclidean_algorithm(&self, a: &ModulusPoly, b: &ModulusPoly, R: i32) -> /* throws ChecksumException */Result, Rc> { - // Assume a's degree is >= b's - if a.get_degree() < b.get_degree() { - let temp: ModulusPoly = a; - a = b; - b = temp; - } - let r_last: ModulusPoly = a; - let mut r: ModulusPoly = b; - let t_last: ModulusPoly = self.field.get_zero(); - let mut t: ModulusPoly = self.field.get_one(); - // Run Euclidean algorithm until r's degree is less than R/2 - while r.get_degree() >= R / 2 { - let r_last_last: ModulusPoly = r_last; - let t_last_last: ModulusPoly = t_last; - r_last = r; - t_last = t; - // Divide rLastLast by rLast, with quotient in q and remainder in r - if r_last.is_zero() { - // Oops, Euclidean algorithm already terminated? - throw ChecksumException::get_checksum_instance(); - } - r = r_last_last; - let mut q: ModulusPoly = self.field.get_zero(); - let denominator_leading_term: i32 = r_last.get_coefficient(&r_last.get_degree()); - let dlt_inverse: i32 = self.field.inverse(denominator_leading_term); - while r.get_degree() >= r_last.get_degree() && !r.is_zero() { - let degree_diff: i32 = r.get_degree() - r_last.get_degree(); - let scale: i32 = self.field.multiply(&r.get_coefficient(&r.get_degree()), dlt_inverse); - q = q.add(&self.field.build_monomial(degree_diff, scale)); - r = r.subtract(&r_last.multiply_by_monomial(degree_diff, scale)); - } - t = q.multiply(t_last).subtract(t_last_last).negative(); - } - let sigma_tilde_at_zero: i32 = t.get_coefficient(0); - if sigma_tilde_at_zero == 0 { - throw ChecksumException::get_checksum_instance(); - } - let inverse: i32 = self.field.inverse(sigma_tilde_at_zero); - let sigma: ModulusPoly = t.multiply(inverse); - let omega: ModulusPoly = r.multiply(inverse); - return Ok( : vec![ModulusPoly; 2] = vec![sigma, omega, ] - ); - } - - fn find_error_locations(&self, error_locator: &ModulusPoly) -> /* throws ChecksumException */Result, Rc> { - // This is a direct application of Chien's search - let num_errors: i32 = error_locator.get_degree(); - let mut result: [i32; num_errors] = [0; num_errors]; - let mut e: i32 = 0; - { - let mut i: i32 = 1; - while i < self.field.get_size() && e < num_errors { - { - if error_locator.evaluate_at(i) == 0 { - result[e] = self.field.inverse(i); - e += 1; - } - } - i += 1; - } - } - - if e != num_errors { - throw ChecksumException::get_checksum_instance(); - } - return Ok(result); - } - - fn find_error_magnitudes(&self, error_evaluator: &ModulusPoly, error_locator: &ModulusPoly, error_locations: &Vec) -> Vec { - let error_locator_degree: i32 = error_locator.get_degree(); - if error_locator_degree < 1 { - return : [i32; 0] = [0; 0]; - } - let formal_derivative_coefficients: [i32; error_locator_degree] = [0; error_locator_degree]; - { - let mut i: i32 = 1; - while i <= error_locator_degree { - { - formal_derivative_coefficients[error_locator_degree - i] = self.field.multiply(i, &error_locator.get_coefficient(i)); - } - i += 1; - } - } - - let formal_derivative: ModulusPoly = ModulusPoly::new(self.field, &formal_derivative_coefficients); - // This is directly applying Forney's Formula - let s: i32 = error_locations.len(); - let mut result: [i32; s] = [0; s]; - { - let mut i: i32 = 0; - while i < s { - { - let xi_inverse: i32 = self.field.inverse(error_locations[i]); - let numerator: i32 = self.field.subtract(0, &error_evaluator.evaluate_at(xi_inverse)); - let denominator: i32 = self.field.inverse(&formal_derivative.evaluate_at(xi_inverse)); - result[i] = self.field.multiply(numerator, denominator); - } - i += 1; - } - } - - return result; - } -} - -// NEW FILE: modulus_g_f.rs -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder::ec; - -/** - *

A field based on powers of a generator integer, modulo some modulus.

- * - * @author Sean Owen - * @see com.google.zxing.common.reedsolomon.GenericGF - */ - - const PDF417_GF: ModulusGF = ModulusGF::new(PDF417Common.NUMBER_OF_CODEWORDS, 3); -pub struct ModulusGF { - - let exp_table: Vec; - - let log_table: Vec; - - let mut zero: ModulusPoly; - - let mut one: ModulusPoly; - - let modulus: i32; -} - -impl ModulusGF { - - fn new( modulus: i32, generator: i32) -> ModulusGF { - let .modulus = modulus; - exp_table = : [i32; modulus] = [0; modulus]; - log_table = : [i32; modulus] = [0; modulus]; - let mut x: i32 = 1; - { - let mut i: i32 = 0; - while i < modulus { - { - exp_table[i] = x; - x = (x * generator) % modulus; - } - i += 1; - } - } - - { - let mut i: i32 = 0; - while i < modulus - 1 { - { - log_table[exp_table[i]] = i; - } - i += 1; - } - } - - // logTable[0] == 0 but this should never be used - zero = ModulusPoly::new(let , : vec![i32; 1] = vec![0, ] - ); - one = ModulusPoly::new(let , : vec![i32; 1] = vec![1, ] - ); - } - - fn get_zero(&self) -> ModulusPoly { - return self.zero; - } - - fn get_one(&self) -> ModulusPoly { - return self.one; - } - - fn build_monomial(&self, degree: i32, coefficient: i32) -> ModulusPoly { - if degree < 0 { - throw IllegalArgumentException::new(); - } - if coefficient == 0 { - return self.zero; - } - let mut coefficients: [i32; degree + 1] = [0; degree + 1]; - coefficients[0] = coefficient; - return ModulusPoly::new(self, &coefficients); - } - - fn add(&self, a: i32, b: i32) -> i32 { - return (a + b) % self.modulus; - } - - fn subtract(&self, a: i32, b: i32) -> i32 { - return (self.modulus + a - b) % self.modulus; - } - - fn exp(&self, a: i32) -> i32 { - return self.exp_table[a]; - } - - fn log(&self, a: i32) -> i32 { - if a == 0 { - throw IllegalArgumentException::new(); - } - return self.log_table[a]; - } - - fn inverse(&self, a: i32) -> i32 { - if a == 0 { - throw ArithmeticException::new(); - } - return self.exp_table[self.modulus - self.log_table[a] - 1]; - } - - fn multiply(&self, a: i32, b: i32) -> i32 { - if a == 0 || b == 0 { - return 0; - } - return self.exp_table[(self.log_table[a] + self.log_table[b]) % (self.modulus - 1)]; - } - - fn get_size(&self) -> i32 { - return self.modulus; - } -} - -// NEW FILE: modulus_poly.rs -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::decoder::ec; - -/** - * @author Sean Owen - */ -struct ModulusPoly { - - let field: ModulusGF; - - let coefficients: Vec; -} - -impl ModulusPoly { - - fn new( field: &ModulusGF, coefficients: &Vec) -> ModulusPoly { - if coefficients.len() == 0 { - throw IllegalArgumentException::new(); - } - let .field = field; - let coefficients_length: i32 = coefficients.len(); - if coefficients_length > 1 && coefficients[0] == 0 { - // Leading term must be non-zero for anything except the constant polynomial "0" - let first_non_zero: i32 = 1; - while first_non_zero < coefficients_length && coefficients[first_non_zero] == 0 { - first_non_zero += 1; - } - if first_non_zero == coefficients_length { - let .coefficients = : vec![i32; 1] = vec![0, ] - ; - } else { - let .coefficients = : [i32; coefficients_length - first_non_zero] = [0; coefficients_length - first_non_zero]; - System::arraycopy(&coefficients, first_non_zero, let .coefficients, 0, let .coefficients.len()); - } - } else { - let .coefficients = coefficients; - } - } - - fn get_coefficients(&self) -> Vec { - return self.coefficients; - } - - /** - * @return degree of this polynomial - */ - fn get_degree(&self) -> i32 { - return self.coefficients.len() - 1; - } - - /** - * @return true iff this polynomial is the monomial "0" - */ - fn is_zero(&self) -> bool { - return self.coefficients[0] == 0; - } - - /** - * @return coefficient of x^degree term in this polynomial - */ - fn get_coefficient(&self, degree: i32) -> i32 { - return self.coefficients[self.coefficients.len() - 1 - degree]; - } - - /** - * @return evaluation of this polynomial at a given point - */ - fn evaluate_at(&self, a: i32) -> i32 { - if a == 0 { - // Just return the x^0 coefficient - return self.get_coefficient(0); - } - if a == 1 { - // Just the sum of the coefficients - let mut result: i32 = 0; - for let coefficient: i32 in self.coefficients { - result = self.field.add(result, coefficient); - } - return result; - } - let mut result: i32 = self.coefficients[0]; - let size: i32 = self.coefficients.len(); - { - let mut i: i32 = 1; - while i < size { - { - result = self.field.add(&self.field.multiply(a, result), self.coefficients[i]); - } - i += 1; - } - } - - return result; - } - - fn add(&self, other: &ModulusPoly) -> ModulusPoly { - if !self.field.equals(other.field) { - throw IllegalArgumentException::new("ModulusPolys do not have same ModulusGF field"); - } - if self.is_zero() { - return other; - } - if other.is_zero() { - return self; - } - let smaller_coefficients: Vec = self.coefficients; - let larger_coefficients: Vec = other.coefficients; - if smaller_coefficients.len() > larger_coefficients.len() { - let temp: Vec = smaller_coefficients; - smaller_coefficients = larger_coefficients; - larger_coefficients = temp; - } - let sum_diff: [i32; larger_coefficients.len()] = [0; larger_coefficients.len()]; - let length_diff: i32 = larger_coefficients.len() - smaller_coefficients.len(); - // Copy high-order terms only found in higher-degree polynomial's coefficients - System::arraycopy(&larger_coefficients, 0, &sum_diff, 0, length_diff); - { - let mut i: i32 = length_diff; - while i < larger_coefficients.len() { - { - sum_diff[i] = self.field.add(smaller_coefficients[i - length_diff], larger_coefficients[i]); - } - i += 1; - } - } - - return ModulusPoly::new(self.field, &sum_diff); - } - - fn subtract(&self, other: &ModulusPoly) -> ModulusPoly { - if !self.field.equals(other.field) { - throw IllegalArgumentException::new("ModulusPolys do not have same ModulusGF field"); - } - if other.is_zero() { - return self; - } - return self.add(&other.negative()); - } - - fn multiply(&self, other: &ModulusPoly) -> ModulusPoly { - if !self.field.equals(other.field) { - throw IllegalArgumentException::new("ModulusPolys do not have same ModulusGF field"); - } - if self.is_zero() || other.is_zero() { - return self.field.get_zero(); - } - let a_coefficients: Vec = self.coefficients; - let a_length: i32 = a_coefficients.len(); - let b_coefficients: Vec = other.coefficients; - let b_length: i32 = b_coefficients.len(); - let mut product: [i32; a_length + b_length - 1] = [0; a_length + b_length - 1]; - { - let mut i: i32 = 0; - while i < a_length { - { - let a_coeff: i32 = a_coefficients[i]; - { - let mut j: i32 = 0; - while j < b_length { - { - product[i + j] = self.field.add(product[i + j], &self.field.multiply(a_coeff, b_coefficients[j])); - } - j += 1; - } - } - - } - i += 1; - } - } - - return ModulusPoly::new(self.field, &product); - } - - fn negative(&self) -> ModulusPoly { - let size: i32 = self.coefficients.len(); - let negative_coefficients: [i32; size] = [0; size]; - { - let mut i: i32 = 0; - while i < size { - { - negative_coefficients[i] = self.field.subtract(0, self.coefficients[i]); - } - i += 1; - } - } - - return ModulusPoly::new(self.field, &negative_coefficients); - } - - fn multiply(&self, scalar: i32) -> ModulusPoly { - if scalar == 0 { - return self.field.get_zero(); - } - if scalar == 1 { - return self; - } - let size: i32 = self.coefficients.len(); - let mut product: [i32; size] = [0; size]; - { - let mut i: i32 = 0; - while i < size { - { - product[i] = self.field.multiply(self.coefficients[i], scalar); - } - i += 1; - } - } - - return ModulusPoly::new(self.field, &product); - } - - fn multiply_by_monomial(&self, degree: i32, coefficient: i32) -> ModulusPoly { - if degree < 0 { - throw IllegalArgumentException::new(); - } - if coefficient == 0 { - return self.field.get_zero(); - } - let size: i32 = self.coefficients.len(); - let mut product: [i32; size + degree] = [0; size + degree]; - { - let mut i: i32 = 0; - while i < size { - { - product[i] = self.field.multiply(self.coefficients[i], coefficient); - } - i += 1; - } - } - - return ModulusPoly::new(self.field, &product); - } - - pub fn to_string(&self) -> String { - let result: StringBuilder = StringBuilder::new(8 * self.get_degree()); - { - let mut degree: i32 = self.get_degree(); - while degree >= 0 { - { - let mut coefficient: i32 = self.get_coefficient(degree); - if coefficient != 0 { - if coefficient < 0 { - result.append(" - "); - coefficient = -coefficient; - } else { - if result.length() > 0 { - result.append(" + "); - } - } - if degree == 0 || coefficient != 1 { - result.append(coefficient); - } - if degree != 0 { - if degree == 1 { - result.append('x'); - } else { - result.append("x^"); - result.append(degree); - } - } - } - } - degree -= 1; - } - } - - return result.to_string(); - } -} - diff --git a/src/pdf417/detector.rs b/src/pdf417/detector.rs deleted file mode 100644 index 6df7e18..0000000 --- a/src/pdf417/detector.rs +++ /dev/null @@ -1,433 +0,0 @@ -use crate::{BinaryBitmap,NotFoundException,DecodeHintType,ResultPoint}; -use crate::common::BitMatrix; - -// NEW FILE: detector.rs -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::detector; - -/** - *

Encapsulates logic that can detect a PDF417 Code in an image, even if the - * PDF417 Code is rotated or skewed, or partially obscured.

- * - * @author SITA Lab (kevin.osullivan@sita.aero) - * @author dswitkin@google.com (Daniel Switkin) - * @author Guenther Grau - */ - - const INDEXES_START_PATTERN: vec![Vec; 4] = vec![0, 4, 1, 5, ] -; - - const INDEXES_STOP_PATTERN: vec![Vec; 4] = vec![6, 2, 7, 3, ] -; - - const MAX_AVG_VARIANCE: f32 = 0.42f; - - const MAX_INDIVIDUAL_VARIANCE: f32 = 0.8f; - -// B S B S B S B S Bar/Space pattern -// 11111111 0 1 0 1 0 1 000 - const START_PATTERN: vec![Vec; 8] = vec![8, 1, 1, 1, 1, 1, 1, 3, ] -; - -// 1111111 0 1 000 1 0 1 00 1 - const STOP_PATTERN: vec![Vec; 9] = vec![7, 1, 1, 3, 1, 1, 1, 2, 1, ] -; - - const MAX_PIXEL_DRIFT: i32 = 3; - - const MAX_PATTERN_DRIFT: i32 = 5; - -// if we set the value too low, then we don't detect the correct height of the bar if the start patterns are damaged. -// if we set the value too high, then we might detect the start pattern from a neighbor barcode. - const SKIPPED_ROW_COUNT_MAX: i32 = 25; - -// A PDF471 barcode should have at least 3 rows, with each row being >= 3 times the module width. -// Therefore it should be at least 9 pixels tall. To be conservative, we use about half the size to -// ensure we don't miss it. - const ROW_STEP: i32 = 5; - - const BARCODE_MIN_HEIGHT: i32 = 10; - - const ROTATIONS: vec![Vec; 4] = vec![0, 180, 270, 90, ] -; -pub struct Detector { -} - -impl Detector { - - fn new() -> Detector { - } - - /** - *

Detects a PDF417 Code in an image. Checks 0, 90, 180, and 270 degree rotations.

- * - * @param image barcode image to decode - * @param hints optional hints to detector - * @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will - * be found and returned - * @return {@link PDF417DetectorResult} encapsulating results of detecting a PDF417 code - * @throws NotFoundException if no PDF417 Code can be found - */ - pub fn detect( image: &BinaryBitmap, hints: &Map, multiple: bool) -> /* throws NotFoundException */Result> { - // TODO detection improvement, tryHarder could try several different luminance thresholds/blackpoints or even - // different binarizers - //boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); - let original_matrix: BitMatrix = image.get_black_matrix(); - for let rotation: i32 in ROTATIONS { - let bit_matrix: BitMatrix = ::apply_rotation(original_matrix, rotation); - let barcode_coordinates: List> = ::detect(multiple, bit_matrix); - if !barcode_coordinates.is_empty() { - return Ok(PDF417DetectorResult::new(bit_matrix, &barcode_coordinates, rotation)); - } - } - return Ok(PDF417DetectorResult::new(original_matrix, ArrayList<>::new(), 0)); - } - - /** - * Applies a rotation to the supplied BitMatrix. - * @param matrix bit matrix to apply rotation to - * @param rotation the degrees of rotation to apply - * @return BitMatrix with applied rotation - */ - fn apply_rotation( matrix: &BitMatrix, rotation: i32) -> BitMatrix { - if rotation % 360 == 0 { - return matrix; - } - let new_matrix: BitMatrix = matrix.clone(); - new_matrix.rotate(rotation); - return new_matrix; - } - - /** - * Detects PDF417 codes in an image. Only checks 0 degree rotation - * @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will - * be found and returned - * @param bitMatrix bit matrix to detect barcodes in - * @return List of ResultPoint arrays containing the coordinates of found barcodes - */ - fn detect( multiple: bool, bit_matrix: &BitMatrix) -> List> { - let barcode_coordinates: List> = ArrayList<>::new(); - let mut row: i32 = 0; - let mut column: i32 = 0; - let found_barcode_in_row: bool = false; - while row < bit_matrix.get_height() { - let vertices: Vec = ::find_vertices(bit_matrix, row, column); - if vertices[0] == null && vertices[3] == null { - if !found_barcode_in_row { - // we didn't find any barcode so that's the end of searching - break; - } - // we didn't find a barcode starting at the given column and row. Try again from the first column and slightly - // below the lowest barcode we found so far. - found_barcode_in_row = false; - column = 0; - for let barcode_coordinate: Vec in barcode_coordinates { - if barcode_coordinate[1] != null { - row = Math::max(row, &barcode_coordinate[1].get_y()) as i32; - } - if barcode_coordinate[3] != null { - row = Math::max(row, barcode_coordinate[3].get_y() as i32); - } - } - row += ROW_STEP; - continue; - } - found_barcode_in_row = true; - barcode_coordinates.add(vertices); - if !multiple { - break; - } - // start pattern of the barcode just found. - if vertices[2] != null { - column = vertices[2].get_x() as i32; - row = vertices[2].get_y() as i32; - } else { - column = vertices[4].get_x() as i32; - row = vertices[4].get_y() as i32; - } - } - return Ok(barcode_coordinates); - } - - /** - * Locate the vertices and the codewords area of a black blob using the Start - * and Stop patterns as locators. - * - * @param matrix the scanned barcode image. - * @return an array containing the vertices: - * vertices[0] x, y top left barcode - * vertices[1] x, y bottom left barcode - * vertices[2] x, y top right barcode - * vertices[3] x, y bottom right barcode - * vertices[4] x, y top left codeword area - * vertices[5] x, y bottom left codeword area - * vertices[6] x, y top right codeword area - * vertices[7] x, y bottom right codeword area - */ - fn find_vertices( matrix: &BitMatrix, start_row: i32, start_column: i32) -> Vec { - let height: i32 = matrix.get_height(); - let width: i32 = matrix.get_width(); - let result: [Option; 8] = [None; 8]; - ::copy_to_result(result, &::find_rows_with_pattern(matrix, height, width, start_row, start_column, &START_PATTERN), &INDEXES_START_PATTERN); - if result[4] != null { - start_column = result[4].get_x() as i32; - start_row = result[4].get_y() as i32; - } - ::copy_to_result(result, &::find_rows_with_pattern(matrix, height, width, start_row, start_column, &STOP_PATTERN), &INDEXES_STOP_PATTERN); - return result; - } - - fn copy_to_result( result: &Vec, tmp_result: &Vec, destination_indexes: &Vec) { - { - let mut i: i32 = 0; - while i < destination_indexes.len() { - { - result[destination_indexes[i]] = tmp_result[i]; - } - i += 1; - } - } - - } - - fn find_rows_with_pattern( matrix: &BitMatrix, height: i32, width: i32, start_row: i32, start_column: i32, pattern: &Vec) -> Vec { - let mut result: [Option; 4] = [None; 4]; - let mut found: bool = false; - let counters: [i32; pattern.len()] = [0; pattern.len()]; - while start_row < height { - { - let mut loc: Vec = ::find_guard_pattern(matrix, start_column, start_row, width, &pattern, &counters); - if loc != null { - while start_row > 0 { - let previous_row_loc: Vec = ::find_guard_pattern(matrix, start_column, start_row -= 1, width, &pattern, &counters); - if previous_row_loc != null { - loc = previous_row_loc; - } else { - start_row += 1; - break; - } - } - result[0] = ResultPoint::new(loc[0], start_row); - result[1] = ResultPoint::new(loc[1], start_row); - found = true; - break; - } - } - start_row += ROW_STEP; - } - - let stop_row: i32 = start_row + 1; - // Last row of the current symbol that contains pattern - if found { - let skipped_row_count: i32 = 0; - let previous_row_loc: vec![Vec; 2] = vec![result[0].get_x() as i32, result[1].get_x() as i32, ] - ; - while stop_row < height { - { - let loc: Vec = ::find_guard_pattern(matrix, previous_row_loc[0], stop_row, width, &pattern, &counters); - // larger drift and don't check for skipped rows. - if loc != null && Math::abs(previous_row_loc[0] - loc[0]) < MAX_PATTERN_DRIFT && Math::abs(previous_row_loc[1] - loc[1]) < MAX_PATTERN_DRIFT { - previous_row_loc = loc; - skipped_row_count = 0; - } else { - if skipped_row_count > SKIPPED_ROW_COUNT_MAX { - break; - } else { - skipped_row_count += 1; - } - } - } - stop_row += 1; - } - - stop_row -= skipped_row_count + 1; - result[2] = ResultPoint::new(previous_row_loc[0], stop_row); - result[3] = ResultPoint::new(previous_row_loc[1], stop_row); - } - if stop_row - start_row < BARCODE_MIN_HEIGHT { - Arrays::fill(result, null); - } - return result; - } - - /** - * @param matrix row of black/white values to search - * @param column x position to start search - * @param row y position to start search - * @param width the number of pixels to search on this row - * @param pattern pattern of counts of number of black and white pixels that are - * being searched for as a pattern - * @param counters array of counters, as long as pattern, to re-use - * @return start/end horizontal offset of guard pattern, as an array of two ints. - */ - fn find_guard_pattern( matrix: &BitMatrix, column: i32, row: i32, width: i32, pattern: &Vec, counters: &Vec) -> Vec { - Arrays::fill(&counters, 0, counters.len(), 0); - let pattern_start: i32 = column; - let pixel_drift: i32 = 0; - // if there are black pixels left of the current pixel shift to the left, but only for MAX_PIXEL_DRIFT pixels - while matrix.get(pattern_start, row) && pattern_start > 0 && pixel_drift += 1 !!!check!!! post increment < MAX_PIXEL_DRIFT { - pattern_start -= 1; - } - let mut x: i32 = pattern_start; - let counter_position: i32 = 0; - let pattern_length: i32 = pattern.len(); - { - let is_white: bool = false; - while x < width { - { - let pixel: bool = matrix.get(x, row); - if pixel != is_white { - counters[counter_position] += 1; - } else { - if counter_position == pattern_length - 1 { - if ::pattern_match_variance(&counters, &pattern) < MAX_AVG_VARIANCE { - return : vec![i32; 2] = vec![pattern_start, x, ] - ; - } - pattern_start += counters[0] + counters[1]; - System::arraycopy(&counters, 2, &counters, 0, counter_position - 1); - counters[counter_position - 1] = 0; - counters[counter_position] = 0; - counter_position -= 1; - } else { - counter_position += 1; - } - counters[counter_position] = 1; - is_white = !is_white; - } - } - x += 1; - } - } - - if counter_position == pattern_length - 1 && ::pattern_match_variance(&counters, &pattern) < MAX_AVG_VARIANCE { - return : vec![i32; 2] = vec![pattern_start, x - 1, ] - ; - } - return null; - } - - /** - * Determines how closely a set of observed counts of runs of black/white - * values matches a given target pattern. This is reported as the ratio of - * the total variance from the expected pattern proportions across all - * pattern elements, to the length of the pattern. - * - * @param counters observed counters - * @param pattern expected pattern - * @return ratio of total variance between counters and pattern compared to total pattern size - */ - fn pattern_match_variance( counters: &Vec, pattern: &Vec) -> f32 { - let num_counters: i32 = counters.len(); - let mut total: i32 = 0; - let pattern_length: i32 = 0; - { - let mut i: i32 = 0; - while i < num_counters { - { - total += counters[i]; - pattern_length += pattern[i]; - } - i += 1; - } - } - - if total < pattern_length { - // is too small to reliably match, so fail: - return Float::POSITIVE_INFINITY; - } - // We're going to fake floating-point math in integers. We just need to use more bits. - // Scale up patternLength so that intermediate values below like scaledCounter will have - // more "significant digits". - let unit_bar_width: f32 = total as f32 / pattern_length; - let max_individual_variance: f32 = MAX_INDIVIDUAL_VARIANCE * unit_bar_width; - let total_variance: f32 = 0.0f; - { - let mut x: i32 = 0; - while x < num_counters { - { - let counter: i32 = counters[x]; - let scaled_pattern: f32 = pattern[x] * unit_bar_width; - let variance: f32 = if counter > scaled_pattern { counter - scaled_pattern } else { scaled_pattern - counter }; - if variance > max_individual_variance { - return Float::POSITIVE_INFINITY; - } - total_variance += variance; - } - x += 1; - } - } - - return total_variance / total; - } -} - -// NEW FILE: p_d_f417_detector_result.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::detector; - -/** - * @author Guenther Grau - */ -pub struct PDF417DetectorResult { - - let bits: BitMatrix; - - let points: List>; - - let rotation: i32; -} - -impl PDF417DetectorResult { - - pub fn new( bits: &BitMatrix, points: &List>, rotation: i32) -> PDF417DetectorResult { - let .bits = bits; - let .points = points; - let .rotation = rotation; - } - - pub fn new( bits: &BitMatrix, points: &List>) -> PDF417DetectorResult { - this(bits, &points, 0); - } - - pub fn get_bits(&self) -> BitMatrix { - return self.bits; - } - - pub fn get_points(&self) -> List> { - return self.points; - } - - pub fn get_rotation(&self) -> i32 { - return self.rotation; - } -} - diff --git a/src/pdf417/encoder.rs b/src/pdf417/encoder.rs deleted file mode 100644 index ef21bd2..0000000 --- a/src/pdf417/encoder.rs +++ /dev/null @@ -1,1566 +0,0 @@ -use crate::{WriterException,}; -use crate::common::{CharacterSetECI,ECIInput,MinimalECIInput}; - - -// NEW FILE: barcode_matrix.rs -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::encoder; - -/** - * Holds all of the information for a barcode in a format where it can be easily accessible - * - * @author Jacob Haynes - */ -pub struct BarcodeMatrix { - - let mut matrix: Vec; - - let current_row: i32; - - let height: i32; - - let width: i32; -} - -impl BarcodeMatrix { - - /** - * @param height the height of the matrix (Rows) - * @param width the width of the matrix (Cols) - */ - fn new( height: i32, width: i32) -> BarcodeMatrix { - matrix = : [Option; height] = [None; height]; - //Initializes the array to the correct width - { - let mut i: i32 = 0, let matrix_length: i32 = matrix.len(); - while i < matrix_length { - { - matrix[i] = BarcodeRow::new((width + 4) * 17 + 1); - } - i += 1; - } - } - - let .width = width * 17; - let .height = height; - let .currentRow = -1; - } - - fn set(&self, x: i32, y: i32, value: i8) { - self.matrix[y].set(x, value); - } - - fn start_row(&self) { - self.current_row += 1; - } - - fn get_current_row(&self) -> BarcodeRow { - return self.matrix[self.current_row]; - } - - pub fn get_matrix(&self) -> Vec> { - return self.get_scaled_matrix(1, 1); - } - - pub fn get_scaled_matrix(&self, x_scale: i32, y_scale: i32) -> Vec> { - let matrix_out: [[i8; self.width * x_scale]; self.height * y_scale] = [[0; self.width * x_scale]; self.height * y_scale]; - let y_max: i32 = self.height * y_scale; - { - let mut i: i32 = 0; - while i < y_max { - { - matrix_out[y_max - i - 1] = self.matrix[i / y_scale].get_scaled_row(x_scale); - } - i += 1; - } - } - - return matrix_out; - } -} - -// NEW FILE: barcode_row.rs -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::encoder; - -/** - * @author Jacob Haynes - */ -struct BarcodeRow { - - let mut row: Vec; - - //A tacker for position in the bar - let current_location: i32; -} - -impl BarcodeRow { - - /** - * Creates a Barcode row of the width - */ - fn new( width: i32) -> BarcodeRow { - let .row = : [i8; width] = [0; width]; - current_location = 0; - } - - /** - * Sets a specific location in the bar - * - * @param x The location in the bar - * @param value Black if true, white if false; - */ - fn set(&self, x: i32, value: i8) { - self.row[x] = value; - } - - /** - * Sets a specific location in the bar - * - * @param x The location in the bar - * @param black Black if true, white if false; - */ - fn set(&self, x: i32, black: bool) { - self.row[x] = ( if black { 1 } else { 0 }) as i8; - } - - /** - * @param black A boolean which is true if the bar black false if it is white - * @param width How many spots wide the bar is. - */ - fn add_bar(&self, black: bool, width: i32) { - { - let mut ii: i32 = 0; - while ii < width { - { - self.set(self.current_location += 1 !!!check!!! post increment, black); - } - ii += 1; - } - } - - } - - /** - * This function scales the row - * - * @param scale How much you want the image to be scaled, must be greater than or equal to 1. - * @return the scaled row - */ - fn get_scaled_row(&self, scale: i32) -> Vec { - let mut output: [i8; self.row.len() * scale] = [0; self.row.len() * scale]; - { - let mut i: i32 = 0; - while i < output.len() { - { - output[i] = self.row[i / scale]; - } - i += 1; - } - } - - return output; - } -} - -// NEW FILE: compaction.rs -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::encoder; - -/** - * Represents possible PDF417 barcode compaction types. - */ -pub enum Compaction { - - AUTO(), TEXT(), BYTE(), NUMERIC() -} -// NEW FILE: dimensions.rs -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::encoder; - -/** - * Data object to specify the minimum and maximum number of rows and columns for a PDF417 barcode. - * - * @author qwandor@google.com (Andrew Walbran) - */ -pub struct Dimensions { - - let min_cols: i32; - - let max_cols: i32; - - let min_rows: i32; - - let max_rows: i32; -} - -impl Dimensions { - - pub fn new( min_cols: i32, max_cols: i32, min_rows: i32, max_rows: i32) -> Dimensions { - let .minCols = min_cols; - let .maxCols = max_cols; - let .minRows = min_rows; - let .maxRows = max_rows; - } - - pub fn get_min_cols(&self) -> i32 { - return self.min_cols; - } - - pub fn get_max_cols(&self) -> i32 { - return self.max_cols; - } - - pub fn get_min_rows(&self) -> i32 { - return self.min_rows; - } - - pub fn get_max_rows(&self) -> i32 { - return self.max_rows; - } -} - -// NEW FILE: p_d_f417.rs -/* - * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::encoder; - -/** - * Top-level class for the logic part of the PDF417 implementation. - */ - -/** - * The start pattern (17 bits) - */ - const START_PATTERN: i32 = 0x1fea8; - -/** - * The stop pattern (18 bits) - */ - const STOP_PATTERN: i32 = 0x3fa29; - -/** - * The codeword table from the Annex A of ISO/IEC 15438:2001(E). - */ - const CODEWORD_TABLE: vec![vec![Vec>; 929]; 3] = vec![vec![0x1d5c0, 0x1eaf0, 0x1f57c, 0x1d4e0, 0x1ea78, 0x1f53e, 0x1a8c0, 0x1d470, 0x1a860, 0x15040, 0x1a830, 0x15020, 0x1adc0, 0x1d6f0, 0x1eb7c, 0x1ace0, 0x1d678, 0x1eb3e, 0x158c0, 0x1ac70, 0x15860, 0x15dc0, 0x1aef0, 0x1d77c, 0x15ce0, 0x1ae78, 0x1d73e, 0x15c70, 0x1ae3c, 0x15ef0, 0x1af7c, 0x15e78, 0x1af3e, 0x15f7c, 0x1f5fa, 0x1d2e0, 0x1e978, 0x1f4be, 0x1a4c0, 0x1d270, 0x1e93c, 0x1a460, 0x1d238, 0x14840, 0x1a430, 0x1d21c, 0x14820, 0x1a418, 0x14810, 0x1a6e0, 0x1d378, 0x1e9be, 0x14cc0, 0x1a670, 0x1d33c, 0x14c60, 0x1a638, 0x1d31e, 0x14c30, 0x1a61c, 0x14ee0, 0x1a778, 0x1d3be, 0x14e70, 0x1a73c, 0x14e38, 0x1a71e, 0x14f78, 0x1a7be, 0x14f3c, 0x14f1e, 0x1a2c0, 0x1d170, 0x1e8bc, 0x1a260, 0x1d138, 0x1e89e, 0x14440, 0x1a230, 0x1d11c, 0x14420, 0x1a218, 0x14410, 0x14408, 0x146c0, 0x1a370, 0x1d1bc, 0x14660, 0x1a338, 0x1d19e, 0x14630, 0x1a31c, 0x14618, 0x1460c, 0x14770, 0x1a3bc, 0x14738, 0x1a39e, 0x1471c, 0x147bc, 0x1a160, 0x1d0b8, 0x1e85e, 0x14240, 0x1a130, 0x1d09c, 0x14220, 0x1a118, 0x1d08e, 0x14210, 0x1a10c, 0x14208, 0x1a106, 0x14360, 0x1a1b8, 0x1d0de, 0x14330, 0x1a19c, 0x14318, 0x1a18e, 0x1430c, 0x14306, 0x1a1de, 0x1438e, 0x14140, 0x1a0b0, 0x1d05c, 0x14120, 0x1a098, 0x1d04e, 0x14110, 0x1a08c, 0x14108, 0x1a086, 0x14104, 0x141b0, 0x14198, 0x1418c, 0x140a0, 0x1d02e, 0x1a04c, 0x1a046, 0x14082, 0x1cae0, 0x1e578, 0x1f2be, 0x194c0, 0x1ca70, 0x1e53c, 0x19460, 0x1ca38, 0x1e51e, 0x12840, 0x19430, 0x12820, 0x196e0, 0x1cb78, 0x1e5be, 0x12cc0, 0x19670, 0x1cb3c, 0x12c60, 0x19638, 0x12c30, 0x12c18, 0x12ee0, 0x19778, 0x1cbbe, 0x12e70, 0x1973c, 0x12e38, 0x12e1c, 0x12f78, 0x197be, 0x12f3c, 0x12fbe, 0x1dac0, 0x1ed70, 0x1f6bc, 0x1da60, 0x1ed38, 0x1f69e, 0x1b440, 0x1da30, 0x1ed1c, 0x1b420, 0x1da18, 0x1ed0e, 0x1b410, 0x1da0c, 0x192c0, 0x1c970, 0x1e4bc, 0x1b6c0, 0x19260, 0x1c938, 0x1e49e, 0x1b660, 0x1db38, 0x1ed9e, 0x16c40, 0x12420, 0x19218, 0x1c90e, 0x16c20, 0x1b618, 0x16c10, 0x126c0, 0x19370, 0x1c9bc, 0x16ec0, 0x12660, 0x19338, 0x1c99e, 0x16e60, 0x1b738, 0x1db9e, 0x16e30, 0x12618, 0x16e18, 0x12770, 0x193bc, 0x16f70, 0x12738, 0x1939e, 0x16f38, 0x1b79e, 0x16f1c, 0x127bc, 0x16fbc, 0x1279e, 0x16f9e, 0x1d960, 0x1ecb8, 0x1f65e, 0x1b240, 0x1d930, 0x1ec9c, 0x1b220, 0x1d918, 0x1ec8e, 0x1b210, 0x1d90c, 0x1b208, 0x1b204, 0x19160, 0x1c8b8, 0x1e45e, 0x1b360, 0x19130, 0x1c89c, 0x16640, 0x12220, 0x1d99c, 0x1c88e, 0x16620, 0x12210, 0x1910c, 0x16610, 0x1b30c, 0x19106, 0x12204, 0x12360, 0x191b8, 0x1c8de, 0x16760, 0x12330, 0x1919c, 0x16730, 0x1b39c, 0x1918e, 0x16718, 0x1230c, 0x12306, 0x123b8, 0x191de, 0x167b8, 0x1239c, 0x1679c, 0x1238e, 0x1678e, 0x167de, 0x1b140, 0x1d8b0, 0x1ec5c, 0x1b120, 0x1d898, 0x1ec4e, 0x1b110, 0x1d88c, 0x1b108, 0x1d886, 0x1b104, 0x1b102, 0x12140, 0x190b0, 0x1c85c, 0x16340, 0x12120, 0x19098, 0x1c84e, 0x16320, 0x1b198, 0x1d8ce, 0x16310, 0x12108, 0x19086, 0x16308, 0x1b186, 0x16304, 0x121b0, 0x190dc, 0x163b0, 0x12198, 0x190ce, 0x16398, 0x1b1ce, 0x1638c, 0x12186, 0x16386, 0x163dc, 0x163ce, 0x1b0a0, 0x1d858, 0x1ec2e, 0x1b090, 0x1d84c, 0x1b088, 0x1d846, 0x1b084, 0x1b082, 0x120a0, 0x19058, 0x1c82e, 0x161a0, 0x12090, 0x1904c, 0x16190, 0x1b0cc, 0x19046, 0x16188, 0x12084, 0x16184, 0x12082, 0x120d8, 0x161d8, 0x161cc, 0x161c6, 0x1d82c, 0x1d826, 0x1b042, 0x1902c, 0x12048, 0x160c8, 0x160c4, 0x160c2, 0x18ac0, 0x1c570, 0x1e2bc, 0x18a60, 0x1c538, 0x11440, 0x18a30, 0x1c51c, 0x11420, 0x18a18, 0x11410, 0x11408, 0x116c0, 0x18b70, 0x1c5bc, 0x11660, 0x18b38, 0x1c59e, 0x11630, 0x18b1c, 0x11618, 0x1160c, 0x11770, 0x18bbc, 0x11738, 0x18b9e, 0x1171c, 0x117bc, 0x1179e, 0x1cd60, 0x1e6b8, 0x1f35e, 0x19a40, 0x1cd30, 0x1e69c, 0x19a20, 0x1cd18, 0x1e68e, 0x19a10, 0x1cd0c, 0x19a08, 0x1cd06, 0x18960, 0x1c4b8, 0x1e25e, 0x19b60, 0x18930, 0x1c49c, 0x13640, 0x11220, 0x1cd9c, 0x1c48e, 0x13620, 0x19b18, 0x1890c, 0x13610, 0x11208, 0x13608, 0x11360, 0x189b8, 0x1c4de, 0x13760, 0x11330, 0x1cdde, 0x13730, 0x19b9c, 0x1898e, 0x13718, 0x1130c, 0x1370c, 0x113b8, 0x189de, 0x137b8, 0x1139c, 0x1379c, 0x1138e, 0x113de, 0x137de, 0x1dd40, 0x1eeb0, 0x1f75c, 0x1dd20, 0x1ee98, 0x1f74e, 0x1dd10, 0x1ee8c, 0x1dd08, 0x1ee86, 0x1dd04, 0x19940, 0x1ccb0, 0x1e65c, 0x1bb40, 0x19920, 0x1eedc, 0x1e64e, 0x1bb20, 0x1dd98, 0x1eece, 0x1bb10, 0x19908, 0x1cc86, 0x1bb08, 0x1dd86, 0x19902, 0x11140, 0x188b0, 0x1c45c, 0x13340, 0x11120, 0x18898, 0x1c44e, 0x17740, 0x13320, 0x19998, 0x1ccce, 0x17720, 0x1bb98, 0x1ddce, 0x18886, 0x17710, 0x13308, 0x19986, 0x17708, 0x11102, 0x111b0, 0x188dc, 0x133b0, 0x11198, 0x188ce, 0x177b0, 0x13398, 0x199ce, 0x17798, 0x1bbce, 0x11186, 0x13386, 0x111dc, 0x133dc, 0x111ce, 0x177dc, 0x133ce, 0x1dca0, 0x1ee58, 0x1f72e, 0x1dc90, 0x1ee4c, 0x1dc88, 0x1ee46, 0x1dc84, 0x1dc82, 0x198a0, 0x1cc58, 0x1e62e, 0x1b9a0, 0x19890, 0x1ee6e, 0x1b990, 0x1dccc, 0x1cc46, 0x1b988, 0x19884, 0x1b984, 0x19882, 0x1b982, 0x110a0, 0x18858, 0x1c42e, 0x131a0, 0x11090, 0x1884c, 0x173a0, 0x13190, 0x198cc, 0x18846, 0x17390, 0x1b9cc, 0x11084, 0x17388, 0x13184, 0x11082, 0x13182, 0x110d8, 0x1886e, 0x131d8, 0x110cc, 0x173d8, 0x131cc, 0x110c6, 0x173cc, 0x131c6, 0x110ee, 0x173ee, 0x1dc50, 0x1ee2c, 0x1dc48, 0x1ee26, 0x1dc44, 0x1dc42, 0x19850, 0x1cc2c, 0x1b8d0, 0x19848, 0x1cc26, 0x1b8c8, 0x1dc66, 0x1b8c4, 0x19842, 0x1b8c2, 0x11050, 0x1882c, 0x130d0, 0x11048, 0x18826, 0x171d0, 0x130c8, 0x19866, 0x171c8, 0x1b8e6, 0x11042, 0x171c4, 0x130c2, 0x171c2, 0x130ec, 0x171ec, 0x171e6, 0x1ee16, 0x1dc22, 0x1cc16, 0x19824, 0x19822, 0x11028, 0x13068, 0x170e8, 0x11022, 0x13062, 0x18560, 0x10a40, 0x18530, 0x10a20, 0x18518, 0x1c28e, 0x10a10, 0x1850c, 0x10a08, 0x18506, 0x10b60, 0x185b8, 0x1c2de, 0x10b30, 0x1859c, 0x10b18, 0x1858e, 0x10b0c, 0x10b06, 0x10bb8, 0x185de, 0x10b9c, 0x10b8e, 0x10bde, 0x18d40, 0x1c6b0, 0x1e35c, 0x18d20, 0x1c698, 0x18d10, 0x1c68c, 0x18d08, 0x1c686, 0x18d04, 0x10940, 0x184b0, 0x1c25c, 0x11b40, 0x10920, 0x1c6dc, 0x1c24e, 0x11b20, 0x18d98, 0x1c6ce, 0x11b10, 0x10908, 0x18486, 0x11b08, 0x18d86, 0x10902, 0x109b0, 0x184dc, 0x11bb0, 0x10998, 0x184ce, 0x11b98, 0x18dce, 0x11b8c, 0x10986, 0x109dc, 0x11bdc, 0x109ce, 0x11bce, 0x1cea0, 0x1e758, 0x1f3ae, 0x1ce90, 0x1e74c, 0x1ce88, 0x1e746, 0x1ce84, 0x1ce82, 0x18ca0, 0x1c658, 0x19da0, 0x18c90, 0x1c64c, 0x19d90, 0x1cecc, 0x1c646, 0x19d88, 0x18c84, 0x19d84, 0x18c82, 0x19d82, 0x108a0, 0x18458, 0x119a0, 0x10890, 0x1c66e, 0x13ba0, 0x11990, 0x18ccc, 0x18446, 0x13b90, 0x19dcc, 0x10884, 0x13b88, 0x11984, 0x10882, 0x11982, 0x108d8, 0x1846e, 0x119d8, 0x108cc, 0x13bd8, 0x119cc, 0x108c6, 0x13bcc, 0x119c6, 0x108ee, 0x119ee, 0x13bee, 0x1ef50, 0x1f7ac, 0x1ef48, 0x1f7a6, 0x1ef44, 0x1ef42, 0x1ce50, 0x1e72c, 0x1ded0, 0x1ef6c, 0x1e726, 0x1dec8, 0x1ef66, 0x1dec4, 0x1ce42, 0x1dec2, 0x18c50, 0x1c62c, 0x19cd0, 0x18c48, 0x1c626, 0x1bdd0, 0x19cc8, 0x1ce66, 0x1bdc8, 0x1dee6, 0x18c42, 0x1bdc4, 0x19cc2, 0x1bdc2, 0x10850, 0x1842c, 0x118d0, 0x10848, 0x18426, 0x139d0, 0x118c8, 0x18c66, 0x17bd0, 0x139c8, 0x19ce6, 0x10842, 0x17bc8, 0x1bde6, 0x118c2, 0x17bc4, 0x1086c, 0x118ec, 0x10866, 0x139ec, 0x118e6, 0x17bec, 0x139e6, 0x17be6, 0x1ef28, 0x1f796, 0x1ef24, 0x1ef22, 0x1ce28, 0x1e716, 0x1de68, 0x1ef36, 0x1de64, 0x1ce22, 0x1de62, 0x18c28, 0x1c616, 0x19c68, 0x18c24, 0x1bce8, 0x19c64, 0x18c22, 0x1bce4, 0x19c62, 0x1bce2, 0x10828, 0x18416, 0x11868, 0x18c36, 0x138e8, 0x11864, 0x10822, 0x179e8, 0x138e4, 0x11862, 0x179e4, 0x138e2, 0x179e2, 0x11876, 0x179f6, 0x1ef12, 0x1de34, 0x1de32, 0x19c34, 0x1bc74, 0x1bc72, 0x11834, 0x13874, 0x178f4, 0x178f2, 0x10540, 0x10520, 0x18298, 0x10510, 0x10508, 0x10504, 0x105b0, 0x10598, 0x1058c, 0x10586, 0x105dc, 0x105ce, 0x186a0, 0x18690, 0x1c34c, 0x18688, 0x1c346, 0x18684, 0x18682, 0x104a0, 0x18258, 0x10da0, 0x186d8, 0x1824c, 0x10d90, 0x186cc, 0x10d88, 0x186c6, 0x10d84, 0x10482, 0x10d82, 0x104d8, 0x1826e, 0x10dd8, 0x186ee, 0x10dcc, 0x104c6, 0x10dc6, 0x104ee, 0x10dee, 0x1c750, 0x1c748, 0x1c744, 0x1c742, 0x18650, 0x18ed0, 0x1c76c, 0x1c326, 0x18ec8, 0x1c766, 0x18ec4, 0x18642, 0x18ec2, 0x10450, 0x10cd0, 0x10448, 0x18226, 0x11dd0, 0x10cc8, 0x10444, 0x11dc8, 0x10cc4, 0x10442, 0x11dc4, 0x10cc2, 0x1046c, 0x10cec, 0x10466, 0x11dec, 0x10ce6, 0x11de6, 0x1e7a8, 0x1e7a4, 0x1e7a2, 0x1c728, 0x1cf68, 0x1e7b6, 0x1cf64, 0x1c722, 0x1cf62, 0x18628, 0x1c316, 0x18e68, 0x1c736, 0x19ee8, 0x18e64, 0x18622, 0x19ee4, 0x18e62, 0x19ee2, 0x10428, 0x18216, 0x10c68, 0x18636, 0x11ce8, 0x10c64, 0x10422, 0x13de8, 0x11ce4, 0x10c62, 0x13de4, 0x11ce2, 0x10436, 0x10c76, 0x11cf6, 0x13df6, 0x1f7d4, 0x1f7d2, 0x1e794, 0x1efb4, 0x1e792, 0x1efb2, 0x1c714, 0x1cf34, 0x1c712, 0x1df74, 0x1cf32, 0x1df72, 0x18614, 0x18e34, 0x18612, 0x19e74, 0x18e32, 0x1bef4, ] -, vec![0x1f560, 0x1fab8, 0x1ea40, 0x1f530, 0x1fa9c, 0x1ea20, 0x1f518, 0x1fa8e, 0x1ea10, 0x1f50c, 0x1ea08, 0x1f506, 0x1ea04, 0x1eb60, 0x1f5b8, 0x1fade, 0x1d640, 0x1eb30, 0x1f59c, 0x1d620, 0x1eb18, 0x1f58e, 0x1d610, 0x1eb0c, 0x1d608, 0x1eb06, 0x1d604, 0x1d760, 0x1ebb8, 0x1f5de, 0x1ae40, 0x1d730, 0x1eb9c, 0x1ae20, 0x1d718, 0x1eb8e, 0x1ae10, 0x1d70c, 0x1ae08, 0x1d706, 0x1ae04, 0x1af60, 0x1d7b8, 0x1ebde, 0x15e40, 0x1af30, 0x1d79c, 0x15e20, 0x1af18, 0x1d78e, 0x15e10, 0x1af0c, 0x15e08, 0x1af06, 0x15f60, 0x1afb8, 0x1d7de, 0x15f30, 0x1af9c, 0x15f18, 0x1af8e, 0x15f0c, 0x15fb8, 0x1afde, 0x15f9c, 0x15f8e, 0x1e940, 0x1f4b0, 0x1fa5c, 0x1e920, 0x1f498, 0x1fa4e, 0x1e910, 0x1f48c, 0x1e908, 0x1f486, 0x1e904, 0x1e902, 0x1d340, 0x1e9b0, 0x1f4dc, 0x1d320, 0x1e998, 0x1f4ce, 0x1d310, 0x1e98c, 0x1d308, 0x1e986, 0x1d304, 0x1d302, 0x1a740, 0x1d3b0, 0x1e9dc, 0x1a720, 0x1d398, 0x1e9ce, 0x1a710, 0x1d38c, 0x1a708, 0x1d386, 0x1a704, 0x1a702, 0x14f40, 0x1a7b0, 0x1d3dc, 0x14f20, 0x1a798, 0x1d3ce, 0x14f10, 0x1a78c, 0x14f08, 0x1a786, 0x14f04, 0x14fb0, 0x1a7dc, 0x14f98, 0x1a7ce, 0x14f8c, 0x14f86, 0x14fdc, 0x14fce, 0x1e8a0, 0x1f458, 0x1fa2e, 0x1e890, 0x1f44c, 0x1e888, 0x1f446, 0x1e884, 0x1e882, 0x1d1a0, 0x1e8d8, 0x1f46e, 0x1d190, 0x1e8cc, 0x1d188, 0x1e8c6, 0x1d184, 0x1d182, 0x1a3a0, 0x1d1d8, 0x1e8ee, 0x1a390, 0x1d1cc, 0x1a388, 0x1d1c6, 0x1a384, 0x1a382, 0x147a0, 0x1a3d8, 0x1d1ee, 0x14790, 0x1a3cc, 0x14788, 0x1a3c6, 0x14784, 0x14782, 0x147d8, 0x1a3ee, 0x147cc, 0x147c6, 0x147ee, 0x1e850, 0x1f42c, 0x1e848, 0x1f426, 0x1e844, 0x1e842, 0x1d0d0, 0x1e86c, 0x1d0c8, 0x1e866, 0x1d0c4, 0x1d0c2, 0x1a1d0, 0x1d0ec, 0x1a1c8, 0x1d0e6, 0x1a1c4, 0x1a1c2, 0x143d0, 0x1a1ec, 0x143c8, 0x1a1e6, 0x143c4, 0x143c2, 0x143ec, 0x143e6, 0x1e828, 0x1f416, 0x1e824, 0x1e822, 0x1d068, 0x1e836, 0x1d064, 0x1d062, 0x1a0e8, 0x1d076, 0x1a0e4, 0x1a0e2, 0x141e8, 0x1a0f6, 0x141e4, 0x141e2, 0x1e814, 0x1e812, 0x1d034, 0x1d032, 0x1a074, 0x1a072, 0x1e540, 0x1f2b0, 0x1f95c, 0x1e520, 0x1f298, 0x1f94e, 0x1e510, 0x1f28c, 0x1e508, 0x1f286, 0x1e504, 0x1e502, 0x1cb40, 0x1e5b0, 0x1f2dc, 0x1cb20, 0x1e598, 0x1f2ce, 0x1cb10, 0x1e58c, 0x1cb08, 0x1e586, 0x1cb04, 0x1cb02, 0x19740, 0x1cbb0, 0x1e5dc, 0x19720, 0x1cb98, 0x1e5ce, 0x19710, 0x1cb8c, 0x19708, 0x1cb86, 0x19704, 0x19702, 0x12f40, 0x197b0, 0x1cbdc, 0x12f20, 0x19798, 0x1cbce, 0x12f10, 0x1978c, 0x12f08, 0x19786, 0x12f04, 0x12fb0, 0x197dc, 0x12f98, 0x197ce, 0x12f8c, 0x12f86, 0x12fdc, 0x12fce, 0x1f6a0, 0x1fb58, 0x16bf0, 0x1f690, 0x1fb4c, 0x169f8, 0x1f688, 0x1fb46, 0x168fc, 0x1f684, 0x1f682, 0x1e4a0, 0x1f258, 0x1f92e, 0x1eda0, 0x1e490, 0x1fb6e, 0x1ed90, 0x1f6cc, 0x1f246, 0x1ed88, 0x1e484, 0x1ed84, 0x1e482, 0x1ed82, 0x1c9a0, 0x1e4d8, 0x1f26e, 0x1dba0, 0x1c990, 0x1e4cc, 0x1db90, 0x1edcc, 0x1e4c6, 0x1db88, 0x1c984, 0x1db84, 0x1c982, 0x1db82, 0x193a0, 0x1c9d8, 0x1e4ee, 0x1b7a0, 0x19390, 0x1c9cc, 0x1b790, 0x1dbcc, 0x1c9c6, 0x1b788, 0x19384, 0x1b784, 0x19382, 0x1b782, 0x127a0, 0x193d8, 0x1c9ee, 0x16fa0, 0x12790, 0x193cc, 0x16f90, 0x1b7cc, 0x193c6, 0x16f88, 0x12784, 0x16f84, 0x12782, 0x127d8, 0x193ee, 0x16fd8, 0x127cc, 0x16fcc, 0x127c6, 0x16fc6, 0x127ee, 0x1f650, 0x1fb2c, 0x165f8, 0x1f648, 0x1fb26, 0x164fc, 0x1f644, 0x1647e, 0x1f642, 0x1e450, 0x1f22c, 0x1ecd0, 0x1e448, 0x1f226, 0x1ecc8, 0x1f666, 0x1ecc4, 0x1e442, 0x1ecc2, 0x1c8d0, 0x1e46c, 0x1d9d0, 0x1c8c8, 0x1e466, 0x1d9c8, 0x1ece6, 0x1d9c4, 0x1c8c2, 0x1d9c2, 0x191d0, 0x1c8ec, 0x1b3d0, 0x191c8, 0x1c8e6, 0x1b3c8, 0x1d9e6, 0x1b3c4, 0x191c2, 0x1b3c2, 0x123d0, 0x191ec, 0x167d0, 0x123c8, 0x191e6, 0x167c8, 0x1b3e6, 0x167c4, 0x123c2, 0x167c2, 0x123ec, 0x167ec, 0x123e6, 0x167e6, 0x1f628, 0x1fb16, 0x162fc, 0x1f624, 0x1627e, 0x1f622, 0x1e428, 0x1f216, 0x1ec68, 0x1f636, 0x1ec64, 0x1e422, 0x1ec62, 0x1c868, 0x1e436, 0x1d8e8, 0x1c864, 0x1d8e4, 0x1c862, 0x1d8e2, 0x190e8, 0x1c876, 0x1b1e8, 0x1d8f6, 0x1b1e4, 0x190e2, 0x1b1e2, 0x121e8, 0x190f6, 0x163e8, 0x121e4, 0x163e4, 0x121e2, 0x163e2, 0x121f6, 0x163f6, 0x1f614, 0x1617e, 0x1f612, 0x1e414, 0x1ec34, 0x1e412, 0x1ec32, 0x1c834, 0x1d874, 0x1c832, 0x1d872, 0x19074, 0x1b0f4, 0x19072, 0x1b0f2, 0x120f4, 0x161f4, 0x120f2, 0x161f2, 0x1f60a, 0x1e40a, 0x1ec1a, 0x1c81a, 0x1d83a, 0x1903a, 0x1b07a, 0x1e2a0, 0x1f158, 0x1f8ae, 0x1e290, 0x1f14c, 0x1e288, 0x1f146, 0x1e284, 0x1e282, 0x1c5a0, 0x1e2d8, 0x1f16e, 0x1c590, 0x1e2cc, 0x1c588, 0x1e2c6, 0x1c584, 0x1c582, 0x18ba0, 0x1c5d8, 0x1e2ee, 0x18b90, 0x1c5cc, 0x18b88, 0x1c5c6, 0x18b84, 0x18b82, 0x117a0, 0x18bd8, 0x1c5ee, 0x11790, 0x18bcc, 0x11788, 0x18bc6, 0x11784, 0x11782, 0x117d8, 0x18bee, 0x117cc, 0x117c6, 0x117ee, 0x1f350, 0x1f9ac, 0x135f8, 0x1f348, 0x1f9a6, 0x134fc, 0x1f344, 0x1347e, 0x1f342, 0x1e250, 0x1f12c, 0x1e6d0, 0x1e248, 0x1f126, 0x1e6c8, 0x1f366, 0x1e6c4, 0x1e242, 0x1e6c2, 0x1c4d0, 0x1e26c, 0x1cdd0, 0x1c4c8, 0x1e266, 0x1cdc8, 0x1e6e6, 0x1cdc4, 0x1c4c2, 0x1cdc2, 0x189d0, 0x1c4ec, 0x19bd0, 0x189c8, 0x1c4e6, 0x19bc8, 0x1cde6, 0x19bc4, 0x189c2, 0x19bc2, 0x113d0, 0x189ec, 0x137d0, 0x113c8, 0x189e6, 0x137c8, 0x19be6, 0x137c4, 0x113c2, 0x137c2, 0x113ec, 0x137ec, 0x113e6, 0x137e6, 0x1fba8, 0x175f0, 0x1bafc, 0x1fba4, 0x174f8, 0x1ba7e, 0x1fba2, 0x1747c, 0x1743e, 0x1f328, 0x1f996, 0x132fc, 0x1f768, 0x1fbb6, 0x176fc, 0x1327e, 0x1f764, 0x1f322, 0x1767e, 0x1f762, 0x1e228, 0x1f116, 0x1e668, 0x1e224, 0x1eee8, 0x1f776, 0x1e222, 0x1eee4, 0x1e662, 0x1eee2, 0x1c468, 0x1e236, 0x1cce8, 0x1c464, 0x1dde8, 0x1cce4, 0x1c462, 0x1dde4, 0x1cce2, 0x1dde2, 0x188e8, 0x1c476, 0x199e8, 0x188e4, 0x1bbe8, 0x199e4, 0x188e2, 0x1bbe4, 0x199e2, 0x1bbe2, 0x111e8, 0x188f6, 0x133e8, 0x111e4, 0x177e8, 0x133e4, 0x111e2, 0x177e4, 0x133e2, 0x177e2, 0x111f6, 0x133f6, 0x1fb94, 0x172f8, 0x1b97e, 0x1fb92, 0x1727c, 0x1723e, 0x1f314, 0x1317e, 0x1f734, 0x1f312, 0x1737e, 0x1f732, 0x1e214, 0x1e634, 0x1e212, 0x1ee74, 0x1e632, 0x1ee72, 0x1c434, 0x1cc74, 0x1c432, 0x1dcf4, 0x1cc72, 0x1dcf2, 0x18874, 0x198f4, 0x18872, 0x1b9f4, 0x198f2, 0x1b9f2, 0x110f4, 0x131f4, 0x110f2, 0x173f4, 0x131f2, 0x173f2, 0x1fb8a, 0x1717c, 0x1713e, 0x1f30a, 0x1f71a, 0x1e20a, 0x1e61a, 0x1ee3a, 0x1c41a, 0x1cc3a, 0x1dc7a, 0x1883a, 0x1987a, 0x1b8fa, 0x1107a, 0x130fa, 0x171fa, 0x170be, 0x1e150, 0x1f0ac, 0x1e148, 0x1f0a6, 0x1e144, 0x1e142, 0x1c2d0, 0x1e16c, 0x1c2c8, 0x1e166, 0x1c2c4, 0x1c2c2, 0x185d0, 0x1c2ec, 0x185c8, 0x1c2e6, 0x185c4, 0x185c2, 0x10bd0, 0x185ec, 0x10bc8, 0x185e6, 0x10bc4, 0x10bc2, 0x10bec, 0x10be6, 0x1f1a8, 0x1f8d6, 0x11afc, 0x1f1a4, 0x11a7e, 0x1f1a2, 0x1e128, 0x1f096, 0x1e368, 0x1e124, 0x1e364, 0x1e122, 0x1e362, 0x1c268, 0x1e136, 0x1c6e8, 0x1c264, 0x1c6e4, 0x1c262, 0x1c6e2, 0x184e8, 0x1c276, 0x18de8, 0x184e4, 0x18de4, 0x184e2, 0x18de2, 0x109e8, 0x184f6, 0x11be8, 0x109e4, 0x11be4, 0x109e2, 0x11be2, 0x109f6, 0x11bf6, 0x1f9d4, 0x13af8, 0x19d7e, 0x1f9d2, 0x13a7c, 0x13a3e, 0x1f194, 0x1197e, 0x1f3b4, 0x1f192, 0x13b7e, 0x1f3b2, 0x1e114, 0x1e334, 0x1e112, 0x1e774, 0x1e332, 0x1e772, 0x1c234, 0x1c674, 0x1c232, 0x1cef4, 0x1c672, 0x1cef2, 0x18474, 0x18cf4, 0x18472, 0x19df4, 0x18cf2, 0x19df2, 0x108f4, 0x119f4, 0x108f2, 0x13bf4, 0x119f2, 0x13bf2, 0x17af0, 0x1bd7c, 0x17a78, 0x1bd3e, 0x17a3c, 0x17a1e, 0x1f9ca, 0x1397c, 0x1fbda, 0x17b7c, 0x1393e, 0x17b3e, 0x1f18a, 0x1f39a, 0x1f7ba, 0x1e10a, 0x1e31a, 0x1e73a, 0x1ef7a, 0x1c21a, 0x1c63a, 0x1ce7a, 0x1defa, 0x1843a, 0x18c7a, 0x19cfa, 0x1bdfa, 0x1087a, 0x118fa, 0x139fa, 0x17978, 0x1bcbe, 0x1793c, 0x1791e, 0x138be, 0x179be, 0x178bc, 0x1789e, 0x1785e, 0x1e0a8, 0x1e0a4, 0x1e0a2, 0x1c168, 0x1e0b6, 0x1c164, 0x1c162, 0x182e8, 0x1c176, 0x182e4, 0x182e2, 0x105e8, 0x182f6, 0x105e4, 0x105e2, 0x105f6, 0x1f0d4, 0x10d7e, 0x1f0d2, 0x1e094, 0x1e1b4, 0x1e092, 0x1e1b2, 0x1c134, 0x1c374, 0x1c132, 0x1c372, 0x18274, 0x186f4, 0x18272, 0x186f2, 0x104f4, 0x10df4, 0x104f2, 0x10df2, 0x1f8ea, 0x11d7c, 0x11d3e, 0x1f0ca, 0x1f1da, 0x1e08a, 0x1e19a, 0x1e3ba, 0x1c11a, 0x1c33a, 0x1c77a, 0x1823a, 0x1867a, 0x18efa, 0x1047a, 0x10cfa, 0x11dfa, 0x13d78, 0x19ebe, 0x13d3c, 0x13d1e, 0x11cbe, 0x13dbe, 0x17d70, 0x1bebc, 0x17d38, 0x1be9e, 0x17d1c, 0x17d0e, 0x13cbc, 0x17dbc, 0x13c9e, 0x17d9e, 0x17cb8, 0x1be5e, 0x17c9c, 0x17c8e, 0x13c5e, 0x17cde, 0x17c5c, 0x17c4e, 0x17c2e, 0x1c0b4, 0x1c0b2, 0x18174, 0x18172, 0x102f4, 0x102f2, 0x1e0da, 0x1c09a, 0x1c1ba, 0x1813a, 0x1837a, 0x1027a, 0x106fa, 0x10ebe, 0x11ebc, 0x11e9e, 0x13eb8, 0x19f5e, 0x13e9c, 0x13e8e, 0x11e5e, 0x13ede, 0x17eb0, 0x1bf5c, 0x17e98, 0x1bf4e, 0x17e8c, 0x17e86, 0x13e5c, 0x17edc, 0x13e4e, 0x17ece, 0x17e58, 0x1bf2e, 0x17e4c, 0x17e46, 0x13e2e, 0x17e6e, 0x17e2c, 0x17e26, 0x10f5e, 0x11f5c, 0x11f4e, 0x13f58, 0x19fae, 0x13f4c, 0x13f46, 0x11f2e, 0x13f6e, 0x13f2c, 0x13f26, ] -, vec![0x1abe0, 0x1d5f8, 0x153c0, 0x1a9f0, 0x1d4fc, 0x151e0, 0x1a8f8, 0x1d47e, 0x150f0, 0x1a87c, 0x15078, 0x1fad0, 0x15be0, 0x1adf8, 0x1fac8, 0x159f0, 0x1acfc, 0x1fac4, 0x158f8, 0x1ac7e, 0x1fac2, 0x1587c, 0x1f5d0, 0x1faec, 0x15df8, 0x1f5c8, 0x1fae6, 0x15cfc, 0x1f5c4, 0x15c7e, 0x1f5c2, 0x1ebd0, 0x1f5ec, 0x1ebc8, 0x1f5e6, 0x1ebc4, 0x1ebc2, 0x1d7d0, 0x1ebec, 0x1d7c8, 0x1ebe6, 0x1d7c4, 0x1d7c2, 0x1afd0, 0x1d7ec, 0x1afc8, 0x1d7e6, 0x1afc4, 0x14bc0, 0x1a5f0, 0x1d2fc, 0x149e0, 0x1a4f8, 0x1d27e, 0x148f0, 0x1a47c, 0x14878, 0x1a43e, 0x1483c, 0x1fa68, 0x14df0, 0x1a6fc, 0x1fa64, 0x14cf8, 0x1a67e, 0x1fa62, 0x14c7c, 0x14c3e, 0x1f4e8, 0x1fa76, 0x14efc, 0x1f4e4, 0x14e7e, 0x1f4e2, 0x1e9e8, 0x1f4f6, 0x1e9e4, 0x1e9e2, 0x1d3e8, 0x1e9f6, 0x1d3e4, 0x1d3e2, 0x1a7e8, 0x1d3f6, 0x1a7e4, 0x1a7e2, 0x145e0, 0x1a2f8, 0x1d17e, 0x144f0, 0x1a27c, 0x14478, 0x1a23e, 0x1443c, 0x1441e, 0x1fa34, 0x146f8, 0x1a37e, 0x1fa32, 0x1467c, 0x1463e, 0x1f474, 0x1477e, 0x1f472, 0x1e8f4, 0x1e8f2, 0x1d1f4, 0x1d1f2, 0x1a3f4, 0x1a3f2, 0x142f0, 0x1a17c, 0x14278, 0x1a13e, 0x1423c, 0x1421e, 0x1fa1a, 0x1437c, 0x1433e, 0x1f43a, 0x1e87a, 0x1d0fa, 0x14178, 0x1a0be, 0x1413c, 0x1411e, 0x141be, 0x140bc, 0x1409e, 0x12bc0, 0x195f0, 0x1cafc, 0x129e0, 0x194f8, 0x1ca7e, 0x128f0, 0x1947c, 0x12878, 0x1943e, 0x1283c, 0x1f968, 0x12df0, 0x196fc, 0x1f964, 0x12cf8, 0x1967e, 0x1f962, 0x12c7c, 0x12c3e, 0x1f2e8, 0x1f976, 0x12efc, 0x1f2e4, 0x12e7e, 0x1f2e2, 0x1e5e8, 0x1f2f6, 0x1e5e4, 0x1e5e2, 0x1cbe8, 0x1e5f6, 0x1cbe4, 0x1cbe2, 0x197e8, 0x1cbf6, 0x197e4, 0x197e2, 0x1b5e0, 0x1daf8, 0x1ed7e, 0x169c0, 0x1b4f0, 0x1da7c, 0x168e0, 0x1b478, 0x1da3e, 0x16870, 0x1b43c, 0x16838, 0x1b41e, 0x1681c, 0x125e0, 0x192f8, 0x1c97e, 0x16de0, 0x124f0, 0x1927c, 0x16cf0, 0x1b67c, 0x1923e, 0x16c78, 0x1243c, 0x16c3c, 0x1241e, 0x16c1e, 0x1f934, 0x126f8, 0x1937e, 0x1fb74, 0x1f932, 0x16ef8, 0x1267c, 0x1fb72, 0x16e7c, 0x1263e, 0x16e3e, 0x1f274, 0x1277e, 0x1f6f4, 0x1f272, 0x16f7e, 0x1f6f2, 0x1e4f4, 0x1edf4, 0x1e4f2, 0x1edf2, 0x1c9f4, 0x1dbf4, 0x1c9f2, 0x1dbf2, 0x193f4, 0x193f2, 0x165c0, 0x1b2f0, 0x1d97c, 0x164e0, 0x1b278, 0x1d93e, 0x16470, 0x1b23c, 0x16438, 0x1b21e, 0x1641c, 0x1640e, 0x122f0, 0x1917c, 0x166f0, 0x12278, 0x1913e, 0x16678, 0x1b33e, 0x1663c, 0x1221e, 0x1661e, 0x1f91a, 0x1237c, 0x1fb3a, 0x1677c, 0x1233e, 0x1673e, 0x1f23a, 0x1f67a, 0x1e47a, 0x1ecfa, 0x1c8fa, 0x1d9fa, 0x191fa, 0x162e0, 0x1b178, 0x1d8be, 0x16270, 0x1b13c, 0x16238, 0x1b11e, 0x1621c, 0x1620e, 0x12178, 0x190be, 0x16378, 0x1213c, 0x1633c, 0x1211e, 0x1631e, 0x121be, 0x163be, 0x16170, 0x1b0bc, 0x16138, 0x1b09e, 0x1611c, 0x1610e, 0x120bc, 0x161bc, 0x1209e, 0x1619e, 0x160b8, 0x1b05e, 0x1609c, 0x1608e, 0x1205e, 0x160de, 0x1605c, 0x1604e, 0x115e0, 0x18af8, 0x1c57e, 0x114f0, 0x18a7c, 0x11478, 0x18a3e, 0x1143c, 0x1141e, 0x1f8b4, 0x116f8, 0x18b7e, 0x1f8b2, 0x1167c, 0x1163e, 0x1f174, 0x1177e, 0x1f172, 0x1e2f4, 0x1e2f2, 0x1c5f4, 0x1c5f2, 0x18bf4, 0x18bf2, 0x135c0, 0x19af0, 0x1cd7c, 0x134e0, 0x19a78, 0x1cd3e, 0x13470, 0x19a3c, 0x13438, 0x19a1e, 0x1341c, 0x1340e, 0x112f0, 0x1897c, 0x136f0, 0x11278, 0x1893e, 0x13678, 0x19b3e, 0x1363c, 0x1121e, 0x1361e, 0x1f89a, 0x1137c, 0x1f9ba, 0x1377c, 0x1133e, 0x1373e, 0x1f13a, 0x1f37a, 0x1e27a, 0x1e6fa, 0x1c4fa, 0x1cdfa, 0x189fa, 0x1bae0, 0x1dd78, 0x1eebe, 0x174c0, 0x1ba70, 0x1dd3c, 0x17460, 0x1ba38, 0x1dd1e, 0x17430, 0x1ba1c, 0x17418, 0x1ba0e, 0x1740c, 0x132e0, 0x19978, 0x1ccbe, 0x176e0, 0x13270, 0x1993c, 0x17670, 0x1bb3c, 0x1991e, 0x17638, 0x1321c, 0x1761c, 0x1320e, 0x1760e, 0x11178, 0x188be, 0x13378, 0x1113c, 0x17778, 0x1333c, 0x1111e, 0x1773c, 0x1331e, 0x1771e, 0x111be, 0x133be, 0x177be, 0x172c0, 0x1b970, 0x1dcbc, 0x17260, 0x1b938, 0x1dc9e, 0x17230, 0x1b91c, 0x17218, 0x1b90e, 0x1720c, 0x17206, 0x13170, 0x198bc, 0x17370, 0x13138, 0x1989e, 0x17338, 0x1b99e, 0x1731c, 0x1310e, 0x1730e, 0x110bc, 0x131bc, 0x1109e, 0x173bc, 0x1319e, 0x1739e, 0x17160, 0x1b8b8, 0x1dc5e, 0x17130, 0x1b89c, 0x17118, 0x1b88e, 0x1710c, 0x17106, 0x130b8, 0x1985e, 0x171b8, 0x1309c, 0x1719c, 0x1308e, 0x1718e, 0x1105e, 0x130de, 0x171de, 0x170b0, 0x1b85c, 0x17098, 0x1b84e, 0x1708c, 0x17086, 0x1305c, 0x170dc, 0x1304e, 0x170ce, 0x17058, 0x1b82e, 0x1704c, 0x17046, 0x1302e, 0x1706e, 0x1702c, 0x17026, 0x10af0, 0x1857c, 0x10a78, 0x1853e, 0x10a3c, 0x10a1e, 0x10b7c, 0x10b3e, 0x1f0ba, 0x1e17a, 0x1c2fa, 0x185fa, 0x11ae0, 0x18d78, 0x1c6be, 0x11a70, 0x18d3c, 0x11a38, 0x18d1e, 0x11a1c, 0x11a0e, 0x10978, 0x184be, 0x11b78, 0x1093c, 0x11b3c, 0x1091e, 0x11b1e, 0x109be, 0x11bbe, 0x13ac0, 0x19d70, 0x1cebc, 0x13a60, 0x19d38, 0x1ce9e, 0x13a30, 0x19d1c, 0x13a18, 0x19d0e, 0x13a0c, 0x13a06, 0x11970, 0x18cbc, 0x13b70, 0x11938, 0x18c9e, 0x13b38, 0x1191c, 0x13b1c, 0x1190e, 0x13b0e, 0x108bc, 0x119bc, 0x1089e, 0x13bbc, 0x1199e, 0x13b9e, 0x1bd60, 0x1deb8, 0x1ef5e, 0x17a40, 0x1bd30, 0x1de9c, 0x17a20, 0x1bd18, 0x1de8e, 0x17a10, 0x1bd0c, 0x17a08, 0x1bd06, 0x17a04, 0x13960, 0x19cb8, 0x1ce5e, 0x17b60, 0x13930, 0x19c9c, 0x17b30, 0x1bd9c, 0x19c8e, 0x17b18, 0x1390c, 0x17b0c, 0x13906, 0x17b06, 0x118b8, 0x18c5e, 0x139b8, 0x1189c, 0x17bb8, 0x1399c, 0x1188e, 0x17b9c, 0x1398e, 0x17b8e, 0x1085e, 0x118de, 0x139de, 0x17bde, 0x17940, 0x1bcb0, 0x1de5c, 0x17920, 0x1bc98, 0x1de4e, 0x17910, 0x1bc8c, 0x17908, 0x1bc86, 0x17904, 0x17902, 0x138b0, 0x19c5c, 0x179b0, 0x13898, 0x19c4e, 0x17998, 0x1bcce, 0x1798c, 0x13886, 0x17986, 0x1185c, 0x138dc, 0x1184e, 0x179dc, 0x138ce, 0x179ce, 0x178a0, 0x1bc58, 0x1de2e, 0x17890, 0x1bc4c, 0x17888, 0x1bc46, 0x17884, 0x17882, 0x13858, 0x19c2e, 0x178d8, 0x1384c, 0x178cc, 0x13846, 0x178c6, 0x1182e, 0x1386e, 0x178ee, 0x17850, 0x1bc2c, 0x17848, 0x1bc26, 0x17844, 0x17842, 0x1382c, 0x1786c, 0x13826, 0x17866, 0x17828, 0x1bc16, 0x17824, 0x17822, 0x13816, 0x17836, 0x10578, 0x182be, 0x1053c, 0x1051e, 0x105be, 0x10d70, 0x186bc, 0x10d38, 0x1869e, 0x10d1c, 0x10d0e, 0x104bc, 0x10dbc, 0x1049e, 0x10d9e, 0x11d60, 0x18eb8, 0x1c75e, 0x11d30, 0x18e9c, 0x11d18, 0x18e8e, 0x11d0c, 0x11d06, 0x10cb8, 0x1865e, 0x11db8, 0x10c9c, 0x11d9c, 0x10c8e, 0x11d8e, 0x1045e, 0x10cde, 0x11dde, 0x13d40, 0x19eb0, 0x1cf5c, 0x13d20, 0x19e98, 0x1cf4e, 0x13d10, 0x19e8c, 0x13d08, 0x19e86, 0x13d04, 0x13d02, 0x11cb0, 0x18e5c, 0x13db0, 0x11c98, 0x18e4e, 0x13d98, 0x19ece, 0x13d8c, 0x11c86, 0x13d86, 0x10c5c, 0x11cdc, 0x10c4e, 0x13ddc, 0x11cce, 0x13dce, 0x1bea0, 0x1df58, 0x1efae, 0x1be90, 0x1df4c, 0x1be88, 0x1df46, 0x1be84, 0x1be82, 0x13ca0, 0x19e58, 0x1cf2e, 0x17da0, 0x13c90, 0x19e4c, 0x17d90, 0x1becc, 0x19e46, 0x17d88, 0x13c84, 0x17d84, 0x13c82, 0x17d82, 0x11c58, 0x18e2e, 0x13cd8, 0x11c4c, 0x17dd8, 0x13ccc, 0x11c46, 0x17dcc, 0x13cc6, 0x17dc6, 0x10c2e, 0x11c6e, 0x13cee, 0x17dee, 0x1be50, 0x1df2c, 0x1be48, 0x1df26, 0x1be44, 0x1be42, 0x13c50, 0x19e2c, 0x17cd0, 0x13c48, 0x19e26, 0x17cc8, 0x1be66, 0x17cc4, 0x13c42, 0x17cc2, 0x11c2c, 0x13c6c, 0x11c26, 0x17cec, 0x13c66, 0x17ce6, 0x1be28, 0x1df16, 0x1be24, 0x1be22, 0x13c28, 0x19e16, 0x17c68, 0x13c24, 0x17c64, 0x13c22, 0x17c62, 0x11c16, 0x13c36, 0x17c76, 0x1be14, 0x1be12, 0x13c14, 0x17c34, 0x13c12, 0x17c32, 0x102bc, 0x1029e, 0x106b8, 0x1835e, 0x1069c, 0x1068e, 0x1025e, 0x106de, 0x10eb0, 0x1875c, 0x10e98, 0x1874e, 0x10e8c, 0x10e86, 0x1065c, 0x10edc, 0x1064e, 0x10ece, 0x11ea0, 0x18f58, 0x1c7ae, 0x11e90, 0x18f4c, 0x11e88, 0x18f46, 0x11e84, 0x11e82, 0x10e58, 0x1872e, 0x11ed8, 0x18f6e, 0x11ecc, 0x10e46, 0x11ec6, 0x1062e, 0x10e6e, 0x11eee, 0x19f50, 0x1cfac, 0x19f48, 0x1cfa6, 0x19f44, 0x19f42, 0x11e50, 0x18f2c, 0x13ed0, 0x19f6c, 0x18f26, 0x13ec8, 0x11e44, 0x13ec4, 0x11e42, 0x13ec2, 0x10e2c, 0x11e6c, 0x10e26, 0x13eec, 0x11e66, 0x13ee6, 0x1dfa8, 0x1efd6, 0x1dfa4, 0x1dfa2, 0x19f28, 0x1cf96, 0x1bf68, 0x19f24, 0x1bf64, 0x19f22, 0x1bf62, 0x11e28, 0x18f16, 0x13e68, 0x11e24, 0x17ee8, 0x13e64, 0x11e22, 0x17ee4, 0x13e62, 0x17ee2, 0x10e16, 0x11e36, 0x13e76, 0x17ef6, 0x1df94, 0x1df92, 0x19f14, 0x1bf34, 0x19f12, 0x1bf32, 0x11e14, 0x13e34, 0x11e12, 0x17e74, 0x13e32, 0x17e72, 0x1df8a, 0x19f0a, 0x1bf1a, 0x11e0a, 0x13e1a, 0x17e3a, 0x1035c, 0x1034e, 0x10758, 0x183ae, 0x1074c, 0x10746, 0x1032e, 0x1076e, 0x10f50, 0x187ac, 0x10f48, 0x187a6, 0x10f44, 0x10f42, 0x1072c, 0x10f6c, 0x10726, 0x10f66, 0x18fa8, 0x1c7d6, 0x18fa4, 0x18fa2, 0x10f28, 0x18796, 0x11f68, 0x18fb6, 0x11f64, 0x10f22, 0x11f62, 0x10716, 0x10f36, 0x11f76, 0x1cfd4, 0x1cfd2, 0x18f94, 0x19fb4, 0x18f92, 0x19fb2, 0x10f14, 0x11f34, 0x10f12, 0x13f74, 0x11f32, 0x13f72, 0x1cfca, 0x18f8a, 0x19f9a, 0x10f0a, 0x11f1a, 0x13f3a, 0x103ac, 0x103a6, 0x107a8, 0x183d6, 0x107a4, 0x107a2, 0x10396, 0x107b6, 0x187d4, 0x187d2, 0x10794, 0x10fb4, 0x10792, 0x10fb2, 0x1c7ea, ] -, ] -; - - const PREFERRED_RATIO: f32 = 3.0f; - -//1px in mm - const DEFAULT_MODULE_WIDTH: f32 = 0.357f; - -//mm - const HEIGHT: f32 = 2.0f; -pub struct PDF417 { - - let barcode_matrix: BarcodeMatrix; - - let compact: bool; - - let mut compaction: Compaction; - - let mut encoding: Charset; - - let min_cols: i32; - - let max_cols: i32; - - let max_rows: i32; - - let min_rows: i32; -} - -impl PDF417 { - - pub fn new() -> PDF417 { - this(false); - } - - pub fn new( compact: bool) -> PDF417 { - let .compact = compact; - compaction = Compaction::AUTO; - // Use default - encoding = null; - min_cols = 2; - max_cols = 30; - max_rows = 30; - min_rows = 2; - } - - pub fn get_barcode_matrix(&self) -> BarcodeMatrix { - return self.barcode_matrix; - } - - /** - * Calculates the necessary number of rows as described in annex Q of ISO/IEC 15438:2001(E). - * - * @param m the number of source codewords prior to the additional of the Symbol Length - * Descriptor and any pad codewords - * @param k the number of error correction codewords - * @param c the number of columns in the symbol in the data region (excluding start, stop and - * row indicator codewords) - * @return the number of rows in the symbol (r) - */ - fn calculate_number_of_rows( m: i32, k: i32, c: i32) -> i32 { - let mut r: i32 = ((m + 1 + k) / c) + 1; - if c * r >= (m + 1 + k + c) { - r -= 1; - } - return r; - } - - /** - * Calculates the number of pad codewords as described in 4.9.2 of ISO/IEC 15438:2001(E). - * - * @param m the number of source codewords prior to the additional of the Symbol Length - * Descriptor and any pad codewords - * @param k the number of error correction codewords - * @param c the number of columns in the symbol in the data region (excluding start, stop and - * row indicator codewords) - * @param r the number of rows in the symbol - * @return the number of pad codewords - */ - fn get_number_of_pad_codewords( m: i32, k: i32, c: i32, r: i32) -> i32 { - let n: i32 = c * r - k; - return if n > m + 1 { n - m - 1 } else { 0 }; - } - - fn encode_char( pattern: i32, len: i32, logic: &BarcodeRow) { - let mut map: i32 = 1 << len - 1; - //Initialize to inverse of first bit - let mut last: bool = (pattern & map) != 0; - let mut width: i32 = 0; - { - let mut i: i32 = 0; - while i < len { - { - let black: bool = (pattern & map) != 0; - if last == black { - width += 1; - } else { - logic.add_bar(last, width); - last = black; - width = 1; - } - map >>= 1; - } - i += 1; - } - } - - logic.add_bar(last, width); - } - - fn encode_low_level(&self, full_codewords: &CharSequence, c: i32, r: i32, error_correction_level: i32, logic: &BarcodeMatrix) { - let mut idx: i32 = 0; - { - let mut y: i32 = 0; - while y < r { - { - let cluster: i32 = y % 3; - logic.start_row(); - ::encode_char(START_PATTERN, 17, &logic.get_current_row()); - let mut left: i32; - let mut right: i32; - if cluster == 0 { - left = (30 * (y / 3)) + ((r - 1) / 3); - right = (30 * (y / 3)) + (c - 1); - } else if cluster == 1 { - left = (30 * (y / 3)) + (error_correction_level * 3) + ((r - 1) % 3); - right = (30 * (y / 3)) + ((r - 1) / 3); - } else { - left = (30 * (y / 3)) + (c - 1); - right = (30 * (y / 3)) + (error_correction_level * 3) + ((r - 1) % 3); - } - let mut pattern: i32 = CODEWORD_TABLE[cluster][left]; - ::encode_char(pattern, 17, &logic.get_current_row()); - { - let mut x: i32 = 0; - while x < c { - { - pattern = CODEWORD_TABLE[cluster][full_codewords.char_at(idx)]; - ::encode_char(pattern, 17, &logic.get_current_row()); - idx += 1; - } - x += 1; - } - } - - if self.compact { - // encodes stop line for compact pdf417 - ::encode_char(STOP_PATTERN, 1, &logic.get_current_row()); - } else { - pattern = CODEWORD_TABLE[cluster][right]; - ::encode_char(pattern, 17, &logic.get_current_row()); - ::encode_char(STOP_PATTERN, 18, &logic.get_current_row()); - } - } - y += 1; - } - } - - } - - /** - * @param msg message to encode - * @param errorCorrectionLevel PDF417 error correction level to use - * @throws WriterException if the contents cannot be encoded in this format - */ - pub fn generate_barcode_logic(&self, msg: &String, error_correction_level: i32) -> /* throws WriterException */Result> { - self.generate_barcode_logic(&msg, error_correction_level, false); - } - - /** - * @param msg message to encode - * @param errorCorrectionLevel PDF417 error correction level to use - * @param autoECI automatically insert ECIs if needed - * @throws WriterException if the contents cannot be encoded in this format - */ - pub fn generate_barcode_logic(&self, msg: &String, error_correction_level: i32, auto_e_c_i: bool) -> /* throws WriterException */Result> { - //1. step: High-level encoding - let error_correction_code_words: i32 = PDF417ErrorCorrection::get_error_correction_codeword_count(error_correction_level); - let high_level: String = PDF417HighLevelEncoder::encode_high_level(&msg, self.compaction, &self.encoding, auto_e_c_i); - let source_code_words: i32 = high_level.length(); - let dimension: Vec = self.determine_dimensions(source_code_words, error_correction_code_words); - let cols: i32 = dimension[0]; - let rows: i32 = dimension[1]; - let pad: i32 = ::get_number_of_pad_codewords(source_code_words, error_correction_code_words, cols, rows); - //2. step: construct data codewords - if source_code_words + error_correction_code_words + 1 > 929 { - // +1 for symbol length CW - throw WriterException::new(format!("Encoded message contains too many code words, message too big ({} bytes)", msg.length())); - } - let n: i32 = source_code_words + pad + 1; - let sb: StringBuilder = StringBuilder::new(n); - sb.append(n as char); - sb.append(&high_level); - { - let mut i: i32 = 0; - while i < pad { - { - //PAD characters - sb.append(900 as char); - } - i += 1; - } - } - - let data_codewords: String = sb.to_string(); - //3. step: Error correction - let ec: String = PDF417ErrorCorrection::generate_error_correction(&data_codewords, error_correction_level); - //4. step: low-level encoding - self.barcode_matrix = BarcodeMatrix::new(rows, cols); - self.encode_low_level(format!("{}{}", data_codewords, ec), cols, rows, error_correction_level, self.barcode_matrix); - } - - /** - * Determine optimal nr of columns and rows for the specified number of - * codewords. - * - * @param sourceCodeWords number of code words - * @param errorCorrectionCodeWords number of error correction code words - * @return dimension object containing cols as width and rows as height - */ - fn determine_dimensions(&self, source_code_words: i32, error_correction_code_words: i32) -> /* throws WriterException */Result, Rc> { - let mut ratio: f32 = 0.0f; - let mut dimension: Vec = null; - { - let mut cols: i32 = self.min_cols; - while cols <= self.max_cols { - { - let rows: i32 = ::calculate_number_of_rows(source_code_words, error_correction_code_words, cols); - if rows < self.min_rows { - break; - } - if rows > self.max_rows { - continue; - } - let new_ratio: f32 = ((17.0 * cols + 69.0) as f32 * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT); - // ignore if previous ratio is closer to preferred ratio - if dimension != null && Math::abs(new_ratio - PREFERRED_RATIO) > Math::abs(ratio - PREFERRED_RATIO) { - continue; - } - ratio = new_ratio; - dimension = : vec![i32; 2] = vec![cols, rows, ] - ; - } - cols += 1; - } - } - - // Handle case when min values were larger than necessary - if dimension == null { - let rows: i32 = ::calculate_number_of_rows(source_code_words, error_correction_code_words, self.min_cols); - if rows < self.min_rows { - dimension = : vec![i32; 2] = vec![self.min_cols, self.min_rows, ] - ; - } - } - if dimension == null { - throw WriterException::new("Unable to fit message in columns"); - } - return Ok(dimension); - } - - /** - * Sets max/min row/col values - * - * @param maxCols maximum allowed columns - * @param minCols minimum allowed columns - * @param maxRows maximum allowed rows - * @param minRows minimum allowed rows - */ - pub fn set_dimensions(&self, max_cols: i32, min_cols: i32, max_rows: i32, min_rows: i32) { - self.maxCols = max_cols; - self.minCols = min_cols; - self.maxRows = max_rows; - self.minRows = min_rows; - } - - /** - * @param compaction compaction mode to use - */ - pub fn set_compaction(&self, compaction: &Compaction) { - self.compaction = compaction; - } - - /** - * @param compact if true, enables compaction - */ - pub fn set_compact(&self, compact: bool) { - self.compact = compact; - } - - /** - * @param encoding sets character encoding to use - */ - pub fn set_encoding(&self, encoding: &Charset) { - self.encoding = encoding; - } -} - -// NEW FILE: p_d_f417_error_correction.rs -/* - * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::encoder; - -/** - * PDF417 error correction code following the algorithm described in ISO/IEC 15438:2001(E) in - * chapter 4.10. - */ - -/** - * Tables of coefficients for calculating error correction words - * (see annex F, ISO/IEC 15438:2001(E)) - */ - const EC_COEFFICIENTS: vec![vec![Vec>; 512]; 9] = vec![vec![27, 917, ] -, vec![522, 568, 723, 809, ] -, vec![237, 308, 436, 284, 646, 653, 428, 379, ] -, vec![274, 562, 232, 755, 599, 524, 801, 132, 295, 116, 442, 428, 295, 42, 176, 65, ] -, vec![361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677, 742, 687, 284, 193, 517, 273, 494, 263, 147, 593, 800, 571, 320, 803, 133, 231, 390, 685, 330, 63, 410, ] -, vec![539, 422, 6, 93, 862, 771, 453, 106, 610, 287, 107, 505, 733, 877, 381, 612, 723, 476, 462, 172, 430, 609, 858, 822, 543, 376, 511, 400, 672, 762, 283, 184, 440, 35, 519, 31, 460, 594, 225, 535, 517, 352, 605, 158, 651, 201, 488, 502, 648, 733, 717, 83, 404, 97, 280, 771, 840, 629, 4, 381, 843, 623, 264, 543, ] -, vec![521, 310, 864, 547, 858, 580, 296, 379, 53, 779, 897, 444, 400, 925, 749, 415, 822, 93, 217, 208, 928, 244, 583, 620, 246, 148, 447, 631, 292, 908, 490, 704, 516, 258, 457, 907, 594, 723, 674, 292, 272, 96, 684, 432, 686, 606, 860, 569, 193, 219, 129, 186, 236, 287, 192, 775, 278, 173, 40, 379, 712, 463, 646, 776, 171, 491, 297, 763, 156, 732, 95, 270, 447, 90, 507, 48, 228, 821, 808, 898, 784, 663, 627, 378, 382, 262, 380, 602, 754, 336, 89, 614, 87, 432, 670, 616, 157, 374, 242, 726, 600, 269, 375, 898, 845, 454, 354, 130, 814, 587, 804, 34, 211, 330, 539, 297, 827, 865, 37, 517, 834, 315, 550, 86, 801, 4, 108, 539, ] -, vec![524, 894, 75, 766, 882, 857, 74, 204, 82, 586, 708, 250, 905, 786, 138, 720, 858, 194, 311, 913, 275, 190, 375, 850, 438, 733, 194, 280, 201, 280, 828, 757, 710, 814, 919, 89, 68, 569, 11, 204, 796, 605, 540, 913, 801, 700, 799, 137, 439, 418, 592, 668, 353, 859, 370, 694, 325, 240, 216, 257, 284, 549, 209, 884, 315, 70, 329, 793, 490, 274, 877, 162, 749, 812, 684, 461, 334, 376, 849, 521, 307, 291, 803, 712, 19, 358, 399, 908, 103, 511, 51, 8, 517, 225, 289, 470, 637, 731, 66, 255, 917, 269, 463, 830, 730, 433, 848, 585, 136, 538, 906, 90, 2, 290, 743, 199, 655, 903, 329, 49, 802, 580, 355, 588, 188, 462, 10, 134, 628, 320, 479, 130, 739, 71, 263, 318, 374, 601, 192, 605, 142, 673, 687, 234, 722, 384, 177, 752, 607, 640, 455, 193, 689, 707, 805, 641, 48, 60, 732, 621, 895, 544, 261, 852, 655, 309, 697, 755, 756, 60, 231, 773, 434, 421, 726, 528, 503, 118, 49, 795, 32, 144, 500, 238, 836, 394, 280, 566, 319, 9, 647, 550, 73, 914, 342, 126, 32, 681, 331, 792, 620, 60, 609, 441, 180, 791, 893, 754, 605, 383, 228, 749, 760, 213, 54, 297, 134, 54, 834, 299, 922, 191, 910, 532, 609, 829, 189, 20, 167, 29, 872, 449, 83, 402, 41, 656, 505, 579, 481, 173, 404, 251, 688, 95, 497, 555, 642, 543, 307, 159, 924, 558, 648, 55, 497, 10, ] -, vec![352, 77, 373, 504, 35, 599, 428, 207, 409, 574, 118, 498, 285, 380, 350, 492, 197, 265, 920, 155, 914, 299, 229, 643, 294, 871, 306, 88, 87, 193, 352, 781, 846, 75, 327, 520, 435, 543, 203, 666, 249, 346, 781, 621, 640, 268, 794, 534, 539, 781, 408, 390, 644, 102, 476, 499, 290, 632, 545, 37, 858, 916, 552, 41, 542, 289, 122, 272, 383, 800, 485, 98, 752, 472, 761, 107, 784, 860, 658, 741, 290, 204, 681, 407, 855, 85, 99, 62, 482, 180, 20, 297, 451, 593, 913, 142, 808, 684, 287, 536, 561, 76, 653, 899, 729, 567, 744, 390, 513, 192, 516, 258, 240, 518, 794, 395, 768, 848, 51, 610, 384, 168, 190, 826, 328, 596, 786, 303, 570, 381, 415, 641, 156, 237, 151, 429, 531, 207, 676, 710, 89, 168, 304, 402, 40, 708, 575, 162, 864, 229, 65, 861, 841, 512, 164, 477, 221, 92, 358, 785, 288, 357, 850, 836, 827, 736, 707, 94, 8, 494, 114, 521, 2, 499, 851, 543, 152, 729, 771, 95, 248, 361, 578, 323, 856, 797, 289, 51, 684, 466, 533, 820, 669, 45, 902, 452, 167, 342, 244, 173, 35, 463, 651, 51, 699, 591, 452, 578, 37, 124, 298, 332, 552, 43, 427, 119, 662, 777, 475, 850, 764, 364, 578, 911, 283, 711, 472, 420, 245, 288, 594, 394, 511, 327, 589, 777, 699, 688, 43, 408, 842, 383, 721, 521, 560, 644, 714, 559, 62, 145, 873, 663, 713, 159, 672, 729, 624, 59, 193, 417, 158, 209, 563, 564, 343, 693, 109, 608, 563, 365, 181, 772, 677, 310, 248, 353, 708, 410, 579, 870, 617, 841, 632, 860, 289, 536, 35, 777, 618, 586, 424, 833, 77, 597, 346, 269, 757, 632, 695, 751, 331, 247, 184, 45, 787, 680, 18, 66, 407, 369, 54, 492, 228, 613, 830, 922, 437, 519, 644, 905, 789, 420, 305, 441, 207, 300, 892, 827, 141, 537, 381, 662, 513, 56, 252, 341, 242, 797, 838, 837, 720, 224, 307, 631, 61, 87, 560, 310, 756, 665, 397, 808, 851, 309, 473, 795, 378, 31, 647, 915, 459, 806, 590, 731, 425, 216, 548, 249, 321, 881, 699, 535, 673, 782, 210, 815, 905, 303, 843, 922, 281, 73, 469, 791, 660, 162, 498, 308, 155, 422, 907, 817, 187, 62, 16, 425, 535, 336, 286, 437, 375, 273, 610, 296, 183, 923, 116, 667, 751, 353, 62, 366, 691, 379, 687, 842, 37, 357, 720, 742, 330, 5, 39, 923, 311, 424, 242, 749, 321, 54, 669, 316, 342, 299, 534, 105, 667, 488, 640, 672, 576, 540, 316, 486, 721, 610, 46, 656, 447, 171, 616, 464, 190, 531, 297, 321, 762, 752, 533, 175, 134, 14, 381, 433, 717, 45, 111, 20, 596, 284, 736, 138, 646, 411, 877, 669, 141, 919, 45, 780, 407, 164, 332, 899, 165, 726, 600, 325, 498, 655, 357, 752, 768, 223, 849, 647, 63, 310, 863, 251, 366, 304, 282, 738, 675, 410, 389, 244, 31, 121, 303, 263, ] -, ] -; -struct PDF417ErrorCorrection { -} - -impl PDF417ErrorCorrection { - - fn new() -> PDF417ErrorCorrection { - } - - /** - * Determines the number of error correction codewords for a specified error correction - * level. - * - * @param errorCorrectionLevel the error correction level (0-8) - * @return the number of codewords generated for error correction - */ - fn get_error_correction_codeword_count( error_correction_level: i32) -> i32 { - if error_correction_level < 0 || error_correction_level > 8 { - throw IllegalArgumentException::new("Error correction level must be between 0 and 8!"); - } - return 1 << (error_correction_level + 1); - } - - /** - * Returns the recommended minimum error correction level as described in annex E of - * ISO/IEC 15438:2001(E). - * - * @param n the number of data codewords - * @return the recommended minimum error correction level - */ - fn get_recommended_minimum_error_correction_level( n: i32) -> /* throws WriterException */Result> { - if n <= 0 { - throw IllegalArgumentException::new("n must be > 0"); - } - if n <= 40 { - return Ok(2); - } - if n <= 160 { - return Ok(3); - } - if n <= 320 { - return Ok(4); - } - if n <= 863 { - return Ok(5); - } - throw WriterException::new("No recommendation possible"); - } - - /** - * Generates the error correction codewords according to 4.10 in ISO/IEC 15438:2001(E). - * - * @param dataCodewords the data codewords - * @param errorCorrectionLevel the error correction level (0-8) - * @return the String representing the error correction codewords - */ - fn generate_error_correction( data_codewords: &CharSequence, error_correction_level: i32) -> String { - let k: i32 = ::get_error_correction_codeword_count(error_correction_level); - let mut e: [Option; k] = [None; k]; - let sld: i32 = data_codewords.length(); - { - let mut i: i32 = 0; - while i < sld { - { - let t1: i32 = (data_codewords.char_at(i) + e[e.len() - 1]) % 929; - let mut t2: i32; - let mut t3: i32; - { - let mut j: i32 = k - 1; - while j >= 1 { - { - t2 = (t1 * EC_COEFFICIENTS[error_correction_level][j]) % 929; - t3 = 929 - t2; - e[j] = ((e[j - 1] + t3) % 929) as char; - } - j -= 1; - } - } - - t2 = (t1 * EC_COEFFICIENTS[error_correction_level][0]) % 929; - t3 = 929 - t2; - e[0] = (t3 % 929) as char; - } - i += 1; - } - } - - let sb: StringBuilder = StringBuilder::new(k); - { - let mut j: i32 = k - 1; - while j >= 0 { - { - if e[j] != 0 { - e[j] = (929 - e[j]) as char; - } - sb.append(e[j]); - } - j -= 1; - } - } - - return sb.to_string(); - } -} - -// NEW FILE: p_d_f417_high_level_encoder.rs -/* - * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::encoder; - -/** - * PDF417 high-level encoder following the algorithm described in ISO/IEC 15438:2001(E) in - * annex P. - */ - -/** - * code for Text compaction - */ - const TEXT_COMPACTION: i32 = 0; - -/** - * code for Byte compaction - */ - const BYTE_COMPACTION: i32 = 1; - -/** - * code for Numeric compaction - */ - const NUMERIC_COMPACTION: i32 = 2; - -/** - * Text compaction submode Alpha - */ - const SUBMODE_ALPHA: i32 = 0; - -/** - * Text compaction submode Lower - */ - const SUBMODE_LOWER: i32 = 1; - -/** - * Text compaction submode Mixed - */ - const SUBMODE_MIXED: i32 = 2; - -/** - * Text compaction submode Punctuation - */ - const SUBMODE_PUNCTUATION: i32 = 3; - -/** - * mode latch to Text Compaction mode - */ - const LATCH_TO_TEXT: i32 = 900; - -/** - * mode latch to Byte Compaction mode (number of characters NOT a multiple of 6) - */ - const LATCH_TO_BYTE_PADDED: i32 = 901; - -/** - * mode latch to Numeric Compaction mode - */ - const LATCH_TO_NUMERIC: i32 = 902; - -/** - * mode shift to Byte Compaction mode - */ - const SHIFT_TO_BYTE: i32 = 913; - -/** - * mode latch to Byte Compaction mode (number of characters a multiple of 6) - */ - const LATCH_TO_BYTE: i32 = 924; - -/** - * identifier for a user defined Extended Channel Interpretation (ECI) - */ - const ECI_USER_DEFINED: i32 = 925; - -/** - * identifier for a general purpose ECO format - */ - const ECI_GENERAL_PURPOSE: i32 = 926; - -/** - * identifier for an ECI of a character set of code page - */ - const ECI_CHARSET: i32 = 927; - -/** - * Raw code table for text compaction Mixed sub-mode - */ - const TEXT_MIXED_RAW: vec![Vec; 30] = vec![48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 38, 13, 9, 44, 58, 35, 45, 46, 36, 47, 43, 37, 42, 61, 94, 0, 32, 0, 0, 0, ] -; - -/** - * Raw code table for text compaction: Punctuation sub-mode - */ - const TEXT_PUNCTUATION_RAW: vec![Vec; 30] = vec![59, 60, 62, 64, 91, 92, 93, 95, 96, 126, 33, 13, 9, 44, 58, 10, 45, 46, 36, 47, 34, 124, 42, 40, 41, 63, 123, 125, 39, 0, ] -; - - const MIXED: [i8; 128] = [0; 128]; - - const PUNCTUATION: [i8; 128] = [0; 128]; - - const DEFAULT_ENCODING: Charset = StandardCharsets::ISO_8859_1; -struct PDF417HighLevelEncoder { -} - -impl PDF417HighLevelEncoder { - - fn new() -> PDF417HighLevelEncoder { - } - - static { - //Construct inverse lookups - Arrays::fill(&MIXED, -1 as i8); - { - let mut i: i32 = 0; - while i < TEXT_MIXED_RAW.len() { - { - let mut b: i8 = TEXT_MIXED_RAW[i]; - if b > 0 { - MIXED[b] = i as i8; - } - } - i += 1; - } - } - - Arrays::fill(&PUNCTUATION, -1 as i8); - { - let mut i: i32 = 0; - while i < TEXT_PUNCTUATION_RAW.len() { - { - let mut b: i8 = TEXT_PUNCTUATION_RAW[i]; - if b > 0 { - PUNCTUATION[b] = i as i8; - } - } - i += 1; - } - } - - } - - /** - * Performs high-level encoding of a PDF417 message using the algorithm described in annex P - * of ISO/IEC 15438:2001(E). If byte compaction has been selected, then only byte compaction - * is used. - * - * @param msg the message - * @param compaction compaction mode to use - * @param encoding character encoding used to encode in default or byte compaction - * or {@code null} for default / not applicable - * @param autoECI encode input minimally using multiple ECIs if needed - * If autoECI encoding is specified and additionally {@code encoding} is specified, then the encoder - * will use the specified {@link Charset} for any character that can be encoded by it, regardless - * if a different encoding would lead to a more compact encoding. When no {@code encoding} is specified - * then charsets will be chosen so that the byte representation is minimal. - * @return the encoded message (the char values range from 0 to 928) - */ - fn encode_high_level( msg: &String, compaction: &Compaction, encoding: &Charset, auto_e_c_i: bool) -> /* throws WriterException */Result> { - if msg.is_empty() { - throw WriterException::new("Empty message not allowed"); - } - if encoding == null && !auto_e_c_i { - { - let mut i: i32 = 0; - while i < msg.length() { - { - if msg.char_at(i) > 255 { - throw WriterException::new(format!("Non-encodable character detected: {} (Unicode: {}). Consider specifying EncodeHintType.PDF417_AUTO_ECI and/or EncodeTypeHint.CHARACTER_SET.", msg.char_at(i), msg.char_at(i) as i32)); - } - } - i += 1; - } - } - - } - //the codewords 0..928 are encoded as Unicode characters - let sb: StringBuilder = StringBuilder::new(&msg.length()); - let mut input: ECIInput; - if auto_e_c_i { - input = MinimalECIInput::new(&msg, &encoding, -1); - } else { - input = NoECIInput::new(&msg); - if encoding == null { - encoding = DEFAULT_ENCODING; - } else if !DEFAULT_ENCODING::equals(&encoding) { - let eci: CharacterSetECI = CharacterSetECI::get_character_set_e_c_i(&encoding); - if eci != null { - ::encoding_e_c_i(&eci.get_value(), &sb); - } - } - } - let len: i32 = input.length(); - let mut p: i32 = 0; - let text_sub_mode: i32 = SUBMODE_ALPHA; - // User selected encoding mode - match compaction { - TEXT => - { - ::encode_text(input, p, len, &sb, text_sub_mode); - break; - } - BYTE => - { - if auto_e_c_i { - ::encode_multi_e_c_i_binary(input, 0, &input.length(), TEXT_COMPACTION, &sb); - } else { - let msg_bytes: Vec = input.to_string().get_bytes(&encoding); - ::encode_binary(&msg_bytes, p, msg_bytes.len(), BYTE_COMPACTION, &sb); - } - break; - } - NUMERIC => - { - sb.append(LATCH_TO_NUMERIC as char); - ::encode_numeric(input, p, len, &sb); - break; - } - _ => - { - //Default mode, see 4.4.2.1 - let encoding_mode: i32 = TEXT_COMPACTION; - while p < len { - while p < len && input.is_e_c_i(p) { - ::encoding_e_c_i(&input.get_e_c_i_value(p), &sb); - p += 1; - } - if p >= len { - break; - } - let n: i32 = ::determine_consecutive_digit_count(input, p); - if n >= 13 { - sb.append(LATCH_TO_NUMERIC as char); - encoding_mode = NUMERIC_COMPACTION; - //Reset after latch - text_sub_mode = SUBMODE_ALPHA; - ::encode_numeric(input, p, n, &sb); - p += n; - } else { - let t: i32 = ::determine_consecutive_text_count(input, p); - if t >= 5 || n == len { - if encoding_mode != TEXT_COMPACTION { - sb.append(LATCH_TO_TEXT as char); - encoding_mode = TEXT_COMPACTION; - //start with submode alpha after latch - text_sub_mode = SUBMODE_ALPHA; - } - text_sub_mode = ::encode_text(input, p, t, &sb, text_sub_mode); - p += t; - } else { - let mut b: i32 = ::determine_consecutive_binary_count(input, p, if auto_e_c_i { null } else { encoding }); - if b == 0 { - b = 1; - } - let bytes: Vec = if auto_e_c_i { null } else { input.sub_sequence(p, p + b).to_string().get_bytes(&encoding) }; - if ((bytes == null && b == 1) || (bytes != null && bytes.len() == 1)) && encoding_mode == TEXT_COMPACTION { - //Switch for one byte (instead of latch) - if auto_e_c_i { - ::encode_multi_e_c_i_binary(input, p, 1, TEXT_COMPACTION, &sb); - } else { - ::encode_binary(&bytes, 0, 1, TEXT_COMPACTION, &sb); - } - } else { - //Mode latch performed by encodeBinary() - if auto_e_c_i { - ::encode_multi_e_c_i_binary(input, p, p + b, encoding_mode, &sb); - } else { - ::encode_binary(&bytes, 0, bytes.len(), encoding_mode, &sb); - } - encoding_mode = BYTE_COMPACTION; - //Reset after latch - text_sub_mode = SUBMODE_ALPHA; - } - p += b; - } - } - } - break; - } - } - return Ok(sb.to_string()); - } - - /** - * Encode parts of the message using Text Compaction as described in ISO/IEC 15438:2001(E), - * chapter 4.4.2. - * - * @param input the input - * @param startpos the start position within the message - * @param count the number of characters to encode - * @param sb receives the encoded codewords - * @param initialSubmode should normally be SUBMODE_ALPHA - * @return the text submode in which this method ends - */ - fn encode_text( input: &ECIInput, startpos: i32, count: i32, sb: &StringBuilder, initial_submode: i32) -> /* throws WriterException */Result> { - let tmp: StringBuilder = StringBuilder::new(count); - let mut submode: i32 = initial_submode; - let mut idx: i32 = 0; - while true { - if input.is_e_c_i(startpos + idx) { - ::encoding_e_c_i(&input.get_e_c_i_value(startpos + idx), &sb); - idx += 1; - } else { - let ch: char = input.char_at(startpos + idx); - match submode { - SUBMODE_ALPHA => - { - if ::is_alpha_upper(ch) { - if ch == ' ' { - //space - tmp.append(26 as char); - } else { - tmp.append((ch - 65) as char); - } - } else { - if ::is_alpha_lower(ch) { - submode = SUBMODE_LOWER; - //ll - tmp.append(27 as char); - continue; - } else if ::is_mixed(ch) { - submode = SUBMODE_MIXED; - //ml - tmp.append(28 as char); - continue; - } else { - //ps - tmp.append(29 as char); - tmp.append(PUNCTUATION[ch] as char); - break; - } - } - break; - } - SUBMODE_LOWER => - { - if ::is_alpha_lower(ch) { - if ch == ' ' { - //space - tmp.append(26 as char); - } else { - tmp.append((ch - 97) as char); - } - } else { - if ::is_alpha_upper(ch) { - //as - tmp.append(27 as char); - tmp.append((ch - 65) as char); - //space cannot happen here, it is also in "Lower" - break; - } else if ::is_mixed(ch) { - submode = SUBMODE_MIXED; - //ml - tmp.append(28 as char); - continue; - } else { - //ps - tmp.append(29 as char); - tmp.append(PUNCTUATION[ch] as char); - break; - } - } - break; - } - SUBMODE_MIXED => - { - if ::is_mixed(ch) { - tmp.append(MIXED[ch] as char); - } else { - if ::is_alpha_upper(ch) { - submode = SUBMODE_ALPHA; - //al - tmp.append(28 as char); - continue; - } else if ::is_alpha_lower(ch) { - submode = SUBMODE_LOWER; - //ll - tmp.append(27 as char); - continue; - } else { - if startpos + idx + 1 < count { - if !input.is_e_c_i(startpos + idx + 1) && ::is_punctuation(&input.char_at(startpos + idx + 1)) { - submode = SUBMODE_PUNCTUATION; - //pl - tmp.append(25 as char); - continue; - } - } - //ps - tmp.append(29 as char); - tmp.append(PUNCTUATION[ch] as char); - } - } - break; - } - _ => - { - //SUBMODE_PUNCTUATION - if ::is_punctuation(ch) { - tmp.append(PUNCTUATION[ch] as char); - } else { - submode = SUBMODE_ALPHA; - //al - tmp.append(29 as char); - continue; - } - } - } - idx += 1; - if idx >= count { - break; - } - } - } - let mut h: char = 0; - let len: i32 = tmp.length(); - { - let mut i: i32 = 0; - while i < len { - { - let odd: bool = (i % 2) != 0; - if odd { - h = ((h * 30) + tmp.char_at(i)) as char; - sb.append(h); - } else { - h = tmp.char_at(i); - } - } - i += 1; - } - } - - if (len % 2) != 0 { - //ps - sb.append(((h * 30) + 29) as char); - } - return Ok(submode); - } - - /** - * Encode all of the message using Byte Compaction as described in ISO/IEC 15438:2001(E) - * - * @param input the input - * @param startpos the start position within the message - * @param count the number of bytes to encode - * @param startmode the mode from which this method starts - * @param sb receives the encoded codewords - */ - fn encode_multi_e_c_i_binary( input: &ECIInput, startpos: i32, count: i32, startmode: i32, sb: &StringBuilder) -> /* throws WriterException */Result> { - let end: i32 = Math::min(startpos + count, &input.length()); - let local_start: i32 = startpos; - while true { - //encode all leading ECIs and advance localStart - while local_start < end && input.is_e_c_i(local_start) { - ::encoding_e_c_i(&input.get_e_c_i_value(local_start), &sb); - local_start += 1; - } - let local_end: i32 = local_start; - //advance end until before the next ECI - while local_end < end && !input.is_e_c_i(local_end) { - local_end += 1; - } - let local_count: i32 = local_end - local_start; - if local_count <= 0 { - //done - break; - } else { - //encode the segment - ::encode_binary(&::sub_bytes(input, local_start, local_end), 0, local_count, if local_start == startpos { startmode } else { BYTE_COMPACTION }, &sb); - local_start = local_end; - } - } - } - - fn sub_bytes( input: &ECIInput, start: i32, end: i32) -> Vec { - let count: i32 = end - start; - let mut result: [i8; count] = [0; count]; - { - let mut i: i32 = start; - while i < end { - { - result[i - start] = (input.char_at(i) & 0xff) as i8; - } - i += 1; - } - } - - return result; - } - - /** - * Encode parts of the message using Byte Compaction as described in ISO/IEC 15438:2001(E), - * chapter 4.4.3. The Unicode characters will be converted to binary using the cp437 - * codepage. - * - * @param bytes the message converted to a byte array - * @param startpos the start position within the message - * @param count the number of bytes to encode - * @param startmode the mode from which this method starts - * @param sb receives the encoded codewords - */ - fn encode_binary( bytes: &Vec, startpos: i32, count: i32, startmode: i32, sb: &StringBuilder) { - if count == 1 && startmode == TEXT_COMPACTION { - sb.append(SHIFT_TO_BYTE as char); - } else { - if (count % 6) == 0 { - sb.append(LATCH_TO_BYTE as char); - } else { - sb.append(LATCH_TO_BYTE_PADDED as char); - } - } - let mut idx: i32 = startpos; - // Encode sixpacks - if count >= 6 { - let mut chars: [Option; 5] = [None; 5]; - while (startpos + count - idx) >= 6 { - let mut t: i64 = 0; - { - let mut i: i32 = 0; - while i < 6 { - { - t <<= 8; - t += bytes[idx + i] & 0xff; - } - i += 1; - } - } - - { - let mut i: i32 = 0; - while i < 5 { - { - chars[i] = (t % 900) as char; - t /= 900; - } - i += 1; - } - } - - { - let mut i: i32 = chars.len() - 1; - while i >= 0 { - { - sb.append(chars[i]); - } - i -= 1; - } - } - - idx += 6; - } - } - //Encode rest (remaining n<5 bytes if any) - { - let mut i: i32 = idx; - while i < startpos + count { - { - let ch: i32 = bytes[i] & 0xff; - sb.append(ch as char); - } - i += 1; - } - } - - } - - fn encode_numeric( input: &ECIInput, startpos: i32, count: i32, sb: &StringBuilder) { - let mut idx: i32 = 0; - let tmp: StringBuilder = StringBuilder::new(count / 3 + 1); - let num900: BigInteger = BigInteger::value_of(900); - let num0: BigInteger = BigInteger::value_of(0); - while idx < count { - tmp.set_length(0); - let len: i32 = Math::min(44, count - idx); - let part: String = format!("1{}", input.sub_sequence(startpos + idx, startpos + idx + len)); - let mut bigint: BigInteger = BigInteger::new(&part); - loop { { - tmp.append(bigint.mod(&num900).int_value() as char); - bigint = bigint.divide(&num900); - }if !(!bigint.equals(&num0)) break;} - //Reverse temporary string - { - let mut i: i32 = tmp.length() - 1; - while i >= 0 { - { - sb.append(&tmp.char_at(i)); - } - i -= 1; - } - } - - idx += len; - } - } - - fn is_digit( ch: char) -> bool { - return ch >= '0' && ch <= '9'; - } - - fn is_alpha_upper( ch: char) -> bool { - return ch == ' ' || (ch >= 'A' && ch <= 'Z'); - } - - fn is_alpha_lower( ch: char) -> bool { - return ch == ' ' || (ch >= 'a' && ch <= 'z'); - } - - fn is_mixed( ch: char) -> bool { - return MIXED[ch] != -1; - } - - fn is_punctuation( ch: char) -> bool { - return PUNCTUATION[ch] != -1; - } - - fn is_text( ch: char) -> bool { - return ch == '\t' || ch == '\n' || ch == '\r' || (ch >= 32 && ch <= 126); - } - - /** - * Determines the number of consecutive characters that are encodable using numeric compaction. - * - * @param input the input - * @param startpos the start position within the input - * @return the requested character count - */ - fn determine_consecutive_digit_count( input: &ECIInput, startpos: i32) -> i32 { - let mut count: i32 = 0; - let len: i32 = input.length(); - let mut idx: i32 = startpos; - if idx < len { - while idx < len && !input.is_e_c_i(idx) && ::is_digit(&input.char_at(idx)) { - count += 1; - idx += 1; - } - } - return count; - } - - /** - * Determines the number of consecutive characters that are encodable using text compaction. - * - * @param input the input - * @param startpos the start position within the input - * @return the requested character count - */ - fn determine_consecutive_text_count( input: &ECIInput, startpos: i32) -> i32 { - let len: i32 = input.length(); - let mut idx: i32 = startpos; - while idx < len { - let numeric_count: i32 = 0; - while numeric_count < 13 && idx < len && !input.is_e_c_i(idx) && ::is_digit(&input.char_at(idx)) { - numeric_count += 1; - idx += 1; - } - if numeric_count >= 13 { - return idx - startpos - numeric_count; - } - if numeric_count > 0 { - //Heuristic: All text-encodable chars or digits are binary encodable - continue; - } - //Check if character is encodable - if input.is_e_c_i(idx) || !::is_text(&input.char_at(idx)) { - break; - } - idx += 1; - } - return idx - startpos; - } - - /** - * Determines the number of consecutive characters that are encodable using binary compaction. - * - * @param input the input - * @param startpos the start position within the message - * @param encoding the charset used to convert the message to a byte array - * @return the requested character count - */ - fn determine_consecutive_binary_count( input: &ECIInput, startpos: i32, encoding: &Charset) -> /* throws WriterException */Result> { - let encoder: CharsetEncoder = if encoding == null { null } else { encoding.new_encoder() }; - let len: i32 = input.length(); - let mut idx: i32 = startpos; - while idx < len { - let numeric_count: i32 = 0; - let mut i: i32 = idx; - while numeric_count < 13 && !input.is_e_c_i(i) && ::is_digit(&input.char_at(i)) { - numeric_count += 1; - //textCount++; - i = idx + numeric_count; - if i >= len { - break; - } - } - if numeric_count >= 13 { - return Ok(idx - startpos); - } - if encoder != null && !encoder.can_encode(&input.char_at(idx)) { - assert!( input instanceof NoECIInput); - let ch: char = input.char_at(idx); - throw WriterException::new(format!("Non-encodable character detected: {} (Unicode: {})", ch, ch as i32)); - } - idx += 1; - } - return Ok(idx - startpos); - } - - fn encoding_e_c_i( eci: i32, sb: &StringBuilder) -> /* throws WriterException */Result> { - if eci >= 0 && eci < 900 { - sb.append(ECI_CHARSET as char); - sb.append(eci as char); - } else if eci < 810900 { - sb.append(ECI_GENERAL_PURPOSE as char); - sb.append((eci / 900 - 1) as char); - sb.append((eci % 900) as char); - } else if eci < 811800 { - sb.append(ECI_USER_DEFINED as char); - sb.append((810900 - eci) as char); - } else { - throw WriterException::new(format!("ECI number not in valid range from 0..811799, but was {}", eci)); - } - } - - #[derive(ECIInput)] - struct NoECIInput { - - let input: String; - } - - impl NoECIInput { - - fn new( input: &String) -> NoECIInput { - let .input = input; - } - - pub fn length(&self) -> i32 { - return self.input.length(); - } - - pub fn char_at(&self, index: i32) -> char { - return self.input.char_at(index); - } - - pub fn is_e_c_i(&self, index: i32) -> bool { - return false; - } - - pub fn get_e_c_i_value(&self, index: i32) -> i32 { - return -1; - } - - pub fn have_n_characters(&self, index: i32, n: i32) -> bool { - return index + n <= self.input.length(); - } - - pub fn sub_sequence(&self, start: i32, end: i32) -> CharSequence { - return self.input.sub_sequence(start, end); - } - - pub fn to_string(&self) -> String { - return self.input; - } - } - -} - -// NEW FILE: p_d_f417_high_level_encoder_test_adapter.rs -/* - * Copyright 2022 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::pdf417::encoder; - -pub struct PDF417HighLevelEncoderTestAdapter { -} - -impl PDF417HighLevelEncoderTestAdapter { - - fn new() -> PDF417HighLevelEncoderTestAdapter { - } - - pub fn encode_high_level( msg: &String, compaction: &Compaction, encoding: &Charset, auto_e_c_i: bool) -> /* throws WriterException */Result> { - return Ok(PDF417HighLevelEncoder::encode_high_level(&msg, compaction, &encoding, auto_e_c_i)); - } -} - diff --git a/src/qrcode.rs b/src/qrcode.rs deleted file mode 100644 index c927464..0000000 --- a/src/qrcode.rs +++ /dev/null @@ -1,316 +0,0 @@ -use crate::{BarcodeFormat,BinaryBitmap,ChecksumException,DecodeHintType,FormatException,NotFoundException,Reader,XRingResult,ResultMetadataType,ResultPoint,EncodeHintType,Writer,WriterException,}; -use crate::common::{BitMatrix,DecoderResult,DetectorResult,}; -use crate::qrcode::decoder::{Decoder,QRCodeDecoderMetaData}; -use crate::qrcode::detector::{Detector}; -use crate::qrcode::encoder::{ByteMatrix,ErrorCorrectionLevel,Encoder,QRCode}; - -// NEW FILE: q_r_code_reader.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode; - -/** - * This implementation can detect and decode QR Codes in an image. - * - * @author Sean Owen - */ - - const NO_POINTS: [Option; 0] = [None; 0]; -#[derive(Reader)] -pub struct QRCodeReader { - - let decoder: Decoder = Decoder::new(); -} - -impl QRCodeReader { - - pub fn get_decoder(&self) -> Decoder { - return self.decoder; - } - - /** - * Locates and decodes a QR code in an image. - * - * @return a String representing the content encoded by the QR code - * @throws NotFoundException if a QR code cannot be found - * @throws FormatException if a QR code cannot be decoded - * @throws ChecksumException if error correction fails - */ - pub fn decode(&self, image: &BinaryBitmap) -> /* throws NotFoundException, ChecksumException, FormatException */Result> { - return Ok(self.decode(image, null)); - } - - pub fn decode(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException, ChecksumException, FormatException */Result> { - let decoder_result: DecoderResult; - let mut points: Vec; - if hints != null && hints.contains_key(DecodeHintType::PURE_BARCODE) { - let bits: BitMatrix = ::extract_pure_bits(&image.get_black_matrix()); - decoder_result = self.decoder.decode(bits, &hints); - points = NO_POINTS; - } else { - let detector_result: DetectorResult = Detector::new(&image.get_black_matrix()).detect(&hints); - decoder_result = self.decoder.decode(&detector_result.get_bits(), &hints); - points = detector_result.get_points(); - } - // If the code was mirrored: swap the bottom-left and the top-right points. - if decoder_result.get_other() instanceof QRCodeDecoderMetaData { - (decoder_result.get_other() as QRCodeDecoderMetaData).apply_mirrored_correction(points); - } - let result: Result = Result::new(&decoder_result.get_text(), &decoder_result.get_raw_bytes(), points, BarcodeFormat::QR_CODE); - let byte_segments: List> = decoder_result.get_byte_segments(); - if byte_segments != null { - result.put_metadata(ResultMetadataType::BYTE_SEGMENTS, &byte_segments); - } - let ec_level: String = decoder_result.get_e_c_level(); - if ec_level != null { - result.put_metadata(ResultMetadataType::ERROR_CORRECTION_LEVEL, &ec_level); - } - if decoder_result.has_structured_append() { - result.put_metadata(ResultMetadataType::STRUCTURED_APPEND_SEQUENCE, &decoder_result.get_structured_append_sequence_number()); - result.put_metadata(ResultMetadataType::STRUCTURED_APPEND_PARITY, &decoder_result.get_structured_append_parity()); - } - result.put_metadata(ResultMetadataType::SYMBOLOGY_IDENTIFIER, format!("]Q{}", decoder_result.get_symbology_modifier())); - return Ok(result); - } - - pub fn reset(&self) { - // do nothing - } - - /** - * This method detects a code in a "pure" image -- that is, pure monochrome image - * which contains only an unrotated, unskewed, image of a code, with some white border - * around it. This is a specialized method that works exceptionally fast in this special - * case. - */ - fn extract_pure_bits( image: &BitMatrix) -> /* throws NotFoundException */Result> { - let left_top_black: Vec = image.get_top_left_on_bit(); - let right_bottom_black: Vec = image.get_bottom_right_on_bit(); - if left_top_black == null || right_bottom_black == null { - throw NotFoundException::get_not_found_instance(); - } - let module_size: f32 = self.module_size(&left_top_black, image); - let mut top: i32 = left_top_black[1]; - let bottom: i32 = right_bottom_black[1]; - let mut left: i32 = left_top_black[0]; - let mut right: i32 = right_bottom_black[0]; - // Sanity check! - if left >= right || top >= bottom { - throw NotFoundException::get_not_found_instance(); - } - if bottom - top != right - left { - // Special case, where bottom-right module wasn't black so we found something else in the last row - // Assume it's a square, so use height as the width - right = left + (bottom - top); - if right >= image.get_width() { - // Abort if that would not make sense -- off image - throw NotFoundException::get_not_found_instance(); - } - } - let matrix_width: i32 = Math::round((right - left + 1.0) / module_size); - let matrix_height: i32 = Math::round((bottom - top + 1.0) / module_size); - if matrix_width <= 0 || matrix_height <= 0 { - throw NotFoundException::get_not_found_instance(); - } - if matrix_height != matrix_width { - // Only possibly decode square regions - throw NotFoundException::get_not_found_instance(); - } - // Push in the "border" by half the module width so that we start - // sampling in the middle of the module. Just in case the image is a - // little off, this will help recover. - let nudge: i32 = (module_size / 2.0f) as i32; - top += nudge; - left += nudge; - // But careful that this does not sample off the edge - // "right" is the farthest-right valid pixel location -- right+1 is not necessarily - // This is positive by how much the inner x loop below would be too large - let nudged_too_far_right: i32 = left + ((matrix_width - 1.0) * module_size) as i32 - right; - if nudged_too_far_right > 0 { - if nudged_too_far_right > nudge { - // Neither way fits; abort - throw NotFoundException::get_not_found_instance(); - } - left -= nudged_too_far_right; - } - // See logic above - let nudged_too_far_down: i32 = top + ((matrix_height - 1.0) * module_size) as i32 - bottom; - if nudged_too_far_down > 0 { - if nudged_too_far_down > nudge { - // Neither way fits; abort - throw NotFoundException::get_not_found_instance(); - } - top -= nudged_too_far_down; - } - // Now just read off the bits - let bits: BitMatrix = BitMatrix::new(matrix_width, matrix_height); - { - let mut y: i32 = 0; - while y < matrix_height { - { - let i_offset: i32 = top + (y * module_size) as i32; - { - let mut x: i32 = 0; - while x < matrix_width { - { - if image.get(left + (x * module_size) as i32, i_offset) { - bits.set(x, y); - } - } - x += 1; - } - } - - } - y += 1; - } - } - - return Ok(bits); - } - - fn module_size( left_top_black: &Vec, image: &BitMatrix) -> /* throws NotFoundException */Result> { - let height: i32 = image.get_height(); - let width: i32 = image.get_width(); - let mut x: i32 = left_top_black[0]; - let mut y: i32 = left_top_black[1]; - let in_black: bool = true; - let mut transitions: i32 = 0; - while x < width && y < height { - if in_black != image.get(x, y) { - if transitions += 1 == 5 { - break; - } - in_black = !in_black; - } - x += 1; - y += 1; - } - if x == width || y == height { - throw NotFoundException::get_not_found_instance(); - } - return Ok((x - left_top_black[0]) / 7.0f); - } -} - -// NEW FILE: q_r_code_writer.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode; - -/** - * This object renders a QR Code as a BitMatrix 2D array of greyscale values. - * - * @author dswitkin@google.com (Daniel Switkin) - */ - - const QUIET_ZONE_SIZE: i32 = 4; -#[derive(Writer)] -pub struct QRCodeWriter { -} - -impl QRCodeWriter { - - pub fn encode(&self, contents: &String, format: &BarcodeFormat, width: i32, height: i32) -> /* throws WriterException */Result> { - return Ok(self.encode(&contents, format, width, height, null)); - } - - pub fn encode(&self, contents: &String, format: &BarcodeFormat, width: i32, height: i32, hints: &Map) -> /* throws WriterException */Result> { - if contents.is_empty() { - throw IllegalArgumentException::new("Found empty contents"); - } - if format != BarcodeFormat::QR_CODE { - throw IllegalArgumentException::new(format!("Can only encode QR_CODE, but got {}", format)); - } - if width < 0 || height < 0 { - throw IllegalArgumentException::new(format!("Requested dimensions are too small: {}x{}", width, height)); - } - let error_correction_level: ErrorCorrectionLevel = ErrorCorrectionLevel::L; - let quiet_zone: i32 = QUIET_ZONE_SIZE; - if hints != null { - if hints.contains_key(EncodeHintType::ERROR_CORRECTION) { - error_correction_level = ErrorCorrectionLevel::value_of(&hints.get(EncodeHintType::ERROR_CORRECTION).to_string()); - } - if hints.contains_key(EncodeHintType::MARGIN) { - quiet_zone = Integer::parse_int(&hints.get(EncodeHintType::MARGIN).to_string()); - } - } - let code: QRCode = Encoder::encode(&contents, error_correction_level, &hints); - return Ok(::render_result(code, width, height, quiet_zone)); - } - - // Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses - // 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap). - fn render_result( code: &QRCode, width: i32, height: i32, quiet_zone: i32) -> BitMatrix { - let input: ByteMatrix = code.get_matrix(); - if input == null { - throw IllegalStateException::new(); - } - let input_width: i32 = input.get_width(); - let input_height: i32 = input.get_height(); - let qr_width: i32 = input_width + (quiet_zone * 2); - let qr_height: i32 = input_height + (quiet_zone * 2); - let output_width: i32 = Math::max(width, qr_width); - let output_height: i32 = Math::max(height, qr_height); - let multiple: i32 = Math::min(output_width / qr_width, output_height / qr_height); - // Padding includes both the quiet zone and the extra white pixels to accommodate the requested - // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone. - // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will - // handle all the padding from 100x100 (the actual QR) up to 200x160. - let left_padding: i32 = (output_width - (input_width * multiple)) / 2; - let top_padding: i32 = (output_height - (input_height * multiple)) / 2; - let output: BitMatrix = BitMatrix::new(output_width, output_height); - { - let input_y: i32 = 0, let output_y: i32 = top_padding; - while input_y < input_height { - { - // Write the contents of this row of the barcode - { - let input_x: i32 = 0, let output_x: i32 = left_padding; - while input_x < input_width { - { - if input.get(input_x, input_y) == 1 { - output.set_region(output_x, output_y, multiple, multiple); - } - } - input_x += 1; - output_x += multiple; - } - } - - } - input_y += 1; - output_y += multiple; - } - } - - return output; - } -} - diff --git a/src/qrcode/decoder.rs b/src/qrcode/decoder.rs deleted file mode 100644 index 199ce5c..0000000 --- a/src/qrcode/decoder.rs +++ /dev/null @@ -1,1934 +0,0 @@ -use crate::{FormatException,DecodeHintType,ChecksumException,ResultPoint}; -use crate::comon::{BitMatrix,BitSource,CharacterSetECI,DecoderResult,StringUtils}; -use crate::common::reedsolomon::{GenericGF,ReedSolomonDecoder,ReedSolomonException}; - - - -// NEW FILE: bit_matrix_parser.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::decoder; - -/** - * @author Sean Owen - */ -struct BitMatrixParser { - - let bit_matrix: BitMatrix; - - let parsed_version: Version; - - let parsed_format_info: FormatInformation; - - let mirror: bool; -} - -impl BitMatrixParser { - - /** - * @param bitMatrix {@link BitMatrix} to parse - * @throws FormatException if dimension is not >= 21 and 1 mod 4 - */ - fn new( bit_matrix: &BitMatrix) -> BitMatrixParser throws FormatException { - let dimension: i32 = bit_matrix.get_height(); - if dimension < 21 || (dimension & 0x03) != 1 { - throw FormatException::get_format_instance(); - } - let .bitMatrix = bit_matrix; - } - - /** - *

Reads format information from one of its two locations within the QR Code.

- * - * @return {@link FormatInformation} encapsulating the QR Code's format info - * @throws FormatException if both format information locations cannot be parsed as - * the valid encoding of format information - */ - fn read_format_information(&self) -> /* throws FormatException */Result> { - if self.parsed_format_info != null { - return Ok(self.parsed_format_info); - } - // Read top-left format info bits - let format_info_bits1: i32 = 0; - { - let mut i: i32 = 0; - while i < 6 { - { - format_info_bits1 = self.copy_bit(i, 8, format_info_bits1); - } - i += 1; - } - } - - // .. and skip a bit in the timing pattern ... - format_info_bits1 = self.copy_bit(7, 8, format_info_bits1); - format_info_bits1 = self.copy_bit(8, 8, format_info_bits1); - format_info_bits1 = self.copy_bit(8, 7, format_info_bits1); - // .. and skip a bit in the timing pattern ... - { - let mut j: i32 = 5; - while j >= 0 { - { - format_info_bits1 = self.copy_bit(8, j, format_info_bits1); - } - j -= 1; - } - } - - // Read the top-right/bottom-left pattern too - let dimension: i32 = self.bit_matrix.get_height(); - let format_info_bits2: i32 = 0; - let j_min: i32 = dimension - 7; - { - let mut j: i32 = dimension - 1; - while j >= j_min { - { - format_info_bits2 = self.copy_bit(8, j, format_info_bits2); - } - j -= 1; - } - } - - { - let mut i: i32 = dimension - 8; - while i < dimension { - { - format_info_bits2 = self.copy_bit(i, 8, format_info_bits2); - } - i += 1; - } - } - - self.parsed_format_info = FormatInformation::decode_format_information(format_info_bits1, format_info_bits2); - if self.parsed_format_info != null { - return Ok(self.parsed_format_info); - } - throw FormatException::get_format_instance(); - } - - /** - *

Reads version information from one of its two locations within the QR Code.

- * - * @return {@link Version} encapsulating the QR Code's version - * @throws FormatException if both version information locations cannot be parsed as - * the valid encoding of version information - */ - fn read_version(&self) -> /* throws FormatException */Result> { - if self.parsed_version != null { - return Ok(self.parsed_version); - } - let dimension: i32 = self.bit_matrix.get_height(); - let provisional_version: i32 = (dimension - 17) / 4; - if provisional_version <= 6 { - return Ok(Version::get_version_for_number(provisional_version)); - } - // Read top-right version info: 3 wide by 6 tall - let version_bits: i32 = 0; - let ij_min: i32 = dimension - 11; - { - let mut j: i32 = 5; - while j >= 0 { - { - { - let mut i: i32 = dimension - 9; - while i >= ij_min { - { - version_bits = self.copy_bit(i, j, version_bits); - } - i -= 1; - } - } - - } - j -= 1; - } - } - - let the_parsed_version: Version = Version::decode_version_information(version_bits); - if the_parsed_version != null && the_parsed_version.get_dimension_for_version() == dimension { - self.parsed_version = the_parsed_version; - return Ok(the_parsed_version); - } - // Hmm, failed. Try bottom left: 6 wide by 3 tall - version_bits = 0; - { - let mut i: i32 = 5; - while i >= 0 { - { - { - let mut j: i32 = dimension - 9; - while j >= ij_min { - { - version_bits = self.copy_bit(i, j, version_bits); - } - j -= 1; - } - } - - } - i -= 1; - } - } - - the_parsed_version = Version::decode_version_information(version_bits); - if the_parsed_version != null && the_parsed_version.get_dimension_for_version() == dimension { - self.parsed_version = the_parsed_version; - return Ok(the_parsed_version); - } - throw FormatException::get_format_instance(); - } - - fn copy_bit(&self, i: i32, j: i32, version_bits: i32) -> i32 { - let bit: bool = if self.mirror { self.bit_matrix.get(j, i) } else { self.bit_matrix.get(i, j) }; - return if bit { (version_bits << 1) | 0x1 } else { version_bits << 1 }; - } - - /** - *

Reads the bits in the {@link BitMatrix} representing the finder pattern in the - * correct order in order to reconstruct the codewords bytes contained within the - * QR Code.

- * - * @return bytes encoded within the QR Code - * @throws FormatException if the exact number of bytes expected is not read - */ - fn read_codewords(&self) -> /* throws FormatException */Result, Rc> { - let format_info: FormatInformation = self.read_format_information(); - let version: Version = self.read_version(); - // Get the data mask for the format used in this QR Code. This will exclude - // some bits from reading as we wind through the bit matrix. - let data_mask: DataMask = DataMask::values()[format_info.get_data_mask()]; - let dimension: i32 = self.bit_matrix.get_height(); - data_mask.unmask_bit_matrix(self.bit_matrix, dimension); - let function_pattern: BitMatrix = version.build_function_pattern(); - let reading_up: bool = true; - let mut result: [i8; version.get_total_codewords()] = [0; version.get_total_codewords()]; - let result_offset: i32 = 0; - let current_byte: i32 = 0; - let bits_read: i32 = 0; - // Read columns in pairs, from right to left - { - let mut j: i32 = dimension - 1; - while j > 0 { - { - if j == 6 { - // Skip whole column with vertical alignment pattern; - // saves time and makes the other code proceed more cleanly - j -= 1; - } - // Read alternatingly from bottom to top then top to bottom - { - let mut count: i32 = 0; - while count < dimension { - { - let i: i32 = if reading_up { dimension - 1 - count } else { count }; - { - let mut col: i32 = 0; - while col < 2 { - { - // Ignore bits covered by the function pattern - if !function_pattern.get(j - col, i) { - // Read a bit - bits_read += 1; - current_byte <<= 1; - if self.bit_matrix.get(j - col, i) { - current_byte |= 1; - } - // If we've made a whole byte, save it off - if bits_read == 8 { - result[result_offset += 1 !!!check!!! post increment] = current_byte as i8; - bits_read = 0; - current_byte = 0; - } - } - } - col += 1; - } - } - - } - count += 1; - } - } - - // readingUp = !readingUp; // switch directions - reading_up ^= true; - } - j -= 2; - } - } - - if result_offset != version.get_total_codewords() { - throw FormatException::get_format_instance(); - } - return Ok(result); - } - - /** - * Revert the mask removal done while reading the code words. The bit matrix should revert to its original state. - */ - fn remask(&self) { - if self.parsed_format_info == null { - // We have no format information, and have no data mask - return; - } - let data_mask: DataMask = DataMask::values()[self.parsed_format_info.get_data_mask()]; - let dimension: i32 = self.bit_matrix.get_height(); - data_mask.unmask_bit_matrix(self.bit_matrix, dimension); - } - - /** - * Prepare the parser for a mirrored operation. - * This flag has effect only on the {@link #readFormatInformation()} and the - * {@link #readVersion()}. Before proceeding with {@link #readCodewords()} the - * {@link #mirror()} method should be called. - * - * @param mirror Whether to read version and format information mirrored. - */ - fn set_mirror(&self, mirror: bool) { - self.parsed_version = null; - self.parsed_format_info = null; - self.mirror = mirror; - } - - /** Mirror the bit matrix in order to attempt a second reading. */ - fn mirror(&self) { - { - let mut x: i32 = 0; - while x < self.bit_matrix.get_width() { - { - { - let mut y: i32 = x + 1; - while y < self.bit_matrix.get_height() { - { - if self.bit_matrix.get(x, y) != self.bit_matrix.get(y, x) { - self.bit_matrix.flip(y, x); - self.bit_matrix.flip(x, y); - } - } - y += 1; - } - } - - } - x += 1; - } - } - - } -} - -// NEW FILE: data_block.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::decoder; - -/** - *

Encapsulates a block of data within a QR Code. QR Codes may split their data into - * multiple blocks, each of which is a unit of data and error-correction codewords. Each - * is represented by an instance of this class.

- * - * @author Sean Owen - */ -struct DataBlock { - - let num_data_codewords: i32; - - let mut codewords: Vec; -} - -impl DataBlock { - - fn new( num_data_codewords: i32, codewords: &Vec) -> DataBlock { - let .numDataCodewords = num_data_codewords; - let .codewords = codewords; - } - - /** - *

When QR Codes use multiple data blocks, they are actually interleaved. - * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This - * method will separate the data into original blocks.

- * - * @param rawCodewords bytes as read directly from the QR Code - * @param version version of the QR Code - * @param ecLevel error-correction level of the QR Code - * @return DataBlocks containing original bytes, "de-interleaved" from representation in the - * QR Code - */ - fn get_data_blocks( raw_codewords: &Vec, version: &Version, ec_level: &ErrorCorrectionLevel) -> Vec { - if raw_codewords.len() != version.get_total_codewords() { - throw IllegalArgumentException::new(); - } - // Figure out the number and size of data blocks used by this version and - // error correction level - let ec_blocks: Version.ECBlocks = version.get_e_c_blocks_for_level(ec_level); - // First count the total number of data blocks - let total_blocks: i32 = 0; - let ec_block_array: Vec = ec_blocks.get_e_c_blocks(); - for let ec_block: Version.ECB in ec_block_array { - total_blocks += ec_block.get_count(); - } - // Now establish DataBlocks of the appropriate size and number of data codewords - let mut result: [Option; total_blocks] = [None; total_blocks]; - let num_result_blocks: i32 = 0; - for let ec_block: Version.ECB in ec_block_array { - { - let mut i: i32 = 0; - while i < ec_block.get_count() { - { - let num_data_codewords: i32 = ec_block.get_data_codewords(); - let num_block_codewords: i32 = ec_blocks.get_e_c_codewords_per_block() + num_data_codewords; - result[num_result_blocks += 1 !!!check!!! post increment] = DataBlock::new(num_data_codewords, : [i8; num_block_codewords] = [0; num_block_codewords]); - } - i += 1; - } - } - - } - // All blocks have the same amount of data, except that the last n - // (where n may be 0) have 1 more byte. Figure out where these start. - let shorter_blocks_total_codewords: i32 = result[0].codewords.len(); - let longer_blocks_start_at: i32 = result.len() - 1; - while longer_blocks_start_at >= 0 { - let num_codewords: i32 = result[longer_blocks_start_at].codewords.len(); - if num_codewords == shorter_blocks_total_codewords { - break; - } - longer_blocks_start_at -= 1; - } - longer_blocks_start_at += 1; - let shorter_blocks_num_data_codewords: i32 = shorter_blocks_total_codewords - ec_blocks.get_e_c_codewords_per_block(); - // The last elements of result may be 1 element longer; - // first fill out as many elements as all of them have - let raw_codewords_offset: i32 = 0; - { - let mut i: i32 = 0; - while i < shorter_blocks_num_data_codewords { - { - { - let mut j: i32 = 0; - while j < num_result_blocks { - { - result[j].codewords[i] = raw_codewords[raw_codewords_offset += 1 !!!check!!! post increment]; - } - j += 1; - } - } - - } - i += 1; - } - } - - // Fill out the last data block in the longer ones - { - let mut j: i32 = longer_blocks_start_at; - while j < num_result_blocks { - { - result[j].codewords[shorter_blocks_num_data_codewords] = raw_codewords[raw_codewords_offset += 1 !!!check!!! post increment]; - } - j += 1; - } - } - - // Now add in error correction blocks - let max: i32 = result[0].codewords.len(); - { - let mut i: i32 = shorter_blocks_num_data_codewords; - while i < max { - { - { - let mut j: i32 = 0; - while j < num_result_blocks { - { - let i_offset: i32 = if j < longer_blocks_start_at { i } else { i + 1 }; - result[j].codewords[i_offset] = raw_codewords[raw_codewords_offset += 1 !!!check!!! post increment]; - } - j += 1; - } - } - - } - i += 1; - } - } - - return result; - } - - fn get_num_data_codewords(&self) -> i32 { - return self.num_data_codewords; - } - - fn get_codewords(&self) -> Vec { - return self.codewords; - } -} - -// NEW FILE: data_mask.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::decoder; - -/** - *

Encapsulates data masks for the data bits in a QR code, per ISO 18004:2006 6.8. Implementations - * of this class can un-mask a raw BitMatrix. For simplicity, they will unmask the entire BitMatrix, - * including areas used for finder patterns, timing patterns, etc. These areas should be unused - * after the point they are unmasked anyway.

- * - *

Note that the diagram in section 6.8.1 is misleading since it indicates that i is column position - * and j is row position. In fact, as the text says, i is row position and j is column position.

- * - * @author Sean Owen - */ -enum DataMask { - - /** - * 000: mask bits for which (x + y) mod 2 == 0 - */ - DATA_MASK_000() { - - fn is_masked(&self, i: i32, j: i32) -> bool { - return ((i + j) & 0x01) == 0; - } - } - , /** - * 001: mask bits for which x mod 2 == 0 - */ - DATA_MASK_001() { - - fn is_masked(&self, i: i32, j: i32) -> bool { - return (i & 0x01) == 0; - } - } - , /** - * 010: mask bits for which y mod 3 == 0 - */ - DATA_MASK_010() { - - fn is_masked(&self, i: i32, j: i32) -> bool { - return j % 3 == 0; - } - } - , /** - * 011: mask bits for which (x + y) mod 3 == 0 - */ - DATA_MASK_011() { - - fn is_masked(&self, i: i32, j: i32) -> bool { - return (i + j) % 3 == 0; - } - } - , /** - * 100: mask bits for which (x/2 + y/3) mod 2 == 0 - */ - DATA_MASK_100() { - - fn is_masked(&self, i: i32, j: i32) -> bool { - return (((i / 2) + (j / 3)) & 0x01) == 0; - } - } - , /** - * 101: mask bits for which xy mod 2 + xy mod 3 == 0 - * equivalently, such that xy mod 6 == 0 - */ - DATA_MASK_101() { - - fn is_masked(&self, i: i32, j: i32) -> bool { - return (i * j) % 6 == 0; - } - } - , /** - * 110: mask bits for which (xy mod 2 + xy mod 3) mod 2 == 0 - * equivalently, such that xy mod 6 < 3 - */ - DATA_MASK_110() { - - fn is_masked(&self, i: i32, j: i32) -> bool { - return ((i * j) % 6) < 3; - } - } - , /** - * 111: mask bits for which ((x+y)mod 2 + xy mod 3) mod 2 == 0 - * equivalently, such that (x + y + xy mod 3) mod 2 == 0 - */ - DATA_MASK_111() { - - fn is_masked(&self, i: i32, j: i32) -> bool { - return ((i + j + ((i * j) % 3)) & 0x01) == 0; - } - } - ; - - // End of enum constants. - /** - *

Implementations of this method reverse the data masking process applied to a QR Code and - * make its bits ready to read.

- * - * @param bits representation of QR Code bits - * @param dimension dimension of QR Code, represented by bits, being unmasked - */ - fn unmask_bit_matrix(&self, bits: &BitMatrix, dimension: i32) { - { - let mut i: i32 = 0; - while i < dimension { - { - { - let mut j: i32 = 0; - while j < dimension { - { - if self.is_masked(i, j) { - bits.flip(j, i); - } - } - j += 1; - } - } - - } - i += 1; - } - } - - } - - fn is_masked(&self, i: i32, j: i32) -> bool ; -} -// NEW FILE: decoded_bit_stream_parser.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::decoder; - -/** - *

QR Codes can encode text as bits in one of several modes, and can use multiple modes - * in one QR Code. This class decodes the bits back into text.

- * - *

See ISO 18004:2006, 6.4.3 - 6.4.7

- * - * @author Sean Owen - */ - -/** - * See ISO 18004:2006, 6.4.4 Table 5 - */ - const ALPHANUMERIC_CHARS: Vec = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".to_char_array(); - - const GB2312_SUBSET: i32 = 1; -struct DecodedBitStreamParser { -} - -impl DecodedBitStreamParser { - - fn new() -> DecodedBitStreamParser { - } - - fn decode( bytes: &Vec, version: &Version, ec_level: &ErrorCorrectionLevel, hints: &Map) -> /* throws FormatException */Result> { - let bits: BitSource = BitSource::new(&bytes); - let result: StringBuilder = StringBuilder::new(50); - let byte_segments: List> = ArrayList<>::new(1); - let symbol_sequence: i32 = -1; - let parity_data: i32 = -1; - let symbology_modifier: i32; - let tryResult1 = 0; - 'try1: loop { - { - let current_character_set_e_c_i: CharacterSetECI = null; - let fc1_in_effect: bool = false; - let has_f_n_c1first: bool = false; - let has_f_n_c1second: bool = false; - let mut mode: Mode; - loop { { - // While still another segment to read... - if bits.available() < 4 { - // OK, assume we're done. Really, a TERMINATOR mode should have been recorded here - mode = Mode::TERMINATOR; - } else { - // mode is encoded by 4 bits - mode = Mode::for_bits(&bits.read_bits(4)); - } - match mode { - TERMINATOR => - { - break; - } - FNC1_FIRST_POSITION => - { - // symbology detection - has_f_n_c1first = true; - // We do little with FNC1 except alter the parsed result a bit according to the spec - fc1_in_effect = true; - break; - } - FNC1_SECOND_POSITION => - { - // symbology detection - has_f_n_c1second = true; - // We do little with FNC1 except alter the parsed result a bit according to the spec - fc1_in_effect = true; - break; - } - STRUCTURED_APPEND => - { - if bits.available() < 16 { - throw FormatException::get_format_instance(); - } - // sequence number and parity is added later to the result metadata - // Read next 8 bits (symbol sequence #) and 8 bits (parity data), then continue - symbol_sequence = bits.read_bits(8); - parity_data = bits.read_bits(8); - break; - } - ECI => - { - // Count doesn't apply to ECI - let value: i32 = ::parse_e_c_i_value(bits); - current_character_set_e_c_i = CharacterSetECI::get_character_set_e_c_i_by_value(value); - if current_character_set_e_c_i == null { - throw FormatException::get_format_instance(); - } - break; - } - HANZI => - { - // First handle Hanzi mode which does not start with character count - // Chinese mode contains a sub set indicator right after mode indicator - let subset: i32 = bits.read_bits(4); - let count_hanzi: i32 = bits.read_bits(&mode.get_character_count_bits(version)); - if subset == GB2312_SUBSET { - ::decode_hanzi_segment(bits, &result, count_hanzi); - } - break; - } - _ => - { - // "Normal" QR code modes: - // How many characters will follow, encoded in this mode? - let count: i32 = bits.read_bits(&mode.get_character_count_bits(version)); - match mode { - NUMERIC => - { - ::decode_numeric_segment(bits, &result, count); - break; - } - ALPHANUMERIC => - { - ::decode_alphanumeric_segment(bits, &result, count, fc1_in_effect); - break; - } - BYTE => - { - ::decode_byte_segment(bits, &result, count, current_character_set_e_c_i, &byte_segments, &hints); - break; - } - KANJI => - { - ::decode_kanji_segment(bits, &result, count); - break; - } - _ => - { - throw FormatException::get_format_instance(); - } - } - break; - } - } - }if !(mode != Mode::TERMINATOR) break;} - if current_character_set_e_c_i != null { - if has_f_n_c1first { - symbology_modifier = 4; - } else if has_f_n_c1second { - symbology_modifier = 6; - } else { - symbology_modifier = 2; - } - } else { - if has_f_n_c1first { - symbology_modifier = 3; - } else if has_f_n_c1second { - symbology_modifier = 5; - } else { - symbology_modifier = 1; - } - } - } - break 'try1 - } - match tryResult1 { - catch ( iae: &IllegalArgumentException) { - throw FormatException::get_format_instance(); - } 0 => break - } - - return Ok(DecoderResult::new(&bytes, &result.to_string(), if byte_segments.is_empty() { null } else { byte_segments }, if ec_level == null { null } else { ec_level.to_string() }, symbol_sequence, parity_data, symbology_modifier)); - } - - /** - * See specification GBT 18284-2000 - */ - fn decode_hanzi_segment( bits: &BitSource, result: &StringBuilder, count: i32) -> /* throws FormatException */Result> { - // Don't crash trying to read more bits than we have available. - if count * 13 > bits.available() { - throw FormatException::get_format_instance(); - } - // Each character will require 2 bytes. Read the characters as 2-byte pairs - // and decode as GB2312 afterwards - let mut buffer: [i8; 2 * count] = [0; 2 * count]; - let mut offset: i32 = 0; - while count > 0 { - // Each 13 bits encodes a 2-byte character - let two_bytes: i32 = bits.read_bits(13); - let assembled_two_bytes: i32 = ((two_bytes / 0x060) << 8) | (two_bytes % 0x060); - if assembled_two_bytes < 0x00A00 { - // In the 0xA1A1 to 0xAAFE range - assembled_two_bytes += 0x0A1A1; - } else { - // In the 0xB0A1 to 0xFAFE range - assembled_two_bytes += 0x0A6A1; - } - buffer[offset] = ((assembled_two_bytes >> 8) & 0xFF) as i8; - buffer[offset + 1] = (assembled_two_bytes & 0xFF) as i8; - offset += 2; - count -= 1; - } - result.append(String::new(&buffer, StringUtils::GB2312_CHARSET)); - } - - fn decode_kanji_segment( bits: &BitSource, result: &StringBuilder, count: i32) -> /* throws FormatException */Result> { - // Don't crash trying to read more bits than we have available. - if count * 13 > bits.available() { - throw FormatException::get_format_instance(); - } - // Each character will require 2 bytes. Read the characters as 2-byte pairs - // and decode as Shift_JIS afterwards - let mut buffer: [i8; 2 * count] = [0; 2 * count]; - let mut offset: i32 = 0; - while count > 0 { - // Each 13 bits encodes a 2-byte character - let two_bytes: i32 = bits.read_bits(13); - let assembled_two_bytes: i32 = ((two_bytes / 0x0C0) << 8) | (two_bytes % 0x0C0); - if assembled_two_bytes < 0x01F00 { - // In the 0x8140 to 0x9FFC range - assembled_two_bytes += 0x08140; - } else { - // In the 0xE040 to 0xEBBF range - assembled_two_bytes += 0x0C140; - } - buffer[offset] = (assembled_two_bytes >> 8) as i8; - buffer[offset + 1] = assembled_two_bytes as i8; - offset += 2; - count -= 1; - } - result.append(String::new(&buffer, StringUtils::SHIFT_JIS_CHARSET)); - } - - fn decode_byte_segment( bits: &BitSource, result: &StringBuilder, count: i32, current_character_set_e_c_i: &CharacterSetECI, byte_segments: &Collection>, hints: &Map) -> /* throws FormatException */Result> { - // Don't crash trying to read more bits than we have available. - if 8 * count > bits.available() { - throw FormatException::get_format_instance(); - } - let read_bytes: [i8; count] = [0; count]; - { - let mut i: i32 = 0; - while i < count { - { - read_bytes[i] = bits.read_bits(8) as i8; - } - i += 1; - } - } - - let mut encoding: Charset; - if current_character_set_e_c_i == null { - // The spec isn't clear on this mode; see - // section 6.4.5: t does not say which encoding to assuming - // upon decoding. I have seen ISO-8859-1 used as well as - // Shift_JIS -- without anything like an ECI designator to - // give a hint. - encoding = StringUtils::guess_charset(&read_bytes, &hints); - } else { - encoding = current_character_set_e_c_i.get_charset(); - } - result.append(String::new(&read_bytes, &encoding)); - byte_segments.add(&read_bytes); - } - - fn to_alpha_numeric_char( value: i32) -> /* throws FormatException */Result> { - if value >= ALPHANUMERIC_CHARS.len() { - throw FormatException::get_format_instance(); - } - return Ok(ALPHANUMERIC_CHARS[value]); - } - - fn decode_alphanumeric_segment( bits: &BitSource, result: &StringBuilder, count: i32, fc1_in_effect: bool) -> /* throws FormatException */Result> { - // Read two characters at a time - let start: i32 = result.length(); - while count > 1 { - if bits.available() < 11 { - throw FormatException::get_format_instance(); - } - let next_two_chars_bits: i32 = bits.read_bits(11); - result.append(&::to_alpha_numeric_char(next_two_chars_bits / 45)); - result.append(&::to_alpha_numeric_char(next_two_chars_bits % 45)); - count -= 2; - } - if count == 1 { - // special case: one character left - if bits.available() < 6 { - throw FormatException::get_format_instance(); - } - result.append(&::to_alpha_numeric_char(&bits.read_bits(6))); - } - // See section 6.4.8.1, 6.4.8.2 - if fc1_in_effect { - // We need to massage the result a bit if in an FNC1 mode: - { - let mut i: i32 = start; - while i < result.length() { - { - if result.char_at(i) == '%' { - if i < result.length() - 1 && result.char_at(i + 1) == '%' { - // %% is rendered as % - result.delete_char_at(i + 1); - } else { - // In alpha mode, % should be converted to FNC1 separator 0x1D - result.set_char_at(i, 0x1D as char); - } - } - } - i += 1; - } - } - - } - } - - fn decode_numeric_segment( bits: &BitSource, result: &StringBuilder, count: i32) -> /* throws FormatException */Result> { - // Read three digits at a time - while count >= 3 { - // Each 10 bits encodes three digits - if bits.available() < 10 { - throw FormatException::get_format_instance(); - } - let three_digits_bits: i32 = bits.read_bits(10); - if three_digits_bits >= 1000 { - throw FormatException::get_format_instance(); - } - result.append(&::to_alpha_numeric_char(three_digits_bits / 100)); - result.append(&::to_alpha_numeric_char((three_digits_bits / 10) % 10)); - result.append(&::to_alpha_numeric_char(three_digits_bits % 10)); - count -= 3; - } - if count == 2 { - // Two digits left over to read, encoded in 7 bits - if bits.available() < 7 { - throw FormatException::get_format_instance(); - } - let two_digits_bits: i32 = bits.read_bits(7); - if two_digits_bits >= 100 { - throw FormatException::get_format_instance(); - } - result.append(&::to_alpha_numeric_char(two_digits_bits / 10)); - result.append(&::to_alpha_numeric_char(two_digits_bits % 10)); - } else if count == 1 { - // One digit left over to read - if bits.available() < 4 { - throw FormatException::get_format_instance(); - } - let digit_bits: i32 = bits.read_bits(4); - if digit_bits >= 10 { - throw FormatException::get_format_instance(); - } - result.append(&::to_alpha_numeric_char(digit_bits)); - } - } - - fn parse_e_c_i_value( bits: &BitSource) -> /* throws FormatException */Result> { - let first_byte: i32 = bits.read_bits(8); - if (first_byte & 0x80) == 0 { - // just one byte - return Ok(first_byte & 0x7F); - } - if (first_byte & 0xC0) == 0x80 { - // two bytes - let second_byte: i32 = bits.read_bits(8); - return Ok(((first_byte & 0x3F) << 8) | second_byte); - } - if (first_byte & 0xE0) == 0xC0 { - // three bytes - let second_third_bytes: i32 = bits.read_bits(16); - return Ok(((first_byte & 0x1F) << 16) | second_third_bytes); - } - throw FormatException::get_format_instance(); - } -} - -// NEW FILE: decoder.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::decoder; - -/** - *

The main class which implements QR Code decoding -- as opposed to locating and extracting - * the QR Code from an image.

- * - * @author Sean Owen - */ -pub struct Decoder { - - let rs_decoder: ReedSolomonDecoder; -} - -impl Decoder { - - pub fn new() -> Decoder { - rs_decoder = ReedSolomonDecoder::new(GenericGF::QR_CODE_FIELD_256); - } - - pub fn decode(&self, image: &Vec>) -> /* throws ChecksumException, FormatException */Result> { - return Ok(self.decode(&image, null)); - } - - /** - *

Convenience method that can decode a QR Code represented as a 2D array of booleans. - * "true" is taken to mean a black module.

- * - * @param image booleans representing white/black QR Code modules - * @param hints decoding hints that should be used to influence decoding - * @return text and bytes encoded within the QR Code - * @throws FormatException if the QR Code cannot be decoded - * @throws ChecksumException if error correction fails - */ - pub fn decode(&self, image: &Vec>, hints: &Map) -> /* throws ChecksumException, FormatException */Result> { - return Ok(self.decode(&BitMatrix::parse(&image), &hints)); - } - - pub fn decode(&self, bits: &BitMatrix) -> /* throws ChecksumException, FormatException */Result> { - return Ok(self.decode(bits, null)); - } - - /** - *

Decodes a QR Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.

- * - * @param bits booleans representing white/black QR Code modules - * @param hints decoding hints that should be used to influence decoding - * @return text and bytes encoded within the QR Code - * @throws FormatException if the QR Code cannot be decoded - * @throws ChecksumException if error correction fails - */ - pub fn decode(&self, bits: &BitMatrix, hints: &Map) -> /* throws FormatException, ChecksumException */Result> { - // Construct a parser and read version, error-correction level - let parser: BitMatrixParser = BitMatrixParser::new(bits); - let mut fe: FormatException = null; - let mut ce: ChecksumException = null; - let tryResult1 = 0; - 'try1: loop { - { - return Ok(self.decode(parser, &hints)); - } - break 'try1 - } - match tryResult1 { - catch ( e: &FormatException) { - fe = e; - } catch ( e: &ChecksumException) { - ce = e; - } 0 => break - } - - let tryResult1 = 0; - 'try1: loop { - { - // Revert the bit matrix - parser.remask(); - // Will be attempting a mirrored reading of the version and format info. - parser.set_mirror(true); - // Preemptively read the version. - parser.read_version(); - // Preemptively read the format information. - parser.read_format_information(); - /* - * Since we're here, this means we have successfully detected some kind - * of version and format information when mirrored. This is a good sign, - * that the QR code may be mirrored, and we should try once more with a - * mirrored content. - */ - // Prepare for a mirrored reading. - parser.mirror(); - let result: DecoderResult = self.decode(parser, &hints); - // Success! Notify the caller that the code was mirrored. - result.set_other(QRCodeDecoderMetaData::new(true)); - return Ok(result); - } - break 'try1 - } - match tryResult1 { - catch ( e: &FormatExceptionChecksumException | ) { - if fe != null { - throw fe; - } - throw ce; - } 0 => break - } - - } - - fn decode(&self, parser: &BitMatrixParser, hints: &Map) -> /* throws FormatException, ChecksumException */Result> { - let version: Version = parser.read_version(); - let ec_level: ErrorCorrectionLevel = parser.read_format_information().get_error_correction_level(); - // Read codewords - let codewords: Vec = parser.read_codewords(); - // Separate into data blocks - let data_blocks: Vec = DataBlock::get_data_blocks(&codewords, version, ec_level); - // Count total number of data bytes - let total_bytes: i32 = 0; - for let data_block: DataBlock in data_blocks { - total_bytes += data_block.get_num_data_codewords(); - } - let result_bytes: [i8; total_bytes] = [0; total_bytes]; - let result_offset: i32 = 0; - // Error-correct and copy data blocks together into a stream of bytes - for let data_block: DataBlock in data_blocks { - let codeword_bytes: Vec = data_block.get_codewords(); - let num_data_codewords: i32 = data_block.get_num_data_codewords(); - self.correct_errors(&codeword_bytes, num_data_codewords); - { - let mut i: i32 = 0; - while i < num_data_codewords { - { - result_bytes[result_offset += 1 !!!check!!! post increment] = codeword_bytes[i]; - } - i += 1; - } - } - - } - // Decode the contents of that stream of bytes - return Ok(DecodedBitStreamParser::decode(&result_bytes, version, ec_level, &hints)); - } - - /** - *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to - * correct the errors in-place using Reed-Solomon error correction.

- * - * @param codewordBytes data and error correction codewords - * @param numDataCodewords number of codewords that are data bytes - * @throws ChecksumException if error correction fails - */ - fn correct_errors(&self, codeword_bytes: &Vec, num_data_codewords: i32) -> /* throws ChecksumException */Result> { - let num_codewords: i32 = codeword_bytes.len(); - // First read into an array of ints - let codewords_ints: [i32; num_codewords] = [0; num_codewords]; - { - let mut i: i32 = 0; - while i < num_codewords { - { - codewords_ints[i] = codeword_bytes[i] & 0xFF; - } - i += 1; - } - } - - let tryResult1 = 0; - 'try1: loop { - { - self.rs_decoder.decode(&codewords_ints, codeword_bytes.len() - num_data_codewords); - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &ReedSolomonException) { - throw ChecksumException::get_checksum_instance(); - } 0 => break - } - - // We don't care about errors in the error-correction codewords - { - let mut i: i32 = 0; - while i < num_data_codewords { - { - codeword_bytes[i] = codewords_ints[i] as i8; - } - i += 1; - } - } - - } -} - -// NEW FILE: error_correction_level.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::decoder; - -/** - *

See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels - * defined by the QR code standard.

- * - * @author Sean Owen - */ -pub enum ErrorCorrectionLevel { - - /** L = ~7% correction */ - L(0x01), /** M = ~15% correction */ - M(0x00), /** Q = ~25% correction */ - Q(0x03), /** H = ~30% correction */ - H(0x02); - - const FOR_BITS: vec![Vec; 4] = vec![M, L, H, Q, ] - ; - - let bits: i32; - - fn new( bits: i32) -> ErrorCorrectionLevel { - let .bits = bits; - } - - pub fn get_bits(&self) -> i32 { - return self.bits; - } - - /** - * @param bits int containing the two bits encoding a QR Code's error correction level - * @return ErrorCorrectionLevel representing the encoded error correction level - */ - pub fn for_bits( bits: i32) -> ErrorCorrectionLevel { - if bits < 0 || bits >= FOR_BITS.len() { - throw IllegalArgumentException::new(); - } - return FOR_BITS[bits]; - } -} -// NEW FILE: format_information.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::decoder; - -/** - *

Encapsulates a QR Code's format information, including the data mask used and - * error correction level.

- * - * @author Sean Owen - * @see DataMask - * @see ErrorCorrectionLevel - */ - - const FORMAT_INFO_MASK_QR: i32 = 0x5412; - -/** - * See ISO 18004:2006, Annex C, Table C.1 - */ - const FORMAT_INFO_DECODE_LOOKUP: vec![vec![Vec>; 2]; 32] = vec![vec![0x5412, 0x00, ] -, vec![0x5125, 0x01, ] -, vec![0x5E7C, 0x02, ] -, vec![0x5B4B, 0x03, ] -, vec![0x45F9, 0x04, ] -, vec![0x40CE, 0x05, ] -, vec![0x4F97, 0x06, ] -, vec![0x4AA0, 0x07, ] -, vec![0x77C4, 0x08, ] -, vec![0x72F3, 0x09, ] -, vec![0x7DAA, 0x0A, ] -, vec![0x789D, 0x0B, ] -, vec![0x662F, 0x0C, ] -, vec![0x6318, 0x0D, ] -, vec![0x6C41, 0x0E, ] -, vec![0x6976, 0x0F, ] -, vec![0x1689, 0x10, ] -, vec![0x13BE, 0x11, ] -, vec![0x1CE7, 0x12, ] -, vec![0x19D0, 0x13, ] -, vec![0x0762, 0x14, ] -, vec![0x0255, 0x15, ] -, vec![0x0D0C, 0x16, ] -, vec![0x083B, 0x17, ] -, vec![0x355F, 0x18, ] -, vec![0x3068, 0x19, ] -, vec![0x3F31, 0x1A, ] -, vec![0x3A06, 0x1B, ] -, vec![0x24B4, 0x1C, ] -, vec![0x2183, 0x1D, ] -, vec![0x2EDA, 0x1E, ] -, vec![0x2BED, 0x1F, ] -, ] -; -struct FormatInformation { - - let error_correction_level: ErrorCorrectionLevel; - - let data_mask: i8; -} - -impl FormatInformation { - - fn new( format_info: i32) -> FormatInformation { - // Bits 3,4 - error_correction_level = ErrorCorrectionLevel::for_bits((format_info >> 3) & 0x03); - // Bottom 3 bits - data_mask = (format_info & 0x07) as i8; - } - - fn num_bits_differing( a: i32, b: i32) -> i32 { - return Integer::bit_count(a ^ b); - } - - /** - * @param maskedFormatInfo1 format info indicator, with mask still applied - * @param maskedFormatInfo2 second copy of same info; both are checked at the same time - * to establish best match - * @return information about the format it specifies, or {@code null} - * if doesn't seem to match any known pattern - */ - fn decode_format_information( masked_format_info1: i32, masked_format_info2: i32) -> FormatInformation { - let format_info: FormatInformation = ::do_decode_format_information(masked_format_info1, masked_format_info2); - if format_info != null { - return format_info; - } - // first - return ::do_decode_format_information(masked_format_info1 ^ FORMAT_INFO_MASK_QR, masked_format_info2 ^ FORMAT_INFO_MASK_QR); - } - - fn do_decode_format_information( masked_format_info1: i32, masked_format_info2: i32) -> FormatInformation { - // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing - let best_difference: i32 = Integer::MAX_VALUE; - let best_format_info: i32 = 0; - for let decode_info: Vec in FORMAT_INFO_DECODE_LOOKUP { - let target_info: i32 = decode_info[0]; - if target_info == masked_format_info1 || target_info == masked_format_info2 { - // Found an exact match - return FormatInformation::new(decode_info[1]); - } - let bits_difference: i32 = ::num_bits_differing(masked_format_info1, target_info); - if bits_difference < best_difference { - best_format_info = decode_info[1]; - best_difference = bits_difference; - } - if masked_format_info1 != masked_format_info2 { - // also try the other option - bits_difference = ::num_bits_differing(masked_format_info2, target_info); - if bits_difference < best_difference { - best_format_info = decode_info[1]; - best_difference = bits_difference; - } - } - } - // differing means we found a match - if best_difference <= 3 { - return FormatInformation::new(best_format_info); - } - return null; - } - - fn get_error_correction_level(&self) -> ErrorCorrectionLevel { - return self.error_correction_level; - } - - fn get_data_mask(&self) -> i8 { - return self.data_mask; - } - - pub fn hash_code(&self) -> i32 { - return (self.error_correction_level.ordinal() << 3) | self.data_mask; - } - - pub fn equals(&self, o: &Object) -> bool { - if !(o instanceof FormatInformation) { - return false; - } - let other: FormatInformation = o as FormatInformation; - return self.errorCorrectionLevel == other.errorCorrectionLevel && self.dataMask == other.dataMask; - } -} - -// NEW FILE: mode.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::decoder; - -/** - *

See ISO 18004:2006, 6.4.1, Tables 2 and 3. This enum encapsulates the various modes in which - * data can be encoded to bits in the QR code standard.

- * - * @author Sean Owen - */ -pub enum Mode { - - // Not really a mode... - TERMINATOR( : vec![i32; 3] = vec![0, 0, 0, ] - , 0x00), NUMERIC( : vec![i32; 3] = vec![10, 12, 14, ] - , 0x01), ALPHANUMERIC( : vec![i32; 3] = vec![9, 11, 13, ] - , 0x02), // Not supported - STRUCTURED_APPEND( : vec![i32; 3] = vec![0, 0, 0, ] - , 0x03), BYTE( : vec![i32; 3] = vec![8, 16, 16, ] - , 0x04), // character counts don't apply - ECI( : vec![i32; 3] = vec![0, 0, 0, ] - , 0x07), KANJI( : vec![i32; 3] = vec![8, 10, 12, ] - , 0x08), FNC1_FIRST_POSITION( : vec![i32; 3] = vec![0, 0, 0, ] - , 0x05), FNC1_SECOND_POSITION( : vec![i32; 3] = vec![0, 0, 0, ] - , 0x09), /** See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. */ - HANZI( : vec![i32; 3] = vec![8, 10, 12, ] - , 0x0D); - - let character_count_bits_for_versions: Vec; - - let bits: i32; - - fn new( character_count_bits_for_versions: &Vec, bits: i32) -> Mode { - let .characterCountBitsForVersions = character_count_bits_for_versions; - let .bits = bits; - } - - /** - * @param bits four bits encoding a QR Code data mode - * @return Mode encoded by these bits - * @throws IllegalArgumentException if bits do not correspond to a known mode - */ - pub fn for_bits( bits: i32) -> Mode { - match bits { - 0x0 => - { - return TERMINATOR; - } - 0x1 => - { - return NUMERIC; - } - 0x2 => - { - return ALPHANUMERIC; - } - 0x3 => - { - return STRUCTURED_APPEND; - } - 0x4 => - { - return BYTE; - } - 0x5 => - { - return FNC1_FIRST_POSITION; - } - 0x7 => - { - return ECI; - } - 0x8 => - { - return KANJI; - } - 0x9 => - { - return FNC1_SECOND_POSITION; - } - 0xD => - { - // 0xD is defined in GBT 18284-2000, may not be supported in foreign country - return HANZI; - } - _ => - { - throw IllegalArgumentException::new(); - } - } - } - - /** - * @param version version in question - * @return number of bits used, in this QR Code symbol {@link Version}, to encode the - * count of characters that will follow encoded in this Mode - */ - pub fn get_character_count_bits(&self, version: &Version) -> i32 { - let number: i32 = version.get_version_number(); - let mut offset: i32; - if number <= 9 { - offset = 0; - } else if number <= 26 { - offset = 1; - } else { - offset = 2; - } - return self.character_count_bits_for_versions[offset]; - } - - pub fn get_bits(&self) -> i32 { - return self.bits; - } -} -// NEW FILE: q_r_code_decoder_meta_data.rs -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::decoder; - -/** - * Meta-data container for QR Code decoding. Instances of this class may be used to convey information back to the - * decoding caller. Callers are expected to process this. - * - * @see com.google.zxing.common.DecoderResult#getOther() - */ -pub struct QRCodeDecoderMetaData { - - let mirrored: bool; -} - -impl QRCodeDecoderMetaData { - - fn new( mirrored: bool) -> QRCodeDecoderMetaData { - let .mirrored = mirrored; - } - - /** - * @return true if the QR Code was mirrored. - */ - pub fn is_mirrored(&self) -> bool { - return self.mirrored; - } - - /** - * Apply the result points' order correction due to mirroring. - * - * @param points Array of points to apply mirror correction to. - */ - pub fn apply_mirrored_correction(&self, points: &Vec) { - if !self.mirrored || points == null || points.len() < 3 { - return; - } - let bottom_left: ResultPoint = points[0]; - points[0] = points[2]; - points[2] = bottom_left; - // No need to 'fix' top-left and alignment pattern. - } -} - -// NEW FILE: version.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::decoder; - -/** - * See ISO 18004:2006 Annex D - * - * @author Sean Owen - */ - -/** - * See ISO 18004:2006 Annex D. - * Element i represents the raw version bits that specify version i + 7 - */ - const VERSION_DECODE_INFO: vec![Vec; 34] = vec![0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, 0x2542E, 0x26A64, 0x27541, 0x28C69, ] -; - - const VERSIONS: Vec = ::build_versions(); -pub struct Version { - - let version_number: i32; - - let alignment_pattern_centers: Vec; - - let ec_blocks: Vec; - - let total_codewords: i32; -} - -impl Version { - - fn new( version_number: i32, alignment_pattern_centers: &Vec, ec_blocks: &ECBlocks) -> Version { - let .versionNumber = version_number; - let .alignmentPatternCenters = alignment_pattern_centers; - let .ecBlocks = ec_blocks; - let mut total: i32 = 0; - let ec_codewords: i32 = ec_blocks[0].get_e_c_codewords_per_block(); - let ecb_array: Vec = ec_blocks[0].get_e_c_blocks(); - for let ec_block: ECB in ecb_array { - total += ec_block.get_count() * (ec_block.get_data_codewords() + ec_codewords); - } - let .totalCodewords = total; - } - - pub fn get_version_number(&self) -> i32 { - return self.version_number; - } - - pub fn get_alignment_pattern_centers(&self) -> Vec { - return self.alignment_pattern_centers; - } - - pub fn get_total_codewords(&self) -> i32 { - return self.total_codewords; - } - - pub fn get_dimension_for_version(&self) -> i32 { - return 17 + 4 * self.version_number; - } - - pub fn get_e_c_blocks_for_level(&self, ec_level: &ErrorCorrectionLevel) -> ECBlocks { - return self.ec_blocks[ec_level.ordinal()]; - } - - /** - *

Deduces version information purely from QR Code dimensions.

- * - * @param dimension dimension in modules - * @return Version for a QR Code of that dimension - * @throws FormatException if dimension is not 1 mod 4 - */ - pub fn get_provisional_version_for_dimension( dimension: i32) -> /* throws FormatException */Result> { - if dimension % 4 != 1 { - throw FormatException::get_format_instance(); - } - let tryResult1 = 0; - 'try1: loop { - { - return Ok(::get_version_for_number((dimension - 17) / 4)); - } - break 'try1 - } - match tryResult1 { - catch ( ignored: &IllegalArgumentException) { - throw FormatException::get_format_instance(); - } 0 => break - } - - } - - pub fn get_version_for_number( version_number: i32) -> Version { - if version_number < 1 || version_number > 40 { - throw IllegalArgumentException::new(); - } - return VERSIONS[version_number - 1]; - } - - fn decode_version_information( version_bits: i32) -> Version { - let best_difference: i32 = Integer::MAX_VALUE; - let best_version: i32 = 0; - { - let mut i: i32 = 0; - while i < VERSION_DECODE_INFO.len() { - { - let target_version: i32 = VERSION_DECODE_INFO[i]; - // Do the version info bits match exactly? done. - if target_version == version_bits { - return ::get_version_for_number(i + 7); - } - // Otherwise see if this is the closest to a real version info bit string - // we have seen so far - let bits_difference: i32 = FormatInformation::num_bits_differing(version_bits, target_version); - if bits_difference < best_difference { - best_version = i + 7; - best_difference = bits_difference; - } - } - i += 1; - } - } - - // differ in less than 8 bits. - if best_difference <= 3 { - return ::get_version_for_number(best_version); - } - // If we didn't find a close enough match, fail - return null; - } - - /** - * See ISO 18004:2006 Annex E - */ - fn build_function_pattern(&self) -> BitMatrix { - let dimension: i32 = self.get_dimension_for_version(); - let bit_matrix: BitMatrix = BitMatrix::new(dimension); - // Top left finder pattern + separator + format - bit_matrix.set_region(0, 0, 9, 9); - // Top right finder pattern + separator + format - bit_matrix.set_region(dimension - 8, 0, 8, 9); - // Bottom left finder pattern + separator + format - bit_matrix.set_region(0, dimension - 8, 9, 8); - // Alignment patterns - let max: i32 = self.alignment_pattern_centers.len(); - { - let mut x: i32 = 0; - while x < max { - { - let i: i32 = self.alignment_pattern_centers[x] - 2; - { - let mut y: i32 = 0; - while y < max { - { - if (x != 0 || (y != 0 && y != max - 1)) && (x != max - 1 || y != 0) { - bit_matrix.set_region(self.alignment_pattern_centers[y] - 2, i, 5, 5); - } - // else no o alignment patterns near the three finder patterns - } - y += 1; - } - } - - } - x += 1; - } - } - - // Vertical timing pattern - bit_matrix.set_region(6, 9, 1, dimension - 17); - // Horizontal timing pattern - bit_matrix.set_region(9, 6, dimension - 17, 1); - if self.version_number > 6 { - // Version info, top right - bit_matrix.set_region(dimension - 11, 0, 3, 6); - // Version info, bottom left - bit_matrix.set_region(0, dimension - 11, 6, 3); - } - return bit_matrix; - } - - /** - *

Encapsulates a set of error-correction blocks in one symbol version. Most versions will - * use blocks of differing sizes within one version, so, this encapsulates the parameters for - * each set of blocks. It also holds the number of error-correction codewords per block since it - * will be the same across all blocks within one version.

- */ - pub struct ECBlocks { - - let ec_codewords_per_block: i32; - - let ec_blocks: Vec; - } - - impl ECBlocks { - - fn new( ec_codewords_per_block: i32, ec_blocks: &ECB) -> ECBlocks { - let .ecCodewordsPerBlock = ec_codewords_per_block; - let .ecBlocks = ec_blocks; - } - - pub fn get_e_c_codewords_per_block(&self) -> i32 { - return self.ec_codewords_per_block; - } - - pub fn get_num_blocks(&self) -> i32 { - let mut total: i32 = 0; - for let ec_block: ECB in self.ec_blocks { - total += ec_block.get_count(); - } - return total; - } - - pub fn get_total_e_c_codewords(&self) -> i32 { - return self.ec_codewords_per_block * self.get_num_blocks(); - } - - pub fn get_e_c_blocks(&self) -> Vec { - return self.ec_blocks; - } - } - - - /** - *

Encapsulates the parameters for one error-correction block in one symbol version. - * This includes the number of data codewords, and the number of times a block with these - * parameters is used consecutively in the QR code version's format.

- */ - pub struct ECB { - - let count: i32; - - let data_codewords: i32; - } - - impl ECB { - - fn new( count: i32, data_codewords: i32) -> ECB { - let .count = count; - let .dataCodewords = data_codewords; - } - - pub fn get_count(&self) -> i32 { - return self.count; - } - - pub fn get_data_codewords(&self) -> i32 { - return self.data_codewords; - } - } - - - pub fn to_string(&self) -> String { - return String::value_of(self.version_number); - } - - /** - * See ISO 18004:2006 6.5.1 Table 9 - */ - fn build_versions() -> Vec { - return : vec![Version; 40] = vec![Version::new(1, , ECBlocks::new(7, ECB::new(1, 19)), ECBlocks::new(10, ECB::new(1, 16)), ECBlocks::new(13, ECB::new(1, 13)), ECBlocks::new(17, ECB::new(1, 9))), Version::new(2, : vec![i32; 2] = vec![6, 18, ] - , ECBlocks::new(10, ECB::new(1, 34)), ECBlocks::new(16, ECB::new(1, 28)), ECBlocks::new(22, ECB::new(1, 22)), ECBlocks::new(28, ECB::new(1, 16))), Version::new(3, : vec![i32; 2] = vec![6, 22, ] - , ECBlocks::new(15, ECB::new(1, 55)), ECBlocks::new(26, ECB::new(1, 44)), ECBlocks::new(18, ECB::new(2, 17)), ECBlocks::new(22, ECB::new(2, 13))), Version::new(4, : vec![i32; 2] = vec![6, 26, ] - , ECBlocks::new(20, ECB::new(1, 80)), ECBlocks::new(18, ECB::new(2, 32)), ECBlocks::new(26, ECB::new(2, 24)), ECBlocks::new(16, ECB::new(4, 9))), Version::new(5, : vec![i32; 2] = vec![6, 30, ] - , ECBlocks::new(26, ECB::new(1, 108)), ECBlocks::new(24, ECB::new(2, 43)), ECBlocks::new(18, ECB::new(2, 15), ECB::new(2, 16)), ECBlocks::new(22, ECB::new(2, 11), ECB::new(2, 12))), Version::new(6, : vec![i32; 2] = vec![6, 34, ] - , ECBlocks::new(18, ECB::new(2, 68)), ECBlocks::new(16, ECB::new(4, 27)), ECBlocks::new(24, ECB::new(4, 19)), ECBlocks::new(28, ECB::new(4, 15))), Version::new(7, : vec![i32; 3] = vec![6, 22, 38, ] - , ECBlocks::new(20, ECB::new(2, 78)), ECBlocks::new(18, ECB::new(4, 31)), ECBlocks::new(18, ECB::new(2, 14), ECB::new(4, 15)), ECBlocks::new(26, ECB::new(4, 13), ECB::new(1, 14))), Version::new(8, : vec![i32; 3] = vec![6, 24, 42, ] - , ECBlocks::new(24, ECB::new(2, 97)), ECBlocks::new(22, ECB::new(2, 38), ECB::new(2, 39)), ECBlocks::new(22, ECB::new(4, 18), ECB::new(2, 19)), ECBlocks::new(26, ECB::new(4, 14), ECB::new(2, 15))), Version::new(9, : vec![i32; 3] = vec![6, 26, 46, ] - , ECBlocks::new(30, ECB::new(2, 116)), ECBlocks::new(22, ECB::new(3, 36), ECB::new(2, 37)), ECBlocks::new(20, ECB::new(4, 16), ECB::new(4, 17)), ECBlocks::new(24, ECB::new(4, 12), ECB::new(4, 13))), Version::new(10, : vec![i32; 3] = vec![6, 28, 50, ] - , ECBlocks::new(18, ECB::new(2, 68), ECB::new(2, 69)), ECBlocks::new(26, ECB::new(4, 43), ECB::new(1, 44)), ECBlocks::new(24, ECB::new(6, 19), ECB::new(2, 20)), ECBlocks::new(28, ECB::new(6, 15), ECB::new(2, 16))), Version::new(11, : vec![i32; 3] = vec![6, 30, 54, ] - , ECBlocks::new(20, ECB::new(4, 81)), ECBlocks::new(30, ECB::new(1, 50), ECB::new(4, 51)), ECBlocks::new(28, ECB::new(4, 22), ECB::new(4, 23)), ECBlocks::new(24, ECB::new(3, 12), ECB::new(8, 13))), Version::new(12, : vec![i32; 3] = vec![6, 32, 58, ] - , ECBlocks::new(24, ECB::new(2, 92), ECB::new(2, 93)), ECBlocks::new(22, ECB::new(6, 36), ECB::new(2, 37)), ECBlocks::new(26, ECB::new(4, 20), ECB::new(6, 21)), ECBlocks::new(28, ECB::new(7, 14), ECB::new(4, 15))), Version::new(13, : vec![i32; 3] = vec![6, 34, 62, ] - , ECBlocks::new(26, ECB::new(4, 107)), ECBlocks::new(22, ECB::new(8, 37), ECB::new(1, 38)), ECBlocks::new(24, ECB::new(8, 20), ECB::new(4, 21)), ECBlocks::new(22, ECB::new(12, 11), ECB::new(4, 12))), Version::new(14, : vec![i32; 4] = vec![6, 26, 46, 66, ] - , ECBlocks::new(30, ECB::new(3, 115), ECB::new(1, 116)), ECBlocks::new(24, ECB::new(4, 40), ECB::new(5, 41)), ECBlocks::new(20, ECB::new(11, 16), ECB::new(5, 17)), ECBlocks::new(24, ECB::new(11, 12), ECB::new(5, 13))), Version::new(15, : vec![i32; 4] = vec![6, 26, 48, 70, ] - , ECBlocks::new(22, ECB::new(5, 87), ECB::new(1, 88)), ECBlocks::new(24, ECB::new(5, 41), ECB::new(5, 42)), ECBlocks::new(30, ECB::new(5, 24), ECB::new(7, 25)), ECBlocks::new(24, ECB::new(11, 12), ECB::new(7, 13))), Version::new(16, : vec![i32; 4] = vec![6, 26, 50, 74, ] - , ECBlocks::new(24, ECB::new(5, 98), ECB::new(1, 99)), ECBlocks::new(28, ECB::new(7, 45), ECB::new(3, 46)), ECBlocks::new(24, ECB::new(15, 19), ECB::new(2, 20)), ECBlocks::new(30, ECB::new(3, 15), ECB::new(13, 16))), Version::new(17, : vec![i32; 4] = vec![6, 30, 54, 78, ] - , ECBlocks::new(28, ECB::new(1, 107), ECB::new(5, 108)), ECBlocks::new(28, ECB::new(10, 46), ECB::new(1, 47)), ECBlocks::new(28, ECB::new(1, 22), ECB::new(15, 23)), ECBlocks::new(28, ECB::new(2, 14), ECB::new(17, 15))), Version::new(18, : vec![i32; 4] = vec![6, 30, 56, 82, ] - , ECBlocks::new(30, ECB::new(5, 120), ECB::new(1, 121)), ECBlocks::new(26, ECB::new(9, 43), ECB::new(4, 44)), ECBlocks::new(28, ECB::new(17, 22), ECB::new(1, 23)), ECBlocks::new(28, ECB::new(2, 14), ECB::new(19, 15))), Version::new(19, : vec![i32; 4] = vec![6, 30, 58, 86, ] - , ECBlocks::new(28, ECB::new(3, 113), ECB::new(4, 114)), ECBlocks::new(26, ECB::new(3, 44), ECB::new(11, 45)), ECBlocks::new(26, ECB::new(17, 21), ECB::new(4, 22)), ECBlocks::new(26, ECB::new(9, 13), ECB::new(16, 14))), Version::new(20, : vec![i32; 4] = vec![6, 34, 62, 90, ] - , ECBlocks::new(28, ECB::new(3, 107), ECB::new(5, 108)), ECBlocks::new(26, ECB::new(3, 41), ECB::new(13, 42)), ECBlocks::new(30, ECB::new(15, 24), ECB::new(5, 25)), ECBlocks::new(28, ECB::new(15, 15), ECB::new(10, 16))), Version::new(21, : vec![i32; 5] = vec![6, 28, 50, 72, 94, ] - , ECBlocks::new(28, ECB::new(4, 116), ECB::new(4, 117)), ECBlocks::new(26, ECB::new(17, 42)), ECBlocks::new(28, ECB::new(17, 22), ECB::new(6, 23)), ECBlocks::new(30, ECB::new(19, 16), ECB::new(6, 17))), Version::new(22, : vec![i32; 5] = vec![6, 26, 50, 74, 98, ] - , ECBlocks::new(28, ECB::new(2, 111), ECB::new(7, 112)), ECBlocks::new(28, ECB::new(17, 46)), ECBlocks::new(30, ECB::new(7, 24), ECB::new(16, 25)), ECBlocks::new(24, ECB::new(34, 13))), Version::new(23, : vec![i32; 5] = vec![6, 30, 54, 78, 102, ] - , ECBlocks::new(30, ECB::new(4, 121), ECB::new(5, 122)), ECBlocks::new(28, ECB::new(4, 47), ECB::new(14, 48)), ECBlocks::new(30, ECB::new(11, 24), ECB::new(14, 25)), ECBlocks::new(30, ECB::new(16, 15), ECB::new(14, 16))), Version::new(24, : vec![i32; 5] = vec![6, 28, 54, 80, 106, ] - , ECBlocks::new(30, ECB::new(6, 117), ECB::new(4, 118)), ECBlocks::new(28, ECB::new(6, 45), ECB::new(14, 46)), ECBlocks::new(30, ECB::new(11, 24), ECB::new(16, 25)), ECBlocks::new(30, ECB::new(30, 16), ECB::new(2, 17))), Version::new(25, : vec![i32; 5] = vec![6, 32, 58, 84, 110, ] - , ECBlocks::new(26, ECB::new(8, 106), ECB::new(4, 107)), ECBlocks::new(28, ECB::new(8, 47), ECB::new(13, 48)), ECBlocks::new(30, ECB::new(7, 24), ECB::new(22, 25)), ECBlocks::new(30, ECB::new(22, 15), ECB::new(13, 16))), Version::new(26, : vec![i32; 5] = vec![6, 30, 58, 86, 114, ] - , ECBlocks::new(28, ECB::new(10, 114), ECB::new(2, 115)), ECBlocks::new(28, ECB::new(19, 46), ECB::new(4, 47)), ECBlocks::new(28, ECB::new(28, 22), ECB::new(6, 23)), ECBlocks::new(30, ECB::new(33, 16), ECB::new(4, 17))), Version::new(27, : vec![i32; 5] = vec![6, 34, 62, 90, 118, ] - , ECBlocks::new(30, ECB::new(8, 122), ECB::new(4, 123)), ECBlocks::new(28, ECB::new(22, 45), ECB::new(3, 46)), ECBlocks::new(30, ECB::new(8, 23), ECB::new(26, 24)), ECBlocks::new(30, ECB::new(12, 15), ECB::new(28, 16))), Version::new(28, : vec![i32; 6] = vec![6, 26, 50, 74, 98, 122, ] - , ECBlocks::new(30, ECB::new(3, 117), ECB::new(10, 118)), ECBlocks::new(28, ECB::new(3, 45), ECB::new(23, 46)), ECBlocks::new(30, ECB::new(4, 24), ECB::new(31, 25)), ECBlocks::new(30, ECB::new(11, 15), ECB::new(31, 16))), Version::new(29, : vec![i32; 6] = vec![6, 30, 54, 78, 102, 126, ] - , ECBlocks::new(30, ECB::new(7, 116), ECB::new(7, 117)), ECBlocks::new(28, ECB::new(21, 45), ECB::new(7, 46)), ECBlocks::new(30, ECB::new(1, 23), ECB::new(37, 24)), ECBlocks::new(30, ECB::new(19, 15), ECB::new(26, 16))), Version::new(30, : vec![i32; 6] = vec![6, 26, 52, 78, 104, 130, ] - , ECBlocks::new(30, ECB::new(5, 115), ECB::new(10, 116)), ECBlocks::new(28, ECB::new(19, 47), ECB::new(10, 48)), ECBlocks::new(30, ECB::new(15, 24), ECB::new(25, 25)), ECBlocks::new(30, ECB::new(23, 15), ECB::new(25, 16))), Version::new(31, : vec![i32; 6] = vec![6, 30, 56, 82, 108, 134, ] - , ECBlocks::new(30, ECB::new(13, 115), ECB::new(3, 116)), ECBlocks::new(28, ECB::new(2, 46), ECB::new(29, 47)), ECBlocks::new(30, ECB::new(42, 24), ECB::new(1, 25)), ECBlocks::new(30, ECB::new(23, 15), ECB::new(28, 16))), Version::new(32, : vec![i32; 6] = vec![6, 34, 60, 86, 112, 138, ] - , ECBlocks::new(30, ECB::new(17, 115)), ECBlocks::new(28, ECB::new(10, 46), ECB::new(23, 47)), ECBlocks::new(30, ECB::new(10, 24), ECB::new(35, 25)), ECBlocks::new(30, ECB::new(19, 15), ECB::new(35, 16))), Version::new(33, : vec![i32; 6] = vec![6, 30, 58, 86, 114, 142, ] - , ECBlocks::new(30, ECB::new(17, 115), ECB::new(1, 116)), ECBlocks::new(28, ECB::new(14, 46), ECB::new(21, 47)), ECBlocks::new(30, ECB::new(29, 24), ECB::new(19, 25)), ECBlocks::new(30, ECB::new(11, 15), ECB::new(46, 16))), Version::new(34, : vec![i32; 6] = vec![6, 34, 62, 90, 118, 146, ] - , ECBlocks::new(30, ECB::new(13, 115), ECB::new(6, 116)), ECBlocks::new(28, ECB::new(14, 46), ECB::new(23, 47)), ECBlocks::new(30, ECB::new(44, 24), ECB::new(7, 25)), ECBlocks::new(30, ECB::new(59, 16), ECB::new(1, 17))), Version::new(35, : vec![i32; 7] = vec![6, 30, 54, 78, 102, 126, 150, ] - , ECBlocks::new(30, ECB::new(12, 121), ECB::new(7, 122)), ECBlocks::new(28, ECB::new(12, 47), ECB::new(26, 48)), ECBlocks::new(30, ECB::new(39, 24), ECB::new(14, 25)), ECBlocks::new(30, ECB::new(22, 15), ECB::new(41, 16))), Version::new(36, : vec![i32; 7] = vec![6, 24, 50, 76, 102, 128, 154, ] - , ECBlocks::new(30, ECB::new(6, 121), ECB::new(14, 122)), ECBlocks::new(28, ECB::new(6, 47), ECB::new(34, 48)), ECBlocks::new(30, ECB::new(46, 24), ECB::new(10, 25)), ECBlocks::new(30, ECB::new(2, 15), ECB::new(64, 16))), Version::new(37, : vec![i32; 7] = vec![6, 28, 54, 80, 106, 132, 158, ] - , ECBlocks::new(30, ECB::new(17, 122), ECB::new(4, 123)), ECBlocks::new(28, ECB::new(29, 46), ECB::new(14, 47)), ECBlocks::new(30, ECB::new(49, 24), ECB::new(10, 25)), ECBlocks::new(30, ECB::new(24, 15), ECB::new(46, 16))), Version::new(38, : vec![i32; 7] = vec![6, 32, 58, 84, 110, 136, 162, ] - , ECBlocks::new(30, ECB::new(4, 122), ECB::new(18, 123)), ECBlocks::new(28, ECB::new(13, 46), ECB::new(32, 47)), ECBlocks::new(30, ECB::new(48, 24), ECB::new(14, 25)), ECBlocks::new(30, ECB::new(42, 15), ECB::new(32, 16))), Version::new(39, : vec![i32; 7] = vec![6, 26, 54, 82, 110, 138, 166, ] - , ECBlocks::new(30, ECB::new(20, 117), ECB::new(4, 118)), ECBlocks::new(28, ECB::new(40, 47), ECB::new(7, 48)), ECBlocks::new(30, ECB::new(43, 24), ECB::new(22, 25)), ECBlocks::new(30, ECB::new(10, 15), ECB::new(67, 16))), Version::new(40, : vec![i32; 7] = vec![6, 30, 58, 86, 114, 142, 170, ] - , ECBlocks::new(30, ECB::new(19, 118), ECB::new(6, 119)), ECBlocks::new(28, ECB::new(18, 47), ECB::new(31, 48)), ECBlocks::new(30, ECB::new(34, 24), ECB::new(34, 25)), ECBlocks::new(30, ECB::new(20, 15), ECB::new(61, 16))), ] - ; - } -} - diff --git a/src/qrcode/detector.rs b/src/qrcode/detector.rs deleted file mode 100644 index 206690d..0000000 --- a/src/qrcode/detector.rs +++ /dev/null @@ -1,1555 +0,0 @@ -use crate::{ResultPoint,NotFoundException,ResultPointCallback,DecodeHintType,FormatException}; -use crate::common::{BitMatrix,DetectorResult,GridSampler,PerspectiveTransform}; -use crate::common::detector::{MathUtils}; -use crate::qrcode::decoder::Version; - - -// NEW FILE: alignment_pattern.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::detector; - -/** - *

Encapsulates an alignment pattern, which are the smaller square patterns found in - * all but the simplest QR Codes.

- * - * @author Sean Owen - */ -pub struct AlignmentPattern { - super: ResultPoint; - - let estimated_module_size: f32; -} - -impl AlignmentPattern { - - fn new( pos_x: f32, pos_y: f32, estimated_module_size: f32) -> AlignmentPattern { - super(pos_x, pos_y); - let .estimatedModuleSize = estimated_module_size; - } - - /** - *

Determines if this alignment pattern "about equals" an alignment pattern at the stated - * position and size -- meaning, it is at nearly the same center with nearly the same size.

- */ - fn about_equals(&self, module_size: f32, i: f32, j: f32) -> bool { - if Math::abs(i - get_y()) <= module_size && Math::abs(j - get_x()) <= module_size { - let module_size_diff: f32 = Math::abs(module_size - self.estimated_module_size); - return module_size_diff <= 1.0f || module_size_diff <= self.estimated_module_size; - } - return false; - } - - /** - * Combines this object's current estimate of a finder pattern position and module size - * with a new estimate. It returns a new {@code FinderPattern} containing an average of the two. - */ - fn combine_estimate(&self, i: f32, j: f32, new_module_size: f32) -> AlignmentPattern { - let combined_x: f32 = (get_x() + j) / 2.0f; - let combined_y: f32 = (get_y() + i) / 2.0f; - let combined_module_size: f32 = (self.estimated_module_size + new_module_size) / 2.0f; - return AlignmentPattern::new(combined_x, combined_y, combined_module_size); - } -} - -// NEW FILE: alignment_pattern_finder.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::detector; - -/** - *

This class attempts to find alignment patterns in a QR Code. Alignment patterns look like finder - * patterns but are smaller and appear at regular intervals throughout the image.

- * - *

At the moment this only looks for the bottom-right alignment pattern.

- * - *

This is mostly a simplified copy of {@link FinderPatternFinder}. It is copied, - * pasted and stripped down here for maximum performance but does unfortunately duplicate - * some code.

- * - *

This class is thread-safe but not reentrant. Each thread must allocate its own object.

- * - * @author Sean Owen - */ -struct AlignmentPatternFinder { - - let image: BitMatrix; - - let possible_centers: List; - - let start_x: i32; - - let start_y: i32; - - let width: i32; - - let height: i32; - - let module_size: f32; - - let cross_check_state_count: Vec; - - let result_point_callback: ResultPointCallback; -} - -impl AlignmentPatternFinder { - - /** - *

Creates a finder that will look in a portion of the whole image.

- * - * @param image image to search - * @param startX left column from which to start searching - * @param startY top row from which to start searching - * @param width width of region to search - * @param height height of region to search - * @param moduleSize estimated module size so far - */ - fn new( image: &BitMatrix, start_x: i32, start_y: i32, width: i32, height: i32, module_size: f32, result_point_callback: &ResultPointCallback) -> AlignmentPatternFinder { - let .image = image; - let .possibleCenters = ArrayList<>::new(5); - let .startX = start_x; - let .startY = start_y; - let .width = width; - let .height = height; - let .moduleSize = module_size; - let .crossCheckStateCount = : [i32; 3] = [0; 3]; - let .resultPointCallback = result_point_callback; - } - - /** - *

This method attempts to find the bottom-right alignment pattern in the image. It is a bit messy since - * it's pretty performance-critical and so is written to be fast foremost.

- * - * @return {@link AlignmentPattern} if found - * @throws NotFoundException if not found - */ - fn find(&self) -> /* throws NotFoundException */Result> { - let start_x: i32 = self.startX; - let height: i32 = self.height; - let max_j: i32 = start_x + self.width; - let middle_i: i32 = self.start_y + (height / 2); - // We are looking for black/white/black modules in 1:1:1 ratio; - // this tracks the number of black/white/black modules seen so far - let state_count: [i32; 3] = [0; 3]; - { - let i_gen: i32 = 0; - while i_gen < height { - { - // Search from middle outwards - let i: i32 = middle_i + ( if (i_gen & 0x01) == 0 { (i_gen + 1) / 2 } else { -((i_gen + 1) / 2) }); - state_count[0] = 0; - state_count[1] = 0; - state_count[2] = 0; - let mut j: i32 = start_x; - // white run continued to the left of the start point - while j < max_j && !self.image.get(j, i) { - j += 1; - } - let current_state: i32 = 0; - while j < max_j { - if self.image.get(j, i) { - // Black pixel - if current_state == 1 { - // Counting black pixels - state_count[1] += 1; - } else { - // Counting white pixels - if current_state == 2 { - // A winner? - if self.found_pattern_cross(&state_count) { - // Yes - let confirmed: AlignmentPattern = self.handle_possible_center(&state_count, i, j); - if confirmed != null { - return Ok(confirmed); - } - } - state_count[0] = state_count[2]; - state_count[1] = 1; - state_count[2] = 0; - current_state = 1; - } else { - state_count[current_state += 1] += 1; - } - } - } else { - // White pixel - if current_state == 1 { - // Counting black pixels - current_state += 1; - } - state_count[current_state] += 1; - } - j += 1; - } - if self.found_pattern_cross(&state_count) { - let confirmed: AlignmentPattern = self.handle_possible_center(&state_count, i, max_j); - if confirmed != null { - return Ok(confirmed); - } - } - } - i_gen += 1; - } - } - - // any guess at all, return it. - if !self.possible_centers.is_empty() { - return Ok(self.possible_centers.get(0)); - } - throw NotFoundException::get_not_found_instance(); - } - - /** - * Given a count of black/white/black pixels just seen and an end position, - * figures the location of the center of this black/white/black run. - */ - fn center_from_end( state_count: &Vec, end: i32) -> f32 { - return (end - state_count[2]) - state_count[1] / 2.0f; - } - - /** - * @param stateCount count of black/white/black pixels just read - * @return true iff the proportions of the counts is close enough to the 1/1/1 ratios - * used by alignment patterns to be considered a match - */ - fn found_pattern_cross(&self, state_count: &Vec) -> bool { - let module_size: f32 = self.moduleSize; - let max_variance: f32 = module_size / 2.0f; - { - let mut i: i32 = 0; - while i < 3 { - { - if Math::abs(module_size - state_count[i]) >= max_variance { - return false; - } - } - i += 1; - } - } - - return true; - } - - /** - *

After a horizontal scan finds a potential alignment pattern, this method - * "cross-checks" by scanning down vertically through the center of the possible - * alignment pattern to see if the same proportion is detected.

- * - * @param startI row where an alignment pattern was detected - * @param centerJ center of the section that appears to cross an alignment pattern - * @param maxCount maximum reasonable number of modules that should be - * observed in any reading state, based on the results of the horizontal scan - * @return vertical center of alignment pattern, or {@link Float#NaN} if not found - */ - fn cross_check_vertical(&self, start_i: i32, center_j: i32, max_count: i32, original_state_count_total: i32) -> f32 { - let image: BitMatrix = self.image; - let max_i: i32 = image.get_height(); - let state_count: Vec = self.cross_check_state_count; - state_count[0] = 0; - state_count[1] = 0; - state_count[2] = 0; - // Start counting up from center - let mut i: i32 = start_i; - while i >= 0 && image.get(center_j, i) && state_count[1] <= max_count { - state_count[1] += 1; - i -= 1; - } - // If already too many modules in this state or ran off the edge: - if i < 0 || state_count[1] > max_count { - return Float::NaN; - } - while i >= 0 && !image.get(center_j, i) && state_count[0] <= max_count { - state_count[0] += 1; - i -= 1; - } - if state_count[0] > max_count { - return Float::NaN; - } - // Now also count down from center - i = start_i + 1; - while i < max_i && image.get(center_j, i) && state_count[1] <= max_count { - state_count[1] += 1; - i += 1; - } - if i == max_i || state_count[1] > max_count { - return Float::NaN; - } - while i < max_i && !image.get(center_j, i) && state_count[2] <= max_count { - state_count[2] += 1; - i += 1; - } - if state_count[2] > max_count { - return Float::NaN; - } - let state_count_total: i32 = state_count[0] + state_count[1] + state_count[2]; - if 5 * Math::abs(state_count_total - original_state_count_total) >= 2 * original_state_count_total { - return Float::NaN; - } - return if self.found_pattern_cross(&state_count) { ::center_from_end(&state_count, i) } else { Float::NaN }; - } - - /** - *

This is called when a horizontal scan finds a possible alignment pattern. It will - * cross check with a vertical scan, and if successful, will see if this pattern had been - * found on a previous horizontal scan. If so, we consider it confirmed and conclude we have - * found the alignment pattern.

- * - * @param stateCount reading state module counts from horizontal scan - * @param i row where alignment pattern may be found - * @param j end of possible alignment pattern in row - * @return {@link AlignmentPattern} if we have found the same pattern twice, or null if not - */ - fn handle_possible_center(&self, state_count: &Vec, i: i32, j: i32) -> AlignmentPattern { - let state_count_total: i32 = state_count[0] + state_count[1] + state_count[2]; - let center_j: f32 = ::center_from_end(&state_count, j); - let center_i: f32 = self.cross_check_vertical(i, center_j as i32, 2 * state_count[1], state_count_total); - if !Float::is_na_n(center_i) { - let estimated_module_size: f32 = (state_count[0] + state_count[1] + state_count[2]) / 3.0f; - for let center: AlignmentPattern in self.possible_centers { - // Look for about the same center and module size: - if center.about_equals(estimated_module_size, center_i, center_j) { - return center.combine_estimate(center_i, center_j, estimated_module_size); - } - } - // Hadn't found this before; save it - let point: AlignmentPattern = AlignmentPattern::new(center_j, center_i, estimated_module_size); - self.possible_centers.add(point); - if self.result_point_callback != null { - self.result_point_callback.found_possible_result_point(point); - } - } - return null; - } -} - -// NEW FILE: detector.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::detector; - -/** - *

Encapsulates logic that can detect a QR Code in an image, even if the QR Code - * is rotated or skewed, or partially obscured.

- * - * @author Sean Owen - */ -pub struct Detector { - - let image: BitMatrix; - - let result_point_callback: ResultPointCallback; -} - -impl Detector { - - pub fn new( image: &BitMatrix) -> Detector { - let .image = image; - } - - pub fn get_image(&self) -> BitMatrix { - return self.image; - } - - pub fn get_result_point_callback(&self) -> ResultPointCallback { - return self.result_point_callback; - } - - /** - *

Detects a QR Code in an image.

- * - * @return {@link DetectorResult} encapsulating results of detecting a QR Code - * @throws NotFoundException if QR Code cannot be found - * @throws FormatException if a QR Code cannot be decoded - */ - pub fn detect(&self) -> /* throws NotFoundException, FormatException */Result> { - return Ok(self.detect(null)); - } - - /** - *

Detects a QR Code in an image.

- * - * @param hints optional hints to detector - * @return {@link DetectorResult} encapsulating results of detecting a QR Code - * @throws NotFoundException if QR Code cannot be found - * @throws FormatException if a QR Code cannot be decoded - */ - pub fn detect(&self, hints: &Map) -> /* throws NotFoundException, FormatException */Result> { - self.result_point_callback = if hints == null { null } else { hints.get(DecodeHintType::NEED_RESULT_POINT_CALLBACK) as ResultPointCallback }; - let finder: FinderPatternFinder = FinderPatternFinder::new(self.image, self.result_point_callback); - let info: FinderPatternInfo = finder.find(&hints); - return Ok(self.process_finder_pattern_info(info)); - } - - pub fn process_finder_pattern_info(&self, info: &FinderPatternInfo) -> /* throws NotFoundException, FormatException */Result> { - let top_left: FinderPattern = info.get_top_left(); - let top_right: FinderPattern = info.get_top_right(); - let bottom_left: FinderPattern = info.get_bottom_left(); - let module_size: f32 = self.calculate_module_size(top_left, top_right, bottom_left); - if module_size < 1.0f { - throw NotFoundException::get_not_found_instance(); - } - let dimension: i32 = ::compute_dimension(top_left, top_right, bottom_left, module_size); - let provisional_version: Version = Version::get_provisional_version_for_dimension(dimension); - let modules_between_f_p_centers: i32 = provisional_version.get_dimension_for_version() - 7; - let alignment_pattern: AlignmentPattern = null; - // Anything above version 1 has an alignment pattern - if provisional_version.get_alignment_pattern_centers().len() > 0 { - // Guess where a "bottom right" finder pattern would have been - let bottom_right_x: f32 = top_right.get_x() - top_left.get_x() + bottom_left.get_x(); - let bottom_right_y: f32 = top_right.get_y() - top_left.get_y() + bottom_left.get_y(); - // Estimate that alignment pattern is closer by 3 modules - // from "bottom right" to known top left location - let correction_to_top_left: f32 = 1.0f - 3.0f / modules_between_f_p_centers; - let est_alignment_x: i32 = (top_left.get_x() + correction_to_top_left * (bottom_right_x - top_left.get_x())) as i32; - let est_alignment_y: i32 = (top_left.get_y() + correction_to_top_left * (bottom_right_y - top_left.get_y())) as i32; - // Kind of arbitrary -- expand search radius before giving up - { - let mut i: i32 = 4; - while i <= 16 { - { - let tryResult1 = 0; - 'try1: loop { - { - alignment_pattern = self.find_alignment_in_region(module_size, est_alignment_x, est_alignment_y, i); - break; - } - break 'try1 - } - match tryResult1 { - catch ( re: &NotFoundException) { - } 0 => break - } - - } - i <<= 1; - } - } - - // If we didn't find alignment pattern... well try anyway without it - } - let transform: PerspectiveTransform = ::create_transform(top_left, top_right, bottom_left, alignment_pattern, dimension); - let bits: BitMatrix = ::sample_grid(self.image, transform, dimension); - let mut points: Vec; - if alignment_pattern == null { - points = : vec![ResultPoint; 3] = vec![bottom_left, top_left, top_right, ] - ; - } else { - points = : vec![ResultPoint; 4] = vec![bottom_left, top_left, top_right, alignment_pattern, ] - ; - } - return Ok(DetectorResult::new(bits, points)); - } - - fn create_transform( top_left: &ResultPoint, top_right: &ResultPoint, bottom_left: &ResultPoint, alignment_pattern: &ResultPoint, dimension: i32) -> PerspectiveTransform { - let dim_minus_three: f32 = dimension - 3.5f; - let bottom_right_x: f32; - let bottom_right_y: f32; - let source_bottom_right_x: f32; - let source_bottom_right_y: f32; - if alignment_pattern != null { - bottom_right_x = alignment_pattern.get_x(); - bottom_right_y = alignment_pattern.get_y(); - source_bottom_right_x = dim_minus_three - 3.0f; - source_bottom_right_y = source_bottom_right_x; - } else { - // Don't have an alignment pattern, just make up the bottom-right point - bottom_right_x = (top_right.get_x() - top_left.get_x()) + bottom_left.get_x(); - bottom_right_y = (top_right.get_y() - top_left.get_y()) + bottom_left.get_y(); - source_bottom_right_x = dim_minus_three; - source_bottom_right_y = dim_minus_three; - } - return PerspectiveTransform::quadrilateral_to_quadrilateral(3.5f, 3.5f, dim_minus_three, 3.5f, source_bottom_right_x, source_bottom_right_y, 3.5f, dim_minus_three, &top_left.get_x(), &top_left.get_y(), &top_right.get_x(), &top_right.get_y(), bottom_right_x, bottom_right_y, &bottom_left.get_x(), &bottom_left.get_y()); - } - - fn sample_grid( image: &BitMatrix, transform: &PerspectiveTransform, dimension: i32) -> /* throws NotFoundException */Result> { - let sampler: GridSampler = GridSampler::get_instance(); - return Ok(sampler.sample_grid(image, dimension, dimension, transform)); - } - - /** - *

Computes the dimension (number of modules on a size) of the QR Code based on the position - * of the finder patterns and estimated module size.

- */ - fn compute_dimension( top_left: &ResultPoint, top_right: &ResultPoint, bottom_left: &ResultPoint, module_size: f32) -> /* throws NotFoundException */Result> { - let tltr_centers_dimension: i32 = MathUtils::round(ResultPoint::distance(top_left, top_right) / module_size); - let tlbl_centers_dimension: i32 = MathUtils::round(ResultPoint::distance(top_left, bottom_left) / module_size); - let mut dimension: i32 = ((tltr_centers_dimension + tlbl_centers_dimension) / 2) + 7; - match // mod 4 - dimension & 0x03 { - 0 => - { - dimension += 1; - break; - } - // 1? do nothing - 2 => - { - dimension -= 1; - break; - } - 3 => - { - throw NotFoundException::get_not_found_instance(); - } - } - return Ok(dimension); - } - - /** - *

Computes an average estimated module size based on estimated derived from the positions - * of the three finder patterns.

- * - * @param topLeft detected top-left finder pattern center - * @param topRight detected top-right finder pattern center - * @param bottomLeft detected bottom-left finder pattern center - * @return estimated module size - */ - pub fn calculate_module_size(&self, top_left: &ResultPoint, top_right: &ResultPoint, bottom_left: &ResultPoint) -> f32 { - // Take the average - return (self.calculate_module_size_one_way(top_left, top_right) + self.calculate_module_size_one_way(top_left, bottom_left)) / 2.0f; - } - - /** - *

Estimates module size based on two finder patterns -- it uses - * {@link #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int)} to figure the - * width of each, measuring along the axis between their centers.

- */ - fn calculate_module_size_one_way(&self, pattern: &ResultPoint, other_pattern: &ResultPoint) -> f32 { - let module_size_est1: f32 = self.size_of_black_white_black_run_both_ways(pattern.get_x() as i32, pattern.get_y() as i32, other_pattern.get_x() as i32, other_pattern.get_y() as i32); - let module_size_est2: f32 = self.size_of_black_white_black_run_both_ways(other_pattern.get_x() as i32, other_pattern.get_y() as i32, pattern.get_x() as i32, pattern.get_y() as i32); - if Float::is_na_n(module_size_est1) { - return module_size_est2 / 7.0f; - } - if Float::is_na_n(module_size_est2) { - return module_size_est1 / 7.0f; - } - // and 1 white and 1 black module on either side. Ergo, divide sum by 14. - return (module_size_est1 + module_size_est2) / 14.0f; - } - - /** - * See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of - * a finder pattern by looking for a black-white-black run from the center in the direction - * of another point (another finder pattern center), and in the opposite direction too. - */ - fn size_of_black_white_black_run_both_ways(&self, from_x: i32, from_y: i32, to_x: i32, to_y: i32) -> f32 { - let mut result: f32 = self.size_of_black_white_black_run(from_x, from_y, to_x, to_y); - // Now count other way -- don't run off image though of course - let mut scale: f32 = 1.0f; - let other_to_x: i32 = from_x - (to_x - from_x); - if other_to_x < 0 { - scale = from_x / (from_x - other_to_x) as f32; - other_to_x = 0; - } else if other_to_x >= self.image.get_width() { - scale = (self.image.get_width() - 1.0 - from_x) / (other_to_x - from_x) as f32; - other_to_x = self.image.get_width() - 1; - } - let other_to_y: i32 = (from_y - (to_y - from_y) * scale) as i32; - scale = 1.0f; - if other_to_y < 0 { - scale = from_y / (from_y - other_to_y) as f32; - other_to_y = 0; - } else if other_to_y >= self.image.get_height() { - scale = (self.image.get_height() - 1.0 - from_y) / (other_to_y - from_y) as f32; - other_to_y = self.image.get_height() - 1; - } - other_to_x = (from_x + (other_to_x - from_x) * scale) as i32; - result += self.size_of_black_white_black_run(from_x, from_y, other_to_x, other_to_y); - // Middle pixel is double-counted this way; subtract 1 - return result - 1.0f; - } - - /** - *

This method traces a line from a point in the image, in the direction towards another point. - * It begins in a black region, and keeps going until it finds white, then black, then white again. - * It reports the distance from the start to this point.

- * - *

This is used when figuring out how wide a finder pattern is, when the finder pattern - * may be skewed or rotated.

- */ - fn size_of_black_white_black_run(&self, from_x: i32, from_y: i32, to_x: i32, to_y: i32) -> f32 { - // Mild variant of Bresenham's algorithm; - // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm - let steep: bool = Math::abs(to_y - from_y) > Math::abs(to_x - from_x); - if steep { - let mut temp: i32 = from_x; - from_x = from_y; - from_y = temp; - temp = to_x; - to_x = to_y; - to_y = temp; - } - let dx: i32 = Math::abs(to_x - from_x); - let dy: i32 = Math::abs(to_y - from_y); - let mut error: i32 = -dx / 2; - let xstep: i32 = if from_x < to_x { 1 } else { -1 }; - let ystep: i32 = if from_y < to_y { 1 } else { -1 }; - // In black pixels, looking for white, first or second time. - let mut state: i32 = 0; - // Loop up until x == toX, but not beyond - let x_limit: i32 = to_x + xstep; - { - let mut x: i32 = from_x, let mut y: i32 = from_y; - while x != x_limit { - { - let real_x: i32 = if steep { y } else { x }; - let real_y: i32 = if steep { x } else { y }; - // color, advance to next state or end if we are in state 2 already - if (state == 1) == self.image.get(real_x, real_y) { - if state == 2 { - return MathUtils::distance(x, y, from_x, from_y); - } - state += 1; - } - error += dy; - if error > 0 { - if y == to_y { - break; - } - y += ystep; - error -= dx; - } - } - x += xstep; - } - } - - // small approximation; (toX+xStep,toY+yStep) might be really correct. Ignore this. - if state == 2 { - return MathUtils::distance(to_x + xstep, to_y, from_x, from_y); - } - // else we didn't find even black-white-black; no estimate is really possible - return Float::NaN; - } - - /** - *

Attempts to locate an alignment pattern in a limited region of the image, which is - * guessed to contain it. This method uses {@link AlignmentPattern}.

- * - * @param overallEstModuleSize estimated module size so far - * @param estAlignmentX x coordinate of center of area probably containing alignment pattern - * @param estAlignmentY y coordinate of above - * @param allowanceFactor number of pixels in all directions to search from the center - * @return {@link AlignmentPattern} if found, or null otherwise - * @throws NotFoundException if an unexpected error occurs during detection - */ - pub fn find_alignment_in_region(&self, overall_est_module_size: f32, est_alignment_x: i32, est_alignment_y: i32, allowance_factor: f32) -> /* throws NotFoundException */Result> { - // Look for an alignment pattern (3 modules in size) around where it - // should be - let allowance: i32 = (allowance_factor * overall_est_module_size) as i32; - let alignment_area_left_x: i32 = Math::max(0, est_alignment_x - allowance); - let alignment_area_right_x: i32 = Math::min(self.image.get_width() - 1, est_alignment_x + allowance); - if alignment_area_right_x - alignment_area_left_x < overall_est_module_size * 3.0 { - throw NotFoundException::get_not_found_instance(); - } - let alignment_area_top_y: i32 = Math::max(0, est_alignment_y - allowance); - let alignment_area_bottom_y: i32 = Math::min(self.image.get_height() - 1, est_alignment_y + allowance); - if alignment_area_bottom_y - alignment_area_top_y < overall_est_module_size * 3.0 { - throw NotFoundException::get_not_found_instance(); - } - let alignment_finder: AlignmentPatternFinder = AlignmentPatternFinder::new(self.image, alignment_area_left_x, alignment_area_top_y, alignment_area_right_x - alignment_area_left_x, alignment_area_bottom_y - alignment_area_top_y, overall_est_module_size, self.result_point_callback); - return Ok(alignment_finder.find()); - } -} - -// NEW FILE: finder_pattern.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::detector; - -/** - *

Encapsulates a finder pattern, which are the three square patterns found in - * the corners of QR Codes. It also encapsulates a count of similar finder patterns, - * as a convenience to the finder's bookkeeping.

- * - * @author Sean Owen - */ -pub struct FinderPattern { - super: ResultPoint; - - let estimated_module_size: f32; - - let count: i32; -} - -impl FinderPattern { - - fn new( pos_x: f32, pos_y: f32, estimated_module_size: f32) -> FinderPattern { - this(pos_x, pos_y, estimated_module_size, 1); - } - - fn new( pos_x: f32, pos_y: f32, estimated_module_size: f32, count: i32) -> FinderPattern { - super(pos_x, pos_y); - let .estimatedModuleSize = estimated_module_size; - let .count = count; - } - - pub fn get_estimated_module_size(&self) -> f32 { - return self.estimated_module_size; - } - - pub fn get_count(&self) -> i32 { - return self.count; - } - - /** - *

Determines if this finder pattern "about equals" a finder pattern at the stated - * position and size -- meaning, it is at nearly the same center with nearly the same size.

- */ - fn about_equals(&self, module_size: f32, i: f32, j: f32) -> bool { - if Math::abs(i - get_y()) <= module_size && Math::abs(j - get_x()) <= module_size { - let module_size_diff: f32 = Math::abs(module_size - self.estimated_module_size); - return module_size_diff <= 1.0f || module_size_diff <= self.estimated_module_size; - } - return false; - } - - /** - * Combines this object's current estimate of a finder pattern position and module size - * with a new estimate. It returns a new {@code FinderPattern} containing a weighted average - * based on count. - */ - fn combine_estimate(&self, i: f32, j: f32, new_module_size: f32) -> FinderPattern { - let combined_count: i32 = self.count + 1; - let combined_x: f32 = (self.count * get_x() + j) / combined_count; - let combined_y: f32 = (self.count * get_y() + i) / combined_count; - let combined_module_size: f32 = (self.count * self.estimated_module_size + new_module_size) / combined_count; - return FinderPattern::new(combined_x, combined_y, combined_module_size, combined_count); - } -} - -// NEW FILE: finder_pattern_finder.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::detector; - -/** - *

This class attempts to find finder patterns in a QR Code. Finder patterns are the square - * markers at three corners of a QR Code.

- * - *

This class is thread-safe but not reentrant. Each thread must allocate its own object. - * - * @author Sean Owen - */ - - const CENTER_QUORUM: i32 = 2; - - let module_comparator: EstimatedModuleComparator = EstimatedModuleComparator::new(); - -// 1 pixel/module times 3 modules/center - const MIN_SKIP: i32 = 3; - -// support up to version 20 for mobile clients - const MAX_MODULES: i32 = 97; -pub struct FinderPatternFinder { - - let image: BitMatrix; - - let possible_centers: List; - - let has_skipped: bool; - - let cross_check_state_count: Vec; - - let result_point_callback: ResultPointCallback; -} - -impl FinderPatternFinder { - - /** - *

Creates a finder that will search the image for three finder patterns.

- * - * @param image image to search - */ - pub fn new( image: &BitMatrix) -> FinderPatternFinder { - this(image, null); - } - - pub fn new( image: &BitMatrix, result_point_callback: &ResultPointCallback) -> FinderPatternFinder { - let .image = image; - let .possibleCenters = ArrayList<>::new(); - let .crossCheckStateCount = : [i32; 5] = [0; 5]; - let .resultPointCallback = result_point_callback; - } - - pub fn get_image(&self) -> BitMatrix { - return self.image; - } - - pub fn get_possible_centers(&self) -> List { - return self.possible_centers; - } - - fn find(&self, hints: &Map) -> /* throws NotFoundException */Result> { - let try_harder: bool = hints != null && hints.contains_key(DecodeHintType::TRY_HARDER); - let max_i: i32 = self.image.get_height(); - let max_j: i32 = self.image.get_width(); - // We are looking for black/white/black/white/black modules in - // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far - // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the - // image, and then account for the center being 3 modules in size. This gives the smallest - // number of pixels the center could be, so skip this often. When trying harder, look for all - // QR versions regardless of how dense they are. - let i_skip: i32 = (3 * max_i) / (4 * MAX_MODULES); - if i_skip < MIN_SKIP || try_harder { - i_skip = MIN_SKIP; - } - let mut done: bool = false; - let state_count: [i32; 5] = [0; 5]; - { - let mut i: i32 = i_skip - 1; - while i < max_i && !done { - { - // Get a row of black/white values - ::do_clear_counts(&state_count); - let current_state: i32 = 0; - { - let mut j: i32 = 0; - while j < max_j { - { - if self.image.get(j, i) { - // Black pixel - if (current_state & 1) == 1 { - // Counting white pixels - current_state += 1; - } - state_count[current_state] += 1; - } else { - // White pixel - if (current_state & 1) == 0 { - // Counting black pixels - if current_state == 4 { - // A winner? - if ::found_pattern_cross(&state_count) { - // Yes - let confirmed: bool = self.handle_possible_center(&state_count, i, j); - if confirmed { - // Start examining every other line. Checking each line turned out to be too - // expensive and didn't improve performance. - i_skip = 2; - if self.has_skipped { - done = self.have_multiply_confirmed_centers(); - } else { - let row_skip: i32 = self.find_row_skip(); - if row_skip > state_count[2] { - // Skip rows between row of lower confirmed center - // and top of presumed third confirmed center - // but back up a bit to get a full chance of detecting - // it, entire width of center of finder pattern - // Skip by rowSkip, but back off by stateCount[2] (size of last center - // of pattern we saw) to be conservative, and also back off by iSkip which - // is about to be re-added - i += row_skip - state_count[2] - i_skip; - j = max_j - 1; - } - } - } else { - ::do_shift_counts2(&state_count); - current_state = 3; - continue; - } - // Clear state to start looking again - current_state = 0; - ::do_clear_counts(&state_count); - } else { - // No, shift counts back by two - ::do_shift_counts2(&state_count); - current_state = 3; - } - } else { - state_count[current_state += 1] += 1; - } - } else { - // Counting white pixels - state_count[current_state] += 1; - } - } - } - j += 1; - } - } - - if ::found_pattern_cross(&state_count) { - let confirmed: bool = self.handle_possible_center(&state_count, i, max_j); - if confirmed { - i_skip = state_count[0]; - if self.has_skipped { - // Found a third one - done = self.have_multiply_confirmed_centers(); - } - } - } - } - i += i_skip; - } - } - - let pattern_info: Vec = self.select_best_patterns(); - ResultPoint::order_best_patterns(pattern_info); - return Ok(FinderPatternInfo::new(pattern_info)); - } - - /** - * Given a count of black/white/black/white/black pixels just seen and an end position, - * figures the location of the center of this run. - */ - fn center_from_end( state_count: &Vec, end: i32) -> f32 { - return (end - state_count[4] - state_count[3]) - state_count[2] / 2.0f; - } - - /** - * @param stateCount count of black/white/black/white/black pixels just read - * @return true iff the proportions of the counts is close enough to the 1/1/3/1/1 ratios - * used by finder patterns to be considered a match - */ - pub fn found_pattern_cross( state_count: &Vec) -> bool { - let total_module_size: i32 = 0; - { - let mut i: i32 = 0; - while i < 5 { - { - let count: i32 = state_count[i]; - if count == 0 { - return false; - } - total_module_size += count; - } - i += 1; - } - } - - if total_module_size < 7 { - return false; - } - let module_size: f32 = total_module_size / 7.0f; - let max_variance: f32 = module_size / 2.0f; - // Allow less than 50% variance from 1-1-3-1-1 proportions - return Math::abs(module_size - state_count[0]) < max_variance && Math::abs(module_size - state_count[1]) < max_variance && Math::abs(3.0f * module_size - state_count[2]) < 3.0 * max_variance && Math::abs(module_size - state_count[3]) < max_variance && Math::abs(module_size - state_count[4]) < max_variance; - } - - /** - * @param stateCount count of black/white/black/white/black pixels just read - * @return true iff the proportions of the counts is close enough to the 1/1/3/1/1 ratios - * used by finder patterns to be considered a match - */ - pub fn found_pattern_diagonal( state_count: &Vec) -> bool { - let total_module_size: i32 = 0; - { - let mut i: i32 = 0; - while i < 5 { - { - let count: i32 = state_count[i]; - if count == 0 { - return false; - } - total_module_size += count; - } - i += 1; - } - } - - if total_module_size < 7 { - return false; - } - let module_size: f32 = total_module_size / 7.0f; - let max_variance: f32 = module_size / 1.333f; - // Allow less than 75% variance from 1-1-3-1-1 proportions - return Math::abs(module_size - state_count[0]) < max_variance && Math::abs(module_size - state_count[1]) < max_variance && Math::abs(3.0f * module_size - state_count[2]) < 3.0 * max_variance && Math::abs(module_size - state_count[3]) < max_variance && Math::abs(module_size - state_count[4]) < max_variance; - } - - fn get_cross_check_state_count(&self) -> Vec { - ::do_clear_counts(&self.cross_check_state_count); - return self.cross_check_state_count; - } - - pub fn clear_counts(&self, counts: &Vec) { - ::do_clear_counts(&counts); - } - - pub fn shift_counts2(&self, state_count: &Vec) { - ::do_shift_counts2(&state_count); - } - - pub fn do_clear_counts( counts: &Vec) { - Arrays::fill(&counts, 0); - } - - pub fn do_shift_counts2( state_count: &Vec) { - state_count[0] = state_count[2]; - state_count[1] = state_count[3]; - state_count[2] = state_count[4]; - state_count[3] = 1; - state_count[4] = 0; - } - - /** - * After a vertical and horizontal scan finds a potential finder pattern, this method - * "cross-cross-cross-checks" by scanning down diagonally through the center of the possible - * finder pattern to see if the same proportion is detected. - * - * @param centerI row where a finder pattern was detected - * @param centerJ center of the section that appears to cross a finder pattern - * @return true if proportions are withing expected limits - */ - fn cross_check_diagonal(&self, center_i: i32, center_j: i32) -> bool { - let state_count: Vec = self.get_cross_check_state_count(); - // Start counting up, left from center finding black center mass - let mut i: i32 = 0; - while center_i >= i && center_j >= i && self.image.get(center_j - i, center_i - i) { - state_count[2] += 1; - i += 1; - } - if state_count[2] == 0 { - return false; - } - // Continue up, left finding white space - while center_i >= i && center_j >= i && !self.image.get(center_j - i, center_i - i) { - state_count[1] += 1; - i += 1; - } - if state_count[1] == 0 { - return false; - } - // Continue up, left finding black border - while center_i >= i && center_j >= i && self.image.get(center_j - i, center_i - i) { - state_count[0] += 1; - i += 1; - } - if state_count[0] == 0 { - return false; - } - let max_i: i32 = self.image.get_height(); - let max_j: i32 = self.image.get_width(); - // Now also count down, right from center - i = 1; - while center_i + i < max_i && center_j + i < max_j && self.image.get(center_j + i, center_i + i) { - state_count[2] += 1; - i += 1; - } - while center_i + i < max_i && center_j + i < max_j && !self.image.get(center_j + i, center_i + i) { - state_count[3] += 1; - i += 1; - } - if state_count[3] == 0 { - return false; - } - while center_i + i < max_i && center_j + i < max_j && self.image.get(center_j + i, center_i + i) { - state_count[4] += 1; - i += 1; - } - if state_count[4] == 0 { - return false; - } - return ::found_pattern_diagonal(&state_count); - } - - /** - *

After a horizontal scan finds a potential finder pattern, this method - * "cross-checks" by scanning down vertically through the center of the possible - * finder pattern to see if the same proportion is detected.

- * - * @param startI row where a finder pattern was detected - * @param centerJ center of the section that appears to cross a finder pattern - * @param maxCount maximum reasonable number of modules that should be - * observed in any reading state, based on the results of the horizontal scan - * @return vertical center of finder pattern, or {@link Float#NaN} if not found - */ - fn cross_check_vertical(&self, start_i: i32, center_j: i32, max_count: i32, original_state_count_total: i32) -> f32 { - let image: BitMatrix = self.image; - let max_i: i32 = image.get_height(); - let state_count: Vec = self.get_cross_check_state_count(); - // Start counting up from center - let mut i: i32 = start_i; - while i >= 0 && image.get(center_j, i) { - state_count[2] += 1; - i -= 1; - } - if i < 0 { - return Float::NaN; - } - while i >= 0 && !image.get(center_j, i) && state_count[1] <= max_count { - state_count[1] += 1; - i -= 1; - } - // If already too many modules in this state or ran off the edge: - if i < 0 || state_count[1] > max_count { - return Float::NaN; - } - while i >= 0 && image.get(center_j, i) && state_count[0] <= max_count { - state_count[0] += 1; - i -= 1; - } - if state_count[0] > max_count { - return Float::NaN; - } - // Now also count down from center - i = start_i + 1; - while i < max_i && image.get(center_j, i) { - state_count[2] += 1; - i += 1; - } - if i == max_i { - return Float::NaN; - } - while i < max_i && !image.get(center_j, i) && state_count[3] < max_count { - state_count[3] += 1; - i += 1; - } - if i == max_i || state_count[3] >= max_count { - return Float::NaN; - } - while i < max_i && image.get(center_j, i) && state_count[4] < max_count { - state_count[4] += 1; - i += 1; - } - if state_count[4] >= max_count { - return Float::NaN; - } - // If we found a finder-pattern-like section, but its size is more than 40% different than - // the original, assume it's a false positive - let state_count_total: i32 = state_count[0] + state_count[1] + state_count[2] + state_count[3] + state_count[4]; - if 5 * Math::abs(state_count_total - original_state_count_total) >= 2 * original_state_count_total { - return Float::NaN; - } - return if ::found_pattern_cross(&state_count) { ::center_from_end(&state_count, i) } else { Float::NaN }; - } - - /** - *

Like {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical, - * except it reads horizontally instead of vertically. This is used to cross-cross - * check a vertical cross check and locate the real center of the alignment pattern.

- */ - fn cross_check_horizontal(&self, start_j: i32, center_i: i32, max_count: i32, original_state_count_total: i32) -> f32 { - let image: BitMatrix = self.image; - let max_j: i32 = image.get_width(); - let state_count: Vec = self.get_cross_check_state_count(); - let mut j: i32 = start_j; - while j >= 0 && image.get(j, center_i) { - state_count[2] += 1; - j -= 1; - } - if j < 0 { - return Float::NaN; - } - while j >= 0 && !image.get(j, center_i) && state_count[1] <= max_count { - state_count[1] += 1; - j -= 1; - } - if j < 0 || state_count[1] > max_count { - return Float::NaN; - } - while j >= 0 && image.get(j, center_i) && state_count[0] <= max_count { - state_count[0] += 1; - j -= 1; - } - if state_count[0] > max_count { - return Float::NaN; - } - j = start_j + 1; - while j < max_j && image.get(j, center_i) { - state_count[2] += 1; - j += 1; - } - if j == max_j { - return Float::NaN; - } - while j < max_j && !image.get(j, center_i) && state_count[3] < max_count { - state_count[3] += 1; - j += 1; - } - if j == max_j || state_count[3] >= max_count { - return Float::NaN; - } - while j < max_j && image.get(j, center_i) && state_count[4] < max_count { - state_count[4] += 1; - j += 1; - } - if state_count[4] >= max_count { - return Float::NaN; - } - // If we found a finder-pattern-like section, but its size is significantly different than - // the original, assume it's a false positive - let state_count_total: i32 = state_count[0] + state_count[1] + state_count[2] + state_count[3] + state_count[4]; - if 5 * Math::abs(state_count_total - original_state_count_total) >= original_state_count_total { - return Float::NaN; - } - return if ::found_pattern_cross(&state_count) { ::center_from_end(&state_count, j) } else { Float::NaN }; - } - - /** - * @param stateCount reading state module counts from horizontal scan - * @param i row where finder pattern may be found - * @param j end of possible finder pattern in row - * @param pureBarcode ignored - * @return true if a finder pattern candidate was found this time - * @deprecated only exists for backwards compatibility - * @see #handlePossibleCenter(int[], int, int) - */ - pub fn handle_possible_center(&self, state_count: &Vec, i: i32, j: i32, pure_barcode: bool) -> bool { - return self.handle_possible_center(&state_count, i, j); - } - - /** - *

This is called when a horizontal scan finds a possible alignment pattern. It will - * cross check with a vertical scan, and if successful, will, ah, cross-cross-check - * with another horizontal scan. This is needed primarily to locate the real horizontal - * center of the pattern in cases of extreme skew. - * And then we cross-cross-cross check with another diagonal scan.

- * - *

If that succeeds the finder pattern location is added to a list that tracks - * the number of times each location has been nearly-matched as a finder pattern. - * Each additional find is more evidence that the location is in fact a finder - * pattern center - * - * @param stateCount reading state module counts from horizontal scan - * @param i row where finder pattern may be found - * @param j end of possible finder pattern in row - * @return true if a finder pattern candidate was found this time - */ - pub fn handle_possible_center(&self, state_count: &Vec, i: i32, j: i32) -> bool { - let state_count_total: i32 = state_count[0] + state_count[1] + state_count[2] + state_count[3] + state_count[4]; - let center_j: f32 = ::center_from_end(&state_count, j); - let center_i: f32 = self.cross_check_vertical(i, center_j as i32, state_count[2], state_count_total); - if !Float::is_na_n(center_i) { - // Re-cross check - center_j = self.cross_check_horizontal(center_j as i32, center_i as i32, state_count[2], state_count_total); - if !Float::is_na_n(center_j) && self.cross_check_diagonal(center_i as i32, center_j as i32) { - let estimated_module_size: f32 = state_count_total / 7.0f; - let mut found: bool = false; - { - let mut index: i32 = 0; - while index < self.possible_centers.size() { - { - let center: FinderPattern = self.possible_centers.get(index); - // Look for about the same center and module size: - if center.about_equals(estimated_module_size, center_i, center_j) { - self.possible_centers.set(index, ¢er.combine_estimate(center_i, center_j, estimated_module_size)); - found = true; - break; - } - } - index += 1; - } - } - - if !found { - let point: FinderPattern = FinderPattern::new(center_j, center_i, estimated_module_size); - self.possible_centers.add(point); - if self.result_point_callback != null { - self.result_point_callback.found_possible_result_point(point); - } - } - return true; - } - } - return false; - } - - /** - * @return number of rows we could safely skip during scanning, based on the first - * two finder patterns that have been located. In some cases their position will - * allow us to infer that the third pattern must lie below a certain point farther - * down in the image. - */ - fn find_row_skip(&self) -> i32 { - let max: i32 = self.possible_centers.size(); - if max <= 1 { - return 0; - } - let first_confirmed_center: ResultPoint = null; - for let center: FinderPattern in self.possible_centers { - if center.get_count() >= CENTER_QUORUM { - if first_confirmed_center == null { - first_confirmed_center = center; - } else { - // We have two confirmed centers - // How far down can we skip before resuming looking for the next - // pattern? In the worst case, only the difference between the - // difference in the x / y coordinates of the two centers. - // This is the case where you find top left last. - self.has_skipped = true; - return (Math::abs(first_confirmed_center.get_x() - center.get_x()) - Math::abs(first_confirmed_center.get_y() - center.get_y())) as i32 / 2; - } - } - } - return 0; - } - - /** - * @return true iff we have found at least 3 finder patterns that have been detected - * at least {@link #CENTER_QUORUM} times each, and, the estimated module size of the - * candidates is "pretty similar" - */ - fn have_multiply_confirmed_centers(&self) -> bool { - let confirmed_count: i32 = 0; - let total_module_size: f32 = 0.0f; - let max: i32 = self.possible_centers.size(); - for let pattern: FinderPattern in self.possible_centers { - if pattern.get_count() >= CENTER_QUORUM { - confirmed_count += 1; - total_module_size += pattern.get_estimated_module_size(); - } - } - if confirmed_count < 3 { - return false; - } - // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive" - // and that we need to keep looking. We detect this by asking if the estimated module sizes - // vary too much. We arbitrarily say that when the total deviation from average exceeds - // 5% of the total module size estimates, it's too much. - let average: f32 = total_module_size / max; - let total_deviation: f32 = 0.0f; - for let pattern: FinderPattern in self.possible_centers { - total_deviation += Math::abs(pattern.get_estimated_module_size() - average); - } - return total_deviation <= 0.05f * total_module_size; - } - - /** - * Get square of distance between a and b. - */ - fn squared_distance( a: &FinderPattern, b: &FinderPattern) -> f64 { - let x: f64 = a.get_x() - b.get_x(); - let y: f64 = a.get_y() - b.get_y(); - return x * x + y * y; - } - - /** - * @return the 3 best {@link FinderPattern}s from our list of candidates. The "best" are - * those have similar module size and form a shape closer to a isosceles right triangle. - * @throws NotFoundException if 3 such finder patterns do not exist - */ - fn select_best_patterns(&self) -> /* throws NotFoundException */Result, Rc> { - let start_size: i32 = self.possible_centers.size(); - if start_size < 3 { - // Couldn't find enough finder patterns - throw NotFoundException::get_not_found_instance(); - } - self.possible_centers.sort(module_comparator); - let mut distortion: f64 = Double::MAX_VALUE; - let best_patterns: [Option; 3] = [None; 3]; - { - let mut i: i32 = 0; - while i < self.possible_centers.size() - 2 { - { - let fpi: FinderPattern = self.possible_centers.get(i); - let min_module_size: f32 = fpi.get_estimated_module_size(); - { - let mut j: i32 = i + 1; - while j < self.possible_centers.size() - 1 { - { - let fpj: FinderPattern = self.possible_centers.get(j); - let squares0: f64 = ::squared_distance(fpi, fpj); - { - let mut k: i32 = j + 1; - while k < self.possible_centers.size() { - { - let fpk: FinderPattern = self.possible_centers.get(k); - let max_module_size: f32 = fpk.get_estimated_module_size(); - if max_module_size > min_module_size * 1.4f { - // module size is not similar - continue; - } - let mut a: f64 = squares0; - let mut b: f64 = ::squared_distance(fpj, fpk); - let mut c: f64 = ::squared_distance(fpi, fpk); - // sorts ascending - inlined - if a < b { - if b > c { - if a < c { - let temp: f64 = b; - b = c; - c = temp; - } else { - let temp: f64 = a; - a = c; - c = b; - b = temp; - } - } - } else { - if b < c { - if a < c { - let temp: f64 = a; - a = b; - b = temp; - } else { - let temp: f64 = a; - a = b; - b = c; - c = temp; - } - } else { - let temp: f64 = a; - a = c; - c = temp; - } - } - // a^2 + b^2 = c^2 (Pythagorean theorem), and a = b (isosceles triangle). - // Since any right triangle satisfies the formula c^2 - b^2 - a^2 = 0, - // we need to check both two equal sides separately. - // The value of |c^2 - 2 * b^2| + |c^2 - 2 * a^2| increases as dissimilarity - // from isosceles right triangle. - let d: f64 = Math::abs(c - 2.0 * b) + Math::abs(c - 2.0 * a); - if d < distortion { - distortion = d; - best_patterns[0] = fpi; - best_patterns[1] = fpj; - best_patterns[2] = fpk; - } - } - k += 1; - } - } - - } - j += 1; - } - } - - } - i += 1; - } - } - - if distortion == Double::MAX_VALUE { - throw NotFoundException::get_not_found_instance(); - } - return Ok(best_patterns); - } - - /** - *

Orders by {@link FinderPattern#getEstimatedModuleSize()}

- */ - #[derive(Comparator, Serializable)] - struct EstimatedModuleComparator { - } - - impl EstimatedModuleComparator { - - pub fn compare(&self, center1: &FinderPattern, center2: &FinderPattern) -> i32 { - return Float::compare(¢er1.get_estimated_module_size(), ¢er2.get_estimated_module_size()); - } - } - -} - -// NEW FILE: finder_pattern_info.rs -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::detector; - -/** - *

Encapsulates information about finder patterns in an image, including the location of - * the three finder patterns, and their estimated module size.

- * - * @author Sean Owen - */ -pub struct FinderPatternInfo { - - let bottom_left: FinderPattern; - - let top_left: FinderPattern; - - let top_right: FinderPattern; -} - -impl FinderPatternInfo { - - pub fn new( pattern_centers: &Vec) -> FinderPatternInfo { - let .bottomLeft = pattern_centers[0]; - let .topLeft = pattern_centers[1]; - let .topRight = pattern_centers[2]; - } - - pub fn get_bottom_left(&self) -> FinderPattern { - return self.bottom_left; - } - - pub fn get_top_left(&self) -> FinderPattern { - return self.top_left; - } - - pub fn get_top_right(&self) -> FinderPattern { - return self.top_right; - } -} - diff --git a/src/qrcode/encoder.rs b/src/qrcode/encoder.rs deleted file mode 100644 index 59011d2..0000000 --- a/src/qrcode/encoder.rs +++ /dev/null @@ -1,2606 +0,0 @@ -use crate::{EncodeHintType,WriterException,}; -use crate::common::{BitArray,StringUtils,CharacterSetECI,ECIEncoderSet,}; -use crate::common::reedsolmon::{GenericGF,ReedSolomonEncoder,}; -use crate::qrcode::decoder::{ErrorCorrectionLevel,Mode,Version,}; - -// NEW FILE: block_pair.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::encoder; - -struct BlockPair { - - let data_bytes: Vec; - - let error_correction_bytes: Vec; -} - -impl BlockPair { - - fn new( data: &Vec, error_correction: &Vec) -> BlockPair { - data_bytes = data; - error_correction_bytes = error_correction; - } - - pub fn get_data_bytes(&self) -> Vec { - return self.data_bytes; - } - - pub fn get_error_correction_bytes(&self) -> Vec { - return self.error_correction_bytes; - } -} - -// NEW FILE: byte_matrix.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::encoder; - -/** - * 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. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -pub struct ByteMatrix { - - let mut bytes: Vec>; - - let width: i32; - - let height: i32; -} - -impl ByteMatrix { - - pub fn new( width: i32, height: i32) -> ByteMatrix { - bytes = : [[i8; width]; height] = [[0; width]; height]; - let .width = width; - let .height = height; - } - - pub fn get_height(&self) -> i32 { - return self.height; - } - - pub fn get_width(&self) -> i32 { - return self.width; - } - - pub fn get(&self, x: i32, y: i32) -> i8 { - return self.bytes[y][x]; - } - - /** - * @return an internal representation as bytes, in row-major order. array[y][x] represents point (x,y) - */ - pub fn get_array(&self) -> Vec> { - return self.bytes; - } - - pub fn set(&self, x: i32, y: i32, value: i8) { - self.bytes[y][x] = value; - } - - pub fn set(&self, x: i32, y: i32, value: i32) { - self.bytes[y][x] = value as i8; - } - - pub fn set(&self, x: i32, y: i32, value: bool) { - self.bytes[y][x] = ( if value { 1 } else { 0 }) as i8; - } - - pub fn clear(&self, value: i8) { - for let a_byte: Vec in self.bytes { - Arrays::fill(&a_byte, value); - } - } - - pub fn to_string(&self) -> String { - let result: StringBuilder = StringBuilder::new(2 * self.width * self.height + 2); - { - let mut y: i32 = 0; - while y < self.height { - { - let bytes_y: Vec = self.bytes[y]; - { - let mut x: i32 = 0; - while x < self.width { - { - match bytes_y[x] { - 0 => - { - result.append(" 0"); - break; - } - 1 => - { - result.append(" 1"); - break; - } - _ => - { - result.append(" "); - break; - } - } - } - x += 1; - } - } - - result.append('\n'); - } - y += 1; - } - } - - return result.to_string(); - } -} - -// NEW FILE: encoder.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::encoder; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author dswitkin@google.com (Daniel Switkin) - ported from C++ - */ - -// The original table is defined in the table 5 of JISX0510:2004 (p.19). - const ALPHANUMERIC_TABLE: vec![Vec; 96] = vec![// 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x00-0x0f -// 0x00-0x0f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x10-0x1f -// 0x10-0x1f --1, // 0x20-0x2f -36, // 0x20-0x2f -// 0x20-0x2f --1, // 0x20-0x2f -// 0x20-0x2f --1, // 0x20-0x2f -// 0x20-0x2f --1, // 0x20-0x2f -37, // 0x20-0x2f -38, // 0x20-0x2f -// 0x20-0x2f --1, // 0x20-0x2f -// 0x20-0x2f --1, // 0x20-0x2f -// 0x20-0x2f --1, // 0x20-0x2f -// 0x20-0x2f --1, // 0x20-0x2f -39, // 0x20-0x2f -40, // 0x20-0x2f -// 0x20-0x2f --1, // 0x20-0x2f -41, // 0x20-0x2f -42, // 0x20-0x2f -43, // 0x30-0x3f -0, // 0x30-0x3f -1, // 0x30-0x3f -2, // 0x30-0x3f -3, // 0x30-0x3f -4, // 0x30-0x3f -5, // 0x30-0x3f -6, // 0x30-0x3f -7, // 0x30-0x3f -8, // 0x30-0x3f -9, // 0x30-0x3f -44, // 0x30-0x3f -// 0x30-0x3f --1, // 0x30-0x3f -// 0x30-0x3f --1, // 0x30-0x3f -// 0x30-0x3f --1, // 0x30-0x3f -// 0x30-0x3f --1, // 0x30-0x3f -// 0x30-0x3f --1, // 0x40-0x4f -// 0x40-0x4f --1, // 0x40-0x4f -10, // 0x40-0x4f -11, // 0x40-0x4f -12, // 0x40-0x4f -13, // 0x40-0x4f -14, // 0x40-0x4f -15, // 0x40-0x4f -16, // 0x40-0x4f -17, // 0x40-0x4f -18, // 0x40-0x4f -19, // 0x40-0x4f -20, // 0x40-0x4f -21, // 0x40-0x4f -22, // 0x40-0x4f -23, // 0x40-0x4f -24, // 0x50-0x5f -25, // 0x50-0x5f -26, // 0x50-0x5f -27, // 0x50-0x5f -28, // 0x50-0x5f -29, // 0x50-0x5f -30, // 0x50-0x5f -31, // 0x50-0x5f -32, // 0x50-0x5f -33, // 0x50-0x5f -34, // 0x50-0x5f -35, // 0x50-0x5f -// 0x50-0x5f --1, // 0x50-0x5f -// 0x50-0x5f --1, // 0x50-0x5f -// 0x50-0x5f --1, // 0x50-0x5f -// 0x50-0x5f --1, // 0x50-0x5f -// 0x50-0x5f --1, ] -; - - const DEFAULT_BYTE_MODE_ENCODING: Charset = StandardCharsets::ISO_8859_1; -pub struct Encoder { -} - -impl Encoder { - - fn new() -> Encoder { - } - - // The mask penalty calculation is complicated. See Table 21 of JISX0510:2004 (p.45) for details. - // Basically it applies four rules and summate all penalties. - fn calculate_mask_penalty( matrix: &ByteMatrix) -> i32 { - return MaskUtil::apply_mask_penalty_rule1(matrix) + MaskUtil::apply_mask_penalty_rule2(matrix) + MaskUtil::apply_mask_penalty_rule3(matrix) + MaskUtil::apply_mask_penalty_rule4(matrix); - } - - /** - * @param content text to encode - * @param ecLevel error correction level to use - * @return {@link QRCode} representing the encoded QR code - * @throws WriterException if encoding can't succeed, because of for example invalid content - * or configuration - */ - pub fn encode( content: &String, ec_level: &ErrorCorrectionLevel) -> /* throws WriterException */Result> { - return Ok(::encode(&content, ec_level, null)); - } - - pub fn encode( content: &String, ec_level: &ErrorCorrectionLevel, hints: &Map) -> /* throws WriterException */Result> { - let mut version: Version; - let header_and_data_bits: BitArray; - let mut mode: Mode; - let has_g_s1_format_hint: bool = hints != null && hints.contains_key(EncodeHintType::GS1_FORMAT) && Boolean::parse_boolean(&hints.get(EncodeHintType::GS1_FORMAT).to_string()); - let has_compaction_hint: bool = hints != null && hints.contains_key(EncodeHintType::QR_COMPACT) && Boolean::parse_boolean(&hints.get(EncodeHintType::QR_COMPACT).to_string()); - // Determine what character encoding has been specified by the caller, if any - let mut encoding: Charset = DEFAULT_BYTE_MODE_ENCODING; - let has_encoding_hint: bool = hints != null && hints.contains_key(EncodeHintType::CHARACTER_SET); - if has_encoding_hint { - encoding = Charset::for_name(&hints.get(EncodeHintType::CHARACTER_SET).to_string()); - } - if has_compaction_hint { - mode = Mode::BYTE; - let priority_encoding: Charset = if encoding.equals(&DEFAULT_BYTE_MODE_ENCODING) { null } else { encoding }; - let rn: MinimalEncoder.ResultList = MinimalEncoder::encode(&content, null, &priority_encoding, has_g_s1_format_hint, ec_level); - header_and_data_bits = BitArray::new(); - rn.get_bits(header_and_data_bits); - version = rn.get_version(); - } else { - // Pick an encoding mode appropriate for the content. Note that this will not attempt to use - // multiple modes / segments even if that were more efficient. - mode = ::choose_mode(&content, &encoding); - // This will store the header information, like mode and - // length, as well as "header" segments like an ECI segment. - let header_bits: BitArray = BitArray::new(); - // Append ECI segment if applicable - if mode == Mode::BYTE && has_encoding_hint { - let eci: CharacterSetECI = CharacterSetECI::get_character_set_e_c_i(&encoding); - if eci != null { - ::append_e_c_i(eci, header_bits); - } - } - // Append the FNC1 mode header for GS1 formatted data if applicable - if has_g_s1_format_hint { - // GS1 formatted codes are prefixed with a FNC1 in first position mode header - ::append_mode_info(Mode::FNC1_FIRST_POSITION, header_bits); - } - // (With ECI in place,) Write the mode marker - ::append_mode_info(mode, header_bits); - // Collect data within the main segment, separately, to count its size if needed. Don't add it to - // main payload yet. - let data_bits: BitArray = BitArray::new(); - ::append_bytes(&content, mode, data_bits, &encoding); - if hints != null && hints.contains_key(EncodeHintType::QR_VERSION) { - let version_number: i32 = Integer::parse_int(&hints.get(EncodeHintType::QR_VERSION).to_string()); - version = Version::get_version_for_number(version_number); - let bits_needed: i32 = ::calculate_bits_needed(mode, header_bits, data_bits, version); - if !::will_fit(bits_needed, version, ec_level) { - throw WriterException::new("Data too big for requested version"); - } - } else { - version = ::recommend_version(ec_level, mode, header_bits, data_bits); - } - header_and_data_bits = BitArray::new(); - header_and_data_bits.append_bit_array(header_bits); - // Find "length" of main segment and write it - let num_letters: i32 = if mode == Mode::BYTE { data_bits.get_size_in_bytes() } else { content.length() }; - ::append_length_info(num_letters, version, mode, header_and_data_bits); - // Put data together into the overall payload - header_and_data_bits.append_bit_array(data_bits); - } - let ec_blocks: Version.ECBlocks = version.get_e_c_blocks_for_level(ec_level); - let num_data_bytes: i32 = version.get_total_codewords() - ec_blocks.get_total_e_c_codewords(); - // Terminate the bits properly. - ::terminate_bits(num_data_bytes, header_and_data_bits); - // Interleave data bits with error correction code. - let final_bits: BitArray = ::interleave_with_e_c_bytes(header_and_data_bits, &version.get_total_codewords(), num_data_bytes, &ec_blocks.get_num_blocks()); - let qr_code: QRCode = QRCode::new(); - qr_code.set_e_c_level(ec_level); - qr_code.set_mode(mode); - qr_code.set_version(version); - // Choose the mask pattern and set to "qrCode". - let dimension: i32 = version.get_dimension_for_version(); - let matrix: ByteMatrix = ByteMatrix::new(dimension, dimension); - // Enable manual selection of the pattern to be used via hint - let mask_pattern: i32 = -1; - if hints != null && hints.contains_key(EncodeHintType::QR_MASK_PATTERN) { - let hint_mask_pattern: i32 = Integer::parse_int(&hints.get(EncodeHintType::QR_MASK_PATTERN).to_string()); - mask_pattern = if QRCode::is_valid_mask_pattern(hint_mask_pattern) { hint_mask_pattern } else { -1 }; - } - if mask_pattern == -1 { - mask_pattern = ::choose_mask_pattern(final_bits, ec_level, version, matrix); - } - qr_code.set_mask_pattern(mask_pattern); - // Build the matrix and set it to "qrCode". - MatrixUtil::build_matrix(final_bits, ec_level, version, mask_pattern, matrix); - qr_code.set_matrix(matrix); - return Ok(qr_code); - } - - /** - * Decides the smallest version of QR code that will contain all of the provided data. - * - * @throws WriterException if the data cannot fit in any version - */ - fn recommend_version( ec_level: &ErrorCorrectionLevel, mode: &Mode, header_bits: &BitArray, data_bits: &BitArray) -> /* throws WriterException */Result> { - // Hard part: need to know version to know how many bits length takes. But need to know how many - // bits it takes to know version. First we take a guess at version by assuming version will be - // the minimum, 1: - let provisional_bits_needed: i32 = ::calculate_bits_needed(mode, header_bits, data_bits, &Version::get_version_for_number(1)); - let provisional_version: Version = ::choose_version(provisional_bits_needed, ec_level); - // Use that guess to calculate the right version. I am still not sure this works in 100% of cases. - let bits_needed: i32 = ::calculate_bits_needed(mode, header_bits, data_bits, provisional_version); - return Ok(::choose_version(bits_needed, ec_level)); - } - - fn calculate_bits_needed( mode: &Mode, header_bits: &BitArray, data_bits: &BitArray, version: &Version) -> i32 { - return header_bits.get_size() + mode.get_character_count_bits(version) + data_bits.get_size(); - } - - /** - * @return the code point of the table used in alphanumeric mode or - * -1 if there is no corresponding code in the table. - */ - fn get_alphanumeric_code( code: i32) -> i32 { - if code < ALPHANUMERIC_TABLE.len() { - return ALPHANUMERIC_TABLE[code]; - } - return -1; - } - - pub fn choose_mode( content: &String) -> Mode { - return ::choose_mode(&content, null); - } - - /** - * Choose the best mode by examining the content. Note that 'encoding' is used as a hint; - * if it is Shift_JIS, and the input is only double-byte Kanji, then we return {@link Mode#KANJI}. - */ - fn choose_mode( content: &String, encoding: &Charset) -> Mode { - if StringUtils::SHIFT_JIS_CHARSET::equals(&encoding) && ::is_only_double_byte_kanji(&content) { - // Choose Kanji mode if all input are double-byte characters - return Mode::KANJI; - } - let has_numeric: bool = false; - let has_alphanumeric: bool = false; - { - let mut i: i32 = 0; - while i < content.length() { - { - let c: char = content.char_at(i); - if c >= '0' && c <= '9' { - has_numeric = true; - } else if ::get_alphanumeric_code(c) != -1 { - has_alphanumeric = true; - } else { - return Mode::BYTE; - } - } - i += 1; - } - } - - if has_alphanumeric { - return Mode::ALPHANUMERIC; - } - if has_numeric { - return Mode::NUMERIC; - } - return Mode::BYTE; - } - - fn is_only_double_byte_kanji( content: &String) -> bool { - let bytes: Vec = content.get_bytes(StringUtils::SHIFT_JIS_CHARSET); - let length: i32 = bytes.len(); - if length % 2 != 0 { - return false; - } - { - let mut i: i32 = 0; - while i < length { - { - let byte1: i32 = bytes[i] & 0xFF; - if (byte1 < 0x81 || byte1 > 0x9F) && (byte1 < 0xE0 || byte1 > 0xEB) { - return false; - } - } - i += 2; - } - } - - return true; - } - - fn choose_mask_pattern( bits: &BitArray, ec_level: &ErrorCorrectionLevel, version: &Version, matrix: &ByteMatrix) -> /* throws WriterException */Result> { - // Lower penalty is better. - let min_penalty: i32 = Integer::MAX_VALUE; - let best_mask_pattern: i32 = -1; - // We try all mask patterns to choose the best one. - { - let mask_pattern: i32 = 0; - while mask_pattern < QRCode.NUM_MASK_PATTERNS { - { - MatrixUtil::build_matrix(bits, ec_level, version, mask_pattern, matrix); - let penalty: i32 = ::calculate_mask_penalty(matrix); - if penalty < min_penalty { - min_penalty = penalty; - best_mask_pattern = mask_pattern; - } - } - mask_pattern += 1; - } - } - - return Ok(best_mask_pattern); - } - - fn choose_version( num_input_bits: i32, ec_level: &ErrorCorrectionLevel) -> /* throws WriterException */Result> { - { - let version_num: i32 = 1; - while version_num <= 40 { - { - let version: Version = Version::get_version_for_number(version_num); - if ::will_fit(num_input_bits, version, ec_level) { - return Ok(version); - } - } - version_num += 1; - } - } - - throw WriterException::new("Data too big"); - } - - /** - * @return true if the number of input bits will fit in a code with the specified version and - * error correction level. - */ - fn will_fit( num_input_bits: i32, version: &Version, ec_level: &ErrorCorrectionLevel) -> bool { - // In the following comments, we use numbers of Version 7-H. - // numBytes = 196 - let num_bytes: i32 = version.get_total_codewords(); - // getNumECBytes = 130 - let ec_blocks: Version.ECBlocks = version.get_e_c_blocks_for_level(ec_level); - let num_ec_bytes: i32 = ec_blocks.get_total_e_c_codewords(); - // getNumDataBytes = 196 - 130 = 66 - let num_data_bytes: i32 = num_bytes - num_ec_bytes; - let total_input_bytes: i32 = (num_input_bits + 7) / 8; - return num_data_bytes >= total_input_bytes; - } - - /** - * Terminate bits as described in 8.4.8 and 8.4.9 of JISX0510:2004 (p.24). - */ - fn terminate_bits( num_data_bytes: i32, bits: &BitArray) -> /* throws WriterException */Result> { - let capacity: i32 = num_data_bytes * 8; - if bits.get_size() > capacity { - throw WriterException::new(format!("data bits cannot fit in the QR Code{} > {}", bits.get_size(), capacity)); - } - // Append Mode.TERMINATE if there is enough space (value is 0000) - { - let mut i: i32 = 0; - while i < 4 && bits.get_size() < capacity { - { - bits.append_bit(false); - } - i += 1; - } - } - - // Append termination bits. See 8.4.8 of JISX0510:2004 (p.24) for details. - // If the last byte isn't 8-bit aligned, we'll add padding bits. - let num_bits_in_last_byte: i32 = bits.get_size() & 0x07; - if num_bits_in_last_byte > 0 { - { - let mut i: i32 = num_bits_in_last_byte; - while i < 8 { - { - bits.append_bit(false); - } - i += 1; - } - } - - } - // If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24). - let num_padding_bytes: i32 = num_data_bytes - bits.get_size_in_bytes(); - { - let mut i: i32 = 0; - while i < num_padding_bytes { - { - bits.append_bits( if (i & 0x01) == 0 { 0xEC } else { 0x11 }, 8); - } - i += 1; - } - } - - if bits.get_size() != capacity { - throw WriterException::new("Bits size does not equal capacity"); - } - } - - /** - * Get number of data bytes and number of error correction bytes for block id "blockID". Store - * the result in "numDataBytesInBlock", and "numECBytesInBlock". See table 12 in 8.5.1 of - * JISX0510:2004 (p.30) - */ - fn get_num_data_bytes_and_num_e_c_bytes_for_block_i_d( num_total_bytes: i32, num_data_bytes: i32, num_r_s_blocks: i32, block_i_d: i32, num_data_bytes_in_block: &Vec, num_e_c_bytes_in_block: &Vec) -> /* throws WriterException */Result> { - if block_i_d >= num_r_s_blocks { - throw WriterException::new("Block ID too large"); - } - // numRsBlocksInGroup2 = 196 % 5 = 1 - let num_rs_blocks_in_group2: i32 = num_total_bytes % num_r_s_blocks; - // numRsBlocksInGroup1 = 5 - 1 = 4 - let num_rs_blocks_in_group1: i32 = num_r_s_blocks - num_rs_blocks_in_group2; - // numTotalBytesInGroup1 = 196 / 5 = 39 - let num_total_bytes_in_group1: i32 = num_total_bytes / num_r_s_blocks; - // numTotalBytesInGroup2 = 39 + 1 = 40 - let num_total_bytes_in_group2: i32 = num_total_bytes_in_group1 + 1; - // numDataBytesInGroup1 = 66 / 5 = 13 - let num_data_bytes_in_group1: i32 = num_data_bytes / num_r_s_blocks; - // numDataBytesInGroup2 = 13 + 1 = 14 - let num_data_bytes_in_group2: i32 = num_data_bytes_in_group1 + 1; - // numEcBytesInGroup1 = 39 - 13 = 26 - let num_ec_bytes_in_group1: i32 = num_total_bytes_in_group1 - num_data_bytes_in_group1; - // numEcBytesInGroup2 = 40 - 14 = 26 - let num_ec_bytes_in_group2: i32 = num_total_bytes_in_group2 - num_data_bytes_in_group2; - // 26 = 26 - if num_ec_bytes_in_group1 != num_ec_bytes_in_group2 { - throw WriterException::new("EC bytes mismatch"); - } - // 5 = 4 + 1. - if num_r_s_blocks != num_rs_blocks_in_group1 + num_rs_blocks_in_group2 { - throw WriterException::new("RS blocks mismatch"); - } - // 196 = (13 + 26) * 4 + (14 + 26) * 1 - if num_total_bytes != ((num_data_bytes_in_group1 + num_ec_bytes_in_group1) * num_rs_blocks_in_group1) + ((num_data_bytes_in_group2 + num_ec_bytes_in_group2) * num_rs_blocks_in_group2) { - throw WriterException::new("Total bytes mismatch"); - } - if block_i_d < num_rs_blocks_in_group1 { - num_data_bytes_in_block[0] = num_data_bytes_in_group1; - num_e_c_bytes_in_block[0] = num_ec_bytes_in_group1; - } else { - num_data_bytes_in_block[0] = num_data_bytes_in_group2; - num_e_c_bytes_in_block[0] = num_ec_bytes_in_group2; - } - } - - /** - * Interleave "bits" with corresponding error correction bytes. On success, store the result in - * "result". The interleave rule is complicated. See 8.6 of JISX0510:2004 (p.37) for details. - */ - fn interleave_with_e_c_bytes( bits: &BitArray, num_total_bytes: i32, num_data_bytes: i32, num_r_s_blocks: i32) -> /* throws WriterException */Result> { - // "bits" must have "getNumDataBytes" bytes of data. - if bits.get_size_in_bytes() != num_data_bytes { - throw WriterException::new("Number of bits and data bytes does not match"); - } - // Step 1. Divide data bytes into blocks and generate error correction bytes for them. We'll - // store the divided data bytes blocks and error correction bytes blocks into "blocks". - let data_bytes_offset: i32 = 0; - let max_num_data_bytes: i32 = 0; - let max_num_ec_bytes: i32 = 0; - // Since, we know the number of reedsolmon blocks, we can initialize the vector with the number. - let blocks: Collection = ArrayList<>::new(num_r_s_blocks); - { - let mut i: i32 = 0; - while i < num_r_s_blocks { - { - let num_data_bytes_in_block: [i32; 1] = [0; 1]; - let num_ec_bytes_in_block: [i32; 1] = [0; 1]; - ::get_num_data_bytes_and_num_e_c_bytes_for_block_i_d(num_total_bytes, num_data_bytes, num_r_s_blocks, i, &num_data_bytes_in_block, &num_ec_bytes_in_block); - let size: i32 = num_data_bytes_in_block[0]; - let data_bytes: [i8; size] = [0; size]; - bits.to_bytes(8 * data_bytes_offset, &data_bytes, 0, size); - let ec_bytes: Vec = ::generate_e_c_bytes(&data_bytes, num_ec_bytes_in_block[0]); - blocks.add(BlockPair::new(&data_bytes, &ec_bytes)); - max_num_data_bytes = Math::max(max_num_data_bytes, size); - max_num_ec_bytes = Math::max(max_num_ec_bytes, ec_bytes.len()); - data_bytes_offset += num_data_bytes_in_block[0]; - } - i += 1; - } - } - - if num_data_bytes != data_bytes_offset { - throw WriterException::new("Data bytes does not match offset"); - } - let result: BitArray = BitArray::new(); - // First, place data blocks. - { - let mut i: i32 = 0; - while i < max_num_data_bytes { - { - for let block: BlockPair in blocks { - let data_bytes: Vec = block.get_data_bytes(); - if i < data_bytes.len() { - result.append_bits(data_bytes[i], 8); - } - } - } - i += 1; - } - } - - // Then, place error correction blocks. - { - let mut i: i32 = 0; - while i < max_num_ec_bytes { - { - for let block: BlockPair in blocks { - let ec_bytes: Vec = block.get_error_correction_bytes(); - if i < ec_bytes.len() { - result.append_bits(ec_bytes[i], 8); - } - } - } - i += 1; - } - } - - if num_total_bytes != result.get_size_in_bytes() { - // Should be same. - throw WriterException::new(format!("Interleaving error: {} and {} differ.", num_total_bytes, result.get_size_in_bytes())); - } - return Ok(result); - } - - fn generate_e_c_bytes( data_bytes: &Vec, num_ec_bytes_in_block: i32) -> Vec { - let num_data_bytes: i32 = data_bytes.len(); - let to_encode: [i32; num_data_bytes + num_ec_bytes_in_block] = [0; num_data_bytes + num_ec_bytes_in_block]; - { - let mut i: i32 = 0; - while i < num_data_bytes { - { - to_encode[i] = data_bytes[i] & 0xFF; - } - i += 1; - } - } - - ReedSolomonEncoder::new(GenericGF::QR_CODE_FIELD_256).encode(&to_encode, num_ec_bytes_in_block); - let ec_bytes: [i8; num_ec_bytes_in_block] = [0; num_ec_bytes_in_block]; - { - let mut i: i32 = 0; - while i < num_ec_bytes_in_block { - { - ec_bytes[i] = to_encode[num_data_bytes + i] as i8; - } - i += 1; - } - } - - return ec_bytes; - } - - /** - * Append mode info. On success, store the result in "bits". - */ - fn append_mode_info( mode: &Mode, bits: &BitArray) { - bits.append_bits(&mode.get_bits(), 4); - } - - /** - * Append length info. On success, store the result in "bits". - */ - fn append_length_info( num_letters: i32, version: &Version, mode: &Mode, bits: &BitArray) -> /* throws WriterException */Result> { - let num_bits: i32 = mode.get_character_count_bits(version); - if num_letters >= (1 << num_bits) { - throw WriterException::new(format!("{} is bigger than {}", num_letters, ((1 << num_bits) - 1))); - } - bits.append_bits(num_letters, num_bits); - } - - /** - * Append "bytes" in "mode" mode (encoding) into "bits". On success, store the result in "bits". - */ - fn append_bytes( content: &String, mode: &Mode, bits: &BitArray, encoding: &Charset) -> /* throws WriterException */Result> { - match mode { - NUMERIC => - { - ::append_numeric_bytes(&content, bits); - break; - } - ALPHANUMERIC => - { - ::append_alphanumeric_bytes(&content, bits); - break; - } - BYTE => - { - ::append8_bit_bytes(&content, bits, &encoding); - break; - } - KANJI => - { - ::append_kanji_bytes(&content, bits); - break; - } - _ => - { - throw WriterException::new(format!("Invalid mode: {}", mode)); - } - } - } - - fn append_numeric_bytes( content: &CharSequence, bits: &BitArray) { - let length: i32 = content.length(); - let mut i: i32 = 0; - while i < length { - let num1: i32 = content.char_at(i) - '0'; - if i + 2 < length { - // Encode three numeric letters in ten bits. - let num2: i32 = content.char_at(i + 1) - '0'; - let num3: i32 = content.char_at(i + 2) - '0'; - bits.append_bits(num1 * 100 + num2 * 10 + num3, 10); - i += 3; - } else if i + 1 < length { - // Encode two numeric letters in seven bits. - let num2: i32 = content.char_at(i + 1) - '0'; - bits.append_bits(num1 * 10 + num2, 7); - i += 2; - } else { - // Encode one numeric letter in four bits. - bits.append_bits(num1, 4); - i += 1; - } - } - } - - fn append_alphanumeric_bytes( content: &CharSequence, bits: &BitArray) -> /* throws WriterException */Result> { - let length: i32 = content.length(); - let mut i: i32 = 0; - while i < length { - let code1: i32 = ::get_alphanumeric_code(&content.char_at(i)); - if code1 == -1 { - throw WriterException::new(); - } - if i + 1 < length { - let code2: i32 = ::get_alphanumeric_code(&content.char_at(i + 1)); - if code2 == -1 { - throw WriterException::new(); - } - // Encode two alphanumeric letters in 11 bits. - bits.append_bits(code1 * 45 + code2, 11); - i += 2; - } else { - // Encode one alphanumeric letter in six bits. - bits.append_bits(code1, 6); - i += 1; - } - } - } - - fn append8_bit_bytes( content: &String, bits: &BitArray, encoding: &Charset) { - let bytes: Vec = content.get_bytes(&encoding); - for let b: i8 in bytes { - bits.append_bits(b, 8); - } - } - - fn append_kanji_bytes( content: &String, bits: &BitArray) -> /* throws WriterException */Result> { - let bytes: Vec = content.get_bytes(StringUtils::SHIFT_JIS_CHARSET); - if bytes.len() % 2 != 0 { - throw WriterException::new("Kanji byte size not even"); - } - // bytes.length must be even - let max_i: i32 = bytes.len() - 1; - { - let mut i: i32 = 0; - while i < max_i { - { - let byte1: i32 = bytes[i] & 0xFF; - let byte2: i32 = bytes[i + 1] & 0xFF; - let code: i32 = (byte1 << 8) | byte2; - let mut subtracted: i32 = -1; - if code >= 0x8140 && code <= 0x9ffc { - subtracted = code - 0x8140; - } else if code >= 0xe040 && code <= 0xebbf { - subtracted = code - 0xc140; - } - if subtracted == -1 { - throw WriterException::new("Invalid byte sequence"); - } - let encoded: i32 = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff); - bits.append_bits(encoded, 13); - } - i += 2; - } - } - - } - - fn append_e_c_i( eci: &CharacterSetECI, bits: &BitArray) { - bits.append_bits(&Mode::ECI::get_bits(), 4); - // This is correct for values up to 127, which is all we need now. - bits.append_bits(&eci.get_value(), 8); - } -} - -// NEW FILE: mask_util.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::encoder; - -/** - * @author Satoru Takabayashi - * @author Daniel Switkin - * @author Sean Owen - */ - -// Penalty weights from section 6.8.2.1 - const N1: i32 = 3; - - const N2: i32 = 3; - - const N3: i32 = 40; - - const N4: i32 = 10; -struct MaskUtil { -} - -impl MaskUtil { - - fn new() -> MaskUtil { - // do nothing - } - - /** - * Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and - * give penalty to them. Example: 00000 or 11111. - */ - fn apply_mask_penalty_rule1( matrix: &ByteMatrix) -> i32 { - return ::apply_mask_penalty_rule1_internal(matrix, true) + ::apply_mask_penalty_rule1_internal(matrix, false); - } - - /** - * Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give - * penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a - * penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block. - */ - fn apply_mask_penalty_rule2( matrix: &ByteMatrix) -> i32 { - let mut penalty: i32 = 0; - let array: Vec> = matrix.get_array(); - let width: i32 = matrix.get_width(); - let height: i32 = matrix.get_height(); - { - let mut y: i32 = 0; - while y < height - 1 { - { - let array_y: Vec = array[y]; - { - let mut x: i32 = 0; - while x < width - 1 { - { - let value: i32 = array_y[x]; - if value == array_y[x + 1] && value == array[y + 1][x] && value == array[y + 1][x + 1] { - penalty += 1; - } - } - x += 1; - } - } - - } - y += 1; - } - } - - return N2 * penalty; - } - - /** - * Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4 - * starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we - * find patterns like 000010111010000, we give penalty once. - */ - fn apply_mask_penalty_rule3( matrix: &ByteMatrix) -> i32 { - let num_penalties: i32 = 0; - let array: Vec> = matrix.get_array(); - let width: i32 = matrix.get_width(); - let height: i32 = matrix.get_height(); - { - let mut y: i32 = 0; - while y < height { - { - { - let mut x: i32 = 0; - while x < width { - { - // We can at least optimize this access - let array_y: Vec = array[y]; - if x + 6 < width && array_y[x] == 1 && array_y[x + 1] == 0 && array_y[x + 2] == 1 && array_y[x + 3] == 1 && array_y[x + 4] == 1 && array_y[x + 5] == 0 && array_y[x + 6] == 1 && (::is_white_horizontal(&array_y, x - 4, x) || ::is_white_horizontal(&array_y, x + 7, x + 11)) { - num_penalties += 1; - } - if y + 6 < height && array[y][x] == 1 && array[y + 1][x] == 0 && array[y + 2][x] == 1 && array[y + 3][x] == 1 && array[y + 4][x] == 1 && array[y + 5][x] == 0 && array[y + 6][x] == 1 && (::is_white_vertical(&array, x, y - 4, y) || ::is_white_vertical(&array, x, y + 7, y + 11)) { - num_penalties += 1; - } - } - x += 1; - } - } - - } - y += 1; - } - } - - return num_penalties * N3; - } - - fn is_white_horizontal( row_array: &Vec, from: i32, to: i32) -> bool { - if from < 0 || row_array.len() < to { - return false; - } - { - let mut i: i32 = from; - while i < to { - { - if row_array[i] == 1 { - return false; - } - } - i += 1; - } - } - - return true; - } - - fn is_white_vertical( array: &Vec>, col: i32, from: i32, to: i32) -> bool { - if from < 0 || array.len() < to { - return false; - } - { - let mut i: i32 = from; - while i < to { - { - if array[i][col] == 1 { - return false; - } - } - i += 1; - } - } - - return true; - } - - /** - * Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give - * penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance. - */ - fn apply_mask_penalty_rule4( matrix: &ByteMatrix) -> i32 { - let num_dark_cells: i32 = 0; - let array: Vec> = matrix.get_array(); - let width: i32 = matrix.get_width(); - let height: i32 = matrix.get_height(); - { - let mut y: i32 = 0; - while y < height { - { - let array_y: Vec = array[y]; - { - let mut x: i32 = 0; - while x < width { - { - if array_y[x] == 1 { - num_dark_cells += 1; - } - } - x += 1; - } - } - - } - y += 1; - } - } - - let num_total_cells: i32 = matrix.get_height() * matrix.get_width(); - let five_percent_variances: i32 = Math::abs(num_dark_cells * 2 - num_total_cells) * 10 / num_total_cells; - return five_percent_variances * N4; - } - - /** - * Return the mask bit for "getMaskPattern" at "x" and "y". See 8.8 of JISX0510:2004 for mask - * pattern conditions. - */ - fn get_data_mask_bit( mask_pattern: i32, x: i32, y: i32) -> bool { - let mut intermediate: i32; - let mut temp: i32; - match mask_pattern { - 0 => - { - intermediate = (y + x) & 0x1; - break; - } - 1 => - { - intermediate = y & 0x1; - break; - } - 2 => - { - intermediate = x % 3; - break; - } - 3 => - { - intermediate = (y + x) % 3; - break; - } - 4 => - { - intermediate = ((y / 2) + (x / 3)) & 0x1; - break; - } - 5 => - { - temp = y * x; - intermediate = (temp & 0x1) + (temp % 3); - break; - } - 6 => - { - temp = y * x; - intermediate = ((temp & 0x1) + (temp % 3)) & 0x1; - break; - } - 7 => - { - temp = y * x; - intermediate = ((temp % 3) + ((y + x) & 0x1)) & 0x1; - break; - } - _ => - { - throw IllegalArgumentException::new(format!("Invalid mask pattern: {}", mask_pattern)); - } - } - return intermediate == 0; - } - - /** - * Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both - * vertical and horizontal orders respectively. - */ - fn apply_mask_penalty_rule1_internal( matrix: &ByteMatrix, is_horizontal: bool) -> i32 { - let mut penalty: i32 = 0; - let i_limit: i32 = if is_horizontal { matrix.get_height() } else { matrix.get_width() }; - let j_limit: i32 = if is_horizontal { matrix.get_width() } else { matrix.get_height() }; - let array: Vec> = matrix.get_array(); - { - let mut i: i32 = 0; - while i < i_limit { - { - let num_same_bit_cells: i32 = 0; - let prev_bit: i32 = -1; - { - let mut j: i32 = 0; - while j < j_limit { - { - let bit: i32 = if is_horizontal { array[i][j] } else { array[j][i] }; - if bit == prev_bit { - num_same_bit_cells += 1; - } else { - if num_same_bit_cells >= 5 { - penalty += N1 + (num_same_bit_cells - 5); - } - // Include the cell itself. - num_same_bit_cells = 1; - prev_bit = bit; - } - } - j += 1; - } - } - - if num_same_bit_cells >= 5 { - penalty += N1 + (num_same_bit_cells - 5); - } - } - i += 1; - } - } - - return penalty; - } -} - -// NEW FILE: matrix_util.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::encoder; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author dswitkin@google.com (Daniel Switkin) - ported from C++ - */ - - const POSITION_DETECTION_PATTERN: vec![vec![Vec>; 7]; 7] = vec![vec![1, 1, 1, 1, 1, 1, 1, ] -, vec![1, 0, 0, 0, 0, 0, 1, ] -, vec![1, 0, 1, 1, 1, 0, 1, ] -, vec![1, 0, 1, 1, 1, 0, 1, ] -, vec![1, 0, 1, 1, 1, 0, 1, ] -, vec![1, 0, 0, 0, 0, 0, 1, ] -, vec![1, 1, 1, 1, 1, 1, 1, ] -, ] -; - - const POSITION_ADJUSTMENT_PATTERN: vec![vec![Vec>; 5]; 5] = vec![vec![1, 1, 1, 1, 1, ] -, vec![1, 0, 0, 0, 1, ] -, vec![1, 0, 1, 0, 1, ] -, vec![1, 0, 0, 0, 1, ] -, vec![1, 1, 1, 1, 1, ] -, ] -; - -// From Appendix E. Table 1, JIS0510X:2004 (p 71). The table was double-checked by komatsu. - const POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE: vec![vec![Vec>; 7]; 40] = vec![// Version 1 -vec![-1, -1, -1, -1, -1, -1, -1, ] -, // Version 2 -vec![6, 18, -1, -1, -1, -1, -1, ] -, // Version 3 -vec![6, 22, -1, -1, -1, -1, -1, ] -, // Version 4 -vec![6, 26, -1, -1, -1, -1, -1, ] -, // Version 5 -vec![6, 30, -1, -1, -1, -1, -1, ] -, // Version 6 -vec![6, 34, -1, -1, -1, -1, -1, ] -, // Version 7 -vec![6, 22, 38, -1, -1, -1, -1, ] -, // Version 8 -vec![6, 24, 42, -1, -1, -1, -1, ] -, // Version 9 -vec![6, 26, 46, -1, -1, -1, -1, ] -, // Version 10 -vec![6, 28, 50, -1, -1, -1, -1, ] -, // Version 11 -vec![6, 30, 54, -1, -1, -1, -1, ] -, // Version 12 -vec![6, 32, 58, -1, -1, -1, -1, ] -, // Version 13 -vec![6, 34, 62, -1, -1, -1, -1, ] -, // Version 14 -vec![6, 26, 46, 66, -1, -1, -1, ] -, // Version 15 -vec![6, 26, 48, 70, -1, -1, -1, ] -, // Version 16 -vec![6, 26, 50, 74, -1, -1, -1, ] -, // Version 17 -vec![6, 30, 54, 78, -1, -1, -1, ] -, // Version 18 -vec![6, 30, 56, 82, -1, -1, -1, ] -, // Version 19 -vec![6, 30, 58, 86, -1, -1, -1, ] -, // Version 20 -vec![6, 34, 62, 90, -1, -1, -1, ] -, // Version 21 -vec![6, 28, 50, 72, 94, -1, -1, ] -, // Version 22 -vec![6, 26, 50, 74, 98, -1, -1, ] -, // Version 23 -vec![6, 30, 54, 78, 102, -1, -1, ] -, // Version 24 -vec![6, 28, 54, 80, 106, -1, -1, ] -, // Version 25 -vec![6, 32, 58, 84, 110, -1, -1, ] -, // Version 26 -vec![6, 30, 58, 86, 114, -1, -1, ] -, // Version 27 -vec![6, 34, 62, 90, 118, -1, -1, ] -, // Version 28 -vec![6, 26, 50, 74, 98, 122, -1, ] -, // Version 29 -vec![6, 30, 54, 78, 102, 126, -1, ] -, // Version 30 -vec![6, 26, 52, 78, 104, 130, -1, ] -, // Version 31 -vec![6, 30, 56, 82, 108, 134, -1, ] -, // Version 32 -vec![6, 34, 60, 86, 112, 138, -1, ] -, // Version 33 -vec![6, 30, 58, 86, 114, 142, -1, ] -, // Version 34 -vec![6, 34, 62, 90, 118, 146, -1, ] -, // Version 35 -vec![6, 30, 54, 78, 102, 126, 150, ] -, // Version 36 -vec![6, 24, 50, 76, 102, 128, 154, ] -, // Version 37 -vec![6, 28, 54, 80, 106, 132, 158, ] -, // Version 38 -vec![6, 32, 58, 84, 110, 136, 162, ] -, // Version 39 -vec![6, 26, 54, 82, 110, 138, 166, ] -, // Version 40 -vec![6, 30, 58, 86, 114, 142, 170, ] -, ] -; - -// Type info cells at the left top corner. - const TYPE_INFO_COORDINATES: vec![vec![Vec>; 2]; 15] = vec![vec![8, 0, ] -, vec![8, 1, ] -, vec![8, 2, ] -, vec![8, 3, ] -, vec![8, 4, ] -, vec![8, 5, ] -, vec![8, 7, ] -, vec![8, 8, ] -, vec![7, 8, ] -, vec![5, 8, ] -, vec![4, 8, ] -, vec![3, 8, ] -, vec![2, 8, ] -, vec![1, 8, ] -, vec![0, 8, ] -, ] -; - -// From Appendix D in JISX0510:2004 (p. 67) -// 1 1111 0010 0101 - const VERSION_INFO_POLY: i32 = 0x1f25; - -// From Appendix C in JISX0510:2004 (p.65). - const TYPE_INFO_POLY: i32 = 0x537; - - const TYPE_INFO_MASK_PATTERN: i32 = 0x5412; -struct MatrixUtil { -} - -impl MatrixUtil { - - fn new() -> MatrixUtil { - // do nothing - } - - // 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 - // with the ByteMatrix initialized all to zero. - fn clear_matrix( matrix: &ByteMatrix) { - matrix.clear(-1 as i8); - } - - // Build 2D matrix of QR Code from "dataBits" with "ecLevel", "version" and "getMaskPattern". On - // success, store the result in "matrix" and return true. - fn build_matrix( data_bits: &BitArray, ec_level: &ErrorCorrectionLevel, version: &Version, mask_pattern: i32, matrix: &ByteMatrix) -> /* throws WriterException */Result> { - ::clear_matrix(matrix); - ::embed_basic_patterns(version, matrix); - // Type information appear with any version. - ::embed_type_info(ec_level, mask_pattern, matrix); - // Version info appear if version >= 7. - ::maybe_embed_version_info(version, matrix); - // Data should be embedded at end. - ::embed_data_bits(data_bits, mask_pattern, matrix); - } - - // Embed basic patterns. On success, modify the matrix and return true. - // The basic patterns are: - // - Position detection patterns - // - Timing patterns - // - Dark dot at the left bottom corner - // - Position adjustment patterns, if need be - fn embed_basic_patterns( version: &Version, matrix: &ByteMatrix) -> /* throws WriterException */Result> { - // Let's get started with embedding big squares at corners. - ::embed_position_detection_patterns_and_separators(matrix); - // Then, embed the dark dot at the left bottom corner. - ::embed_dark_dot_at_left_bottom_corner(matrix); - // Position adjustment patterns appear if version >= 2. - ::maybe_embed_position_adjustment_patterns(version, matrix); - // Timing patterns should be embedded after position adj. patterns. - ::embed_timing_patterns(matrix); - } - - // Embed type information. On success, modify the matrix. - fn embed_type_info( ec_level: &ErrorCorrectionLevel, mask_pattern: i32, matrix: &ByteMatrix) -> /* throws WriterException */Result> { - let type_info_bits: BitArray = BitArray::new(); - ::make_type_info_bits(ec_level, mask_pattern, type_info_bits); - { - let mut i: i32 = 0; - while i < type_info_bits.get_size() { - { - // Place bits in LSB to MSB order. LSB (least significant bit) is the last value in - // "typeInfoBits". - let bit: bool = type_info_bits.get(type_info_bits.get_size() - 1 - i); - // Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46). - let coordinates: Vec = TYPE_INFO_COORDINATES[i]; - let x1: i32 = coordinates[0]; - let y1: i32 = coordinates[1]; - matrix.set(x1, y1, bit); - let mut x2: i32; - let mut y2: i32; - if i < 8 { - // Right top corner. - x2 = matrix.get_width() - i - 1; - y2 = 8; - } else { - // Left bottom corner. - x2 = 8; - y2 = matrix.get_height() - 7 + (i - 8); - } - matrix.set(x2, y2, bit); - } - i += 1; - } - } - - } - - // Embed version information if need be. On success, modify the matrix and return true. - // See 8.10 of JISX0510:2004 (p.47) for how to embed version information. - fn maybe_embed_version_info( version: &Version, matrix: &ByteMatrix) -> /* throws WriterException */Result> { - if version.get_version_number() < 7 { - // Don't need version info. - return; - } - let version_info_bits: BitArray = BitArray::new(); - ::make_version_info_bits(version, version_info_bits); - // It will decrease from 17 to 0. - let bit_index: i32 = 6 * 3 - 1; - { - let mut i: i32 = 0; - while i < 6 { - { - { - let mut j: i32 = 0; - while j < 3 { - { - // Place bits in LSB (least significant bit) to MSB order. - let bit: bool = version_info_bits.get(bit_index); - bit_index -= 1; - // Left bottom corner. - matrix.set(i, matrix.get_height() - 11 + j, bit); - // Right bottom corner. - matrix.set(matrix.get_height() - 11 + j, i, bit); - } - j += 1; - } - } - - } - i += 1; - } - } - - } - - // Embed "dataBits" using "getMaskPattern". On success, modify the matrix and return true. - // For debugging purposes, it skips masking process if "getMaskPattern" is -1. - // See 8.7 of JISX0510:2004 (p.38) for how to embed data bits. - fn embed_data_bits( data_bits: &BitArray, mask_pattern: i32, matrix: &ByteMatrix) -> /* throws WriterException */Result> { - let bit_index: i32 = 0; - let mut direction: i32 = -1; - // Start from the right bottom cell. - let mut x: i32 = matrix.get_width() - 1; - let mut y: i32 = matrix.get_height() - 1; - while x > 0 { - // Skip the vertical timing pattern. - if x == 6 { - x -= 1; - } - while y >= 0 && y < matrix.get_height() { - { - let mut i: i32 = 0; - while i < 2 { - { - let xx: i32 = x - i; - // Skip the cell if it's not empty. - if !::is_empty(&matrix.get(xx, y)) { - continue; - } - let mut bit: bool; - if bit_index < data_bits.get_size() { - bit = data_bits.get(bit_index); - bit_index += 1; - } else { - // Padding bit. If there is no bit left, we'll fill the left cells with 0, as described - // in 8.4.9 of JISX0510:2004 (p. 24). - bit = false; - } - // Skip masking if mask_pattern is -1. - if mask_pattern != -1 && MaskUtil::get_data_mask_bit(mask_pattern, xx, y) { - bit = !bit; - } - matrix.set(xx, y, bit); - } - i += 1; - } - } - - y += direction; - } - // Reverse the direction. - direction = -direction; - y += direction; - // Move to the left. - x -= 2; - } - // All bits should be consumed. - if bit_index != data_bits.get_size() { - throw WriterException::new(format!("Not all bits consumed: {}/{}", bit_index, data_bits.get_size())); - } - } - - // Return the position of the most significant bit set (to one) in the "value". The most - // significant bit is position 32. If there is no bit set, return 0. Examples: - // - findMSBSet(0) => 0 - // - findMSBSet(1) => 1 - // - findMSBSet(255) => 8 - fn find_m_s_b_set( value: i32) -> i32 { - return 32 - Integer::number_of_leading_zeros(value); - } - - // Calculate BCH (Bose-Chaudhuri-Hocquenghem) code for "value" using polynomial "poly". The BCH - // code is used for encoding type information and version information. - // Example: Calculation of version information of 7. - // f(x) is created from 7. - // - 7 = 000111 in 6 bits - // - f(x) = x^2 + x^1 + x^0 - // g(x) is given by the standard (p. 67) - // - g(x) = x^12 + x^11 + x^10 + x^9 + x^8 + x^5 + x^2 + 1 - // Multiply f(x) by x^(18 - 6) - // - f'(x) = f(x) * x^(18 - 6) - // - f'(x) = x^14 + x^13 + x^12 - // Calculate the remainder of f'(x) / g(x) - // x^2 - // __________________________________________________ - // g(x) )x^14 + x^13 + x^12 - // x^14 + x^13 + x^12 + x^11 + x^10 + x^7 + x^4 + x^2 - // -------------------------------------------------- - // x^11 + x^10 + x^7 + x^4 + x^2 - // - // The remainder is x^11 + x^10 + x^7 + x^4 + x^2 - // Encode it in binary: 110010010100 - // 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 - // operations. We don't care if coefficients are positive or negative. - fn calculate_b_c_h_code( value: i32, poly: i32) -> i32 { - if poly == 0 { - throw IllegalArgumentException::new("0 polynomial"); - } - // If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1 - // from 13 to make it 12. - let msb_set_in_poly: i32 = ::find_m_s_b_set(poly); - value <<= msb_set_in_poly - 1; - // Do the division business using exclusive-or operations. - while ::find_m_s_b_set(value) >= msb_set_in_poly { - value ^= poly << (::find_m_s_b_set(value) - msb_set_in_poly); - } - // Now the "value" is the remainder (i.e. the BCH code) - return value; - } - - // Make bit vector of type information. On success, store the result in "bits" and return true. - // Encode error correction level and mask pattern. See 8.9 of - // JISX0510:2004 (p.45) for details. - fn make_type_info_bits( ec_level: &ErrorCorrectionLevel, mask_pattern: i32, bits: &BitArray) -> /* throws WriterException */Result> { - if !QRCode::is_valid_mask_pattern(mask_pattern) { - throw WriterException::new("Invalid mask pattern"); - } - let type_info: i32 = (ec_level.get_bits() << 3) | mask_pattern; - bits.append_bits(type_info, 5); - let bch_code: i32 = ::calculate_b_c_h_code(type_info, TYPE_INFO_POLY); - bits.append_bits(bch_code, 10); - let mask_bits: BitArray = BitArray::new(); - mask_bits.append_bits(TYPE_INFO_MASK_PATTERN, 15); - bits.xor(mask_bits); - if bits.get_size() != 15 { - // Just in case. - throw WriterException::new(format!("should not happen but we got: {}", bits.get_size())); - } - } - - // Make bit vector of version information. On success, store the result in "bits" and return true. - // See 8.10 of JISX0510:2004 (p.45) for details. - fn make_version_info_bits( version: &Version, bits: &BitArray) -> /* throws WriterException */Result> { - bits.append_bits(&version.get_version_number(), 6); - let bch_code: i32 = ::calculate_b_c_h_code(&version.get_version_number(), VERSION_INFO_POLY); - bits.append_bits(bch_code, 12); - if bits.get_size() != 18 { - // Just in case. - throw WriterException::new(format!("should not happen but we got: {}", bits.get_size())); - } - } - - // Check if "value" is empty. - fn is_empty( value: i32) -> bool { - return value == -1; - } - - fn embed_timing_patterns( matrix: &ByteMatrix) { - // separation patterns (size 1). Thus, 8 = 7 + 1. - { - let mut i: i32 = 8; - while i < matrix.get_width() - 8 { - { - let bit: i32 = (i + 1) % 2; - // Horizontal line. - if ::is_empty(&matrix.get(i, 6)) { - matrix.set(i, 6, bit); - } - // Vertical line. - if ::is_empty(&matrix.get(6, i)) { - matrix.set(6, i, bit); - } - } - i += 1; - } - } - - } - - // Embed the lonely dark dot at left bottom corner. JISX0510:2004 (p.46) - fn embed_dark_dot_at_left_bottom_corner( matrix: &ByteMatrix) -> /* throws WriterException */Result> { - if matrix.get(8, matrix.get_height() - 8) == 0 { - throw WriterException::new(); - } - matrix.set(8, matrix.get_height() - 8, 1); - } - - fn embed_horizontal_separation_pattern( x_start: i32, y_start: i32, matrix: &ByteMatrix) -> /* throws WriterException */Result> { - { - let mut x: i32 = 0; - while x < 8 { - { - if !::is_empty(&matrix.get(x_start + x, y_start)) { - throw WriterException::new(); - } - matrix.set(x_start + x, y_start, 0); - } - x += 1; - } - } - - } - - fn embed_vertical_separation_pattern( x_start: i32, y_start: i32, matrix: &ByteMatrix) -> /* throws WriterException */Result> { - { - let mut y: i32 = 0; - while y < 7 { - { - if !::is_empty(&matrix.get(x_start, y_start + y)) { - throw WriterException::new(); - } - matrix.set(x_start, y_start + y, 0); - } - y += 1; - } - } - - } - - fn embed_position_adjustment_pattern( x_start: i32, y_start: i32, matrix: &ByteMatrix) { - { - let mut y: i32 = 0; - while y < 5 { - { - let pattern_y: Vec = POSITION_ADJUSTMENT_PATTERN[y]; - { - let mut x: i32 = 0; - while x < 5 { - { - matrix.set(x_start + x, y_start + y, pattern_y[x]); - } - x += 1; - } - } - - } - y += 1; - } - } - - } - - fn embed_position_detection_pattern( x_start: i32, y_start: i32, matrix: &ByteMatrix) { - { - let mut y: i32 = 0; - while y < 7 { - { - let pattern_y: Vec = POSITION_DETECTION_PATTERN[y]; - { - let mut x: i32 = 0; - while x < 7 { - { - matrix.set(x_start + x, y_start + y, pattern_y[x]); - } - x += 1; - } - } - - } - y += 1; - } - } - - } - - // Embed position detection patterns and surrounding vertical/horizontal separators. - fn embed_position_detection_patterns_and_separators( matrix: &ByteMatrix) -> /* throws WriterException */Result> { - // Embed three big squares at corners. - let pdp_width: i32 = POSITION_DETECTION_PATTERN[0].len(); - // Left top corner. - ::embed_position_detection_pattern(0, 0, matrix); - // Right top corner. - ::embed_position_detection_pattern(matrix.get_width() - pdp_width, 0, matrix); - // Left bottom corner. - ::embed_position_detection_pattern(0, matrix.get_width() - pdp_width, matrix); - // Embed horizontal separation patterns around the squares. - let hsp_width: i32 = 8; - // Left top corner. - ::embed_horizontal_separation_pattern(0, hsp_width - 1, matrix); - // Right top corner. - ::embed_horizontal_separation_pattern(matrix.get_width() - hsp_width, hsp_width - 1, matrix); - // Left bottom corner. - ::embed_horizontal_separation_pattern(0, matrix.get_width() - hsp_width, matrix); - // Embed vertical separation patterns around the squares. - let vsp_size: i32 = 7; - // Left top corner. - ::embed_vertical_separation_pattern(vsp_size, 0, matrix); - // Right top corner. - ::embed_vertical_separation_pattern(matrix.get_height() - vsp_size - 1, 0, matrix); - // Left bottom corner. - ::embed_vertical_separation_pattern(vsp_size, matrix.get_height() - vsp_size, matrix); - } - - // Embed position adjustment patterns if need be. - fn maybe_embed_position_adjustment_patterns( version: &Version, matrix: &ByteMatrix) { - if version.get_version_number() < 2 { - // The patterns appear if version >= 2 - return; - } - let index: i32 = version.get_version_number() - 1; - let coordinates: Vec = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index]; - for let y: i32 in coordinates { - if y >= 0 { - for let x: i32 in coordinates { - if x >= 0 && ::is_empty(&matrix.get(x, y)) { - // If the cell is unset, we embed the position adjustment pattern here. - // -2 is necessary since the x/y coordinates point to the center of the pattern, not the - // left top corner. - ::embed_position_adjustment_pattern(x - 2, y - 2, matrix); - } - } - } - } - } -} - -// NEW FILE: minimal_encoder.rs -/* - * Copyright 2021 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::encoder; - -/** - * Encoder that encodes minimally - * - * Algorithm: - * - * The eleventh commandment was "Thou Shalt Compute" or "Thou Shalt Not Compute" - I forget which (Alan Perilis). - * - * This implementation computes. As an alternative, the QR-Code specification suggests heuristics like this one: - * - * If initial input data is in the exclusive subset of the Alphanumeric character set AND if there are less than - * [6,7,8] characters followed by data from the remainder of the 8-bit byte character set, THEN select the 8- - * bit byte mode ELSE select Alphanumeric mode; - * - * This is probably right for 99.99% of cases but there is at least this one counter example: The string "AAAAAAa" - * encodes 2 bits smaller as ALPHANUMERIC(AAAAAA), BYTE(a) than by encoding it as BYTE(AAAAAAa). - * Perhaps that is the only counter example but without having proof, it remains unclear. - * - * ECI switching: - * - * In multi language content the algorithm selects the most compact representation using ECI modes. - * For example the most compact representation of the string "\u0150\u015C" (O-double-acute, S-circumflex) is - * ECI(UTF-8), BYTE(\u0150\u015C) while prepending one or more times the same leading character as in - * "\u0150\u0150\u015C", the most compact representation uses two ECIs so that the string is encoded as - * ECI(ISO-8859-2), BYTE(\u0150\u0150), ECI(ISO-8859-3), BYTE(\u015C). - * - * @author Alex Geller - */ -struct MinimalEncoder { - - let string_to_encode: String; - - let is_g_s1: bool; - - let mut encoders: ECIEncoderSet; - - let ec_level: ErrorCorrectionLevel; -} - -impl MinimalEncoder { - - enum VersionSize { - - SMALL("version 1-9"), MEDIUM("version 10-26"), LARGE("version 27-40"); - - let description: String; - - fn new( description: &String) -> VersionSize { - let .description = description; - } - - pub fn to_string(&self) -> String { - return self.description; - } - } - - /** - * Creates a MinimalEncoder - * - * @param stringToEncode The string to encode - * @param priorityCharset The preferred {@link Charset}. When the value of the argument is null, the algorithm - * chooses charsets that leads to a minimal representation. Otherwise the algorithm will use the priority - * charset to encode any character in the input that can be encoded by it if the charset is among the - * supported charsets. - * @param isGS1 {@code true} if a FNC1 is to be prepended; {@code false} otherwise - * @param ecLevel The error correction level. - * @see ResultList#getVersion - */ - fn new( string_to_encode: &String, priority_charset: &Charset, is_g_s1: bool, ec_level: &ErrorCorrectionLevel) -> MinimalEncoder { - let .stringToEncode = string_to_encode; - let .isGS1 = is_g_s1; - let .encoders = ECIEncoderSet::new(&string_to_encode, &priority_charset, -1); - let .ecLevel = ec_level; - } - - /** - * Encodes the string minimally - * - * @param stringToEncode The string to encode - * @param version The preferred {@link Version}. A minimal version is computed (see - * {@link ResultList#getVersion method} when the value of the argument is null - * @param priorityCharset The preferred {@link Charset}. When the value of the argument is null, the algorithm - * chooses charsets that leads to a minimal representation. Otherwise the algorithm will use the priority - * charset to encode any character in the input that can be encoded by it if the charset is among the - * supported charsets. - * @param isGS1 {@code true} if a FNC1 is to be prepended; {@code false} otherwise - * @param ecLevel The error correction level. - * @return An instance of {@code ResultList} representing the minimal solution. - * @see ResultList#getBits - * @see ResultList#getVersion - * @see ResultList#getSize - */ - fn encode( string_to_encode: &String, version: &Version, priority_charset: &Charset, is_g_s1: bool, ec_level: &ErrorCorrectionLevel) -> /* throws WriterException */Result> { - return Ok(MinimalEncoder::new(&string_to_encode, &priority_charset, is_g_s1, ec_level).encode(version)); - } - - fn encode(&self, version: &Version) -> /* throws WriterException */Result> { - if version == null { - // compute minimal encoding trying the three version sizes. - let versions: vec![Vec; 3] = vec![::get_version(VersionSize::SMALL), ::get_version(VersionSize::MEDIUM), ::get_version(VersionSize::LARGE), ] - ; - let results: vec![Vec; 3] = vec![self.encode_specific_version(versions[0]), self.encode_specific_version(versions[1]), self.encode_specific_version(versions[2]), ] - ; - let smallest_size: i32 = Integer::MAX_VALUE; - let smallest_result: i32 = -1; - { - let mut i: i32 = 0; - while i < 3 { - { - let size: i32 = results[i].get_size(); - if Encoder::will_fit(size, versions[i], self.ec_level) && size < smallest_size { - smallest_size = size; - smallest_result = i; - } - } - i += 1; - } - } - - if smallest_result < 0 { - throw WriterException::new("Data too big for any version"); - } - return Ok(results[smallest_result]); - } else { - // compute minimal encoding for a given version - let result: ResultList = self.encode_specific_version(version); - if !Encoder::will_fit(&result.get_size(), &::get_version(&::get_version_size(&result.get_version())), self.ec_level) { - throw WriterException::new(format!("Data too big for version{}", version)); - } - return Ok(result); - } - } - - fn get_version_size( version: &Version) -> VersionSize { - return if version.get_version_number() <= 9 { VersionSize::SMALL } else { if version.get_version_number() <= 26 { VersionSize::MEDIUM } else { VersionSize::LARGE } }; - } - - fn get_version( version_size: &VersionSize) -> Version { - match version_size { - SMALL => - { - return Version::get_version_for_number(9); - } - MEDIUM => - { - return Version::get_version_for_number(26); - } - LARGE => - { - } - _ => - { - return Version::get_version_for_number(40); - } - } - } - - fn is_numeric( c: char) -> bool { - return c >= '0' && c <= '9'; - } - - fn is_double_byte_kanji( c: char) -> bool { - return Encoder::is_only_double_byte_kanji(&String::value_of(c)); - } - - fn is_alphanumeric( c: char) -> bool { - return Encoder::get_alphanumeric_code(c) != -1; - } - - fn can_encode(&self, mode: &Mode, c: char) -> bool { - match mode { - KANJI => - { - return ::is_double_byte_kanji(c); - } - ALPHANUMERIC => - { - return ::is_alphanumeric(c); - } - NUMERIC => - { - return ::is_numeric(c); - } - // any character can be encoded as byte(s). Up to the caller to manage splitting into - BYTE => - { - return true; - } - // multiple bytes when String.getBytes(Charset) return more than one byte. - _ => - { - return false; - } - } - } - - fn get_compacted_ordinal( mode: &Mode) -> i32 { - if mode == null { - return 0; - } - match mode { - KANJI => - { - return 0; - } - ALPHANUMERIC => - { - return 1; - } - NUMERIC => - { - return 2; - } - BYTE => - { - return 3; - } - _ => - { - throw IllegalStateException::new(format!("Illegal mode {}", mode)); - } - } - } - - fn add_edge(&self, edges: &Vec>>, position: i32, edge: &Edge) { - let vertex_index: i32 = position + edge.characterLength; - let mode_edges: Vec = edges[vertex_index][edge.charsetEncoderIndex]; - let mode_ordinal: i32 = ::get_compacted_ordinal(edge.mode); - if mode_edges[mode_ordinal] == null || mode_edges[mode_ordinal].cachedTotalSize > edge.cachedTotalSize { - mode_edges[mode_ordinal] = edge; - } - } - - fn add_edges(&self, version: &Version, edges: &Vec>>, from: i32, previous: &Edge) { - let mut start: i32 = 0; - let mut end: i32 = self.encoders.length(); - let priority_encoder_index: i32 = self.encoders.get_priority_encoder_index(); - if priority_encoder_index >= 0 && self.encoders.can_encode(&self.string_to_encode.char_at(from), priority_encoder_index) { - start = priority_encoder_index; - end = priority_encoder_index + 1; - } - { - let mut i: i32 = start; - while i < end { - { - if self.encoders.can_encode(&self.string_to_encode.char_at(from), i) { - self.add_edge(edges, from, Edge::new(Mode::BYTE, from, i, 1, previous, version)); - } - } - i += 1; - } - } - - if self.can_encode(Mode::KANJI, &self.string_to_encode.char_at(from)) { - self.add_edge(edges, from, Edge::new(Mode::KANJI, from, 0, 1, previous, version)); - } - let input_length: i32 = self.string_to_encode.length(); - if self.can_encode(Mode::ALPHANUMERIC, &self.string_to_encode.char_at(from)) { - self.add_edge(edges, from, Edge::new(Mode::ALPHANUMERIC, from, 0, if from + 1 >= input_length || !self.can_encode(Mode::ALPHANUMERIC, &self.string_to_encode.char_at(from + 1)) { 1 } else { 2 }, previous, version)); - } - if self.can_encode(Mode::NUMERIC, &self.string_to_encode.char_at(from)) { - self.add_edge(edges, from, Edge::new(Mode::NUMERIC, from, 0, if from + 1 >= input_length || !self.can_encode(Mode::NUMERIC, &self.string_to_encode.char_at(from + 1)) { 1 } else { if from + 2 >= input_length || !self.can_encode(Mode::NUMERIC, &self.string_to_encode.char_at(from + 2)) { 2 } else { 3 } }, previous, version)); - } - } - - fn encode_specific_version(&self, version: &Version) -> /* throws WriterException */Result> { - let input_length: i32 = self.string_to_encode.length(); - // Array that represents vertices. There is a vertex for every character, encoding and mode. The vertex contains - // a list of all edges that lead to it that have the same encoding and mode. - // The lists are created lazily - // The last dimension in the array below encodes the 4 modes KANJI, ALPHANUMERIC, NUMERIC and BYTE via the - // function getCompactedOrdinal(Mode) - let edges: [[[Option; 4]; self.encoders.length()]; input_length + 1] = [[[None; 4]; self.encoders.length()]; input_length + 1]; - self.add_edges(version, edges, 0, null); - { - let mut i: i32 = 1; - while i <= input_length { - { - { - let mut j: i32 = 0; - while j < self.encoders.length() { - { - { - let mut k: i32 = 0; - while k < 4 { - { - if edges[i][j][k] != null && i < input_length { - self.add_edges(version, edges, i, edges[i][j][k]); - } - } - k += 1; - } - } - - } - j += 1; - } - } - - } - i += 1; - } - } - - let minimal_j: i32 = -1; - let minimal_k: i32 = -1; - let minimal_size: i32 = Integer::MAX_VALUE; - { - let mut j: i32 = 0; - while j < self.encoders.length() { - { - { - let mut k: i32 = 0; - while k < 4 { - { - if edges[input_length][j][k] != null { - let edge: Edge = edges[input_length][j][k]; - if edge.cachedTotalSize < minimal_size { - minimal_size = edge.cachedTotalSize; - minimal_j = j; - minimal_k = k; - } - } - } - k += 1; - } - } - - } - j += 1; - } - } - - if minimal_j < 0 { - throw WriterException::new(format!("Internal error: failed to encode \"{}\"", self.string_to_encode)); - } - return Ok(ResultList::new(version, edges[input_length][minimal_j][minimal_k])); - } - - struct Edge { - - let mode: Mode; - - let from_position: i32; - - let charset_encoder_index: i32; - - let character_length: i32; - - let previous: Edge; - - let cached_total_size: i32; - } - - impl Edge { - - fn new( mode: &Mode, from_position: i32, charset_encoder_index: i32, character_length: i32, previous: &Edge, version: &Version) -> Edge { - let .mode = mode; - let .fromPosition = from_position; - let .charsetEncoderIndex = if mode == Mode::BYTE || previous == null { charset_encoder_index } else { // inherit the encoding if not of type BYTE - previous.charsetEncoderIndex }; - let .characterLength = character_length; - let .previous = previous; - let mut size: i32 = if previous != null { previous.cachedTotalSize } else { 0 }; - let need_e_c_i: bool = mode == Mode::BYTE && // at the beginning and charset is not ISO-8859-1 - (previous == null && let .charsetEncoderIndex != 0) || (previous != null && let .charsetEncoderIndex != previous.charsetEncoderIndex); - if previous == null || mode != previous.mode || need_e_c_i { - size += 4 + mode.get_character_count_bits(version); - } - match mode { - KANJI => - { - size += 13; - break; - } - ALPHANUMERIC => - { - size += if character_length == 1 { 6 } else { 11 }; - break; - } - NUMERIC => - { - size += if character_length == 1 { 4 } else { if character_length == 2 { 7 } else { 10 } }; - break; - } - BYTE => - { - size += 8 * encoders.encode(&string_to_encode.substring(from_position, from_position + character_length), charset_encoder_index).len(); - if need_e_c_i { - // the ECI assignment numbers for ISO-8859-x, UTF-8 and UTF-16 are all 8 bit long - size += 4 + 8; - } - break; - } - } - cached_total_size = size; - } - } - - - struct ResultList { - - let list: List = ArrayList<>::new(); - - let version: Version; - } - - impl ResultList { - - fn new( version: &Version, solution: &Edge) -> ResultList { - let mut length: i32 = 0; - let mut current: Edge = solution; - let contains_e_c_i: bool = false; - while current != null { - length += current.characterLength; - let previous: Edge = current.previous; - let need_e_c_i: bool = current.mode == Mode::BYTE && // at the beginning and charset is not ISO-8859-1 - (previous == null && current.charsetEncoderIndex != 0) || (previous != null && current.charsetEncoderIndex != previous.charsetEncoderIndex); - if need_e_c_i { - contains_e_c_i = true; - } - if previous == null || previous.mode != current.mode || need_e_c_i { - list.add(0, ResultNode::new(current.mode, current.fromPosition, current.charsetEncoderIndex, length)); - length = 0; - } - if need_e_c_i { - list.add(0, ResultNode::new(Mode::ECI, current.fromPosition, current.charsetEncoderIndex, 0)); - } - current = previous; - } - // If there is no ECI at the beginning then we put an ECI to the default charset (ISO-8859-1) - if is_g_s1 { - let mut first: ResultNode = list.get(0); - if first != null && first.mode != Mode::ECI && contains_e_c_i { - // prepend a default character set ECI - list.add(0, ResultNode::new(Mode::ECI, 0, 0, 0)); - } - first = list.get(0); - // prepend or insert a FNC1_FIRST_POSITION after the ECI (if any) - list.add( if first.mode != Mode::ECI { 0 } else { 1 }, ResultNode::new(Mode::FNC1_FIRST_POSITION, 0, 0, 0)); - } - // set version to smallest version into which the bits fit. - let version_number: i32 = version.get_version_number(); - let lower_limit: i32; - let upper_limit: i32; - match ::get_version_size(version) { - SMALL => - { - lower_limit = 1; - upper_limit = 9; - break; - } - MEDIUM => - { - lower_limit = 10; - upper_limit = 26; - break; - } - LARGE => - { - } - _ => - { - lower_limit = 27; - upper_limit = 40; - break; - } - } - let size: i32 = self.get_size(version); - // increase version if needed - while version_number < upper_limit && !Encoder::will_fit(size, &Version::get_version_for_number(version_number), ec_level) { - version_number += 1; - } - // shrink version if possible - while version_number > lower_limit && Encoder::will_fit(size, &Version::get_version_for_number(version_number - 1), ec_level) { - version_number -= 1; - } - let .version = Version::get_version_for_number(version_number); - } - - /** - * returns the size in bits - */ - fn get_size(&self) -> i32 { - return self.get_size(self.version); - } - - fn get_size(&self, version: &Version) -> i32 { - let mut result: i32 = 0; - for let result_node: ResultNode in self.list { - result += result_node.get_size(version); - } - return result; - } - - /** - * appends the bits - */ - fn get_bits(&self, bits: &BitArray) -> /* throws WriterException */Result> { - for let result_node: ResultNode in self.list { - result_node.get_bits(bits); - } - } - - fn get_version(&self) -> Version { - return self.version; - } - - pub fn to_string(&self) -> String { - let result: StringBuilder = StringBuilder::new(); - let mut previous: ResultNode = null; - for let current: ResultNode in self.list { - if previous != null { - result.append(","); - } - result.append(¤t.to_string()); - previous = current; - } - return result.to_string(); - } - - struct ResultNode { - - let mode: Mode; - - let from_position: i32; - - let charset_encoder_index: i32; - - let character_length: i32; - } - - impl ResultNode { - - fn new( mode: &Mode, from_position: i32, charset_encoder_index: i32, character_length: i32) -> ResultNode { - let .mode = mode; - let .fromPosition = from_position; - let .charsetEncoderIndex = charset_encoder_index; - let .characterLength = character_length; - } - - /** - * returns the size in bits - */ - fn get_size(&self, version: &Version) -> i32 { - let mut size: i32 = 4 + self.mode.get_character_count_bits(version); - match self.mode { - KANJI => - { - size += 13 * self.character_length; - break; - } - ALPHANUMERIC => - { - size += (self.character_length / 2) * 11; - size += if (self.character_length % 2) == 1 { 6 } else { 0 }; - break; - } - NUMERIC => - { - size += (self.character_length / 3) * 10; - let rest: i32 = self.character_length % 3; - size += if rest == 1 { 4 } else { if rest == 2 { 7 } else { 0 } }; - break; - } - BYTE => - { - size += 8 * self.get_character_count_indicator(); - break; - } - ECI => - { - // the ECI assignment numbers for ISO-8859-x, UTF-8 and UTF-16 are all 8 bit long - size += 8; - } - } - return size; - } - - /** - * returns the length in characters according to the specification (differs from getCharacterLength() in BYTE mode - * for multi byte encoded characters) - */ - fn get_character_count_indicator(&self) -> i32 { - return if self.mode == Mode::BYTE { self.encoders.encode(&self.string_to_encode.substring(self.from_position, self.from_position + self.character_length), self.charset_encoder_index).len() } else { self.character_length }; - } - - /** - * appends the bits - */ - fn get_bits(&self, bits: &BitArray) -> /* throws WriterException */Result> { - bits.append_bits(&self.mode.get_bits(), 4); - if self.character_length > 0 { - let length: i32 = self.get_character_count_indicator(); - bits.append_bits(length, &self.mode.get_character_count_bits(self.version)); - } - if self.mode == Mode::ECI { - bits.append_bits(&self.encoders.get_e_c_i_value(self.charset_encoder_index), 8); - } else if self.character_length > 0 { - // append data - Encoder::append_bytes(&self.string_to_encode.substring(self.from_position, self.from_position + self.character_length), self.mode, bits, &self.encoders.get_charset(self.charset_encoder_index)); - } - } - - pub fn to_string(&self) -> String { - let result: StringBuilder = StringBuilder::new(); - result.append(self.mode).append('('); - if self.mode == Mode::ECI { - result.append(&self.encoders.get_charset(self.charset_encoder_index).display_name()); - } else { - result.append(&self.make_printable(&self.string_to_encode.substring(self.from_position, self.from_position + self.character_length))); - } - result.append(')'); - return result.to_string(); - } - - fn make_printable(&self, s: &String) -> String { - let result: StringBuilder = StringBuilder::new(); - { - let mut i: i32 = 0; - while i < s.length() { - { - if s.char_at(i) < 32 || s.char_at(i) > 126 { - result.append('.'); - } else { - result.append(&s.char_at(i)); - } - } - i += 1; - } - } - - return result.to_string(); - } - } - - } - -} - -// NEW FILE: q_r_code.rs -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// package com::google::zxing::qrcode::encoder; - -/** - * @author satorux@google.com (Satoru Takabayashi) - creator - * @author dswitkin@google.com (Daniel Switkin) - ported from C++ - */ - - const NUM_MASK_PATTERNS: i32 = 8; -pub struct QRCode { - - let mut mode: Mode; - - let ec_level: ErrorCorrectionLevel; - - let version: Version; - - let mask_pattern: i32; - - let mut matrix: ByteMatrix; -} - -impl QRCode { - - pub fn new() -> QRCode { - mask_pattern = -1; - } - - /** - * @return the mode. Not relevant if {@link com.google.zxing.EncodeHintType#QR_COMPACT} is selected. - */ - pub fn get_mode(&self) -> Mode { - return self.mode; - } - - pub fn get_e_c_level(&self) -> ErrorCorrectionLevel { - return self.ec_level; - } - - pub fn get_version(&self) -> Version { - return self.version; - } - - pub fn get_mask_pattern(&self) -> i32 { - return self.mask_pattern; - } - - pub fn get_matrix(&self) -> ByteMatrix { - return self.matrix; - } - - pub fn to_string(&self) -> String { - let result: StringBuilder = StringBuilder::new(200); - result.append("<<\n"); - result.append(" mode: "); - result.append(self.mode); - result.append("\n ecLevel: "); - result.append(self.ec_level); - result.append("\n version: "); - result.append(self.version); - result.append("\n maskPattern: "); - result.append(self.mask_pattern); - if self.matrix == null { - result.append("\n matrix: null\n"); - } else { - result.append("\n matrix:\n"); - result.append(self.matrix); - } - result.append(">>\n"); - return result.to_string(); - } - - pub fn set_mode(&self, value: &Mode) { - self.mode = value; - } - - pub fn set_e_c_level(&self, value: &ErrorCorrectionLevel) { - self.ec_level = value; - } - - pub fn set_version(&self, version: &Version) { - self.version = version; - } - - pub fn set_mask_pattern(&self, value: i32) { - self.mask_pattern = value; - } - - pub fn set_matrix(&self, value: &ByteMatrix) { - self.matrix = value; - } - - // Check if "mask_pattern" is valid. - pub fn is_valid_mask_pattern( mask_pattern: i32) -> bool { - return mask_pattern >= 0 && mask_pattern < NUM_MASK_PATTERNS; - } -} -