21 Commits

Author SHA1 Message Date
ibireme 684394255f bumping the version to 0.9.2 2015-12-01 02:01:45 +08:00
ibireme 9122a8ccd9 improved compatibility 2015-11-25 10:00:37 +08:00
ibireme 19ef4290a9 updated readme 2015-11-15 21:42:43 +08:00
ibireme 970838c6c1 updated readme, add niconiconi~ 2015-11-13 11:50:37 +08:00
ibireme 77f4318300 change image scale's default value 2015-11-10 11:23:09 +08:00
ibireme 0f875c6de9 updated readme 2015-11-07 14:36:36 +08:00
ibireme 0f95266e96 updated readme 2015-11-05 21:10:16 +08:00
ibireme bdc088abf1 Updated Travis CI Config 2015-11-04 14:50:06 +08:00
ibireme 2dd7540f62 Add Travis CI 2015-11-04 13:51:33 +08:00
ibireme 91f04aa02b update readme 2015-11-02 02:19:46 +08:00
ibireme 627be90f71 update readme 2015-10-30 21:31:11 +08:00
ibireme a4c5009703 update WebP.framework to version 0.4.4 2015-10-30 17:53:13 +08:00
ibireme c98a66e8e3 update header and label 2015-10-30 11:54:25 +08:00
ibireme d48e61aba2 update readme 2015-10-29 18:05:17 +08:00
ibireme 69c8028b9a update readme 2015-10-29 13:54:30 +08:00
ibireme 8aa0225ef0 disable demo project "png compress setting" 2015-10-27 17:54:24 +08:00
ibireme 11a23bf176 update readme 2015-10-26 11:22:18 +08:00
ibireme 8406084d12 update readme 2015-10-26 11:04:11 +08:00
ibireme 587db11db9 update readme 2015-10-25 11:46:23 +08:00
ibireme 115a5f9911 update readme 2015-10-25 11:11:53 +08:00
ibireme 3e8f8a0dda version 0.9.0 2015-10-25 00:00:45 +08:00
12 changed files with 258 additions and 28 deletions
+7
View File
@@ -0,0 +1,7 @@
language: objective-c
osx_image: xcode7
xcode_project: Framework/YYImage.xcodeproj
xcode_scheme: YYImage
script:
- xctool -project Framework/YYImage.xcodeproj -scheme YYImage build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
@@ -434,6 +434,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMPRESS_PNG_FILES = NO;
FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../Vendor\"";
INFOPLIST_FILE = YYImageDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@@ -448,6 +449,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMPRESS_PNG_FILES = NO;
FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../Vendor\"";
INFOPLIST_FILE = YYImageDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.9.0</string>
<string>0.9.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
+226 -21
View File
@@ -1,12 +1,14 @@
YYImage
YYImage <a href="#中文介绍">中文介绍</a>
==============
[![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/ibireme/YYImage/master/LICENSE)&nbsp;
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)&nbsp;
[![Cocoapods](http://img.shields.io/cocoapods/v/YYImage.svg?style=flat)](http://cocoapods.org/?q= YYImage)&nbsp;
[![Cocoapods](http://img.shields.io/cocoapods/p/YYImage.svg?style=flat)](http://cocoapods.org/?q= YYImage)&nbsp;
[![Support](https://img.shields.io/badge/support-iOS%206%2B%20-blue.svg?style=flat)](https://www.apple.com/nl/ios/)
[![CocoaPods](http://img.shields.io/cocoapods/v/YYImage.svg?style=flat)](http://cocoapods.org/?q= YYImage)&nbsp;
[![CocoaPods](http://img.shields.io/cocoapods/p/YYImage.svg?style=flat)](http://cocoapods.org/?q= YYImage)&nbsp;
[![Support](https://img.shields.io/badge/support-iOS%206%2B%20-blue.svg?style=flat)](https://www.apple.com/nl/ios/)&nbsp;
[![Build Status](https://travis-ci.org/ibireme/YYImage.svg?branch=master)](https://travis-ci.org/ibireme/YYImage)
Image framework for iOS to display/encode/decode animated WebP, APNG, GIF, and more.
Image framework for iOS to display/encode/decode animated WebP, APNG, GIF, and more.<br/>
(It's a component of [YYKit](https://github.com/ibireme/YYKit))
![niconiconi~](https://raw.github.com/ibireme/YYImage/master/Demo/YYImageDemo/niconiconi@2x.gif
)
@@ -14,19 +16,21 @@ Image framework for iOS to display/encode/decode animated WebP, APNG, GIF, and m
Features
==============
- Display/encode/decode animated image with these types:<br/>&nbsp;&nbsp;&nbsp;&nbsp;WebP, APNG, GIF.
- Display/encode decode still image with these types:<br/>&nbsp;&nbsp;&nbsp;&nbsp;WebP, PNG, GIF, JPEG, JP2, TIFF, BMP, ICO, ICNS.
- Display/encode/decode still image with these types:<br/>&nbsp;&nbsp;&nbsp;&nbsp;WebP, PNG, GIF, JPEG, JP2, TIFF, BMP, ICO, ICNS.
- Baseline/progressive/interlaced image decode with these types:<br/>&nbsp;&nbsp;&nbsp;&nbsp;PNG, GIF, JPEG, BMP.
- Display frame based image animation and sprire sheet animation.
- Display frame based image animation and sprite sheet animation.
- Fully compatible with UIImage and UIImageView class.
- Extendable protocol for custom image animation.
- Dynamic frame buffer for lower memory usage.
- Dynamic memory buffer for lower memory usage.
- Fully documented.
Usage
==============
###Display animated image
// File: ani@2x.webp
UIImage *image = [YYImage imageNamed:@"ani.webp"];
// File: ani@3x.gif
UIImage *image = [YYImage imageNamed:@"ani.gif"];
UIImageView *imageView = [[YYAnimatedImageView alloc] initWithImage:image];
[self.view addSubView:imageView];
@@ -75,6 +79,8 @@ Usage
[imageView startAnimating];
// set frame index:
imageView.currentAnimatedImageIndex = 12;
// get current status
image.currentIsPlayingAnimation;
###Image decoder
@@ -114,10 +120,17 @@ Usage
[webpEncoder addImage:image2 duration:0.2];
NSData webpData = [webpEncoder encode];
###Image type detection
// Get image type from image data
YYImageType type = YYImageDetectType(data);
if (type == YYImageTypePNG) ...
Installation
==============
### Cocoapods
### CocoaPods
1. Update cocoapods to the latest version.
1. Add `pod "YYImage"` to your Podfile.
@@ -128,7 +141,7 @@ Installation
### Carthage
1. Add `github "ibireme/YYImage"` to your Cartfile.
2. Run `carthage update` and add the framework to your project.
2. Run `carthage update --platform ios` and add the framework to your project.
3. Import \<YYImage/YYImage.h\>
4. Notice: carthage framework doesn't include webp component, if you want to support webp, use cocoapods or install manually.
@@ -137,22 +150,214 @@ Installation
1. Download all the files in the YYImage subdirectory.
2. Add the source files to your Xcode project.
3. Link with required frameworks:
* UIKit.framework
* CoreFoundation.framework
* QuartzCore.framework
* AssetsLibrary.framework
* ImageIO.framework
* Accelerate.framework
* MobileCoreServices.framework
* UIKit
* CoreFoundation
* QuartzCore
* AssetsLibrary
* ImageIO
* Accelerate
* MobileCoreServices
* libz
4. Add `Vendor/WebP.framework`(static library) to your Xcode project if you want to support webp.
5. Import `YYImage.h`.
About
Documentation
==============
This library supports iOS 6.0 and later.
Full API documentation is available on [CocoaDocs](http://cocoadocs.org/docsets/YYImage/).<br/>
You can also install documentation locally using [appledoc](https://github.com/tomaz/appledoc).
Requirements
==============
This library requires a deployment target of iOS 6.0 or greater.
License
==============
YYImage is provided under the MIT license. See LICENSE file for details.
<br/><br/>
---
中文介绍
==============
YYImage: 功能强大的 iOS 图像框架。<br/>
(该项目是 [YYKit](https://github.com/ibireme/YYKit) 组件之一)
![niconiconi~](https://raw.github.com/ibireme/YYImage/master/Demo/YYImageDemo/niconiconi@2x.gif
)
特性
==============
- 支持以下类型动画图像的播放/编码/解码:<br/>
&nbsp;&nbsp;&nbsp;&nbsp;WebP, APNG, GIF。
- 支持以下类型静态图像的显示/编码/解码:<br>
&nbsp;&nbsp;&nbsp;&nbsp;WebP, PNG, GIF, JPEG, JP2, TIFF, BMP, ICO, ICNS。
- 支持以下类型图片的渐进式/逐行扫描/隔行扫描解码:<br/>
&nbsp;&nbsp;&nbsp;&nbsp;PNG, GIF, JPEG, BMP。
- 支持多张图片构成的帧动画播放,支持单张图片的 sprite sheet 动画。
- 完全兼容 UIImage 和 UIImageView,使用方便。
- 保留可扩展的接口,以支持自定义动画。
- 高效的动态内存缓存管理,以保证高性能低内存的动画播放。
- 每个类和方法都有完善的文档注释。
用法
==============
###显示动画类型的图片
// 文件: ani@3x.gif
UIImage *image = [YYImage imageNamed:@"ani.gif"];
UIImageView *imageView = [[YYAnimatedImageView alloc] initWithImage:image];
[self.view addSubView:imageView];
###播放帧动画
// 文件: frame1.png, frame2.png, frame3.png
NSArray *paths = @[@"/ani/frame1.png", @"/ani/frame2.png", @"/ani/frame3.png"];
NSArray *times = @[@0.1, @0.2, @0.1];
UIImage *image = [YYFrameImage alloc] initWithImagePaths:paths frameDurations:times repeats:YES];
UIImageView *imageView = [YYAnimatedImageView alloc] initWithImage:image];
[self.view addSubView:imageView];
###播放 sprite sheet 动画
// 8 * 12 sprites in a single sheet image
UIImage *spriteSheet = [UIImage imageNamed:@"sprite-sheet"];
NSMutableArray *contentRects = [NSMutableArray new];
NSMutableArray *durations = [NSMutableArray new];
for (int j = 0; j < 12; j++) {
for (int i = 0; i < 8; i++) {
CGRect rect;
rect.size = CGSizeMake(img.size.width / 8, img.size.height / 12);
rect.origin.x = img.size.width / 8 * i;
rect.origin.y = img.size.height / 12 * j;
[contentRects addObject:[NSValue valueWithCGRect:rect]];
[durations addObject:@(1 / 60.0)];
}
}
YYSpriteSheetImage *sprite;
sprite = [[YYSpriteSheetImage alloc] initWithSpriteSheetImage:img
contentRects:contentRects
frameDurations:durations
loopCount:0];
YYAnimatedImageView *imageView = [YYAnimatedImageView new];
imageView.size = CGSizeMake(img.size.width / 8, img.size.height / 12);
imageView.image = sprite;
[self.view addSubView:imageView];
###动画播放控制
YYAnimatedImageView *imageView = ...;
// 暂停:
[imageView stopAnimating];
// 播放:
[imageView startAnimating];
// 设置播放进度:
imageView.currentAnimatedImageIndex = 12;
// 获取播放状态:
image.currentIsPlayingAnimation;
//上面两个属性都支持 KVO。
###图片解码
// 解码单帧图片:
NSData *data = [NSData dataWithContentOfFile:@"/tmp/image.webp"];
YYImageDecoder *decoder = [YYImageDecoder decoderWithData:data scale:2.0];
UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image;
// 渐进式图片解码 (可用于图片下载显示):
NSMutableData *data = [NSMutableData new];
YYImageDecoder *decoder = [[YYImageDecoder alloc] initWithScale:2.0];
while(newDataArrived) {
[data appendData:newData];
[decoder updateData:data final:NO];
if (decoder.frameCount > 0) {
UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image;
// progressive display...
}
}
[decoder updateData:data final:YES];
UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image;
// final display...
###图片编码
// 编码静态图 (支持各种常见图片格式):
YYImageEncoder *jpegEncoder = [[YYImageEncoder alloc] initWithType:YYImageTypeJPEG];
jpegEncoder.quality = 0.9;
[jpegEncoder addImage:image duration:0];
NSData jpegData = [jpegEncoder encode];
// 编码动态图 (支持 GIF/APNG/WebP):
YYImageEncoder *webpEncoder = [[YYImageEncoder alloc] initWithType:YYImageTypeWebP];
webpEncoder.loopCount = 5;
[webpEncoder addImage:image0 duration:0.1];
[webpEncoder addImage:image1 duration:0.15];
[webpEncoder addImage:image2 duration:0.2];
NSData webpData = [webpEncoder encode];
###图片类型探测
// 获取图片类型
YYImageType type = YYImageDetectType(data);
if (type == YYImageTypePNG) ...
安装
==============
### CocoaPods
1. 将 cocoapods 更新至最新版本.
1. 在 Podfile 中添加 `pod "YYImage"`
2. 执行 `pod install``pod update`
3. 导入 \<YYImage/YYImage.h\>。
### Carthage
1. 在 Cartfile 中添加 `github "ibireme/YYImage"`
2. 执行 `carthage update --platform ios` 并将生成的 framework 添加到你的工程。
3. 导入 \<YYImage/YYImage.h\>。
4. 注意: carthage framework 并没有包含 webp 组件。如果你需要支持 webp,可以用 CocoaPods 安装,或者手动安装。
### 手动安装
1. 下载 YYImage 文件夹内的所有内容。
2. 将 YYModel 内的源文件添加(拖放)到你的工程。
3. 链接以下 frameworks:
* UIKit
* CoreFoundation
* QuartzCore
* AssetsLibrary
* ImageIO
* Accelerate
* MobileCoreServices
* libz
4. 如果你需要支持 webp,可以将 `Vendor/WebP.framework`(静态库) 加入你的工程。
5. 导入 `YYImage.h`
文档
==============
你可以在 [CocoaDocs](http://cocoadocs.org/docsets/YYImage/) 查看在线 API 文档,也可以用 [appledoc](https://github.com/tomaz/appledoc) 本地生成文档。
关于
==============
该项目最低支持 iOS 6.0。
许可证
==============
YYModel 使用 MIT 许可证,详情见 LICENSE 文件。
相关链接
==============
[移动端图片格式调研](http://blog.ibireme.com/2015/11/02/mobile_image_benchmark/)<br/>
[iOS 处理图片的一些小 Tip](http://blog.ibireme.com/2015/11/02/ios_image_tips/)
+4 -4
View File
@@ -72,13 +72,13 @@
#define PACKAGE "libwebp"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "http://code.google.com/p/webp/issues"
#define PACKAGE_BUGREPORT "https://bugs.chromium.org/p/webp"
/* Define to the full name of this package. */
#define PACKAGE_NAME "libwebp"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libwebp 0.4.3"
#define PACKAGE_STRING "libwebp 0.4.4"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libwebp"
@@ -87,7 +87,7 @@
#define PACKAGE_URL "http://developers.google.com/speed/webp"
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.4.3"
#define PACKAGE_VERSION "0.4.4"
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
@@ -97,7 +97,7 @@
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "0.4.3"
#define VERSION "0.4.4"
/* Enable experimental code */
/* #undef WEBP_EXPERIMENTAL_FEATURES */
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'YYImage'
s.summary = 'Image framework for iOS to display/encode/decode animated WebP, APNG, GIF, and more.'
s.version = '0.8.9'
s.version = '0.9.2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.authors = { 'ibireme' => 'ibireme@gmail.com' }
s.social_media_url = 'http://blog.ibireme.com'
+7
View File
@@ -197,6 +197,13 @@ typedef NS_ENUM(NSUInteger, YYAnimagedImageType) {
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
_runloopMode = NSRunLoopCommonModes;
_autoPlayAnimatedImage = YES;
return self;
}
- (instancetype)initWithImage:(UIImage *)image {
self = [super init];
_runloopMode = NSRunLoopCommonModes;
+2
View File
@@ -13,6 +13,8 @@
#if __has_include(<YYImage/YYImage.h>)
#import <YYImage/YYAnimatedImageView.h>
#elif __has_include(<YYWebImage/YYImage.h>)
#import <YYWebImage/YYAnimatedImageView.h>
#else
#import "YYAnimatedImageView.h"
#endif
+5
View File
@@ -18,6 +18,11 @@ FOUNDATION_EXPORT const unsigned char YYImageVersionString[];
#import <YYImage/YYSpriteSheetImage.h>
#import <YYImage/YYImageCoder.h>
#import <YYImage/YYAnimatedImageView.h>
#elif __has_include(<YYWebImage/YYImage.h>)
#import <YYWebImage/YYFrameImage.h>
#import <YYWebImage/YYSpriteSheetImage.h>
#import <YYWebImage/YYImageCoder.h>
#import <YYWebImage/YYAnimatedImageView.h>
#else
#import "YYFrameImage.h"
#import "YYSpriteSheetImage.h"
+1 -1
View File
@@ -144,7 +144,7 @@ static CGFloat _NSStringPathScale(NSString *string) {
- (instancetype)initWithData:(NSData *)data scale:(CGFloat)scale {
if (data.length == 0) return nil;
if (scale <= 0) scale = 1;
if (scale <= 0) scale = [UIScreen mainScreen].scale;
_preloadedLock = OS_SPINLOCK_INIT;
@autoreleasepool {
YYImageDecoder *decoder = [YYImageDecoder decoderWithData:data scale:scale];
+2
View File
@@ -13,6 +13,8 @@
#if __has_include(<YYImage/YYImage.h>)
#import <YYImage/YYAnimatedImageView.h>
#elif __has_include(<YYWebImage/YYImage.h>)
#import <YYWebImage/YYAnimatedImageView.h>
#else
#import "YYAnimatedImageView.h"
#endif