PINProgressiveImage.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // PINProgressiveImage.h
  3. // Pods
  4. //
  5. // Created by Garrett Moon on 2/9/15.
  6. //
  7. //
  8. #import <Foundation/Foundation.h>
  9. #if PIN_TARGET_IOS
  10. #import <UIKit/UIKit.h>
  11. #elif PIN_TARGET_MAC
  12. #import <Cocoa/Cocoa.h>
  13. #endif
  14. #import "PINRemoteImageMacros.h"
  15. /** An object which store the data of a downloading image and vends progressive scans **/
  16. @interface PINProgressiveImage : NSObject
  17. @property (atomic, copy, nonnull) NSArray *progressThresholds;
  18. @property (atomic, assign) CFTimeInterval estimatedRemainingTimeThreshold;
  19. @property (atomic, assign) CFTimeInterval startTime;
  20. - (void)updateProgressiveImageWithData:(nonnull NSData *)data expectedNumberOfBytes:(int64_t)expectedNumberOfBytes;
  21. /**
  22. Returns the latest image based on thresholds, returns nil if no new image is generated
  23. @param blurred A boolean to indicate if the image should be blurred
  24. @param maxProgressiveRenderSize the maximum dimensions at which to apply a blur. If an image exceeds either the height
  25. or width of this dimension, the image will *not* be blurred regardless of the blurred parameter.
  26. @param renderedImageQuality Value between 0 and 1. Computed by dividing the received number of bytes by the expected number of bytes
  27. @return PINImage a progressive scan of the image or nil if a new one has not been generated
  28. */
  29. - (nullable PINImage *)currentImageBlurred:(BOOL)blurred maxProgressiveRenderSize:(CGSize)maxProgressiveRenderSize renderedImageQuality:(nonnull out CGFloat *)renderedImageQuality;
  30. /**
  31. Returns the current data for the image.
  32. @return NSData the current data for the image
  33. */
  34. - (nullable NSData *)data;
  35. @end