Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0deeafcf9d | |||
| dfe43e3e2b | |||
| d099161c69 | |||
| d0b3a1a252 | |||
| a157270270 | |||
| b659f9055d | |||
| eb13210dc3 | |||
| a62a9cdd48 | |||
| 8bec20644a | |||
| 84501d3495 | |||
| 66f20c481f | |||
| bd71dcac5d | |||
| f42422b919 | |||
| a8e5fc490e | |||
| 79e4918851 | |||
| e29bc97813 | |||
| 66e6dad4fe | |||
| e6fa4e47fa | |||
| 8adb9893ee | |||
| e2051d8e9e | |||
| 8e20c717a0 |
@@ -442,6 +442,7 @@
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.ibireme.YYImageDemo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
STRIP_PNG_TEXT = NO;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -457,6 +458,7 @@
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.ibireme.YYImageDemo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
STRIP_PNG_TEXT = NO;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<string>1.0.3</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -19,9 +19,9 @@ Features
|
||||
- Display/encode/decode still image with these types:<br/> WebP, PNG, GIF, JPEG, JP2, TIFF, BMP, ICO, ICNS.
|
||||
- Baseline/progressive/interlaced image decode with these types:<br/> PNG, GIF, JPEG, BMP.
|
||||
- Display frame based image animation and sprite sheet animation.
|
||||
- Dynamic memory buffer for lower memory usage.
|
||||
- Fully compatible with UIImage and UIImageView class.
|
||||
- Extendable protocol for custom image animation.
|
||||
- Dynamic memory buffer for lower memory usage.
|
||||
- Fully documented.
|
||||
|
||||
Usage
|
||||
@@ -85,7 +85,7 @@ Usage
|
||||
###Image decoder
|
||||
|
||||
// Decode single frame:
|
||||
NSData *data = [NSData dataWithContentOfFile:@"/tmp/image.webp"];
|
||||
NSData *data = [NSData dataWithContentsOfFile:@"/tmp/image.webp"];
|
||||
YYImageDecoder *decoder = [YYImageDecoder decoderWithData:data scale:2.0];
|
||||
UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image;
|
||||
|
||||
@@ -161,6 +161,15 @@ Installation
|
||||
4. Import `YYImage.h`.
|
||||
5. Notice: if you want to support WebP format, you may add `Vendor/WebP.framework`(static library) to your Xcode project.
|
||||
|
||||
FAQ
|
||||
==============
|
||||
_Q: Why I can't display WebP image?_
|
||||
|
||||
A: Make sure you added the `WebP.framework` in your project. You may call `YYImageWebPAvailable()` to check whether the WebP subspec is installed correctly.
|
||||
|
||||
_Q: Why I can't play APNG animation?_
|
||||
|
||||
A: You should disable the `Compress PNG Files` and `Remove Text Metadata From PNG Files` in your project's build settings. Or you can rename your APNG file's extension name with `apng`.
|
||||
|
||||
Documentation
|
||||
==============
|
||||
@@ -168,6 +177,7 @@ Full API documentation is available on [CocoaDocs](http://cocoadocs.org/docsets/
|
||||
You can also install documentation locally using [appledoc](https://github.com/tomaz/appledoc).
|
||||
|
||||
|
||||
|
||||
Requirements
|
||||
==============
|
||||
This library requires `iOS 6.0+` and `Xcode 7.0+`.
|
||||
@@ -197,9 +207,9 @@ YYImage: 功能强大的 iOS 图像框架。<br/>
|
||||
- 支持以下类型图片的渐进式/逐行扫描/隔行扫描解码:<br/>
|
||||
PNG, GIF, JPEG, BMP。
|
||||
- 支持多张图片构成的帧动画播放,支持单张图片的 sprite sheet 动画。
|
||||
- 高效的动态内存缓存管理,以保证高性能低内存的动画播放。
|
||||
- 完全兼容 UIImage 和 UIImageView,使用方便。
|
||||
- 保留可扩展的接口,以支持自定义动画。
|
||||
- 高效的动态内存缓存管理,以保证高性能低内存的动画播放。
|
||||
- 每个类和方法都有完善的文档注释。
|
||||
|
||||
|
||||
@@ -265,7 +275,7 @@ YYImage: 功能强大的 iOS 图像框架。<br/>
|
||||
###图片解码
|
||||
|
||||
// 解码单帧图片:
|
||||
NSData *data = [NSData dataWithContentOfFile:@"/tmp/image.webp"];
|
||||
NSData *data = [NSData dataWithContentsOfFile:@"/tmp/image.webp"];
|
||||
YYImageDecoder *decoder = [YYImageDecoder decoderWithData:data scale:2.0];
|
||||
UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image;
|
||||
|
||||
@@ -341,6 +351,16 @@ YYImage: 功能强大的 iOS 图像框架。<br/>
|
||||
4. 导入 `YYImage.h`。
|
||||
5. 注意:如果你需要支持 WebP,可以将 `Vendor/WebP.framework`(静态库) 加入你的工程。
|
||||
|
||||
常见问题
|
||||
==============
|
||||
_Q: 为什么我不能显示 WebP 图片?_
|
||||
|
||||
A: 确保 `WebP.framework` 已经被添加到你的工程内了。你可以调用 `YYImageWebPAvailable()` 来检查一下 WebP 组件是否被正确安装。
|
||||
|
||||
_Q: 为什么我不能播放 APNG 动画?_
|
||||
|
||||
A: 你应该禁用 Build Settings 中的 `Compress PNG Files` 和 `Remove Text Metadata From PNG Files`. 或者你也可以把 APNG 文件的扩展名改为`apng`.
|
||||
|
||||
文档
|
||||
==============
|
||||
你可以在 [CocoaDocs](http://cocoadocs.org/docsets/YYImage/) 查看在线 API 文档,也可以用 [appledoc](https://github.com/tomaz/appledoc) 本地生成文档。
|
||||
|
||||
Vendored
BIN
Binary file not shown.
Vendored
-2
@@ -104,7 +104,6 @@ for PLATFORM in ${PLATFORMS}; do
|
||||
--disable-shared --enable-static \
|
||||
--enable-libwebpmux \
|
||||
--enable-libwebpdemux \
|
||||
--enable-libwebpdecoder \
|
||||
--enable-swap-16bit-csp \
|
||||
CFLAGS="${CFLAGS}"
|
||||
set +x
|
||||
@@ -119,7 +118,6 @@ for PLATFORM in ${PLATFORMS}; do
|
||||
ar x libwebp.a
|
||||
ar x libwebpmux.a
|
||||
ar x libwebpdemux.a
|
||||
ar x libwebpdecoder.a
|
||||
ar q webp.a *.o
|
||||
|
||||
LIBLIST+=" ${ROOTDIR}/lib/webp.a"
|
||||
|
||||
+1
-1
@@ -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 = '1.0'
|
||||
s.version = '1.0.3'
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.authors = { 'ibireme' => 'ibireme@gmail.com' }
|
||||
s.social_media_url = 'http://blog.ibireme.com'
|
||||
|
||||
@@ -620,7 +620,7 @@ typedef NS_ENUM(NSUInteger, YYAnimatedImageType) {
|
||||
_runloopMode = runloopMode.copy;
|
||||
}
|
||||
|
||||
#pragma mark - Overrice NSObject(NSKeyValueObservingCustomization)
|
||||
#pragma mark - Override NSObject(NSKeyValueObservingCustomization)
|
||||
|
||||
+ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key {
|
||||
if ([key isEqualToString:@"currentAnimatedImageIndex"]) {
|
||||
|
||||
+27
-10
@@ -822,7 +822,7 @@ static BOOL YYCGImageDecodeToBitmapBufferWith32BitFormat(CGImageRef srcImage, vI
|
||||
} else {
|
||||
contextBitmapInfo |= alphaFirst ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaPremultipliedLast;
|
||||
}
|
||||
CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 32, YYCGColorSpaceGetDeviceRGB(), contextBitmapInfo);
|
||||
CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 0, YYCGColorSpaceGetDeviceRGB(), contextBitmapInfo);
|
||||
if (!context) goto fail;
|
||||
|
||||
CGContextDrawImage(context, CGRectMake(0, 0, width, height), srcImage); // decode and convert
|
||||
@@ -1406,7 +1406,7 @@ CGImageRef YYCGImageCreateWithWebPData(CFDataRef webpData,
|
||||
void *tmp = calloc(1, destLength);
|
||||
if (tmp) {
|
||||
vImage_Buffer src = {destBytes, canvasHeight, canvasWidth, bytesPerRow};
|
||||
vImage_Buffer dest = {destBytes, canvasHeight, canvasWidth, bytesPerRow};
|
||||
vImage_Buffer dest = {tmp, canvasHeight, canvasWidth, bytesPerRow};
|
||||
vImage_CGAffineTransform transform = {1, 0, 0, 1, iter.x_offset, -iter.y_offset};
|
||||
uint8_t backColor[4] = {0};
|
||||
vImageAffineWarpCG_ARGB8888(&src, &dest, NULL, &transform, backColor, kvImageBackgroundColorFill);
|
||||
@@ -1530,6 +1530,7 @@ CGImageRef YYCGImageCreateWithWebPData(CFDataRef webpData,
|
||||
if (_webpSource) WebPDemuxDelete(_webpSource);
|
||||
#endif
|
||||
if (_blendCanvas) CFRelease(_blendCanvas);
|
||||
pthread_mutex_destroy(&_lock);
|
||||
}
|
||||
|
||||
+ (instancetype)decoderWithData:(NSData *)data scale:(CGFloat)scale {
|
||||
@@ -1835,6 +1836,13 @@ CGImageRef YYCGImageCreateWithWebPData(CFDataRef webpData,
|
||||
dispatch_semaphore_wait(_framesLock, DISPATCH_TIME_FOREVER);
|
||||
_frames = frames;
|
||||
dispatch_semaphore_signal(_framesLock);
|
||||
#else
|
||||
static const char *func = __FUNCTION__;
|
||||
static const int line = __LINE__;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSLog(@"[%s: %d] WebP is not available, check the documentation to see how to install WebP component: https://github.com/ibireme/YYImage#installation", func, line);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1968,13 +1976,16 @@ CGImageRef YYCGImageCreateWithWebPData(CFDataRef webpData,
|
||||
if (_type == YYImageTypeGIF) { // get gif loop count
|
||||
CFDictionaryRef properties = CGImageSourceCopyProperties(_source, NULL);
|
||||
if (properties) {
|
||||
CFTypeRef loop = CFDictionaryGetValue(properties, kCGImagePropertyGIFLoopCount);
|
||||
if (loop) CFNumberGetValue(loop, kCFNumberNSIntegerType, &_loopCount);
|
||||
CFDictionaryRef gif = CFDictionaryGetValue(properties, kCGImagePropertyGIFDictionary);
|
||||
if (gif) {
|
||||
CFTypeRef loop = CFDictionaryGetValue(gif, kCGImagePropertyGIFLoopCount);
|
||||
if (loop) CFNumberGetValue(loop, kCFNumberNSIntegerType, &_loopCount);
|
||||
}
|
||||
CFRelease(properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
ICO, GIF, APNG may contains multi-frame.
|
||||
*/
|
||||
@@ -2311,10 +2322,16 @@ CGImageRef YYCGImageCreateWithWebPData(CFDataRef webpData,
|
||||
}
|
||||
|
||||
- (instancetype)initWithType:(YYImageType)type {
|
||||
if (type == YYImageTypeUnknown || type >= YYImageTypeOther) return nil;
|
||||
if (type == YYImageTypeUnknown || type >= YYImageTypeOther) {
|
||||
NSLog(@"[%s: %d] Unsupported image type:%d",__FUNCTION__, __LINE__, (int)type);
|
||||
return nil;
|
||||
}
|
||||
|
||||
#if !YYIMAGE_WEBP_ENABLED
|
||||
if (type == YYImageTypeWebP) return nil;
|
||||
if (type == YYImageTypeWebP) {
|
||||
NSLog(@"[%s: %d] WebP is not available, check the documentation to see how to install WebP component: https://github.com/ibireme/YYImage#installation", __FUNCTION__, __LINE__);
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
|
||||
self = [super init];
|
||||
@@ -2440,13 +2457,13 @@ CGImageRef YYCGImageCreateWithWebPData(CFDataRef webpData,
|
||||
} else if ([imageSrc isKindOfClass:[NSURL class]]) {
|
||||
CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)imageSrc, NULL);
|
||||
if (source) {
|
||||
CGImageDestinationAddImageFromSource(destination, source, i, (CFDictionaryRef)frameProperty);
|
||||
CGImageDestinationAddImageFromSource(destination, source, 0, (CFDictionaryRef)frameProperty);
|
||||
CFRelease(source);
|
||||
}
|
||||
} else if ([imageSrc isKindOfClass:[NSData class]]) {
|
||||
CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef)imageSrc, NULL);
|
||||
if (source) {
|
||||
CGImageDestinationAddImageFromSource(destination, source, i, (CFDictionaryRef)frameProperty);
|
||||
CGImageDestinationAddImageFromSource(destination, source, 0, (CFDictionaryRef)frameProperty);
|
||||
CFRelease(source);
|
||||
}
|
||||
}
|
||||
@@ -2766,7 +2783,7 @@ CGImageRef YYCGImageCreateWithWebPData(CFDataRef webpData,
|
||||
}
|
||||
|
||||
- (BOOL)yy_isDecodedForDisplay {
|
||||
if (self.images.count > 1) return YES;
|
||||
if (self.images.count > 1 || [self isKindOfClass:[YYSpriteSheetImage class]]) return YES;
|
||||
NSNumber *num = objc_getAssociatedObject(self, @selector(yy_isDecodedForDisplay));
|
||||
return [num boolValue];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user