I am not a fan of fullScreenImage or fullResolutionImage. I found that when you do this across multiple assets in a queue, even if you immediately release UIImage, memory usage will increase dramatically, and that shouldn't. Also, when using fullScreenImage or fullResolutionImage, the returned UIImage is still compressed, which means that it will be unpacked before being drawn for the first time, thus in the main thread, which will block your user interface.
I prefer to use this method.
-(UIImage *)fullSizeImageForAssetRepresentation:(ALAssetRepresentation *)assetRepresentation { UIImage *result = nil; NSData *data = nil; uint8_t *buffer = (uint8_t *)malloc(sizeof(uint8_t)*[assetRepresentation size]); if (buffer != NULL) { NSError *error = nil; NSUInteger bytesRead = [assetRepresentation getBytes:buffer fromOffset:0 length:[assetRepresentation size] error:&error]; data = [NSData dataWithBytes:buffer length:bytesRead]; free(buffer); } if ([data length]) { CGImageSourceRef sourceRef = CGImageSourceCreateWithData((__bridge CFDataRef)data, nil); NSMutableDictionary *options = [NSMutableDictionary dictionary]; [options setObject:(id)kCFBooleanTrue forKey:(id)kCGImageSourceShouldAllowFloat]; [options setObject:(id)kCFBooleanTrue forKey:(id)kCGImageSourceCreateThumbnailFromImageAlways]; [options setObject:(id)[NSNumber numberWithFloat:640.0f] forKey:(id)kCGImageSourceThumbnailMaxPixelSize];
You can use it as follows:
source share