mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Add hint for GS1
git-svn-id: https://zxing.googlecode.com/svn/trunk@2595 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
a42d32ca15
commit
cae4e9c19d
|
@ -65,6 +65,13 @@ public enum DecodeHintType {
|
||||||
*/
|
*/
|
||||||
ASSUME_CODE_39_CHECK_DIGIT,
|
ASSUME_CODE_39_CHECK_DIGIT,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The caller needs to be notified via callback when a possible {@link ResultPoint}
|
* The caller needs to be notified via callback when a possible {@link ResultPoint}
|
||||||
* is found. Maps to a {@link ResultPointCallback}.
|
* is found. Maps to a {@link ResultPointCallback}.
|
||||||
|
|
|
@ -236,6 +236,8 @@ public final class Code128Reader extends OneDReader {
|
||||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||||
throws NotFoundException, FormatException, ChecksumException {
|
throws NotFoundException, FormatException, ChecksumException {
|
||||||
|
|
||||||
|
boolean convertFNC1 = hints != null && hints.containsKey(DecodeHintType.ASSUME_GS1);
|
||||||
|
|
||||||
int[] startPatternInfo = findStartPattern(row);
|
int[] startPatternInfo = findStartPattern(row);
|
||||||
int startCode = startPatternInfo[2];
|
int startCode = startPatternInfo[2];
|
||||||
int codeSet;
|
int codeSet;
|
||||||
|
@ -322,13 +324,15 @@ public final class Code128Reader extends OneDReader {
|
||||||
}
|
}
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case CODE_FNC_1:
|
case CODE_FNC_1:
|
||||||
if (result.length() == 0){
|
if (convertFNC1) {
|
||||||
// GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code
|
if (result.length() == 0){
|
||||||
// is FNC1 then this is GS1-128. We add the symbology identifier.
|
// GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code
|
||||||
result.append("]C1");
|
// is FNC1 then this is GS1-128. We add the symbology identifier.
|
||||||
} else {
|
result.append("]C1");
|
||||||
// GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS)
|
} else {
|
||||||
result.append((char) 29);
|
// GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS)
|
||||||
|
result.append((char) 29);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CODE_FNC_2:
|
case CODE_FNC_2:
|
||||||
|
@ -361,6 +365,17 @@ public final class Code128Reader extends OneDReader {
|
||||||
}
|
}
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case CODE_FNC_1:
|
case CODE_FNC_1:
|
||||||
|
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:
|
case CODE_FNC_2:
|
||||||
case CODE_FNC_3:
|
case CODE_FNC_3:
|
||||||
case CODE_FNC_4_B:
|
case CODE_FNC_4_B:
|
||||||
|
@ -394,7 +409,16 @@ public final class Code128Reader extends OneDReader {
|
||||||
}
|
}
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case CODE_FNC_1:
|
case CODE_FNC_1:
|
||||||
// do nothing?
|
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;
|
break;
|
||||||
case CODE_CODE_A:
|
case CODE_CODE_A:
|
||||||
codeSet = CODE_CODE_A;
|
codeSet = CODE_CODE_A;
|
||||||
|
|
Loading…
Reference in a new issue