当前位置: 首页>>代码示例>>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;未经允许,请勿转载。