mirror of
https://github.com/zxing/zxing.git
synced 2024-11-10 04:54:04 -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 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}
|
||||
* 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)
|
||||
throws NotFoundException, FormatException, ChecksumException {
|
||||
|
||||
boolean convertFNC1 = hints != null && hints.containsKey(DecodeHintType.ASSUME_GS1);
|
||||
|
||||
int[] startPatternInfo = findStartPattern(row);
|
||||
int startCode = startPatternInfo[2];
|
||||
int codeSet;
|
||||
|
@ -322,13 +324,15 @@ public final class Code128Reader extends OneDReader {
|
|||
}
|
||||
switch (code) {
|
||||
case CODE_FNC_1:
|
||||
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);
|
||||
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:
|
||||
|
@ -361,6 +365,17 @@ public final class Code128Reader extends OneDReader {
|
|||
}
|
||||
switch (code) {
|
||||
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_3:
|
||||
case CODE_FNC_4_B:
|
||||
|
@ -394,7 +409,16 @@ public final class Code128Reader extends OneDReader {
|
|||
}
|
||||
switch (code) {
|
||||
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;
|
||||
case CODE_CODE_A:
|
||||
codeSet = CODE_CODE_A;
|
||||
|
|
Loading…
Reference in a new issue