@fendent/react-native-enriched 0.5.2-fork.3 → 0.5.2-fork.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
@interface UIImage (ImageExtension)
|
|
10
10
|
|
|
11
11
|
/*
|
|
12
|
-
UIImage *animation = [UIImage
|
|
12
|
+
UIImage *animation = [UIImage animatedImageWithData:theData];
|
|
13
13
|
|
|
14
14
|
I interpret `theData` as an animated image (GIF or WebP). I create an
|
|
15
15
|
animated `UIImage` using the source images and frame delays from the data.
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
contain frame 0 3/3 = 1 time, then frame 1 9/3 = 3 times, then frame 2
|
|
29
29
|
15/3 = 5 times. I set `animation.duration` to (3+9+15)/100 = 0.27 seconds.
|
|
30
30
|
*/
|
|
31
|
-
+ (UIImage *_Nullable)
|
|
32
|
-
(NSData *_Nonnull)theData;
|
|
31
|
+
+ (UIImage *_Nullable)animatedImageWithData:(NSData *_Nonnull)theData;
|
|
33
32
|
|
|
34
33
|
@end
|
|
@@ -120,8 +120,7 @@ static void releaseImages(const std::vector<CGImageRef> &images) {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
static UIImage *
|
|
124
|
-
animatedImageWithAnimatedGIFImageSource(CGImageSourceRef const source) {
|
|
123
|
+
static UIImage *animatedImageWithImageSource(CGImageSourceRef const source) {
|
|
125
124
|
size_t const count = CGImageSourceGetCount(source);
|
|
126
125
|
if (count == 0) {
|
|
127
126
|
return nil;
|
|
@@ -146,10 +145,10 @@ animatedImageWithAnimatedGIFImageSource(CGImageSourceRef const source) {
|
|
|
146
145
|
return animation;
|
|
147
146
|
}
|
|
148
147
|
|
|
149
|
-
static UIImage *
|
|
150
|
-
|
|
148
|
+
static UIImage *
|
|
149
|
+
animatedImageWithReleasingSource(CGImageSourceRef CF_RELEASES_ARGUMENT source) {
|
|
151
150
|
if (source) {
|
|
152
|
-
UIImage *const image =
|
|
151
|
+
UIImage *const image = animatedImageWithImageSource(source);
|
|
153
152
|
CFRelease(source);
|
|
154
153
|
return image;
|
|
155
154
|
} else {
|
|
@@ -157,8 +156,8 @@ static UIImage *animatedImageWithAnimatedGIFReleasingImageSource(
|
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
158
|
|
|
160
|
-
+ (UIImage *)
|
|
161
|
-
return
|
|
159
|
+
+ (UIImage *)animatedImageWithData:(NSData *)data {
|
|
160
|
+
return animatedImageWithReleasingSource(
|
|
162
161
|
CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL));
|
|
163
162
|
}
|
|
164
163
|
|
|
@@ -96,10 +96,10 @@ static NSCache<NSString *, UIImage *> *ImageAttachmentCache(void) {
|
|
|
96
96
|
NSData *bytes = [NSData dataWithContentsOfURL:url];
|
|
97
97
|
|
|
98
98
|
// We pass all image data (including static formats like PNG or JPEG)
|
|
99
|
-
// through the
|
|
100
|
-
// a single-frame UIImage for static formats and an animated
|
|
101
|
-
// GIFs.
|
|
102
|
-
UIImage *img = bytes ? [UIImage
|
|
99
|
+
// through the animated image parser. It safely acts as a universal parser,
|
|
100
|
+
// returning a single-frame UIImage for static formats and an animated
|
|
101
|
+
// UIImage for GIFs and WebPs.
|
|
102
|
+
UIImage *img = bytes ? [UIImage animatedImageWithData:bytes]
|
|
103
103
|
: [UIImage systemImageNamed:@"photo"];
|
|
104
104
|
|
|
105
105
|
dispatch_async(dispatch_get_main_queue(), ^{
|