LuxChat  2.0
Instant messenger for iOS
JTSAnimatedGIFUtility.h
1 //
2 // JTSAnimatedGIFUtility.h
3 // JTSImageVC
4 //
5 // Created by Jared Sinclair on 3/29/14.
6 // Copyright (c) 2014 Nice Boy, LLC. All rights reserved.
7 //
8 
9 @import UIKit;
10 
11 @interface JTSAnimatedGIFUtility : NSObject
12 
13 + (BOOL)imageURLIsAGIF:(NSString *)imageURL;
14 
15 /*
16  UIImage *animation = [UIImage animatedImageWithAnimatedGIFData:theData];
17 
18  I interpret `theData` as a GIF. I create an animated `UIImage` using the source images in the GIF.
19 
20  The GIF stores a separate duration for each frame, in units of centiseconds (hundredths of a second). However, a `UIImage` only has a single, total `duration` property, which is a floating-point number.
21 
22  To handle this mismatch, I add each source image (from the GIF) to `animation` a varying number of times to match the ratios between the frame durations in the GIF.
23 
24  For example, suppose the GIF contains three frames. Frame 0 has duration 3. Frame 1 has duration 9. Frame 2 has duration 15. I divide each duration by the greatest common denominator of all the durations, which is 3, and add each frame the resulting number of times. Thus `animation` will contain frame 0 3/3 = 1 time, then frame 1 9/3 = 3 times, then frame 2 15/3 = 5 times. I set `animation.duration` to (3+9+15)/100 = 0.27 seconds.
25  */
26 + (UIImage *)animatedImageWithAnimatedGIFData:(NSData *)theData;
27 
28 /*
29  UIImage *image = [UIImage animatedImageWithAnimatedGIFURL:theURL];
30 
31  I interpret the contents of `theURL` as a GIF. I create an animated `UIImage` using the source images in the GIF.
32 
33  I operate exactly like `+[UIImage animatedImageWithAnimatedGIFData:]`, except that I read the data from `theURL`. If `theURL` is not a `file:` URL, you probably want to call me on a background thread or GCD queue to avoid blocking the main thread.
34  */
35 + (UIImage *)animatedImageWithAnimatedGIFURL:(NSURL *)theURL;
36 
37 @end
38 
39 
Definition: JTSAnimatedGIFUtility.h:11