首页 文章

Zxing如何保存图像或制作QRCode?

提问于
浏览
0

我将Zxing整合到Android工作室并进行扫描,以保存扫描图像 .

但'Zxing'没有返回任何图像,所以我需要将结果转换为QRCode .

还有其他方法可以保存QRCode图像吗?


我试过教Bhavika

但是,出现以下错误

import java.awt.Color;无法解析符号'颜色'

import java.awt.Graphics2D;无法解析符号'Graphics2D'

import java.awt.image.BufferedImage;无法解析符号'BufferedImage'

import javax.imageio.ImageIO;无法解析符号'ImageIO'

我不知道他是怎么回事,解决方案是什么?

2 回答

  • 0

    看看this link是否对你有帮助 . 本教程还将图像转换为QR码 .

  • 0

    我使用此代码制作QRCODE图像


    QRCodeWriter writer = new QRCodeWriter();
            try {
                BitMatrix bitMatrix = writer.encode(SendQrCode, BarcodeFormat.QR_CODE, 512, 512);//SendQrCode is Want to make a string
                int width = bitMatrix.getWidth();
                int height = bitMatrix.getHeight();
                bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
                for (int x = 0; x < width; x++) {
                    for (int y = 0; y < height; y++) {
                        bmp.setPixel(x, y, bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE);
                    }
                }
                ((ImageView) findViewById(R.id.img_result_qr)).setImageBitmap(bmp);
    
            } catch (WriterException e) {
                e.printStackTrace();
            }
    

相关问题