Difference between revisions of "Swift: Convert between CGImage, CIImage and UIImage"
From Hawk Wiki
(Created page with "===Swift: Convert CIImage to CGImage=== <pre class="brush:swift"> func convertCIImageToCGImage(inputImage: CIImage) -> CGImage! { let context = CIContext(options: nil)...") |
(No difference)
|
Latest revision as of 04:15, 23 March 2015
Contents
Swift: Convert CIImage to CGImage
func convertCIImageToCGImage(inputImage: CIImage) -> CGImage! { let context = CIContext(options: nil) if context != nil { return context.createCGImage(inputImage, fromRect: inputImage.extent()) } return nil }
Swift: Convert CGImage to CIImage
func convertCGImageToCIImage(inputImage: CGImage) -> CIImage! { var ciImage = CIImage(CGImage: inputImage) return ciImage }
Swift: Convert CGImage or CIImage to UIImage
UIImage(CGImage: cgImage) UIImage(CIImage: ciImage)
Swift: Convert UIImage to CIImage
//uiImage: UIImage //Convert to CIImage var ciImage = CIImage(image: uiImage)
Swift: Convert UIImage to CGImage
To convert to CGImage, it requires 2 steps:
First convert to CIImage #Swift: Convert UIImage to CIImage.
Then convert to CGImage #Swift:_Convert_CIImage_to_CGImage