Merge pull request #2071 from dreampiggy/macOS_isGIF_implementation

Implements -[NSImage isGIF] method to return whether current NSImage is GIF representation.
This commit is contained in:
Bogdan Poplauschi 2017-10-21 19:02:30 +03:00 committed by GitHub
commit 66289772b5
1 changed files with 12 additions and 1 deletions

View File

@ -23,7 +23,18 @@
}
- (BOOL)isGIF {
return NO;
BOOL isGIF = NO;
for (NSImageRep *rep in self.representations) {
if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)rep;
NSUInteger frameCount = [[bitmapRep valueForProperty:NSImageFrameCount] unsignedIntegerValue];
if (frameCount > 1) {
isGIF = YES;
break;
}
}
}
return isGIF;
}
@end