How do you change the Back and Foreground Color of a CIFilter CIQRCodeGenerator Filter

后端 未结 3 1442

I\'m trying to make a QR Code Generator for OS X but i haven\'t had succession in making a QRCode that can be more colourful that the black and white ones I\'m using the CIQRCod

3条回答
  •  攒了一身酷
    2021-02-15 01:11

    CIQRCodeGenerator only generates QR codes in black and white, but you can easily transform the resulting image to another color scheme.

    Create an instance of the CIFalseColor filter, set its inputImage to the outputImage from your generator, and its inputColor0 and inputColor1 to the colors you want to use instead of black and white. Then draw the false color filter's outputImage into your CG context.

    You could also consider using the CIMaskToAlpha filter to turn either the black or white in the QR code image to transparent; then you'll be able to put it on top of any background color. (Just don't put it on too busy a background or people won't be able to scan it.)

提交回复
热议问题