Last active
June 6, 2018 08:37
-
-
Save tonymillion/6716935 to your computer and use it in GitHub Desktop.
force decoding of UIImage on load on iOS7 (so it can be done on a background thread not the UI thread).
This file contains 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
+(UIImage*)immediateImageWithData:(NSData*)data | |
{ | |
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); | |
CGImageRef cgImage = CGImageSourceCreateImageAtIndex(source, 0, (__bridge CFDictionaryRef)@{(id)kCGImageSourceShouldCacheImmediately: (id)kCFBooleanTrue}); | |
UIImage *temp = [UIImage imageWithCGImage:cgImage]; | |
CGImageRelease(cgImage); | |
CFRelease(source); | |
return temp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment