【问题标题】:Generate colorful QR code生成彩色二维码
【发布时间】:2011-11-09 10:23:30
【问题描述】:

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

这怎么可能。

请帮帮我。

【问题讨论】:

  • 嗨 Shweta,我是来自钦奈的 Dinesh。我在我的应用程序中使用相同的 kuapay。但它只适用于第一次。如果我尝试在不关闭应用程序的情况下再次重新生成。然后应用程序自动崩溃。你能帮我么?谢谢

标签: iphone sdk qr-code


【解决方案1】:

【讨论】:

  • @Kinghthong 感谢您的回复。我已经编辑了我的代码..你能帮我吗..拜托它是
【解决方案2】:

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

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

你会从上面的链接中找到 qrencode 库,以及 UIImage 的类别。

在你需要用你选择的颜色简单地调用这个方法来生成它之后。

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

【讨论】:

    【解决方案3】:
    【解决方案4】:
         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();
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多