How-to generate a QR code with the logo in the middle using CIQRCodeGenerator

孤者浪人 提交于 2020-01-22 19:40:30

问题


I am trying to generate a QR code that has a logo in the middle, as it is:

.

I am using a code I found here, my code is:

func generateQrCode(message: String!) -> CIImage! {

    var data = message.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)

    var filter: CIFilter = CIFilter(name: "CIQRCodeGenerator")
    filter.setValue(data, forKey: "inputMessage")
    filter.setValue("H", forKey: "inputCorrectionLevel")

    return filter.outputImage
}

How could adapt the code to generate a QR with a custom logo in the middle?


回答1:


Just overlay the middle part with the logo. The QR spec isn't going to some version that has a logo in the middle. The logo is just garbage that the error handling of the QR code reader handles. You don't want to make the logo too big, or else it won't be readable because of too many errors.

http://en.wikipedia.org/wiki/QR_code#Error_correction



来源:https://stackoverflow.com/questions/28801350/how-to-generate-a-qr-code-with-the-logo-in-the-middle-using-ciqrcodegenerator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!