mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Fix previous update to PDF417 regarding AS vs AL
git-svn-id: https://zxing.googlecode.com/svn/trunk@1764 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
3de06bcf41
commit
0e28aa0e4c
|
@ -40,7 +40,8 @@ final class DecodedBitStreamParser {
|
||||||
private static final int LOWER = 1;
|
private static final int LOWER = 1;
|
||||||
private static final int MIXED = 2;
|
private static final int MIXED = 2;
|
||||||
private static final int PUNCT = 3;
|
private static final int PUNCT = 3;
|
||||||
private static final int PUNCT_SHIFT = 4;
|
private static final int ALPHA_SHIFT = 4;
|
||||||
|
private static final int PUNCT_SHIFT = 5;
|
||||||
|
|
||||||
private static final int PL = 25;
|
private static final int PL = 25;
|
||||||
private static final int LL = 27;
|
private static final int LL = 27;
|
||||||
|
@ -88,27 +89,22 @@ final class DecodedBitStreamParser {
|
||||||
int code = codewords[codeIndex++];
|
int code = codewords[codeIndex++];
|
||||||
while (codeIndex < codewords[0]) {
|
while (codeIndex < codewords[0]) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case TEXT_COMPACTION_MODE_LATCH: {
|
case TEXT_COMPACTION_MODE_LATCH:
|
||||||
codeIndex = textCompaction(codewords, codeIndex, result);
|
codeIndex = textCompaction(codewords, codeIndex, result);
|
||||||
break;
|
break;
|
||||||
}
|
case BYTE_COMPACTION_MODE_LATCH:
|
||||||
case BYTE_COMPACTION_MODE_LATCH: {
|
|
||||||
codeIndex = byteCompaction(code, codewords, codeIndex, result);
|
codeIndex = byteCompaction(code, codewords, codeIndex, result);
|
||||||
break;
|
break;
|
||||||
}
|
case NUMERIC_COMPACTION_MODE_LATCH:
|
||||||
case NUMERIC_COMPACTION_MODE_LATCH: {
|
|
||||||
codeIndex = numericCompaction(codewords, codeIndex, result);
|
codeIndex = numericCompaction(codewords, codeIndex, result);
|
||||||
break;
|
break;
|
||||||
}
|
case MODE_SHIFT_TO_BYTE_COMPACTION_MODE:
|
||||||
case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: {
|
|
||||||
codeIndex = byteCompaction(code, codewords, codeIndex, result);
|
codeIndex = byteCompaction(code, codewords, codeIndex, result);
|
||||||
break;
|
break;
|
||||||
}
|
case BYTE_COMPACTION_MODE_LATCH_6:
|
||||||
case BYTE_COMPACTION_MODE_LATCH_6: {
|
|
||||||
codeIndex = byteCompaction(code, codewords, codeIndex, result);
|
codeIndex = byteCompaction(code, codewords, codeIndex, result);
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
// Default to text compaction. During testing numerous barcodes
|
// Default to text compaction. During testing numerous barcodes
|
||||||
// appeared to be missing the starting mode. In these cases defaulting
|
// appeared to be missing the starting mode. In these cases defaulting
|
||||||
// to text compaction seems to work.
|
// to text compaction seems to work.
|
||||||
|
@ -116,7 +112,6 @@ final class DecodedBitStreamParser {
|
||||||
codeIndex = textCompaction(codewords, codeIndex, result);
|
codeIndex = textCompaction(codewords, codeIndex, result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (codeIndex < codewords.length) {
|
if (codeIndex < codewords.length) {
|
||||||
code = codewords[codeIndex++];
|
code = codewords[codeIndex++];
|
||||||
} else {
|
} else {
|
||||||
|
@ -152,22 +147,19 @@ final class DecodedBitStreamParser {
|
||||||
index += 2;
|
index += 2;
|
||||||
} else {
|
} else {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case TEXT_COMPACTION_MODE_LATCH: {
|
case TEXT_COMPACTION_MODE_LATCH:
|
||||||
codeIndex--;
|
codeIndex--;
|
||||||
end = true;
|
end = true;
|
||||||
break;
|
break;
|
||||||
}
|
case BYTE_COMPACTION_MODE_LATCH:
|
||||||
case BYTE_COMPACTION_MODE_LATCH: {
|
|
||||||
codeIndex--;
|
codeIndex--;
|
||||||
end = true;
|
end = true;
|
||||||
break;
|
break;
|
||||||
}
|
case NUMERIC_COMPACTION_MODE_LATCH:
|
||||||
case NUMERIC_COMPACTION_MODE_LATCH: {
|
|
||||||
codeIndex--;
|
codeIndex--;
|
||||||
end = true;
|
end = true;
|
||||||
break;
|
break;
|
||||||
}
|
case MODE_SHIFT_TO_BYTE_COMPACTION_MODE:
|
||||||
case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: {
|
|
||||||
// The Mode Shift codeword 913 shall cause a temporary
|
// The Mode Shift codeword 913 shall cause a temporary
|
||||||
// switch from Text Compaction mode to Byte Compaction mode.
|
// switch from Text Compaction mode to Byte Compaction mode.
|
||||||
// This switch shall be in effect for only the next codeword,
|
// This switch shall be in effect for only the next codeword,
|
||||||
|
@ -179,15 +171,13 @@ final class DecodedBitStreamParser {
|
||||||
byteCompactionData[index] = code; //Integer.toHexString(code);
|
byteCompactionData[index] = code; //Integer.toHexString(code);
|
||||||
index++;
|
index++;
|
||||||
break;
|
break;
|
||||||
}
|
case BYTE_COMPACTION_MODE_LATCH_6:
|
||||||
case BYTE_COMPACTION_MODE_LATCH_6: {
|
|
||||||
codeIndex--;
|
codeIndex--;
|
||||||
end = true;
|
end = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
decodeTextCompaction(textCompactionData, byteCompactionData, index, result);
|
decodeTextCompaction(textCompactionData, byteCompactionData, index, result);
|
||||||
return codeIndex;
|
return codeIndex;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +243,9 @@ final class DecodedBitStreamParser {
|
||||||
if (subModeCh == 26) {
|
if (subModeCh == 26) {
|
||||||
ch = ' ';
|
ch = ' ';
|
||||||
} else if (subModeCh == AS) {
|
} else if (subModeCh == AS) {
|
||||||
subMode = ALPHA;
|
// Shift to alpha
|
||||||
|
priorToShiftMode = subMode;
|
||||||
|
subMode = ALPHA_SHIFT;
|
||||||
} else if (subModeCh == ML) {
|
} else if (subModeCh == ML) {
|
||||||
subMode = MIXED;
|
subMode = MIXED;
|
||||||
} else if (subModeCh == PS) {
|
} else if (subModeCh == PS) {
|
||||||
|
@ -291,7 +283,7 @@ final class DecodedBitStreamParser {
|
||||||
|
|
||||||
case PUNCT:
|
case PUNCT:
|
||||||
// Punctuation
|
// Punctuation
|
||||||
if (subModeCh < PS) {
|
if (subModeCh < PAL) {
|
||||||
ch = PUNCT_CHARS[subModeCh];
|
ch = PUNCT_CHARS[subModeCh];
|
||||||
} else {
|
} else {
|
||||||
if (subModeCh == PAL) {
|
if (subModeCh == PAL) {
|
||||||
|
@ -302,10 +294,24 @@ final class DecodedBitStreamParser {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ALPHA_SHIFT:
|
||||||
|
// Restore sub-mode
|
||||||
|
subMode = priorToShiftMode;
|
||||||
|
if (subModeCh < 26) {
|
||||||
|
ch = (char) ('A' + subModeCh);
|
||||||
|
} else {
|
||||||
|
if (subModeCh == 26) {
|
||||||
|
ch = ' ';
|
||||||
|
} else {
|
||||||
|
// is this even possible?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case PUNCT_SHIFT:
|
case PUNCT_SHIFT:
|
||||||
// Restore sub-mode
|
// Restore sub-mode
|
||||||
subMode = priorToShiftMode;
|
subMode = priorToShiftMode;
|
||||||
if (subModeCh < PS) {
|
if (subModeCh < PAL) {
|
||||||
ch = PUNCT_CHARS[subModeCh];
|
ch = PUNCT_CHARS[subModeCh];
|
||||||
} else {
|
} else {
|
||||||
if (subModeCh == PAL) {
|
if (subModeCh == PAL) {
|
||||||
|
@ -375,7 +381,7 @@ final class DecodedBitStreamParser {
|
||||||
// If Byte Compaction mode is invoked with codeword 901,
|
// If Byte Compaction mode is invoked with codeword 901,
|
||||||
// the final group of codewords is interpreted directly
|
// the final group of codewords is interpreted directly
|
||||||
// as one byte per codeword, without compaction.
|
// as one byte per codeword, without compaction.
|
||||||
for (int i = ((count / 5) * 5); i < count; i++) {
|
for (int i = (count / 5) * 5; i < count; i++) {
|
||||||
result.append((char) byteCompactedCodewords[i]);
|
result.append((char) byteCompactedCodewords[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Activebarcode
|
ActiveBarcode
|
|
@ -33,8 +33,8 @@ public final class PDF417BlackBox2TestCase extends AbstractBlackBoxTestCase {
|
||||||
|
|
||||||
public PDF417BlackBox2TestCase() {
|
public PDF417BlackBox2TestCase() {
|
||||||
super("test/data/blackbox/pdf417-2", new MultiFormatReader(), BarcodeFormat.PDF417);
|
super("test/data/blackbox/pdf417-2", new MultiFormatReader(), BarcodeFormat.PDF417);
|
||||||
addTest(11, 11, 0.0f);
|
addTest(13, 13, 0.0f);
|
||||||
addTest(11, 11, 180.0f);
|
addTest(13, 13, 180.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue