Skip to content

Commit 2a370b0

Browse files
author
Andy LaVoy
committed
updated formatting for project
1 parent 5bf37d5 commit 2a370b0

File tree

5 files changed

+54
-31
lines changed

5 files changed

+54
-31
lines changed

SDWebImage/NSData+GIF.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010

1111
@implementation NSData (GIF)
1212

13-
- (BOOL)isGIF {
13+
- (BOOL)isGIF
14+
{
1415
BOOL isGIF = NO;
1516

1617
uint8_t c;
1718
[self getBytes:&c length:1];
1819

19-
switch (c) {
20+
switch (c)
21+
{
2022
case 0x47: // probably a GIF
2123
isGIF = YES;
2224
break;

SDWebImage/SDImageCache.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,12 @@ - (UIImage *)diskImageForKey:(NSString *)key
181181
NSData *data = [NSData dataWithContentsOfFile:path];
182182
if (data)
183183
{
184-
if ([data isGIF]) {
184+
if ([data isGIF])
185+
{
185186
return [UIImage animatedGIFWithData:data];
186-
} else {
187+
}
188+
else
189+
{
187190
UIImage *image = [[UIImage alloc] initWithData:data];
188191
UIImage *scaledImage = [self scaledImageForKey:key image:image];
189192
return [UIImage decodedImageWithImage:scaledImage];

SDWebImage/SDWebImageManager.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ - (NSString *)cacheKeyForURL:(NSURL *)url
123123
__block id<SDWebImageOperation> subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *data, NSError *error, BOOL finished)
124124
{
125125
BOOL imageIsGIF = [data isGIF];
126-
if (imageIsGIF) {
126+
if (imageIsGIF)
127+
{
127128
downloadedImage = [UIImage animatedGIFWithData:data];
128129
}
129130

SDWebImage/UIImage+GIF.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
@interface UIImage (GIF)
1313

14-
+(UIImage*)animatedGIFNamed:(NSString*)name;
15-
+(UIImage*)animatedGIFWithData:(NSData *)data;
14+
+ (UIImage *)animatedGIFNamed:(NSString *)name;
15+
+ (UIImage *)animatedGIFWithData:(NSData *)data;
1616

17-
-(UIImage*)animatedImageByScalingAndCroppingToSize:(CGSize)size;
17+
- (UIImage *)animatedImageByScalingAndCroppingToSize:(CGSize)size;
1818

1919
@end

SDWebImage/UIImage+GIF.m

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,25 @@
1111

1212
@implementation UIImage (GIF)
1313

14-
+(UIImage*)animatedGIFWithData:(NSData *)data {
15-
if (!data) {
14+
+ (UIImage *)animatedGIFWithData:(NSData *)data
15+
{
16+
if (!data)
17+
{
1618
return nil;
1719
}
1820

1921
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
2022

2123
size_t count = CGImageSourceGetCount(source);
22-
NSMutableArray* images = [NSMutableArray array];
24+
NSMutableArray *images = [NSMutableArray array];
2325

2426
NSTimeInterval duration = 0.0f;
2527

26-
for (size_t i = 0; i < count; i++) {
28+
for (size_t i = 0; i < count; i++)
29+
{
2730
CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL);
2831

29-
NSDictionary* frameProperties = CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(source, i, NULL));
32+
NSDictionary *frameProperties = CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(source, i, NULL));
3033
duration += [[[frameProperties objectForKey:(NSString*)kCGImagePropertyGIFDictionary] objectForKey:(NSString*)kCGImagePropertyGIFDelayTime] doubleValue];
3134

3235
[images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]];
@@ -36,50 +39,59 @@ +(UIImage*)animatedGIFWithData:(NSData *)data {
3639

3740
CFRelease(source);
3841

39-
if (!duration) {
42+
if (!duration)
43+
{
4044
duration = (1.0f/10.0f)*count;
4145
}
4246

4347
return [UIImage animatedImageWithImages:images duration:duration];
4448
}
4549

46-
+(UIImage*)animatedGIFNamed:(NSString *)name {
50+
+ (UIImage *)animatedGIFNamed:(NSString *)name
51+
{
4752
CGFloat scale = [UIScreen mainScreen].scale;
4853

49-
if (scale > 1.0f) {
50-
NSString* retinaPath = [[NSBundle mainBundle] pathForResource:[name stringByAppendingString:@"@2x"] ofType:@"gif"];
54+
if (scale > 1.0f)
55+
{
56+
NSString *retinaPath = [[NSBundle mainBundle] pathForResource:[name stringByAppendingString:@"@2x"] ofType:@"gif"];
5157

52-
NSData* data = [NSData dataWithContentsOfFile:retinaPath];
58+
NSData *data = [NSData dataWithContentsOfFile:retinaPath];
5359

54-
if (data) {
60+
if (data)
61+
{
5562
return [UIImage animatedGIFWithData:data];
5663
}
5764

58-
NSString* path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"];
65+
NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"];
5966

6067
data = [NSData dataWithContentsOfFile:path];
6168

62-
if (data) {
69+
if (data)
70+
{
6371
return [UIImage animatedGIFWithData:data];
6472
}
6573

6674
return [UIImage imageNamed:name];
6775
}
68-
else {
69-
NSString* path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"];
76+
else
77+
{
78+
NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"];
7079

71-
NSData* data = [NSData dataWithContentsOfFile:path];
80+
NSData *data = [NSData dataWithContentsOfFile:path];
7281

73-
if (data) {
82+
if (data)
83+
{
7484
return [UIImage animatedGIFWithData:data];
7585
}
7686

7787
return [UIImage imageNamed:name];
7888
}
7989
}
8090

81-
-(UIImage*)animatedImageByScalingAndCroppingToSize:(CGSize)size {
82-
if (CGSizeEqualToSize(self.size, size) || CGSizeEqualToSize(size, CGSizeZero)) {
91+
- (UIImage *)animatedImageByScalingAndCroppingToSize:(CGSize)size
92+
{
93+
if (CGSizeEqualToSize(self.size, size) || CGSizeEqualToSize(size, CGSizeZero))
94+
{
8395
return self;
8496
}
8597

@@ -91,17 +103,22 @@ -(UIImage*)animatedImageByScalingAndCroppingToSize:(CGSize)size {
91103
CGFloat scaleFactor = (widthFactor > heightFactor) ? widthFactor :heightFactor;
92104
scaledSize.width = self.size.width * scaleFactor;
93105
scaledSize.height = self.size.height * scaleFactor;
94-
if (widthFactor > heightFactor) {
106+
107+
if (widthFactor > heightFactor)
108+
{
95109
thumbnailPoint.y = (size.height - scaledSize.height) * 0.5;
96-
} else if (widthFactor < heightFactor) {
110+
}
111+
else if (widthFactor < heightFactor)
112+
{
97113
thumbnailPoint.x = (size.width - scaledSize.width) * 0.5;
98114
}
99115

100-
NSMutableArray* scaledImages = [NSMutableArray array];
116+
NSMutableArray *scaledImages = [NSMutableArray array];
101117

102118
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
103119

104-
for (UIImage* image in self.images) {
120+
for (UIImage *image in self.images)
121+
{
105122
[image drawInRect:CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledSize.width, scaledSize.height)];
106123
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
107124

0 commit comments

Comments
 (0)