---
title: barcodeGenerator()
framework: coreimage
role: symbol
role_heading: Type Method
path: coreimage/cifilter-swift.class/barcodegenerator()
---

# barcodeGenerator()

Generates a barcode as an image from the descriptor.

## Declaration

```swift
class func barcodeGenerator() -> any CIFilter & CIBarcodeGenerator
```

## Return Value

Return Value The generated image.

## Discussion

Discussion This method generates a custom barcode as an image. The effect uses barcode descriptors to specify properties of the generated barcode. The barcode generator uses the following property: The following code creates a filter that generates a QR code containing the text Johnny Appleseed. func barcode(inputMessage: Data) -> CIImage {    let barcodeGenerator = CIFilter.barcodeGenerator()     barcodeGenerator.barcodeDescriptor = CIQRCodeDescriptor(payload: inputMessage, symbolVersion: 1, maskPattern: 4, errorCorrectionLevel: .levelL)!     return barcodeGenerator.outputImage! }

let johnnyAppleseed: [UInt8] = [0x41, 0x04, 0xA6, 0xF6, 0x86, 0xE6, 0xE7, 0x92, 0x04, 0x17, 0x07, 0x06, 0xC6, 0x57, 0x36, 0x56, 0x56, 0x40, 0xEC] let data = Data(johnnyAppleseed)

let bImage = barcode(inputMessage: data)

## See Also

### Related Documentation

- [CIAztecCodeDescriptor](coreimage/ciazteccodedescriptor.md)
- [CIDataMatrixCodeDescriptor](coreimage/cidatamatrixcodedescriptor.md)
- [CIPDF417CodeDescriptor](coreimage/cipdf417codedescriptor.md)
- [CIQRCodeDescriptor](coreimage/ciqrcodedescriptor.md)

### Filters

- [attributedTextImageGenerator()](coreimage/cifilter-swift.class/attributedtextimagegenerator().md)
- [aztecCodeGenerator()](coreimage/cifilter-swift.class/azteccodegenerator().md)
- [blurredRectangleGenerator()](coreimage/cifilter-swift.class/blurredrectanglegenerator().md)
- [checkerboardGenerator()](coreimage/cifilter-swift.class/checkerboardgenerator().md)
- [code128BarcodeGenerator()](coreimage/cifilter-swift.class/code128barcodegenerator().md)
- [lenticularHaloGenerator()](coreimage/cifilter-swift.class/lenticularhalogenerator().md)
- [meshGenerator()](coreimage/cifilter-swift.class/meshgenerator().md)
- [pdf417BarcodeGenerator()](coreimage/cifilter-swift.class/pdf417barcodegenerator().md)
- [qrCodeGenerator()](coreimage/cifilter-swift.class/qrcodegenerator().md)
- [randomGenerator()](coreimage/cifilter-swift.class/randomgenerator().md)
- [roundedRectangleGenerator()](coreimage/cifilter-swift.class/roundedrectanglegenerator().md)
- [roundedRectangleStrokeGenerator()](coreimage/cifilter-swift.class/roundedrectanglestrokegenerator().md)
- [starShineGenerator()](coreimage/cifilter-swift.class/starshinegenerator().md)
- [stripesGenerator()](coreimage/cifilter-swift.class/stripesgenerator().md)
- [sunbeamsGenerator()](coreimage/cifilter-swift.class/sunbeamsgenerator().md)
