I have an image:
As you can clearly see, the barcode doesn't fit in very well with the UI :/
I thought a potential fix for this, was to "green screen" out the black in the image, leaving on the white part of the barcode.
The barcode itself is generated on the fly.
func generateBarcode(from string: String) -> UIImage? {
let data = string.data(using: String.Encoding.ascii)
if let filter = CIFilter(name: "CICode128BarcodeGenerator") {
filter.setValue(data, forKey: "inputMessage")
let transform = CGAffineTransform(scaleX: 3, y: 3)
if let output = filter.outputImage?.applying(transform) {
let invertFiler = CIFilter(name: "CIColorInvert")!
invertFiler.setValue(output, forKey: kCIInputImageKey)
return UIImage(ciImage: (invertFiler.outputImage?.applying(transform))!) //TODO: Remove force unwrap
}
}
return nil
}
Now I've heard I can use a "CIColorCube" filter but haven't been able to work out to use it.
Is removing the black part possible? And, if so, would you be able to help me out?
Thanks