Unable to convert CIImage to UIImage in Swift 3.0

后端 未结 3 550
栀梦
栀梦 2020-12-10 02:49

I am making image form QR Code by using following code:

  func createQRFromString(str: String) -> CIImage? {
        let stringData = str.dat         


        
3条回答
  •  無奈伤痛
    2020-12-10 03:22

    func convert(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
    }
    

    Use this function to convert CIImage to UIImage . It works .

提交回复
热议问题