1

Я пытался восстановить модуль Titanium для iOS10 (https://github.com/Exygy/Titanium-Ti.Barcode)Создание UIImage из CIImage на прошивке 10

Хотя восстановления, я получаю следующее сообщение об ошибке, и сборка не удается.

cannot initialize a variable of type 'UIImage *' with an rvalue of type 
    'CIImage *' 
UIImage *image = [blob image]; 
     ^  ~~~~~~~~~~~~ 

Ниже приводится фрагмент кода, где он становится генерироваться:

id blob = [args valueForKey:@"image"]; 
ENSURE_TYPE(blob, TiBlob); 
UIImage* image = [blob image]; 

Я нуб в Objective C.

ответ

4

Вы можете использовать следующие:

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

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 
    } 
0

Попробуйте этот метод:

CIContext *context = [CIContext contextWithOptions:nil]; 
CGImageRef cgImage = [context createCGImage:ciImage fromRect:[ciImage extent]]; 
UIImage* uiImage = [UIImage imageWithCGImage:cgImage]; 
CGImageRelease(cgImage); 
0

CIImage к UIImage

Swift 3,0

let uiImage = UIImage(CIImage: ciImage) 
0

В стремительной 4.0

let ciImage: CIImage? = blob.image() 
let uiImage = UIImage(ciImage: ciImage!) 
Смежные вопросы