Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CGImageSource to CGImage?

I got this following code that access a PHAsset. I need to pass a CGImage out of this:

let imageManager = PHImageManager.defaultManager()
imageManager.requestImageDataForAsset(self.asset!, options: nil, resultHandler:{
    (data, responseString, imageOriet, info) -> Void in
    let imageData: NSData = data!
    if let imageSource = CGImageSourceCreateWithData(imageData, nil) {
        let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil)! as NSDictionary

        //How do I create a CGImage now?

    }
})

I need to extract a CGImage out of this. Having trouble getting there...

like image 657
Gizmodo Avatar asked Sep 23 '16 20:09

Gizmodo


1 Answers

Once you have the image source you can create an image using CGImageSourceCreateImageAtIndex:

let image = CGImageSourceCreateImageAtIndex(imageSource, 0, nil)
like image 135
sbooth Avatar answered Sep 22 '22 08:09

sbooth