Authored by Bogdan Poplauschi
Committed by GitHub

Merge pull request #2071 from dreampiggy/macOS_isGIF_implementation

Implements -[NSImage isGIF] method to return whether current NSImage is GIF representation.
@@ -23,7 +23,18 @@ @@ -23,7 +23,18 @@
23 } 23 }
24 24
25 - (BOOL)isGIF { 25 - (BOOL)isGIF {
26 - return NO; 26 + BOOL isGIF = NO;
  27 + for (NSImageRep *rep in self.representations) {
  28 + if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
  29 + NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)rep;
  30 + NSUInteger frameCount = [[bitmapRep valueForProperty:NSImageFrameCount] unsignedIntegerValue];
  31 + if (frameCount > 1) {
  32 + isGIF = YES;
  33 + break;
  34 + }
  35 + }
  36 + }
  37 + return isGIF;
27 } 38 }
28 39
29 @end 40 @end