2

我想使用 ZXing 生成 QR 码并将其显示在屏幕上,但是我要求 QR 码显示在特定背景 [图像] 上。ZXing可以吗?

谢谢

编辑:能够将状态栏标题从纯文本 [我正在使用 TYPE_TEXT] 更改为其他内容也很棒。

4

3 回答 3

1

只需使用库创建条形码图像并将其显示在您自己的活动中即可。你可以随心所欲地设计它。

于 2012-11-07T21:45:04.277 回答
1

这是如何使用 ZXING 库创建透明二维码的示例:

        QRCodeWriter qrCodeWriter = new QRCodeWriter();
        // create output image
        BufferedImage image = new BufferedImage(382, 382, BufferedImage.TYPE_INT_ARGB);
        // create bit matrix
        BitMatrix bitMatrix = new MultiFormatWriter().encode(
                qrCodeString,
                BarcodeFormat.QR_CODE, 382, 382);
        // set pixels of output image based of bit matrix (black or translucent)
        for (int i = 0; i < 382; i++) {
            for (int j = 0; j < 382; j++) {
                image.setRGB(i,j, bitMatrix.get(i,j) ? Color.BLACK.getRGB() : Color.TRANSLUCENT);
            }
        }
        // write output image as png
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ImageIO.write(image, "PNG", outputStream);
于 2021-05-16T14:33:36.370 回答
0

没有办法。通常,条形码周围需要一个安静的白色区域,因此您通常不想这样做。如果你真的需要这种情况,你可以编写自己的布局并嵌入与显示相同的代码。

于 2012-11-08T00:17:10.040 回答