本文整理汇总了Java中com.google.zxing.common.BitArray.getNextSet方法的典型用法代码示例。如果您正苦于以下问题:Java BitArray.getNextSet方法的具体用法?Java BitArray.getNextSet怎么用?Java BitArray.getNextSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.zxing.common.BitArray
的用法示例。
在下文中一共展示了BitArray.getNextSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findGuardPattern
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
/**
* @param row row of black/white values to search
* @param rowOffset position to start search
* @param whiteFirst if true, indicates that the pattern specifies white/black/white/...
* pixel counts, otherwise, it is interpreted as black/white/black/...
* @param pattern pattern of counts of number of black and white pixels that are being
* searched for as a pattern
* @param counters array of counters, as long as pattern, to re-use
* @return start/end horizontal offset of guard pattern, as an array of two ints
* @throws NotFoundException if pattern is not found
*/
private static int[] findGuardPattern(BitArray row,
int rowOffset,
boolean whiteFirst,
int[] pattern,
int[] counters) throws NotFoundException {
int width = row.getSize();
rowOffset = whiteFirst ? row.getNextUnset(rowOffset) : row.getNextSet(rowOffset);
int counterPosition = 0;
int patternStart = rowOffset;
int patternLength = pattern.length;
boolean isWhite = whiteFirst;
for (int x = rowOffset; x < width; x++) {
if (row.get(x) != isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) {
return new int[]{patternStart, x};
}
patternStart += counters[0] + counters[1];
System.arraycopy(counters, 2, counters, 0, counterPosition - 1);
counters[counterPosition - 1] = 0;
counters[counterPosition] = 0;
counterPosition--;
} else {
counterPosition++;
}
counters[counterPosition] = 1;
isWhite = !isWhite;
}
}
throw NotFoundException.getNotFoundInstance();
}
示例2: findAsteriskPattern
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException {
int width = row.getSize();
int rowOffset = row.getNextSet(0);
int counterPosition = 0;
int patternStart = rowOffset;
boolean isWhite = false;
int patternLength = counters.length;
for (int i = rowOffset; i < width; i++) {
if (row.get(i) != isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
// Look for whitespace before start pattern, >= 50% of width of start pattern
if (toNarrowWidePattern(counters) == ASTERISK_ENCODING &&
row.isRange(Math.max(0, patternStart - ((i - patternStart) / 2)), patternStart, false)) {
return new int[]{patternStart, i};
}
patternStart += counters[0] + counters[1];
System.arraycopy(counters, 2, counters, 0, counterPosition - 1);
counters[counterPosition - 1] = 0;
counters[counterPosition] = 0;
counterPosition--;
} else {
counterPosition++;
}
counters[counterPosition] = 1;
isWhite = !isWhite;
}
}
throw NotFoundException.getNotFoundInstance();
}
示例3: getNextSecondBar
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private static int getNextSecondBar(BitArray row, int initialPos){
int currentPos;
if (row.get(initialPos)) {
currentPos = row.getNextUnset(initialPos);
currentPos = row.getNextSet(currentPos);
} else {
currentPos = row.getNextSet(initialPos);
currentPos = row.getNextUnset(currentPos);
}
return currentPos;
}
示例4: getNextSecondBar
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private static int getNextSecondBar(BitArray row, int initialPos) {
int currentPos;
if (row.get(initialPos)) {
currentPos = row.getNextUnset(initialPos);
currentPos = row.getNextSet(currentPos);
} else {
currentPos = row.getNextSet(initialPos);
currentPos = row.getNextUnset(currentPos);
}
return currentPos;
}
示例5: findGuardPattern
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
/**
* @param row row of black/white values to search
* @param rowOffset position to start search
* @param whiteFirst if true, indicates that the pattern specifies white/black/white/...
* pixel counts, otherwise, it is interpreted as black/white/black/...
* @param pattern pattern of counts of number of black and white pixels that are being
* searched for as a pattern
* @param counters array of counters, as long as pattern, to re-use
* @return start/end horizontal offset of guard pattern, as an array of two ints
* @throws NotFoundException if pattern is not found
*/
private static int[] findGuardPattern(BitArray row,
int rowOffset,
boolean whiteFirst,
int[] pattern,
int[] counters) throws NotFoundException {
int patternLength = pattern.length;
int width = row.getSize();
boolean isWhite = whiteFirst;
rowOffset = whiteFirst ? row.getNextUnset(rowOffset) : row.getNextSet(rowOffset);
int counterPosition = 0;
int patternStart = rowOffset;
for (int x = rowOffset; x < width; x++) {
if (row.get(x) ^ isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) {
return new int[]{patternStart, x};
}
patternStart += counters[0] + counters[1];
System.arraycopy(counters, 2, counters, 0, patternLength - 2);
counters[patternLength - 2] = 0;
counters[patternLength - 1] = 0;
counterPosition--;
} else {
counterPosition++;
}
counters[counterPosition] = 1;
isWhite = !isWhite;
}
}
throw NotFoundException.getNotFoundInstance();
}
示例6: skipWhiteSpace
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
/**
* Skip all whitespace until we get to the first black line.
*
* @param row row of black/white values to search
* @return index of the first black line.
* @throws NotFoundException Throws exception if no black lines are found in the row
*/
private static int skipWhiteSpace(BitArray row) throws NotFoundException {
int width = row.getSize();
int endStart = row.getNextSet(0);
if (endStart == width) {
throw NotFoundException.getNotFoundInstance();
}
return endStart;
}
示例7: findAsteriskPattern
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException {
int width = row.getSize();
int rowOffset = row.getNextSet(0);
int counterPosition = 0;
int patternStart = rowOffset;
boolean isWhite = false;
int patternLength = counters.length;
for (int i = rowOffset; i < width; i++) {
if (row.get(i) ^ isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
// Look for whitespace before start pattern, >= 50% of width of start pattern
if (toNarrowWidePattern(counters) == ASTERISK_ENCODING &&
row.isRange(Math.max(0, patternStart - ((i - patternStart) / 2)), patternStart, false)) {
return new int[]{patternStart, i};
}
patternStart += counters[0] + counters[1];
System.arraycopy(counters, 2, counters, 0, patternLength - 2);
counters[patternLength - 2] = 0;
counters[patternLength - 1] = 0;
counterPosition--;
} else {
counterPosition++;
}
counters[counterPosition] = 1;
isWhite = !isWhite;
}
}
throw NotFoundException.getNotFoundInstance();
}
示例8: decodeMiddle
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString) throws NotFoundException {
int[] counters = decodeMiddleCounters;
counters[0] = 0;
counters[1] = 0;
counters[2] = 0;
counters[3] = 0;
int end = row.getSize();
int rowOffset = startRange[1];
int lgPatternFound = 0;
for (int x = 0; x < 5 && rowOffset < end; x++) {
int bestMatch = UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_AND_G_PATTERNS);
resultString.append((char) ('0' + bestMatch % 10));
for (int counter : counters) {
rowOffset += counter;
}
if (bestMatch >= 10) {
lgPatternFound |= 1 << (4 - x);
}
if (x != 4) {
// Read off separator if not last
rowOffset = row.getNextSet(rowOffset);
rowOffset = row.getNextUnset(rowOffset);
}
}
if (resultString.length() != 5) {
throw NotFoundException.getNotFoundInstance();
}
int checkDigit = determineCheckDigit(lgPatternFound);
if (extensionChecksum(resultString.toString()) != checkDigit) {
throw NotFoundException.getNotFoundInstance();
}
return rowOffset;
}
示例9: decodeMiddle
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString) throws NotFoundException {
int[] counters = decodeMiddleCounters;
counters[0] = 0;
counters[1] = 0;
counters[2] = 0;
counters[3] = 0;
int end = row.getSize();
int rowOffset = startRange[1];
int checkParity = 0;
for (int x = 0; x < 2 && rowOffset < end; x++) {
int bestMatch = UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_AND_G_PATTERNS);
resultString.append((char) ('0' + bestMatch % 10));
for (int counter : counters) {
rowOffset += counter;
}
if (bestMatch >= 10) {
checkParity |= 1 << (1 - x);
}
if (x != 1) {
// Read off separator if not last
rowOffset = row.getNextSet(rowOffset);
rowOffset = row.getNextUnset(rowOffset);
}
}
if (resultString.length() != 2) {
throw NotFoundException.getNotFoundInstance();
}
if (Integer.parseInt(resultString.toString()) % 4 != checkParity) {
throw NotFoundException.getNotFoundInstance();
}
return rowOffset;
}
示例10: findGuardPattern
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
/**
* @param row row of black/white values to search
* @param rowOffset position to start search
* @param whiteFirst if true, indicates that the pattern specifies white/black/white/...
* pixel counts, otherwise, it is interpreted as black/white/black/...
* @param pattern pattern of counts of number of black and white pixels that are being
* searched for as a pattern
* @param counters array of counters, as long as pattern, to re-use
* @return start/end horizontal offset of guard pattern, as an array of two ints
* @throws NotFoundException if pattern is not found
*/
private static int[] findGuardPattern(BitArray row,
int rowOffset,
boolean whiteFirst,
int[] pattern,
int[] counters) throws NotFoundException {
int width = row.getSize();
rowOffset = whiteFirst ? row.getNextUnset(rowOffset) : row.getNextSet(rowOffset);
int counterPosition = 0;
int patternStart = rowOffset;
int patternLength = pattern.length;
boolean isWhite = whiteFirst;
for (int x = rowOffset; x < width; x++) {
if (row.get(x) ^ isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) {
return new int[]{patternStart, x};
}
patternStart += counters[0] + counters[1];
System.arraycopy(counters, 2, counters, 0, patternLength - 2);
counters[patternLength - 2] = 0;
counters[patternLength - 1] = 0;
counterPosition--;
} else {
counterPosition++;
}
counters[counterPosition] = 1;
isWhite = !isWhite;
}
}
throw NotFoundException.getNotFoundInstance();
}
示例11: skipWhiteSpace
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private static int skipWhiteSpace(BitArray row) throws NotFoundException {
int width = row.getSize();
int endStart = row.getNextSet(0);
if (endStart != width) {
return endStart;
}
throw NotFoundException.getNotFoundInstance();
}
示例12: decodeMiddle
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString) throws NotFoundException {
int[] counters = decodeMiddleCounters;
counters[0] = 0;
counters[1] = 0;
counters[2] = 0;
counters[3] = 0;
int end = row.getSize();
int rowOffset = startRange[1];
int checkParity = 0;
for (int x = 0; x < 2 && rowOffset < end; x++) {
int bestMatch = UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_AND_G_PATTERNS);
resultString.append((char) ('0' + bestMatch % 10));
for (int counter : counters) {
rowOffset += counter;
}
if (bestMatch >= 10) {
checkParity |= 1 << (1 - x);
}
if (x != 1) {
// Read off separator if not last
rowOffset = row.getNextSet(rowOffset);
rowOffset = row.getNextUnset(rowOffset);
}
}
if (resultString.length() != 2) {
throw NotFoundException.getNotFoundInstance();
}
if (Integer.parseInt(resultString.toString()) % 4 != checkParity) {
throw NotFoundException.getNotFoundInstance();
}
return rowOffset;
}
示例13: findStartPattern
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private static int[] findStartPattern(BitArray row) throws NotFoundException {
int width = row.getSize();
int rowOffset = row.getNextSet(0);
int counterPosition = 0;
int[] counters = new int[6];
int patternStart = rowOffset;
boolean isWhite = false;
int patternLength = counters.length;
for (int i = rowOffset; i < width; i++) {
if (row.get(i) ^ isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
float bestVariance = MAX_AVG_VARIANCE;
int bestMatch = -1;
for (int startCode = CODE_START_A; startCode <= CODE_START_C; startCode++) {
float variance = patternMatchVariance(counters, CODE_PATTERNS[startCode],
MAX_INDIVIDUAL_VARIANCE);
if (variance < bestVariance) {
bestVariance = variance;
bestMatch = startCode;
}
}
// Look for whitespace before start pattern, >= 50% of width of start pattern
if (bestMatch >= 0 &&
row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart, false)) {
return new int[]{patternStart, i, bestMatch};
}
patternStart += counters[0] + counters[1];
System.arraycopy(counters, 2, counters, 0, patternLength - 2);
counters[patternLength - 2] = 0;
counters[patternLength - 1] = 0;
counterPosition--;
} else {
counterPosition++;
}
counters[counterPosition] = 1;
isWhite = !isWhite;
}
}
throw NotFoundException.getNotFoundInstance();
}
示例14: decodeRow
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType, ?> map) throws
NotFoundException, ChecksumException, FormatException {
int[] start = findAsteriskPattern(row);
int nextStart = row.getNextSet(start[1]);
int end = row.getSize();
int[] theCounters = this.counters;
Arrays.fill(theCounters, 0);
StringBuilder result = this.decodeRowResult;
result.setLength(0);
char decodedChar;
do {
OneDReader.recordPattern(row, nextStart, theCounters);
int pattern = toPattern(theCounters);
if (pattern < 0) {
throw NotFoundException.getNotFoundInstance();
}
decodedChar = patternToChar(pattern);
result.append(decodedChar);
int lastStart = nextStart;
for (int counter : theCounters) {
nextStart += counter;
}
nextStart = row.getNextSet(nextStart);
} while (decodedChar != '*');
result.deleteCharAt(result.length() - 1);
int lastPatternSize = 0;
for (int counter2 : theCounters) {
lastPatternSize += counter2;
}
if (nextStart == end || !row.get(nextStart)) {
throw NotFoundException.getNotFoundInstance();
} else if (result.length() < 2) {
throw NotFoundException.getNotFoundInstance();
} else {
checkChecksums(result);
result.setLength(result.length() - 2);
float left = ((float) (start[1] + start[0])) / 2.0f;
float right = ((float) lastStart) + (((float) lastPatternSize) / 2.0f);
return new Result(decodeExtended(result), null, new ResultPoint[]{new ResultPoint
(left, (float) rowNumber), new ResultPoint(right, (float) rowNumber)},
BarcodeFormat.CODE_93);
}
}
示例15: findStartPattern
import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private static int[] findStartPattern(BitArray row) throws NotFoundException {
int width = row.getSize();
int rowOffset = row.getNextSet(0);
int counterPosition = 0;
int[] counters = new int[6];
int patternStart = rowOffset;
boolean isWhite = false;
int patternLength = counters.length;
for (int i = rowOffset; i < width; i++) {
if (row.get(i) != isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
float bestVariance = MAX_AVG_VARIANCE;
int bestMatch = -1;
for (int startCode = CODE_START_A; startCode <= CODE_START_C; startCode++) {
float variance = patternMatchVariance(counters, CODE_PATTERNS[startCode],
MAX_INDIVIDUAL_VARIANCE);
if (variance < bestVariance) {
bestVariance = variance;
bestMatch = startCode;
}
}
// Look for whitespace before start pattern, >= 50% of width of start pattern
if (bestMatch >= 0 &&
row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart, false)) {
return new int[]{patternStart, i, bestMatch};
}
patternStart += counters[0] + counters[1];
System.arraycopy(counters, 2, counters, 0, counterPosition - 1);
counters[counterPosition - 1] = 0;
counters[counterPosition] = 0;
counterPosition--;
} else {
counterPosition++;
}
counters[counterPosition] = 1;
isWhite = !isWhite;
}
}
throw NotFoundException.getNotFoundInstance();
}