diff --git a/Demo/YYImageDemo/YYImageBenchmark.m b/Demo/YYImageDemo/YYImageBenchmark.m index ff6010a..64bf3f0 100644 --- a/Demo/YYImageDemo/YYImageBenchmark.m +++ b/Demo/YYImageDemo/YYImageBenchmark.m @@ -11,7 +11,7 @@ #import "YYBPGCoder.h" #import "UIView+YYAdd.h" #import -#import +#import #import diff --git a/Framework/YYImage.xcodeproj/project.pbxproj b/Framework/YYImage.xcodeproj/project.pbxproj index c92e2ba..c2df260 100644 --- a/Framework/YYImage.xcodeproj/project.pbxproj +++ b/Framework/YYImage.xcodeproj/project.pbxproj @@ -22,9 +22,8 @@ D9A9954A1F0564D40062698B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9A995451F0564BB0062698B /* QuartzCore.framework */; }; D9A9954B1F0564D40062698B /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9A995441F0564B70062698B /* Accelerate.framework */; }; D9A9954C1F0564D40062698B /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9A995431F0564B20062698B /* ImageIO.framework */; }; - D9A9954D1F0564D40062698B /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9A995421F0564AF0062698B /* MobileCoreServices.framework */; }; - D9A9954E1F0564D40062698B /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9A995411F0564A70062698B /* AssetsLibrary.framework */; }; D9A9954F1F0564D40062698B /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D9A995401F05649B0062698B /* libz.tbd */; }; + FD6A394B2C2BFFD500762359 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD6A394A2C2BFFD500762359 /* CoreServices.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -48,6 +47,7 @@ D9A995451F0564BB0062698B /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; D9A995461F0564BF0062698B /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; D9A995471F0564C40062698B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + FD6A394A2C2BFFD500762359 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/CoreServices.framework; sourceTree = DEVELOPER_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -55,13 +55,12 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + FD6A394B2C2BFFD500762359 /* CoreServices.framework in Frameworks */, D9A995481F0564D40062698B /* UIKit.framework in Frameworks */, D9A995491F0564D40062698B /* CoreFoundation.framework in Frameworks */, D9A9954A1F0564D40062698B /* QuartzCore.framework in Frameworks */, D9A9954B1F0564D40062698B /* Accelerate.framework in Frameworks */, D9A9954C1F0564D40062698B /* ImageIO.framework in Frameworks */, - D9A9954D1F0564D40062698B /* MobileCoreServices.framework in Frameworks */, - D9A9954E1F0564D40062698B /* AssetsLibrary.framework in Frameworks */, D9A9954F1F0564D40062698B /* libz.tbd in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -107,6 +106,7 @@ D9A9953F1F05649B0062698B /* Frameworks */ = { isa = PBXGroup; children = ( + FD6A394A2C2BFFD500762359 /* CoreServices.framework */, D9A995471F0564C40062698B /* UIKit.framework */, D9A995461F0564BF0062698B /* CoreFoundation.framework */, D9A995451F0564BB0062698B /* QuartzCore.framework */, @@ -260,7 +260,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -310,7 +310,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; @@ -330,6 +330,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.ibireme.YYImage; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -349,6 +350,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.ibireme.YYImage; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; diff --git a/Framework/YYImage.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Framework/YYImage.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Framework/YYImage.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/README.md b/README.md index cf5b226..3d7c304 100755 --- a/README.md +++ b/README.md @@ -158,10 +158,9 @@ Installation * UIKit * CoreFoundation * QuartzCore - * AssetsLibrary * ImageIO * Accelerate - * MobileCoreServices + * CoreServices * libz 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. @@ -191,204 +190,3 @@ This library requires `iOS 6.0+` and `Xcode 8.0+`. License ============== YYImage is provided under the MIT license. See LICENSE file for details. - - -

---- -中文介绍 -============== -YYImage: 功能强大的 iOS 图像框架。
-(该项目是 [YYKit](https://github.com/ibireme/YYKit) 组件之一) - -![niconiconi~](https://raw.github.com/ibireme/YYImage/master/Demo/YYImageDemo/niconiconi@2x.gif -) - -特性 -============== -- 支持以下类型动画图像的播放/编码/解码:
-     WebP, APNG, GIF。 -- 支持以下类型静态图像的显示/编码/解码:
-     WebP, PNG, GIF, JPEG, JP2, TIFF, BMP, ICO, ICNS。 -- 支持以下类型图片的渐进式/逐行扫描/隔行扫描解码:
-     PNG, GIF, JPEG, BMP。 -- 支持多张图片构成的帧动画播放,支持单张图片的 sprite sheet 动画。 -- 高效的动态内存缓存管理,以保证高性能低内存的动画播放。 -- 完全兼容 UIImage 和 UIImageView,使用方便。 -- 保留可扩展的接口,以支持自定义动画。 -- 每个类和方法都有完善的文档注释。 - - -用法 -============== - -### 显示动画类型的图片 -```objc -// 文件: ani@3x.gif -UIImage *image = [YYImage imageNamed:@"ani.gif"]; -UIImageView *imageView = [[YYAnimatedImageView alloc] initWithImage:image]; -[self.view addSubview:imageView]; -``` - -### 播放帧动画 -```objc -// 文件: 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 动画 -```objc -// 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]; -``` - -### 动画播放控制 -```objc -YYAnimatedImageView *imageView = ...; -// 暂停: -[imageView stopAnimating]; -// 播放: -[imageView startAnimating]; -// 设置播放进度: -imageView.currentAnimatedImageIndex = 12; -// 获取播放状态: -image.currentIsPlayingAnimation; -//上面两个属性都支持 KVO。 -``` - -### 图片解码 -```objc -// 解码单帧图片: -NSData *data = [NSData dataWithContentsOfFile:@"/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... -``` - -### 图片编码 -```objc -// 编码静态图 (支持各种常见图片格式): -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]; -``` - -### 图片类型探测 -```objc -// 获取图片类型 -YYImageType type = YYImageDetectType(data); -if (type == YYImageTypePNG) ... -``` - -安装 -============== - -### CocoaPods - -1. 将 cocoapods 更新至最新版本. -2. 在 Podfile 中添加 `pod 'YYImage'`。 -3. 执行 `pod install` 或 `pod update`。 -4. 导入 \。 -5. 注意:pod 配置并没有包含 WebP 组件, 如果你需要支持 WebP,可以在 Podfile 中添加 `pod 'YYImage/WebP'`。 - -### Carthage - -1. 在 Cartfile 中添加 `github "ibireme/YYImage"`。 -2. 执行 `carthage update --platform ios` 并将生成的 framework 添加到你的工程。 -3. 导入 \。 -4. 注意:carthage framework 并没有包含 WebP 组件。如果你需要支持 WebP,可以用 CocoaPods 安装,或者手动安装。 - -### 手动安装 - -1. 下载 YYImage 文件夹内的所有内容。 -2. 将 YYImage 内的源文件添加(拖放)到你的工程。 -3. 链接以下 frameworks: - * UIKit - * CoreFoundation - * QuartzCore - * AssetsLibrary - * ImageIO - * Accelerate - * MobileCoreServices - * libz -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) 本地生成文档。 - - -系统要求 -============== -该项目最低支持 `iOS 6.0` 和 `Xcode 8.0`。 - - -许可证 -============== -YYImage 使用 MIT 许可证,详情见 LICENSE 文件。 - - -相关链接 -============== -[移动端图片格式调研](https://blog.ibireme.com/2015/11/02/mobile_image_benchmark/)
- -[iOS 处理图片的一些小 Tip](https://blog.ibireme.com/2015/11/02/ios_image_tips/) - diff --git a/YYImage.podspec b/YYImage.podspec index 7f76678..fd6cd43 100644 --- a/YYImage.podspec +++ b/YYImage.podspec @@ -1,14 +1,14 @@ 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.4' + s.version = '1.1.0' s.license = { :type => 'MIT', :file => 'LICENSE' } s.authors = { 'ibireme' => 'ibireme@gmail.com' } s.social_media_url = 'http://blog.ibireme.com' - s.homepage = 'https://github.com/ibireme/YYImage' + s.homepage = 'https://github.com/oxen-io/session-ios-yyimage' s.platform = :ios, '6.0' s.ios.deployment_target = '6.0' - s.source = { :git => 'https://github.com/ibireme/YYImage.git', :tag => s.version.to_s } + s.source = { :git => 'https://github.com/oxen-io/session-ios-yyimage', :tag => s.version.to_s } s.requires_arc = true s.default_subspec = 'Core' @@ -17,7 +17,7 @@ Pod::Spec.new do |s| core.source_files = 'YYImage/*.{h,m}' core.public_header_files = 'YYImage/*.{h}' core.libraries = 'z' - core.frameworks = 'UIKit', 'CoreFoundation', 'QuartzCore', 'AssetsLibrary', 'ImageIO', 'Accelerate', 'MobileCoreServices' + core.frameworks = 'UIKit', 'CoreFoundation', 'QuartzCore', 'ImageIO', 'Accelerate', 'CoreServices' end s.subspec 'WebP' do |webp| diff --git a/YYImage/YYAnimatedImageView.m b/YYImage/YYAnimatedImageView.m index 07ee652..26eca96 100644 --- a/YYImage/YYAnimatedImageView.m +++ b/YYImage/YYAnimatedImageView.m @@ -26,13 +26,13 @@ dispatch_semaphore_signal(view->_lock); -static int64_t _YYDeviceMemoryTotal() { +static int64_t _YYDeviceMemoryTotal(void) { int64_t mem = [[NSProcessInfo processInfo] physicalMemory]; if (mem < -1) mem = -1; return mem; } -static int64_t _YYDeviceMemoryFree() { +static int64_t _YYDeviceMemoryFree(void) { mach_port_t host_port = mach_host_self(); mach_msg_type_number_t host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t); vm_size_t page_size; @@ -528,6 +528,11 @@ - (void)step:(CADisplayLink *)link { - (void)displayLayer:(CALayer *)layer { if (_curFrame) { layer.contents = (__bridge id)_curFrame.CGImage; + } else { + // If we have no animation frames, call super implementation. iOS 14+ UIImageView use this delegate method for rendering. + if ([UIImageView instancesRespondToSelector:@selector(displayLayer:)]) { + [super displayLayer:layer]; + } } } @@ -577,7 +582,7 @@ - (void)setCurrentAnimatedImageIndex:(NSUInteger)currentAnimatedImageIndex { if (currentAnimatedImageIndex >= _curAnimatedImage.animatedImageFrameCount) return; if (_curIndex == currentAnimatedImageIndex) return; - void (^block)() = ^{ + void (^block)(void) = ^{ LOCK( [_requestQueue cancelAllOperations]; [_buffer removeAllObjects]; diff --git a/YYImage/YYFrameImage.m b/YYImage/YYFrameImage.m index 93efe88..416d97f 100644 --- a/YYImage/YYFrameImage.m +++ b/YYImage/YYFrameImage.m @@ -68,7 +68,7 @@ - (instancetype)initWithImagePaths:(NSArray *)paths frameDurations:(NSArray *)fr NSData *firstData = [NSData dataWithContentsOfFile:firstPath]; CGFloat scale = _NSStringPathScale(firstPath); UIImage *firstCG = [[[UIImage alloc] initWithData:firstData] yy_imageByDecoded]; - self = [self initWithCGImage:firstCG.CGImage scale:scale orientation:UIImageOrientationUp]; + self = [self initWithCGImage:firstCG.CGImage scale:scale orientation:firstCG.imageOrientation]; if (!self) return nil; long frameByte = CGImageGetBytesPerRow(firstCG.CGImage) * CGImageGetHeight(firstCG.CGImage); _oneFrameBytes = (NSUInteger)frameByte; @@ -94,7 +94,7 @@ - (instancetype)initWithImageDataArray:(NSArray *)dataArray frameDurations:(NSAr NSData *firstData = dataArray[0]; CGFloat scale = [UIScreen mainScreen].scale; UIImage *firstCG = [[[UIImage alloc] initWithData:firstData] yy_imageByDecoded]; - self = [self initWithCGImage:firstCG.CGImage scale:scale orientation:UIImageOrientationUp]; + self = [self initWithCGImage:firstCG.CGImage scale:scale orientation:firstCG.imageOrientation]; if (!self) return nil; long frameByte = CGImageGetBytesPerRow(firstCG.CGImage) * CGImageGetHeight(firstCG.CGImage); _oneFrameBytes = (NSUInteger)frameByte; diff --git a/YYImage/YYImage.m b/YYImage/YYImage.m index 9fa7efc..6f85b35 100644 --- a/YYImage/YYImage.m +++ b/YYImage/YYImage.m @@ -15,7 +15,7 @@ An array of NSNumber objects, shows the best order for path scale search. e.g. iPhone3GS:@[@1,@2,@3] iPhone5:@[@2,@3,@1] iPhone6 Plus:@[@3,@2,@1] */ -static NSArray *_NSBundlePreferredScales() { +static NSArray *_NSBundlePreferredScales(void) { static NSArray *scales; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ diff --git a/YYImage/YYImageCoder.h b/YYImage/YYImageCoder.h index 31299e7..3480194 100644 --- a/YYImage/YYImageCoder.h +++ b/YYImage/YYImageCoder.h @@ -323,19 +323,6 @@ typedef NS_ENUM(NSUInteger, YYImageBlendOperation) { */ @property (nonatomic) BOOL yy_isDecodedForDisplay; -/** - Saves this image to iOS Photos Album. - - @discussion This method attempts to save the original data to album if the - image is created from an animated GIF/APNG, otherwise, it will save the image - as JPEG or PNG (based on the alpha information). - - @param completionBlock The block invoked (in main thread) after the save operation completes. - assetURL: An URL that identifies the saved image file. If the image is not saved, assetURL is nil. - error: If the image is not saved, an error object that describes the reason for failure, otherwise nil. - */ -- (void)yy_saveToAlbumWithCompletionBlock:(nullable void(^)(NSURL * _Nullable assetURL, NSError * _Nullable error))completionBlock; - /** Return a 'best' data representation for this image. @@ -368,10 +355,10 @@ CG_EXTERN NSString *_Nullable YYImageTypeGetExtension(YYImageType type); /// Returns the shared DeviceRGB color space. -CG_EXTERN CGColorSpaceRef YYCGColorSpaceGetDeviceRGB(); +CG_EXTERN CGColorSpaceRef YYCGColorSpaceGetDeviceRGB(void); /// Returns the shared DeviceGray color space. -CG_EXTERN CGColorSpaceRef YYCGColorSpaceGetDeviceGray(); +CG_EXTERN CGColorSpaceRef YYCGColorSpaceGetDeviceGray(void); /// Returns whether a color space is DeviceRGB. CG_EXTERN BOOL YYCGColorSpaceIsDeviceRGB(CGColorSpaceRef space); @@ -446,7 +433,7 @@ CG_EXTERN CFDataRef _Nullable YYCGImageCreateEncodedData(CGImageRef imageRef, YY /** Whether WebP is available in YYImage. */ -CG_EXTERN BOOL YYImageWebPAvailable(); +CG_EXTERN BOOL YYImageWebPAvailable(void); /** Get a webp image frame count; diff --git a/YYImage/YYImageCoder.m b/YYImage/YYImageCoder.m index 66cf46e..221b19e 100644 --- a/YYImage/YYImageCoder.m +++ b/YYImage/YYImageCoder.m @@ -15,8 +15,7 @@ #import #import #import -#import -#import +#import #import #import #import @@ -641,7 +640,7 @@ static inline CGFloat YYImageDegreesToRadians(CGFloat degrees) { return degrees * M_PI / 180; } -CGColorSpaceRef YYCGColorSpaceGetDeviceRGB() { +CGColorSpaceRef YYCGColorSpaceGetDeviceRGB(void) { static CGColorSpaceRef space; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -650,7 +649,7 @@ CGColorSpaceRef YYCGColorSpaceGetDeviceRGB() { return space; } -CGColorSpaceRef YYCGColorSpaceGetDeviceGray() { +CGColorSpaceRef YYCGColorSpaceGetDeviceGray(void) { static CGColorSpaceRef space; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -1437,7 +1436,7 @@ Call WebPDecode() on a multi-frame webp data will get an error (VP8_STATUS_UNSUP #else -BOOL YYImageWebPAvailable() { +BOOL YYImageWebPAvailable(void) { return NO; } @@ -2356,6 +2355,7 @@ - (instancetype)initWithType:(YYImageType)type { } break; case YYImageTypeWebP: { _quality = 0.8; + _lossless = YES; } break; default: break; @@ -2561,6 +2561,7 @@ - (NSData *)_encodeAPNG { CFRelease(extendedImage); return nil; } + CFRelease(extendedImage); pngDatas[0] = (__bridge id)(frameData); CFRelease(frameData); } @@ -2792,23 +2793,6 @@ - (void)setYy_isDecodedForDisplay:(BOOL)isDecodedForDisplay { objc_setAssociatedObject(self, @selector(yy_isDecodedForDisplay), @(isDecodedForDisplay), OBJC_ASSOCIATION_RETAIN_NONATOMIC); } -- (void)yy_saveToAlbumWithCompletionBlock:(void(^)(NSURL *assetURL, NSError *error))completionBlock { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - NSData *data = [self _yy_dataRepresentationForSystem:YES]; - ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; - [library writeImageDataToSavedPhotosAlbum:data metadata:nil completionBlock:^(NSURL *assetURL, NSError *error){ - if (!completionBlock) return; - if (pthread_main_np()) { - completionBlock(assetURL, error); - } else { - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(assetURL, error); - }); - } - }]; - }); -} - - (NSData *)yy_imageDataRepresentation { return [self _yy_dataRepresentationForSystem:NO]; }