Java Code Examples for com.google.zxing.qrcode.decoder.Version#getVersionNumber()

The following examples show how to use com.google.zxing.qrcode.decoder.Version#getVersionNumber() . 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: MatrixUtil.java    From weex with Apache License 2.0 6 votes vote down vote up
static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) throws WriterException {
  if (version.getVersionNumber() < 7) {  // Version info is necessary if version >= 7.
    return;  // Don't need version info.
  }
  BitArray versionInfoBits = new BitArray();
  makeVersionInfoBits(version, versionInfoBits);

  int bitIndex = 6 * 3 - 1;  // It will decrease from 17 to 0.
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 3; ++j) {
      // Place bits in LSB (least significant bit) to MSB order.
      boolean bit = versionInfoBits.get(bitIndex);
      bitIndex--;
      // Left bottom corner.
      matrix.set(i, matrix.getHeight() - 11 + j, bit);
      // Right bottom corner.
      matrix.set(matrix.getHeight() - 11 + j, i, bit);
    }
  }
}
 
Example 2
Source File: MatrixUtil.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) {
  if (version.getVersionNumber() < 2) {  // The patterns appear if version >= 2
    return;
  }
  int index = version.getVersionNumber() - 1;
  int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
  for (int y : coordinates) {
    if (y >= 0) {
      for (int x : coordinates) {
        if (x >= 0 && isEmpty(matrix.get(x, y))) {
          // If the cell is unset, we embed the position adjustment pattern here.
          // -2 is necessary since the x/y coordinates point to the center of the pattern, not the
          // left top corner.
          embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
        }
      }
    }
  }
}
 
Example 3
Source File: MatrixUtil.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) throws WriterException {
  if (version.getVersionNumber() < 7) {  // Version info is necessary if version >= 7.
    return;  // Don't need version info.
  }
  BitArray versionInfoBits = new BitArray();
  makeVersionInfoBits(version, versionInfoBits);

  int bitIndex = 6 * 3 - 1;  // It will decrease from 17 to 0.
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 3; ++j) {
      // Place bits in LSB (least significant bit) to MSB order.
      boolean bit = versionInfoBits.get(bitIndex);
      bitIndex--;
      // Left bottom corner.
      matrix.set(i, matrix.getHeight() - 11 + j, bit);
      // Right bottom corner.
      matrix.set(matrix.getHeight() - 11 + j, i, bit);
    }
  }
}
 
Example 4
Source File: MatrixUtil.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) {
	if (version.getVersionNumber() < 2) { // The patterns appear if version
											// >= 2
		return;
	}
	int index = version.getVersionNumber() - 1;
	int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
	int numCoordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index].length;
	for (int i = 0; i < numCoordinates; ++i) {
		for (int j = 0; j < numCoordinates; ++j) {
			int y = coordinates[i];
			int x = coordinates[j];
			if (x == -1 || y == -1) {
				continue;
			}
			// If the cell is unset, we embed the position adjustment
			// pattern here.
			if (isEmpty(matrix.get(x, y))) {
				// -2 is necessary since the x/y coordinates point to the
				// center of the pattern, not the
				// left top corner.
				embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
			}
		}
	}
}
 
Example 5
Source File: MatrixUtil.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) throws WriterException {
	if (version.getVersionNumber() < 7) { // Version info is necessary if
											// version >= 7.
		return; // Don't need version info.
	}
	BitArray versionInfoBits = new BitArray();
	makeVersionInfoBits(version, versionInfoBits);

	int bitIndex = 6 * 3 - 1; // It will decrease from 17 to 0.
	for (int i = 0; i < 6; ++i) {
		for (int j = 0; j < 3; ++j) {
			// Place bits in LSB (least significant bit) to MSB order.
			boolean bit = versionInfoBits.get(bitIndex);
			bitIndex--;
			// Left bottom corner.
			matrix.set(i, matrix.getHeight() - 11 + j, bit);
			// Right bottom corner.
			matrix.set(matrix.getHeight() - 11 + j, i, bit);
		}
	}
}
 
Example 6
Source File: MatrixUtil.java    From reacteu-app with MIT License 6 votes vote down vote up
private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) {
  if (version.getVersionNumber() < 2) {  // The patterns appear if version >= 2
    return;
  }
  int index = version.getVersionNumber() - 1;
  int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
  int numCoordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index].length;
  for (int i = 0; i < numCoordinates; ++i) {
    for (int j = 0; j < numCoordinates; ++j) {
      int y = coordinates[i];
      int x = coordinates[j];
      if (x == -1 || y == -1) {
        continue;
      }
      // If the cell is unset, we embed the position adjustment pattern here.
      if (isEmpty(matrix.get(x, y))) {
        // -2 is necessary since the x/y coordinates point to the center of the pattern, not the
        // left top corner.
        embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
      }
    }
  }
}
 
Example 7
Source File: MatrixUtil.java    From reacteu-app with MIT License 6 votes vote down vote up
static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) throws WriterException {
  if (version.getVersionNumber() < 7) {  // Version info is necessary if version >= 7.
    return;  // Don't need version info.
  }
  BitArray versionInfoBits = new BitArray();
  makeVersionInfoBits(version, versionInfoBits);

  int bitIndex = 6 * 3 - 1;  // It will decrease from 17 to 0.
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 3; ++j) {
      // Place bits in LSB (least significant bit) to MSB order.
      boolean bit = versionInfoBits.get(bitIndex);
      bitIndex--;
      // Left bottom corner.
      matrix.set(i, matrix.getHeight() - 11 + j, bit);
      // Right bottom corner.
      matrix.set(matrix.getHeight() - 11 + j, i, bit);
    }
  }
}
 
Example 8
Source File: MatrixUtil.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) {
  if (version.getVersionNumber() < 2) {  // The patterns appear if version >= 2
    return;
  }
  int index = version.getVersionNumber() - 1;
  int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
  int numCoordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index].length;
  for (int i = 0; i < numCoordinates; ++i) {
    for (int j = 0; j < numCoordinates; ++j) {
      int y = coordinates[i];
      int x = coordinates[j];
      if (x == -1 || y == -1) {
        continue;
      }
      // If the cell is unset, we embed the position adjustment pattern here.
      if (isEmpty(matrix.get(x, y))) {
        // -2 is necessary since the x/y coordinates point to the center of the pattern, not the
        // left top corner.
        embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
      }
    }
  }
}
 
Example 9
Source File: MatrixUtil.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) throws WriterException {
  if (version.getVersionNumber() < 7) {  // Version info is necessary if version >= 7.
    return;  // Don't need version info.
  }
  BitArray versionInfoBits = new BitArray();
  makeVersionInfoBits(version, versionInfoBits);

  int bitIndex = 6 * 3 - 1;  // It will decrease from 17 to 0.
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 3; ++j) {
      // Place bits in LSB (least significant bit) to MSB order.
      boolean bit = versionInfoBits.get(bitIndex);
      bitIndex--;
      // Left bottom corner.
      matrix.set(i, matrix.getHeight() - 11 + j, bit);
      // Right bottom corner.
      matrix.set(matrix.getHeight() - 11 + j, i, bit);
    }
  }
}
 
Example 10
Source File: MatrixUtil.java    From weex with Apache License 2.0 6 votes vote down vote up
private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) {
  if (version.getVersionNumber() < 2) {  // The patterns appear if version >= 2
    return;
  }
  int index = version.getVersionNumber() - 1;
  int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
  int numCoordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index].length;
  for (int i = 0; i < numCoordinates; ++i) {
    for (int j = 0; j < numCoordinates; ++j) {
      int y = coordinates[i];
      int x = coordinates[j];
      if (x == -1 || y == -1) {
        continue;
      }
      // If the cell is unset, we embed the position adjustment pattern here.
      if (isEmpty(matrix.get(x, y))) {
        // -2 is necessary since the x/y coordinates point to the center of the pattern, not the
        // left top corner.
        embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
      }
    }
  }
}
 
Example 11
Source File: MatrixUtil.java    From ScreenCapture with MIT License 6 votes vote down vote up
static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) throws WriterException {
  if (version.getVersionNumber() < 7) {  // Version info is necessary if version >= 7.
    return;  // Don't need version info.
  }
  BitArray versionInfoBits = new BitArray();
  makeVersionInfoBits(version, versionInfoBits);

  int bitIndex = 6 * 3 - 1;  // It will decrease from 17 to 0.
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 3; ++j) {
      // Place bits in LSB (least significant bit) to MSB order.
      boolean bit = versionInfoBits.get(bitIndex);
      bitIndex--;
      // Left bottom corner.
      matrix.set(i, matrix.getHeight() - 11 + j, bit);
      // Right bottom corner.
      matrix.set(matrix.getHeight() - 11 + j, i, bit);
    }
  }
}
 
Example 12
Source File: MatrixUtil.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) {
  if (version.getVersionNumber() < 2) {  // The patterns appear if version >= 2
    return;
  }
  int index = version.getVersionNumber() - 1;
  int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
  int numCoordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index].length;
  for (int i = 0; i < numCoordinates; ++i) {
    for (int j = 0; j < numCoordinates; ++j) {
      int y = coordinates[i];
      int x = coordinates[j];
      if (x == -1 || y == -1) {
        continue;
      }
      // If the cell is unset, we embed the position adjustment pattern here.
      if (isEmpty(matrix.get(x, y))) {
        // -2 is necessary since the x/y coordinates point to the center of the pattern, not the
        // left top corner.
        embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
      }
    }
  }
}
 
Example 13
Source File: MatrixUtil.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) throws WriterException {
  if (version.getVersionNumber() < 7) {  // Version info is necessary if version >= 7.
    return;  // Don't need version info.
  }
  BitArray versionInfoBits = new BitArray();
  makeVersionInfoBits(version, versionInfoBits);

  int bitIndex = 6 * 3 - 1;  // It will decrease from 17 to 0.
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 3; ++j) {
      // Place bits in LSB (least significant bit) to MSB order.
      boolean bit = versionInfoBits.get(bitIndex);
      bitIndex--;
      // Left bottom corner.
      matrix.set(i, matrix.getHeight() - 11 + j, bit);
      // Right bottom corner.
      matrix.set(matrix.getHeight() - 11 + j, i, bit);
    }
  }
}
 
Example 14
Source File: MatrixUtil.java    From ZXing-Orient with Apache License 2.0 6 votes vote down vote up
private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) {
  if (version.getVersionNumber() < 2) {  // The patterns appear if version >= 2
    return;
  }
  int index = version.getVersionNumber() - 1;
  int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
  int numCoordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index].length;
  for (int i = 0; i < numCoordinates; ++i) {
    for (int j = 0; j < numCoordinates; ++j) {
      int y = coordinates[i];
      int x = coordinates[j];
      if (x == -1 || y == -1) {
        continue;
      }
      // If the cell is unset, we embed the position adjustment pattern here.
      if (isEmpty(matrix.get(x, y))) {
        // -2 is necessary since the x/y coordinates point to the center of the pattern, not the
        // left top corner.
        embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
      }
    }
  }
}
 
Example 15
Source File: MatrixUtil.java    From ZXing-Orient with Apache License 2.0 6 votes vote down vote up
static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) throws WriterException {
  if (version.getVersionNumber() < 7) {  // Version info is necessary if version >= 7.
    return;  // Don't need version info.
  }
  BitArray versionInfoBits = new BitArray();
  makeVersionInfoBits(version, versionInfoBits);

  int bitIndex = 6 * 3 - 1;  // It will decrease from 17 to 0.
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 3; ++j) {
      // Place bits in LSB (least significant bit) to MSB order.
      boolean bit = versionInfoBits.get(bitIndex);
      bitIndex--;
      // Left bottom corner.
      matrix.set(i, matrix.getHeight() - 11 + j, bit);
      // Right bottom corner.
      matrix.set(matrix.getHeight() - 11 + j, i, bit);
    }
  }
}
 
Example 16
Source File: MatrixUtil.java    From QrCodeScanner with GNU General Public License v3.0 6 votes vote down vote up
private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) {
  if (version.getVersionNumber() < 2) {  // The patterns appear if version >= 2
    return;
  }
  int index = version.getVersionNumber() - 1;
  int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
  for (int y : coordinates) {
    if (y >= 0) {
      for (int x : coordinates) {
        if (x >= 0 && isEmpty(matrix.get(x, y))) {
          // If the cell is unset, we embed the position adjustment pattern here.
          // -2 is necessary since the x/y coordinates point to the center of the pattern, not the
          // left top corner.
          embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
        }
      }
    }
  }
}
 
Example 17
Source File: MatrixUtil.java    From QrCodeScanner with GNU General Public License v3.0 6 votes vote down vote up
static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) throws WriterException {
  if (version.getVersionNumber() < 7) {  // Version info is necessary if version >= 7.
    return;  // Don't need version info.
  }
  BitArray versionInfoBits = new BitArray();
  makeVersionInfoBits(version, versionInfoBits);

  int bitIndex = 6 * 3 - 1;  // It will decrease from 17 to 0.
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 3; ++j) {
      // Place bits in LSB (least significant bit) to MSB order.
      boolean bit = versionInfoBits.get(bitIndex);
      bitIndex--;
      // Left bottom corner.
      matrix.set(i, matrix.getHeight() - 11 + j, bit);
      // Right bottom corner.
      matrix.set(matrix.getHeight() - 11 + j, i, bit);
    }
  }
}
 
Example 18
Source File: MatrixUtil.java    From Tesseract-OCR-Scanner with Apache License 2.0 6 votes vote down vote up
private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) {
  if (version.getVersionNumber() < 2) {  // The patterns appear if version >= 2
    return;
  }
  int index = version.getVersionNumber() - 1;
  int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
  for (int y : coordinates) {
    if (y >= 0) {
      for (int x : coordinates) {
        if (x >= 0 && isEmpty(matrix.get(x, y))) {
          // If the cell is unset, we embed the position adjustment pattern here.
          // -2 is necessary since the x/y coordinates point to the center of the pattern, not the
          // left top corner.
          embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
        }
      }
    }
  }
}
 
Example 19
Source File: MatrixUtil.java    From Tesseract-OCR-Scanner with Apache License 2.0 6 votes vote down vote up
static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) throws WriterException {
  if (version.getVersionNumber() < 7) {  // Version info is necessary if version >= 7.
    return;  // Don't need version info.
  }
  BitArray versionInfoBits = new BitArray();
  makeVersionInfoBits(version, versionInfoBits);

  int bitIndex = 6 * 3 - 1;  // It will decrease from 17 to 0.
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 3; ++j) {
      // Place bits in LSB (least significant bit) to MSB order.
      boolean bit = versionInfoBits.get(bitIndex);
      bitIndex--;
      // Left bottom corner.
      matrix.set(i, matrix.getHeight() - 11 + j, bit);
      // Right bottom corner.
      matrix.set(matrix.getHeight() - 11 + j, i, bit);
    }
  }
}
 
Example 20
Source File: MatrixUtil.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) {
  if (version.getVersionNumber() < 2) {  // The patterns appear if version >= 2
    return;
  }
  int index = version.getVersionNumber() - 1;
  int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
  for (int y : coordinates) {
    if (y >= 0) {
      for (int x : coordinates) {
        if (x >= 0 && isEmpty(matrix.get(x, y))) {
          // If the cell is unset, we embed the position adjustment pattern here.
          // -2 is necessary since the x/y coordinates point to the center of the pattern, not the
          // left top corner.
          embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
        }
      }
    }
  }
}