Java Code Examples for com.google.zxing.common.BitMatrix#clear()

The following examples show how to use com.google.zxing.common.BitMatrix#clear() . 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: QRCodeHelper.java    From AndroidWallet with GNU General Public License v3.0 6 votes vote down vote up
private static BitMatrix updateBit(BitMatrix matrix, int margin){
    int tempM = margin*2;
    int[] rec = matrix.getEnclosingRectangle();   //获取二维码图案的属性
    int resWidth = rec[2] + tempM;
    int resHeight = rec[3] + tempM;
    BitMatrix resMatrix = new BitMatrix(resWidth, resHeight); // 按照自定义边框生成新的BitMatrix
    resMatrix.clear();
    for(int i= margin; i < resWidth- margin; i++){   //循环,将二维码图案绘制到新的bitMatrix中
        for(int j=margin; j < resHeight-margin; j++){
            if(matrix.get(i-margin + rec[0], j-margin + rec[1])){
                resMatrix.set(i,j);
            }
        }
    }
    return resMatrix;
}
 
Example 2
Source File: PDF417Writer.java    From letv with Apache License 2.0 6 votes vote down vote up
private static BitMatrix bitMatrixFrombitArray(byte[][] input) {
    BitMatrix output = new BitMatrix(input[0].length + 60, input.length + 60);
    output.clear();
    int y = 0;
    int yOutput = output.getHeight() - 30;
    while (y < input.length) {
        for (int x = 0; x < input[0].length; x++) {
            if (input[y][x] == (byte) 1) {
                output.set(x + 30, yOutput);
            }
        }
        y++;
        yOutput--;
    }
    return output;
}
 
Example 3
Source File: DataMatrixWriter.java    From ZXing-Orient with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the ByteMatrix to BitMatrix.
 *
 * @param matrix The input matrix.
 * @return The output matrix.
 */
private static BitMatrix convertByteMatrixToBitMatrix(ByteMatrix matrix) {
  int matrixWidgth = matrix.getWidth();
  int matrixHeight = matrix.getHeight();

  BitMatrix output = new BitMatrix(matrixWidgth, matrixHeight);
  output.clear();
  for (int i = 0; i < matrixWidgth; i++) {
    for (int j = 0; j < matrixHeight; j++) {
      // Zero is white in the bytematrix
      if (matrix.get(i, j) == 1) {
        output.set(i, j);
      }
    }
  }

  return output;
}
 
Example 4
Source File: DataMatrixWriter.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the ByteMatrix to BitMatrix.
 *
 * @param matrix The input matrix.
 * @return The output matrix.
 */
private static BitMatrix convertByteMatrixToBitMatrix(ByteMatrix matrix) {
  int matrixWidgth = matrix.getWidth();
  int matrixHeight = matrix.getHeight();

  BitMatrix output = new BitMatrix(matrixWidgth, matrixHeight);
  output.clear();
  for (int i = 0; i < matrixWidgth; i++) {
    for (int j = 0; j < matrixHeight; j++) {
      // Zero is white in the bytematrix
      if (matrix.get(i, j) == 1) {
        output.set(i, j);
      }
    }
  }

  return output;
}
 
Example 5
Source File: DataMatrixWriter.java    From weex with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the ByteMatrix to BitMatrix.
 *
 * @param matrix The input matrix.
 * @return The output matrix.
 */
private static BitMatrix convertByteMatrixToBitMatrix(ByteMatrix matrix) {
  int matrixWidgth = matrix.getWidth();
  int matrixHeight = matrix.getHeight();

  BitMatrix output = new BitMatrix(matrixWidgth, matrixHeight);
  output.clear();
  for (int i = 0; i < matrixWidgth; i++) {
    for (int j = 0; j < matrixHeight; j++) {
      // Zero is white in the bytematrix
      if (matrix.get(i, j) == 1) {
        output.set(i, j);
      }
    }
  }

  return output;
}
 
Example 6
Source File: DataMatrixWriter.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
/**
 * Convert the ByteMatrix to BitMatrix.
 *
 * @param matrix The input matrix.
 * @return The output matrix.
 */
private static BitMatrix convertByteMatrixToBitMatrix(ByteMatrix matrix) {
  int matrixWidgth = matrix.getWidth();
  int matrixHeight = matrix.getHeight();

  BitMatrix output = new BitMatrix(matrixWidgth, matrixHeight);
  output.clear();
  for (int i = 0; i < matrixWidgth; i++) {
    for (int j = 0; j < matrixHeight; j++) {
      // Zero is white in the bytematrix
      if (matrix.get(i, j) == 1) {
        output.set(i, j);
      }
    }
  }

  return output;
}
 
Example 7
Source File: PDF417Writer.java    From reacteu-app with MIT License 6 votes vote down vote up
/**
 * This takes an array holding the values of the PDF 417
 *
 * @param input a byte array of information with 0 is black, and 1 is white
 * @return BitMatrix of the input
 */
private static BitMatrix bitMatrixFrombitArray(byte[][] input) {
  // Creates a small whitespace border around the barcode
  int whiteSpace = 30;

  // Creates the bitmatrix with extra space for whitespace
  BitMatrix output = new BitMatrix(input[0].length + 2 * whiteSpace, input.length + 2 * whiteSpace);
  output.clear();
  for (int y = 0, yOutput = output.getHeight() - whiteSpace; y < input.length; y++, yOutput--) {
    for (int x = 0; x < input[0].length; x++) {
      // Zero is white in the bytematrix
      if (input[y][x] == 1) {
        output.set(x + whiteSpace, yOutput);
      }
    }
  }
  return output;
}
 
Example 8
Source File: PDF417Writer.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private static BitMatrix a(byte abyte0[][])
{
    BitMatrix bitmatrix = new BitMatrix(60 + abyte0.length, 60 + abyte0[0].length);
    bitmatrix.clear();
    for (int i = 0; i < abyte0.length; i++)
    {
        for (int j = 0; j < abyte0[0].length; j++)
        {
            if (abyte0[i][j] == 1)
            {
                bitmatrix.set(i + 30, j + 30);
            }
        }

    }

    return bitmatrix;
}
 
Example 9
Source File: DataMatrixWriter.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the ByteMatrix to BitMatrix.
 * 
 * @param matrix
 *            The input matrix.
 * @return The output matrix.
 */
private static BitMatrix convertByteMatrixToBitMatrix(ByteMatrix matrix) {
	int matrixWidgth = matrix.getWidth();
	int matrixHeight = matrix.getHeight();

	BitMatrix output = new BitMatrix(matrixWidgth, matrixHeight);
	output.clear();
	for (int i = 0; i < matrixWidgth; i++) {
		for (int j = 0; j < matrixHeight; j++) {
			// Zero is white in the bytematrix
			if (matrix.get(i, j) == 1) {
				output.set(i, j);
			}
		}
	}

	return output;
}
 
Example 10
Source File: PDF417Writer.java    From ZXing-Orient with Apache License 2.0 5 votes vote down vote up
/**
 * This takes an array holding the values of the PDF 417
 *
 * @param input a byte array of information with 0 is black, and 1 is white
 * @param margin border around the barcode
 * @return BitMatrix of the input
 */
private static BitMatrix bitMatrixFrombitArray(byte[][] input, int margin) {
  // Creates the bitmatrix with extra space for whitespace
  BitMatrix output = new BitMatrix(input[0].length + 2 * margin, input.length + 2 * margin);
  output.clear();
  for (int y = 0, yOutput = output.getHeight() - margin - 1; y < input.length; y++, yOutput--) {
    for (int x = 0; x < input[0].length; x++) {
      // Zero is white in the bytematrix
      if (input[y][x] == 1) {
        output.set(x + margin, yOutput);
      }
    }
  }
  return output;
}
 
Example 11
Source File: PDF417Writer.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
/**
 * This takes an array holding the values of the PDF 417
 *
 * @param input a byte array of information with 0 is black, and 1 is white
 * @param margin border around the barcode
 * @return BitMatrix of the input
 */
private static BitMatrix bitMatrixFrombitArray(byte[][] input, int margin) {
  // Creates the bitmatrix with extra space for whitespace
  BitMatrix output = new BitMatrix(input[0].length + 2 * margin, input.length + 2 * margin);
  output.clear();
  for (int y = 0, yOutput = output.getHeight() - margin - 1; y < input.length; y++, yOutput--) {
    for (int x = 0; x < input[0].length; x++) {
      // Zero is white in the bytematrix
      if (input[y][x] == 1) {
        output.set(x + margin, yOutput);
      }
    }
  }
  return output;
}
 
Example 12
Source File: PDF417Writer.java    From weex with Apache License 2.0 5 votes vote down vote up
/**
 * This takes an array holding the values of the PDF 417
 *
 * @param input a byte array of information with 0 is black, and 1 is white
 * @param margin border around the barcode
 * @return BitMatrix of the input
 */
private static BitMatrix bitMatrixFrombitArray(byte[][] input, int margin) {
  // Creates the bitmatrix with extra space for whitespace
  BitMatrix output = new BitMatrix(input[0].length + 2 * margin, input.length + 2 * margin);
  output.clear();
  for (int y = 0, yOutput = output.getHeight() - margin - 1; y < input.length; y++, yOutput--) {
    for (int x = 0; x < input[0].length; x++) {
      // Zero is white in the bytematrix
      if (input[y][x] == 1) {
        output.set(x + margin, yOutput);
      }
    }
  }
  return output;
}
 
Example 13
Source File: PDF417Writer.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
/**
 * This takes an array holding the values of the PDF 417
 *
 * @param input a byte array of information with 0 is black, and 1 is white
 * @param margin border around the barcode
 * @return BitMatrix of the input
 */
private static BitMatrix bitMatrixFrombitArray(byte[][] input, int margin) {
  // Creates the bitmatrix with extra space for whitespace
  BitMatrix output = new BitMatrix(input[0].length + 2 * margin, input.length + 2 * margin);
  output.clear();
  for (int y = 0, yOutput = output.getHeight() - margin - 1; y < input.length; y++, yOutput--) {
    for (int x = 0; x < input[0].length; x++) {
      // Zero is white in the bytematrix
      if (input[y][x] == 1) {
        output.set(x + margin, yOutput);
      }
    }
  }
  return output;
}