"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core/src/main/java/com/google/zxing/oned/Code128Reader.java" between
zxing-zxing-3.4.1.tar.gz and zxing-zxing-3.5.0.tar.gz

About: ZXing ("zebra crossing") is a multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages. Info: Project is in maintenance mode (no active development).

Code128Reader.java  (zxing-zxing-3.4.1):Code128Reader.java  (zxing-zxing-3.5.0)
skipping to change at line 25 skipping to change at line 25
*/ */
package com.google.zxing.oned; package com.google.zxing.oned;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.ChecksumException; import com.google.zxing.ChecksumException;
import com.google.zxing.DecodeHintType; import com.google.zxing.DecodeHintType;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.Result; import com.google.zxing.Result;
import com.google.zxing.ResultMetadataType;
import com.google.zxing.ResultPoint; import com.google.zxing.ResultPoint;
import com.google.zxing.common.BitArray; import com.google.zxing.common.BitArray;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* <p>Decodes Code 128 barcodes.</p> * <p>Decodes Code 128 barcodes.</p>
* *
skipping to change at line 241 skipping to change at line 242
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }
} }
@Override @Override
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hin ts) public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hin ts)
throws NotFoundException, FormatException, ChecksumException { throws NotFoundException, FormatException, ChecksumException {
boolean convertFNC1 = hints != null && hints.containsKey(DecodeHintType.ASSU ME_GS1); boolean convertFNC1 = hints != null && hints.containsKey(DecodeHintType.ASSU ME_GS1);
int symbologyModifier = 0;
int[] startPatternInfo = findStartPattern(row); int[] startPatternInfo = findStartPattern(row);
int startCode = startPatternInfo[2]; int startCode = startPatternInfo[2];
List<Byte> rawCodes = new ArrayList<>(20); List<Byte> rawCodes = new ArrayList<>(20);
rawCodes.add((byte) startCode); rawCodes.add((byte) startCode);
int codeSet; int codeSet;
switch (startCode) { switch (startCode) {
case CODE_START_A: case CODE_START_A:
codeSet = CODE_CODE_A; codeSet = CODE_CODE_A;
skipping to change at line 342 skipping to change at line 345
} }
shiftUpperMode = false; shiftUpperMode = false;
} else { } else {
// Don't let CODE_STOP, which always appears, affect whether whether we think the last // Don't let CODE_STOP, which always appears, affect whether whether we think the last
// code was printable or not. // code was printable or not.
if (code != CODE_STOP) { if (code != CODE_STOP) {
lastCharacterWasPrintable = false; lastCharacterWasPrintable = false;
} }
switch (code) { switch (code) {
case CODE_FNC_1: 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 (convertFNC1) {
if (result.length() == 0) { if (result.length() == 0) {
// GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code // 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 identi fier. // is FNC1 then this is GS1-128. We add the symbology identi fier.
result.append("]C1"); result.append("]C1");
} else { } else {
// GS1 specification 5.4.7.5. Every subsequent FNC1 is retur ned as ASCII 29 (GS) // GS1 specification 5.4.7.5. Every subsequent FNC1 is retur ned as ASCII 29 (GS)
result.append((char) 29); result.append((char) 29);
} }
} }
break; break;
case CODE_FNC_2: case CODE_FNC_2:
symbologyModifier = 4;
break;
case CODE_FNC_3: case CODE_FNC_3:
// do nothing? // do nothing?
break; break;
case CODE_FNC_4_A: case CODE_FNC_4_A:
if (!upperMode && shiftUpperMode) { if (!upperMode && shiftUpperMode) {
upperMode = true; upperMode = true;
shiftUpperMode = false; shiftUpperMode = false;
} else if (upperMode && shiftUpperMode) { } else if (upperMode && shiftUpperMode) {
upperMode = false; upperMode = false;
shiftUpperMode = false; shiftUpperMode = false;
skipping to change at line 398 skipping to change at line 408
} else { } else {
result.append((char) (' ' + code + 128)); result.append((char) (' ' + code + 128));
} }
shiftUpperMode = false; shiftUpperMode = false;
} else { } else {
if (code != CODE_STOP) { if (code != CODE_STOP) {
lastCharacterWasPrintable = false; lastCharacterWasPrintable = false;
} }
switch (code) { switch (code) {
case CODE_FNC_1: 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 (convertFNC1) {
if (result.length() == 0) { if (result.length() == 0) {
// GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code // 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 identi fier. // is FNC1 then this is GS1-128. We add the symbology identi fier.
result.append("]C1"); result.append("]C1");
} else { } else {
// GS1 specification 5.4.7.5. Every subsequent FNC1 is retur ned as ASCII 29 (GS) // GS1 specification 5.4.7.5. Every subsequent FNC1 is retur ned as ASCII 29 (GS)
result.append((char) 29); result.append((char) 29);
} }
} }
break; break;
case CODE_FNC_2: case CODE_FNC_2:
symbologyModifier = 4;
break;
case CODE_FNC_3: case CODE_FNC_3:
// do nothing? // do nothing?
break; break;
case CODE_FNC_4_B: case CODE_FNC_4_B:
if (!upperMode && shiftUpperMode) { if (!upperMode && shiftUpperMode) {
upperMode = true; upperMode = true;
shiftUpperMode = false; shiftUpperMode = false;
} else if (upperMode && shiftUpperMode) { } else if (upperMode && shiftUpperMode) {
upperMode = false; upperMode = false;
shiftUpperMode = false; shiftUpperMode = false;
skipping to change at line 452 skipping to change at line 469
if (code < 10) { if (code < 10) {
result.append('0'); result.append('0');
} }
result.append(code); result.append(code);
} else { } else {
if (code != CODE_STOP) { if (code != CODE_STOP) {
lastCharacterWasPrintable = false; lastCharacterWasPrintable = false;
} }
switch (code) { switch (code) {
case CODE_FNC_1: 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 (convertFNC1) {
if (result.length() == 0) { if (result.length() == 0) {
// GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code // 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 identi fier. // is FNC1 then this is GS1-128. We add the symbology identi fier.
result.append("]C1"); result.append("]C1");
} else { } else {
// GS1 specification 5.4.7.5. Every subsequent FNC1 is retur ned as ASCII 29 (GS) // GS1 specification 5.4.7.5. Every subsequent FNC1 is retur ned as ASCII 29 (GS)
result.append((char) 29); result.append((char) 29);
} }
} }
skipping to change at line 528 skipping to change at line 550
} }
float left = (startPatternInfo[1] + startPatternInfo[0]) / 2.0f; float left = (startPatternInfo[1] + startPatternInfo[0]) / 2.0f;
float right = lastStart + lastPatternSize / 2.0f; float right = lastStart + lastPatternSize / 2.0f;
int rawCodesSize = rawCodes.size(); int rawCodesSize = rawCodes.size();
byte[] rawBytes = new byte[rawCodesSize]; byte[] rawBytes = new byte[rawCodesSize];
for (int i = 0; i < rawCodesSize; i++) { for (int i = 0; i < rawCodesSize; i++) {
rawBytes[i] = rawCodes.get(i); rawBytes[i] = rawCodes.get(i);
} }
Result resultObject = new Result(
return new Result(
result.toString(), result.toString(),
rawBytes, rawBytes,
new ResultPoint[]{ new ResultPoint[]{
new ResultPoint(left, rowNumber), new ResultPoint(left, rowNumber),
new ResultPoint(right, rowNumber)}, new ResultPoint(right, rowNumber)},
BarcodeFormat.CODE_128); BarcodeFormat.CODE_128);
resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]C" + sym
bologyModifier);
return resultObject;
} }
} }
 End of changes. 9 change blocks. 
2 lines changed or deleted 29 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)