让FLAnimatedImage支持SDWebImage的修改 -- Flipboard开源高性能动画GIF引擎(源码)
2016-02-09 01:15
676 查看
大家都已经知道,FLAnimatedImage是一个适用于iOS的高性能动画GIF引擎:
可同时播放多个GIF,回放速度可以和桌面浏览器匹敌,在压力内存下表现良好。FLAnimatedImage经过了良好的测试,实现了Flipboard中的GIF。
详细内容可参看:http://engineering.flipboard.com/2014/05/animated-gif/
源代码地址:https://github.com/Flipboard/FLAnimatedImage
FLAnimatedImage is a performant animated GIF engine for iOS:
Plays multiple GIFs simultaneously with a playback speed comparable to desktop browsers
Honors variable frame delays
Behaves gracefully under memory pressure
Eliminates delays or blocking during the first playback loop
Interprets the frame delays of fast GIFs the same way modern browsers do
It's a well-tested component that powers all GIFs in Flipboard. To understand its behavior it comes with
an interactive demo:
Apps that don't support animated GIFs yet
Apps that already support animated GIFs but want a higher performance solution
People who want to tinker with the code (the corresponding blog post is a great place to start; also
see the "To Do" section below)
FLAnimatedImage is a well encapsulated drop-in component. Simply replace your
with instances of
There is no central cache or state to manage.
To get started, simply copy the two classes
your Xcode project or add via CocoaPods by adding this to your Podfile:
In your code,
It's flexible to integrate in your custom image loading stack and backwards compatible to iOS 5.
It uses ARC and the Apple frameworks
and
Since FLAnimatedImage is licensed under MIT it's compatible with the terms of using it for any app on the App Store.
Support other animated image formats such as APNG or WebP
Integration into network libraries and image caches
Investigate whether
Smarter buffering
Bring demo app to iOS 5 and iPhone
This has shipped to many people and since mid 2013 we made many tweaks. But it's a version 1.0, so please come with your questions, issues and pull requests.
Feel free to reach out to @RaphaelSchaad for further help.
大家在运行demo时会卡顿很久,现在引入SDWebImage的cache机制,制作了一个category
此修改只适用于测试,不建议用在app中
源码地址:https://github.com/iunion/FLAnimatedImage
使用方法:
[objc] view
plain copy
print?
NSURL *url2 = [NSURL URLWithString:@"http://raphaelschaad.com/static/nyan.gif"];
//NSData *data2 = [NSData dataWithContentsOfURL:url2];
//FLAnimatedImage *animatedImage2 = [[FLAnimatedImage alloc] initWithAnimatedGIFData:data2];
//self.imageView2.animatedImage = animatedImage2;
__block RootViewController *aself = self;
[self.imageView2 setImageWithURL:url2 animatedsuccess:^(UIImage *image, FLAnimatedImage *animatedImage, BOOL cached) {
aself.imageView2.debug_delegate = aself.debugView2;
animatedImage.debug_delegate = aself.debugView2;
aself.debugView2.imageView = aself.imageView2;
aself.debugView2.image = animatedImage;
aself.imageView2.userInteractionEnabled = YES;
} failure:^(NSError *error) {
}]; 让FLAnimatedImage支持SDWebImage的修改
-- Flipboard开源高性能动画GIF引擎(源码)
可同时播放多个GIF,回放速度可以和桌面浏览器匹敌,在压力内存下表现良好。FLAnimatedImage经过了良好的测试,实现了Flipboard中的GIF。
详细内容可参看:http://engineering.flipboard.com/2014/05/animated-gif/
源代码地址:https://github.com/Flipboard/FLAnimatedImage
FLAnimatedImage is a performant animated GIF engine for iOS:
Plays multiple GIFs simultaneously with a playback speed comparable to desktop browsers
Honors variable frame delays
Behaves gracefully under memory pressure
Eliminates delays or blocking during the first playback loop
Interprets the frame delays of fast GIFs the same way modern browsers do
It's a well-tested component that powers all GIFs in Flipboard. To understand its behavior it comes with
an interactive demo:
Who
is this for?
Apps that don't support animated GIFs yetApps that already support animated GIFs but want a higher performance solution
People who want to tinker with the code (the corresponding blog post is a great place to start; also
see the "To Do" section below)
Installation
& Usage
FLAnimatedImage is a well encapsulated drop-in component. Simply replace your UIImageViewinstances
with instances of
FLAnimatedImageViewto get animated GIF support.
There is no central cache or state to manage.
To get started, simply copy the two classes
FLAnimatedImage.h/.mand
FLAnimatedImageView.h/.minto
your Xcode project or add via CocoaPods by adding this to your Podfile:
pod 'FLAnimatedImage', '~> 1.0'
In your code,
#import "FLAnimatedImage.h"and
#import "FLAnimatedImageView.h"and then create an image from an animated GIF and setup the image view to display it:
FLAnimatedImage *image = [[FLAnimatedImage alloc] initWithAnimatedGIFData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://raphaelschaad.com/static/nyan.gif"]]]; FLAnimatedImageView *imageView = [[FLAnimatedImageView alloc] init]; imageView.animatedImage = image; imageView.frame = CGRectMake(0.0, 0.0, 100.0, 100.0); [self.view addSubview:imageView];
It's flexible to integrate in your custom image loading stack and backwards compatible to iOS 5.
It uses ARC and the Apple frameworks
QuartzCore,
ImageIO,
MobileCoreServices,
and
CoreGraphics.
Since FLAnimatedImage is licensed under MIT it's compatible with the terms of using it for any app on the App Store.
To
Do
Support other animated image formats such as APNG or WebPIntegration into network libraries and image caches
Investigate whether
FLAnimatedImageshould become a
UIImagesubclass
UIScrollViewsupport
Smarter buffering
Bring demo app to iOS 5 and iPhone
This has shipped to many people and since mid 2013 we made many tweaks. But it's a version 1.0, so please come with your questions, issues and pull requests.
Feel free to reach out to @RaphaelSchaad for further help.
大家在运行demo时会卡顿很久,现在引入SDWebImage的cache机制,制作了一个category
此修改只适用于测试,不建议用在app中
源码地址:https://github.com/iunion/FLAnimatedImage
使用方法:
[objc] view
plain copy
print?
NSURL *url2 = [NSURL URLWithString:@"http://raphaelschaad.com/static/nyan.gif"];
//NSData *data2 = [NSData dataWithContentsOfURL:url2];
//FLAnimatedImage *animatedImage2 = [[FLAnimatedImage alloc] initWithAnimatedGIFData:data2];
//self.imageView2.animatedImage = animatedImage2;
__block RootViewController *aself = self;
[self.imageView2 setImageWithURL:url2 animatedsuccess:^(UIImage *image, FLAnimatedImage *animatedImage, BOOL cached) {
aself.imageView2.debug_delegate = aself.debugView2;
animatedImage.debug_delegate = aself.debugView2;
aself.debugView2.imageView = aself.imageView2;
aself.debugView2.image = animatedImage;
aself.imageView2.userInteractionEnabled = YES;
} failure:^(NSError *error) {
}]; 让FLAnimatedImage支持SDWebImage的修改
-- Flipboard开源高性能动画GIF引擎(源码)
相关文章推荐
- Accessibility辅助功能的使用
- 内存泄漏检测
- 《机器学习实战》--KNN
- 1000: 简单的a+b
- 回顾工作,迎接2016
- 15. 3Sum
- java开发webservice的几种方式
- 集训队专题(4)1002 LOOPS
- NodeJs编写小爬虫
- 关于学习C语言
- meta
- 详解函数声明VS函数表达式
- HDU 1166 敌兵布阵【简单典型的线段树问题】
- mongoose 文档(五) Validation
- JAVA 中Math.ceil()、Math.floor()和Math.round()的区别
- JacksonWant ——iOS系统学习笔记(二)
- hdu 3938 Portal
- 【Android开发小记--18】SharedPreferences 以及 PreferenceActivity
- Centos 6.3虚拟机及VMware tools的安装过程
- 平凡的一天