分解gif圖片中的每一幀進行處理
阿新 • • 發佈:2019-02-13
NSString *path = [[NSBundle mainBundle] pathForResource:@"a" ofType:@"gif"];
// NSURL *url = [NSURL URLWithString:path];
NSLog(@"======%@",path);
NSURL *fileUrl = [NSURL fileURLWithPath:path];
CGImageSourceRef gifSource = CGImageSourceCreateWithURL((CFURLRef)fileUrl, NULL);
size_t frameCout = CGImageSourceGetCount(gifSource);
NSMutableArray *sizeArray = [NSMutableArray arrayWithCapacity:0];
for (size_t i=0; i<frameCout; i++) {
CGImageRef imageRef = CGImageSourceCreateImageAtIndex(gifSource, i, NULL); //從GIF圖片中取出源圖片
UIImage *imageName = [UIImage imageWithCGImage:imageRef];
[sizeArray addObject:imageName];
CGImageRelease(imageRef);
}
// NSURL *url = [NSURL URLWithString:path];
NSLog(@"======%@",path);
NSURL *fileUrl = [NSURL fileURLWithPath:path];
CGImageSourceRef gifSource = CGImageSourceCreateWithURL((CFURLRef)fileUrl, NULL);
size_t frameCout = CGImageSourceGetCount(gifSource);
NSMutableArray *sizeArray = [NSMutableArray arrayWithCapacity:0];
for (size_t i=0; i<frameCout; i++) {
CGImageRef imageRef = CGImageSourceCreateImageAtIndex(gifSource, i, NULL); //從GIF圖片中取出源圖片
UIImage *imageName = [UIImage imageWithCGImage:imageRef];
[sizeArray addObject:imageName];
CGImageRelease(imageRef);
}