当前位置: 首页>>代码示例>>Java>>正文


Java BitArray.getSize方法代码示例

本文整理汇总了Java中com.google.zxing.common.BitArray.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java BitArray.getSize方法的具体用法?Java BitArray.getSize怎么用?Java BitArray.getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.zxing.common.BitArray的用法示例。


在下文中一共展示了BitArray.getSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseFoundFinderPattern

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private FinderPattern parseFoundFinderPattern(BitArray row, int rowNumber, boolean right, int[] startEnd)
    throws NotFoundException {
  // Actually we found elements 2-5
  boolean firstIsBlack = row.get(startEnd[0]);
  int firstElementStart = startEnd[0] - 1;
  // Locate element 1
  while (firstElementStart >= 0 && firstIsBlack ^ row.get(firstElementStart)) {
    firstElementStart--;
  }
  firstElementStart++;
  int firstCounter = startEnd[0] - firstElementStart;
  // Make 'counters' hold 1-4
  int[] counters = getDecodeFinderCounters();
  System.arraycopy(counters, 0, counters, 1, counters.length - 1);
  counters[0] = firstCounter;
  int value = parseFinderValue(counters, FINDER_PATTERNS);
  int start = firstElementStart;
  int end = startEnd[1];
  if (right) {
    // row is actually reversed
    start = row.getSize() - 1 - start;
    end = row.getSize() - 1 - end;
  }
  return new FinderPattern(value, new int[] {firstElementStart, startEnd[1]}, start, end, rowNumber);
}
 
开发者ID:10045125,项目名称:QrCode,代码行数:26,代码来源:RSS14Reader.java

示例2: setCounters

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
/**
 * Records the size of all runs of white and black pixels, starting with white.
 * This is just like recordPattern, except it records all the counters, and
 * uses our builtin "counters" member for storage.
 * @param row row to count from
 */
private void setCounters(BitArray row) throws NotFoundException {
  counterLength = 0;
  // Start from the first white bit.
  int i = row.getNextUnset(0);
  int end = row.getSize();
  if (i >= end) {
    throw NotFoundException.getNotFoundInstance();
  }
  boolean isWhite = true;
  int count = 0;
  while (i < end) {
    if (row.get(i) ^ isWhite) { // that is, exactly one is true
      count++;
    } else {
      counterAppend(count);
      count = 1;
      isWhite = !isWhite;
    }
    i++;
  }
  counterAppend(count);
}
 
开发者ID:10045125,项目名称:QrCode,代码行数:29,代码来源:CodaBarReader.java

示例3: setCounters

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
/**
 * Records the size of all runs of white and black pixels, starting with white.
 * This is just like recordPattern, except it records all the counters, and
 * uses our builtin "counters" member for storage.
 * @param row row to count from
 */
private void setCounters(BitArray row) throws NotFoundException {
  counterLength = 0;
  // Start from the first white bit.
  int i = row.getNextUnset(0);
  int end = row.getSize();
  if (i >= end) {
    throw NotFoundException.getNotFoundInstance();
  }
  boolean isWhite = true;
  int count = 0;
  while (i < end) {
    if (row.get(i) != isWhite) {
      count++;
    } else {
      counterAppend(count);
      count = 1;
      isWhite = !isWhite;
    }
    i++;
  }
  counterAppend(count);
}
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:29,代码来源:CodaBarReader.java

示例4: 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;
}
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:17,代码来源:ITFReader.java

示例5: embedTypeInfo

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
static void embedTypeInfo(ErrorCorrectionLevel ecLevel, int maskPattern, ByteMatrix matrix)
        throws WriterException {
    BitArray typeInfoBits = new BitArray();
    makeTypeInfoBits(ecLevel, maskPattern, typeInfoBits);
    for (int i = 0; i < typeInfoBits.getSize(); i++) {
        boolean bit = typeInfoBits.get((typeInfoBits.getSize() - 1) - i);
        matrix.set(TYPE_INFO_COORDINATES[i][0], TYPE_INFO_COORDINATES[i][1], bit);
        if (i < 8) {
            matrix.set((matrix.getWidth() - i) - 1, 8, bit);
        } else {
            matrix.set(8, (matrix.getHeight() - 7) + (i - 8), bit);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:MatrixUtil.java

示例6: findAsteriskPattern

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private int[] findAsteriskPattern(BitArray row) throws NotFoundException {
  int width = row.getSize();
  int rowOffset = row.getNextSet(0);

  Arrays.fill(counters, 0);
  int[] theCounters = counters;
  int patternStart = rowOffset;
  boolean isWhite = false;
  int patternLength = theCounters.length;

  int counterPosition = 0;
  for (int i = rowOffset; i < width; i++) {
    if (row.get(i) != isWhite) {
      theCounters[counterPosition]++;
    } else {
      if (counterPosition == patternLength - 1) {
        if (toPattern(theCounters) == ASTERISK_ENCODING) {
          return new int[]{patternStart, i};
        }
        patternStart += theCounters[0] + theCounters[1];
        System.arraycopy(theCounters, 2, theCounters, 0, counterPosition - 1);
        theCounters[counterPosition - 1] = 0;
        theCounters[counterPosition] = 0;
        counterPosition--;
      } else {
        counterPosition++;
      }
      theCounters[counterPosition] = 1;
      isWhite = !isWhite;
    }
  }
  throw NotFoundException.getNotFoundInstance();
}
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:34,代码来源:Code93Reader.java

示例7: 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;
}
 
开发者ID:10045125,项目名称:QrCode,代码行数:39,代码来源:UPCEANExtension5Support.java

示例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;
}
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:39,代码来源:UPCEANExtension5Support.java

示例9: 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;
    int i = rowOffset;
    while (i < width) {
        if ((row.get(i) ^ isWhite) != 0) {
            counters[counterPosition] = counters[counterPosition] + 1;
        } else {
            if (counterPosition != patternLength - 1) {
                counterPosition++;
            } else if (toNarrowWidePattern(counters) == ASTERISK_ENCODING && row.isRange(Math
                    .max(0, patternStart - ((i - patternStart) / 2)), patternStart, false)) {
                return new int[]{patternStart, i};
            } else {
                patternStart += counters[0] + counters[1];
                System.arraycopy(counters, 2, counters, 0, patternLength - 2);
                counters[patternLength - 2] = 0;
                counters[patternLength - 1] = 0;
                counterPosition--;
            }
            counters[counterPosition] = 1;
            if (isWhite) {
                isWhite = false;
            } else {
                isWhite = true;
            }
        }
        i++;
    }
    throw NotFoundException.getNotFoundInstance();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:37,代码来源:Code39Reader.java

示例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, counterPosition - 1);
        counters[counterPosition - 1] = 0;
        counters[counterPosition] = 0;
        counterPosition--;
      } else {
        counterPosition++;
      }
      counters[counterPosition] = 1;
      isWhite = !isWhite;
    }
  }
  throw NotFoundException.getNotFoundInstance();
}
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:45,代码来源:UPCEANReader.java

示例11: decodeMiddle

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
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;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:39,代码来源:UPCEANExtension5Support.java

示例12: generateCheckWords

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
private static BitArray generateCheckWords(BitArray bitArray, int totalBits, int wordSize) {
  // bitArray is guaranteed to be a multiple of the wordSize, so no padding needed
  int messageSizeInWords = bitArray.getSize() / wordSize;
  ReedSolomonEncoder rs = new ReedSolomonEncoder(getGF(wordSize));
  int totalWords = totalBits / wordSize;
  int[] messageWords = bitsToWords(bitArray, wordSize, totalWords);
  rs.encode(messageWords, totalWords - messageSizeInWords);
  int startPad = totalBits % wordSize;
  BitArray messageBits = new BitArray();
  messageBits.appendBits(0, startPad);
  for (int messageWord : messageWords) {
    messageBits.appendBits(messageWord, wordSize);
  }
  return messageBits;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:16,代码来源:Encoder.java

示例13: decodeMiddle

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
@Override
protected int decodeMiddle(BitArray row, int[] startRange, StringBuilder result)
    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 < 6 && rowOffset < end; x++) {
    int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS);
    result.append((char) ('0' + bestMatch % 10));
    for (int counter : counters) {
      rowOffset += counter;
    }
    if (bestMatch >= 10) {
      lgPatternFound |= 1 << (5 - x);
    }
  }

  determineNumSysAndCheckDigit(result, lgPatternFound);

  return rowOffset;
}
 
开发者ID:10045125,项目名称:QrCode,代码行数:29,代码来源:UPCEReader.java

示例14: recordPattern

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
/**
 * Records the size of successive runs of white and black pixels in a row, starting at a given point.
 * The values are recorded in the given array, and the number of runs recorded is equal to the size
 * of the array. If the row starts on a white pixel at the given start point, then the first count
 * recorded is the run of white pixels starting from that point; likewise it is the count of a run
 * of black pixels if the row begin on a black pixels at that point.
 *
 * @param row row to count from
 * @param start offset into row to start at
 * @param counters array into which to record counts
 * @throws NotFoundException if counters cannot be filled entirely from row before running out
 *  of pixels
 */
protected static void recordPattern(BitArray row,
                                    int start,
                                    int[] counters) throws NotFoundException {
  int numCounters = counters.length;
  Arrays.fill(counters, 0, numCounters, 0);
  int end = row.getSize();
  if (start >= end) {
    throw NotFoundException.getNotFoundInstance();
  }
  boolean isWhite = !row.get(start);
  int counterPosition = 0;
  int i = start;
  while (i < end) {
    if (row.get(i) ^ isWhite) { // that is, exactly one is true
      counters[counterPosition]++;
    } else {
      counterPosition++;
      if (counterPosition == numCounters) {
        break;
      } else {
        counters[counterPosition] = 1;
        isWhite = !isWhite;
      }
    }
    i++;
  }
  // If we read fully the last section of pixels and filled up our counters -- or filled
  // the last counter but ran off the side of the image, OK. Otherwise, a problem.
  if (!(counterPosition == numCounters || (counterPosition == numCounters - 1 && i == end))) {
    throw NotFoundException.getNotFoundInstance();
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:46,代码来源:OneDReader.java

示例15: stuffBits

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
static BitArray stuffBits(BitArray bits, int wordSize) {
    BitArray out = new BitArray();
    int n = bits.getSize();
    int mask = (1 << wordSize) - 2;
    int i = 0;
    while (i < n) {
        int word = 0;
        int j = 0;
        while (j < wordSize) {
            if (i + j >= n || bits.get(i + j)) {
                word |= 1 << ((wordSize - 1) - j);
            }
            j++;
        }
        if ((word & mask) == mask) {
            out.appendBits(word & mask, wordSize);
            i--;
        } else if ((word & mask) == 0) {
            out.appendBits(word | 1, wordSize);
            i--;
        } else {
            out.appendBits(word, wordSize);
        }
        i += wordSize;
    }
    return out;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:28,代码来源:Encoder.java


注:本文中的com.google.zxing.common.BitArray.getSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。