iosobjective-cuiimageappcelerator-titaniumtitanium-modules

Create UIImage from CIImage on iOS 10


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.


Solution

  • 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!)