Sha256: ce3ac9886e95ff5ded0cf319d764b92954fae0d1d9fa98bbd373a23437943e7d
Contents?: true
Size: 1.4 KB
Versions: 3
Compression:
Stored size: 1.4 KB
Contents
// // SDWebImageCompat.m // SDWebImage // // Created by Olivier Poitrey on 11/12/12. // Copyright (c) 2012 Dailymotion. All rights reserved. // #import "SDWebImageCompat.h" #if !__has_feature(objc_arc) #error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag #endif inline UIImage *SDScaledImageForPath(NSString *path, NSObject *imageOrData) { if (!imageOrData) { return nil; } UIImage *image = nil; if ([imageOrData isKindOfClass:[NSData class]]) { image = [[UIImage alloc] initWithData:(NSData *)imageOrData]; } else if ([imageOrData isKindOfClass:[UIImage class]]) { image = (UIImage *)imageOrData; } else { return nil; } if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { CGFloat scale = 1.0; if (path.length >= 8) { // Search @2x. at the end of the string, before a 3 to 4 extension length (only if key len is 8 or more @2x. + 4 len ext) NSRange range = [path rangeOfString:@"@2x." options:0 range:NSMakeRange(path.length - 8, 5)]; if (range.location != NSNotFound) { scale = 2.0; } } UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; image = scaledImage; } return image; }
Version data entries
3 entries across 3 versions & 1 rubygems