生成彩色QR码

时间:2011-11-09 10:23:31

标签: iphone sdk qr-code

我想生成彩色QR码。 我曾使用https://github.com/kuapay/iOS-QR-Code-Generator代码生成QR码。 现在生成的qr代码总是n黑色。我想用红色或任何颜色 其他颜色。 着色编码和QR码.png图像的绘制完成QR_Draw_png.mm文件。 我应该在QR_Draw_png.mm这个文件中编辑什么。 如何生成丰富多彩的qr代码。

怎么可能。

请帮帮我。

4 个答案:

答案 0 :(得分:2)

答案 1 :(得分:1)

这是生成彩色QR码的最佳示例。

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

您将从上面的链接和UIImage的类别中找到qrencode库。

您需要使用所选颜色简单地调用此方法以生成它。

mgView.image = [UIImage QRCodeGenerator:txtCouponName.text
                          andLightColour:[UIColor whiteColor]
                           andDarkColour:[UIColor blackColor]
                            andQuietZone:1
                                 andSize:300];

答案 2 :(得分:0)

答案 3 :(得分:0)

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