UIImage+MemoryCacheCost.h 1.3 KB

123456789101112131415161718192021222324252627
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. #import "SDWebImageCompat.h"
  9. /**
  10. UIImage category for memory cache cost.
  11. */
  12. @interface UIImage (MemoryCacheCost)
  13. /**
  14. The memory cache cost for specify image used by image cache. The cost function is the bytes size held in memory.
  15. If you set some associated object to `UIImage`, you can set the custom value to indicate the memory cost.
  16. For `UIImage`, this method return the single frame bytes size when `image.images` is nil for static image. Return full frame bytes size when `image.images` is not nil for animated image.
  17. For `NSImage`, this method return the single frame bytes size because `NSImage` does not store all frames in memory.
  18. @note Note that because of the limitations of category this property can get out of sync if you create another instance with CGImage or other methods.
  19. @note For custom animated class conforms to `SDAnimatedImage`, you can override this getter method in your subclass to return a more proper value instead, which representing the current frame's total bytes.
  20. */
  21. @property (assign, nonatomic) NSUInteger sd_memoryCost;
  22. @end