Эх сурвалжийг харах

Merge pull request #27 from storix/incorrect-gif-loopcount-bug

Get gif image loop count error
Yaoyuan 9 жил өмнө
parent
commit
f42422b919
1 өөрчлөгдсөн 11 нэмэгдсэн , 8 устгасан
  1. 11 8
      YYImage/YYImageCoder.m

+ 11 - 8
YYImage/YYImageCoder.m

@@ -1973,16 +1973,19 @@ CGImageRef YYCGImageCreateWithWebPData(CFDataRef webpData,
         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.
      */