18
18
static CGSVGDocumentRef (*CGSVGDocumentRetain)(CGSVGDocumentRef);
19
19
static void (*CGSVGDocumentRelease)(CGSVGDocumentRef);
20
20
21
+ #if SD_UIKIT
22
+
21
23
@interface UIImage (PrivateSVGSupport)
22
24
23
25
- (instancetype )_initWithCGSVGDocument : (CGSVGDocumentRef)document ;
@@ -28,6 +30,8 @@ - (CGSVGDocumentRef)_CGSVGDocument;
28
30
29
31
@end
30
32
33
+ #endif
34
+
31
35
@implementation SDImageSVGCoder
32
36
33
37
+ (SDImageSVGCoder *)sharedCoder {
@@ -55,14 +59,18 @@ - (UIImage *)decodedImageWithData:(NSData *)data options:(SDImageCoderOptions *)
55
59
if (!data) {
56
60
return nil ;
57
61
}
58
-
62
+ # if SD_UIKIT
59
63
if ([self .class supportsVectorSVGImage ]) {
60
64
return [self createVectorSVGWithData: data options: options];
61
65
} else {
62
66
return [self createBitmapSVGWithData: data options: options];
63
67
}
68
+ #else
69
+ return [self createBitmapSVGWithData: data options: options];
70
+ #endif
64
71
}
65
72
73
+ #if SD_UIKIT
66
74
- (UIImage *)createVectorSVGWithData : (NSData *)data options : (SDImageCoderOptions *)options {
67
75
NSParameterAssert (data);
68
76
CGDataProviderRef provider = CGDataProviderCreateWithCFData ((__bridge CFDataRef)data);
@@ -78,6 +86,7 @@ - (UIImage *)createVectorSVGWithData:(NSData *)data options:(SDImageCoderOptions
78
86
79
87
return image;
80
88
}
89
+ #endif
81
90
82
91
- (UIImage *)createBitmapSVGWithData : (NSData *)data options : (SDImageCoderOptions *)options {
83
92
NSParameterAssert (data);
@@ -148,6 +157,9 @@ - (NSData *)encodedDataWithImage:(UIImage *)image format:(SDImageFormat)format o
148
157
#pragma mark - Helper
149
158
150
159
+ (BOOL )supportsVectorSVGImage {
160
+ #if SD_MAC
161
+ return NO ;
162
+ #else
151
163
static dispatch_once_t onceToken;
152
164
static BOOL supports;
153
165
dispatch_once (&onceToken, ^{
@@ -159,6 +171,7 @@ + (BOOL)supportsVectorSVGImage {
159
171
}
160
172
});
161
173
return supports;
174
+ #endif
162
175
}
163
176
164
177
+ (BOOL )isSVGFormatForData : (NSData *)data {
0 commit comments