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


Java BitSource.getByteOffset方法代码示例

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


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

示例1: decodeBase256Segment

import com.google.zxing.common.BitSource; //导入方法依赖的package包/类
/**
 * See ISO 16022:2006, 5.2.9 and Annex B, B.2
 */
private static void decodeBase256Segment(BitSource bits,
                                         StringBuilder result,
                                         Collection<byte[]> byteSegments)
    throws FormatException {
  // Figure out how long the Base 256 Segment is.
  int codewordPosition = 1 + bits.getByteOffset(); // position is 1-indexed
  int d1 = unrandomize255State(bits.readBits(8), codewordPosition++);
  int count;
  if (d1 == 0) {  // Read the remainder of the symbol
    count = bits.available() / 8;
  } else if (d1 < 250) {
    count = d1;
  } else {
    count = 250 * (d1 - 249) + unrandomize255State(bits.readBits(8), codewordPosition++);
  }

  // We're seeing NegativeArraySizeException errors from users.
  if (count < 0) {
    throw FormatException.getFormatInstance();
  }

  byte[] bytes = new byte[count];
  for (int i = 0; i < count; i++) {
    // Have seen this particular error in the wild, such as at
    // http://www.bcgen.com/demo/IDAutomationStreamingDataMatrix.aspx?MODE=3&D=Fred&PFMT=3&PT=F&X=0.3&O=0&LM=0.2
    if (bits.available() < 8) {
      throw FormatException.getFormatInstance();
    }
    bytes[i] = (byte) unrandomize255State(bits.readBits(8), codewordPosition++);
  }
  byteSegments.add(bytes);
  try {
    result.append(new String(bytes, "ISO8859_1"));
  } catch (UnsupportedEncodingException uee) {
    throw new IllegalStateException("Platform does not support required encoding: " + uee);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:41,代码来源:DecodedBitStreamParser.java

示例2: decodeBase256Segment

import com.google.zxing.common.BitSource; //导入方法依赖的package包/类
private static void decodeBase256Segment(BitSource bits, StringBuilder result,
                                         Collection<byte[]> byteSegments) throws
        FormatException {
    int count;
    int codewordPosition = bits.getByteOffset() + 1;
    int codewordPosition2 = codewordPosition + 1;
    int d1 = unrandomize255State(bits.readBits(8), codewordPosition);
    if (d1 == 0) {
        count = bits.available() / 8;
        codewordPosition = codewordPosition2;
    } else if (d1 < 250) {
        count = d1;
        codewordPosition = codewordPosition2;
    } else {
        codewordPosition = codewordPosition2 + 1;
        count = ((d1 - 249) * 250) + unrandomize255State(bits.readBits(8), codewordPosition2);
    }
    if (count < 0) {
        throw FormatException.getFormatInstance();
    }
    byte[] bytes = new byte[count];
    int i = 0;
    codewordPosition2 = codewordPosition;
    while (i < count) {
        if (bits.available() < 8) {
            throw FormatException.getFormatInstance();
        }
        codewordPosition = codewordPosition2 + 1;
        bytes[i] = (byte) unrandomize255State(bits.readBits(8), codewordPosition2);
        i++;
        codewordPosition2 = codewordPosition;
    }
    byteSegments.add(bytes);
    try {
        result.append(new String(bytes, "ISO8859_1"));
    } catch (UnsupportedEncodingException uee) {
        throw new IllegalStateException("Platform does not support required encoding: " + uee);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:40,代码来源:DecodedBitStreamParser.java


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