I'm building an Iphone app that needs to convert a UIImage to a CGImageRef. I have no idea how to do this and would love some help. I have no background in working with images... :)
            Asked
            
        
        
            Active
            
        
            Viewed 3.8k times
        
    3 Answers
110
            It is as simple as image.CGImage where image is a UIImage object.
        Deepak Danduprolu
        
- 44,595
 - 12
 - 101
 - 105
 
- 
                    5Do note that the CGImage may not be exactly equivalent to the UIImage. In particular, watch out for `imageOrientation` being other than `UIImageOrientationUp`. – Anomie May 20 '11 at 04:02
 - 
                    3Be aware of `image` could also be created from `CIImage` – zc246 Sep 07 '16 at 08:53
 
16
            
            
        CGImageRef cgImage = [someImage CGImage];
        Jason Coco
        
- 77,985
 - 20
 - 184
 - 180
 
- 
                    11Unless the UIImage was initialized from a CIImage, in that case, CGImage will be nil. – Alex Zavatone May 30 '14 at 20:46
 
3
            
            
        write folowing to get CGImage from UIImage: Suppose u have an UIImage object ex imageObject then,
CGImage imageRef = imageObject.CGImage
        Duck
        
- 34,902
 - 47
 - 248
 - 470
 
        Satish Azad
        
- 2,302
 - 1
 - 16
 - 35