让FLAnimatedImage支持SDWebImage的修改 -- Flipboard开源高性能动画GIF引擎(源码)
来源:互联网 发布:阿里云搭建网站多久 编辑:程序博客网 时间:2024/05/21 08:49
可同时播放多个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 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)
Installation & Usage
FLAnimatedImage is a well encapsulated drop-in component. Simply replace your UIImageView
instances with instances of FLAnimatedImageView
to get animated GIF support. There is no central cache or state to manage.
To get started, simply copy the two classes FLAnimatedImage.h/.m
and FLAnimatedImageView.h/.m
into 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 WebP
- Integration into network libraries and image caches
- Investigate whether
FLAnimatedImage
should become aUIImage
subclass UIScrollView
support- 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
使用方法:
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引擎(源码)
- 让FLAnimatedImage支持SDWebImage的修改 -- Flipboard开源高性能动画GIF引擎(源码)
- Gif 渲染引擎 FLAnimatedImage
- 支持GIF动画的ImageView
- 支持GIF动画的ImageView
- android 对GIF动画格式的支持
- Delphi增加对动画Gif的支持
- ios开发-支持gif动画的UIImageView
- 一个组合的Loading动画(源码+GIF)
- SDWebImage 加载显示 GIF 与性能问题
- SDWebImage源码解读 之UIImage+GIF
- FLAnimatedImage -ios gif图片加载框架介绍
- C# 让RichTextBox支持GIF
- 让Duilib完美支持gif
- 让你的PHP同时支持GIF、png、JPEG
- 让你的PHP同时支持GIF、png、JPEG
- SDWebImage的源码解读
- 【小技巧】如何修改 Lua 5.1 的引擎,让Lua支持中文变量名、混合变量名
- JAVA进阶:VO(DTO)与PO(DAO)之间的转换 .
- Boost::Thread使用示例
- Yii:CHtml::ajaxLink方法在URL format为path情况下的多参数传递示例
- Android animation startOffset broken or buggy?
- PCB问题小结(1)
- 让FLAnimatedImage支持SDWebImage的修改 -- Flipboard开源高性能动画GIF引擎(源码)
- java synchronized详解
- Linux CentOS 设置静态 IP Adr
- Web服务器的功能
- “应用程序配置不正确,程序无法启动”的解决方法资料收集
- PAT1006:换个格式输出整数
- 【C++11】30分钟了解C++11新特性
- Content-Disposition的作用
- 云技术在安防行业中的应用分析