Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

ImageIO versus UIImageJPEGRepresentation

View gist:1845108
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// UIImageJPEGRepresentation
 
NSData *data = UIImageJPEGRepresentation(tileImage, 0.71);
[data writeToURL:cacheURL atomically:YES];
 
 
// ImageIO
 
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/UTCoreTypes.h>
 
CGImageDestinationRef destination = CGImageDestinationCreateWithURL((CFURLRef)cacheURL, kUTTypeJPEG, 1, NULL);
NSDictionary *destOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:0.71] forKey:(NSString *)kCGImageDestinationLossyCompressionQuality];
CGImageDestinationAddImage(destination, [scaledTileImage CGImage], (CFDictionaryRef)destOptions);
CGImageDestinationFinalize(destination);
CFRelease(destination);

UIImageJPEGRepresentation uses ImageIO underneath.

Do you have any bench marks for memory usage and speed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.