zxing控制1维码的宽度

OneDimensionalCodeWriter

/**

  • @return a byte array of horizontal pixels (0 = white, 1 = black)
    */

private static BitMatrix renderResult(boolean[] code, int width, int height, int sidesMargin) {

int inputWidth = code.length;
// Add quiet zone on both sides.
int fullWidth = inputWidth + sidesMargin;
int outputWidth = Math.max(width, fullWidth);
int outputHeight = Math.max(1, height);

int multiple = outputWidth / fullWidth;
int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;

BitMatrix output = new BitMatrix(outputWidth, outputHeight);
for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
  if (code[inputX]) {
    output.setRegion(outputX, 0, multiple, outputHeight);
  }
}
return output;

}

上一篇:FBI留后手 不愿公开iPhone破解工具


下一篇:使用注解开发| 学习笔记