This is how I load a JPEG or PNG file into a CGImage:
imgDataProvider = CGDataProviderCreateWithFilename( [imgFilepath UTF8String] );
if( [[imgFilepath pathExtension] isEqualToString: @"png"] )
{
image = CGImageCreateWithPNGDataProvider(imgDataProvider, NULL, true, kCGRenderingIntentDefault);
}
else if( [[imgFilepath pathExtension] isEqualToString: @"jpg"] || [[imgFilepath pathExtension] isEqualToString: @"jpeg"] )
{
image = CGImageCreateWithJPEGDataProvider(imgDataProvider, NULL, true, kCGRenderingIntentDefault);
}
Unfortunaltey the is not a CGImageCreateWith
... variant for HEIF
How do I create a CGImage from a HEIF encoded image file?
It was easier than I thought