SLImage.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // SLImage.h
  3. // WSLImageView
  4. //
  5. // Created by 王双龙 on 2018/10/26.
  6. // Copyright © 2018年 https://www.jianshu.com/u/e15d1f644bea. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "SLImageDecoder.h"
  10. NS_ASSUME_NONNULL_BEGIN
  11. //利用解码工具进行解码并存储解码后的信息
  12. @interface SLImage : UIImage
  13. /** 图片类型 */
  14. @property (nonatomic, assign, readonly) SLImageType imageType;
  15. /** 图像帧总个数 */
  16. @property (nonatomic, assign, readonly) NSInteger frameCount;
  17. /** 循环次数 0:无限循环 */
  18. @property (nonatomic, assign, readonly) NSInteger loopCount;
  19. /// 循环一次的时长
  20. @property (nonatomic, assign, readonly) NSTimeInterval totalTime;
  21. /** 图片所占的内存大小 */
  22. @property (nonatomic, readonly) NSUInteger animatedImageMemorySize;
  23. /** 是否预加载所有的帧 注意内存大小 默认NO */
  24. @property (nonatomic, assign) BOOL preloadAllAnimatedImageFrames;
  25. /**
  26. 重写系统方法,用法尽量和原来保持一致
  27. */
  28. + (SLImage *)imageNamed:(NSString *)name;
  29. + (SLImage *)imageWithContentsOfFile:(NSString *)path;
  30. + (SLImage *)imageWithData:(NSData *)data;
  31. /**
  32. 某一帧的图片信息:索引、持续时长、宽高、方向、解码后的image
  33. */
  34. - (SLImageFrame *)imageFrameAtIndex:(NSInteger)index;
  35. /**
  36. 动图中的某一帧image
  37. */
  38. - (UIImage *)imageAtIndex:(NSUInteger)index;
  39. /**
  40. 某一帧持续时长
  41. */
  42. - (NSTimeInterval)imageDurationAtIndex:(NSUInteger)index;
  43. /**
  44. 一帧所占的内存大小 假设每一帧大小相同
  45. */
  46. - (NSUInteger)imageFrameBytes;
  47. @end
  48. NS_ASSUME_NONNULL_END