initWithCGImage:
Initializes and returns the image object with the specified Quartz image reference.
- (id)initWithCGImage:(CGImageRef)CGImage
Parameters
- CGImage
- A Quartz image reference.
Return Value of [UIImage initWithCGImage]
An initialized
UIImage
object, or nil
if the method could not initialize the image from the specified data.
Example of [UIImage initWithCGImage]
UIImage * makeAnImage()
{
unsigned char * pixels = malloc(...);
// ...
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, pixels, pixelBufferSize, NULL);
CGImageRef imageRef = CGImageCreate(..., provider, ...);
UIImage * image = [[UIImage alloc] initWithCGImage:imageRef];
return [image autorelease];
}
Example of [UIImage initWithCGImage]