Created
February 16, 2012 14:10
-
-
Save odrobnik/1845108 to your computer and use it in GitHub Desktop.
ImageIO versus UIImageJPEGRepresentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
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
UIImageJPEGRepresentation uses ImageIO underneath.