Implements -[NSImage isGIF] method to return whether current NSImage is GIF representation.

This commit is contained in:
DreamPiggy 2017-10-21 23:31:31 +08:00
parent 04855c945e
commit 30fd6cc6ab
1 changed files with 12 additions and 1 deletions

View File

@ -23,7 +23,18 @@
} }
- (BOOL)isGIF { - (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 @end