Java Code Examples for com.google.zxing.datamatrix.encoder.SymbolInfo#getSymbolHeight()

The following examples show how to use com.google.zxing.datamatrix.encoder.SymbolInfo#getSymbolHeight() . 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: DataMatrixWriter.java    From ZXing-Orient with Apache License 2.0 4 votes vote down vote up
/**
 * Encode the given symbol info to a bit matrix.
 *
 * @param placement  The DataMatrix placement.
 * @param symbolInfo The symbol info to encode.
 * @return The bit matrix generated.
 */
private static BitMatrix encodeLowLevel(DefaultPlacement placement, SymbolInfo symbolInfo) {
  int symbolWidth = symbolInfo.getSymbolDataWidth();
  int symbolHeight = symbolInfo.getSymbolDataHeight();

  ByteMatrix matrix = new ByteMatrix(symbolInfo.getSymbolWidth(), symbolInfo.getSymbolHeight());

  int matrixY = 0;

  for (int y = 0; y < symbolHeight; y++) {
    // Fill the top edge with alternate 0 / 1
    int matrixX;
    if ((y % symbolInfo.matrixHeight) == 0) {
      matrixX = 0;
      for (int x = 0; x < symbolInfo.getSymbolWidth(); x++) {
        matrix.set(matrixX, matrixY, (x % 2) == 0);
        matrixX++;
      }
      matrixY++;
    }
    matrixX = 0;
    for (int x = 0; x < symbolWidth; x++) {
      // Fill the right edge with full 1
      if ((x % symbolInfo.matrixWidth) == 0) {
        matrix.set(matrixX, matrixY, true);
        matrixX++;
      }
      matrix.set(matrixX, matrixY, placement.getBit(x, y));
      matrixX++;
      // Fill the right edge with alternate 0 / 1
      if ((x % symbolInfo.matrixWidth) == symbolInfo.matrixWidth - 1) {
        matrix.set(matrixX, matrixY, (y % 2) == 0);
        matrixX++;
      }
    }
    matrixY++;
    // Fill the bottom edge with full 1
    if ((y % symbolInfo.matrixHeight) == symbolInfo.matrixHeight - 1) {
      matrixX = 0;
      for (int x = 0; x < symbolInfo.getSymbolWidth(); x++) {
        matrix.set(matrixX, matrixY, true);
        matrixX++;
      }
      matrixY++;
    }
  }

  return convertByteMatrixToBitMatrix(matrix);
}
 
Example 2
Source File: DataMatrixWriter.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 4 votes vote down vote up
/**
 * Encode the given symbol info to a bit matrix.
 *
 * @param placement  The DataMatrix placement.
 * @param symbolInfo The symbol info to encode.
 * @return The bit matrix generated.
 */
private static BitMatrix encodeLowLevel(DefaultPlacement placement, SymbolInfo symbolInfo) {
  int symbolWidth = symbolInfo.getSymbolDataWidth();
  int symbolHeight = symbolInfo.getSymbolDataHeight();

  ByteMatrix matrix = new ByteMatrix(symbolInfo.getSymbolWidth(), symbolInfo.getSymbolHeight());

  int matrixY = 0;

  for (int y = 0; y < symbolHeight; y++) {
    // Fill the top edge with alternate 0 / 1
    int matrixX;
    if ((y % symbolInfo.matrixHeight) == 0) {
      matrixX = 0;
      for (int x = 0; x < symbolInfo.getSymbolWidth(); x++) {
        matrix.set(matrixX, matrixY, (x % 2) == 0);
        matrixX++;
      }
      matrixY++;
    }
    matrixX = 0;
    for (int x = 0; x < symbolWidth; x++) {
      // Fill the right edge with full 1
      if ((x % symbolInfo.matrixWidth) == 0) {
        matrix.set(matrixX, matrixY, true);
        matrixX++;
      }
      matrix.set(matrixX, matrixY, placement.getBit(x, y));
      matrixX++;
      // Fill the right edge with alternate 0 / 1
      if ((x % symbolInfo.matrixWidth) == symbolInfo.matrixWidth - 1) {
        matrix.set(matrixX, matrixY, (y % 2) == 0);
        matrixX++;
      }
    }
    matrixY++;
    // Fill the bottom edge with full 1
    if ((y % symbolInfo.matrixHeight) == symbolInfo.matrixHeight - 1) {
      matrixX = 0;
      for (int x = 0; x < symbolInfo.getSymbolWidth(); x++) {
        matrix.set(matrixX, matrixY, true);
        matrixX++;
      }
      matrixY++;
    }
  }

  return convertByteMatrixToBitMatrix(matrix);
}
 
Example 3
Source File: DataMatrixWriter.java    From weex with Apache License 2.0 4 votes vote down vote up
/**
 * Encode the given symbol info to a bit matrix.
 *
 * @param placement  The DataMatrix placement.
 * @param symbolInfo The symbol info to encode.
 * @return The bit matrix generated.
 */
private static BitMatrix encodeLowLevel(DefaultPlacement placement, SymbolInfo symbolInfo) {
  int symbolWidth = symbolInfo.getSymbolDataWidth();
  int symbolHeight = symbolInfo.getSymbolDataHeight();

  ByteMatrix matrix = new ByteMatrix(symbolInfo.getSymbolWidth(), symbolInfo.getSymbolHeight());

  int matrixY = 0;

  for (int y = 0; y < symbolHeight; y++) {
    // Fill the top edge with alternate 0 / 1
    int matrixX;
    if ((y % symbolInfo.matrixHeight) == 0) {
      matrixX = 0;
      for (int x = 0; x < symbolInfo.getSymbolWidth(); x++) {
        matrix.set(matrixX, matrixY, (x % 2) == 0);
        matrixX++;
      }
      matrixY++;
    }
    matrixX = 0;
    for (int x = 0; x < symbolWidth; x++) {
      // Fill the right edge with full 1
      if ((x % symbolInfo.matrixWidth) == 0) {
        matrix.set(matrixX, matrixY, true);
        matrixX++;
      }
      matrix.set(matrixX, matrixY, placement.getBit(x, y));
      matrixX++;
      // Fill the right edge with alternate 0 / 1
      if ((x % symbolInfo.matrixWidth) == symbolInfo.matrixWidth - 1) {
        matrix.set(matrixX, matrixY, (y % 2) == 0);
        matrixX++;
      }
    }
    matrixY++;
    // Fill the bottom edge with full 1
    if ((y % symbolInfo.matrixHeight) == symbolInfo.matrixHeight - 1) {
      matrixX = 0;
      for (int x = 0; x < symbolInfo.getSymbolWidth(); x++) {
        matrix.set(matrixX, matrixY, true);
        matrixX++;
      }
      matrixY++;
    }
  }

  return convertByteMatrixToBitMatrix(matrix);
}
 
Example 4
Source File: DataMatrixWriter.java    From barcodescanner-lib-aar with MIT License 4 votes vote down vote up
/**
 * Encode the given symbol info to a bit matrix.
 *
 * @param placement  The DataMatrix placement.
 * @param symbolInfo The symbol info to encode.
 * @return The bit matrix generated.
 */
private static BitMatrix encodeLowLevel(DefaultPlacement placement, SymbolInfo symbolInfo) {
  int symbolWidth = symbolInfo.getSymbolDataWidth();
  int symbolHeight = symbolInfo.getSymbolDataHeight();

  ByteMatrix matrix = new ByteMatrix(symbolInfo.getSymbolWidth(), symbolInfo.getSymbolHeight());

  int matrixY = 0;

  for (int y = 0; y < symbolHeight; y++) {
    // Fill the top edge with alternate 0 / 1
    int matrixX;
    if ((y % symbolInfo.matrixHeight) == 0) {
      matrixX = 0;
      for (int x = 0; x < symbolInfo.getSymbolWidth(); x++) {
        matrix.set(matrixX, matrixY, (x % 2) == 0);
        matrixX++;
      }
      matrixY++;
    }
    matrixX = 0;
    for (int x = 0; x < symbolWidth; x++) {
      // Fill the right edge with full 1
      if ((x % symbolInfo.matrixWidth) == 0) {
        matrix.set(matrixX, matrixY, true);
        matrixX++;
      }
      matrix.set(matrixX, matrixY, placement.getBit(x, y));
      matrixX++;
      // Fill the right edge with alternate 0 / 1
      if ((x % symbolInfo.matrixWidth) == symbolInfo.matrixWidth - 1) {
        matrix.set(matrixX, matrixY, (y % 2) == 0);
        matrixX++;
      }
    }
    matrixY++;
    // Fill the bottom edge with full 1
    if ((y % symbolInfo.matrixHeight) == symbolInfo.matrixHeight - 1) {
      matrixX = 0;
      for (int x = 0; x < symbolInfo.getSymbolWidth(); x++) {
        matrix.set(matrixX, matrixY, true);
        matrixX++;
      }
      matrixY++;
    }
  }

  return convertByteMatrixToBitMatrix(matrix);
}
 
Example 5
Source File: DataMatrixWriter.java    From RipplePower with Apache License 2.0 4 votes vote down vote up
/**
 * Encode the given symbol info to a bit matrix.
 * 
 * @param placement
 *            The DataMatrix placement.
 * @param symbolInfo
 *            The symbol info to encode.
 * @return The bit matrix generated.
 */
private static BitMatrix encodeLowLevel(DefaultPlacement placement, SymbolInfo symbolInfo) {
	int symbolWidth = symbolInfo.getSymbolDataWidth();
	int symbolHeight = symbolInfo.getSymbolDataHeight();

	ByteMatrix matrix = new ByteMatrix(symbolInfo.getSymbolWidth(), symbolInfo.getSymbolHeight());

	int matrixY = 0;

	for (int y = 0; y < symbolHeight; y++) {
		// Fill the top edge with alternate 0 / 1
		int matrixX;
		if ((y % symbolInfo.matrixHeight) == 0) {
			matrixX = 0;
			for (int x = 0; x < symbolInfo.getSymbolWidth(); x++) {
				matrix.set(matrixX, matrixY, (x % 2) == 0);
				matrixX++;
			}
			matrixY++;
		}
		matrixX = 0;
		for (int x = 0; x < symbolWidth; x++) {
			// Fill the right edge with full 1
			if ((x % symbolInfo.matrixWidth) == 0) {
				matrix.set(matrixX, matrixY, true);
				matrixX++;
			}
			matrix.set(matrixX, matrixY, placement.getBit(x, y));
			matrixX++;
			// Fill the right edge with alternate 0 / 1
			if ((x % symbolInfo.matrixWidth) == symbolInfo.matrixWidth - 1) {
				matrix.set(matrixX, matrixY, (y % 2) == 0);
				matrixX++;
			}
		}
		matrixY++;
		// Fill the bottom edge with full 1
		if ((y % symbolInfo.matrixHeight) == symbolInfo.matrixHeight - 1) {
			matrixX = 0;
			for (int x = 0; x < symbolInfo.getSymbolWidth(); x++) {
				matrix.set(matrixX, matrixY, true);
				matrixX++;
			}
			matrixY++;
		}
	}

	return convertByteMatrixToBitMatrix(matrix);
}