AM031447
AM031447

Reputation: 495

Zxing how to save the image or make QRCode?

I integrated Zxing in Android studio and scanning, to save scanned images.

But 'Zxing' is not returning any image, so I need to convert the result into a QRCode.

Is there any other way to save QRCode images?


I tried teaching Bhavika provided

However, the following error

         import java.awt.Color; can not resolve symbol 'Color'

         import java.awt.Graphics2D; can not resolve symbol 'Graphics2D'

         import java.awt.image.BufferedImage; can not resolve symbol 'BufferedImage'

         import javax.imageio.ImageIO; can not resolve symbol 'ImageIO'

I do not know how he happened, what is the solution?

Upvotes: 1

Views: 3586

Answers (2)

AM031447
AM031447

Reputation: 495

I use this code to make QRCODE image


            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();
        }

Upvotes: 2

boltthrower
boltthrower

Reputation: 1250

See if this link helps you. The tutorial is also converting an image to QR code.

Upvotes: 0

Related Questions