Generate colorful QR code

2019-01-12 07:25发布

I want to generate the colorful QR code. I had used https://github.com/kuapay/iOS-QR-Code-Generator code to generate the QR code. now the qr code generated is always n black color.I want to make it in Red or any other color. The coding of coloring And the drawing of QR code .png image is done QR_Draw_png.mm file. What should i edit in QR_Draw_png.mm this file. How to do the generate the colorful qr code.

How is it possible.

Please help me.

4条回答
Bombasti
2楼-- · 2019-01-12 08:11
     QRCodeWriter writer = new QRCodeWriter();
    try {
        BitMatrix bitMatrix = writer.encode(content, BarcodeFormat.QR_CODE, 512, 512);
        int width = bitMatrix.getWidth();
        int height = bitMatrix.getHeight();
        Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
// set colors for QR code
                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();
    }
查看更多
迷人小祖宗
3楼-- · 2019-01-12 08:18

This is the best example to generate colorful QR code.

http://www.oscarsanderson.com/2013/08/12/implementing-a-qr-code-generator-on-the-iphone/

You will found qrencode library from above link, and Category of UIImage.

After you need to simple call this method with your selected Color to generate it.

mgView.image = [UIImage QRCodeGenerator:txtCouponName.text
                          andLightColour:[UIColor whiteColor]
                           andDarkColour:[UIColor blackColor]
                            andQuietZone:1
                                 andSize:300];
查看更多
登录 后发表回答