Restored SKIP_N_BARCODES functionality and corrected a logic error

git-svn-id: https://zxing.googlecode.com/svn/trunk@304 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2008-03-20 17:01:19 +00:00
parent 91e3968774
commit 93054c2213
2 changed files with 19 additions and 17 deletions

View file

@ -56,7 +56,6 @@ public final class DecodeHintType {
* Skip the first n barcodes found. Currently applies only to 1D formats. This * Skip the first n barcodes found. Currently applies only to 1D formats. This
* enables a caller to repeatedly decode and find multiple barcodes. Maps * enables a caller to repeatedly decode and find multiple barcodes. Maps
* to an {@link Integer}. * to an {@link Integer}.
* @deprecated
*/ */
public static final DecodeHintType SKIP_N_BARCODES = new DecodeHintType(); public static final DecodeHintType SKIP_N_BARCODES = new DecodeHintType();

View file

@ -69,13 +69,13 @@ public abstract class AbstractOneDReader implements OneDReader {
BitArray row = new BitArray(width); BitArray row = new BitArray(width);
//int barcodesToSkip = 0; int barcodesToSkip = 0;
//if (hints != null) { if (hints != null) {
// Integer number = (Integer) hints.get(DecodeHintType.SKIP_N_BARCODES); Integer number = (Integer) hints.get(DecodeHintType.SKIP_N_BARCODES);
// if (number != null) { if (number != null) {
// barcodesToSkip = number.intValue(); barcodesToSkip = number.intValue();
// } }
//} }
// We're going to examine rows from the middle outward, searching alternately above and below the middle, // We're going to examine rows from the middle outward, searching alternately above and below the middle,
// and farther out each time. rowStep is the number of rows between each successive attempt above and below // and farther out each time. rowStep is the number of rows between each successive attempt above and below
@ -94,7 +94,7 @@ public abstract class AbstractOneDReader implements OneDReader {
maxLines = 7; maxLines = 7;
} }
//Result lastResult = null; Hashtable lastResults = null;
for (int x = 0; x < maxLines; x++) { for (int x = 0; x < maxLines; x++) {
@ -131,22 +131,25 @@ public abstract class AbstractOneDReader implements OneDReader {
// Look for a barcode // Look for a barcode
Result result = decodeRow(rowNumber, row, hints); Result result = decodeRow(rowNumber, row, hints);
//if (lastResult != null && lastResult.getText().equals(result.getText())) { if (lastResults != null && lastResults.containsKey(result.getText())) {
// Just saw the last barcode again, proceed // Just saw the last barcode again, proceed
//continue; continue;
//} }
//if (barcodesToSkip > 0) { // See if we should skip and keep looking if (barcodesToSkip > 0) { // See if we should skip and keep looking
// barcodesToSkip--; barcodesToSkip--;
// lastResult = result; // Remember what we just saw if (lastResults == null) {
//} else { lastResults = new Hashtable(3);
}
lastResults.put(result.getText(), Boolean.TRUE); // Remember what we just saw
} else {
// We found our barcode // We found our barcode
if (attempt == 1) { if (attempt == 1) {
// But it was upside down, so note that // But it was upside down, so note that
result.putMetadata(ResultMetadataType.ORIENTATION, new Integer(180)); result.putMetadata(ResultMetadataType.ORIENTATION, new Integer(180));
} }
return result; return result;
//} }
} catch (ReaderException re) { } catch (ReaderException re) {
// continue -- just couldn't decode this row // continue -- just couldn't decode this row