UIImage+MultiFormat.m
669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// UIImage+MultiFormat.m
// SDWebImage
//
// Created by Olivier Poitrey on 07/06/13.
// Copyright (c) 2013 Dailymotion. All rights reserved.
//
#import "UIImage+MultiFormat.h"
#import "UIImage+GIF.h"
#import "UIImage+WebP.h"
@implementation UIImage (MultiFormat)
+ (UIImage *)sd_imageWithData:(NSData *)data
{
UIImage *image;
if ([data sd_isGIF])
{
image = [UIImage sd_animatedGIFWithData:data];
}
else
{
image = [[UIImage alloc] initWithData:data];
}
#ifdef SD_WEBP
if (!image) // TODO: detect webp signature
{
image = [UIImage sd_imageWithWebPData:data];
}
#endif
return image;
}
@end