Tuesday, April 23, 2013

UIImage imageWithCGImage example ios


imageWithCGImage:

Creates and returns an image object representing the specified Quartz image.
+ (UIImage *)imageWithCGImage:(CGImageRef)cgImage
Parameters
cgImage
The Quartz image object.
Return Value of [UIImage imageWithCGImage]
A new image object for the specified Quartz image, or nil if the method could not initialize the image from the specified image reference.
Discussion of [UIImage imageWithCGImage]
This method does not cache the image object. You can use the methods of the Core Graphics framework to create a Quartz image reference.
Example of [UIImage imageWithCGImage]

CGImageRef cgImage = [asset thumbnail];
    UIImage *thumbImage = [[UIImage imageWithCGImage:cgImage ]retain];
    UIImageView *thumbImageView = [[UIImageView alloc] initWithImage:thumbImage];
    CGImageRelease(cgImage);