-(voID) sepatateGifAnimation:(NSImage *) gifImage{ NSArray * reps = [gifImage representations]; for (NSImageRep * rep in reps) { // find the bitmap representation if ([rep isKindOfClass:[NSBitmAPImageRep class]] == NO) continue; // get the bitmap representation NSBitmAPImageRep * bitmapRep = (NSBitmAPImageRep *)rep; // check multiframe gif int numFrame = [[bitmapRep valueForProperty:NSImageFrameCount] intValue]; if (numFrame == 0) break; for (int i = 0; i < numFrame; ++i) { // set the current frame [bitmapRep setProperty:NSImageCurrentFrame withValue:[NSNumber numberWithInt:i]]; NSData *repData = [bitmapRep representationUsingType:NSPNGfileType propertIEs:nil]; [repData writetofile:[Nsstring stringWithFormat: @"/Users/mac-d1/work/UnTitled13_%02d.png",i] atomically:NO]; // NSImage *image = [[NSImage alloc] initWithData:repData];//NSData to NSImage 转化生成NSImage进行其他的 *** 作。 } }总结
以上是内存溢出为你收集整理的[Cocoa]_[初级]_[Cocoa中对GIF动画分解成一帧帧的图片]全部内容,希望文章能够帮你解决[Cocoa]_[初级]_[Cocoa中对GIF动画分解成一帧帧的图片]所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)