Reputation: 330
I was trying to rebuild a Titanium Module for iOS10 (https://github.com/Exygy/Titanium-Ti.Barcode)
While rebuilding, I am getting following error and the build is failing.
cannot initialize a variable of type 'UIImage *' with an rvalue of type
'CIImage *'
UIImage *image = [blob image];
^ ~~~~~~~~~~~~
Following is the piece of code where it is getting generated:
id blob = [args valueForKey:@"image"];
ENSURE_TYPE(blob, TiBlob);
UIImage* image = [blob image];
I am a noob in the Objective C.
Upvotes: 2
Views: 6162
Reputation: 3436
You can use following :
Objective C:
CIImage *ciImage = [blob image];
UIImage *uiImage = [[UIImage alloc] initWithCIImage:ciImage];
Swift 4.0:
let ciImage: CIImage? = blob.image()
let uiImage = UIImage(ciImage: ciImage!)
Upvotes: 5
Reputation: 780
Try this method:
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef cgImage = [context createCGImage:ciImage fromRect:[ciImage extent]];
UIImage* uiImage = [UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);
Upvotes: 0
Reputation: 400
In swift 4.0
let ciImage: CIImage? = blob.image()
let uiImage = UIImage(ciImage: ciImage!)
Upvotes: 0
Reputation: 2962
CIImage to UIImage
Swift 3.0
let uiImage = UIImage(CIImage: ciImage)
Upvotes: 0
Reputation: 1613
Swift 3.0
func convertCIImagetoUIimage(cmage:CIImage) -> UIImage {
let context:CIContext = CIContext.init(options: nil)
let cgImage:CGImage = context.createCGImage(cmage, from: cmage.extent)!
let image:UIImage = UIImage.init(cgImage: cgImage)
return image
}
Upvotes: 1