Gif图片的解析
来源:互联网 发布:c语言好考么 编辑:程序博客网 时间:2024/05/16 01:32
- //加载gif
- 02
- 03 NSString *filePath = [[NSBundle mainBundle]pathForResource:@"bai3" ofType:@"gif"];
- 04
- 05 NSData *data = [NSData dataWithContentsOfFile:filePath];
- 06
- 07 CGImageSourceRef gif = CGImageSourceCreateWithData((CFDataRef)data, nil);
- 08
- 09 //获取gif的各种属性
- 10
- 11 CFDictionaryRef gifprops =(CGImageSourceCopyPropertiesAtIndex(gif,0,NULL));
- 12
- 13 NSLog(@"_______%@",gifprops);
- 14
- 15
- 16 NSInteger count =CGImageSourceGetCount(gif);
- 17
- 18 NSLog(@"________%d",count);
- 19
- 20
- 21 CFDictionaryRef gifDic = CFDictionaryGetValue(gifprops, kCGImagePropertyGIFDictionary);
- 22
- 23 CFDictionaryRef delay = CFDictionaryGetValue(gifDic, kCGImagePropertyGIFDelayTime);
- 24
- 25 NSLog(@"_______%@",delay);
- 26
- 27
- 28 //[gifDic objectForKey:(NSString *)kCGImagePropertyGIFDelayTime];
- 29
- 30 // NSNumber * w = CFDictionaryGetValue(gifprops, @"PixelWidth");
- 31
- 32 // NSNumber * h =CFDictionaryGetValue(gifprops, @"PixelHeight");
- 33
- 34 // float totalDuration = delay.doubleValue * count;
- 35
- 36 // float pixelWidth = w.intValue;
- 37
- 38 // float pixelHeight = h.intValue;
- 39
- 40 //将gif解析成UIImage类型对象,并加进images数组中
- 41
- 42
- 43 NSMutableArray *images = [NSMutableArray arrayWithCapacity:count];
- 44
- 45 for(int index=0;index<count;index++)
- 46
- 47 {
- 48
- 49 CGImageRef ref = CGImageSourceCreateImageAtIndex(gif, index, nil);
- 50
- 51 UIImage *img = [UIImage imageWithCGImage:ref];
- 52
- 53 [images addObject:img];
- 54
- 55 CFRelease(ref);
- 56
- 57 }
- 58
- 59 CFRelease(gifprops);
- 60
- 61 CFRelease(gif);
0 0
- Gif图片的解析
- IOS GIF图片的解析
- gif格式图片的解析
- android skia 解析gif图片
- gif 格式图片详细解析
- gif 格式图片详细解析
- gif 格式图片详细解析
- gif 格式图片详细解析
- iOS中GIF图片的解析+合成
- 探索Glide对Gif图片资源的获取、解析过程
- 探索Glide对Gif图片资源的获取、解析过程
- gif图片的制作
- gif图片的合成
- 安卓里的gif图片解决方案:Fresco+gif
- 解析gif图得到图片数组
- Android 6.0 利用Fresco解析gif图片
- GIF图片的显示问题
- 载入动态的GIF 图片
- 欢迎使用CSDN-markdown编辑器
- MySQL数据库操作及SQL语句笔记
- mmap内存映射/dev/mem到用户空间 + kernel config
- 懵逼Java
- linux mysql
- Gif图片的解析
- PAT甲级1082
- DBLP数据集python解析
- RecyclerView
- 2017 追梦 远方
- S2 优化数据库设计 第二章上级
- 安卓程序-计算器
- java基础知识脑图
- Ajax状态值及状态码