當前位置: 首頁>>代碼示例>>Java>>正文


Java BitMatrix.getEnclosingRectangle方法代碼示例

本文整理匯總了Java中com.google.zxing.common.BitMatrix.getEnclosingRectangle方法的典型用法代碼示例。如果您正苦於以下問題:Java BitMatrix.getEnclosingRectangle方法的具體用法?Java BitMatrix.getEnclosingRectangle怎麽用?Java BitMatrix.getEnclosingRectangle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.zxing.common.BitMatrix的用法示例。


在下文中一共展示了BitMatrix.getEnclosingRectangle方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateBit

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
/**
 * Get BitMatrix
 *
 * @param matrix BitMatrix
 * @param margin margin
 * @return BitMatrix
 */
public static BitMatrix updateBit(BitMatrix matrix, int margin) {
    int tempM = margin * 2;
    int[] rec = matrix.getEnclosingRectangle();   //Gets the properties of the two-dimensional code pattern
    int resWidth = rec[2] + tempM;
    int resHeight = rec[3] + tempM;
    BitMatrix resMatrix = new BitMatrix(resWidth, resHeight); //Generates a new BitMatrix according to the custom borders
    resMatrix.clear();
    for (int i = margin; i < resWidth - margin; i++) {   //Loop to draw the 2D code pattern into the new 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;
}
 
開發者ID:Jusenr,項目名稱:androidtools,代碼行數:24,代碼來源:QRCodeUtils.java

示例2: extractPureBits

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
/**
 * This method detects a code in a "pure" image -- that is, pure monochrome image
 * which contains only an unrotated, unskewed, image of a code, with some white border
 * around it. This is a specialized method that works exceptionally fast in this special
 * case.
 *
 * @see com.google.zxing.datamatrix.DataMatrixReader#extractPureBits(BitMatrix)
 * @see com.google.zxing.qrcode.QRCodeReader#extractPureBits(BitMatrix)
 */
private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException {
  
  int[] enclosingRectangle = image.getEnclosingRectangle();
  if (enclosingRectangle == null) {
    throw NotFoundException.getNotFoundInstance();
  }
  
  int left = enclosingRectangle[0];
  int top = enclosingRectangle[1];
  int width = enclosingRectangle[2];
  int height = enclosingRectangle[3];

  // Now just read off the bits
  BitMatrix bits = new BitMatrix(MATRIX_WIDTH, MATRIX_HEIGHT);
  for (int y = 0; y < MATRIX_HEIGHT; y++) {
    int iy = top + (y * height + height / 2) / MATRIX_HEIGHT;
    for (int x = 0; x < MATRIX_WIDTH; x++) {
      int ix = left + (x * width + width / 2 + (y & 0x01) *  width / 2) / MATRIX_WIDTH;
      if (image.get(ix, iy)) {
        bits.set(x, y);
      }
    }
  }
  return bits;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:35,代碼來源:MaxiCodeReader.java

示例3: extractPureBits

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException {
    int[] enclosingRectangle = image.getEnclosingRectangle();
    if (enclosingRectangle == null) {
        throw NotFoundException.getNotFoundInstance();
    }
    int left = enclosingRectangle[0];
    int top = enclosingRectangle[1];
    int width = enclosingRectangle[2];
    int height = enclosingRectangle[3];
    BitMatrix bits = new BitMatrix(30, 33);
    for (int y = 0; y < 33; y++) {
        int iy = top + (((y * height) + (height / 2)) / 33);
        for (int x = 0; x < 30; x++) {
            if (image.get(left + ((((x * width) + (width / 2)) + (((y & 1) * width) / 2)) /
                    30), iy)) {
                bits.set(x, y);
            }
        }
    }
    return bits;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:22,代碼來源:MaxiCodeReader.java

示例4: deleteWhite

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
public static BitMatrix deleteWhite(BitMatrix matrix){
	int[] rec = matrix.getEnclosingRectangle();
	int resWidth = rec[2] + 1;
	int resHeight = rec[3] + 1;

	BitMatrix resMatrix = new BitMatrix(resWidth, resHeight);
	resMatrix.clear();
	for (int i = 0; i < resWidth; i++) {
		for (int j = 0; j < resHeight; j++) {
			if (matrix.get(i + rec[0], j + rec[1]))
				resMatrix.set(i, j);
		}
	}
	return resMatrix;
}
 
開發者ID:thlws,項目名稱:payment-wechat,代碼行數:16,代碼來源:ZxingUtil.java


注:本文中的com.google.zxing.common.BitMatrix.getEnclosingRectangle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。