PINAnimatedImage Class Reference

Inherits from NSObject
Declared in PINAnimatedImage.h

Overview

PINAnimatedImage is a class which decodes GIFs to memory mapped files on disk. Like PINRemoteImageManager, it will only decode a GIF one time, regardless of the number of the number of PINAnimatedImages created with the same NSData.

PINAnimatedImage’s are also decoded chunks at a time, writing each chunk to a separate file. This allows callback and playback to start before the GIF is completely decoded. If a frame is requested beyond what has been processed, nil will be returned. Because a fileReady is called on each chunk completion, you can pause playback if you hit a nil frame until you receive another fileReady call.

Internally, PINAnimatedImage attempts to keep only the files it needs open – the last file associated with the requested frame and the one after (to prime).

It’s important to note that until infoCompletion is called, it is unsafe to access many of the methods on PINAnimatedImage.

  infoCompletion

A block to be called on when GIF info has been processed. Status will == PINAnimatedImageStatusInfoProcessed

@property (nonatomic, strong, readwrite) PINAnimatedImageInfoReady infoCompletion

Declared In

PINAnimatedImage.h

  fileReady

A block to be called whenever a new file is done being processed. You can start (or resume) playback when you get this callback, though it’s possible for playback to catch up to the decoding and you’ll need to pause.

@property (nonatomic, strong, readwrite) dispatch_block_t fileReady

Declared In

PINAnimatedImage.h

  animatedImageReady

A block to be called when the animated image is fully decoded and written to disk.

@property (nonatomic, strong, readwrite) dispatch_block_t animatedImageReady

Declared In

PINAnimatedImage.h

  status

The current status of the animated image.

@property (nonatomic, assign, readwrite) PINAnimatedImageStatus status

Declared In

PINAnimatedImage.h

  coverImageReady

A helper function which references status to check if the coverImage is ready.

@property (nonatomic, readonly) BOOL coverImageReady

Declared In

PINAnimatedImage.h

  playbackReady

A helper function which references status to check if playback is ready.

@property (nonatomic, readonly) BOOL playbackReady

Declared In

PINAnimatedImage.h

  coverImage

The first frame / cover image of the animated image.

@property (nonatomic, readonly) PINImage *coverImage

Discussion

Warning: Access to this property before status == PINAnimatedImageStatusInfoProcessed is undefined. You can check coverImageReady too.

Declared In

PINAnimatedImage.h

  totalDuration

The total duration of one loop of playback.

@property (nonatomic, readonly) CFTimeInterval totalDuration

Discussion

Warning: Access to this property before status == PINAnimatedImageStatusInfoProcessed is undefined.

Declared In

PINAnimatedImage.h

  frameInterval

The number of frames to play per second * display refresh rate (defined as 60 which appears to be true on iOS). You probably want to set this value on a displayLink.

@property (nonatomic, readonly) NSUInteger frameInterval

Discussion

Warning: Access to this property before status == PINAnimatedImageStatusInfoProcessed is undefined.

Declared In

PINAnimatedImage.h

  loopCount

The number of times to loop the animated image. Returns 0 if looping should occur infinitely.

@property (nonatomic, readonly) size_t loopCount

Discussion

Warning: Access to this property before status == PINAnimatedImageStatusInfoProcessed is undefined.

Declared In

PINAnimatedImage.h

  frameCount

The total number of frames in the animated image.

@property (nonatomic, readonly) size_t frameCount

Discussion

Warning: Access to this property before status == PINAnimatedImageStatusInfoProcessed is undefined.

Declared In

PINAnimatedImage.h

– imageAtIndex:

The image at the frame index passed in.

- (CGImageRef)imageAtIndex:(NSUInteger)index

Parameters

index

The index of the frame to retrieve.

Discussion

Warning: Access to this property before status == PINAnimatedImageStatusInfoProcessed is undefined.

Declared In

PINAnimatedImage.h

– durationAtIndex:

The duration of the frame of the passed in index.

- (CFTimeInterval)durationAtIndex:(NSUInteger)index

Parameters

index

The index of the frame to retrieve the duration it should be shown for.

Discussion

Warning: Access to this property before status == PINAnimatedImageStatusInfoProcessed is undefined.

Declared In

PINAnimatedImage.h

– clearAnimatedImageCache

Clears out the strong references to any memory maps that are being held.

- (void)clearAnimatedImageCache

Declared In

PINAnimatedImage.h