Move the imageLoopCount and isAnimated into UIImage+WebCache file, removed the outdated methods
This commit is contained in:
parent
55d0822d20
commit
9c124435b6
|
@ -319,6 +319,18 @@
|
|||
3290FA0D1FA478AF0047D20C /* SDWebImageFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = 3290FA031FA478AF0047D20C /* SDWebImageFrame.m */; };
|
||||
3290FA0E1FA478AF0047D20C /* SDWebImageFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = 3290FA031FA478AF0047D20C /* SDWebImageFrame.m */; };
|
||||
3290FA0F1FA478AF0047D20C /* SDWebImageFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = 3290FA031FA478AF0047D20C /* SDWebImageFrame.m */; };
|
||||
329A18591FFF5DFD008C9A2F /* UIImage+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 329A18571FFF5DFD008C9A2F /* UIImage+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
329A185A1FFF5DFD008C9A2F /* UIImage+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 329A18571FFF5DFD008C9A2F /* UIImage+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
329A185B1FFF5DFD008C9A2F /* UIImage+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 329A18571FFF5DFD008C9A2F /* UIImage+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
329A185C1FFF5DFD008C9A2F /* UIImage+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 329A18571FFF5DFD008C9A2F /* UIImage+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
329A185D1FFF5DFD008C9A2F /* UIImage+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 329A18571FFF5DFD008C9A2F /* UIImage+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
329A185E1FFF5DFD008C9A2F /* UIImage+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 329A18571FFF5DFD008C9A2F /* UIImage+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
329A185F1FFF5DFD008C9A2F /* UIImage+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 329A18581FFF5DFD008C9A2F /* UIImage+WebCache.m */; };
|
||||
329A18601FFF5DFD008C9A2F /* UIImage+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 329A18581FFF5DFD008C9A2F /* UIImage+WebCache.m */; };
|
||||
329A18611FFF5DFD008C9A2F /* UIImage+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 329A18581FFF5DFD008C9A2F /* UIImage+WebCache.m */; };
|
||||
329A18621FFF5DFD008C9A2F /* UIImage+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 329A18581FFF5DFD008C9A2F /* UIImage+WebCache.m */; };
|
||||
329A18631FFF5DFD008C9A2F /* UIImage+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 329A18581FFF5DFD008C9A2F /* UIImage+WebCache.m */; };
|
||||
329A18641FFF5DFD008C9A2F /* UIImage+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 329A18581FFF5DFD008C9A2F /* UIImage+WebCache.m */; };
|
||||
32CF1C071FA496B000004BD1 /* SDWebImageCoderHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 32CF1C051FA496B000004BD1 /* SDWebImageCoderHelper.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
32CF1C081FA496B000004BD1 /* SDWebImageCoderHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 32CF1C051FA496B000004BD1 /* SDWebImageCoderHelper.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
32CF1C091FA496B000004BD1 /* SDWebImageCoderHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 32CF1C051FA496B000004BD1 /* SDWebImageCoderHelper.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
|
@ -1320,6 +1332,8 @@
|
|||
323F8B3D1F38EF770092B609 /* muxread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = muxread.c; sourceTree = "<group>"; };
|
||||
3290FA021FA478AF0047D20C /* SDWebImageFrame.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDWebImageFrame.h; sourceTree = "<group>"; };
|
||||
3290FA031FA478AF0047D20C /* SDWebImageFrame.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDWebImageFrame.m; sourceTree = "<group>"; };
|
||||
329A18571FFF5DFD008C9A2F /* UIImage+WebCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImage+WebCache.h"; path = "SDWebImage/UIImage+WebCache.h"; sourceTree = "<group>"; };
|
||||
329A18581FFF5DFD008C9A2F /* UIImage+WebCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImage+WebCache.m"; path = "SDWebImage/UIImage+WebCache.m"; sourceTree = "<group>"; };
|
||||
32CF1C051FA496B000004BD1 /* SDWebImageCoderHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDWebImageCoderHelper.h; sourceTree = "<group>"; };
|
||||
32CF1C061FA496B000004BD1 /* SDWebImageCoderHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDWebImageCoderHelper.m; sourceTree = "<group>"; };
|
||||
4314D1991D0E0E3B004B36C9 /* libSDWebImage watchOS static.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libSDWebImage watchOS static.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -1624,6 +1638,8 @@
|
|||
4369C2851D9811BB007E863A /* WebCache Categories */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
329A18571FFF5DFD008C9A2F /* UIImage+WebCache.h */,
|
||||
329A18581FFF5DFD008C9A2F /* UIImage+WebCache.m */,
|
||||
4397D2F41D0DE2DF00BB2784 /* NSImage+WebCache.h */,
|
||||
4397D2F51D0DE2DF00BB2784 /* NSImage+WebCache.m */,
|
||||
535699B415113E7300A4C397 /* MKAnnotationView+WebCache.h */,
|
||||
|
@ -1987,6 +2003,7 @@
|
|||
80377C4A1F2F666300F89830 /* bit_writer_utils.h in Headers */,
|
||||
4397D2F81D0DF44200BB2784 /* MKAnnotationView+WebCache.h in Headers */,
|
||||
323F8BE71F38EF770092B609 /* vp8li_enc.h in Headers */,
|
||||
329A185C1FFF5DFD008C9A2F /* UIImage+WebCache.h in Headers */,
|
||||
4369C27A1D9807EC007E863A /* UIView+WebCache.h in Headers */,
|
||||
80377DCC1F2F66A700F89830 /* lossless_common.h in Headers */,
|
||||
321E60971F38E8ED00405457 /* SDWebImageImageIOCoder.h in Headers */,
|
||||
|
@ -2078,6 +2095,7 @@
|
|||
80377D501F2F66A700F89830 /* mips_macro.h in Headers */,
|
||||
80377C291F2F666300F89830 /* thread_utils.h in Headers */,
|
||||
4314D16D1D0E0E3B004B36C9 /* SDImageCache.h in Headers */,
|
||||
329A185A1FFF5DFD008C9A2F /* UIImage+WebCache.h in Headers */,
|
||||
4314D16F1D0E0E3B004B36C9 /* NSData+ImageContentType.h in Headers */,
|
||||
80377C121F2F666300F89830 /* bit_reader_inl_utils.h in Headers */,
|
||||
4314D1701D0E0E3B004B36C9 /* mux.h in Headers */,
|
||||
|
@ -2142,6 +2160,7 @@
|
|||
43A62A1B1D0E0A800089D7DD /* decode.h in Headers */,
|
||||
321E608A1F38E8C800405457 /* SDWebImageCoder.h in Headers */,
|
||||
80377C601F2F666400F89830 /* bit_reader_inl_utils.h in Headers */,
|
||||
329A185D1FFF5DFD008C9A2F /* UIImage+WebCache.h in Headers */,
|
||||
431BB6DC1D06D2C1006A3455 /* UIButton+WebCache.h in Headers */,
|
||||
431BB6E11D06D2C1006A3455 /* SDWebImage.h in Headers */,
|
||||
80377E311F2F66A800F89830 /* yuv.h in Headers */,
|
||||
|
@ -2238,6 +2257,7 @@
|
|||
4397D2D11D0DDD8C00BB2784 /* decode.h in Headers */,
|
||||
80377E481F2F66A800F89830 /* dsp.h in Headers */,
|
||||
323F8BE91F38EF770092B609 /* vp8li_enc.h in Headers */,
|
||||
329A185E1FFF5DFD008C9A2F /* UIImage+WebCache.h in Headers */,
|
||||
80377E761F2F66A800F89830 /* yuv.h in Headers */,
|
||||
80377C7A1F2F666400F89830 /* bit_reader_inl_utils.h in Headers */,
|
||||
80377E631F2F66A800F89830 /* lossless.h in Headers */,
|
||||
|
@ -2296,6 +2316,7 @@
|
|||
80377C301F2F666300F89830 /* bit_writer_utils.h in Headers */,
|
||||
431739541CDFC8B70008FEB9 /* types.h in Headers */,
|
||||
323F8BE61F38EF770092B609 /* vp8li_enc.h in Headers */,
|
||||
329A185B1FFF5DFD008C9A2F /* UIImage+WebCache.h in Headers */,
|
||||
4369C2791D9807EC007E863A /* UIView+WebCache.h in Headers */,
|
||||
80377D871F2F66A700F89830 /* lossless_common.h in Headers */,
|
||||
321E60961F38E8ED00405457 /* SDWebImageImageIOCoder.h in Headers */,
|
||||
|
@ -2391,6 +2412,7 @@
|
|||
321E60941F38E8ED00405457 /* SDWebImageImageIOCoder.h in Headers */,
|
||||
431738BD1CDFC2660008FEB9 /* decode.h in Headers */,
|
||||
80377D0B1F2F66A100F89830 /* mips_macro.h in Headers */,
|
||||
329A18591FFF5DFD008C9A2F /* UIImage+WebCache.h in Headers */,
|
||||
5376131A155AD0D5005750A4 /* SDWebImageDownloader.h in Headers */,
|
||||
4369C2771D9807EC007E863A /* UIView+WebCache.h in Headers */,
|
||||
80377CEF1F2F66A100F89830 /* dsp.h in Headers */,
|
||||
|
@ -2794,6 +2816,7 @@
|
|||
00733A5E1BC4880000A5A117 /* UIImage+MultiFormat.m in Sources */,
|
||||
80377DD01F2F66A700F89830 /* lossless_enc_neon.c in Sources */,
|
||||
80377DE21F2F66A700F89830 /* rescaler.c in Sources */,
|
||||
329A18621FFF5DFD008C9A2F /* UIImage+WebCache.m in Sources */,
|
||||
80377DAD1F2F66A700F89830 /* argb_mips_dsp_r2.c in Sources */,
|
||||
00733A601BC4880000A5A117 /* UIImageView+HighlightedWebCache.m in Sources */,
|
||||
323F8BAB1F38EF770092B609 /* picture_psnr_enc.c in Sources */,
|
||||
|
@ -2817,6 +2840,7 @@
|
|||
80377EA01F2F66D400F89830 /* vp8_dec.c in Sources */,
|
||||
80377EA31F2F66D400F89830 /* vp8l_dec.c in Sources */,
|
||||
80377E9D1F2F66D400F89830 /* io_dec.c in Sources */,
|
||||
329A18601FFF5DFD008C9A2F /* UIImage+WebCache.m in Sources */,
|
||||
80377D541F2F66A700F89830 /* rescaler_mips32.c in Sources */,
|
||||
80377D331F2F66A700F89830 /* dec.c in Sources */,
|
||||
323F8BAF1F38EF770092B609 /* picture_rescale_enc.c in Sources */,
|
||||
|
@ -2960,6 +2984,7 @@
|
|||
80377ED01F2F66D500F89830 /* vp8_dec.c in Sources */,
|
||||
80377ED31F2F66D500F89830 /* vp8l_dec.c in Sources */,
|
||||
80377ECD1F2F66D500F89830 /* io_dec.c in Sources */,
|
||||
329A18631FFF5DFD008C9A2F /* UIImage+WebCache.m in Sources */,
|
||||
80377E231F2F66A800F89830 /* rescaler_mips32.c in Sources */,
|
||||
80377E021F2F66A800F89830 /* dec.c in Sources */,
|
||||
323F8BB21F38EF770092B609 /* picture_rescale_enc.c in Sources */,
|
||||
|
@ -3124,6 +3149,7 @@
|
|||
80377EE01F2F66D500F89830 /* vp8_dec.c in Sources */,
|
||||
32CF1C121FA496B000004BD1 /* SDWebImageCoderHelper.m in Sources */,
|
||||
80377E521F2F66A800F89830 /* filters_msa.c in Sources */,
|
||||
329A18641FFF5DFD008C9A2F /* UIImage+WebCache.m in Sources */,
|
||||
80377C821F2F666400F89830 /* filters_utils.c in Sources */,
|
||||
4397D28C1D0DDD8C00BB2784 /* UIImageView+WebCache.m in Sources */,
|
||||
80377E581F2F66A800F89830 /* lossless_enc_mips32.c in Sources */,
|
||||
|
@ -3372,6 +3398,7 @@
|
|||
43CE75801CFE9427006C64D0 /* FLAnimatedImageView.m in Sources */,
|
||||
4369C2801D9807EC007E863A /* UIView+WebCache.m in Sources */,
|
||||
80377D8B1F2F66A700F89830 /* lossless_enc_neon.c in Sources */,
|
||||
329A18611FFF5DFD008C9A2F /* UIImage+WebCache.m in Sources */,
|
||||
80377D9D1F2F66A700F89830 /* rescaler.c in Sources */,
|
||||
80377D681F2F66A700F89830 /* argb_mips_dsp_r2.c in Sources */,
|
||||
323F8BAA1F38EF770092B609 /* picture_psnr_enc.c in Sources */,
|
||||
|
@ -3519,6 +3546,7 @@
|
|||
43CE757F1CFE9427006C64D0 /* FLAnimatedImageView.m in Sources */,
|
||||
4369C27E1D9807EC007E863A /* UIView+WebCache.m in Sources */,
|
||||
80377D011F2F66A100F89830 /* lossless_enc_neon.c in Sources */,
|
||||
329A185F1FFF5DFD008C9A2F /* UIImage+WebCache.m in Sources */,
|
||||
80377D131F2F66A100F89830 /* rescaler.c in Sources */,
|
||||
80377CDE1F2F66A100F89830 /* argb_mips_dsp_r2.c in Sources */,
|
||||
323F8BA81F38EF770092B609 /* picture_psnr_enc.c in Sources */,
|
||||
|
|
|
@ -10,13 +10,10 @@
|
|||
|
||||
#if SD_MAC
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
@interface NSImage (Additions)
|
||||
|
||||
@interface NSImage (WebCache)
|
||||
|
||||
- (CGImageRef)CGImage;
|
||||
- (NSArray<NSImage *> *)images;
|
||||
- (BOOL)isGIF;
|
||||
- (nullable CGImageRef)CGImage;
|
||||
- (nullable NSArray<NSImage *> *)images;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#if SD_MAC
|
||||
|
||||
@implementation NSImage (WebCache)
|
||||
@implementation NSImage (Additions)
|
||||
|
||||
- (CGImageRef)CGImage {
|
||||
NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height);
|
||||
|
@ -22,19 +22,6 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)isGIF {
|
||||
BOOL isGIF = NO;
|
||||
for (NSImageRep *rep in self.representations) {
|
||||
if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
|
||||
NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)rep;
|
||||
NSUInteger frameCount = [[bitmapRep valueForProperty:NSImageFrameCount] unsignedIntegerValue];
|
||||
isGIF = frameCount > 1 ? YES : NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isGIF;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
#import "SDWebImageCompat.h"
|
||||
#import "UIImage+MultiFormat.h"
|
||||
#import "UIImage+WebCache.h"
|
||||
|
||||
#if !__has_feature(objc_arc)
|
||||
#error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
@interface SDWebImageFrame : NSObject
|
||||
|
||||
// This class is used for creating animated images via `animatedImageWithFrames` in `SDWebImageCoderHelper`. Attension if you need animated images loop count, use `sd_imageLoopCount` property in `UIImage+MultiFormat`
|
||||
// This class is used for creating animated images via `animatedImageWithFrames` in `SDWebImageCoderHelper`. Attension if you need animated images loop count, use `sd_imageLoopCount` property in `UIImage+WebCache.h`
|
||||
|
||||
/**
|
||||
The image of current frame. You should not set an animated image.
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
#import "SDWebImageGIFCoder.h"
|
||||
#import "NSImage+WebCache.h"
|
||||
#import "UIImage+WebCache.h"
|
||||
#import <ImageIO/ImageIO.h>
|
||||
#import "NSData+ImageContentType.h"
|
||||
#import "UIImage+MultiFormat.h"
|
||||
#import "SDWebImageCoderHelper.h"
|
||||
|
||||
@implementation SDWebImageGIFCoder
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#import "SDWebImageWebPCoder.h"
|
||||
#import "SDWebImageCoderHelper.h"
|
||||
#import "NSImage+WebCache.h"
|
||||
#import "UIImage+MultiFormat.h"
|
||||
#import "UIImage+WebCache.h"
|
||||
#if __has_include(<webp/decode.h>) && __has_include(<webp/encode.h>) && __has_include(<webp/demux.h>) && __has_include(<webp/mux.h>)
|
||||
#import <webp/decode.h>
|
||||
#import <webp/encode.h>
|
||||
|
|
|
@ -15,11 +15,6 @@
|
|||
* Creates an animated UIImage from an NSData.
|
||||
* For static GIF, will create an UIImage with `images` array set to nil. For animated GIF, will create an UIImage with valid `images` array.
|
||||
*/
|
||||
+ (UIImage *)sd_animatedGIFWithData:(NSData *)data;
|
||||
|
||||
/**
|
||||
* Checks if an UIImage instance is a GIF. Will use the `images` array.
|
||||
*/
|
||||
- (BOOL)isGIF;
|
||||
+ (nullable UIImage *)sd_animatedGIFWithData:(nullable NSData *)data;
|
||||
|
||||
@end
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#import "UIImage+GIF.h"
|
||||
#import "SDWebImageGIFCoder.h"
|
||||
#import "NSImage+WebCache.h"
|
||||
|
||||
@implementation UIImage (GIF)
|
||||
|
||||
|
@ -20,8 +19,4 @@
|
|||
return [[SDWebImageGIFCoder sharedCoder] decodedImageWithData:data];
|
||||
}
|
||||
|
||||
- (BOOL)isGIF {
|
||||
return (self.images != nil);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -11,18 +11,6 @@
|
|||
|
||||
@interface UIImage (MultiFormat)
|
||||
|
||||
/**
|
||||
* UIKit:
|
||||
* For static image format, this value is always 0.
|
||||
* For animated image format, 0 means infinite looping.
|
||||
* Note that because of the limitations of categories this property can get out of sync if you create another instance with CGImage or other methods.
|
||||
* AppKit:
|
||||
* NSImage currently only support animated via GIF imageRep unlike UIImage.
|
||||
* The getter of this property will get the loop count from GIF imageRep
|
||||
* The setter of this property will set the loop count from GIF imageRep
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger sd_imageLoopCount;
|
||||
|
||||
+ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data;
|
||||
- (nullable NSData *)sd_imageData;
|
||||
- (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat;
|
||||
|
|
|
@ -7,52 +7,10 @@
|
|||
*/
|
||||
|
||||
#import "UIImage+MultiFormat.h"
|
||||
|
||||
#import "objc/runtime.h"
|
||||
#import "SDWebImageCodersManager.h"
|
||||
|
||||
@implementation UIImage (MultiFormat)
|
||||
|
||||
#if SD_MAC
|
||||
- (NSUInteger)sd_imageLoopCount {
|
||||
NSUInteger imageLoopCount = 0;
|
||||
for (NSImageRep *rep in self.representations) {
|
||||
if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
|
||||
NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)rep;
|
||||
imageLoopCount = [[bitmapRep valueForProperty:NSImageLoopCount] unsignedIntegerValue];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return imageLoopCount;
|
||||
}
|
||||
|
||||
- (void)setSd_imageLoopCount:(NSUInteger)sd_imageLoopCount {
|
||||
for (NSImageRep *rep in self.representations) {
|
||||
if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
|
||||
NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)rep;
|
||||
[bitmapRep setProperty:NSImageLoopCount withValue:@(sd_imageLoopCount)];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
- (NSUInteger)sd_imageLoopCount {
|
||||
NSUInteger imageLoopCount = 0;
|
||||
NSNumber *value = objc_getAssociatedObject(self, @selector(sd_imageLoopCount));
|
||||
if ([value isKindOfClass:[NSNumber class]]) {
|
||||
imageLoopCount = value.unsignedIntegerValue;
|
||||
}
|
||||
return imageLoopCount;
|
||||
}
|
||||
|
||||
- (void)setSd_imageLoopCount:(NSUInteger)sd_imageLoopCount {
|
||||
NSNumber *value = @(sd_imageLoopCount);
|
||||
objc_setAssociatedObject(self, @selector(sd_imageLoopCount), value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
#endif
|
||||
|
||||
+ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data {
|
||||
return [[SDWebImageCodersManager sharedInstance] decodedImageWithData:data];
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* This file is part of the SDWebImage package.
|
||||
* (c) Olivier Poitrey <rs@dailymotion.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
#import "SDWebImageCompat.h"
|
||||
|
||||
@interface UIImage (WebCache)
|
||||
|
||||
/**
|
||||
* UIKit:
|
||||
* For static image format, this value is always 0.
|
||||
* For animated image format, 0 means infinite looping.
|
||||
* Note that because of the limitations of categories this property can get out of sync if you create another instance with CGImage or other methods.
|
||||
* AppKit:
|
||||
* NSImage currently only support animated via GIF imageRep unlike UIImage.
|
||||
* The getter of this property will get the loop count from GIF imageRep
|
||||
* The setter of this property will set the loop count from GIF imageRep
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger sd_imageLoopCount;
|
||||
/**
|
||||
* UIKit:
|
||||
* Check the `images` array property
|
||||
* AppKit:
|
||||
* NSImage currently only support animated via GIF imageRep unlike UIImage. It will check all the imageRef
|
||||
*/
|
||||
@property (nonatomic, assign, readonly) BOOL sd_isAnimated;
|
||||
|
||||
@end
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* This file is part of the SDWebImage package.
|
||||
* (c) Olivier Poitrey <rs@dailymotion.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
#import "UIImage+WebCache.h"
|
||||
#import "objc/runtime.h"
|
||||
|
||||
@implementation UIImage (WebCache)
|
||||
|
||||
#if SD_MAC
|
||||
- (NSUInteger)sd_imageLoopCount {
|
||||
NSUInteger imageLoopCount = 0;
|
||||
for (NSImageRep *rep in self.representations) {
|
||||
if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
|
||||
NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)rep;
|
||||
imageLoopCount = [[bitmapRep valueForProperty:NSImageLoopCount] unsignedIntegerValue];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return imageLoopCount;
|
||||
}
|
||||
|
||||
- (void)setSd_imageLoopCount:(NSUInteger)sd_imageLoopCount {
|
||||
for (NSImageRep *rep in self.representations) {
|
||||
if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
|
||||
NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)rep;
|
||||
[bitmapRep setProperty:NSImageLoopCount withValue:@(sd_imageLoopCount)];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)sd_isAnimated {
|
||||
BOOL isGIF = NO;
|
||||
for (NSImageRep *rep in self.representations) {
|
||||
if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
|
||||
NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)rep;
|
||||
NSUInteger frameCount = [[bitmapRep valueForProperty:NSImageFrameCount] unsignedIntegerValue];
|
||||
isGIF = frameCount > 1 ? YES : NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isGIF;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
- (NSUInteger)sd_imageLoopCount {
|
||||
NSUInteger imageLoopCount = 0;
|
||||
NSNumber *value = objc_getAssociatedObject(self, @selector(sd_imageLoopCount));
|
||||
if ([value isKindOfClass:[NSNumber class]]) {
|
||||
imageLoopCount = value.unsignedIntegerValue;
|
||||
}
|
||||
return imageLoopCount;
|
||||
}
|
||||
|
||||
- (void)setSd_imageLoopCount:(NSUInteger)sd_imageLoopCount {
|
||||
NSNumber *value = @(sd_imageLoopCount);
|
||||
objc_setAssociatedObject(self, @selector(sd_imageLoopCount), value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
- (BOOL)sd_isAnimated {
|
||||
return (self.images != nil);
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
|
@ -12,17 +12,6 @@
|
|||
|
||||
@interface UIImage (WebP)
|
||||
|
||||
/**
|
||||
* Get the current WebP image loop count, the default value is 0.
|
||||
* For static WebP image, the value is 0.
|
||||
* For animated WebP image, 0 means repeat the animation indefinitely.
|
||||
* Note that because of the limitations of categories this property can get out of sync
|
||||
* if you create another instance with CGImage or other methods.
|
||||
* @return WebP image loop count
|
||||
* @deprecated use `sd_imageLoopCount` instead.
|
||||
*/
|
||||
- (NSInteger)sd_webpLoopCount __deprecated_msg("Method deprecated. Use `sd_imageLoopCount` in `UIImage+MultiFormat.h`");
|
||||
|
||||
+ (nullable UIImage *)sd_imageWithWebPData:(nullable NSData *)data;
|
||||
|
||||
@end
|
||||
|
|
|
@ -10,14 +10,9 @@
|
|||
|
||||
#import "UIImage+WebP.h"
|
||||
#import "SDWebImageWebPCoder.h"
|
||||
#import "UIImage+MultiFormat.h"
|
||||
|
||||
@implementation UIImage (WebP)
|
||||
|
||||
- (NSInteger)sd_webpLoopCount {
|
||||
return self.sd_imageLoopCount;
|
||||
}
|
||||
|
||||
+ (nullable UIImage *)sd_imageWithWebPData:(nullable NSData *)data {
|
||||
if (!data) {
|
||||
return nil;
|
||||
|
|
|
@ -31,6 +31,7 @@ FOUNDATION_EXPORT const unsigned char WebImageVersionString[];
|
|||
#import <SDWebImage/UIButton+WebCache.h>
|
||||
#import <SDWebImage/SDWebImagePrefetcher.h>
|
||||
#import <SDWebImage/UIView+WebCacheOperation.h>
|
||||
#import <SDWebImage/UIImage+WebCache.h>
|
||||
#import <SDWebImage/UIImage+MultiFormat.h>
|
||||
#import <SDWebImage/SDWebImageOperation.h>
|
||||
#import <SDWebImage/SDWebImageDownloader.h>
|
||||
|
|
Loading…
Reference in New Issue