Java 类com.google.zxing.oned.rss.AbstractRSSReader 实例源码

项目:boohee_v5.6    文件:RSSExpandedReader.java   
private FinderPattern parseFoundFinderPattern(BitArray row, int rowNumber, boolean oddPattern) {
    int firstCounter;
    int start;
    int end;
    if (oddPattern) {
        int firstElementStart = this.startEnd[0] - 1;
        while (firstElementStart >= 0 && !row.get(firstElementStart)) {
            firstElementStart--;
        }
        firstElementStart++;
        firstCounter = this.startEnd[0] - firstElementStart;
        start = firstElementStart;
        end = this.startEnd[1];
    } else {
        start = this.startEnd[0];
        end = row.getNextUnset(this.startEnd[1] + 1);
        firstCounter = end - this.startEnd[1];
    }
    int[] counters = getDecodeFinderCounters();
    System.arraycopy(counters, 0, counters, 1, counters.length - 1);
    counters[0] = firstCounter;
    try {
        return new FinderPattern(AbstractRSSReader.parseFinderValue(counters,
                FINDER_PATTERNS), new int[]{start, end}, start, end, rowNumber);
    } catch (NotFoundException e) {
        return null;
    }
}
项目:boohee_v5.6    文件:RSSExpandedReader.java   
private void findNextPair(BitArray row, List<ExpandedPair> previousPairs, int forcedOffset)
        throws NotFoundException {
    int rowOffset;
    int[] counters = getDecodeFinderCounters();
    counters[0] = 0;
    counters[1] = 0;
    counters[2] = 0;
    counters[3] = 0;
    int width = row.getSize();
    if (forcedOffset >= 0) {
        rowOffset = forcedOffset;
    } else if (previousPairs.isEmpty()) {
        rowOffset = 0;
    } else {
        rowOffset = ((ExpandedPair) previousPairs.get(previousPairs.size() - 1))
                .getFinderPattern().getStartEnd()[1];
    }
    boolean searchingEvenPair = previousPairs.size() % 2 != 0;
    if (this.startFromEven) {
        searchingEvenPair = !searchingEvenPair;
    }
    boolean isWhite = false;
    while (rowOffset < width) {
        isWhite = !row.get(rowOffset);
        if (!isWhite) {
            break;
        }
        rowOffset++;
    }
    int counterPosition = 0;
    int patternStart = rowOffset;
    for (int x = rowOffset; x < width; x++) {
        if ((row.get(x) ^ isWhite) != 0) {
            counters[counterPosition] = counters[counterPosition] + 1;
        } else {
            if (counterPosition == 3) {
                if (searchingEvenPair) {
                    reverseCounters(counters);
                }
                if (AbstractRSSReader.isFinderPattern(counters)) {
                    this.startEnd[0] = patternStart;
                    this.startEnd[1] = x;
                    return;
                }
                if (searchingEvenPair) {
                    reverseCounters(counters);
                }
                patternStart += counters[0] + counters[1];
                counters[0] = counters[2];
                counters[1] = counters[3];
                counters[2] = 0;
                counters[3] = 0;
                counterPosition--;
            } else {
                counterPosition++;
            }
            counters[counterPosition] = 1;
            isWhite = !isWhite;
        }
    }
    throw NotFoundException.getNotFoundInstance();
}