Java Code Examples for com.google.zxing.common.BitSource#getBitOffset()

The following examples show how to use com.google.zxing.common.BitSource#getBitOffset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DecodedBitStreamParser.java    From ZXing-Orient with Apache License 2.0 5 votes vote down vote up
/**
 * See ISO 16022:2006, 5.2.8 and Annex C Table C.3
 */
private static void decodeEdifactSegment(BitSource bits, StringBuilder result) {
  do {
    // If there is only two or less bytes left then it will be encoded as ASCII
    if (bits.available() <= 16) {
      return;
    }

    for (int i = 0; i < 4; i++) {
      int edifactValue = bits.readBits(6);

      // Check for the unlatch character
      if (edifactValue == 0x1F) {  // 011111
        // Read rest of byte, which should be 0, and stop
        int bitsLeft = 8 - bits.getBitOffset();
        if (bitsLeft != 8) {
          bits.readBits(bitsLeft);
        }
        return;
      }

      if ((edifactValue & 0x20) == 0) {  // no 1 in the leading (6th) bit
        edifactValue |= 0x40;  // Add a leading 01 to the 6 bit binary value
      }
      result.append((char) edifactValue);
    }
  } while (bits.available() > 0);
}
 
Example 2
Source File: DecodedBitStreamParser.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
/**
 * See ISO 16022:2006, 5.2.8 and Annex C Table C.3
 */
private static void decodeEdifactSegment(BitSource bits, StringBuilder result) {
  do {
    // If there is only two or less bytes left then it will be encoded as ASCII
    if (bits.available() <= 16) {
      return;
    }

    for (int i = 0; i < 4; i++) {
      int edifactValue = bits.readBits(6);

      // Check for the unlatch character
      if (edifactValue == 0x1F) {  // 011111
        // Read rest of byte, which should be 0, and stop
        int bitsLeft = 8 - bits.getBitOffset();
        if (bitsLeft != 8) {
          bits.readBits(bitsLeft);
        }
        return;
      }

      if ((edifactValue & 0x20) == 0) {  // no 1 in the leading (6th) bit
        edifactValue |= 0x40;  // Add a leading 01 to the 6 bit binary value
      }
      result.append((char) edifactValue);
    }
  } while (bits.available() > 0);
}
 
Example 3
Source File: DecodedBitStreamParser.java    From weex with Apache License 2.0 5 votes vote down vote up
/**
 * See ISO 16022:2006, 5.2.8 and Annex C Table C.3
 */
private static void decodeEdifactSegment(BitSource bits, StringBuilder result) {
  do {
    // If there is only two or less bytes left then it will be encoded as ASCII
    if (bits.available() <= 16) {
      return;
    }

    for (int i = 0; i < 4; i++) {
      int edifactValue = bits.readBits(6);

      // Check for the unlatch character
      if (edifactValue == 0x1F) {  // 011111
        // Read rest of byte, which should be 0, and stop
        int bitsLeft = 8 - bits.getBitOffset();
        if (bitsLeft != 8) {
          bits.readBits(bitsLeft);
        }
        return;
      }

      if ((edifactValue & 0x20) == 0) {  // no 1 in the leading (6th) bit
        edifactValue |= 0x40;  // Add a leading 01 to the 6 bit binary value
      }
      result.append((char) edifactValue);
    }
  } while (bits.available() > 0);
}
 
Example 4
Source File: DecodedBitStreamParser.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
/**
 * See ISO 16022:2006, 5.2.8 and Annex C Table C.3
 */
private static void decodeEdifactSegment(BitSource bits, StringBuilder result) {
  do {
    // If there is only two or less bytes left then it will be encoded as ASCII
    if (bits.available() <= 16) {
      return;
    }

    for (int i = 0; i < 4; i++) {
      int edifactValue = bits.readBits(6);

      // Check for the unlatch character
      if (edifactValue == 0x1F) {  // 011111
        // Read rest of byte, which should be 0, and stop
        int bitsLeft = 8 - bits.getBitOffset();
        if (bitsLeft != 8) {
          bits.readBits(bitsLeft);
        }
        return;
      }

      if ((edifactValue & 0x20) == 0) {  // no 1 in the leading (6th) bit
        edifactValue |= 0x40;  // Add a leading 01 to the 6 bit binary value
      }
      result.append((char) edifactValue);
    }
  } while (bits.available() > 0);
}
 
Example 5
Source File: DecodedBitStreamParser.java    From reacteu-app with MIT License 5 votes vote down vote up
/**
 * See ISO 16022:2006, 5.2.8 and Annex C Table C.3
 */
private static void decodeEdifactSegment(BitSource bits, StringBuilder result) {
  do {
    // If there is only two or less bytes left then it will be encoded as ASCII
    if (bits.available() <= 16) {
      return;
    }

    for (int i = 0; i < 4; i++) {
      int edifactValue = bits.readBits(6);

      // Check for the unlatch character
      if (edifactValue == 0x1F) {  // 011111
        // Read rest of byte, which should be 0, and stop
        int bitsLeft = 8 - bits.getBitOffset();
        if (bitsLeft != 8) {
          bits.readBits(bitsLeft);
        }
        return;
      }

      if ((edifactValue & 0x20) == 0) {  // no 1 in the leading (6th) bit
        edifactValue |= 0x40;  // Add a leading 01 to the 6 bit binary value
      }
      result.append((char) edifactValue);
    }
  } while (bits.available() > 0);
}
 
Example 6
Source File: DecodedBitStreamParser.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
/**
 * See ISO 16022:2006, 5.2.8 and Annex C Table C.3
 */
private static void decodeEdifactSegment(BitSource bits, StringBuilder result) {
	do {
		// If there is only two or less bytes left then it will be encoded
		// as ASCII
		if (bits.available() <= 16) {
			return;
		}

		for (int i = 0; i < 4; i++) {
			int edifactValue = bits.readBits(6);

			// Check for the unlatch character
			if (edifactValue == 0x1F) { // 011111
				// Read rest of byte, which should be 0, and stop
				int bitsLeft = 8 - bits.getBitOffset();
				if (bitsLeft != 8) {
					bits.readBits(bitsLeft);
				}
				return;
			}

			if ((edifactValue & 0x20) == 0) { // no 1 in the leading (6th)
												// bit
				edifactValue |= 0x40; // Add a leading 01 to the 6 bit
										// binary value
			}
			result.append((char) edifactValue);
		}
	} while (bits.available() > 0);
}