Iphone 2D 绘图 - 如何获取图片属性?
来源:互联网 发布:吉林顺通网络的骗局 编辑:程序博客网 时间:2024/05/17 04:56
如何获取图片属性,例如一个图片的高度和长度、DPI、EXIF数据等?
在Mac OS X 10.4的Mac系统和IOS4的IOS系统中都已经介绍了ImageIO框架,它提供一个功能从一个图片中获取图片属性例如大小、DPI、EXIF数据等。
获取图片属性:
1、为你的图片创建一个 CGImageSourceRef。
2、调用CGImageSourceCopyPropertiesAtIndex获得图片属性字典的拷贝
3、调用CFDictionaryGetValue中你感兴趣的属性键来获取字典内的数字,可用的键都存在 CGImageProperties Reference
以下是一个例子让你如果获取图片的宽度和高度
CFURLRef url = CFURLCreateFromFileSystemRepresentation (kCFAllocatorDefault, (const UInt8 *)inputFileName, strlen(inputFileName), false);if (!url) { printf ("* * Bad input file path\n"); }CGImageSourceRef myImageSource;myImageSource = CGImageSourceCreateWithURL(url, NULL);CFDictionaryRef imagePropertiesDictionary;imagePropertiesDictionary = CGImageSourceCopyPropertiesAtIndex(myImageSource,0, NULL);CFNumberRef imageWidth = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyPixelWidth);CFNumberRef imageHeight = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyPixelHeight);int w = 0;int h = 0;CFNumberGetValue(imageWidth, kCFNumberIntType, &w);CFNumberGetValue(imageHeight, kCFNumberIntType, &h);CFRelease(imagePropertiesDictionary);CFRelease(myImageSource);printf("Image Width: %d\n",w);printf("Image Height: %d\n",h);
- Iphone 2D 绘图 - 如何获取图片属性?
- Quartz 2D 绘图d
- 说说如何使用 canvas 进行 2D 绘图
- 2D绘图
- 2D绘图 钟表
- 2D绘图 (Qt)
- 2D绘图 (Qt)
- opengl 2D绘图
- QT--2D绘图
- 2D绘图
- Android 2D绘图
- Qt 2D绘图
- Quartz 2D绘图
- Quartz 2D 绘图
- 2D绘图
- 2D绘图
- Quartz 2d绘图
- Android 2D 绘图
- 学习札记
- 一个”flag“标记的小应用
- WPF 线段Line过长渲染出现的问题
- POJ 1080
- 使用JMeter往Mysql中插入数据,数据时成功插入了,但是JDBC请求为什么显示的是报错状态
- Iphone 2D 绘图 - 如何获取图片属性?
- 分层的一点思考
- 闭包实践(二)--函数复合
- ArrayList和Vector的区别
- 一个ie下的兼容性问题
- HashMap和Hashtable的区别
- List、Map、Set三个接口,存取元素时,各有什么特点?
- 数学求解之截取字符串
- 如何精确测量程序运行时间