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


Java ByteMatrix類代碼示例

本文整理匯總了Java中com.google.zxing.qrcode.encoder.ByteMatrix的典型用法代碼示例。如果您正苦於以下問題:Java ByteMatrix類的具體用法?Java ByteMatrix怎麽用?Java ByteMatrix使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ByteMatrix類屬於com.google.zxing.qrcode.encoder包,在下文中一共展示了ByteMatrix類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertByteMatrixToBitMatrix

import com.google.zxing.qrcode.encoder.ByteMatrix; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:24,代碼來源:DataMatrixWriter.java

示例2: convertByteMatrixToBitMatrix

import com.google.zxing.qrcode.encoder.ByteMatrix; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:Ag47,項目名稱:TrueTone,代碼行數:24,代碼來源:DataMatrixWriter.java

示例3: convertByteMatrixToBitMatrix

import com.google.zxing.qrcode.encoder.ByteMatrix; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:cping,項目名稱:RipplePower,代碼行數:25,代碼來源:DataMatrixWriter.java

示例4: drawQRCodeRect

import com.google.zxing.qrcode.encoder.ByteMatrix; //導入依賴的package包/類
private void drawQRCodeRect(Canvas canvas, ByteMatrix input, Rect qrRegionRect, int multiple
                                   , int qrWidth, int qrHeight, Paint paint) {
        Rect qrBox = new Rect();
        int r = (int) (multiple * 0.4);
        for (int inputY = 0, outputY = qrRegionRect.top; inputY < qrHeight; inputY++, outputY += multiple) {
            for (int inputX = 0, outputX = qrRegionRect.left; inputX < qrWidth; inputX++, outputX += multiple) {
                qrBox.left = outputX;
                qrBox.right = outputX + multiple;
                qrBox.top = outputY;
                qrBox.bottom = outputY + multiple;

                if (input.get(inputX, inputY) == 1) {
//                    canvas.drawRect(new Rect(outputX, outputY, outputX + multiple, outputY + multiple), paint);
                    drawRoundRect(canvas, new RectF(outputX, outputY, outputX + multiple, outputY + multiple), paint, r
                                  , (isSet(input, inputX - 1, inputY - 1) || isSet(input, inputX, inputY - 1) || isSet(input, inputX - 1, inputY))
                                  , (isSet(input, inputX, inputY - 1) || isSet(input, inputX + 1, inputY - 1) || isSet(input, inputX + 1, inputY))
                                  , (isSet(input, inputX, inputY + 1) || isSet(input, inputX, inputY - 1) || isSet(input, inputX - 1, inputY))
                                  , (isSet(input, inputX + 1, inputY) || isSet(input, inputX + 1, inputY + 1) || isSet(input, inputX, inputY + 1)));
                }
            }
        }
    }
 
開發者ID:Tinker-S,項目名稱:FaceBarCodeDemo,代碼行數:23,代碼來源:PixelBorderQREffect.java

示例5: create

import com.google.zxing.qrcode.encoder.ByteMatrix; //導入依賴的package包/類
/**
 * Create a QR matrix and render it use given configs.
 *
 * @param contents          Contents to encode.
 * @param size              Width as well as the height of the output QR code, includes margin.
 * @param margin            Margin to add around the QR code.
 * @param dataDotScale      Scale the data blocks and makes them appear smaller.
 * @param colorDark         Color of blocks. Will be OVERRIDE by autoColor. (BYTE_DTA, BYTE_POS, BYTE_AGN, BYTE_TMG)
 * @param colorLight        Color of empty space. Will be OVERRIDE by autoColor. (BYTE_EPT)
 * @param backgroundImage   The background image to embed in the QR code. If null, no background image will be embedded.
 * @param whiteMargin       If true, background image will not be drawn on the margin area.
 * @param autoColor         If true, colorDark will be set to the dominant color of background.
 * @param binarize          If true, all images will be binarized while rendering. Default is false.
 * @param binarizeThreshold Threshold value used while binarizing. Default is 128. 0 < threshold < 255.
 * @param roundedDataDots   If true, data blocks will appear as filled circles. Default is false.
 * @param logoImage         The logo image which appears at the center of the QR code. Null to disable.
 * @param logoMargin        The margin around the logo image. 0 to disable.
 * @param logoCornerRadius  The radius of logo image's corners. 0 to disable.
 * @param logoScale         Logo's size = logoScale * innerRenderSize
 * @return Bitmap of QR code
 * @throws IllegalArgumentException Refer to the messages below.
 */
private static Bitmap create(String contents, int size, int margin, float dataDotScale, int colorDark,
                             int colorLight, Bitmap backgroundImage, boolean whiteMargin, boolean autoColor,
                             boolean binarize, int binarizeThreshold, boolean roundedDataDots,
                             Bitmap logoImage, int logoMargin, int logoCornerRadius, float logoScale) throws IllegalArgumentException {
    if (contents.isEmpty()) {
        throw new IllegalArgumentException("Error: contents is empty. (contents.isEmpty())");
    }
    if (size < 0) {
        throw new IllegalArgumentException("Error: a negative size is given. (size < 0)");
    }
    if (margin < 0) {
        throw new IllegalArgumentException("Error: a negative margin is given. (margin < 0)");
    }
    if (size - 2 * margin <= 0) {
        throw new IllegalArgumentException("Error: there is no space left for the QRCode. (size - 2 * margin <= 0)");
    }
    ByteMatrix byteMatrix = getBitMatrix(contents);
    if (size - 2 * margin < byteMatrix.getWidth()) {
        throw new IllegalArgumentException("Error: there is no space left for the QRCode. (size - 2 * margin < " + byteMatrix.getWidth() + ")");
    }
    if (dataDotScale < 0 || dataDotScale > 1) {
        throw new IllegalArgumentException("Error: an illegal data dot scale is given. (dataDotScale < 0 || dataDotScale > 1)");
    }
    return render(byteMatrix, size - 2 * margin, margin, dataDotScale, colorDark, colorLight, backgroundImage,
            whiteMargin, autoColor, binarize, binarizeThreshold, roundedDataDots, logoImage, logoMargin,
            logoCornerRadius, logoScale);
}
 
開發者ID:SumiMakito,項目名稱:AwesomeQRCode,代碼行數:50,代碼來源:AwesomeQRCode.java

示例6: renderResult

import com.google.zxing.qrcode.encoder.ByteMatrix; //導入依賴的package包/類
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
  ByteMatrix input = code.getMatrix();
  if (input == null) {
    throw new IllegalStateException();
  }
  int inputWidth = input.getWidth();
  int inputHeight = input.getHeight();
  int qrWidth = inputWidth + (quietZone * 2);
  int qrHeight = inputHeight + (quietZone * 2);
  int outputWidth = Math.max(width, qrWidth);
  int outputHeight = Math.max(height, qrHeight);

  int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
  // Padding includes both the quiet zone and the extra white pixels to accommodate the requested
  // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
  // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
  // handle all the padding from 100x100 (the actual QR) up to 200x160.
  int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
  int topPadding = (outputHeight - (inputHeight * multiple)) / 2;

  BitMatrix output = new BitMatrix(outputWidth, outputHeight);

  for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
    // Write the contents of this row of the barcode
    for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
      if (input.get(inputX, inputY) == 1) {
        output.setRegion(outputX, outputY, multiple, multiple);
      }
    }
  }

  return output;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:34,代碼來源:QRCodeWriter.java

示例7: renderResult

import com.google.zxing.qrcode.encoder.ByteMatrix; //導入依賴的package包/類
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
    ByteMatrix input = code.getMatrix();
    if (input == null) {
        throw new IllegalStateException();
    }
    int inputWidth = input.getWidth();
    int inputHeight = input.getHeight();
    int qrWidth = inputWidth + (quietZone << 1);
    int qrHeight = inputHeight + (quietZone << 1);
    int outputWidth = Math.max(width, qrWidth);
    int outputHeight = Math.max(height, qrHeight);
    int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
    int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
    int topPadding = (outputHeight - (inputHeight * multiple)) / 2;
    BitMatrix output = new BitMatrix(outputWidth, outputHeight);
    int inputY = 0;
    int outputY = topPadding;
    while (inputY < inputHeight) {
        int inputX = 0;
        int outputX = leftPadding;
        while (inputX < inputWidth) {
            if (input.get(inputX, inputY) == (byte) 1) {
                output.setRegion(outputX, outputY, multiple, multiple);
            }
            inputX++;
            outputX += multiple;
        }
        inputY++;
        outputY += multiple;
    }
    return output;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:33,代碼來源:QRCodeWriter.java

示例8: renderResult

import com.google.zxing.qrcode.encoder.ByteMatrix; //導入依賴的package包/類
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
    ByteMatrix input = code.getMatrix();
    if (input == null) {
        throw new IllegalStateException();
    }
    int inputWidth = input.getWidth();
    int inputHeight = input.getHeight();
    int qrWidth = inputWidth + (quietZone * 2);
    int qrHeight = inputHeight + (quietZone * 2);
    int outputWidth = Math.max(width, qrWidth);
    int outputHeight = Math.max(height, qrHeight);
    int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
    int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
    int topPadding = (outputHeight - (inputHeight * multiple)) / 2;
    BitMatrix output = new BitMatrix(outputWidth, outputHeight);
    int inputY = 0;
    int outputY = topPadding;
    while (inputY < inputHeight) {
        int inputX = 0;
        int outputX = leftPadding;
        while (inputX < inputWidth) {
            if (input.get(inputX, inputY) == (byte) 1) {
                output.setRegion(outputX, outputY, multiple, multiple);
            }
            inputX++;
            outputX += multiple;
        }
        inputY++;
        outputY += multiple;
    }
    return output;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:33,代碼來源:QRCodeWriter.java

示例9: convertByteMatrixToBitMatrix

import com.google.zxing.qrcode.encoder.ByteMatrix; //導入依賴的package包/類
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++) {
            if (matrix.get(i, j) == (byte) 1) {
                output.set(i, j);
            }
        }
    }
    return output;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:15,代碼來源:DataMatrixWriter.java

示例10: renderResult

import com.google.zxing.qrcode.encoder.ByteMatrix; //導入依賴的package包/類
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
  ByteMatrix input = code.getMatrix();
  if (input == null) {
    throw new IllegalStateException();
  }
  int inputWidth = input.getWidth();
  int inputHeight = input.getHeight();
  int qrWidth = inputWidth + (quietZone << 1);
  int qrHeight = inputHeight + (quietZone << 1);
  int outputWidth = Math.max(width, qrWidth);
  int outputHeight = Math.max(height, qrHeight);

  int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
  // Padding includes both the quiet zone and the extra white pixels to accommodate the requested
  // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
  // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
  // handle all the padding from 100x100 (the actual QR) up to 200x160.
  int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
  int topPadding = (outputHeight - (inputHeight * multiple)) / 2;

  BitMatrix output = new BitMatrix(outputWidth, outputHeight);

  for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
    // Write the contents of this row of the barcode
    for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
      if (input.get(inputX, inputY) == 1) {
        output.setRegion(outputX, outputY, multiple, multiple);
      }
    }
  }

  return output;
}
 
開發者ID:atomsheep,項目名稱:sres-app,代碼行數:34,代碼來源:QRCodeWriter.java

示例11: renderResult

import com.google.zxing.qrcode.encoder.ByteMatrix; //導入依賴的package包/類
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
    ByteMatrix input = code.getMatrix();
    if (input == null) {
        throw new IllegalStateException();
    }
    int inputWidth = input.getWidth();
    int inputHeight = input.getHeight();
    int qrWidth = inputWidth + (quietZone * 2);
    int qrHeight = inputHeight + (quietZone * 2);
    int outputWidth = Math.max(width, qrWidth);
    int outputHeight = Math.max(height, qrHeight);

    int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
    // Padding includes both the quiet zone and the extra white pixels to accommodate the requested
    // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
    // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
    // handle all the padding from 100x100 (the actual QR) up to 200x160.
    int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
    int topPadding = (outputHeight - (inputHeight * multiple)) / 2;

    BitMatrix output = new BitMatrix(outputWidth, outputHeight);

    for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
        // Write the contents of this row of the barcode
        for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
            if (input.get(inputX, inputY) == 1) {
                output.setRegion(outputX, outputY, multiple, multiple);
            }
        }
    }

    return output;
}
 
開發者ID:Ag47,項目名稱:TrueTone,代碼行數:34,代碼來源:QRCodeWriter.java

示例12: renderResult

import com.google.zxing.qrcode.encoder.ByteMatrix; //導入依賴的package包/類
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
    ByteMatrix input = code.getMatrix();
    if (input == null) {
        throw new IllegalStateException();
    }
    int inputWidth = input.getWidth();
    int inputHeight = input.getHeight();
    int qrWidth = inputWidth + (quietZone << 1);
    int qrHeight = inputHeight + (quietZone << 1);
    int outputWidth = Math.max(width, qrWidth);
    int outputHeight = Math.max(height, qrHeight);

    int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
    // Padding includes both the quiet zone and the extra white pixels to accommodate the requested
    // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
    // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
    // handle all the padding from 100x100 (the actual QR) up to 200x160.
    int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
    int topPadding = (outputHeight - (inputHeight * multiple)) / 2;

    BitMatrix output = new BitMatrix(outputWidth, outputHeight);

    for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
        // Write the contents of this row of the barcode
        for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
            if (input.get(inputX, inputY) == 1) {
                output.setRegion(outputX, outputY, multiple, multiple);
            }
        }
    }

    return output;
}
 
開發者ID:yakovenkodenis,項目名稱:Discounty,代碼行數:34,代碼來源:QRCodeWriter.java


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