Skip to content

Commit

Permalink
Merge pull request ibireme#27 from storix/incorrect-gif-loopcount-bug
Browse files Browse the repository at this point in the history
Get gif image loop count error
  • Loading branch information
ibireme committed Apr 21, 2016
2 parents 79e4918 + a8e5fc4 commit f42422b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions YYImage/YYImageCoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -1973,16 +1973,19 @@ - (void)_updateSourceImageIO {
if (_type == YYImageTypePNG) { // use custom apng decoder and ignore multi-frame
_frameCount = 1;
}
if (_type == YYImageTypeGIF) { // get gif loop count
CFDictionaryRef properties = CGImageSourceCopyProperties(_source, NULL);
if (properties) {
CFTypeRef loop = CFDictionaryGetValue(properties, kCGImagePropertyGIFLoopCount);
if (loop) CFNumberGetValue(loop, kCFNumberNSIntegerType, &_loopCount);
CFRelease(properties);
}
if (_type == YYImageTypeGIF) { // get gif loop count
CFDictionaryRef properties = CGImageSourceCopyProperties(_source, NULL);
if (properties) {
CFDictionaryRef gif = CFDictionaryGetValue(properties, kCGImagePropertyGIFDictionary);
if (gif) {
CFTypeRef loop = CFDictionaryGetValue(gif, kCGImagePropertyGIFLoopCount);
if (loop) CFNumberGetValue(loop, kCFNumberNSIntegerType, &_loopCount);
}
CFRelease(properties);
}
}
}

/*
ICO, GIF, APNG may contains multi-frame.
*/
Expand Down

0 comments on commit f42422b

Please sign in to comment.