-
-
Save hbridge/42de971eba5bbc7f9bf4 to your computer and use it in GitHub Desktop.
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
//1 | |
NSDictionary *imageOptions = | |
@{ | |
(NSString *)kCGImageSourceCreateThumbnailFromImageAlways : @YES, | |
(NSString *)kCGImageSourceThumbnailMaxPixelSize : [NSNumber numberWithUnsignedInteger:size], | |
(NSString *)kCGImageSourceCreateThumbnailWithTransform : @YES, | |
}; | |
CGImageSourceRef src = CGImageSourceCreateWithURL((__bridge CFURLRef)asset.defaultRepresentation.url, | |
nil); | |
CGImageRef thumbnail = CGImageSourceCreateThumbnailAtIndex(src, 0, (__bridge CFDictionaryRef)imageOptions); | |
UIImage *image = [UIImage imageWithCGImage:thumbnail]; | |
CGImageRelease(thumbnail); | |
CFRelease(src); | |
return image; | |
//2 | |
NSDictionary *imageOptions = | |
@{ | |
(NSString *)kCGImageSourceCreateThumbnailFromImageAlways : @YES, | |
(NSString *)kCGImageSourceThumbnailMaxPixelSize : [NSNumber numberWithUnsignedInteger:size], | |
(NSString *)kCGImageSourceCreateThumbnailWithTransform : @YES, | |
}; | |
CGImageSourceRef src = CGImageSourceCreateWithURL((__bridge CFURLRef)asset.defaultRepresentation.url, | |
(__bridge CFDictionaryRef)imageOptions); | |
CGImageRef thumbnail = CGImageSourceCreateThumbnailAtIndex(src, 0, (__bridge CFDictionaryRef)imageOptions); | |
UIImage *image = [UIImage imageWithCGImage:thumbnail]; | |
CGImageRelease(thumbnail); | |
CFRelease(src); | |
return image; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment