Skip to content

@Cocoanetics /gist:1845108
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
ImageIO versus UIImageJPEGRepresentation
// 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);
@jllubia

UIImageJPEGRepresentation uses ImageIO underneath.

@sao101

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.