mirror of
https://github.com/zxing/zxing.git
synced 2024-11-10 04:54:04 -08:00
Clean up whitespace (#800)
This commit is contained in:
parent
5a5237b4a8
commit
7df4aa6694
|
@ -114,7 +114,7 @@ public enum DecodeHintType {
|
|||
DecodeHintType(Class<?> valueType) {
|
||||
this.valueType = valueType;
|
||||
}
|
||||
|
||||
|
||||
public Class<?> getValueType() {
|
||||
return valueType;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ 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();
|
||||
|
@ -40,7 +40,7 @@ public final class Dimension {
|
|||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof Dimension) {
|
||||
Dimension d = (Dimension) other;
|
||||
|
@ -49,7 +49,7 @@ public final class Dimension {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return width * 32713 + height;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public enum EncodeHintType {
|
|||
* (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).
|
||||
|
|
|
@ -40,8 +40,8 @@ public final class FormatException extends ReaderException {
|
|||
public static FormatException getFormatInstance() {
|
||||
return isStackTrace ? new FormatException() : INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
public static FormatException getFormatInstance(Throwable cause) {
|
||||
return isStackTrace ? new FormatException(cause) : INSTANCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ 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 {
|
||||
|
@ -51,7 +51,7 @@ public final class InvertedLuminanceSource extends LuminanceSource {
|
|||
}
|
||||
return invertedMatrix;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCropSupported() {
|
||||
return delegate.isCropSupported();
|
||||
|
|
|
@ -29,7 +29,7 @@ package com.google.zxing;
|
|||
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;
|
||||
|
@ -138,17 +138,17 @@ public final class PlanarYUVLuminanceSource extends LuminanceSource {
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public final class RGBLuminanceSource extends LuminanceSource {
|
|||
luminances[offset] = (byte) ((r + g2 + b) / 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private RGBLuminanceSource(byte[] pixels,
|
||||
int dataWidth,
|
||||
int dataHeight,
|
||||
|
@ -116,7 +116,7 @@ public final class RGBLuminanceSource extends LuminanceSource {
|
|||
}
|
||||
return matrix;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCropSupported() {
|
||||
return true;
|
||||
|
|
|
@ -66,4 +66,4 @@ public interface Reader {
|
|||
*/
|
||||
void reset();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public enum ResultMetadataType {
|
|||
* For some products, indicates the suggested retail price in the barcode as a
|
||||
* formatted {@link String}.
|
||||
*/
|
||||
SUGGESTED_PRICE ,
|
||||
SUGGESTED_PRICE,
|
||||
|
||||
/**
|
||||
* For some products, the possible country of manufacture as a {@link String} denoting the
|
||||
|
@ -93,5 +93,5 @@ public enum ResultMetadataType {
|
|||
* parity is given with it.
|
||||
*/
|
||||
STRUCTURED_APPEND_PARITY,
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -107,7 +107,6 @@ public class ResultPoint {
|
|||
patterns[2] = pointC;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param pattern1 first pattern
|
||||
* @param pattern2 second pattern
|
||||
|
@ -128,5 +127,4 @@ public class ResultPoint {
|
|||
return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public final class WriterException extends Exception {
|
|||
public WriterException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
public WriterException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ public final class AztecReader implements Reader {
|
|||
points,
|
||||
BarcodeFormat.AZTEC,
|
||||
System.currentTimeMillis());
|
||||
|
||||
|
||||
List<byte[]> byteSegments = decoderResult.getByteSegments();
|
||||
if (byteSegments != null) {
|
||||
result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
|
||||
|
@ -110,7 +110,7 @@ public final class AztecReader implements Reader {
|
|||
if (ecLevel != null) {
|
||||
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.Map;
|
|||
* Renders an Aztec code as a {@link BitMatrix}.
|
||||
*/
|
||||
public final class AztecWriter implements Writer {
|
||||
|
||||
|
||||
private static final Charset DEFAULT_CHARSET = Charset.forName("ISO-8859-1");
|
||||
|
||||
@Override
|
||||
|
|
|
@ -76,17 +76,17 @@ public final class Detector {
|
|||
|
||||
// 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 % 4],
|
||||
bullsEyeCorners[(shift + 1) % 4],
|
||||
bullsEyeCorners[(shift + 2) % 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);
|
||||
}
|
||||
|
||||
|
@ -105,13 +105,13 @@ public final class Detector {
|
|||
// 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[1], bullsEyeCorners[2], length), // Bottom
|
||||
sampleLine(bullsEyeCorners[2], bullsEyeCorners[3], length), // Left side
|
||||
sampleLine(bullsEyeCorners[3], bullsEyeCorners[0], length) // Top
|
||||
sampleLine(bullsEyeCorners[3], bullsEyeCorners[0], length) // Top
|
||||
};
|
||||
|
||||
// bullsEyeCorners[shift] is the corner of the bulls'eye that has three
|
||||
// orientation marks.
|
||||
// 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);
|
||||
|
@ -130,11 +130,11 @@ public final class Detector {
|
|||
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;
|
||||
|
@ -222,25 +222,25 @@ public final class Detector {
|
|||
}
|
||||
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);
|
||||
|
@ -269,9 +269,9 @@ public final class Detector {
|
|||
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);
|
||||
|
@ -319,7 +319,7 @@ public final class Detector {
|
|||
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);
|
||||
|
@ -341,7 +341,7 @@ public final class Detector {
|
|||
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);
|
||||
|
@ -369,7 +369,7 @@ public final class Detector {
|
|||
ResultPoint topRight,
|
||||
ResultPoint bottomRight,
|
||||
ResultPoint bottomLeft) throws NotFoundException {
|
||||
|
||||
|
||||
GridSampler sampler = GridSampler.getInstance();
|
||||
int dimension = getDimension();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import com.google.zxing.common.BitMatrix;
|
|||
|
||||
/**
|
||||
* Aztec 2D code representation
|
||||
*
|
||||
*
|
||||
* @author Rustam Abdullaev
|
||||
*/
|
||||
public final class AztecCode {
|
||||
|
@ -52,14 +52,14 @@ public final class AztecCode {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ package com.google.zxing.aztec.encoder;
|
|||
import com.google.zxing.common.BitArray;
|
||||
|
||||
final class BinaryShiftToken extends Token {
|
||||
|
||||
|
||||
private final short binaryShiftStart;
|
||||
private final short binaryShiftByteCount;
|
||||
|
||||
|
||||
BinaryShiftToken(Token previous,
|
||||
int binaryShiftStart,
|
||||
int binaryShiftByteCount) {
|
||||
|
@ -34,7 +34,7 @@ final class BinaryShiftToken extends Token {
|
|||
@Override
|
||||
public void appendTo(BitArray bitArray, byte[] text) {
|
||||
for (int i = 0; i < binaryShiftByteCount; i++) {
|
||||
if (i == 0 || (i == 31 && binaryShiftByteCount <= 62)) {
|
||||
if (i == 0 || (i == 31 && binaryShiftByteCount <= 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
|
||||
|
|
|
@ -43,17 +43,17 @@ public final class Encoder {
|
|||
|
||||
/**
|
||||
* Encodes the given binary content as an Aztec symbol
|
||||
*
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
|
@ -63,7 +63,7 @@ public final class Encoder {
|
|||
public static AztecCode encode(byte[] data, int minECCPercent, int userSpecifiedLayers) {
|
||||
// High-level encode
|
||||
BitArray bits = new HighLevelEncoder(data).encode();
|
||||
|
||||
|
||||
// stuff bits and choose symbol size
|
||||
int eccBits = bits.getSize() * minECCPercent / 100 + 11;
|
||||
int totalSizeBits = bits.getSize() + eccBits;
|
||||
|
@ -123,7 +123,7 @@ public final class Encoder {
|
|||
}
|
||||
}
|
||||
BitArray messageBits = generateCheckWords(stuffedBits, totalBitsInLayer, wordSize);
|
||||
|
||||
|
||||
// generate mode message
|
||||
int messageSizeInWords = stuffedBits.getSize() / wordSize;
|
||||
BitArray modeMessage = generateModeMessage(compact, layers, messageSizeInWords);
|
||||
|
@ -149,7 +149,7 @@ public final class Encoder {
|
|||
}
|
||||
}
|
||||
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);
|
||||
|
@ -175,7 +175,7 @@ public final class Encoder {
|
|||
|
||||
// draw mode message
|
||||
drawModeMessage(matrix, compact, matrixSize, modeMessage);
|
||||
|
||||
|
||||
// draw alignment marks
|
||||
if (compact) {
|
||||
drawBullsEye(matrix, matrixSize / 2, 5);
|
||||
|
@ -190,7 +190,7 @@ public final class Encoder {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AztecCode aztec = new AztecCode();
|
||||
aztec.setCompact(compact);
|
||||
aztec.setSize(matrixSize);
|
||||
|
@ -199,7 +199,7 @@ public final class Encoder {
|
|||
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++) {
|
||||
|
@ -216,7 +216,7 @@ public final class Encoder {
|
|||
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) {
|
||||
|
@ -230,7 +230,7 @@ public final class Encoder {
|
|||
}
|
||||
return modeMessage;
|
||||
}
|
||||
|
||||
|
||||
private static void drawModeMessage(BitMatrix matrix, boolean compact, int matrixSize, BitArray modeMessage) {
|
||||
int center = matrixSize / 2;
|
||||
if (compact) {
|
||||
|
@ -267,7 +267,7 @@ public final class Encoder {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
@ -283,7 +283,7 @@ public final class Encoder {
|
|||
}
|
||||
return messageBits;
|
||||
}
|
||||
|
||||
|
||||
private static int[] bitsToWords(BitArray stuffedBits, int wordSize, int totalWords) {
|
||||
int[] message = new int[totalWords];
|
||||
int i;
|
||||
|
@ -297,7 +297,7 @@ public final class Encoder {
|
|||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
private static GenericGF getGF(int wordSize) {
|
||||
switch (wordSize) {
|
||||
case 4:
|
||||
|
|
|
@ -163,19 +163,19 @@ public final class HighLevelEncoder {
|
|||
int pairCode;
|
||||
int nextChar = index + 1 < text.length ? text[index + 1] : 0;
|
||||
switch (text[index]) {
|
||||
case '\r':
|
||||
pairCode = nextChar == '\n' ? 2 : 0;
|
||||
case '\r':
|
||||
pairCode = nextChar == '\n' ? 2 : 0;
|
||||
break;
|
||||
case '.' :
|
||||
pairCode = nextChar == ' ' ? 3 : 0;
|
||||
case '.' :
|
||||
pairCode = nextChar == ' ' ? 3 : 0;
|
||||
break;
|
||||
case ',' :
|
||||
pairCode = nextChar == ' ' ? 4 : 0;
|
||||
case ',' :
|
||||
pairCode = nextChar == ' ' ? 4 : 0;
|
||||
break;
|
||||
case ':' :
|
||||
pairCode = nextChar == ' ' ? 5 : 0;
|
||||
case ':' :
|
||||
pairCode = nextChar == ' ' ? 5 : 0;
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
pairCode = 0;
|
||||
}
|
||||
if (pairCode > 0) {
|
||||
|
|
|
@ -19,12 +19,12 @@ 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) {
|
||||
SimpleToken(Token previous, int value, int bitCount) {
|
||||
super(previous);
|
||||
this.value = (short) value;
|
||||
this.bitCount = (short) bitCount;
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.google.zxing.common.BitArray;
|
|||
* 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
|
||||
|
@ -53,19 +53,19 @@ final class State {
|
|||
// binaryShiftByteCount <= 62 ? 20 : 21);
|
||||
//assert this.bitCount == token.getTotalBitCount() + binaryShiftBitCount;
|
||||
}
|
||||
|
||||
|
||||
int getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
|
||||
Token getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
int getBinaryShiftByteCount() {
|
||||
return binaryShiftByteCount;
|
||||
}
|
||||
|
||||
|
||||
int getBitCount() {
|
||||
return bitCount;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ final class State {
|
|||
Token token = this.token;
|
||||
int mode = this.mode;
|
||||
int bitCount = this.bitCount;
|
||||
if (this.mode == HighLevelEncoder.MODE_PUNCT || this.mode == HighLevelEncoder.MODE_DIGIT) {
|
||||
if (this.mode == HighLevelEncoder.MODE_PUNCT || this.mode == HighLevelEncoder.MODE_DIGIT) {
|
||||
//assert binaryShiftByteCount == 0;
|
||||
int latch = HighLevelEncoder.LATCH_TABLE[mode][HighLevelEncoder.MODE_UPPER];
|
||||
token = token.add(latch & 0xFFFF, latch >> 16);
|
||||
|
|
|
@ -19,15 +19,15 @@ 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;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public enum CharacterSetECI {
|
|||
CharacterSetECI(int value) {
|
||||
this(new int[] {value});
|
||||
}
|
||||
|
||||
|
||||
CharacterSetECI(int value, String... otherEncodingNames) {
|
||||
this.values = new int[] {value};
|
||||
this.otherEncodingNames = otherEncodingNames;
|
||||
|
|
|
@ -136,17 +136,17 @@ public final class DecoderResult {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public final class DefaultGridSampler extends GridSampler {
|
|||
int dimensionY,
|
||||
PerspectiveTransform transform) throws NotFoundException {
|
||||
if (dimensionX <= 0 || dimensionY <= 0) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
BitMatrix bits = new BitMatrix(dimensionX, dimensionY);
|
||||
float[] points = new float[2 * dimensionX];
|
||||
|
|
|
@ -41,7 +41,7 @@ public abstract class GridSampler {
|
|||
* 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) {
|
||||
|
@ -95,7 +95,7 @@ public abstract class GridSampler {
|
|||
float p2FromX, float p2FromY,
|
||||
float p3FromX, float p3FromY,
|
||||
float p4FromX, float p4FromY) throws NotFoundException;
|
||||
|
||||
|
||||
public abstract BitMatrix sampleGrid(BitMatrix image,
|
||||
int dimensionX,
|
||||
int dimensionY,
|
||||
|
|
|
@ -85,7 +85,7 @@ public final class PerspectiveTransform {
|
|||
|
||||
public void transformPoints(float[] xValues, float[] yValues) {
|
||||
int n = xValues.length;
|
||||
for (int i = 0; i < n; i ++) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
float x = xValues[i];
|
||||
float y = yValues[i];
|
||||
float denominator = a13 * x + a23 * y + a33;
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class StringUtils {
|
|||
SHIFT_JIS.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING) ||
|
||||
EUC_JP.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING);
|
||||
|
||||
private StringUtils() {}
|
||||
private StringUtils() { }
|
||||
|
||||
/**
|
||||
* @param bytes bytes encoding a string, whose encoding should be guessed
|
||||
|
|
|
@ -91,7 +91,7 @@ public final class WhiteRectangleDetector {
|
|||
boolean sizeExceeded = false;
|
||||
boolean aBlackPointFoundOnBorder = true;
|
||||
boolean atLeastOneBlackPointFoundOnBorder = false;
|
||||
|
||||
|
||||
boolean atLeastOneBlackPointFoundOnRight = false;
|
||||
boolean atLeastOneBlackPointFoundOnBottom = false;
|
||||
boolean atLeastOneBlackPointFoundOnLeft = false;
|
||||
|
@ -165,7 +165,7 @@ public final class WhiteRectangleDetector {
|
|||
// . .
|
||||
// .....
|
||||
boolean topBorderNotWhite = true;
|
||||
while ((topBorderNotWhite || !atLeastOneBlackPointFoundOnTop) && up >= 0) {
|
||||
while ((topBorderNotWhite || !atLeastOneBlackPointFoundOnTop) && up >= 0) {
|
||||
topBorderNotWhite = containsBlackPoint(left, right, up, true);
|
||||
if (topBorderNotWhite) {
|
||||
up--;
|
||||
|
|
|
@ -153,14 +153,14 @@ public final class GenericGF {
|
|||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
public int getGeneratorBase() {
|
||||
return generatorBase;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GF(0x" + Integer.toHexString(primitive) + ',' + size + ')';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ public final class ReedSolomonDecoder {
|
|||
}
|
||||
|
||||
t = q.multiply(tLast).addOrSubtract(tLastLast);
|
||||
|
||||
|
||||
if (r.getDegree() >= rLast.getDegree()) {
|
||||
throw new IllegalStateException("Division algorithm failed to reduce polynomial?");
|
||||
}
|
||||
|
|
|
@ -49,11 +49,11 @@ public final class DataMatrixWriter implements Writer {
|
|||
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 are too small: " + width + 'x' + height);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ final class BitMatrixParser {
|
|||
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());
|
||||
|
@ -52,7 +52,7 @@ final class BitMatrixParser {
|
|||
* the datamatrix code.</p>
|
||||
*
|
||||
* <p>See ISO 16022:2006 Table 7 - ECC 200 symbol attributes</p>
|
||||
*
|
||||
*
|
||||
* @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
|
||||
|
@ -76,18 +76,18 @@ final class BitMatrixParser {
|
|||
|
||||
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
|
||||
|
@ -122,7 +122,7 @@ final class BitMatrixParser {
|
|||
} 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)) {
|
||||
|
@ -141,10 +141,10 @@ final class BitMatrixParser {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Reads a bit of the mapping matrix accounting for boundary wrapping.</p>
|
||||
*
|
||||
*
|
||||
* @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
|
||||
|
@ -164,12 +164,12 @@ final class BitMatrixParser {
|
|||
readMappingMatrix.set(column, row);
|
||||
return mappingBitMatrix.get(column, row);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Reads the 8 bits of the standard Utah-shaped pattern.</p>
|
||||
*
|
||||
*
|
||||
* <p>See ISO 16022:2006, 5.8.1 Figure 6</p>
|
||||
*
|
||||
*
|
||||
* @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
|
||||
|
@ -211,12 +211,12 @@ final class BitMatrixParser {
|
|||
}
|
||||
return currentByte;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Reads the 8 bits of the special corner condition 1.</p>
|
||||
*
|
||||
*
|
||||
* <p>See ISO 16022:2006, Figure F.3</p>
|
||||
*
|
||||
*
|
||||
* @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
|
||||
|
@ -256,12 +256,12 @@ final class BitMatrixParser {
|
|||
}
|
||||
return currentByte;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Reads the 8 bits of the special corner condition 2.</p>
|
||||
*
|
||||
*
|
||||
* <p>See ISO 16022:2006, Figure F.4</p>
|
||||
*
|
||||
*
|
||||
* @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
|
||||
|
@ -301,12 +301,12 @@ final class BitMatrixParser {
|
|||
}
|
||||
return currentByte;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Reads the 8 bits of the special corner condition 3.</p>
|
||||
*
|
||||
*
|
||||
* <p>See ISO 16022:2006, Figure F.5</p>
|
||||
*
|
||||
*
|
||||
* @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
|
||||
|
@ -346,12 +346,12 @@ final class BitMatrixParser {
|
|||
}
|
||||
return currentByte;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Reads the 8 bits of the special corner condition 4.</p>
|
||||
*
|
||||
*
|
||||
* <p>See ISO 16022:2006, Figure F.6</p>
|
||||
*
|
||||
*
|
||||
* @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
|
||||
|
@ -391,31 +391,31 @@ final class BitMatrixParser {
|
|||
}
|
||||
return currentByte;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Extracts the data region from a {@link BitMatrix} that contains
|
||||
* alignment patterns.</p>
|
||||
*
|
||||
*
|
||||
* @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;
|
||||
|
@ -437,4 +437,4 @@ final class BitMatrixParser {
|
|||
return bitMatrixWithoutAlignment;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,14 +82,14 @@ final class DataBlock {
|
|||
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++) {
|
||||
|
|
|
@ -48,7 +48,7 @@ public final class Version {
|
|||
this.dataRegionSizeRows = dataRegionSizeRows;
|
||||
this.dataRegionSizeColumns = dataRegionSizeColumns;
|
||||
this.ecBlocks = ecBlocks;
|
||||
|
||||
|
||||
// Calculate the total number of codewords
|
||||
int total = 0;
|
||||
int ecCodewords = ecBlocks.getECCodewords();
|
||||
|
@ -66,23 +66,23 @@ public final class Version {
|
|||
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;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public final class Version {
|
|||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
|
||||
|
|
|
@ -137,16 +137,16 @@ public final class Detector {
|
|||
// The top right point is actually the corner of a module, which is one of the two black modules
|
||||
// adjacent to the white module at the top right. Tracing to that corner from either the top left
|
||||
// or bottom right should work here.
|
||||
|
||||
|
||||
int dimensionTop = transitionsBetween(topLeft, topRight).getTransitions();
|
||||
int dimensionRight = transitionsBetween(bottomRight, topRight).getTransitions();
|
||||
|
||||
|
||||
if ((dimensionTop & 0x01) == 1) {
|
||||
// it can't be odd, so, round... up?
|
||||
dimensionTop++;
|
||||
}
|
||||
dimensionTop += 2;
|
||||
|
||||
|
||||
if ((dimensionRight & 0x01) == 1) {
|
||||
// it can't be odd, so, round... up?
|
||||
dimensionRight++;
|
||||
|
@ -182,10 +182,10 @@ public final class Detector {
|
|||
}
|
||||
|
||||
bits = sampleGrid(image, topLeft, bottomLeft, bottomRight, correctedTopRight, dimensionTop, dimensionRight);
|
||||
|
||||
|
||||
} else {
|
||||
// The matrix is square
|
||||
|
||||
|
||||
int dimension = Math.min(dimensionRight, dimensionTop);
|
||||
// correct top right point to match the white module
|
||||
correctedTopRight = correctTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension);
|
||||
|
@ -419,7 +419,7 @@ public final class Detector {
|
|||
int getTransitions() {
|
||||
return transitions;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return from + "/" + to + '/' + transitions;
|
||||
|
|
|
@ -78,5 +78,5 @@ final class ASCIIEncoder implements Encoder {
|
|||
}
|
||||
throw new IllegalArgumentException("not digits: " + digit1 + digit2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ final class Base256Encoder implements Encoder {
|
|||
buffer.charAt(i), context.getCodewordCount() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static char randomize255State(char ch, int codewordPosition) {
|
||||
int pseudoRandom = ((149 * codewordPosition) % 255) + 1;
|
||||
int tempVariable = ch + pseudoRandom;
|
||||
|
|
|
@ -42,7 +42,7 @@ public class DefaultPlacement {
|
|||
this.bits = new byte[numcols * numrows];
|
||||
Arrays.fill(this.bits, (byte) -1); //Initialize with "not set" value
|
||||
}
|
||||
|
||||
|
||||
final int getNumrows() {
|
||||
return numrows;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class DefaultPlacement {
|
|||
} while (row >= 0 && (col < numcols));
|
||||
row++;
|
||||
col += 3;
|
||||
|
||||
|
||||
/* and then sweep downward diagonally, inserting successive characters, ... */
|
||||
do {
|
||||
if ((row >= 0) && (col < numcols) && !hasBit(col, row)) {
|
||||
|
@ -107,10 +107,10 @@ public class DefaultPlacement {
|
|||
} while ((row < numrows) && (col >= 0));
|
||||
row += 3;
|
||||
col++;
|
||||
|
||||
|
||||
/* ...until the entire array is scanned */
|
||||
} while ((row < numrows) || (col < numcols));
|
||||
|
||||
|
||||
/* Lastly, if the lower righthand corner is untouched, fill in fixed pattern */
|
||||
if (!hasBit(numcols - 1, numrows - 1)) {
|
||||
setBit(numcols - 1, numrows - 1, true);
|
||||
|
|
|
@ -73,7 +73,7 @@ final class EncoderContext {
|
|||
public char getCurrent() {
|
||||
return msg.charAt(pos);
|
||||
}
|
||||
|
||||
|
||||
public StringBuilder getCodewords() {
|
||||
return codewords;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ final class EncoderContext {
|
|||
public int getCodewordCount() {
|
||||
return this.codewords.length();
|
||||
}
|
||||
|
||||
|
||||
public int getNewEncoding() {
|
||||
return newEncoding;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ final class EncoderContext {
|
|||
public int getRemainingCharacters() {
|
||||
return getTotalMessageCharCount() - pos;
|
||||
}
|
||||
|
||||
|
||||
public SymbolInfo getSymbolInfo() {
|
||||
return symbolInfo;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Arrays;
|
|||
* annex S.
|
||||
*/
|
||||
public final class HighLevelEncoder {
|
||||
|
||||
|
||||
/**
|
||||
* Padding character
|
||||
*/
|
||||
|
@ -154,12 +154,12 @@ public final class HighLevelEncoder {
|
|||
* @return the encoded message (the char values range from 0 to 255)
|
||||
*/
|
||||
public static String encodeHighLevel(String msg,
|
||||
SymbolShapeHint shape,
|
||||
Dimension minSize,
|
||||
SymbolShapeHint shape,
|
||||
Dimension minSize,
|
||||
Dimension maxSize) {
|
||||
//the codewords 0..255 are encoded as Unicode characters
|
||||
Encoder[] encoders = {
|
||||
new ASCIIEncoder(), new C40Encoder(), new TextEncoder(),
|
||||
new ASCIIEncoder(), new C40Encoder(), new TextEncoder(),
|
||||
new X12Encoder(), new EdifactEncoder(), new Base256Encoder()
|
||||
};
|
||||
|
||||
|
|
|
@ -119,9 +119,9 @@ public class SymbolInfo {
|
|||
}
|
||||
|
||||
public static SymbolInfo lookup(int dataCodewords,
|
||||
SymbolShapeHint shape,
|
||||
Dimension minSize,
|
||||
Dimension maxSize,
|
||||
SymbolShapeHint shape,
|
||||
Dimension minSize,
|
||||
Dimension maxSize,
|
||||
boolean fail) {
|
||||
for (SymbolInfo symbol : symbols) {
|
||||
if (shape == SymbolShapeHint.FORCE_SQUARE && symbol.rectangular) {
|
||||
|
@ -207,11 +207,11 @@ public class SymbolInfo {
|
|||
public int getInterleavedBlockCount() {
|
||||
return dataCapacity / rsBlockData;
|
||||
}
|
||||
|
||||
|
||||
public final int getDataCapacity() {
|
||||
return dataCapacity;
|
||||
}
|
||||
|
||||
|
||||
public final int getErrorCodewords() {
|
||||
return errorCodewords;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*
|
||||
* 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.
|
||||
|
|
|
@ -97,12 +97,12 @@ public final class MaxiCodeReader implements Reader {
|
|||
* @see com.google.zxing.qrcode.QRCodeReader#extractPureBits(BitMatrix)
|
||||
*/
|
||||
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];
|
||||
|
|
|
@ -78,7 +78,7 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
|
|||
if (currentDepth > MAX_DEPTH) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Result result;
|
||||
try {
|
||||
result = delegate.decode(image, hints);
|
||||
|
@ -128,29 +128,29 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
|
|||
// Decode left of barcode
|
||||
if (minX > MIN_DIMENSION_TO_RECUR) {
|
||||
doDecodeMultiple(image.crop(0, 0, (int) minX, height),
|
||||
hints, results,
|
||||
xOffset, yOffset,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
hints, results,
|
||||
xOffset, yOffset + (int) maxY,
|
||||
currentDepth + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ 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 {
|
||||
|
@ -92,17 +92,17 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Collection<int[]> 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 = chooseCode(contents, position, codeSet);
|
||||
|
||||
|
||||
//Get the pattern index
|
||||
int patternIndex;
|
||||
if (newCodeSet == codeSet) {
|
||||
|
@ -148,24 +148,24 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
|
|||
}
|
||||
codeSet = newCodeSet;
|
||||
}
|
||||
|
||||
|
||||
// Get the pattern
|
||||
patterns.add(Code128Reader.CODE_PATTERNS[patternIndex]);
|
||||
|
||||
|
||||
// Compute checksum
|
||||
checkSum += patternIndex * checkWeight;
|
||||
if (position != 0) {
|
||||
checkWeight++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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) {
|
||||
|
@ -173,14 +173,14 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
|
|||
codeWidth += width;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Compute result
|
||||
boolean[] result = new boolean[codeWidth];
|
||||
int pos = 0;
|
||||
for (int[] pattern : patterns) {
|
||||
pos += appendPattern(result, pos, pattern, true);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ public final class Code39Reader extends OneDReader {
|
|||
result.setLength(0);
|
||||
|
||||
int[] start = findAsteriskPattern(row, theCounters);
|
||||
// Read off white space
|
||||
// Read off white space
|
||||
int nextStart = row.getNextSet(start[1]);
|
||||
int end = row.getSize();
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* This object renders a CODE39 code as a {@link BitMatrix}.
|
||||
*
|
||||
*
|
||||
* @author erik.barbara@gmail.com (Erik Barbara)
|
||||
*/
|
||||
public final class Code39Writer extends OneDimensionalCodeWriter {
|
||||
|
@ -86,4 +86,4 @@ public final class Code39Writer extends OneDimensionalCodeWriter {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public final class Code93Reader extends OneDReader {
|
|||
throws NotFoundException, ChecksumException, FormatException {
|
||||
|
||||
int[] start = findAsteriskPattern(row);
|
||||
// Read off white space
|
||||
// Read off white space
|
||||
int nextStart = row.getNextSet(start[1]);
|
||||
int end = row.getSize();
|
||||
|
||||
|
|
|
@ -50,12 +50,12 @@ final class EANManufacturerOrgSupport {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void add(int[] range, String id) {
|
||||
ranges.add(range);
|
||||
countryIdentifiers.add(id);
|
||||
}
|
||||
|
||||
|
||||
private synchronized void initIfNeeded() {
|
||||
if (!ranges.isEmpty()) {
|
||||
return;
|
||||
|
@ -86,15 +86,15 @@ final class EANManufacturerOrgSupport {
|
|||
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[] {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[] {540,549}, "BE/LU");
|
||||
add(new int[] {560}, "PT");
|
||||
add(new int[] {569}, "IS");
|
||||
add(new int[] {570,579}, "DK");
|
||||
|
@ -102,13 +102,13 @@ final class EANManufacturerOrgSupport {
|
|||
add(new int[] {594}, "RO");
|
||||
add(new int[] {599}, "HU");
|
||||
add(new int[] {600,601}, "ZA");
|
||||
add(new int[] {603}, "GH");
|
||||
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[] {618}, "CI");
|
||||
add(new int[] {619}, "TN");
|
||||
add(new int[] {621}, "SY");
|
||||
add(new int[] {622}, "EG");
|
||||
|
@ -141,7 +141,7 @@ final class EANManufacturerOrgSupport {
|
|||
add(new int[] {779}, "AR");
|
||||
add(new int[] {780}, "CL");
|
||||
add(new int[] {784}, "PY");
|
||||
add(new int[] {785}, "PE");
|
||||
add(new int[] {785}, "PE");
|
||||
add(new int[] {786}, "EC");
|
||||
add(new int[] {789,790}, "BR");
|
||||
add(new int[] {800,839}, "IT");
|
||||
|
@ -150,7 +150,7 @@ final class EANManufacturerOrgSupport {
|
|||
add(new int[] {858}, "SK");
|
||||
add(new int[] {859}, "CZ");
|
||||
add(new int[] {860}, "YU");
|
||||
add(new int[] {865}, "MN");
|
||||
add(new int[] {865}, "MN");
|
||||
add(new int[] {867}, "KP");
|
||||
add(new int[] {868,869}, "TR");
|
||||
add(new int[] {870,879}, "NL");
|
||||
|
@ -159,7 +159,7 @@ final class EANManufacturerOrgSupport {
|
|||
add(new int[] {888}, "SG");
|
||||
add(new int[] {890}, "IN");
|
||||
add(new int[] {893}, "VN");
|
||||
add(new int[] {896}, "PK");
|
||||
add(new int[] {896}, "PK");
|
||||
add(new int[] {899}, "ID");
|
||||
add(new int[] {900,919}, "AT");
|
||||
add(new int[] {930,939}, "AU");
|
||||
|
|
|
@ -51,7 +51,7 @@ public final class ITFReader extends OneDReader {
|
|||
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 };
|
||||
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;
|
||||
|
@ -126,8 +126,8 @@ public final class ITFReader extends OneDReader {
|
|||
return new Result(
|
||||
resultString,
|
||||
null, // no natural byte representation for these barcodes
|
||||
new ResultPoint[] { new ResultPoint(startRange[1], rowNumber),
|
||||
new ResultPoint(endRange[0], rowNumber)},
|
||||
new ResultPoint[] {new ResultPoint(startRange[1], rowNumber),
|
||||
new ResultPoint(endRange[0], rowNumber)},
|
||||
BarcodeFormat.ITF);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* This object renders a ITF code as a {@link BitMatrix}.
|
||||
*
|
||||
*
|
||||
* @author erik.barbara@gmail.com (Erik Barbara)
|
||||
*/
|
||||
public final class ITFWriter extends OneDimensionalCodeWriter {
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class MultiFormatOneDReader extends OneDReader {
|
|||
private final OneDReader[] readers;
|
||||
|
||||
public MultiFormatOneDReader(Map<DecodeHintType,?> hints) {
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<BarcodeFormat> possibleFormats = hints == null ? null :
|
||||
(Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
|
||||
boolean useCode39CheckDigit = hints != null &&
|
||||
|
|
|
@ -94,7 +94,7 @@ public final class MultiFormatUPCEANReader extends OneDReader {
|
|||
boolean ean13MayBeUPCA =
|
||||
result.getBarcodeFormat() == BarcodeFormat.EAN_13 &&
|
||||
result.getText().charAt(0) == '0';
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<BarcodeFormat> possibleFormats =
|
||||
hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
|
||||
boolean canReturnUPCA = possibleFormats == null || possibleFormats.contains(BarcodeFormat.UPC_A);
|
||||
|
|
|
@ -91,7 +91,7 @@ final class UPCEANExtension2Support {
|
|||
if (Integer.parseInt(resultString.toString()) % 4 != checkParity) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
|
||||
return rowOffset;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ final class UPCEANExtension5Support {
|
|||
if (extensionChecksum(resultString.toString()) != checkDigit) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
|
||||
return rowOffset;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public final class UPCEWriter extends UPCEANWriter {
|
|||
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];
|
||||
|
@ -100,5 +100,5 @@ public final class UPCEWriter extends UPCEANWriter {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class DataCharacter {
|
|||
public final String toString() {
|
||||
return value + "(" + checksumPortion + ')';
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if (!(o instanceof DataCharacter)) {
|
||||
|
|
|
@ -68,14 +68,14 @@ final class ExpandedPair {
|
|||
public 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)) {
|
||||
|
|
|
@ -34,30 +34,30 @@ final class ExpandedRow {
|
|||
this.rowNumber = rowNumber;
|
||||
this.wasReversed = wasReversed;
|
||||
}
|
||||
|
||||
|
||||
List<ExpandedPair> getPairs() {
|
||||
return this.pairs;
|
||||
}
|
||||
|
||||
|
||||
int getRowNumber() {
|
||||
return this.rowNumber;
|
||||
}
|
||||
|
||||
|
||||
boolean isReversed() {
|
||||
return this.wasReversed;
|
||||
}
|
||||
|
||||
|
||||
boolean isEquivalent(List<ExpandedPair> 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.
|
||||
|
||||
/**
|
||||
* Two rows are equal if they contain the same pairs in the same order.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
|
|
@ -161,7 +161,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
if (checkChecksum()) {
|
||||
return this.pairs;
|
||||
}
|
||||
|
||||
|
||||
boolean tryStackedDecode = !this.rows.isEmpty();
|
||||
storeRow(rowNumber, false); // TODO: deal with reversed rows
|
||||
if (tryStackedDecode) {
|
||||
|
@ -176,7 +176,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
return ps;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
removePartialRows(this.pairs, this.rows);
|
||||
}
|
||||
|
||||
// Remove all the rows that contains only specified pairs
|
||||
// Remove all the rows that contains only specified pairs
|
||||
private static void removePartialRows(List<ExpandedPair> pairs, List<ExpandedRow> rows) {
|
||||
for (Iterator<ExpandedRow> iterator = rows.iterator(); iterator.hasNext();) {
|
||||
ExpandedRow r = iterator.next();
|
||||
|
@ -441,11 +441,11 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
// 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);
|
||||
|
|
|
@ -160,7 +160,7 @@ final class FieldParser {
|
|||
{ "391", VARIABLE_LENGTH, 18},
|
||||
{ "392", VARIABLE_LENGTH, 15},
|
||||
{ "393", VARIABLE_LENGTH, 18},
|
||||
{ "703", VARIABLE_LENGTH, 30}
|
||||
{ "703", VARIABLE_LENGTH, 30},
|
||||
};
|
||||
|
||||
private static final Object [][] FOUR_DIGIT_DATA_LENGTH = {
|
||||
|
|
|
@ -43,7 +43,7 @@ final class BarcodeValue {
|
|||
}
|
||||
|
||||
/**
|
||||
* Determines the maximum occurrence of a set value and returns all values which were set with this occurrence.
|
||||
* 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() {
|
||||
|
|
|
@ -62,8 +62,8 @@ final class DetectionResult {
|
|||
// 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
|
||||
* @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();
|
||||
|
|
|
@ -22,9 +22,9 @@ 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;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ final class DetectionResultRowIndicatorColumn extends DetectionResultColumn {
|
|||
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
|
||||
// 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;
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.google.zxing.pdf417.PDF417Common;
|
|||
*/
|
||||
final class PDF417CodewordDecoder {
|
||||
|
||||
private static final float[][] RATIOS_TABLE =
|
||||
private static final float[][] RATIOS_TABLE =
|
||||
new float[PDF417Common.SYMBOL_TABLE.length][PDF417Common.BARS_IN_MODULE];
|
||||
|
||||
static {
|
||||
|
@ -63,7 +63,7 @@ final class PDF417CodewordDecoder {
|
|||
int sumPreviousBits = 0;
|
||||
for (int i = 0; i < PDF417Common.MODULES_IN_CODEWORD; i++) {
|
||||
float sampleIndex =
|
||||
bitCountSum / (2 * PDF417Common.MODULES_IN_CODEWORD) +
|
||||
bitCountSum / (2 * PDF417Common.MODULES_IN_CODEWORD) +
|
||||
(i * bitCountSum) / PDF417Common.MODULES_IN_CODEWORD;
|
||||
if (sumPreviousBits + moduleBitCount[bitCountIndex] <= sampleIndex) {
|
||||
sumPreviousBits += moduleBitCount[bitCountIndex];
|
||||
|
|
|
@ -47,7 +47,7 @@ public final class 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
|
||||
// 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,
|
||||
|
@ -285,7 +285,7 @@ public final class PDF417ScanningDecoder {
|
|||
* 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.
|
||||
* 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
|
||||
|
@ -433,7 +433,7 @@ public final class PDF417ScanningDecoder {
|
|||
}
|
||||
// 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.
|
||||
// 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) {
|
||||
|
|
|
@ -108,5 +108,5 @@ public final class ModulusGF {
|
|||
int getSize() {
|
||||
return modulus;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ public final class Detector {
|
|||
|
||||
if (vertices[0] == null && vertices[3] == null) {
|
||||
if (!foundBarcodeInRow) {
|
||||
// we didn't find any barcode so that's the end of searching
|
||||
// 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
|
||||
|
@ -127,7 +127,7 @@ public final class Detector {
|
|||
if (!multiple) {
|
||||
break;
|
||||
}
|
||||
// if we didn't find a right row indicator column, then continue the search for the next barcode after the
|
||||
// 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();
|
||||
|
@ -246,7 +246,7 @@ public final class Detector {
|
|||
* @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
|
||||
* @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,
|
||||
|
@ -260,7 +260,7 @@ public final class Detector {
|
|||
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
|
||||
// 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--;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package com.google.zxing.pdf417.encoder;
|
|||
* Represents possible PDF417 barcode compaction types.
|
||||
*/
|
||||
public enum Compaction {
|
||||
|
||||
|
||||
AUTO,
|
||||
TEXT,
|
||||
BYTE,
|
||||
|
|
|
@ -98,13 +98,13 @@ final class PDF417HighLevelEncoder {
|
|||
* 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;
|
||||
|
|
|
@ -129,7 +129,7 @@ public class QRCodeReader implements Reader {
|
|||
int bottom = rightBottomBlack[1];
|
||||
int left = leftTopBlack[0];
|
||||
int right = rightBottomBlack[0];
|
||||
|
||||
|
||||
// Sanity check!
|
||||
if (left >= right || top >= bottom) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
|
@ -161,7 +161,7 @@ public class QRCodeReader implements Reader {
|
|||
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
|
||||
|
|
|
@ -221,7 +221,7 @@ final class BitMatrixParser {
|
|||
* 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) {
|
||||
|
@ -236,7 +236,7 @@ final class BitMatrixParser {
|
|||
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);
|
||||
bitMatrix.flip(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ final class DecodedBitStreamParser {
|
|||
List<byte[]> byteSegments = new ArrayList<>(1);
|
||||
int symbolSequence = -1;
|
||||
int parityData = -1;
|
||||
|
||||
|
||||
try {
|
||||
CharacterSetECI currentCharacterSetECI = null;
|
||||
boolean fc1InEffect = false;
|
||||
|
|
|
@ -21,19 +21,19 @@ 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.
|
||||
/**
|
||||
* @return true if the QR Code was mirrored.
|
||||
*/
|
||||
public boolean isMirrored() {
|
||||
return mirrored;
|
||||
|
@ -41,7 +41,7 @@ public final class QRCodeDecoderMetaData {
|
|||
|
||||
/**
|
||||
* Apply the result points' order correction due to mirroring.
|
||||
*
|
||||
*
|
||||
* @param points Array of points to apply mirror correction to.
|
||||
*/
|
||||
public void applyMirroredCorrection(ResultPoint[] points) {
|
||||
|
|
|
@ -31,7 +31,7 @@ final class MatrixUtil {
|
|||
// do nothing
|
||||
}
|
||||
|
||||
private static final int[][] POSITION_DETECTION_PATTERN = {
|
||||
private static final int[][] POSITION_DETECTION_PATTERN = {
|
||||
{1, 1, 1, 1, 1, 1, 1},
|
||||
{1, 0, 0, 0, 0, 0, 1},
|
||||
{1, 0, 1, 1, 1, 0, 1},
|
||||
|
|
Loading…
Reference in a new issue